mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Copy markdown in sidebar.
This commit is contained in:
parent
9564515d21
commit
c5b32494b7
@ -53,23 +53,26 @@ public class CopyTextBottomSheetFragment extends RoundedBottomSheetDialogFragmen
|
||||
View rootView = inflater.inflate(R.layout.fragment_copy_text_bottom_sheet, container, false);
|
||||
ButterKnife.bind(this, rootView);
|
||||
|
||||
String rawText = getArguments().getString(EXTRA_RAW_TEXT);
|
||||
markdownText = getArguments().getString(EXTRA_MARKDOWN);
|
||||
if (markdownText != null) {
|
||||
markdownText = markdownText.replaceAll("<sup>", "^").replaceAll("</sup>", "");
|
||||
String rawText = getArguments().getString(EXTRA_RAW_TEXT, null);
|
||||
markdownText = getArguments().getString(EXTRA_MARKDOWN, null);
|
||||
|
||||
if (rawText != null) {
|
||||
copyRawTextTextView.setOnClickListener(view -> {
|
||||
showCopyDialog(rawText);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
copyAllRawTextTextView.setOnClickListener(view -> {
|
||||
copyText(rawText);
|
||||
dismiss();
|
||||
});
|
||||
} else {
|
||||
copyRawTextTextView.setVisibility(View.GONE);
|
||||
copyAllRawTextTextView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
copyRawTextTextView.setOnClickListener(view -> {
|
||||
showCopyDialog(rawText);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
copyAllRawTextTextView.setOnClickListener(view -> {
|
||||
copyText(rawText);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
if (markdownText != null) {
|
||||
markdownText = markdownText.replaceAll("<sup>", "^").replaceAll("</sup>", "");
|
||||
copyMarkdownTextView.setOnClickListener(view -> {
|
||||
showCopyDialog(markdownText);
|
||||
dismiss();
|
||||
|
@ -48,6 +48,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
||||
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
|
||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubredditData;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CopyTextBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.subreddit.FetchSubredditData;
|
||||
@ -76,6 +77,7 @@ public class SidebarFragment extends Fragment {
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private String sidebarDescription;
|
||||
|
||||
public SidebarFragment() {
|
||||
// Required empty public constructor
|
||||
@ -107,6 +109,16 @@ public class SidebarFragment extends Fragment {
|
||||
@Override
|
||||
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
|
||||
textView.setTextColor(markdownColor);
|
||||
textView.setOnLongClickListener(view -> {
|
||||
if (sidebarDescription != null && !sidebarDescription.equals("") && textView.getSelectionStart() == -1 && textView.getSelectionEnd() == -1) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(CopyTextBottomSheetFragment.EXTRA_MARKDOWN, sidebarDescription);
|
||||
CopyTextBottomSheetFragment copyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
|
||||
copyTextBottomSheetFragment.setArguments(bundle);
|
||||
copyTextBottomSheetFragment.show(getChildFragmentManager(), copyTextBottomSheetFragment.getTag());
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,8 +174,9 @@ public class SidebarFragment extends Fragment {
|
||||
.get(SubredditViewModel.class);
|
||||
mSubredditViewModel.getSubredditLiveData().observe(getViewLifecycleOwner(), subredditData -> {
|
||||
if (subredditData != null) {
|
||||
if (subredditData.getSidebarDescription() != null && !subredditData.getSidebarDescription().equals("")) {
|
||||
markwonAdapter.setMarkdown(markwon, subredditData.getSidebarDescription());
|
||||
sidebarDescription = subredditData.getSidebarDescription();
|
||||
if (sidebarDescription != null && !sidebarDescription.equals("")) {
|
||||
markwonAdapter.setMarkdown(markwon, sidebarDescription);
|
||||
markwonAdapter.notifyDataSetChanged();
|
||||
}
|
||||
} else {
|
||||
|
@ -395,7 +395,6 @@ public class ViewRPANBroadcastFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onMessage(@NonNull WebSocket webSocket, @NonNull String text) {
|
||||
Log.i("asfasdf", "s " + text);
|
||||
messageReceivedListener.onMessage(text);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user