aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java46
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java64
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeOnlyDisablePreviewInVideoAndGifPostsEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/values/strings.xml3
-rw-r--r--app/src/main/res/xml/data_saving_mode_preferences.xml5
8 files changed, 100 insertions, 48 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
index 25f82e1e..bdfb619f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
@@ -124,20 +124,21 @@ import static ml.docilealligator.infinityforreddit.activities.CommentActivity.WR
public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements CacheManager {
private static final int VIEW_TYPE_POST_DETAIL_VIDEO_AUTOPLAY = 1;
private static final int VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW = 2;
- private static final int VIEW_TYPE_POST_DETAIL_IMAGE_AND_GIF_AUTOPLAY = 3;
- private static final int VIEW_TYPE_POST_DETAIL_LINK = 4;
- private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 5;
- private static final int VIEW_TYPE_POST_DETAIL_GALLERY = 6;
- private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 7;
- private static final int VIEW_TYPE_FIRST_LOADING = 8;
- private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 9;
- private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 10;
- private static final int VIEW_TYPE_COMMENT = 11;
- private static final int VIEW_TYPE_COMMENT_FULLY_COLLAPSED = 12;
- private static final int VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS = 13;
- private static final int VIEW_TYPE_IS_LOADING_MORE_COMMENTS = 14;
- private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 15;
- private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 16;
+ private static final int VIEW_TYPE_POST_DETAIL_IMAGE = 3;
+ private static final int VIEW_TYPE_POST_DETAIL_GIF_AUTOPLAY = 4;
+ private static final int VIEW_TYPE_POST_DETAIL_LINK = 5;
+ private static final int VIEW_TYPE_POST_DETAIL_NO_PREVIEW_LINK = 6;
+ private static final int VIEW_TYPE_POST_DETAIL_GALLERY = 7;
+ private static final int VIEW_TYPE_POST_DETAIL_TEXT_TYPE = 8;
+ private static final int VIEW_TYPE_FIRST_LOADING = 9;
+ private static final int VIEW_TYPE_FIRST_LOADING_FAILED = 10;
+ private static final int VIEW_TYPE_NO_COMMENT_PLACEHOLDER = 11;
+ private static final int VIEW_TYPE_COMMENT = 12;
+ private static final int VIEW_TYPE_COMMENT_FULLY_COLLAPSED = 13;
+ private static final int VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS = 14;
+ private static final int VIEW_TYPE_IS_LOADING_MORE_COMMENTS = 15;
+ private static final int VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED = 16;
+ private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 17;
private AppCompatActivity mActivity;
private Retrofit mRetrofit;
@@ -178,6 +179,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private boolean mAutomaticallyTryRedgifs;
private boolean mDataSavingMode;
private boolean mDisableImagePreview;
+ private boolean mOnlyDisablePreviewInVideoAndGifPosts;
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
private boolean isInitiallyLoading;
private boolean isInitiallyLoadingFailed;
@@ -513,6 +515,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mDataSavingMode = networkType == Utils.NETWORK_TYPE_CELLULAR;
}
mDisableImagePreview = sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false);
+ mOnlyDisablePreviewInVideoAndGifPosts = sharedPreferences.getBoolean(SharedPreferencesUtils.ONLY_DISABLE_PREVIEW_IN_VIDEO_AND_GIF_POSTS, false);
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
isInitiallyLoading = true;
@@ -590,12 +593,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (!mAutoplayNsfwVideos && mPost.isNSFW()) {
return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW;
}
- return VIEW_TYPE_POST_DETAIL_IMAGE_AND_GIF_AUTOPLAY;
+ return VIEW_TYPE_POST_DETAIL_GIF_AUTOPLAY;
} else {
return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW;
}
case Post.IMAGE_TYPE:
- return VIEW_TYPE_POST_DETAIL_IMAGE_AND_GIF_AUTOPLAY;
+ return VIEW_TYPE_POST_DETAIL_IMAGE;
case Post.LINK_TYPE:
return VIEW_TYPE_POST_DETAIL_LINK;
case Post.NO_PREVIEW_LINK_TYPE:
@@ -668,22 +671,27 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
switch (viewType) {
case VIEW_TYPE_POST_DETAIL_VIDEO_AUTOPLAY:
if (mDataSavingMode) {
- if (mDisableImagePreview) {
+ if (mDisableImagePreview || mOnlyDisablePreviewInVideoAndGifPosts) {
return new PostDetailNoPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_no_preview, parent, false));
}
return new PostDetailVideoAndGifPreviewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_video_and_gif_preview, parent, false));
}
return new PostDetailVideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_video_autoplay, parent, false));
case VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW:
- if (mDataSavingMode && mDisableImagePreview) {
+ if (mDataSavingMode && (mDisableImagePreview || mOnlyDisablePreviewInVideoAndGifPosts)) {
return new PostDetailNoPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_no_preview, parent, false));
}
return new PostDetailVideoAndGifPreviewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_video_and_gif_preview, parent, false));
- case VIEW_TYPE_POST_DETAIL_IMAGE_AND_GIF_AUTOPLAY:
+ case VIEW_TYPE_POST_DETAIL_IMAGE:
if (mDataSavingMode && mDisableImagePreview) {
return new PostDetailNoPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_no_preview, parent, false));
}
return new PostDetailImageAndGifAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_image_and_gif_autoplay, parent, false));
+ case VIEW_TYPE_POST_DETAIL_GIF_AUTOPLAY:
+ if (mDataSavingMode && (mDisableImagePreview || mOnlyDisablePreviewInVideoAndGifPosts)) {
+ return new PostDetailNoPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_no_preview, parent, false));
+ }
+ return new PostDetailImageAndGifAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_image_and_gif_autoplay, parent, false));
case VIEW_TYPE_POST_DETAIL_LINK:
if (mDataSavingMode && mDisableImagePreview) {
return new PostDetailNoPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_no_preview, parent, false));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index ccb2880c..15faf972 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -193,7 +193,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mLongPressToHideToolbarInCompactLayout;
private boolean mCompactLayoutToolbarHiddenByDefault;
private boolean mDataSavingMode = false;
- private boolean mDisableImagePreview = false;
+ private boolean mDisableImagePreview;
+ private boolean mOnlyDisablePreviewInVideoAndGifPosts;
private boolean mMarkPostsAsRead;
private boolean mMarkPostsAsReadAfterVoting;
private boolean mMarkPostsAsReadOnScroll;
@@ -259,6 +260,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mDataSavingMode = networkType == Utils.NETWORK_TYPE_CELLULAR;
}
mDisableImagePreview = sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false);
+ mOnlyDisablePreviewInVideoAndGifPosts = sharedPreferences.getBoolean(SharedPreferencesUtils.ONLY_DISABLE_PREVIEW_IN_VIDEO_AND_GIF_POSTS, false);
mMarkPostsAsRead = postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
mMarkPostsAsReadAfterVoting = postHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, false);
@@ -685,6 +687,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} else if (post.getPostType() == Post.GALLERY_TYPE) {
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_gallery_24dp);
}
+ } else if (mDataSavingMode && mOnlyDisablePreviewInVideoAndGifPosts && (post.getPostType() == Post.VIDEO_TYPE || post.getPostType() == Post.GIF_TYPE)) {
+ ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
+ ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_outline_video_24dp);
+ ((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
} else {
Post.Preview preview = getSuitablePreview(post.getPreviews());
if (preview != null) {
@@ -924,16 +930,16 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (post.getPostType() != Post.TEXT_TYPE && post.getPostType() != Post.NO_PREVIEW_LINK_TYPE && !(mDataSavingMode && mDisableImagePreview)) {
((PostCompactBaseViewHolder) holder).relativeLayout.setVisibility(View.VISIBLE);
- if (post.getPostType() != Post.GIF_TYPE && post.getPostType() != Post.VIDEO_TYPE) {
- ((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
- }
- if (post.getPostType() == Post.GALLERY_TYPE && post.getPreviews().isEmpty()) {
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageFrameLayout.setVisibility(View.VISIBLE);
- } else {
- ((PostCompactBaseViewHolder) holder).imageView.setVisibility(View.VISIBLE);
+ if (post.getPostType() == Post.GALLERY_TYPE && post.getPreviews() != null && post.getPreviews().isEmpty()) {
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_gallery_24dp);
}
ArrayList<Post.Preview> previews = post.getPreviews();
if (previews != null && !previews.isEmpty()) {
+ if (post.getPostType() != Post.GIF_TYPE && post.getPostType() != Post.VIDEO_TYPE) {
+ ((PostCompactBaseViewHolder) holder).imageView.setVisibility(View.VISIBLE);
+ ((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
+ }
loadImage(holder, post, previews.get(0));
}
}
@@ -960,15 +966,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
case Post.IMAGE_TYPE:
((PostCompactBaseViewHolder) holder).typeTextView.setText(R.string.image);
if (mDataSavingMode && mDisableImagePreview) {
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageFrameLayout.setVisibility(View.VISIBLE);
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_image_24dp);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_image_24dp);
}
break;
case Post.LINK_TYPE:
((PostCompactBaseViewHolder) holder).typeTextView.setText(R.string.link);
if (mDataSavingMode && mDisableImagePreview) {
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageFrameLayout.setVisibility(View.VISIBLE);
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_link);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_link);
}
((PostCompactBaseViewHolder) holder).linkTextView.setVisibility(View.VISIBLE);
@@ -977,9 +983,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
break;
case Post.GIF_TYPE:
((PostCompactBaseViewHolder) holder).typeTextView.setText(R.string.gif);
- if (mDataSavingMode && mDisableImagePreview) {
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageFrameLayout.setVisibility(View.VISIBLE);
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_image_24dp);
+ if (mDataSavingMode && (mDisableImagePreview || mOnlyDisablePreviewInVideoAndGifPosts)) {
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_image_24dp);
} else {
((PostCompactBaseViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);
}
@@ -987,9 +993,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
break;
case Post.VIDEO_TYPE:
((PostCompactBaseViewHolder) holder).typeTextView.setText(R.string.video);
- if (mDataSavingMode && mDisableImagePreview) {
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageFrameLayout.setVisibility(View.VISIBLE);
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_outline_video_24dp);
+ if (mDataSavingMode && (mDisableImagePreview || mOnlyDisablePreviewInVideoAndGifPosts)) {
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_outline_video_24dp);
} else {
((PostCompactBaseViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);
}
@@ -1002,14 +1008,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactBaseViewHolder) holder).linkTextView.setVisibility(View.VISIBLE);
String noPreviewLinkDomain = Uri.parse(noPreviewLinkUrl).getHost();
((PostCompactBaseViewHolder) holder).linkTextView.setText(noPreviewLinkDomain);
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageFrameLayout.setVisibility(View.VISIBLE);
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_link);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_link);
break;
case Post.GALLERY_TYPE:
((PostCompactBaseViewHolder) holder).typeTextView.setText(R.string.gallery);
if (mDataSavingMode && mDisableImagePreview) {
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageFrameLayout.setVisibility(View.VISIBLE);
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_gallery_24dp);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_gallery_24dp);
}
break;
case Post.TEXT_TYPE:
@@ -1316,6 +1322,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mDisableImagePreview = disableImagePreview;
}
+ public void setOnlyDisablePreviewInVideoPosts(boolean onlyDisablePreviewInVideoAndGifPosts) {
+ mOnlyDisablePreviewInVideoAndGifPosts = onlyDisablePreviewInVideoAndGifPosts;
+ }
+
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
@@ -1405,7 +1415,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostCompactBaseViewHolder) holder).imageView.setVisibility(View.GONE);
((PostCompactBaseViewHolder) holder).playButtonImageView.setVisibility(View.GONE);
- ((PostCompactBaseViewHolder) holder).noPreviewLinkImageFrameLayout.setVisibility(View.GONE);
+ ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.GONE);
((PostCompactBaseViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactBaseViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
((PostCompactBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
@@ -2493,8 +2503,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
ProgressBar progressBar;
ImageView imageView;
ImageView playButtonImageView;
- FrameLayout noPreviewLinkImageFrameLayout;
- ImageView noPreviewLinkImageView;
+ FrameLayout noPreviewPostImageFrameLayout;
+ ImageView noPreviewPostImageView;
Barrier imageBarrier;
ConstraintLayout bottomConstraintLayout;
ImageView upvoteButton;
@@ -2544,8 +2554,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
this.progressBar = progressBar;
this.imageView = imageView;
this.playButtonImageView = playButtonImageView;
- this.noPreviewLinkImageFrameLayout = noPreviewLinkImageFrameLayout;
- this.noPreviewLinkImageView = noPreviewLinkImageView;
+ this.noPreviewPostImageFrameLayout = noPreviewLinkImageFrameLayout;
+ this.noPreviewPostImageView = noPreviewLinkImageView;
this.imageBarrier = imageBarrier;
this.bottomConstraintLayout = bottomConstraintLayout;
this.upvoteButton = upvoteButton;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeOnlyDisablePreviewInVideoAndGifPostsEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeOnlyDisablePreviewInVideoAndGifPostsEvent.java
new file mode 100644
index 00000000..a383099f
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeOnlyDisablePreviewInVideoAndGifPostsEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class ChangeOnlyDisablePreviewInVideoAndGifPostsEvent {
+ public boolean onlyDisablePreviewInVideoAndGifPosts;
+
+ public ChangeOnlyDisablePreviewInVideoAndGifPostsEvent(boolean onlyDisablePreviewInVideoAndGifPosts) {
+ this.onlyDisablePreviewInVideoAndGifPosts = onlyDisablePreviewInVideoAndGifPosts;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index bf2bdd6b..5f64e1e1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -88,6 +88,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeMuteAutoplayingVideosEv
import ml.docilealligator.infinityforreddit.events.ChangeMuteNSFWVideoEvent;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.events.ChangeNetworkStatusEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeOnlyDisablePreviewInVideoAndGifPostsEvent;
import ml.docilealligator.infinityforreddit.events.ChangePostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeSavePostFeedScrolledPositionEvent;
import ml.docilealligator.infinityforreddit.events.ChangeShowAbsoluteNumberOfVotesEvent;
@@ -1552,6 +1553,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Subscribe
+ public void onChangeOnlyDisablePreviewInVideoAndGifPostsEvent(ChangeOnlyDisablePreviewInVideoAndGifPostsEvent changeOnlyDisablePreviewInVideoAndGifPostsEvent) {
+ if (mAdapter != null) {
+ mAdapter.setOnlyDisablePreviewInVideoPosts(changeOnlyDisablePreviewInVideoAndGifPostsEvent.onlyDisablePreviewInVideoAndGifPosts);
+ refreshAdapter();
+ }
+ }
+
+ @Subscribe
public void onChangeSwipeActionEvent(ChangeSwipeActionEvent changeSwipeActionEvent) {
swipeRightAction = changeSwipeActionEvent.swipeRightAction == -1 ? swipeRightAction : changeSwipeActionEvent.swipeRightAction;
swipeLeftAction = changeSwipeActionEvent.swipeLeftAction == -1 ? swipeLeftAction : changeSwipeActionEvent.swipeLeftAction;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java
index 652e737f..84377724 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java
@@ -8,9 +8,10 @@ import androidx.preference.SwitchPreference;
import org.greenrobot.eventbus.EventBus;
+import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.events.ChangeDataSavingModeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDisableImagePreviewEvent;
-import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.events.ChangeOnlyDisablePreviewInVideoAndGifPostsEvent;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class DataSavingModePreferenceFragment extends PreferenceFragmentCompat {
@@ -21,6 +22,7 @@ public class DataSavingModePreferenceFragment extends PreferenceFragmentCompat {
ListPreference dataSavingModeListPreference = findPreference(SharedPreferencesUtils.DATA_SAVING_MODE);
SwitchPreference disableImagePreviewPreference = findPreference(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW);
+ SwitchPreference onlyDisablePreviewInVideoAndGifPostsPreference = findPreference(SharedPreferencesUtils.ONLY_DISABLE_PREVIEW_IN_VIDEO_AND_GIF_POSTS);
if (dataSavingModeListPreference != null) {
dataSavingModeListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
@@ -35,5 +37,12 @@ public class DataSavingModePreferenceFragment extends PreferenceFragmentCompat {
return true;
});
}
+
+ if (onlyDisablePreviewInVideoAndGifPostsPreference != null) {
+ onlyDisablePreviewInVideoAndGifPostsPreference.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeOnlyDisablePreviewInVideoAndGifPostsEvent((Boolean) newValue));
+ return true;
+ });
+ }
}
} \ No newline at end of file
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 8cfd5ce5..c288bb15 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -149,6 +149,7 @@ public class SharedPreferencesUtils {
public static final String LANGUAGE_DEFAULT_VALUE = "auto";
public static final String ENABLE_SEARCH_HISTORY = "enable_search_history";
public static final String POST_FILTER = "post_filter";
+ public static final String ONLY_DISABLE_PREVIEW_IN_VIDEO_AND_GIF_POSTS = "only_disable_preview_in_video_and_gif_posts";
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/strings.xml b/app/src/main/res/values/strings.xml
index aebcb892..ae44cf19 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,7 +1,7 @@
<resources>
<string name="application_name" translatable="false">Infinity</string>
<string name="login_activity_label">Login</string>
- <string name="search_activity_label">Search</string>
+ <string name="search_activity_label" translatable="false"> </string>
<string name="comment_activity_label">Send Comment</string>
<string name="comment_activity_label_is_replying">Reply</string>
<string name="post_text_activity_label">Text Post</string>
@@ -517,6 +517,7 @@
<string name="settings_credits_ufo_capturing_animation_title">UFO Capturing Animation</string>
<string name="settings_hide_subreddit_description_title">Hide Subreddit Description</string>
<string name="settings_disable_image_preview_title">Disable Image Preview in Data Saving Mode</string>
+ <string name="settings_only_disable_preview_in_video_and_gif_posts_title">Only Disable Preview in Video and Gif Posts</string>
<string name="settings_swipe_action_swipe_left_title">Swipe Left</string>
<string name="settings_swipe_action_swipe_right_title">Swipe Right</string>
<string name="settings_swipe_action_info_summary">Not applicable to post feed with more than 1 column or post detail.</string>
diff --git a/app/src/main/res/xml/data_saving_mode_preferences.xml b/app/src/main/res/xml/data_saving_mode_preferences.xml
index e635f2db..6ff3f04a 100644
--- a/app/src/main/res/xml/data_saving_mode_preferences.xml
+++ b/app/src/main/res/xml/data_saving_mode_preferences.xml
@@ -20,4 +20,9 @@
app:key="disable_image_preview"
android:title="@string/settings_disable_image_preview_title" />
+ <SwitchPreference
+ app:defaultValue="false"
+ app:key="only_disable_preview_in_video_and_gif_posts"
+ android:title="@string/settings_only_disable_preview_in_video_and_gif_posts_title" />
+
</PreferenceScreen> \ No newline at end of file