Copy subreddit description raw text.

This commit is contained in:
Alex Ning 2021-08-03 12:26:55 +08:00
parent c5b32494b7
commit b34ff90bd1

View File

@ -90,6 +90,7 @@ import ml.docilealligator.infinityforreddit.asynctasks.AddSubredditOrUserToMulti
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsSubscribedToSubreddit; import ml.docilealligator.infinityforreddit.asynctasks.CheckIsSubscribedToSubreddit;
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubredditData; import ml.docilealligator.infinityforreddit.asynctasks.InsertSubredditData;
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccount; import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccount;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostTypeBottomSheetFragment;
@ -222,6 +223,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private String mAccessToken; private String mAccessToken;
private String mAccountName; private String mAccountName;
private String subredditName; private String subredditName;
private String description;
private boolean mFetchSubredditInfoSuccess = false; private boolean mFetchSubredditInfoSuccess = false;
private int mNCurrentOnlineSubscribers = 0; private int mNCurrentOnlineSubscribers = 0;
private boolean isNsfwSubreddit = false; private boolean isNsfwSubreddit = false;
@ -410,6 +412,17 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}))) })))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS)).build(); .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, mSubredditViewModel = new ViewModelProvider(this,
new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, subredditName)) new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, subredditName))
.get(SubredditViewModel.class); .get(SubredditViewModel.class);
@ -461,11 +474,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
nSubscribersTextView.setText(nSubscribers); nSubscribersTextView.setText(nSubscribers);
creationTimeTextView.setText(new SimpleDateFormat("MMM d, yyyy", creationTimeTextView.setText(new SimpleDateFormat("MMM d, yyyy",
locale).format(subredditData.getCreatedUTC())); locale).format(subredditData.getCreatedUTC()));
if (hideSubredditDescription || subredditData.getDescription().equals("")) { description = subredditData.getDescription();
if (hideSubredditDescription || description.equals("")) {
descriptionTextView.setVisibility(View.GONE); descriptionTextView.setVisibility(View.GONE);
} else { } else {
descriptionTextView.setVisibility(View.VISIBLE); descriptionTextView.setVisibility(View.VISIBLE);
markwon.setMarkdown(descriptionTextView, subredditData.getDescription()); markwon.setMarkdown(descriptionTextView, description);
} }
if (subredditData.isNSFW()) { if (subredditData.isNSFW()) {