aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-01-09 02:05:20 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-01-09 02:05:20 +0000
commitf0b149ce82cf11df1f5cf84c7d644e5e670ad0b2 (patch)
treee75272ac86da929a6b2e6c0939dc040eaa242bed
parent38be0ba01f6dd08c0be1a830e0d0389405949a56 (diff)
downloadinfinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar
infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar.gz
infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar.bz2
infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar.lz
infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar.xz
infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar.zst
infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.zip
Use MarkwonView (a markdown library) instead of HtmlTextView to display post content and comments.
-rw-r--r--.idea/caches/build_file_checksums.serbin533 -> 533 bytes
-rw-r--r--app/build.gradle4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentMultiLevelRecyclerViewAdapter.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java26
-rw-r--r--app/src/main/res/layout/activity_view_post_detail.xml7
-rw-r--r--app/src/main/res/layout/activity_view_subreddit_detail.xml18
-rw-r--r--app/src/main/res/layout/item_post_comment.xml7
-rw-r--r--app/src/main/res/values/strings.xml2
8 files changed, 31 insertions, 40 deletions
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index 3ba2f49b..20d483cc 100644
--- a/.idea/caches/build_file_checksums.ser
+++ b/.idea/caches/build_file_checksums.ser
Binary files differ
diff --git a/app/build.gradle b/app/build.gradle
index 903953de..43ead6ce 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -59,7 +59,6 @@ dependencies {
annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleVersion"
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
- implementation 'org.sufficientlysecure:html-textview:3.6'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.4.0'
implementation 'jp.wasabeef:glide-transformations:4.0.0'
@@ -72,4 +71,7 @@ dependencies {
implementation 'com.felipecsl:gifimageview:2.2.0'
implementation "android.arch.paging:runtime:1.0.1"
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"
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentMultiLevelRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentMultiLevelRecyclerViewAdapter.java
index bb95b2f6..3e3c655c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentMultiLevelRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentMultiLevelRecyclerViewAdapter.java
@@ -18,8 +18,6 @@ import com.multilevelview.MultiLevelAdapter;
import com.multilevelview.MultiLevelRecyclerView;
import com.multilevelview.models.RecyclerViewItem;
-import org.sufficientlysecure.htmltextview.HtmlTextView;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -27,6 +25,7 @@ import java.util.Locale;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Retrofit;
+import ru.noties.markwon.view.MarkwonView;
class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
private Context mContext;
@@ -67,7 +66,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
((CommentViewHolder) holder).authorTextView.setText(commentItem.getAuthor());
((CommentViewHolder) holder).commentTimeTextView.setText(commentItem.getCommentTime());
- ((CommentViewHolder) holder).commentHtmlTextView.setHtml(commentItem.getCommentContent());
+ ((CommentViewHolder) holder).commentMarkdownView.setMarkdown(commentItem.getCommentContent());
((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(commentItem.getScore()));
((CommentViewHolder) holder).verticalBlock.getLayoutParams().width = commentItem.getDepth() * 16;
@@ -260,7 +259,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
class CommentViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.author_text_view_item_post_comment) TextView authorTextView;
@BindView(R.id.comment_time_text_view_item_post_comment) TextView commentTimeTextView;
- @BindView(R.id.comment_html_text_view_item_post_comment) HtmlTextView commentHtmlTextView;
+ @BindView(R.id.comment_markdown_view_item_post_comment) MarkwonView commentMarkdownView;
@BindView(R.id.plus_button_item_post_comment) ImageView upvoteButton;
@BindView(R.id.score_text_view_item_post_comment) TextView scoreTextView;
@BindView(R.id.minus_button_item_post_comment) ImageView downvoteButton;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
index de7b7992..1b3a9f90 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
@@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.ColorFilter;
+import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
@@ -36,8 +37,6 @@ import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
import com.multilevelview.MultiLevelRecyclerView;
import com.santalu.aspectratioimageview.AspectRatioImageView;
-import org.sufficientlysecure.htmltextview.HtmlTextView;
-
import java.util.ArrayList;
import java.util.List;
@@ -50,6 +49,7 @@ import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;
import jp.wasabeef.glide.transformations.BlurTransformation;
import retrofit2.Retrofit;
+import ru.noties.markwon.view.MarkwonView;
public class ViewPostDetailActivity extends AppCompatActivity {
@@ -66,7 +66,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
@BindView(R.id.subreddit_icon_circle_image_view_view_post_detail) CircleImageView mSubredditIconCircleImageView;
@BindView(R.id.post_time_text_view_view_post_detail) TextView mPostTimeTextView;
@BindView(R.id.subreddit_text_view_view_post_detail) TextView mSubredditTextView;
- @BindView(R.id.content_html_text_view_view_post_detail) HtmlTextView mContentTextView;
+ @BindView(R.id.content_markdown_view_view_post_detail) MarkwonView mContentMarkdownView;
@BindView(R.id.type_text_view_view_post_detail) Chip mTypeChip;
@BindView(R.id.gilded_image_view_view_post_detail) ImageView mGildedImageView;
@BindView(R.id.gilded_number_text_view_view_post_detail) TextView mGildedNumberTextView;
@@ -151,11 +151,11 @@ public class ViewPostDetailActivity extends AppCompatActivity {
switch (mPost.getVoteType()) {
case 1:
//Upvote
- mUpvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
+ mUpvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
break;
case -1:
//Downvote
- mDownvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.minusButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
+ mDownvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.minusButtonColor), PorterDuff.Mode.SRC_IN);
break;
}
@@ -268,8 +268,8 @@ public class ViewPostDetailActivity extends AppCompatActivity {
case Post.NO_PREVIEW_LINK_TYPE:
mTypeChip.setText("LINK");
if(!mPost.getSelfText().equals("")) {
- mContentTextView.setVisibility(View.VISIBLE);
- mContentTextView.setHtml(mPost.getSelfText());
+ mContentMarkdownView.setVisibility(View.VISIBLE);
+ mContentMarkdownView.setMarkdown(mPost.getSelfText());
}
mNoPreviewLinkImageView.setVisibility(View.VISIBLE);
mNoPreviewLinkImageView.setOnClickListener(view -> {
@@ -284,8 +284,8 @@ public class ViewPostDetailActivity extends AppCompatActivity {
case Post.TEXT_TYPE:
mTypeChip.setVisibility(View.GONE);
if(!mPost.getSelfText().equals("")) {
- mContentTextView.setVisibility(View.VISIBLE);
- mContentTextView.setHtml(mPost.getSelfText());
+ mContentMarkdownView.setVisibility(View.VISIBLE);
+ mContentMarkdownView.setMarkdown(mPost.getSelfText());
}
break;
}
@@ -298,7 +298,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
mDownvoteButton.clearColorFilter();
if (mUpvoteButton.getColorFilter() == null) {
- mUpvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
+ mUpvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
if(isDownvotedBefore) {
mScoreTextView.setText(Integer.toString(mPost.getScore() + 2));
} else {
@@ -340,7 +340,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
public void onVoteThingFail() {
Toast.makeText(ViewPostDetailActivity.this, "Cannot unvote this post", Toast.LENGTH_SHORT).show();
mScoreTextView.setText(Integer.toString(mPost.getScore() + 1));
- mUpvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
+ mUpvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
mPost.setScore(mPost.getScore() + 1);
}
}, mPost.getFullName(), RedditUtils.DIR_UNVOTE);
@@ -354,7 +354,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
mUpvoteButton.clearColorFilter();
if (mDownvoteButton.getColorFilter() == null) {
- mDownvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.minusButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
+ mDownvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.minusButtonColor), PorterDuff.Mode.SRC_IN);
if (isUpvotedBefore) {
mScoreTextView.setText(Integer.toString(mPost.getScore() - 2));
} else {
@@ -395,7 +395,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
@Override
public void onVoteThingFail() {
Toast.makeText(ViewPostDetailActivity.this, "Cannot unvote this post", Toast.LENGTH_SHORT).show();
- mDownvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.minusButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
+ mDownvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.minusButtonColor), PorterDuff.Mode.SRC_IN);
mScoreTextView.setText(Integer.toString(mPost.getScore()));
mPost.setScore(mPost.getScore());
}
diff --git a/app/src/main/res/layout/activity_view_post_detail.xml b/app/src/main/res/layout/activity_view_post_detail.xml
index 5880a9d3..bb2bd0e2 100644
--- a/app/src/main/res/layout/activity_view_post_detail.xml
+++ b/app/src/main/res/layout/activity_view_post_detail.xml
@@ -70,16 +70,13 @@
android:textColor="#000000"
android:textSize="18sp" />
- <org.sufficientlysecure.htmltextview.HtmlTextView
- android:id="@+id/content_html_text_view_view_post_detail"
+ <ru.noties.markwon.view.MarkwonView
+ android:id="@+id/content_markdown_view_view_post_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
- android:layout_marginLeft="16dp"
- android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
- android:textAppearance="@android:style/TextAppearance.Small"
android:visibility="gone" />
<RelativeLayout
diff --git a/app/src/main/res/layout/activity_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml
index 97aad464..6492e140 100644
--- a/app/src/main/res/layout/activity_view_subreddit_detail.xml
+++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml
@@ -29,7 +29,8 @@
android:id="@+id/banner_image_view_view_subreddit_detail_activity"
android:layout_width="match_parent"
android:scaleType="centerCrop"
- android:layout_height="180dp" />
+ android:layout_height="180dp"
+ android:contentDescription="@string/content_description_banner_imageview" />
<com.felipecsl.gifimageview.library.GifImageView
android:id="@+id/icon_gif_image_view_view_subreddit_detail_activity"
@@ -58,6 +59,7 @@
android:id="@+id/subreddit_name_text_view_view_subreddit_detail_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:textSize="18sp"
android:textColor="@color/colorAccent"
@@ -70,17 +72,6 @@
android:textColor="@android:color/white"
android:layout_gravity="center_horizontal"/>
- <!--<RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="48dp"
- android:layout_marginStart="16dp"
- android:layout_marginEnd="16dp">
-
-
-
- </RelativeLayout>-->
-
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -91,6 +82,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
+ android:layout_alignParentStart="true"
+ android:layout_toStartOf="@id/online_subscriber_count_text_view_view_subreddit_detail_activity"
android:layout_marginBottom="16dp"/>
<TextView
@@ -98,7 +91,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
- android:layout_toStartOf="@id/subscriber_count_text_view_view_subreddit_detail_activity"
android:textColor="@android:color/black" />
</RelativeLayout>
diff --git a/app/src/main/res/layout/item_post_comment.xml b/app/src/main/res/layout/item_post_comment.xml
index 6981b955..e047d214 100644
--- a/app/src/main/res/layout/item_post_comment.xml
+++ b/app/src/main/res/layout/item_post_comment.xml
@@ -40,15 +40,14 @@
</LinearLayout>
- <org.sufficientlysecure.htmltextview.HtmlTextView
- android:id="@+id/comment_html_text_view_item_post_comment"
+ <ru.noties.markwon.view.MarkwonView
+ android:id="@+id/comment_markdown_view_item_post_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
- android:layout_marginBottom="8dp"
- android:textAppearance="@android:style/TextAppearance.Small"/>
+ android:layout_marginBottom="8dp"/>
<RelativeLayout
android:id="@+id/relative_layout_item_post_comment"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f9c75d07..7084659c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -125,4 +125,6 @@
<string name="subscribe_failed">Subscribe Failed</string>
<string name="unsubscribed">Unsubscribed</string>"
<string name="unsubscribe_failed">Unsubscribe Failed</string>
+
+ <string name="content_description_banner_imageview">Subreddit Banner Image</string>
</resources>