diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-08-03 04:26:55 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-08-03 04:26:55 +0000 |
commit | b34ff90bd1aabdb4bcd2fd0d2d776a268a9f8ba4 (patch) | |
tree | 640ca0fd448385341f85ee8cef39f4f799a12ead | |
parent | c5b32494b79ce0566faccd88272482523dd5d4d3 (diff) | |
download | infinity-for-reddit-b34ff90bd1aabdb4bcd2fd0d2d776a268a9f8ba4.tar infinity-for-reddit-b34ff90bd1aabdb4bcd2fd0d2d776a268a9f8ba4.tar.gz infinity-for-reddit-b34ff90bd1aabdb4bcd2fd0d2d776a268a9f8ba4.tar.bz2 infinity-for-reddit-b34ff90bd1aabdb4bcd2fd0d2d776a268a9f8ba4.tar.lz infinity-for-reddit-b34ff90bd1aabdb4bcd2fd0d2d776a268a9f8ba4.tar.xz infinity-for-reddit-b34ff90bd1aabdb4bcd2fd0d2d776a268a9f8ba4.tar.zst infinity-for-reddit-b34ff90bd1aabdb4bcd2fd0d2d776a268a9f8ba4.zip |
Copy subreddit description raw text.
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index d1da0979..57620c51 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -90,6 +90,7 @@ import ml.docilealligator.infinityforreddit.asynctasks.AddSubredditOrUserToMulti import ml.docilealligator.infinityforreddit.asynctasks.CheckIsSubscribedToSubreddit; import ml.docilealligator.infinityforreddit.asynctasks.InsertSubredditData; import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccount; +import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostTypeBottomSheetFragment; @@ -222,6 +223,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp private String mAccessToken; private String mAccountName; private String subredditName; + private String description; private boolean mFetchSubredditInfoSuccess = false; private int mNCurrentOnlineSubscribers = 0; private boolean isNsfwSubreddit = false; @@ -410,6 +412,17 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp }))) .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS)).build(); + descriptionTextView.setOnLongClickListener(view -> { + if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) { + Bundle bundle = new Bundle(); + bundle.putString(CopyTextBottomSheetFragment.EXTRA_RAW_TEXT, description); + CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment(); + copyTextBottomSheetFragment.setArguments(bundle); + copyTextBottomSheetFragment.show(getSupportFragmentManager(), copyTextBottomSheetFragment.getTag()); + } + return true; + }); + mSubredditViewModel = new ViewModelProvider(this, new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, subredditName)) .get(SubredditViewModel.class); @@ -461,11 +474,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp nSubscribersTextView.setText(nSubscribers); creationTimeTextView.setText(new SimpleDateFormat("MMM d, yyyy", locale).format(subredditData.getCreatedUTC())); - if (hideSubredditDescription || subredditData.getDescription().equals("")) { + description = subredditData.getDescription(); + if (hideSubredditDescription || description.equals("")) { descriptionTextView.setVisibility(View.GONE); } else { descriptionTextView.setVisibility(View.VISIBLE); - markwon.setMarkdown(descriptionTextView, subredditData.getDescription()); + markwon.setMarkdown(descriptionTextView, description); } if (subredditData.isNSFW()) { |