From 297db53aa3038e4486a8fc199425a77476c9cb06 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 7 May 2019 19:45:08 +0800 Subject: [PATCH] Reverse the change of unescaping HTML because it also remove all the HTML tags. Fixed subreddit name and post time overlapping. Fixed menu item text not shown in MainActivity. --- .../infinityforreddit/ParseComment.java | 3 +-- .../infinityforreddit/ParsePost.java | 10 +++++----- .../main/res/layout/activity_view_post_detail.xml | 5 ++++- app/src/main/res/layout/app_bar_main.xml | 5 ++++- app/src/main/res/layout/item_post.xml | 15 +++++++++------ 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java index c2808e97..78bc2581 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java @@ -1,7 +1,6 @@ package ml.docilealligator.infinityforreddit; import android.os.AsyncTask; -import android.text.Html; import android.util.Log; import org.json.JSONArray; @@ -117,7 +116,7 @@ class ParseComment { boolean isSubmitter = data.getBoolean(JSONUtils.IS_SUBMITTER_KEY); String commentContent = ""; if(!data.isNull(JSONUtils.BODY_HTML_KEY)) { - commentContent = Html.fromHtml(data.getString(JSONUtils.BODY_HTML_KEY).trim()).toString(); + commentContent = data.getString(JSONUtils.BODY_HTML_KEY).trim(); } String permalink = data.getString(JSONUtils.PERMALINK_KEY); int score = data.getInt(JSONUtils.SCORE_KEY); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java index 6cb68323..280d36a7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java @@ -1,7 +1,6 @@ package ml.docilealligator.infinityforreddit; import android.os.AsyncTask; -import android.text.Html; import android.util.Log; import org.json.JSONArray; @@ -63,6 +62,7 @@ class ParsePost { for(int i = 0; i < allData.length(); i++) { String kind = allData.getJSONObject(i).getString(JSONUtils.KIND_KEY); if(!kind.equals("t3")) { + //It's a comment continue; } JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY); @@ -149,7 +149,7 @@ class ParsePost { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { post.setSelfText(""); } else { - post.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString()); + post.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()); } bestPostData.add(post); } else { @@ -162,7 +162,7 @@ class ParsePost { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { linkPost.setSelfText(""); } else { - linkPost.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString()); + linkPost.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()); } bestPostData.add(linkPost); } @@ -253,7 +253,7 @@ class ParsePost { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { textWithImagePost.setSelfText(""); } else { - textWithImagePost.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString()); + textWithImagePost.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()); } bestPostData.add(textWithImagePost); } else { @@ -266,7 +266,7 @@ class ParsePost { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { linkPost.setSelfText(""); } else { - linkPost.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString()); + linkPost.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()); } linkPost.setPreviewWidth(previewWidth); 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 26239fef..1fe7d3cd 100644 --- a/app/src/main/res/layout/activity_view_post_detail.xml +++ b/app/src/main/res/layout/activity_view_post_detail.xml @@ -34,11 +34,13 @@ diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index cfd4637b..483a7e55 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -26,7 +26,10 @@ + android:layout_height="?attr/actionBarSize" + app:layout_collapseMode="pin" + app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" + app:popupTheme="@style/AppTheme.PopupOverlay" /> + android:textColor="#E91E63"/> @@ -46,11 +48,11 @@ android:id="@+id/stickied_post_image_view_best_post_item" android:layout_width="24dp" android:layout_height="24dp" - android:layout_gravity="center" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:tint="@color/colorPrimary" android:visibility="gone" + app:layout_constraintStart_toEndOf="@id/subreddit_icon_name_linear_layout_view_item_best_post" app:layout_constraintEnd_toStartOf="@+id/post_time_text_view_best_post_item" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent"/> @@ -58,12 +60,13 @@ + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintHorizontal_bias="1"/>