aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/DownloadLocationPreferenceFragment.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java4
5 files changed, 18 insertions, 12 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java
index d811ddf0..b27c6f09 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java
@@ -465,7 +465,7 @@ public class DownloadMediaService extends Service {
}
private String getDownloadLocation(int mediaType, boolean isNsfw) {
- if (isNsfw && mSharedPreferences.getBoolean(SharedPreferencesUtils.SEPARATE_NSFW_FOLDER, false)) {
+ if (isNsfw && mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_NSFW_MEDIA_IN_DIFFERENT_FOLDER, false)) {
return mSharedPreferences.getString(SharedPreferencesUtils.NSFW_DOWNLOAD_LOCATION, "");
}
switch (mediaType) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java
index 5a7dcef9..eebbf8ea 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java
@@ -144,7 +144,7 @@ public class DownloadRedditVideoService extends Service {
if (videoResponse.isSuccessful() && videoResponse.body() != null) {
String externalCacheDirectoryPath = externalCacheDirectory.getAbsolutePath() + "/";
String destinationFileDirectory;
- if (isNsfw && sharedPreferences.getBoolean(SharedPreferencesUtils.SEPARATE_NSFW_FOLDER, false)) {
+ if (isNsfw && sharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_NSFW_MEDIA_IN_DIFFERENT_FOLDER, false)) {
destinationFileDirectory = sharedPreferences.getString(SharedPreferencesUtils.NSFW_DOWNLOAD_LOCATION, "");
} else {
destinationFileDirectory = sharedPreferences.getString(SharedPreferencesUtils.VIDEO_DOWNLOAD_LOCATION, "");
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 915438a6..045f356b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DataSavingModePreferenceFragment.java
@@ -28,27 +28,27 @@ public class DataSavingModePreferenceFragment extends PreferenceFragmentCompat {
if (dataSavingModeListPreference != null) {
if (dataSavingModeListPreference.getValue().equals("0")) {
if (onlyDisablePreviewInVideoAndGifPostsPreference != null) {
- onlyDisablePreviewInVideoAndGifPostsPreference.setEnabled(false);
+ onlyDisablePreviewInVideoAndGifPostsPreference.setVisible(false);
}
if (disableImagePreviewPreference != null) {
- disableImagePreviewPreference.setEnabled(false);
+ disableImagePreviewPreference.setVisible(false);
}
}
dataSavingModeListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeDataSavingModeEvent((String) newValue));
if (newValue.equals("0")) {
if (onlyDisablePreviewInVideoAndGifPostsPreference != null) {
- onlyDisablePreviewInVideoAndGifPostsPreference.setEnabled(false);
+ onlyDisablePreviewInVideoAndGifPostsPreference.setVisible(false);
}
if (disableImagePreviewPreference != null) {
- disableImagePreviewPreference.setEnabled(false);
+ disableImagePreviewPreference.setVisible(false);
}
} else {
if (onlyDisablePreviewInVideoAndGifPostsPreference != null) {
- onlyDisablePreviewInVideoAndGifPostsPreference.setEnabled(true);
+ onlyDisablePreviewInVideoAndGifPostsPreference.setVisible(true);
}
if (disableImagePreviewPreference != null) {
- disableImagePreviewPreference.setEnabled(true);
+ disableImagePreviewPreference.setVisible(true);
}
}
return true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DownloadLocationPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DownloadLocationPreferenceFragment.java
index 331f7de6..6bfb459e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DownloadLocationPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DownloadLocationPreferenceFragment.java
@@ -1,5 +1,7 @@
package ml.docilealligator.infinityforreddit.settings;
+import static android.content.Intent.ACTION_OPEN_DOCUMENT_TREE;
+
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -18,8 +20,6 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
-import static android.content.Intent.ACTION_OPEN_DOCUMENT_TREE;
-
public class DownloadLocationPreferenceFragment extends PreferenceFragmentCompat {
private static final int IMAGE_DOWNLOAD_LOCATION_REQUEST_CODE = 10;
private static final int GIF_DOWNLOAD_LOCATION_REQUEST_CODE = 11;
@@ -122,6 +122,12 @@ public class DownloadLocationPreferenceFragment extends PreferenceFragmentCompat
if (videoDownloadLocationPreference != null) {
videoDownloadLocationPreference.setSummary(data.getDataString());
}
+ } else if (requestCode == NSFW_DOWNLOAD_LOCATION_REQUEST_CODE) {
+ activity.getContentResolver().takePersistableUriPermission(data.getData(), Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
+ sharedPreferences.edit().putString(SharedPreferencesUtils.NSFW_DOWNLOAD_LOCATION, data.getDataString()).apply();
+ if (nsfwDownloadLocationPreference != null) {
+ nsfwDownloadLocationPreference.setSummary(data.getDataString());
+ }
}
}
}
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 6ee508c5..296fc651 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -130,9 +130,9 @@ public class SharedPreferencesUtils {
public static final String IMAGE_DOWNLOAD_LOCATION = "image_download_location";
public static final String GIF_DOWNLOAD_LOCATION = "gif_download_location";
public static final String VIDEO_DOWNLOAD_LOCATION = "video_download_location";
- public static final String NSFW_DOWNLOAD_LOCATION = "nsfw_download_location";
- public static final String SEPARATE_NSFW_FOLDER = "separate_nsfw_folder";
public static final String SEPARATE_FOLDER_FOR_EACH_SUBREDDIT = "separate_folder_for_each_subreddit";
+ public static final String SAVE_NSFW_MEDIA_IN_DIFFERENT_FOLDER = "save_nsfw_media_in_different_folder";
+ public static final String NSFW_DOWNLOAD_LOCATION = "nsfw_download_location";
public static final String VIBRATE_WHEN_ACTION_TRIGGERED = "vibrate_when_action_triggered";
public static final String DISABLE_SWIPING_BETWEEN_TABS = "disable_swiping_between_tabs";
public static final String ENABLE_SWIPE_ACTION = "enable_swipe_action";