aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java28
-rw-r--r--app/src/main/res/layout/adapter_default_entry.xml15
-rw-r--r--app/src/main/res/layout/adapter_table_block.xml19
-rw-r--r--app/src/main/res/layout/item_post_detail.xml10
-rw-r--r--app/src/main/res/layout/view_table_entry_cell.xml9
6 files changed, 77 insertions, 14 deletions
diff --git a/app/build.gradle b/app/build.gradle
index d52412a8..b8218769 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -66,10 +66,11 @@ dependencies {
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 '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 'io.noties.markwon:core:4.2.0'
+ implementation 'io.noties.markwon:linkify:4.2.0'
+ implementation 'io.noties.markwon:ext-strikethrough:4.2.0'
+ implementation "io.noties.markwon:simple-ext:4.2.0"
+ implementation "io.noties.markwon:recycler-table:4.2.0"
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'
@@ -82,4 +83,5 @@ dependencies {
implementation 'androidx.preference:preference:1.1.0'
implementation 'com.nex3z:flow-layout:1.3.0'
implementation 'com.r0adkll:slidableactivity:2.1.0'
+ implementation 'com.atlassian.commonmark:commonmark:0.13.1'
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index 694e0f62..74c04432 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -27,6 +27,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.content.ContextCompat;
+import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.RequestBuilder;
@@ -39,6 +40,8 @@ import com.bumptech.glide.request.target.Target;
import com.libRG.CustomTextView;
import com.santalu.aspectratioimageview.AspectRatioImageView;
+import org.commonmark.ext.gfm.tables.TableBlock;
+
import java.util.ArrayList;
import java.util.Locale;
@@ -49,6 +52,9 @@ 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.recycler.MarkwonAdapter;
+import io.noties.markwon.recycler.table.TableEntry;
+import io.noties.markwon.recycler.table.TableEntryPlugin;
import io.noties.markwon.simple.ext.SimpleExtPlugin;
import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute;
import jp.wasabeef.glide.transformations.BlurTransformation;
@@ -97,6 +103,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private RedditDataRoomDatabase mRedditDataRoomDatabase;
private RequestManager mGlide;
private Markwon mMarkwon;
+ private final MarkwonAdapter mMarkwonAdapter;
private String mAccessToken;
private String mAccountName;
private Post mPost;
@@ -152,7 +159,14 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
})
)
)
+ .usePlugin(TableEntryPlugin.create(mActivity))
+ .build();
+ mMarkwonAdapter = MarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text)
+ .include(TableBlock.class, TableEntry.create(builder -> builder
+ .tableLayout(R.layout.adapter_table_block, R.id.table_layout)
+ .textLayoutIsRoot(R.layout.view_table_entry_cell)))
.build();
+ mMarkwonAdapter.setMarkdown(mMarkwon, "");
mAccessToken = accessToken;
mAccountName = accountName;
mPost = post;
@@ -493,7 +507,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (mPost.getSelfText() != null && !mPost.getSelfText().equals("")) {
((PostDetailViewHolder) holder).mContentMarkdownView.setVisibility(View.VISIBLE);
- mMarkwon.setMarkdown(((PostDetailViewHolder) holder).mContentMarkdownView, mPost.getSelfText());
+ ((PostDetailViewHolder) holder).mContentMarkdownView.setLayoutManager(new LinearLayoutManager(mActivity));
+ ((PostDetailViewHolder) holder).mContentMarkdownView.setAdapter(mMarkwonAdapter);
+ mMarkwonAdapter.setMarkdown(mMarkwon, mPost.getSelfText());
+ mMarkwonAdapter.notifyDataSetChanged();
}
((PostDetailViewHolder) holder).mNoPreviewLinkImageView.setVisibility(View.VISIBLE);
@@ -513,7 +530,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (!mPost.getSelfText().equals("")) {
((PostDetailViewHolder) holder).mContentMarkdownView.setVisibility(View.VISIBLE);
- mMarkwon.setMarkdown(((PostDetailViewHolder) holder).mContentMarkdownView, mPost.getSelfText());
+ ((PostDetailViewHolder) holder).mContentMarkdownView.setLayoutManager(new LinearLayoutManager(mActivity));
+ ((PostDetailViewHolder) holder).mContentMarkdownView.setAdapter(mMarkwonAdapter);
+ mMarkwonAdapter.setMarkdown(mMarkwon, mPost.getSelfText());
+ mMarkwonAdapter.notifyDataSetChanged();
}
break;
}
@@ -1550,8 +1570,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
TextView mPostTimeTextView;
@BindView(R.id.title_text_view_item_post_detail)
TextView mTitleTextView;
+ /*@BindView(R.id.content_markdown_view_item_post_detail)
+ TextView mContentMarkdownView;*/
@BindView(R.id.content_markdown_view_item_post_detail)
- TextView mContentMarkdownView;
+ RecyclerView mContentMarkdownView;
@BindView(R.id.type_text_view_item_post_detail)
CustomTextView mTypeTextView;
@BindView(R.id.gilded_number_text_view_item_post_detail)
diff --git a/app/src/main/res/layout/adapter_default_entry.xml b/app/src/main/res/layout/adapter_default_entry.xml
new file mode 100644
index 00000000..e9fb8929
--- /dev/null
+++ b/app/src/main/res/layout/adapter_default_entry.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="16dip"
+ android:layout_marginRight="16dip"
+ android:lineSpacingExtra="2dip"
+ android:paddingTop="8dip"
+ android:paddingBottom="8dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="#000"
+ android:textSize="16sp"
+ tools:text="Hello" /> \ No newline at end of file
diff --git a/app/src/main/res/layout/adapter_table_block.xml b/app/src/main/res/layout/adapter_table_block.xml
new file mode 100644
index 00000000..b3b63a27
--- /dev/null
+++ b/app/src/main/res/layout/adapter_table_block.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ android:paddingLeft="16dp"
+ android:paddingTop="8dp"
+ android:paddingRight="16dp"
+ android:paddingBottom="8dp"
+ android:scrollbarStyle="outsideInset">
+
+ <TableLayout
+ android:id="@+id/table_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:stretchColumns="*" />
+
+</HorizontalScrollView> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_post_detail.xml b/app/src/main/res/layout/item_post_detail.xml
index 7a9dac19..41fa34da 100644
--- a/app/src/main/res/layout/item_post_detail.xml
+++ b/app/src/main/res/layout/item_post_detail.xml
@@ -81,15 +81,11 @@
android:textColor="@color/primaryTextColor"
android:textSize="?attr/title_font_18" />
- <TextView
+ <androidx.recyclerview.widget.RecyclerView
android:id="@+id/content_markdown_view_item_post_detail"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="16dp"
- android:paddingEnd="16dp"
- android:layout_marginTop="16dp"
- android:visibility="gone"
- android:textSize="?attr/content_font_default" />
+ android:layout_height="match_parent"
+ android:visibility="gone" />
<com.nex3z.flowlayout.FlowLayout
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/view_table_entry_cell.xml b/app/src/main/res/layout/view_table_entry_cell.xml
new file mode 100644
index 00000000..6d544918
--- /dev/null
+++ b/app/src/main/res/layout/view_table_entry_cell.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="#000"
+ android:textSize="16sp"
+ tools:text="Table content" /> \ No newline at end of file