mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Superscript is now available.
This commit is contained in:
parent
c7df7399f9
commit
47b57fd50f
@ -69,6 +69,7 @@ dependencies {
|
||||
implementation 'io.noties.markwon:core:4.1.2'
|
||||
implementation 'io.noties.markwon:linkify:4.1.2'
|
||||
implementation 'io.noties.markwon:ext-strikethrough:4.1.2'
|
||||
implementation "io.noties.markwon:simple-ext:4.1.2"
|
||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
|
||||
implementation 'com.github.Ferfalk:SimpleSearchView:0.1.3'
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.style.SuperscriptSpan;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -32,6 +33,7 @@ import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.CommentData;
|
||||
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
||||
@ -116,6 +118,12 @@ public class CommentActivity extends BaseActivity {
|
||||
}
|
||||
})
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
||||
return new SuperscriptSpan();
|
||||
})
|
||||
)
|
||||
)
|
||||
.build();
|
||||
markwon.setMarkdown(commentParentMarkwonView, intent.getStringExtra(EXTRA_COMMENT_PARENT_TEXT_KEY));
|
||||
parentFullname = intent.getStringExtra(EXTRA_PARENT_FULLNAME_KEY);
|
||||
|
@ -32,6 +32,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -132,7 +133,7 @@ public class EditCommentActivity extends BaseActivity {
|
||||
Toast.makeText(EditCommentActivity.this, R.string.edit_success, Toast.LENGTH_SHORT).show();
|
||||
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra(EXTRA_EDITED_COMMENT_CONTENT, content);
|
||||
returnIntent.putExtra(EXTRA_EDITED_COMMENT_CONTENT, Utils.modifyMarkdown(content));
|
||||
returnIntent.putExtra(EXTRA_EDITED_COMMENT_POSITION, getIntent().getExtras().getInt(EXTRA_POSITION));
|
||||
setResult(RESULT_OK, returnIntent);
|
||||
|
||||
|
@ -235,7 +235,7 @@ public class RulesActivity extends BaseActivity {
|
||||
String shortName = rulesArray.getJSONObject(i).getString(JSONUtils.SHORT_NAME_KEY);
|
||||
String description = null;
|
||||
if (rulesArray.getJSONObject(i).has(JSONUtils.DESCRIPTION_KEY)) {
|
||||
description = Utils.addSubredditAndUserLink(rulesArray.getJSONObject(i).getString(JSONUtils.DESCRIPTION_KEY));
|
||||
description = Utils.modifyMarkdown(rulesArray.getJSONObject(i).getString(JSONUtils.DESCRIPTION_KEY));
|
||||
}
|
||||
rules.add(new Rule(shortName, description));
|
||||
}
|
||||
|
@ -8,11 +8,10 @@ import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.style.SuperscriptSpan;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.TypedValue;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
@ -50,6 +49,7 @@ import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||
import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute;
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
@ -146,6 +146,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
})
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
||||
return new SuperscriptSpan();
|
||||
})
|
||||
)
|
||||
)
|
||||
.build();
|
||||
mAccessToken = accessToken;
|
||||
mAccountName = accountName;
|
||||
|
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.style.SuperscriptSpan;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -31,6 +32,7 @@ import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
||||
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
||||
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
||||
@ -97,6 +99,12 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
})
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
||||
return new SuperscriptSpan();
|
||||
})
|
||||
)
|
||||
)
|
||||
.build();
|
||||
mAccessToken = accessToken;
|
||||
mAccountName = accountName;
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.text.style.SuperscriptSpan;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
@ -24,6 +25,7 @@ import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
||||
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
||||
import ml.docilealligator.infinityforreddit.Message;
|
||||
@ -80,6 +82,12 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
||||
})
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
||||
return new SuperscriptSpan();
|
||||
})
|
||||
)
|
||||
)
|
||||
.build();
|
||||
mAccessToken = accessToken;
|
||||
mResources = context.getResources();
|
||||
|
@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit.Adapter;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.style.SuperscriptSpan;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -21,6 +22,7 @@ import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.Rule;
|
||||
@ -48,6 +50,12 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
||||
})
|
||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||
.usePlugin(StrikethroughPlugin.create())
|
||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
||||
return new SuperscriptSpan();
|
||||
})
|
||||
)
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class FetchMessages {
|
||||
String author = rawMessageJSON.getString(JSONUtils.AUTHOR_KEY);
|
||||
String parentFullname = rawMessageJSON.getString(JSONUtils.PARENT_ID_KEY);
|
||||
String title = rawMessageJSON.has(JSONUtils.LINK_TITLE_KEY) ? rawMessageJSON.getString(JSONUtils.LINK_TITLE_KEY) : null;
|
||||
String body = Utils.addSubredditAndUserLink(rawMessageJSON.getString(JSONUtils.BODY_KEY));
|
||||
String body = Utils.modifyMarkdown(rawMessageJSON.getString(JSONUtils.BODY_KEY));
|
||||
String context = rawMessageJSON.getString(JSONUtils.CONTEXT_KEY);
|
||||
String distinguished = rawMessageJSON.getString(JSONUtils.DISTINGUISHED_KEY);
|
||||
boolean wasComment = rawMessageJSON.getBoolean(JSONUtils.WAS_COMMENT_KEY);
|
||||
|
@ -129,7 +129,7 @@ public class ParseComment {
|
||||
String distinguished = singleCommentData.getString(JSONUtils.DISTINGUISHED_KEY);
|
||||
String commentContent = "";
|
||||
if (!singleCommentData.isNull(JSONUtils.BODY_KEY)) {
|
||||
commentContent = Utils.addSubredditAndUserLink(singleCommentData.getString(JSONUtils.BODY_KEY).trim());
|
||||
commentContent = Utils.modifyMarkdown(singleCommentData.getString(JSONUtils.BODY_KEY).trim());
|
||||
}
|
||||
String permalink = Html.fromHtml(singleCommentData.getString(JSONUtils.PERMALINK_KEY)).toString();
|
||||
int score = singleCommentData.getInt(JSONUtils.SCORE_KEY);
|
||||
|
@ -126,7 +126,7 @@ public class ParsePost {
|
||||
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
|
||||
post.setSelfText("");
|
||||
} else {
|
||||
post.setSelfText(Utils.addSubredditAndUserLink(data.getString(JSONUtils.SELFTEXT_KEY).trim()));
|
||||
post.setSelfText(Utils.modifyMarkdown(data.getString(JSONUtils.SELFTEXT_KEY).trim()));
|
||||
if (data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
|
||||
post.setSelfTextPlainTrimmed("");
|
||||
} else {
|
||||
@ -147,7 +147,7 @@ public class ParsePost {
|
||||
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
|
||||
post.setSelfText("");
|
||||
} else {
|
||||
post.setSelfText(Utils.addSubredditAndUserLink(data.getString(JSONUtils.SELFTEXT_KEY).trim()));
|
||||
post.setSelfText(Utils.modifyMarkdown(data.getString(JSONUtils.SELFTEXT_KEY).trim()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -222,7 +222,7 @@ public class ParsePost {
|
||||
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
|
||||
post.setSelfText("");
|
||||
} else {
|
||||
post.setSelfText(Utils.addSubredditAndUserLink(data.getString(JSONUtils.SELFTEXT_KEY).trim()));
|
||||
post.setSelfText(Utils.modifyMarkdown(data.getString(JSONUtils.SELFTEXT_KEY).trim()));
|
||||
if (data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
|
||||
post.setSelfTextPlainTrimmed("");
|
||||
} else {
|
||||
@ -245,7 +245,7 @@ public class ParsePost {
|
||||
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
|
||||
post.setSelfText("");
|
||||
} else {
|
||||
post.setSelfText(Utils.addSubredditAndUserLink(data.getString(JSONUtils.SELFTEXT_KEY).trim()));
|
||||
post.setSelfText(Utils.modifyMarkdown(data.getString(JSONUtils.SELFTEXT_KEY).trim()));
|
||||
}
|
||||
|
||||
post.setPreviewWidth(previewWidth);
|
||||
|
@ -12,8 +12,9 @@ public class Utils {
|
||||
private static final long MONTH_MILLIS = 30 * DAY_MILLIS;
|
||||
private static final long YEAR_MILLIS = 12 * MONTH_MILLIS;
|
||||
|
||||
public static String addSubredditAndUserLink(String markdown) {
|
||||
return markdown.replaceAll("((?<=[\\s])|^)/{0,1}[rRuU]/\\w+/{0,1}", "[$0]($0)");
|
||||
public static String modifyMarkdown(String markdown) {
|
||||
return markdown.replaceAll("((?<=[\\s])|^)/{0,1}[rRuU]/\\w+/{0,1}", "[$0]($0)")
|
||||
.replaceAll("\\^\\w+", "$0^");
|
||||
}
|
||||
|
||||
public static CharSequence trimTrailingWhitespace(CharSequence source) {
|
||||
|
Loading…
Reference in New Issue
Block a user