aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java30
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java15
-rw-r--r--app/src/main/res/values/arrays.xml22
-rw-r--r--app/src/main/res/values/strings.xml9
-rw-r--r--app/src/main/res/xml/comment_preferences.xml8
-rw-r--r--app/src/main/res/xml/post_details_preferences.xml8
13 files changed, 98 insertions, 26 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
index fab5e216..0261eae5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
@@ -227,7 +227,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
imageIntent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, mediaMetadata.fileName);
});
ImageAndGifPlugin imageAndGifPlugin = new ImageAndGifPlugin();
- imageAndGifEntry = new ImageAndGifEntry(this, mGlide, mediaMetadata -> {
+ imageAndGifEntry = new ImageAndGifEntry(this, mGlide, SharedPreferencesUtils.EMBEDDED_MEDIA_ALL, mediaMetadata -> {
Intent imageIntent = new Intent(this, ViewImageOrGifActivity.class);
if (mediaMetadata.isGIF) {
imageIntent.putExtra(ViewImageOrGifActivity.EXTRA_GIF_URL_KEY, mediaMetadata.original.url);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
index fede7776..691b411d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java
@@ -176,7 +176,7 @@ public class WikiActivity extends BaseActivity {
});
imageAndGifPlugin = new ImageAndGifPlugin();
imageAndGifEntry = new ImageAndGifEntry(this,
- mGlide, mediaMetadata -> {
+ mGlide, SharedPreferencesUtils.EMBEDDED_MEDIA_ALL, mediaMetadata -> {
Intent intent = new Intent(this, ViewImageOrGifActivity.class);
if (mediaMetadata.isGIF) {
intent.putExtra(ViewImageOrGifActivity.EXTRA_GIF_URL_KEY, mediaMetadata.original.url);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
index 296bb8a3..95ad046c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
@@ -198,20 +198,22 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
mMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
miscPlugin, mEmoteCloseBracketInlineProcessor, mEmotePlugin, mImageAndGifPlugin, mCommentColor,
commentSpoilerBackgroundColor, onLinkLongClickListener);
- mImageAndGifEntry = new ImageAndGifEntry(activity, Glide.with(activity), mediaMetadata -> {
- Intent intent = new Intent(activity, ViewImageOrGifActivity.class);
- if (mediaMetadata.isGIF) {
- intent.putExtra(ViewImageOrGifActivity.EXTRA_GIF_URL_KEY, mediaMetadata.original.url);
- } else {
- intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, mediaMetadata.original.url);
- }
- intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, username);
- intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, mediaMetadata.fileName);
- if (canStartActivity) {
- canStartActivity = false;
- activity.startActivity(intent);
- }
- });
+ mImageAndGifEntry = new ImageAndGifEntry(activity, Glide.with(activity),
+ Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.EMBEDDED_MEDIA_TYPE, "15")),
+ mediaMetadata -> {
+ Intent intent = new Intent(activity, ViewImageOrGifActivity.class);
+ if (mediaMetadata.isGIF) {
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_GIF_URL_KEY, mediaMetadata.original.url);
+ } else {
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, mediaMetadata.original.url);
+ }
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, username);
+ intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, mediaMetadata.fileName);
+ if (canStartActivity) {
+ canStartActivity = false;
+ activity.startActivity(intent);
+ }
+ });
recycledViewPool = new RecyclerView.RecycledViewPool();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index dd6b9c91..f4000e5c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -244,7 +244,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
boolean doNotBlurNsfwInNsfwSubreddits = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, false);
boolean needBlurSpoiler = nsfwAndSpoilerSharedPreferences.getBoolean((mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : mAccountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, false);
boolean blurImage = (post.isNSFW() && needBlurNsfw && !(doNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (post.isSpoiler() && needBlurSpoiler);
- mImageAndGifEntry = new ImageAndGifEntry(activity, mGlide, blurImage,
+ mImageAndGifEntry = new ImageAndGifEntry(activity, mGlide, Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.EMBEDDED_MEDIA_TYPE, "15")), blurImage,
mediaMetadata -> {
Intent intent = new Intent(activity, ViewImageOrGifActivity.class);
if (mediaMetadata.isGIF) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index baf833ee..5f5c7cd7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -404,7 +404,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
miscPlugin, mEmoteCloseBracketInlineProcessor, mEmotePlugin, mImageAndGifPlugin, markdownColor,
postSpoilerBackgroundColor, onLinkLongClickListener);
mImageAndGifEntry = new ImageAndGifEntry(activity,
- mGlide, mDataSavingMode, mDisableImagePreview,
+ mGlide, Integer.parseInt(postDetailsSharedPreferences.getString(SharedPreferencesUtils.EMBEDDED_MEDIA_TYPE, "15")),
+ mDataSavingMode, mDisableImagePreview,
(post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (mPost.isSpoiler() && mNeedBlurSpoiler),
mediaMetadata -> {
Intent intent = new Intent(activity, ViewImageOrGifActivity.class);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
index 6170d7dd..3be31942 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java
@@ -38,6 +38,7 @@ import ml.docilealligator.infinityforreddit.markdown.EvenBetterLinkMovementMetho
import ml.docilealligator.infinityforreddit.markdown.ImageAndGifEntry;
import ml.docilealligator.infinityforreddit.markdown.ImageAndGifPlugin;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
+import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
private final BaseActivity activity;
@@ -103,7 +104,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
});
imageAndGifPlugin = new ImageAndGifPlugin();
imageAndGifEntry = new ImageAndGifEntry(activity,
- Glide.with(activity),
+ Glide.with(activity), SharedPreferencesUtils.EMBEDDED_MEDIA_ALL,
mediaMetadata -> {
Intent imageIntent = new Intent(activity, ViewImageOrGifActivity.class);
if (mediaMetadata.isGIF) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
index b3f139b1..e1a1f13d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java
@@ -163,7 +163,7 @@ public class SidebarFragment extends Fragment {
});
ImageAndGifPlugin imageAndGifPlugin = new ImageAndGifPlugin();
imageAndGifEntry = new ImageAndGifEntry(activity,
- Glide.with(this),
+ Glide.with(this), SharedPreferencesUtils.EMBEDDED_MEDIA_ALL,
mediaMetadata -> {
Intent imageIntent = new Intent(activity, ViewImageOrGifActivity.class);
if (mediaMetadata.isGIF) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java
index 01dc27ab..aa053f4f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java
@@ -53,8 +53,10 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
private final int primaryTextColor;
private final int postContentColor;
private final int linkColor;
+ private final boolean canShowImage;
+ private final boolean canShowGif;
- public ImageAndGifEntry(BaseActivity baseActivity, RequestManager glide,
+ public ImageAndGifEntry(BaseActivity baseActivity, RequestManager glide, int embeddedMediaType,
OnItemClickListener onItemClickListener) {
this.baseActivity = baseActivity;
this.glide = glide;
@@ -66,6 +68,8 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
primaryTextColor = baseActivity.getCustomThemeWrapper().getPrimaryTextColor();
postContentColor = baseActivity.getCustomThemeWrapper().getPostContentColor();
linkColor = baseActivity.getCustomThemeWrapper().getLinkColor();
+ canShowImage = SharedPreferencesUtils.canShowImage(embeddedMediaType);
+ canShowGif = SharedPreferencesUtils.canShowGif(embeddedMediaType);
String dataSavingModeString = sharedPreferences.getString(SharedPreferencesUtils.DATA_SAVING_MODE, SharedPreferencesUtils.DATA_SAVING_MODE_OFF);
if (dataSavingModeString.equals(SharedPreferencesUtils.DATA_SAVING_MODE_ALWAYS)) {
@@ -76,13 +80,13 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
disableImagePreview = sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false);
}
- public ImageAndGifEntry(BaseActivity baseActivity, RequestManager glide, boolean blurImage,
- OnItemClickListener onItemClickListener) {
- this(baseActivity, glide, onItemClickListener);
+ public ImageAndGifEntry(BaseActivity baseActivity, RequestManager glide, int embeddedMediaType,
+ boolean blurImage, OnItemClickListener onItemClickListener) {
+ this(baseActivity, glide, embeddedMediaType, onItemClickListener);
this.blurImage = blurImage;
}
- public ImageAndGifEntry(BaseActivity baseActivity, RequestManager glide, boolean dataSavingMode,
+ public ImageAndGifEntry(BaseActivity baseActivity, RequestManager glide, int embeddedMediaType, boolean dataSavingMode,
boolean disableImagePreview, boolean blurImage,
OnItemClickListener onItemClickListener) {
this.baseActivity = baseActivity;
@@ -98,6 +102,8 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
primaryTextColor = baseActivity.getCustomThemeWrapper().getPrimaryTextColor();
postContentColor = baseActivity.getCustomThemeWrapper().getPostContentColor();
linkColor = baseActivity.getCustomThemeWrapper().getLinkColor();
+ canShowImage = SharedPreferencesUtils.canShowImage(embeddedMediaType);
+ canShowGif = SharedPreferencesUtils.canShowGif(embeddedMediaType);
}
@NonNull
@@ -125,7 +131,7 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima
RequestBuilder<Drawable> imageRequestBuilder;
if (dataSavingMode) {
- if (disableImagePreview) {
+ if (disableImagePreview || (node.mediaMetadata.isGIF && !canShowGif) || (!node.mediaMetadata.isGIF && !canShowImage)) {
holder.binding.imageWrapperRelativeLayoutMarkdownImageAndGifBlock.setVisibility(View.GONE);
holder.binding.captionTextViewMarkdownImageAndGifBlock.setVisibility(View.VISIBLE);
holder.binding.captionTextViewMarkdownImageAndGifBlock.setGravity(Gravity.NO_GRAVITY);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
index 51ad438b..ff2f800e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -256,6 +256,21 @@ public class SharedPreferencesUtils {
return POST_DETAIL_FAB_LANDSCAPE_Y_BASE + display.getDisplayId();
}
+ public static final String EMBEDDED_MEDIA_TYPE = "embedded_media_type";
+ public static final int EMBEDDED_MEDIA_ALL = 15;
+
+ public static boolean canShowImage(int embeddedMediaType) {
+ return embeddedMediaType == 15 || embeddedMediaType == 7 || embeddedMediaType == 6 || embeddedMediaType == 3;
+ }
+
+ public static boolean canShowGif(int embeddedMediaType) {
+ return embeddedMediaType == 15 || embeddedMediaType == 7 || embeddedMediaType == 5 || embeddedMediaType == 2;
+ }
+
+ public static boolean canShowEmoji(int embeddedMediaType) {
+ return embeddedMediaType == 15 || embeddedMediaType == 6 || embeddedMediaType == 5 || embeddedMediaType == 1;
+ }
+
public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";
public static final String MAIN_PAGE_TAB_COUNT = "_main_page_tab_count";
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index adb1cb64..3b94b241 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -698,4 +698,26 @@
<item>@string/save_locally_and_online</item>
</string-array>
+ <string-array name="settings_embedded_media_type">
+ <item>@string/all</item>
+ <item>@string/image_and_gif</item>
+ <item>@string/image_and_emoji</item>
+ <item>@string/gif_and_emoji</item>
+ <item>@string/image_embedded_media</item>
+ <item>@string/gif</item>
+ <item>@string/emoji</item>
+ <item>@string/none</item>
+ </string-array>
+
+ <string-array name="settings_embedded_media_type_values">
+ <item>15</item>
+ <item>7</item>
+ <item>6</item>
+ <item>5</item>
+ <item>3</item>
+ <item>2</item>
+ <item>1</item>
+ <item>0</item>
+ </string-array>
+
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 898df6ed..833411b2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -642,6 +642,7 @@
<string name="settings_hide_fab_in_post_feed">Hide FAB in Post Feed</string>
<string name="settings_comment_divider_type">Comment Divider Type</string>
<string name="settings_comment_filter_title">Comment Filter</string>
+ <string name="settings_embedded_media_type_title">Embedded Media Type</string>
<string name="no_link_available">Cannot get the link</string>
@@ -1393,4 +1394,12 @@
<string name="local">Local</string>
<string name="online">Online</string>
+ <string name="image_and_gif">Image and GIF</string>
+ <string name="image_and_emoji">Image and emoji</string>
+ <string name="gif_and_emoji">GIF and emoji</string>
+ <string name="image_embedded_media">Image</string>
+ <string name="emoji">Emoji</string>
+ <string name="none">None</string>
+
+
</resources>
diff --git a/app/src/main/res/xml/comment_preferences.xml b/app/src/main/res/xml/comment_preferences.xml
index bfd4237a..79b49351 100644
--- a/app/src/main/res/xml/comment_preferences.xml
+++ b/app/src/main/res/xml/comment_preferences.xml
@@ -63,4 +63,12 @@
app:title="@string/settings_show_fewer_toolbar_options_threshold_title"
app:singleLineTitle="false" />
+ <ml.docilealligator.infinityforreddit.customviews.CustomFontListPreference
+ app:defaultValue="15"
+ app:entries="@array/settings_embedded_media_type"
+ app:entryValues="@array/settings_embedded_media_type_values"
+ app:key="embedded_media_type"
+ app:title="@string/settings_embedded_media_type_title"
+ app:useSimpleSummaryProvider="true" />
+
</PreferenceScreen> \ No newline at end of file
diff --git a/app/src/main/res/xml/post_details_preferences.xml b/app/src/main/res/xml/post_details_preferences.xml
index 0cbf770f..3ff62eee 100644
--- a/app/src/main/res/xml/post_details_preferences.xml
+++ b/app/src/main/res/xml/post_details_preferences.xml
@@ -37,4 +37,12 @@
app:key="hide_the_number_of_comments"
app:title="@string/settings_hide_the_number_of_comments" />
+ <ml.docilealligator.infinityforreddit.customviews.CustomFontListPreference
+ app:defaultValue="15"
+ app:entries="@array/settings_embedded_media_type"
+ app:entryValues="@array/settings_embedded_media_type_values"
+ app:key="embedded_media_type"
+ app:title="@string/settings_embedded_media_type_title"
+ app:useSimpleSummaryProvider="true" />
+
</PreferenceScreen> \ No newline at end of file