diff options
Diffstat (limited to 'app/src/main')
7 files changed, 33 insertions, 22 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"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6d795c87..093c6213 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -516,9 +516,10 @@ <string name="settings_image_download_location_title">Image Download Location</string> <string name="settings_gif_download_location_title">Gif Download Location</string> <string name="settings_video_download_location_title">Video Download Location</string> - <string name="settings_nsfw_download_location_title">NSFW Download Location</string> - <string name="settings_nsfw_separate_folder">Separate Folder for NSFW Posts</string> <string name="settings_separate_folder_for_each_subreddit">Separate Folder for Each Subreddit</string> + <string name="settings_save_nsfw_media_in_different_folder_title">Save NSFW Media in Different Location</string> + <string name="settings_save_nsfw_media_in_different_folder_summary">Does not separate folder for NSFW media from different subreddits even if Separate Folder for Each Subreddit is enabled.</string> + <string name="settings_nsfw_download_location_title">NSFW Download Location</string> <string name="settings_swipe_action_title">Swipe Action</string> <string name="settings_swipe_action_haptic_feedback_title">Haptic Feedback</string> <string name="settings_disable_swiping_between_tabs_title">Disable Swiping Between Tabs</string> diff --git a/app/src/main/res/xml/download_location_preferences.xml b/app/src/main/res/xml/download_location_preferences.xml index 4e2c1f7a..3de56ef3 100644 --- a/app/src/main/res/xml/download_location_preferences.xml +++ b/app/src/main/res/xml/download_location_preferences.xml @@ -11,17 +11,21 @@ app:key="video_download_location" app:title="@string/settings_video_download_location_title" /> - <Preference - app:key="nsfw_download_location" - app:title="@string/settings_nsfw_download_location_title" /> - <SwitchPreference app:defaultValue="false" - app:key="separate_nsfw_folder" - app:title="@string/settings_nsfw_separate_folder" /> + app:key="separate_folder_for_each_subreddit" + app:title="@string/settings_separate_folder_for_each_subreddit" /> + + <PreferenceCategory + app:title="@string/nsfw" /> <SwitchPreference app:defaultValue="false" - app:key="separate_folder_for_each_subreddit" - app:title="@string/settings_separate_folder_for_each_subreddit" /> + app:key="save_nsfw_media_in_different_folder" + app:title="@string/settings_save_nsfw_media_in_different_folder_title" + app:summary="@string/settings_save_nsfw_media_in_different_folder_summary" /> + + <Preference + app:key="nsfw_download_location" + app:title="@string/settings_nsfw_download_location_title" /> </PreferenceScreen>
\ No newline at end of file |