aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-07-30 16:04:57 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-07-30 16:04:57 +0000
commit109b4be8c3002df503f86ac94d57f1a1be005cec (patch)
treef0c79236daf0a71399c3a0fc2f572e403bf404c4 /app/src/main/java
parent61d3302a309c888d4a0718ded3b83518f10d3630 (diff)
downloadinfinity-for-reddit-109b4be8c3002df503f86ac94d57f1a1be005cec.tar
infinity-for-reddit-109b4be8c3002df503f86ac94d57f1a1be005cec.tar.gz
infinity-for-reddit-109b4be8c3002df503f86ac94d57f1a1be005cec.tar.bz2
infinity-for-reddit-109b4be8c3002df503f86ac94d57f1a1be005cec.tar.lz
infinity-for-reddit-109b4be8c3002df503f86ac94d57f1a1be005cec.tar.xz
infinity-for-reddit-109b4be8c3002df503f86ac94d57f1a1be005cec.tar.zst
infinity-for-reddit-109b4be8c3002df503f86ac94d57f1a1be005cec.zip
Add an option to delete all the post feed scrolled positions.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AdvancedPreferenceFragment.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java1
2 files changed, 20 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AdvancedPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AdvancedPreferenceFragment.java
index de92c7fe..43779da2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AdvancedPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AdvancedPreferenceFragment.java
@@ -53,6 +53,9 @@ public class AdvancedPreferenceFragment extends PreferenceFragmentCompat {
@Named("dark_theme")
SharedPreferences darkThemeSharedPreferences;
@Inject
+ @Named("post_feed_scrolled_position_cache")
+ SharedPreferences postFeedScrolledPositionSharedPreferences;
+ @Inject
@Named("amoled_theme")
SharedPreferences amoledThemeSharedPreferences;
private Activity activity;
@@ -68,6 +71,7 @@ public class AdvancedPreferenceFragment extends PreferenceFragmentCompat {
Preference deleteSortTypePreference = findPreference(SharedPreferencesUtils.DELETE_ALL_SORT_TYPE_DATA_IN_DATABASE);
Preference deletePostLaoutPreference = findPreference(SharedPreferencesUtils.DELETE_ALL_POST_LAYOUT_DATA_IN_DATABASE);
Preference deleteAllThemesPreference = findPreference(SharedPreferencesUtils.DELETE_ALL_THEMES_IN_DATABASE);
+ Preference deletePostFeedScrolledPositionsPreference = findPreference(SharedPreferencesUtils.DELETE_POST_FEED_SCROLLED_POSITIONS_IN_DATABASE);
Preference resetAllSettingsPreference = findPreference(SharedPreferencesUtils.RESET_ALL_SETTINGS);
if (deleteSubredditsPreference != null) {
@@ -142,6 +146,21 @@ public class AdvancedPreferenceFragment extends PreferenceFragmentCompat {
});
}
+ if (deletePostFeedScrolledPositionsPreference != null) {
+ deletePostFeedScrolledPositionsPreference.setOnPreferenceClickListener(preference -> {
+ new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.are_you_sure)
+ .setPositiveButton(R.string.yes, (dialogInterface, i)
+ -> {
+ postFeedScrolledPositionSharedPreferences.edit().clear().apply();
+ Toast.makeText(activity, R.string.delete_all_post_feed_scrolled_positions_success, Toast.LENGTH_SHORT).show();
+ })
+ .setNegativeButton(R.string.no, null)
+ .show();
+ return true;
+ });
+ }
+
if (resetAllSettingsPreference != null) {
resetAllSettingsPreference.setOnPreferenceClickListener(preference -> {
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
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 783ab80c..50294522 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -119,6 +119,7 @@ public class SharedPreferencesUtils {
public static final String DELETE_ALL_SORT_TYPE_DATA_IN_DATABASE = "delete_all_sort_type_data_in_database";
public static final String DELETE_ALL_POST_LAYOUT_DATA_IN_DATABASE = "delete_all_post_layout_data_in_database";
public static final String DELETE_ALL_THEMES_IN_DATABASE = "delete_all_themes_in_database";
+ public static final String DELETE_POST_FEED_SCROLLED_POSITIONS_IN_DATABASE = "delete_post_feed_scrolled_positions_in_database";
public static final String RESET_ALL_SETTINGS = "reset_all_settings";
public static final String MAIN_PAGE_TAB_1_TITLE = "main_page_tab_1_title";
public static final String MAIN_PAGE_TAB_2_TITLE = "main_page_tab_2_title";