Skip to content

Commit

Permalink
Resolve #32
Browse files Browse the repository at this point in the history
Add message for if reply is empty
Default new captcha to off
Change dupe calc to be a tad better
  • Loading branch information
Adamantcheese committed Jun 5, 2019
1 parent 3884cd6 commit 2bde753
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public void onMoreClicked() {
if (board.spoilers) {
callback.openCommentSpoilerButton(moreOpen);
}
if (board.site.name().equals("4chan") && board.code.equals("g")) {
callback.openCommentCodeButton(moreOpen);
}
if (previewOpen) {
callback.openFileName(moreOpen);
if (board.spoilers) {
Expand Down Expand Up @@ -201,6 +204,10 @@ public void onAttachClicked() {
public void onSubmitClicked() {
callback.loadViewsIntoDraft(draft);

if (draft.comment.trim().isEmpty()) {
callback.openMessage(true, false, getAppContext().getString(R.string.reply_comment_empty), true);
}

draft.loadable = loadable;
draft.spoilerImage = draft.spoilerImage && board.spoilers;
draft.captchaResponse = null;
Expand Down Expand Up @@ -349,6 +356,10 @@ public void commentSpoilerClicked() {
commentInsert("[spoiler]", "[/spoiler]");
}

public void commentCodeClicked() {
commentInsert("[code]", "[/code]");
}

public void quote(Post post, boolean withText) {
handleQuote(post, withText ? post.comment.toString() : null);
}
Expand Down Expand Up @@ -433,6 +444,7 @@ private void closeAll() {
callback.openSubject(false);
callback.openCommentQuoteButton(false);
callback.openCommentSpoilerButton(false);
callback.openCommentCodeButton(false);
callback.openNameOptions(false);
callback.openFileName(false);
callback.openSpoiler(false, false);
Expand Down Expand Up @@ -561,6 +573,8 @@ void initializeAuthentication(Site site,

void openCommentSpoilerButton(boolean open);

void openCommentCodeButton(boolean open);

void openFileName(boolean open);

void setFileName(String fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void startDownloadTask(Context context, final ImageSaveTask task) {
String fileName = filterName(name + "." + postImage.extension);
File saveFile = new File(getSaveLocation(task), fileName);
while (saveFile.exists()) {
fileName = filterName(name + "_" + Long.toHexString(SystemClock.elapsedRealtimeNanos()) + "." + postImage.extension);
fileName = filterName(name + "_" + Long.toString(SystemClock.elapsedRealtimeNanos(), Character.MAX_RADIX) + "." + postImage.extension);
saveFile = new File(getSaveLocation(task), fileName);
}
task.setDestination(saveFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public Long getTimeoutValue() {

reencodeHintShown = new BooleanSetting(p, "preference_reencode_hint_already_shown", false);

useNewCaptchaWindow = new BooleanSetting(p, "use_new_captcha_window", true);
useNewCaptchaWindow = new BooleanSetting(p, "use_new_captcha_window", false);
useRealGoogleCookies = new BooleanSetting(p, "use_real_google_cookies", false);
googleCookie = new StringSetting(p, "google_cookie", "");
lastGoogleCookieUpdateTime = new LongSetting(p, "last_google_cookie_update_time", 0L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class ReplyLayout extends LoadView implements View.OnClickListener, Reply
private LinearLayout nameOptions;
private Button commentQuoteButton;
private Button commentSpoilerButton;
private Button commentCodeButton;
private SelectionListeningEditText comment;
private TextView commentCounter;
private CheckBox spoiler;
Expand Down Expand Up @@ -150,6 +151,7 @@ protected void onFinishInflate() {
ViewGroup commentButtons = replyInputLayout.findViewById(R.id.comment_buttons);
commentQuoteButton = replyInputLayout.findViewById(R.id.comment_quote);
commentSpoilerButton = replyInputLayout.findViewById(R.id.comment_spoiler);
commentCodeButton = replyInputLayout.findViewById(R.id.comment_code);
comment = replyInputLayout.findViewById(R.id.comment);
commentCounter = replyInputLayout.findViewById(R.id.comment_counter);
spoiler = replyInputLayout.findViewById(R.id.spoiler);
Expand All @@ -166,6 +168,7 @@ protected void onFinishInflate() {
// Setup reply layout views
commentQuoteButton.setOnClickListener(this);
commentSpoilerButton.setOnClickListener(this);
commentCodeButton.setOnClickListener(this);

comment.addTextChangedListener(this);
comment.setSelectionChangedListener(this);
Expand Down Expand Up @@ -254,6 +257,8 @@ public void onClick(View v) {
presenter.commentQuoteClicked();
} else if (v == commentSpoilerButton) {
presenter.commentSpoilerClicked();
} else if (v == commentCodeButton) {
presenter.commentCodeClicked();
}
}

Expand Down Expand Up @@ -475,6 +480,11 @@ public void openCommentSpoilerButton(boolean open) {
commentSpoilerButton.setVisibility(open ? View.VISIBLE : View.GONE);
}

@Override
public void openCommentCodeButton(boolean open) {
commentCodeButton.setVisibility(open ? View.VISIBLE : View.GONE);
}

@Override
public void openFileName(boolean open) {
fileName.setVisibility(open ? View.VISIBLE : View.GONE);
Expand Down
12 changes: 12 additions & 0 deletions Kuroba/app/src/main/res/layout/layout_reply_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:textSize="15dp"
android:visibility="gone" />

<Button
android:id="@+id/comment_code"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="0dp"
android:padding="0dp"
android:text="@string/reply_comment_button_code"
android:textAllCaps="false"
android:textSize="15dp"
android:visibility="gone" />

</LinearLayout>

<CheckBox
Expand Down
2 changes: 2 additions & 0 deletions Kuroba/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ If the pattern matches then the post can be hidden or highlighted.<br>
<string name="reply_captcha_text">Type the text</string>
<string name="reply_comment_button_quote" translatable="false">&gt;</string>
<string name="reply_comment_button_spoiler">[s]</string>
<string name="reply_comment_button_code">[c]</string>

<string name="delete_confirm">Delete your post?</string>
<string name="delete_wait">Deleting post&#8230;</string>
Expand Down Expand Up @@ -653,4 +654,5 @@ Don't have a 4chan Pass?<br>
<string name="delete_site_dialog_title">Delete site?</string>
<string name="delete_site_dialog_message">Are you sure you want to delete "%1$s"? This action will delete the site and everything that is associated with it. The app will be restarted. Do you wish to proceed?</string>
<string name="could_not_remove_site_error_message">"Could not remove site %1$s, error message: %2$s</string>
<string name="reply_comment_empty">Comment body is empty.</string>
</resources>

0 comments on commit 2bde753

Please sign in to comment.