From d5c0b7f9d4402371b8298fe8a3f0182e78d39f9e Mon Sep 17 00:00:00 2001 From: Floens Date: Sun, 14 Jun 2015 22:22:58 +0200 Subject: [PATCH] Allow the No.123 to be clicked to open the reply screen --- .../chan/core/presenter/ThreadPresenter.java | 5 ++++ .../org/floens/chan/ui/cell/PostCell.java | 24 ++++++++++++++++--- .../chan/ui/cell/PostCellInterface.java | 2 ++ .../controller/ThemeSettingsController.java | 4 ++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java b/Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java index ab14adf2..93674bda 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java +++ b/Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java @@ -382,6 +382,11 @@ public class ThreadPresenter implements ChanLoader.ChanLoaderCallback, PostAdapt } } + @Override + public void onPostNoClicked(Post post) { + threadPresenterCallback.quote(post, false); + } + @Override public void onShowPostReplies(Post post) { diff --git a/Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java b/Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java index cb54a07e..e8c9b1d3 100644 --- a/Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java +++ b/Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java @@ -27,6 +27,7 @@ import android.text.Layout; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; +import android.text.TextPaint; import android.text.TextUtils; import android.text.format.DateUtils; import android.text.method.LinkMovementMethod; @@ -299,9 +300,11 @@ public class PostCell extends RelativeLayout implements PostCellInterface, PostL titleParts[titlePartsCount++] = post.nameTripcodeIdCapcodeSpan; CharSequence relativeTime = DateUtils.getRelativeTimeSpanString(post.time * 1000L, Time.get(), DateUtils.SECOND_IN_MILLIS, 0); - SpannableString date = new SpannableString("No." + post.no + " " + relativeTime); + String noText = "No." + post.no; + SpannableString date = new SpannableString(noText + " " + relativeTime); date.setSpan(new ForegroundColorSpan(theme.detailsColor), 0, date.length(), 0); date.setSpan(new AbsoluteSizeSpan(detailsSizePx), 0, date.length(), 0); + date.setSpan(new NoClickableSpan(), 0, noText.length(), 0); titleParts[titlePartsCount] = date; @@ -351,12 +354,15 @@ public class PostCell extends RelativeLayout implements PostCellInterface, PostL if (commentClickable != threadMode) { commentClickable = threadMode; if (commentClickable) { - comment.setMovementMethod(new PostViewMovementMethod()); + PostViewMovementMethod movementMethod = new PostViewMovementMethod(); + comment.setMovementMethod(movementMethod); comment.setOnClickListener(selfClicked); + title.setMovementMethod(movementMethod); } else { comment.setOnClickListener(null); comment.setClickable(false); comment.setMovementMethod(null); + title.setMovementMethod(null); } } @@ -478,7 +484,7 @@ public class PostCell extends RelativeLayout implements PostCellInterface, PostL ignoreNextOnClick = true; link[0].onClick(widget); buffer.removeSpan(BACKGROUND_SPAN); - } else if (action == MotionEvent.ACTION_DOWN) { + } else if (action == MotionEvent.ACTION_DOWN && link[0] instanceof PostLinkable) { buffer.setSpan(BACKGROUND_SPAN, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0]), 0); } else if (action == MotionEvent.ACTION_CANCEL) { buffer.removeSpan(BACKGROUND_SPAN); @@ -493,4 +499,16 @@ public class PostCell extends RelativeLayout implements PostCellInterface, PostL return true; } } + + private class NoClickableSpan extends ClickableSpan { + @Override + public void onClick(View widget) { + callback.onPostNoClicked(post); + } + + @Override + public void updateDrawState(TextPaint ds) { + ds.setUnderlineText(false); + } + } } diff --git a/Clover/app/src/main/java/org/floens/chan/ui/cell/PostCellInterface.java b/Clover/app/src/main/java/org/floens/chan/ui/cell/PostCellInterface.java index 0817c716..ddf6ba8f 100644 --- a/Clover/app/src/main/java/org/floens/chan/ui/cell/PostCellInterface.java +++ b/Clover/app/src/main/java/org/floens/chan/ui/cell/PostCellInterface.java @@ -52,5 +52,7 @@ public interface PostCellInterface { void onPostOptionClicked(Post post, Object id); void onPostLinkableClicked(PostLinkable linkable); + + void onPostNoClicked(Post post); } } diff --git a/Clover/app/src/main/java/org/floens/chan/ui/controller/ThemeSettingsController.java b/Clover/app/src/main/java/org/floens/chan/ui/controller/ThemeSettingsController.java index 17f95640..001fb0f7 100644 --- a/Clover/app/src/main/java/org/floens/chan/ui/controller/ThemeSettingsController.java +++ b/Clover/app/src/main/java/org/floens/chan/ui/controller/ThemeSettingsController.java @@ -103,6 +103,10 @@ public class ThemeSettingsController extends Controller implements View.OnClickL @Override public void onPostLinkableClicked(PostLinkable linkable) { } + + @Override + public void onPostNoClicked(Post post) { + } }; }