mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Try to fix superscript.
This commit is contained in:
parent
f4bfa4fc40
commit
abb37707fb
@ -138,6 +138,7 @@ dependencies {
|
|||||||
implementation "io.noties.markwon:linkify:$markwonVersion"
|
implementation "io.noties.markwon:linkify:$markwonVersion"
|
||||||
implementation "io.noties.markwon:recycler-table:$markwonVersion"
|
implementation "io.noties.markwon:recycler-table:$markwonVersion"
|
||||||
implementation "io.noties.markwon:simple-ext:$markwonVersion"
|
implementation "io.noties.markwon:simple-ext:$markwonVersion"
|
||||||
|
implementation "io.noties.markwon:html:$markwonVersion"
|
||||||
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
|
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
|
||||||
implementation 'me.saket:better-link-movement-method:2.2.0'
|
implementation 'me.saket:better-link-movement-method:2.2.0'
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.style.SuperscriptSpan;
|
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -42,11 +41,11 @@ import io.noties.markwon.Markwon;
|
|||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.html.HtmlPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
import io.noties.markwon.recycler.table.TableEntry;
|
import io.noties.markwon.recycler.table.TableEntry;
|
||||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
import ml.docilealligator.infinityforreddit.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||||
@ -136,6 +135,7 @@ public class CommentActivity extends BaseActivity {
|
|||||||
|
|
||||||
int linkColor = mCustomThemeWrapper.getLinkColor();
|
int linkColor = mCustomThemeWrapper.getLinkColor();
|
||||||
Markwon markwon = Markwon.builder(this)
|
Markwon markwon = Markwon.builder(this)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
@ -153,12 +153,6 @@ public class CommentActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
|
||||||
return new SuperscriptSpan();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.build();
|
.build();
|
||||||
if (parentTextMarkdown != null) {
|
if (parentTextMarkdown != null) {
|
||||||
commentParentMarkwonView.setOnLongClickListener(view -> {
|
commentParentMarkwonView.setOnLongClickListener(view -> {
|
||||||
@ -182,6 +176,7 @@ public class CommentActivity extends BaseActivity {
|
|||||||
contentMarkdownRecyclerView.setVisibility(View.VISIBLE);
|
contentMarkdownRecyclerView.setVisibility(View.VISIBLE);
|
||||||
contentMarkdownRecyclerView.setNestedScrollingEnabled(false);
|
contentMarkdownRecyclerView.setNestedScrollingEnabled(false);
|
||||||
Markwon postBodyMarkwon = Markwon.builder(this)
|
Markwon postBodyMarkwon = Markwon.builder(this)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
|
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
|
||||||
@ -214,12 +209,6 @@ public class CommentActivity extends BaseActivity {
|
|||||||
})
|
})
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
|
||||||
return new SuperscriptSpan();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.usePlugin(TableEntryPlugin.create(this))
|
.usePlugin(TableEntryPlugin.create(this))
|
||||||
.build();
|
.build();
|
||||||
MarkwonAdapter markwonAdapter = MarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text)
|
MarkwonAdapter markwonAdapter = MarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text)
|
||||||
|
@ -10,7 +10,6 @@ import android.text.SpannableStringBuilder;
|
|||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.text.style.SuperscriptSpan;
|
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -44,15 +43,15 @@ import io.noties.markwon.Markwon;
|
|||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.html.HtmlPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
import io.noties.markwon.recycler.table.TableEntry;
|
import io.noties.markwon.recycler.table.TableEntry;
|
||||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
|
||||||
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
|
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
|
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class FullMarkdownActivity extends BaseActivity {
|
public class FullMarkdownActivity extends BaseActivity {
|
||||||
@ -123,6 +122,7 @@ public class FullMarkdownActivity extends BaseActivity {
|
|||||||
int spoilerBackgroundColor = markdownColor | 0xFF000000;
|
int spoilerBackgroundColor = markdownColor | 0xFF000000;
|
||||||
int linkColor = mCustomThemeWrapper.getLinkColor();
|
int linkColor = mCustomThemeWrapper.getLinkColor();
|
||||||
Markwon markwon = Markwon.builder(this)
|
Markwon markwon = Markwon.builder(this)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@ -204,12 +204,6 @@ public class FullMarkdownActivity extends BaseActivity {
|
|||||||
})
|
})
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
|
||||||
return new SuperscriptSpan();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.usePlugin(TableEntryPlugin.create(this))
|
.usePlugin(TableEntryPlugin.create(this))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import android.text.SpannableStringBuilder;
|
|||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.text.style.SuperscriptSpan;
|
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -79,12 +78,12 @@ import io.noties.markwon.Markwon;
|
|||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.html.HtmlPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
import io.noties.markwon.recycler.table.TableEntry;
|
import io.noties.markwon.recycler.table.TableEntry;
|
||||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
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.BlurTransformation;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||||
@ -266,6 +265,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
int postSpoilerBackgroundColor = markdownColor | 0xFF000000;
|
int postSpoilerBackgroundColor = markdownColor | 0xFF000000;
|
||||||
int linkColor = customThemeWrapper.getLinkColor();
|
int linkColor = customThemeWrapper.getLinkColor();
|
||||||
mPostDetailMarkwon = Markwon.builder(mActivity)
|
mPostDetailMarkwon = Markwon.builder(mActivity)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@ -368,15 +368,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
return true;
|
return true;
|
||||||
})))
|
})))
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
|
||||||
return new SuperscriptSpan();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.usePlugin(TableEntryPlugin.create(mActivity))
|
.usePlugin(TableEntryPlugin.create(mActivity))
|
||||||
.build();
|
.build();
|
||||||
mCommentMarkwon = Markwon.builder(mActivity)
|
mCommentMarkwon = Markwon.builder(mActivity)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@ -462,12 +457,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
return true;
|
return true;
|
||||||
})))
|
})))
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
|
||||||
return new SuperscriptSpan();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.build();
|
.build();
|
||||||
mMarkwonAdapter = MarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text)
|
mMarkwonAdapter = MarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text)
|
||||||
.include(TableBlock.class, TableEntry.create(builder -> builder
|
.include(TableBlock.class, TableEntry.create(builder -> builder
|
||||||
|
@ -42,6 +42,7 @@ import io.noties.markwon.Markwon;
|
|||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.html.HtmlPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||||
@ -115,6 +116,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
mCommentColor = customThemeWrapper.getCommentColor();
|
mCommentColor = customThemeWrapper.getCommentColor();
|
||||||
int commentSpoilerBackgroundColor = mCommentColor | 0xFF000000;
|
int commentSpoilerBackgroundColor = mCommentColor | 0xFF000000;
|
||||||
mMarkwon = Markwon.builder(mActivity)
|
mMarkwon = Markwon.builder(mActivity)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@ -203,12 +205,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
})))
|
})))
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
|
||||||
return new SuperscriptSpan();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.build();
|
.build();
|
||||||
mLocale = locale;
|
mLocale = locale;
|
||||||
mAccessToken = accessToken;
|
mAccessToken = accessToken;
|
||||||
|
@ -10,7 +10,6 @@ import android.text.Spanned;
|
|||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.text.style.SuperscriptSpan;
|
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -35,8 +34,10 @@ import io.noties.markwon.Markwon;
|
|||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.html.HtmlPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
||||||
@ -44,8 +45,6 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
|||||||
import ml.docilealligator.infinityforreddit.message.FetchMessage;
|
import ml.docilealligator.infinityforreddit.message.FetchMessage;
|
||||||
import ml.docilealligator.infinityforreddit.message.Message;
|
import ml.docilealligator.infinityforreddit.message.Message;
|
||||||
import ml.docilealligator.infinityforreddit.message.ReadMessage;
|
import ml.docilealligator.infinityforreddit.message.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
|
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
|
||||||
@ -100,6 +99,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
||||||
|
|
||||||
mMarkwon = Markwon.builder(mContext)
|
mMarkwon = Markwon.builder(mContext)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@ -177,12 +177,6 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
})
|
})
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
|
||||||
return new SuperscriptSpan();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.build();
|
.build();
|
||||||
mAccessToken = accessToken;
|
mAccessToken = accessToken;
|
||||||
if (where.equals(FetchMessage.WHERE_MESSAGES)) {
|
if (where.equals(FetchMessage.WHERE_MESSAGES)) {
|
||||||
|
@ -4,7 +4,6 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.style.SuperscriptSpan;
|
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -28,15 +27,15 @@ import io.noties.markwon.Markwon;
|
|||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.html.HtmlPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.message.Message;
|
import ml.docilealligator.infinityforreddit.message.Message;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
|
|
||||||
@ -67,6 +66,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
mLocale = locale;
|
mLocale = locale;
|
||||||
mAccountName = accountName;
|
mAccountName = accountName;
|
||||||
mMarkwon = Markwon.builder(viewPrivateMessagesActivity)
|
mMarkwon = Markwon.builder(viewPrivateMessagesActivity)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
@ -85,12 +85,6 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
})
|
})
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
|
||||||
return new SuperscriptSpan();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.build();
|
.build();
|
||||||
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
||||||
mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE);
|
mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE);
|
||||||
|
@ -3,7 +3,6 @@ package ml.docilealligator.infinityforreddit.adapters;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.style.SuperscriptSpan;
|
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -23,9 +22,9 @@ import io.noties.markwon.Markwon;
|
|||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.html.HtmlPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
|
||||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.Rule;
|
import ml.docilealligator.infinityforreddit.Rule;
|
||||||
@ -41,6 +40,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
|||||||
|
|
||||||
public RulesRecyclerViewAdapter(AppCompatActivity activity, CustomThemeWrapper customThemeWrapper) {
|
public RulesRecyclerViewAdapter(AppCompatActivity activity, CustomThemeWrapper customThemeWrapper) {
|
||||||
markwon = Markwon.builder(activity)
|
markwon = Markwon.builder(activity)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
@ -69,12 +69,6 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
|||||||
})))
|
})))
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
|
||||||
return new SuperscriptSpan();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.build();
|
.build();
|
||||||
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||||
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||||
|
@ -7,7 +7,6 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.style.SuperscriptSpan;
|
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -36,12 +35,12 @@ import io.noties.markwon.Markwon;
|
|||||||
import io.noties.markwon.MarkwonConfiguration;
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.html.HtmlPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
import io.noties.markwon.recycler.table.TableEntry;
|
import io.noties.markwon.recycler.table.TableEntry;
|
||||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
|
||||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
@ -103,6 +102,7 @@ public class SidebarFragment extends Fragment {
|
|||||||
markdownColor = mCustomThemeWrapper.getSecondaryTextColor();
|
markdownColor = mCustomThemeWrapper.getSecondaryTextColor();
|
||||||
|
|
||||||
Markwon markwon = Markwon.builder(activity)
|
Markwon markwon = Markwon.builder(activity)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
|
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
|
||||||
@ -134,12 +134,6 @@ public class SidebarFragment extends Fragment {
|
|||||||
return true;
|
return true;
|
||||||
})))
|
})))
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
|
||||||
return new SuperscriptSpan();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.usePlugin(TableEntryPlugin.create(activity))
|
.usePlugin(TableEntryPlugin.create(activity))
|
||||||
.build();
|
.build();
|
||||||
MarkwonAdapter markwonAdapter = MarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text)
|
MarkwonAdapter markwonAdapter = MarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text)
|
||||||
|
@ -52,57 +52,42 @@ public class Utils {
|
|||||||
return fixSuperScript(regexed);
|
return fixSuperScript(regexed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String fixSuperScript(StringBuilder regexed) {
|
private static String fixSuperScript(StringBuilder regexed) {
|
||||||
int newestCaretIndex = regexed.indexOf("^");
|
boolean hasBracket = false;
|
||||||
if (newestCaretIndex >= 0) {
|
int nCarets = 0;
|
||||||
boolean hasBracket = false;
|
for (int i = 0; i < regexed.length(); i++) {
|
||||||
int caretWithLeftBracketIndex = -1;
|
char currentChar = regexed.charAt(i);
|
||||||
for (int i = newestCaretIndex + 1; i < regexed.length(); i++) {
|
if (currentChar == '^') {
|
||||||
char currentChar = regexed.charAt(i);
|
if (!(i > 0 && regexed.charAt(i - 1) == '\\')) {
|
||||||
if (currentChar == '^') {
|
if (i < regexed.length() - 1 && regexed.charAt(i + 1) == '(') {
|
||||||
if (!(i > 0 && regexed.charAt(i - 1) == '\\')) {
|
regexed.replace(i, i + 2, "<sup>");
|
||||||
if (newestCaretIndex < 0) {
|
|
||||||
newestCaretIndex = i;
|
|
||||||
} else {
|
|
||||||
regexed.insert(i, '^');
|
|
||||||
newestCaretIndex = i + 1;
|
|
||||||
i++;
|
|
||||||
if (newestCaretIndex == regexed.length() - 1) {
|
|
||||||
regexed.deleteCharAt(regexed.length() - 1);
|
|
||||||
newestCaretIndex = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (currentChar == ' ' || currentChar == '\n') {
|
|
||||||
if (newestCaretIndex >= 0) {
|
|
||||||
if (i != newestCaretIndex + 1) {
|
|
||||||
regexed.insert(i, '^');
|
|
||||||
newestCaretIndex = -1;
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
newestCaretIndex = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (currentChar == '(') {
|
|
||||||
if (newestCaretIndex >= 0 && i == newestCaretIndex + 1) {
|
|
||||||
hasBracket = true;
|
hasBracket = true;
|
||||||
newestCaretIndex = -1;
|
} else {
|
||||||
caretWithLeftBracketIndex = i - 1;
|
regexed.replace(i, i + 1, "<sup>");
|
||||||
}
|
|
||||||
} else if (currentChar == ')') {
|
|
||||||
if (hasBracket) {
|
|
||||||
hasBracket = false;
|
|
||||||
regexed.setCharAt(i, '^');
|
|
||||||
regexed.replace(caretWithLeftBracketIndex, caretWithLeftBracketIndex + 2, "^");
|
|
||||||
caretWithLeftBracketIndex = -1;
|
|
||||||
i--;
|
|
||||||
}
|
}
|
||||||
|
nCarets++;
|
||||||
}
|
}
|
||||||
|
} else if (currentChar == ')' && hasBracket) {
|
||||||
|
hasBracket = false;
|
||||||
|
regexed.replace(i, i + 1, "</sup>");
|
||||||
|
nCarets--;
|
||||||
|
} else if (currentChar == '\n') {
|
||||||
|
hasBracket = false;
|
||||||
|
for (int j = 0; j < nCarets; j++) {
|
||||||
|
regexed.insert(i, "</sup>");
|
||||||
|
i += 6;
|
||||||
|
}
|
||||||
|
nCarets = 0;
|
||||||
|
} else if (currentChar == ' ' && !hasBracket) {
|
||||||
|
for (int j = 0; j < nCarets; j++) {
|
||||||
|
regexed.insert(i, "</sup>");
|
||||||
|
i += 6;
|
||||||
|
}
|
||||||
|
nCarets = 0;
|
||||||
}
|
}
|
||||||
if (newestCaretIndex >=0 || caretWithLeftBracketIndex >= 0) {
|
}
|
||||||
regexed.insert(regexed.length(), '^');
|
for (int j = 0; j < nCarets; j++) {
|
||||||
}
|
regexed.append("</sup>");
|
||||||
}
|
}
|
||||||
|
|
||||||
return regexed.toString();
|
return regexed.toString();
|
||||||
|
Loading…
Reference in New Issue
Block a user