diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 9ae71cf7..d5246306 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser index 941f4d61..798ac03c 100644 Binary files a/.idea/caches/gradle_models.ser and b/.idea/caches/gradle_models.ser differ diff --git a/app/build.gradle b/app/build.gradle index 0f78862a..3ddc20d7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -67,10 +67,10 @@ dependencies { annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0' implementation 'com.github.santalu:aspect-ratio-imageview:1.0.6' implementation 'androidx.paging:paging-runtime:2.1.0' - implementation "com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE" - implementation "ru.noties:markwon:2.0.1" - implementation "ru.noties:markwon-syntax-highlight:2.0.1" - implementation "ru.noties:markwon-view:2.0.1" + implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE' + implementation 'io.noties.markwon:core:4.1.0' + implementation 'io.noties.markwon:linkify:4.1.0' + implementation 'io.noties.markwon:ext-strikethrough:4.1.0' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16' implementation 'com.github.Ferfalk:SimpleSearchView:0.1.3' implementation 'org.greenrobot:eventbus:3.1.1' @@ -79,6 +79,7 @@ dependencies { implementation 'com.github.livefront:bridge:v1.2.0' implementation 'com.evernote:android-state:1.4.1' annotationProcessor 'com.evernote:android-state-processor:1.4.1' - implementation "androidx.work:work-runtime:2.2.0" - implementation "androidx.preference:preference:1.1.0-rc01" + implementation 'androidx.work:work-runtime:2.2.0' + implementation 'androidx.preference:preference:1.1.0-rc01' + implementation 'org.sufficientlysecure:html-textview:3.6' } diff --git a/app/src/main/java/CustomView/CustomMarkwonView.java b/app/src/main/java/CustomView/CustomMarkwonView.java index 940b6b76..c89ff405 100644 --- a/app/src/main/java/CustomView/CustomMarkwonView.java +++ b/app/src/main/java/CustomView/CustomMarkwonView.java @@ -1,38 +1,73 @@ package CustomView; import android.content.Context; -import android.content.Intent; -import android.net.Uri; -import android.util.AttributeSet; +import android.text.Spanned; +import android.widget.TextView; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import ml.docilealligator.infinityforreddit.LinkResolverActivity; -import ru.noties.markwon.SpannableConfiguration; -import ru.noties.markwon.view.MarkwonView; +import org.commonmark.node.Node; -public class CustomMarkwonView extends MarkwonView { +import java.util.List; - public CustomMarkwonView(Context context) { - super(context); - } +import io.noties.markwon.Markwon; +import io.noties.markwon.MarkwonPlugin; - public CustomMarkwonView(Context context, AttributeSet attrs) { - super(context, attrs); - } +public class CustomMarkwonView extends Markwon { public void setMarkdown(@Nullable String markdown, Context context) { - SpannableConfiguration configuration = SpannableConfiguration.builder(context).linkResolver((view, link) -> { - Intent intent = new Intent(context, LinkResolverActivity.class); - Uri uri = Uri.parse(link); - if(uri.getScheme() == null && uri.getHost() == null) { - intent.setData(LinkResolverActivity.getRedditUriByPath(link)); - } else { - intent.setData(uri); - } - context.startActivity(intent); - }).build(); - super.setMarkdown(configuration, markdown); + } + + @NonNull + @Override + public Node parse(@NonNull String input) { + return null; + } + + @NonNull + @Override + public Spanned render(@NonNull Node node) { + return null; + } + + @NonNull + @Override + public Spanned toMarkdown(@NonNull String input) { + return null; + } + + @Override + public void setMarkdown(@NonNull TextView textView, @NonNull String markdown) { + + } + + @Override + public void setParsedMarkdown(@NonNull TextView textView, @NonNull Spanned markdown) { + + } + + @Override + public boolean hasPlugin(@NonNull Class extends MarkwonPlugin> plugin) { + return false; + } + + @Nullable + @Override + public
P getPlugin(@NonNull Class
type) { + return null; + } + + @NonNull + @Override + public
P requirePlugin(@NonNull Class
type) {
+ return null;
+ }
+
+ @NonNull
+ @Override
+ public List extends MarkwonPlugin> getPlugins() {
+ return null;
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentActivity.java
index 5b5cd0ab..17e4061c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentActivity.java
@@ -4,14 +4,17 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
+import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.text.util.Linkify;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -31,8 +34,11 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import io.noties.markwon.AbstractMarkwonPlugin;
+import io.noties.markwon.Markwon;
+import io.noties.markwon.MarkwonConfiguration;
+import io.noties.markwon.linkify.LinkifyPlugin;
import retrofit2.Retrofit;
-import ru.noties.markwon.view.MarkwonView;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
@@ -54,7 +60,7 @@ public class CommentActivity extends AppCompatActivity {
@BindView(R.id.coordinator_layout_comment_activity) CoordinatorLayout coordinatorLayout;
@BindView(R.id.toolbar_comment_activity) Toolbar toolbar;
- @BindView(R.id.comment_parent_markwon_view_comment_activity) MarkwonView commentParentMarkwonView;
+ @BindView(R.id.comment_parent_markwon_view_comment_activity) TextView commentParentMarkwonView;
@BindView(R.id.comment_edit_text_comment_activity) EditText commentEditText;
private boolean mNullAccessToken = false;
@@ -122,7 +128,25 @@ public class CommentActivity extends AppCompatActivity {
}
Intent intent = getIntent();
- commentParentMarkwonView.setMarkdown(intent.getExtras().getString(EXTRA_COMMENT_PARENT_TEXT_KEY));
+ Markwon markwon = Markwon.builder(this)
+ .usePlugin(new AbstractMarkwonPlugin() {
+ @Override
+ public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
+ builder.linkResolver((view, link) -> {
+ Intent intent = new Intent(CommentActivity.this, LinkResolverActivity.class);
+ Uri uri = Uri.parse(link);
+ if(uri.getScheme() == null && uri.getHost() == null) {
+ intent.setData(LinkResolverActivity.getRedditUriByPath(link));
+ } else {
+ intent.setData(uri);
+ }
+ startActivity(intent);
+ });
+ }
+ })
+ .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
+ .build();
+ markwon.setMarkdown(commentParentMarkwonView, intent.getExtras().getString(EXTRA_COMMENT_PARENT_TEXT_KEY));
parentFullname = intent.getExtras().getString(EXTRA_PARENT_FULLNAME_KEY);
parentDepth = intent.getExtras().getInt(EXTRA_PARENT_DEPTH_KEY);
parentPosition = intent.getExtras().getInt(EXTRA_PARENT_POSITION_KEY);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
index 996ba720..0f29b823 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java
@@ -7,6 +7,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -40,9 +41,14 @@ import java.util.ArrayList;
import java.util.Locale;
import CustomView.AspectRatioGifImageView;
-import CustomView.CustomMarkwonView;
import butterknife.BindView;
import butterknife.ButterKnife;
+import io.noties.markwon.AbstractMarkwonPlugin;
+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.urlprocessor.UrlProcessorRelativeToAbsolute;
import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import retrofit2.Retrofit;
@@ -63,6 +69,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter