diff options
author | MetalNeo <53447663+MetalNeo@users.noreply.github.com> | 2021-12-20 13:13:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-20 13:13:08 +0000 |
commit | 34127032de45b6f860d998daf3adfebcb029e0fc (patch) | |
tree | d8f896a200b5eb60cb3ff74a17370eefe883a34b /app/src | |
parent | 21e7dad1b04f7b1753aa50efc2cf760568c9595f (diff) | |
download | infinity-for-reddit-34127032de45b6f860d998daf3adfebcb029e0fc.tar infinity-for-reddit-34127032de45b6f860d998daf3adfebcb029e0fc.tar.gz infinity-for-reddit-34127032de45b6f860d998daf3adfebcb029e0fc.tar.bz2 infinity-for-reddit-34127032de45b6f860d998daf3adfebcb029e0fc.tar.lz infinity-for-reddit-34127032de45b6f860d998daf3adfebcb029e0fc.tar.xz infinity-for-reddit-34127032de45b6f860d998daf3adfebcb029e0fc.tar.zst infinity-for-reddit-34127032de45b6f860d998daf3adfebcb029e0fc.zip |
Added Setting for Separate NSFW Download Folder (#584)
Add an option to separate NSFW media downloads
Diffstat (limited to '')
12 files changed, 66 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java index 4e303c29..0c105691 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java @@ -83,6 +83,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa public static final String EXTRA_FILE_NAME_KEY = "EFNK"; public static final String EXTRA_SUBREDDIT_OR_USERNAME_KEY = "ESOUK"; public static final String EXTRA_POST_TITLE_KEY = "EPTK"; + public static final String EXTRA_IS_NSFW = "EIN"; private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0; @BindView(R.id.progress_bar_view_image_or_gif_activity) ProgressBar mProgressBar; @@ -112,6 +113,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa private String mImageFileName; private String mSubredditName; private boolean isGif = true; + private boolean isNsfw; @Override protected void onCreate(Bundle savedInstanceState) { @@ -165,6 +167,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa mImageFileName = intent.getStringExtra(EXTRA_FILE_NAME_KEY); String postTitle = intent.getStringExtra(EXTRA_POST_TITLE_KEY); mSubredditName = intent.getStringExtra(EXTRA_SUBREDDIT_OR_USERNAME_KEY); + isNsfw = intent.getBooleanExtra(EXTRA_IS_NSFW, false); boolean useBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_BOTTOM_TOOLBAR_IN_MEDIA_VIEWER, false); if (postTitle != null) { @@ -368,6 +371,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, isGif ? DownloadMediaService.EXTRA_MEDIA_TYPE_GIF : DownloadMediaService.EXTRA_MEDIA_TYPE_IMAGE); intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, mImageFileName); intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, mSubredditName); + intent.putExtra(DownloadMediaService.EXTRA_IS_NSFW, isNsfw); ContextCompat.startForegroundService(this, intent); Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java index 753c2767..659ff7a8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java @@ -57,6 +57,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA public static final String EXTRA_REDDIT_GALLERY = "ERG"; public static final String EXTRA_SUBREDDIT_NAME = "ESN"; + public static final String EXTRA_IS_NSFW = "EIN"; @BindView(R.id.hauler_view_view_reddit_gallery_activity) HaulerView haulerView; @@ -70,6 +71,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA private SectionsPagerAdapter sectionsPagerAdapter; private ArrayList<Post.Gallery> gallery; private String subredditName; + private boolean isNsfw; private boolean useBottomAppBar; @Override @@ -155,6 +157,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA return; } subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); + isNsfw = getIntent().getBooleanExtra(EXTRA_IS_NSFW, false); if (sharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_VERTICALLY_TO_GO_BACK_FROM_MEDIA, true)) { haulerView.setOnDragDismissedListener(dragDirection -> { @@ -290,6 +293,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA bundle.putString(ViewRedditGalleryVideoFragment.EXTRA_SUBREDDIT_NAME, subredditName); bundle.putInt(ViewRedditGalleryVideoFragment.EXTRA_INDEX, position); bundle.putInt(ViewRedditGalleryVideoFragment.EXTRA_MEDIA_COUNT, gallery.size()); + bundle.putBoolean(ViewRedditGalleryVideoFragment.EXTRA_IS_NSFW, isNsfw); fragment.setArguments(bundle); return fragment; } else { @@ -299,6 +303,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA bundle.putString(ViewRedditGalleryImageOrGifFragment.EXTRA_SUBREDDIT_NAME, subredditName); bundle.putInt(ViewRedditGalleryImageOrGifFragment.EXTRA_INDEX, position); bundle.putInt(ViewRedditGalleryImageOrGifFragment.EXTRA_MEDIA_COUNT, gallery.size()); + bundle.putBoolean(ViewRedditGalleryImageOrGifFragment.EXTRA_IS_NSFW, false); fragment.setArguments(bundle); return fragment; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index 93c9649e..2727e40a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -895,11 +895,13 @@ public class ViewVideoActivity extends AppCompatActivity { intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_VIDEO); intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, videoFileName); intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, subredditName); + intent.putExtra(DownloadMediaService.EXTRA_IS_NSFW, isNSFW); } else { intent = new Intent(this, DownloadRedditVideoService.class); intent.putExtra(DownloadRedditVideoService.EXTRA_VIDEO_URL, videoDownloadUrl); intent.putExtra(DownloadRedditVideoService.EXTRA_POST_ID, id); intent.putExtra(DownloadRedditVideoService.EXTRA_SUBREDDIT, subredditName); + intent.putExtra(DownloadRedditVideoService.EXTRA_IS_NSFW, isNSFW); } ContextCompat.startForegroundService(this, intent); Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show(); 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 edd0ee82..eb2dd24e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -1968,6 +1968,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie + "-" + post.getId() + ".jpg"); intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, post.getTitle()); intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, post.getSubredditName()); + intent.putExtra(ViewImageOrGifActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); } else if (post.getPostType() == Post.GIF_TYPE) { Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class); @@ -1976,6 +1977,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie intent.putExtra(ViewImageOrGifActivity.EXTRA_GIF_URL_KEY, post.getVideoUrl()); intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, post.getTitle()); intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, post.getSubredditName()); + intent.putExtra(ViewImageOrGifActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); } else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) { Intent intent = new Intent(mActivity, LinkResolverActivity.class); @@ -1987,6 +1989,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class); intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, post.getGallery()); intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, post.getSubredditName()); + intent.putExtra(ViewRedditGalleryActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java index cc3110ea..1333d7c1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java @@ -75,6 +75,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { public static final String EXTRA_SUBREDDIT_NAME = "ESN"; public static final String EXTRA_INDEX = "EI"; public static final String EXTRA_MEDIA_COUNT = "EMC"; + public static final String EXTRA_IS_NSFW = "EIN"; private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0; @BindView(R.id.progress_bar_view_reddit_gallery_image_or_gif_fragment) @@ -108,6 +109,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { private RequestManager glide; private Post.Gallery media; private String subredditName; + private boolean isNsfw; private boolean isDownloading = false; private boolean isActionBarHidden = false; private boolean isUseBottomCaption = false; @@ -132,6 +134,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { media = getArguments().getParcelable(EXTRA_REDDIT_GALLERY_MEDIA); subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME); + isNsfw = getArguments().getBoolean(EXTRA_IS_NSFW, false); glide = Glide.with(activity); imageView.setImageViewFactory(new GlideImageViewFactory()); @@ -398,6 +401,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, media.mediaType == Post.Gallery.TYPE_GIF ? DownloadMediaService.EXTRA_MEDIA_TYPE_GIF: DownloadMediaService.EXTRA_MEDIA_TYPE_IMAGE); intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, media.fileName); intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, subredditName); + intent.putExtra(DownloadMediaService.EXTRA_IS_NSFW, isNsfw); ContextCompat.startForegroundService(activity, intent); Toast.makeText(activity, R.string.download_started, Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java index 2946d193..343905c7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java @@ -62,6 +62,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment { public static final String EXTRA_SUBREDDIT_NAME = "ESN"; public static final String EXTRA_INDEX = "EI"; public static final String EXTRA_MEDIA_COUNT = "EMC"; + public static final String EXTRA_IS_NSFW = "EIN"; private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0; private static final String IS_MUTE_STATE = "IMS"; private static final String POSITION_STATE = "PS"; @@ -79,6 +80,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment { private ViewRedditGalleryActivity activity; private Post.Gallery galleryVideo; private String subredditName; + private boolean isNsfw; private SimpleExoPlayer player; private DataSource.Factory dataSourceFactory; private boolean wasPlaying = false; @@ -109,6 +111,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment { galleryVideo = getArguments().getParcelable(EXTRA_REDDIT_GALLERY_VIDEO); subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME); + isNsfw = getArguments().getBoolean(EXTRA_IS_NSFW, false); if (!mSharedPreferences.getBoolean(SharedPreferencesUtils.VIDEO_PLAYER_IGNORE_NAV_BAR, false)) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || getResources().getBoolean(R.bool.isTablet)) { @@ -242,6 +245,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment { intent.putExtra(DownloadMediaService.EXTRA_MEDIA_TYPE, DownloadMediaService.EXTRA_MEDIA_TYPE_VIDEO); intent.putExtra(DownloadMediaService.EXTRA_FILE_NAME, galleryVideo.fileName); intent.putExtra(DownloadMediaService.EXTRA_SUBREDDIT_NAME, subredditName); + intent.putExtra(DownloadMediaService.EXTRA_IS_NSFW, isNsfw); ContextCompat.startForegroundService(activity, intent); Toast.makeText(activity, R.string.download_started, Toast.LENGTH_SHORT).show(); } 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 f0a551fe..d811ddf0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java @@ -57,6 +57,7 @@ public class DownloadMediaService extends Service { public static final String EXTRA_FILE_NAME = "EFN"; public static final String EXTRA_SUBREDDIT_NAME = "ESN"; public static final String EXTRA_MEDIA_TYPE = "EIG"; + public static final String EXTRA_IS_NSFW = "EIN"; public static final int EXTRA_MEDIA_TYPE_IMAGE = 0; public static final int EXTRA_MEDIA_TYPE_GIF = 1; public static final int EXTRA_MEDIA_TYPE_VIDEO = 2; @@ -101,6 +102,7 @@ public class DownloadMediaService extends Service { String fileName = intent.getString(EXTRA_FILE_NAME); String subredditName = intent.getString(EXTRA_SUBREDDIT_NAME); int mediaType = intent.getInt(EXTRA_MEDIA_TYPE, EXTRA_MEDIA_TYPE_IMAGE); + boolean isNsfw = intent.getBoolean(EXTRA_IS_NSFW, false); String mimeType = mediaType == EXTRA_MEDIA_TYPE_VIDEO ? "video/*" : "image/*"; final DownloadProgressResponseBody.ProgressListener progressListener = new DownloadProgressResponseBody.ProgressListener() { @@ -139,7 +141,7 @@ public class DownloadMediaService extends Service { try { response = retrofit.create(DownloadFile.class).downloadFile(fileUrl).execute(); if (response.isSuccessful() && response.body() != null) { - String destinationFileDirectory = getDownloadLocation(mediaType); + String destinationFileDirectory = getDownloadLocation(mediaType, isNsfw); if (destinationFileDirectory.equals("")) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { File directory = getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); @@ -462,7 +464,10 @@ public class DownloadMediaService extends Service { } } - private String getDownloadLocation(int mediaType) { + private String getDownloadLocation(int mediaType, boolean isNsfw) { + if (isNsfw && mSharedPreferences.getBoolean(SharedPreferencesUtils.SEPARATE_NSFW_FOLDER, false)) { + return mSharedPreferences.getString(SharedPreferencesUtils.NSFW_DOWNLOAD_LOCATION, ""); + } switch (mediaType) { case EXTRA_MEDIA_TYPE_GIF: return mSharedPreferences.getString(SharedPreferencesUtils.GIF_DOWNLOAD_LOCATION, ""); 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 2079e024..5a7dcef9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java @@ -63,6 +63,7 @@ public class DownloadRedditVideoService extends Service { public static final String EXTRA_VIDEO_URL = "EVU"; public static final String EXTRA_SUBREDDIT = "ES"; public static final String EXTRA_POST_ID = "EPI"; + public static final String EXTRA_IS_NSFW = "EIN"; private static final int NO_ERROR = -1; private static final int ERROR_CANNOT_GET_CACHE_DIRECTORY = 0; @@ -99,6 +100,7 @@ public class DownloadRedditVideoService extends Service { String audioUrl = videoUrl.substring(0, videoUrl.lastIndexOf('/')) + "/DASH_audio.mp4"; String subredditName = intent.getString(EXTRA_SUBREDDIT); String fileNameWithoutExtension = subredditName + "-" + intent.getString(EXTRA_POST_ID); + boolean isNsfw = intent.getBoolean(EXTRA_IS_NSFW, false); int randomNotificationIdOffset = msg.arg1; final DownloadProgressResponseBody.ProgressListener progressListener = new DownloadProgressResponseBody.ProgressListener() { @@ -141,7 +143,12 @@ public class DownloadRedditVideoService extends Service { Response<ResponseBody> videoResponse = downloadFile.downloadFile(videoUrl).execute(); if (videoResponse.isSuccessful() && videoResponse.body() != null) { String externalCacheDirectoryPath = externalCacheDirectory.getAbsolutePath() + "/"; - String destinationFileDirectory = sharedPreferences.getString(SharedPreferencesUtils.VIDEO_DOWNLOAD_LOCATION, ""); + String destinationFileDirectory; + if (isNsfw && sharedPreferences.getBoolean(SharedPreferencesUtils.SEPARATE_NSFW_FOLDER, false)) { + destinationFileDirectory = sharedPreferences.getString(SharedPreferencesUtils.NSFW_DOWNLOAD_LOCATION, ""); + } else { + destinationFileDirectory = sharedPreferences.getString(SharedPreferencesUtils.VIDEO_DOWNLOAD_LOCATION, ""); + } String destinationFileUriString; boolean isDefaultDestination; if (destinationFileDirectory.equals("")) { 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 633cd581..331f7de6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DownloadLocationPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/DownloadLocationPreferenceFragment.java @@ -24,10 +24,12 @@ 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; private static final int VIDEO_DOWNLOAD_LOCATION_REQUEST_CODE = 12; + private static final int NSFW_DOWNLOAD_LOCATION_REQUEST_CODE = 13; Preference imageDownloadLocationPreference; Preference gifDownloadLocationPreference; Preference videoDownloadLocationPreference; + Preference nsfwDownloadLocationPreference; private Activity activity; @Inject @Named("default") @@ -40,7 +42,21 @@ public class DownloadLocationPreferenceFragment extends PreferenceFragmentCompat imageDownloadLocationPreference = findPreference(SharedPreferencesUtils.IMAGE_DOWNLOAD_LOCATION); gifDownloadLocationPreference = findPreference(SharedPreferencesUtils.GIF_DOWNLOAD_LOCATION); videoDownloadLocationPreference = findPreference(SharedPreferencesUtils.VIDEO_DOWNLOAD_LOCATION); + nsfwDownloadLocationPreference = findPreference(SharedPreferencesUtils.NSFW_DOWNLOAD_LOCATION); + if (nsfwDownloadLocationPreference != null) { + String downloadLocation = sharedPreferences.getString(SharedPreferencesUtils.NSFW_DOWNLOAD_LOCATION, ""); + if (!downloadLocation.equals("")) { + nsfwDownloadLocationPreference.setSummary(downloadLocation); + } + + nsfwDownloadLocationPreference.setOnPreferenceClickListener(preference -> { + Intent intent = new Intent(ACTION_OPEN_DOCUMENT_TREE); + intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + startActivityForResult(intent, NSFW_DOWNLOAD_LOCATION_REQUEST_CODE); + return true; + }); + } if (imageDownloadLocationPreference != null) { String downloadLocation = sharedPreferences.getString(SharedPreferencesUtils.IMAGE_DOWNLOAD_LOCATION, ""); if (!downloadLocation.equals("")) { 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 285c8d58..6ee508c5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -130,6 +130,8 @@ 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 VIBRATE_WHEN_ACTION_TRIGGERED = "vibrate_when_action_triggered"; public static final String DISABLE_SWIPING_BETWEEN_TABS = "disable_swiping_between_tabs"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ded35ce5..6d795c87 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -516,6 +516,8 @@ <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_swipe_action_title">Swipe Action</string> <string name="settings_swipe_action_haptic_feedback_title">Haptic Feedback</string> diff --git a/app/src/main/res/xml/download_location_preferences.xml b/app/src/main/res/xml/download_location_preferences.xml index e8215fe9..4e2c1f7a 100644 --- a/app/src/main/res/xml/download_location_preferences.xml +++ b/app/src/main/res/xml/download_location_preferences.xml @@ -11,6 +11,15 @@ 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" /> + <SwitchPreference app:defaultValue="false" app:key="separate_folder_for_each_subreddit" |