mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 14:02:44 +00:00
add button to reset all customized icons
This commit is contained in:
parent
8c3ed1ac22
commit
afd7bc2985
2 changed files with 19 additions and 5 deletions
|
@ -37,6 +37,7 @@ import helium314.keyboard.latin.common.FileUtils
|
|||
import helium314.keyboard.latin.customIconNames
|
||||
import helium314.keyboard.latin.databinding.ReorderDialogItemBinding
|
||||
import helium314.keyboard.latin.utils.ResourceUtils
|
||||
import helium314.keyboard.latin.utils.confirmDialog
|
||||
import helium314.keyboard.latin.utils.getStringResourceOrName
|
||||
import helium314.keyboard.latin.utils.infoDialog
|
||||
import kotlinx.serialization.encodeToString
|
||||
|
@ -211,11 +212,21 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
|||
orientation = LinearLayout.VERTICAL
|
||||
setPadding(padding, 3 * padding, padding, padding)
|
||||
}
|
||||
val d = AlertDialog.Builder(ctx)
|
||||
val builder = AlertDialog.Builder(ctx)
|
||||
.setTitle(R.string.customize_icons)
|
||||
.setView(ScrollView(context).apply { addView(ll) })
|
||||
.setPositiveButton(R.string.dialog_close, null)
|
||||
.create()
|
||||
if (sharedPreferences.contains(Settings.PREF_CUSTOM_ICON_NAMES))
|
||||
builder.setNeutralButton(R.string.button_default) { _, _ ->
|
||||
confirmDialog(
|
||||
ctx,
|
||||
ctx.getString(R.string.customize_icons_reset_message),
|
||||
ctx.getString(android.R.string.ok),
|
||||
{ sharedPreferences.edit().remove(Settings.PREF_CUSTOM_ICON_NAMES).apply() }
|
||||
)
|
||||
}
|
||||
val dialog = builder.create()
|
||||
|
||||
val cf = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(ContextCompat.getColor(ctx, R.color.foreground), BlendModeCompat.SRC_IN)
|
||||
val iconsAndNames = KeyboardIconsSet.getAllIcons(ctx).keys.map { iconName ->
|
||||
val name = iconName.getStringResourceOrName("", ctx)
|
||||
|
@ -230,12 +241,12 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
|||
b.reorderItemName.text = name
|
||||
b.root.setOnClickListener {
|
||||
customizeIcon(iconName)
|
||||
d.dismiss()
|
||||
dialog.dismiss()
|
||||
}
|
||||
b.reorderItemSwitch.isGone = true
|
||||
b.reorderItemDragIndicator.isGone = true
|
||||
}
|
||||
d.show()
|
||||
dialog.show()
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -301,7 +312,8 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
|||
runCatching {
|
||||
val icons2 = customIconNames(sharedPreferences).toMutableMap()
|
||||
icons2.remove(iconName)
|
||||
sharedPreferences.edit().putString(Settings.PREF_CUSTOM_ICON_NAMES, Json.encodeToString(icons2)).apply()
|
||||
if (icons2.isEmpty()) sharedPreferences.edit().remove(Settings.PREF_CUSTOM_ICON_NAMES).apply()
|
||||
else sharedPreferences.edit().putString(Settings.PREF_CUSTOM_ICON_NAMES, Json.encodeToString(icons2)).apply()
|
||||
KeyboardIconsSet.instance.loadIcons(ctx)
|
||||
}
|
||||
onClickCustomizeIcons()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue