aboutsummaryrefslogtreecommitdiff
path: root/app
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
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')
-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
-rw-r--r--app/src/main/res/values/strings.xml2
-rw-r--r--app/src/main/res/xml/advanced_preferences.xml4
4 files changed, 26 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";
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9d918d75..0dbcce20 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -458,6 +458,7 @@
<string name="settings_delete_all_sort_type_data_in_database_title">Delete All Sort Types in Database</string>
<string name="settings_delete_all_post_layout_data_in_database_title">Delete All Post Layouts in Database</string>
<string name="settings_delete_all_themes_in_database_title">Delete All Themes in Database</string>
+ <string name="settings_delete_post_feed_scrolled_positions_in_database_title">Delete All Post Feed Scrolled Positions in Database</string>
<string name="settings_reset_all_settings_title">Reset All Settings</string>
<string name="settings_advanced_settings_summary">Clean the database and shared preferences</string>
<string name="settings_tab_info">Restart the app to see the changes</string>
@@ -778,6 +779,7 @@
<string name="delete_all_sort_types_success">Delete all sort types successful</string>
<string name="delete_all_post_layouts_success">Delete all post layouts successful</string>
<string name="delete_all_themes_success">Delete all themes successful</string>
+ <string name="delete_all_post_feed_scrolled_positions_success">Delete all post feed scrolled positions successful</string>
<string name="reset_all_settings_success">Reset all settings successful</string>
<string name="theme_preview">Theme Preview</string>
diff --git a/app/src/main/res/xml/advanced_preferences.xml b/app/src/main/res/xml/advanced_preferences.xml
index 432623d3..224433ba 100644
--- a/app/src/main/res/xml/advanced_preferences.xml
+++ b/app/src/main/res/xml/advanced_preferences.xml
@@ -23,6 +23,10 @@
app:title="@string/settings_delete_all_themes_in_database_title" />
<Preference
+ app:key="delete_post_feed_scrolled_positions_in_database"
+ app:title="@string/settings_delete_post_feed_scrolled_positions_in_database_title" />
+
+ <Preference
app:key="reset_all_settings"
app:title="@string/settings_reset_all_settings_title" />