1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-29 11:15:51 +00:00

Added menu to reset questions

This commit is contained in:
M66B 2019-05-09 07:32:48 +02:00
parent d232bc882c
commit b4f31be14d
3 changed files with 26 additions and 5 deletions

View file

@ -60,6 +60,10 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"badge", "subscriptions", "search_local", "english", "authentication", "paranoid", "updates", "debug"
};
private final static String[] RESET_QUESTIONS = new String[]{
"show_html_confirmed", "show_images_confirmed", "print_html_confirmed", "edit_ref_confirmed", "automove", "autosend"
};
@Override
@Nullable
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -188,7 +192,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_options, menu);
inflater.inflate(R.menu.menu_options_misc, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@ -196,17 +200,20 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_default:
onMenuDefault();
onMenuDefault(RESET_OPTIONS);
return true;
case R.id.menu_reset_questions:
onMenuDefault(RESET_QUESTIONS);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void onMenuDefault() {
private void onMenuDefault(String[] options) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
SharedPreferences.Editor editor = prefs.edit();
for (String option : RESET_OPTIONS)
for (String option : options)
editor.remove(option);
editor.apply();
}

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_default"
android:title="@string/title_setup_defaults"
app:showAsAction="never" />
<item
android:id="@+id/menu_reset_questions"
android:title="@string/title_setup_reset_questions"
app:showAsAction="never" />
</menu>

View file

@ -147,8 +147,9 @@
<string name="title_setup_system_theme">System theme</string>
<string name="title_setup_advanced">Advanced</string>
<string name="title_setup_defaults">Restore defaults</string>
<string name="title_setup_options">Options</string>
<string name="title_setup_defaults">Restore defaults</string>
<string name="title_setup_reset_questions">Reset questions</string>
<string name="title_advanced">Advanced options</string>