aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-01-04 06:34:10 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-01-04 06:34:10 +0000
commiteb381eb3f4b2eb90cd3953fdca85902966228b1c (patch)
tree7ff1c1230edaa360841ce26bcf2e182758362d3b /app/src/main
parentb0d8c58a530fd0a79270fa9784e1538af1b6ac84 (diff)
downloadinfinity-for-reddit-eb381eb3f4b2eb90cd3953fdca85902966228b1c.tar
infinity-for-reddit-eb381eb3f4b2eb90cd3953fdca85902966228b1c.tar.gz
infinity-for-reddit-eb381eb3f4b2eb90cd3953fdca85902966228b1c.tar.bz2
infinity-for-reddit-eb381eb3f4b2eb90cd3953fdca85902966228b1c.tar.lz
infinity-for-reddit-eb381eb3f4b2eb90cd3953fdca85902966228b1c.tar.xz
infinity-for-reddit-eb381eb3f4b2eb90cd3953fdca85902966228b1c.tar.zst
infinity-for-reddit-eb381eb3f4b2eb90cd3953fdca85902966228b1c.zip
Long click a url link in comments to see options.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
index e42058b5..8fa48204 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
@@ -18,7 +18,6 @@ import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.SuperscriptSpan;
import android.text.util.Linkify;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -445,6 +444,16 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
})
.usePlugin(StrikethroughPlugin.create())
+ .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, activity).setOnLinkLongClickListener((textView, url) -> {
+ if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) {
+ UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
+ urlMenuBottomSheetFragment.setArguments(bundle);
+ urlMenuBottomSheetFragment.show(activity.getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag());
+ }
+ return true;
+ })))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.usePlugin(SimpleExtPlugin.create(plugin ->
plugin.addExtension(1, '^', (configuration, props) -> {
@@ -3722,9 +3731,16 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
linearLayout.setOnClickListener(hideToolbarOnClickListener);
commentTimeTextView.setOnClickListener(hideToolbarOnClickListener);
}
- View.OnLongClickListener expandsCommentsOnLongClickListener = view -> expandComments();
- commentMarkdownView.setOnLongClickListener(expandsCommentsOnLongClickListener);
- itemView.setOnLongClickListener(expandsCommentsOnLongClickListener);
+ commentMarkdownView.setOnLongClickListener(view -> {
+ if (commentMarkdownView.getSelectionStart() == -1 && commentMarkdownView.getSelectionEnd() == -1) {
+ expandComments();
+ }
+ return true;
+ });
+ itemView.setOnLongClickListener(view -> {
+ expandComments();
+ return true;
+ });
}
commentMarkdownView.setMovementMethod(LinkMovementMethod.getInstance());
commentMarkdownView.setHighlightColor(Color.TRANSPARENT);