aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-11-09 04:27:21 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-11-09 04:27:21 +0000
commitd37a386291c89e3740a762dbc99fe621fb8faac3 (patch)
treea69c2cff4b87af716e4ca2c99338d41931e7a7e4
parent252412d8ce5cd87e94bceaf30b5108eec63aadb7 (diff)
downloadinfinity-for-reddit-d37a386291c89e3740a762dbc99fe621fb8faac3.tar
infinity-for-reddit-d37a386291c89e3740a762dbc99fe621fb8faac3.tar.gz
infinity-for-reddit-d37a386291c89e3740a762dbc99fe621fb8faac3.tar.bz2
infinity-for-reddit-d37a386291c89e3740a762dbc99fe621fb8faac3.tar.lz
infinity-for-reddit-d37a386291c89e3740a762dbc99fe621fb8faac3.tar.xz
infinity-for-reddit-d37a386291c89e3740a762dbc99fe621fb8faac3.tar.zst
infinity-for-reddit-d37a386291c89e3740a762dbc99fe621fb8faac3.zip
Shrink icon size in flair and award tags.
Diffstat (limited to '')
-rw-r--r--app/src/main/AndroidManifest.xml1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java27
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserFlairRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java4
7 files changed, 17 insertions, 31 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b174ee0e..b2b2dcb1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -9,6 +9,7 @@
</intent>
</queries>
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
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 f9268870..66c4ba8e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -11,8 +11,6 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
-import android.text.Html;
-import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
@@ -113,7 +111,6 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
-import ml.docilealligator.infinityforreddit.Utils.GlideImageGetter;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import ml.docilealligator.infinityforreddit.VoteThing;
@@ -767,7 +764,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (mPost.getAuthorFlairHTML() != null && !mPost.getAuthorFlairHTML().equals("")) {
((PostDetailBaseViewHolder) holder).mAuthorFlairTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((PostDetailBaseViewHolder) holder).mAuthorFlairTextView, mPost.getAuthorFlairHTML());
+ Utils.setHTMLWithImageToTextView(((PostDetailBaseViewHolder) holder).mAuthorFlairTextView, mPost.getAuthorFlairHTML(), true);
} else if (mPost.getAuthorFlair() != null && !mPost.getAuthorFlair().equals("")) {
((PostDetailBaseViewHolder) holder).mAuthorFlairTextView.setVisibility(View.VISIBLE);
((PostDetailBaseViewHolder) holder).mAuthorFlairTextView.setText(mPost.getAuthorFlair());
@@ -825,19 +822,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (mPost.getFlair() != null && !mPost.getFlair().equals("")) {
((PostDetailBaseViewHolder) holder).mFlairTextView.setVisibility(View.VISIBLE);
- Spannable flairHTML;
- GlideImageGetter glideImageGetter = new GlideImageGetter(((PostDetailBaseViewHolder) holder).mFlairTextView);
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
- flairHTML = (Spannable) Html.fromHtml(mPost.getFlair(), Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
- } else {
- flairHTML = (Spannable) Html.fromHtml(mPost.getFlair(), glideImageGetter, null);
- }
- ((PostDetailBaseViewHolder) holder).mFlairTextView.setText(flairHTML);
+ Utils.setHTMLWithImageToTextView(((PostDetailBaseViewHolder) holder).mFlairTextView, mPost.getFlair(), false);
}
if (mPost.getAwards() != null && !mPost.getAwards().equals("")) {
((PostDetailBaseViewHolder) holder).mAwardsTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((PostDetailBaseViewHolder) holder).mAwardsTextView, mPost.getAwards());
+ Utils.setHTMLWithImageToTextView(((PostDetailBaseViewHolder) holder).mAwardsTextView, mPost.getAwards(), true);
}
if (mPost.isNSFW()) {
@@ -1030,7 +1020,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (comment.getAuthorFlairHTML() != null && !comment.getAuthorFlairHTML().equals("")) {
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).authorFlairTextView, comment.getAuthorFlairHTML());
+ Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).authorFlairTextView, comment.getAuthorFlairHTML(), true);
} else if (comment.getAuthorFlair() != null && !comment.getAuthorFlair().equals("")) {
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
((CommentViewHolder) holder).authorFlairTextView.setText(comment.getAuthorFlair());
@@ -1065,14 +1055,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (comment.getAwards() != null && !comment.getAwards().equals("")) {
((CommentViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE);
- Spannable awardsHTML;
- GlideImageGetter glideImageGetter = new GlideImageGetter(((CommentViewHolder) holder).awardsTextView);
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
- awardsHTML = (Spannable) Html.fromHtml(comment.getAwards(), Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
- } else {
- awardsHTML = (Spannable) Html.fromHtml(comment.getAwards(), glideImageGetter, null);
- }
- ((CommentViewHolder) holder).awardsTextView.setText(awardsHTML);
+ Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).awardsTextView, comment.getAwards(), true);
}
mCommentMarkwon.setMarkdown(((CommentViewHolder) holder).commentMarkdownView, comment.getCommentMarkdown());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
index 508d22aa..147a13d1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
@@ -251,7 +251,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
if (comment.getAuthorFlairHTML() != null && !comment.getAuthorFlairHTML().equals("")) {
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).authorFlairTextView, comment.getAuthorFlairHTML());
+ Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).authorFlairTextView, comment.getAuthorFlairHTML(), true);
} else if (comment.getAuthorFlair() != null && !comment.getAuthorFlair().equals("")) {
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
((CommentViewHolder) holder).authorFlairTextView.setText(comment.getAuthorFlair());
@@ -266,7 +266,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
if (comment.getAwards() != null && !comment.getAwards().equals("")) {
((CommentViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).awardsTextView, comment.getAwards());
+ Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).awardsTextView, comment.getAwards(), true);
}
mMarkwon.setMarkdown(((CommentViewHolder) holder).commentMarkdownView, comment.getCommentMarkdown());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index 0f953683..0a80f67e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -523,7 +523,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (flair != null && !flair.equals("")) {
((PostBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((PostBaseViewHolder) holder).flairTextView, flair);
+ Utils.setHTMLWithImageToTextView(((PostBaseViewHolder) holder).flairTextView, flair, false);
}
if (nAwards > 0) {
@@ -837,7 +837,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (flair != null && !flair.equals("")) {
((PostCompactBaseViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
- Utils.setHTMLWithImageToTextView(((PostCompactBaseViewHolder) holder).flairTextView, flair);
+ Utils.setHTMLWithImageToTextView(((PostCompactBaseViewHolder) holder).flairTextView, flair, false);
}
if (nAwards > 0) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserFlairRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserFlairRecyclerViewAdapter.java
index e0669959..a9ae4687 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserFlairRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserFlairRecyclerViewAdapter.java
@@ -47,7 +47,7 @@ public class UserFlairRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerV
if (userFlair.getHtmlText() == null || userFlair.getHtmlText().equals("")) {
((UserFlairViewHolder) holder).userFlairHtmlTextView.setText(userFlair.getText());
} else {
- Utils.setHTMLWithImageToTextView(((UserFlairViewHolder) holder).userFlairHtmlTextView, userFlair.getHtmlText());
+ Utils.setHTMLWithImageToTextView(((UserFlairViewHolder) holder).userFlairHtmlTextView, userFlair.getHtmlText(), true);
}
if (userFlair.isEditable()) {
((UserFlairViewHolder) holder).editUserFlairImageView.setVisibility(View.VISIBLE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
index bd100469..00f940a0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
@@ -25,12 +25,14 @@ public class GlideImageGetter implements Html.ImageGetter {
private WeakReference<TextView> container;
private boolean matchParentWidth;
+ private boolean enlargeImage;
private HtmlImagesHandler imagesHandler;
private float density = 1.0f;
private float textSize;
- public GlideImageGetter(TextView textView) {
+ public GlideImageGetter(TextView textView, boolean enlargeImage) {
this(textView, false, false, null);
+ this.enlargeImage = enlargeImage;
}
public GlideImageGetter(TextView textView, boolean matchParentWidth, HtmlImagesHandler imagesHandler) {
@@ -88,7 +90,7 @@ public class GlideImageGetter implements Html.ImageGetter {
int drawableWidth = (int) (drawable.getIntrinsicWidth() * density);
int drawableHeight = (int) (drawable.getIntrinsicHeight() * density);
float ratio = (float) drawableWidth / (float) drawableHeight;
- drawableHeight = (int) (textSize * 1.5);
+ drawableHeight = enlargeImage ? (int) (textSize * 1.5) : (int) textSize;
drawableWidth = (int) (drawableHeight * ratio);
int maxWidth = container.get().getMeasuredWidth();
if ((maxWidth > 0 && (drawableWidth > maxWidth)) || matchParentWidth) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
index f3d32e5d..d277e8df 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
@@ -134,9 +134,9 @@ public class Utils {
}
}
- public static void setHTMLWithImageToTextView(TextView textView, String content) {
+ public static void setHTMLWithImageToTextView(TextView textView, String content, boolean enlargeImage) {
Spannable html;
- GlideImageGetter glideImageGetter = new GlideImageGetter(textView);
+ GlideImageGetter glideImageGetter = new GlideImageGetter(textView, enlargeImage);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
html = (Spannable) Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
} else {