mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 20:57:25 +01:00
Long click the url in post content to see options in CommentAndPostRecyclerViewAdapter without interfere with copy options.
This commit is contained in:
parent
a6f728a96b
commit
b0d8c58a53
@ -18,6 +18,7 @@ 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;
|
||||
@ -79,12 +80,19 @@ import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||
import io.noties.markwon.recycler.table.TableEntry;
|
||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||
import ml.docilealligator.infinityforreddit.VoteThing;
|
||||
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
|
||||
import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
|
||||
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
||||
@ -99,21 +107,17 @@ import ml.docilealligator.infinityforreddit.asynctasks.LoadUserDataAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CommentMoreBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.comment.Comment;
|
||||
import ml.docilealligator.infinityforreddit.comment.FetchComment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
|
||||
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
|
||||
import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks;
|
||||
import ml.docilealligator.infinityforreddit.post.Post;
|
||||
import ml.docilealligator.infinityforreddit.post.PostDataSource;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||
import ml.docilealligator.infinityforreddit.VoteThing;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
@ -317,12 +321,15 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
|
||||
textView.setTextColor(markdownColor);
|
||||
textView.setOnLongClickListener(view -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, mPost.getSelfTextPlain());
|
||||
bundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, mPost.getSelfText());
|
||||
CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
|
||||
copyTextBottomSheetFragment.setArguments(bundle);
|
||||
copyTextBottomSheetFragment.show(mActivity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
|
||||
if (textView.getSelectionStart() == -1 && textView.getSelectionEnd() == -1) {
|
||||
// do your code here this will only call if its not a hyperlink
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, mPost.getSelfTextPlain());
|
||||
bundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, mPost.getSelfText());
|
||||
CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
|
||||
copyTextBottomSheetFragment.setArguments(bundle);
|
||||
copyTextBottomSheetFragment.show(mActivity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@ -344,6 +351,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) -> {
|
||||
|
Loading…
Reference in New Issue
Block a user