aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorscria1000 <91804886+scria1000@users.noreply.github.com>2021-12-20 13:21:26 +0000
committerGitHub <noreply@github.com>2021-12-20 13:21:26 +0000
commit7150ac69815a34011a3c92f2adf75baa5bf76c65 (patch)
tree08bea12806141f2a6a8cc1d8564224e72dcf1e03 /app/src/main/java/ml/docilealligator/infinityforreddit
parenta7b58cf0a410a1670aa9230cab4d05938caf6648 (diff)
downloadinfinity-for-reddit-7150ac69815a34011a3c92f2adf75baa5bf76c65.tar
infinity-for-reddit-7150ac69815a34011a3c92f2adf75baa5bf76c65.tar.gz
infinity-for-reddit-7150ac69815a34011a3c92f2adf75baa5bf76c65.tar.bz2
infinity-for-reddit-7150ac69815a34011a3c92f2adf75baa5bf76c65.tar.lz
infinity-for-reddit-7150ac69815a34011a3c92f2adf75baa5bf76c65.tar.xz
infinity-for-reddit-7150ac69815a34011a3c92f2adf75baa5bf76c65.tar.zst
infinity-for-reddit-7150ac69815a34011a3c92f2adf75baa5bf76c65.zip
Mutually exclusive toggling behaviour for DataSavingMode (#603)
Mutually exclusive toggling behavior for DataSavingMode.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java38
1 files changed, 37 insertions, 1 deletions
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 84377724..915438a6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java
@@ -24,9 +24,33 @@ public class DataSavingModePreferenceFragment extends PreferenceFragmentCompat {
SwitchPreference disableImagePreviewPreference = findPreference(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW);
SwitchPreference onlyDisablePreviewInVideoAndGifPostsPreference = findPreference(SharedPreferencesUtils.ONLY_DISABLE_PREVIEW_IN_VIDEO_AND_GIF_POSTS);
+
if (dataSavingModeListPreference != null) {
+ if (dataSavingModeListPreference.getValue().equals("0")) {
+ if (onlyDisablePreviewInVideoAndGifPostsPreference != null) {
+ onlyDisablePreviewInVideoAndGifPostsPreference.setEnabled(false);
+ }
+ if (disableImagePreviewPreference != null) {
+ disableImagePreviewPreference.setEnabled(false);
+ }
+ }
dataSavingModeListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeDataSavingModeEvent((String) newValue));
+ if (newValue.equals("0")) {
+ if (onlyDisablePreviewInVideoAndGifPostsPreference != null) {
+ onlyDisablePreviewInVideoAndGifPostsPreference.setEnabled(false);
+ }
+ if (disableImagePreviewPreference != null) {
+ disableImagePreviewPreference.setEnabled(false);
+ }
+ } else {
+ if (onlyDisablePreviewInVideoAndGifPostsPreference != null) {
+ onlyDisablePreviewInVideoAndGifPostsPreference.setEnabled(true);
+ }
+ if (disableImagePreviewPreference != null) {
+ disableImagePreviewPreference.setEnabled(true);
+ }
+ }
return true;
});
}
@@ -34,6 +58,12 @@ public class DataSavingModePreferenceFragment extends PreferenceFragmentCompat {
if (disableImagePreviewPreference != null) {
disableImagePreviewPreference.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeDisableImagePreviewEvent((Boolean) newValue));
+ if ((Boolean) newValue) {
+ EventBus.getDefault().post(new ChangeOnlyDisablePreviewInVideoAndGifPostsEvent(false));
+ if (onlyDisablePreviewInVideoAndGifPostsPreference != null) {
+ onlyDisablePreviewInVideoAndGifPostsPreference.setChecked(false);
+ }
+ }
return true;
});
}
@@ -41,8 +71,14 @@ public class DataSavingModePreferenceFragment extends PreferenceFragmentCompat {
if (onlyDisablePreviewInVideoAndGifPostsPreference != null) {
onlyDisablePreviewInVideoAndGifPostsPreference.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeOnlyDisablePreviewInVideoAndGifPostsEvent((Boolean) newValue));
+ if ((Boolean) newValue) {
+ EventBus.getDefault().post(new ChangeDisableImagePreviewEvent(false));
+ if (disableImagePreviewPreference != null) {
+ disableImagePreviewPreference.setChecked(false);
+ }
+ }
return true;
});
}
}
-} \ No newline at end of file
+}