mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 03:52:15 +02:00
Show warning on reset to default button in AppBar (#13476)
This commit is contained in:
parent
c96e2eff9e
commit
a89502c9fb
@ -18,11 +18,13 @@ package com.ichi2.anki.preferences
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.edit
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceCategory
|
||||
import com.ichi2.anki.AnkiDroidApp
|
||||
import com.ichi2.anki.R
|
||||
import com.ichi2.utils.*
|
||||
|
||||
class CustomButtonsSettingsFragment : SettingsFragment() {
|
||||
override val preferenceResource: Int
|
||||
@ -34,30 +36,37 @@ class CustomButtonsSettingsFragment : SettingsFragment() {
|
||||
// Reset toolbar button customizations
|
||||
val resetCustomButtons = requirePreference<Preference>("reset_custom_buttons")
|
||||
resetCustomButtons.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
AnkiDroidApp.getSharedPrefs(requireContext()).edit {
|
||||
remove("customButtonUndo")
|
||||
remove("customButtonScheduleCard")
|
||||
remove("customButtonEditCard")
|
||||
remove("customButtonTags")
|
||||
remove("customButtonAddCard")
|
||||
remove("customButtonReplay")
|
||||
remove("customButtonCardInfo")
|
||||
remove("customButtonSelectTts")
|
||||
remove("customButtonDeckOptions")
|
||||
remove("customButtonMarkCard")
|
||||
remove("customButtonToggleMicToolBar")
|
||||
remove("customButtonBury")
|
||||
remove("customButtonSuspend")
|
||||
remove("customButtonFlag")
|
||||
remove("customButtonDelete")
|
||||
remove("customButtonEnableWhiteboard")
|
||||
remove("customButtonSaveWhiteboard")
|
||||
remove("customButtonWhiteboardPenColor")
|
||||
remove("customButtonClearWhiteboard")
|
||||
remove("customButtonShowHideWhiteboard")
|
||||
AlertDialog.Builder(requireContext()).show {
|
||||
title(R.string.reset_settings_to_default)
|
||||
positiveButton(R.string.reset) {
|
||||
// Reset the settings to default
|
||||
AnkiDroidApp.getSharedPrefs(requireContext()).edit {
|
||||
remove("customButtonUndo")
|
||||
remove("customButtonScheduleCard")
|
||||
remove("customButtonEditCard")
|
||||
remove("customButtonTags")
|
||||
remove("customButtonAddCard")
|
||||
remove("customButtonReplay")
|
||||
remove("customButtonCardInfo")
|
||||
remove("customButtonSelectTts")
|
||||
remove("customButtonDeckOptions")
|
||||
remove("customButtonMarkCard")
|
||||
remove("customButtonToggleMicToolBar")
|
||||
remove("customButtonBury")
|
||||
remove("customButtonSuspend")
|
||||
remove("customButtonFlag")
|
||||
remove("customButtonDelete")
|
||||
remove("customButtonEnableWhiteboard")
|
||||
remove("customButtonSaveWhiteboard")
|
||||
remove("customButtonWhiteboardPenColor")
|
||||
remove("customButtonClearWhiteboard")
|
||||
remove("customButtonShowHideWhiteboard")
|
||||
}
|
||||
// #9263: refresh the screen to display the changes
|
||||
refreshScreen()
|
||||
}
|
||||
negativeButton(R.string.dialog_cancel, null)
|
||||
}
|
||||
// #9263: refresh the screen to display the changes
|
||||
refreshScreen()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +178,8 @@
|
||||
<string name="custom_buttons_setting_if_room">Show if room</string>
|
||||
<string name="custom_buttons_setting_menu_only">Menu only</string>
|
||||
<string name="reset_custom_buttons" maxLength="41">Reset to default</string>
|
||||
<string name="reset_settings_to_default">Reset settings to default</string>
|
||||
<string name="reset">Reset</string>
|
||||
<string name="thirdparty_apps_title" maxLength="41">Third-party API apps</string>
|
||||
<string name="thirdparty_apps_summary">See a list of applications which make use of the AnkiDroid API such as dictionaries, utilities.</string>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user