mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-29 02:54:44 +01:00
Markdown in subreddit and user descriptions.
This commit is contained in:
parent
d046e51a95
commit
a288a638b5
@ -9,6 +9,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
@ -64,6 +65,13 @@ import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.MarkwonPlugin;
|
||||
import io.noties.markwon.core.MarkwonTheme;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.inlineparser.BangInlineProcessor;
|
||||
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
||||
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||
@ -99,6 +107,10 @@ import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
||||
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
|
||||
import ml.docilealligator.infinityforreddit.fragments.SidebarFragment;
|
||||
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
|
||||
import ml.docilealligator.infinityforreddit.markdown.RedditHeadingPlugin;
|
||||
import ml.docilealligator.infinityforreddit.markdown.SpoilerAwareMovementMethod;
|
||||
import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin;
|
||||
import ml.docilealligator.infinityforreddit.markdown.SuperscriptPlugin;
|
||||
import ml.docilealligator.infinityforreddit.message.ReadMessage;
|
||||
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
|
||||
import ml.docilealligator.infinityforreddit.post.Post;
|
||||
@ -387,8 +399,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
urlMenuBottomSheetFragment.show(getSupportFragmentManager(), null);
|
||||
return true;
|
||||
};
|
||||
Markwon markwon = MarkdownUtils.createLinksOnlyMarkwon(this,
|
||||
miscPlugin, onLinkLongClickListener);
|
||||
|
||||
Markwon markwon = MarkdownUtils.createDescriptionMarkwon(this, miscPlugin, onLinkLongClickListener);
|
||||
|
||||
descriptionTextView.setOnLongClickListener(view -> {
|
||||
if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
|
||||
|
@ -389,8 +389,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
urlMenuBottomSheetFragment.show(getSupportFragmentManager(), null);
|
||||
return true;
|
||||
};
|
||||
Markwon markwon = MarkdownUtils.createLinksOnlyMarkwon(this,
|
||||
miscPlugin, onLinkLongClickListener);
|
||||
Markwon markwon = MarkdownUtils.createDescriptionMarkwon(this, miscPlugin, onLinkLongClickListener);
|
||||
|
||||
descriptionTextView.setOnLongClickListener(view -> {
|
||||
if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
|
||||
|
@ -51,6 +51,25 @@ public class MarkdownUtils {
|
||||
.build();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Markwon createDescriptionMarkwon(Context context, MarkwonPlugin miscPlugin,
|
||||
BetterLinkMovementMethod.OnLinkLongClickListener onLinkLongClickListener) {
|
||||
return Markwon.builder(context)
|
||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||
plugin.excludeInlineProcessor(BangInlineProcessor.class);
|
||||
}))
|
||||
.usePlugin(miscPlugin)
|
||||
.usePlugin(SuperscriptPlugin.create())
|
||||
.usePlugin(RedditHeadingPlugin.create())
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()
|
||||
.setOnLinkLongClickListener(onLinkLongClickListener)))
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(TableEntryPlugin.create(context))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Markwon instance that processes only the links.
|
||||
* @return configured Markwon instance
|
||||
|
Loading…
x
Reference in New Issue
Block a user