mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-25 02:18:23 +01:00
Finished adding advanced preferences.
This commit is contained in:
parent
ca599fede5
commit
84d4679aa9
@ -0,0 +1,57 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.AsyncTask;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
|
public class DeleteAllPostLayoutsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
private SharedPreferences defaultSharedPreferences;
|
||||||
|
private SharedPreferences postLayoutSharedPreferences;
|
||||||
|
private DeleteAllPostLayoutsAsyncTaskListener deleteAllPostLayoutsAsyncTaskListener;
|
||||||
|
|
||||||
|
public interface DeleteAllPostLayoutsAsyncTaskListener {
|
||||||
|
void success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeleteAllPostLayoutsAsyncTask(SharedPreferences defaultSharedPreferences,
|
||||||
|
SharedPreferences postLayoutSharedPreferences,
|
||||||
|
DeleteAllPostLayoutsAsyncTaskListener deleteAllPostLayoutsAsyncTaskListener) {
|
||||||
|
this.defaultSharedPreferences = defaultSharedPreferences;
|
||||||
|
this.postLayoutSharedPreferences = postLayoutSharedPreferences;
|
||||||
|
this.deleteAllPostLayoutsAsyncTaskListener = deleteAllPostLayoutsAsyncTaskListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
Map<String,?> keys = defaultSharedPreferences.getAll();
|
||||||
|
SharedPreferences.Editor editor = defaultSharedPreferences.edit();
|
||||||
|
|
||||||
|
for(Map.Entry<String,?> entry : keys.entrySet()){
|
||||||
|
String key = entry.getKey();
|
||||||
|
if (key.startsWith(SharedPreferencesUtils.POST_LAYOUT_SHARED_PREFERENCES_FILE)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.POST_LAYOUT_POPULAR_POST)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.POST_LAYOUT_ALL_POST)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST)) {
|
||||||
|
editor.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
editor.apply();
|
||||||
|
|
||||||
|
postLayoutSharedPreferences.edit().clear().apply();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void aVoid) {
|
||||||
|
super.onPostExecute(aVoid);
|
||||||
|
deleteAllPostLayoutsAsyncTaskListener.success();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.AsyncTask;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
|
public class DeleteAllSortTypesAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
private SharedPreferences defaultSharedPreferences;
|
||||||
|
private SharedPreferences sortTypeSharedPreferences;
|
||||||
|
private DeleteAllSortTypesAsyncTaskListener deleteAllSortTypesAsyncTaskListener;
|
||||||
|
|
||||||
|
public interface DeleteAllSortTypesAsyncTaskListener {
|
||||||
|
void success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeleteAllSortTypesAsyncTask(SharedPreferences defaultSharedPreferences,
|
||||||
|
SharedPreferences sortTypeSharedPreferences,
|
||||||
|
DeleteAllSortTypesAsyncTaskListener deleteAllSortTypesAsyncTaskListener) {
|
||||||
|
this.defaultSharedPreferences = defaultSharedPreferences;
|
||||||
|
this.sortTypeSharedPreferences = sortTypeSharedPreferences;
|
||||||
|
this.deleteAllSortTypesAsyncTaskListener = deleteAllSortTypesAsyncTaskListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
Map<String,?> keys = defaultSharedPreferences.getAll();
|
||||||
|
SharedPreferences.Editor editor = defaultSharedPreferences.edit();
|
||||||
|
|
||||||
|
for(Map.Entry<String,?> entry : keys.entrySet()){
|
||||||
|
String key = entry.getKey();
|
||||||
|
if (key.startsWith(SharedPreferencesUtils.SORT_TYPE_BEST_POST) || key.startsWith(SharedPreferencesUtils.SORT_TIME_BEST_POST)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.SORT_TYPE_ALL_POST) || key.startsWith(SharedPreferencesUtils.SORT_TIME_ALL_POST)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.SORT_TYPE_POPULAR_POST) || key.startsWith(SharedPreferencesUtils.SORT_TIME_POPULAR_POST)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST) || key.startsWith(SharedPreferencesUtils.SORT_TIME_SEARCH_POST)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE) || key.startsWith(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE) || key.startsWith(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE) || key.startsWith(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT) || key.startsWith(SharedPreferencesUtils.SORT_TIME_USER_COMMENT)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.SORT_TYPE_SEARCH_SUBREDDIT) || key.startsWith(SharedPreferencesUtils.SORT_TYPE_SEARCH_USER)
|
||||||
|
|| key.startsWith(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT)) {
|
||||||
|
editor.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
editor.apply();
|
||||||
|
|
||||||
|
sortTypeSharedPreferences.edit().clear().apply();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void aVoid) {
|
||||||
|
super.onPostExecute(aVoid);
|
||||||
|
deleteAllSortTypesAsyncTaskListener.success();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.AsyncTask;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
public class DeleteAllThemesAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
private RedditDataRoomDatabase redditDataRoomDatabase;
|
||||||
|
private SharedPreferences lightThemeSharedPreferences;
|
||||||
|
private SharedPreferences darkThemeSharedPreferences;
|
||||||
|
private SharedPreferences amoledThemeSharedPreferences;
|
||||||
|
private DeleteAllThemesAsyncTaskListener deleteAllThemesAsyncTaskListener;
|
||||||
|
|
||||||
|
public interface DeleteAllThemesAsyncTaskListener {
|
||||||
|
void success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeleteAllThemesAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
|
SharedPreferences lightThemeSharedPreferences,
|
||||||
|
SharedPreferences darkThemeSharedPreferences,
|
||||||
|
SharedPreferences amoledThemeSharedPreferences,
|
||||||
|
DeleteAllThemesAsyncTaskListener deleteAllThemesAsyncTaskListener) {
|
||||||
|
this.redditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
|
this.lightThemeSharedPreferences = lightThemeSharedPreferences;
|
||||||
|
this.darkThemeSharedPreferences = darkThemeSharedPreferences;
|
||||||
|
this.amoledThemeSharedPreferences = amoledThemeSharedPreferences;
|
||||||
|
this.deleteAllThemesAsyncTaskListener = deleteAllThemesAsyncTaskListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
redditDataRoomDatabase.customThemeDao().deleteAllCustomThemes();
|
||||||
|
lightThemeSharedPreferences.edit().clear().apply();
|
||||||
|
darkThemeSharedPreferences.edit().clear().apply();
|
||||||
|
amoledThemeSharedPreferences.edit().clear().apply();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void aVoid) {
|
||||||
|
super.onPostExecute(aVoid);
|
||||||
|
deleteAllThemesAsyncTaskListener.success();
|
||||||
|
}
|
||||||
|
}
|
@ -49,19 +49,19 @@ public class InsertCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||||||
if (customTheme.isLightTheme) {
|
if (customTheme.isLightTheme) {
|
||||||
redditDataRoomDatabase.customThemeDao().unsetLightTheme();
|
redditDataRoomDatabase.customThemeDao().unsetLightTheme();
|
||||||
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, lightThemeSharedPreferences);
|
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, lightThemeSharedPreferences);
|
||||||
} else if (previousTheme.isLightTheme) {
|
} else if (previousTheme != null && previousTheme.isLightTheme) {
|
||||||
lightThemeSharedPreferences.edit().clear().apply();
|
lightThemeSharedPreferences.edit().clear().apply();
|
||||||
}
|
}
|
||||||
if (customTheme.isDarkTheme) {
|
if (customTheme.isDarkTheme) {
|
||||||
redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
|
redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
|
||||||
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, darkThemeSharedPreferences);
|
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, darkThemeSharedPreferences);
|
||||||
} else if (previousTheme.isDarkTheme) {
|
} else if (previousTheme != null && previousTheme.isDarkTheme) {
|
||||||
darkThemeSharedPreferences.edit().clear().apply();
|
darkThemeSharedPreferences.edit().clear().apply();
|
||||||
}
|
}
|
||||||
if (customTheme.isAmoledTheme) {
|
if (customTheme.isAmoledTheme) {
|
||||||
redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
|
redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
|
||||||
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, amoledThemeSharedPreferences);
|
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, amoledThemeSharedPreferences);
|
||||||
} else if (previousTheme.isAmoledTheme) {
|
} else if (previousTheme != null && previousTheme.isAmoledTheme) {
|
||||||
amoledThemeSharedPreferences.edit().clear().apply();
|
amoledThemeSharedPreferences.edit().clear().apply();
|
||||||
}
|
}
|
||||||
redditDataRoomDatabase.customThemeDao().insert(customTheme);
|
redditDataRoomDatabase.customThemeDao().insert(customTheme);
|
||||||
|
@ -51,4 +51,7 @@ public interface CustomThemeDao {
|
|||||||
|
|
||||||
@Query("UPDATE custom_themes SET name = :newName WHERE name = :oldName")
|
@Query("UPDATE custom_themes SET name = :newName WHERE name = :oldName")
|
||||||
void updateName(String oldName, String newName);
|
void updateName(String oldName, String newName);
|
||||||
|
|
||||||
|
@Query("DELETE FROM custom_themes")
|
||||||
|
void deleteAllCustomThemes();
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,19 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteAllPostLayoutsAsyncTask;
|
||||||
|
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteAllSortTypesAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteAllSubredditsAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteAllSubredditsAsyncTask;
|
||||||
|
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteAllThemesAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteAllUsersAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteAllUsersAsyncTask;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
@ -32,6 +40,21 @@ public class AdvancedPreferenceFragment extends PreferenceFragmentCompat {
|
|||||||
@Inject
|
@Inject
|
||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("sort_type")
|
||||||
|
SharedPreferences mSortTypeSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("post_layout")
|
||||||
|
SharedPreferences mPostLayoutSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("light_theme")
|
||||||
|
SharedPreferences lightThemeSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("dark_theme")
|
||||||
|
SharedPreferences darkThemeSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("amoled_theme")
|
||||||
|
SharedPreferences amoledThemeSharedPreferences;
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,34 +67,96 @@ public class AdvancedPreferenceFragment extends PreferenceFragmentCompat {
|
|||||||
Preference deleteUsersPreference = findPreference(SharedPreferencesUtils.DELETE_ALL_USERS_DATA_IN_DATABASE);
|
Preference deleteUsersPreference = findPreference(SharedPreferencesUtils.DELETE_ALL_USERS_DATA_IN_DATABASE);
|
||||||
Preference deleteSortTypePreference = findPreference(SharedPreferencesUtils.DELETE_ALL_SORT_TYPE_DATA_IN_DATABASE);
|
Preference deleteSortTypePreference = findPreference(SharedPreferencesUtils.DELETE_ALL_SORT_TYPE_DATA_IN_DATABASE);
|
||||||
Preference deletePostLaoutPreference = findPreference(SharedPreferencesUtils.DELETE_ALL_POST_LAYOUT_DATA_IN_DATABASE);
|
Preference deletePostLaoutPreference = findPreference(SharedPreferencesUtils.DELETE_ALL_POST_LAYOUT_DATA_IN_DATABASE);
|
||||||
|
Preference deleteAllThemesPreference = findPreference(SharedPreferencesUtils.DELETE_ALL_THEMES_IN_DATABASE);
|
||||||
|
Preference resetAllSettingsPreference = findPreference(SharedPreferencesUtils.RESET_ALL_SETTINGS);
|
||||||
|
|
||||||
deleteSubredditsPreference.setOnPreferenceClickListener(preference -> {
|
if (deleteSubredditsPreference != null) {
|
||||||
new DeleteAllSubredditsAsyncTask(mRedditDataRoomDatabase,
|
deleteSubredditsPreference.setOnPreferenceClickListener(preference -> {
|
||||||
() -> Toast.makeText(activity, R.string.delete_all_subreddits_success, Toast.LENGTH_SHORT).show()).execute();
|
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
|
||||||
return true;
|
.setTitle(R.string.are_you_sure)
|
||||||
});
|
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||||
|
-> new DeleteAllSubredditsAsyncTask(mRedditDataRoomDatabase,
|
||||||
|
() -> Toast.makeText(activity, R.string.delete_all_subreddits_success, Toast.LENGTH_SHORT).show()).execute())
|
||||||
|
.setNegativeButton(R.string.no, null)
|
||||||
|
.show();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
deleteUsersPreference.setOnPreferenceClickListener(preference -> {
|
if (deleteUsersPreference != null) {
|
||||||
new DeleteAllUsersAsyncTask(mRedditDataRoomDatabase,
|
deleteUsersPreference.setOnPreferenceClickListener(preference -> {
|
||||||
() -> Toast.makeText(activity, R.string.delete_all_users_success, Toast.LENGTH_SHORT).show()).execute();
|
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
|
||||||
return true;
|
.setTitle(R.string.are_you_sure)
|
||||||
});
|
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||||
|
-> new DeleteAllUsersAsyncTask(mRedditDataRoomDatabase,
|
||||||
|
() -> Toast.makeText(activity, R.string.delete_all_users_success, Toast.LENGTH_SHORT).show()).execute())
|
||||||
|
.setNegativeButton(R.string.no, null)
|
||||||
|
.show();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
deleteSortTypePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
if (deleteSortTypePreference != null) {
|
||||||
@Override
|
deleteSortTypePreference.setOnPreferenceClickListener(preference -> {
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
|
||||||
|
.setTitle(R.string.are_you_sure)
|
||||||
|
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||||
|
-> new DeleteAllSortTypesAsyncTask(mSharedPreferences, mSortTypeSharedPreferences, () -> {
|
||||||
|
Toast.makeText(activity, R.string.delete_all_sort_types_success, Toast.LENGTH_SHORT).show();
|
||||||
|
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||||
|
}).execute())
|
||||||
|
.setNegativeButton(R.string.no, null)
|
||||||
|
.show();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
if (deletePostLaoutPreference != null) {
|
||||||
}
|
deletePostLaoutPreference.setOnPreferenceClickListener(preference -> {
|
||||||
});
|
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
|
||||||
|
.setTitle(R.string.are_you_sure)
|
||||||
|
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||||
|
-> new DeleteAllPostLayoutsAsyncTask(mSharedPreferences, mPostLayoutSharedPreferences, () -> {
|
||||||
|
Toast.makeText(activity, R.string.delete_all_post_layouts_success, Toast.LENGTH_SHORT).show();
|
||||||
|
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||||
|
}).execute())
|
||||||
|
.setNegativeButton(R.string.no, null)
|
||||||
|
.show();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
deletePostLaoutPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
if (deleteAllThemesPreference != null) {
|
||||||
@Override
|
deleteAllThemesPreference.setOnPreferenceClickListener(preference -> {
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
|
||||||
|
.setTitle(R.string.are_you_sure)
|
||||||
|
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||||
|
-> new DeleteAllThemesAsyncTask(mRedditDataRoomDatabase, lightThemeSharedPreferences,
|
||||||
|
darkThemeSharedPreferences, amoledThemeSharedPreferences, () -> {
|
||||||
|
Toast.makeText(activity, R.string.delete_all_themes_success, Toast.LENGTH_SHORT).show();
|
||||||
|
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||||
|
}).execute())
|
||||||
|
.setNegativeButton(R.string.no, null)
|
||||||
|
.show();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
if (resetAllSettingsPreference != null) {
|
||||||
}
|
resetAllSettingsPreference.setOnPreferenceClickListener(preference -> {
|
||||||
});
|
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
|
||||||
|
.setTitle(R.string.are_you_sure)
|
||||||
|
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||||
|
-> {
|
||||||
|
mSharedPreferences.edit().clear().apply();
|
||||||
|
Toast.makeText(activity, R.string.reset_all_settings_success, Toast.LENGTH_SHORT).show();
|
||||||
|
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.no, null)
|
||||||
|
.show();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,4 +90,6 @@ public class SharedPreferencesUtils {
|
|||||||
public static final String DELETE_ALL_USERS_DATA_IN_DATABASE= "delete_all_users_data_in_database";
|
public static final String DELETE_ALL_USERS_DATA_IN_DATABASE= "delete_all_users_data_in_database";
|
||||||
public static final String DELETE_ALL_SORT_TYPE_DATA_IN_DATABASE= "delete_all_sort_type_data_in_database";
|
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_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 RESET_ALL_SETTINGS = "reset_all_settings";
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M11,7h2v2h-2zM11,11h2v6h-2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"
|
||||||
|
android:fillColor="#4DFFFFFF"/>
|
||||||
|
</vector>
|
9
app/src/main/res/drawable/ic_info_preference_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_info_preference_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M11,7h2v2h-2zM11,11h2v6h-2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"
|
||||||
|
android:fillColor="#42000000"/>
|
||||||
|
</vector>
|
@ -365,12 +365,15 @@
|
|||||||
<string name="settings_customize_dark_theme_title">Dark Theme</string>
|
<string name="settings_customize_dark_theme_title">Dark Theme</string>
|
||||||
<string name="settings_customize_amoled_theme_title">Amoled Theme</string>
|
<string name="settings_customize_amoled_theme_title">Amoled Theme</string>
|
||||||
<string name="settings_manage_themes_title">Manage Themes</string>
|
<string name="settings_manage_themes_title">Manage Themes</string>
|
||||||
<string name="settings_custom_theme_cannot_apply_to_settings_page_title">Custom themes cannot be applied to settings page (except toolbar, status bar and navigation bar).</string>
|
<string name="settings_custom_theme_cannot_apply_to_settings_page_summary">Custom themes cannot be applied to settings page (except toolbar, status bar and navigation bar).</string>
|
||||||
<string name="settings_advanced_master_title">Advanced</string>
|
<string name="settings_advanced_master_title">Advanced</string>
|
||||||
<string name="settings_delete_all_subreddits_data_in_database_title">Delete All Subreddits in Database</string>
|
<string name="settings_delete_all_subreddits_data_in_database_title">Delete All Subreddits in Database</string>
|
||||||
<string name="settings_delete_all_users_data_in_database_title">Delete All Users in Database</string>
|
<string name="settings_delete_all_users_data_in_database_title">Delete All Users in Database</string>
|
||||||
<string name="settings_delete_all_sort_type_data_in_database_title">Delete All Sort Type in Database</string>
|
<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 Layout Data 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_reset_all_settings_title">Reset All Settings</string>
|
||||||
|
<string name="settings_advanced_settings_summary">Clean the database and shared preferences</string>
|
||||||
|
|
||||||
<string name="no_link_available">Cannot get the link</string>
|
<string name="no_link_available">Cannot get the link</string>
|
||||||
|
|
||||||
@ -645,5 +648,10 @@
|
|||||||
|
|
||||||
<string name="delete_all_subreddits_success">Delete all subreddits successful</string>
|
<string name="delete_all_subreddits_success">Delete all subreddits successful</string>
|
||||||
<string name="delete_all_users_success">Delete all users successful</string>
|
<string name="delete_all_users_success">Delete all users successful</string>
|
||||||
|
<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="reset_all_settings_success">Reset all settings successful</string>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -18,4 +18,17 @@
|
|||||||
app:key="delete_all_post_layout_data_in_database"
|
app:key="delete_all_post_layout_data_in_database"
|
||||||
app:title="@string/settings_delete_all_post_layout_data_in_database_title" />
|
app:title="@string/settings_delete_all_post_layout_data_in_database_title" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
app:key="delete_all_themes_in_database"
|
||||||
|
app:title="@string/settings_delete_all_themes_in_database_title" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
app:key="reset_all_settings"
|
||||||
|
app:title="@string/settings_reset_all_settings_title" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:icon="@drawable/ic_info_preference_24dp"
|
||||||
|
app:summary="@string/settings_custom_theme_cannot_apply_to_settings_page_summary"
|
||||||
|
app:enabled="false" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@ -42,7 +42,8 @@
|
|||||||
app:title="@string/settings_manage_themes_title" />
|
app:title="@string/settings_manage_themes_title" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
app:summary="@string/settings_custom_theme_cannot_apply_to_settings_page_title"
|
android:icon="@drawable/ic_info_preference_24dp"
|
||||||
|
app:summary="@string/settings_custom_theme_cannot_apply_to_settings_page_summary"
|
||||||
app:enabled="false" />
|
app:enabled="false" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user