mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-25 11:22:20 +00:00
add button to clear all custom toolbar codes
This commit is contained in:
parent
9a2009d182
commit
9edbbcf0ea
2 changed files with 16 additions and 4 deletions
|
@ -199,11 +199,21 @@ fun toolbarKeysCustomizer(context: Context) {
|
||||||
orientation = LinearLayout.VERTICAL
|
orientation = LinearLayout.VERTICAL
|
||||||
setPadding(3 * padding, padding, padding, padding)
|
setPadding(3 * padding, padding, padding, padding)
|
||||||
}
|
}
|
||||||
val dialog = AlertDialog.Builder(context)
|
val builder = AlertDialog.Builder(context)
|
||||||
.setTitle(R.string.customize_toolbar_key_codes)
|
.setTitle(R.string.customize_toolbar_key_codes)
|
||||||
.setView(ScrollView(context).apply { addView(ll) })
|
.setView(ScrollView(context).apply { addView(ll) })
|
||||||
.setPositiveButton(R.string.dialog_close, null)
|
.setPositiveButton(R.string.dialog_close, null)
|
||||||
.create()
|
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
||||||
|
if (readCustomKeyCodes(prefs).isNotEmpty() || readCustomLongpressCodes(prefs).isNotEmpty())
|
||||||
|
builder.setNeutralButton(R.string.button_default) { _, _ ->
|
||||||
|
confirmDialog(context, context.getString(R.string.customize_toolbar_key_code_reset_message), context.getString(android.R.string.ok)) {
|
||||||
|
prefs.edit {
|
||||||
|
remove(Settings.PREF_TOOLBAR_CUSTOM_KEY_CODES)
|
||||||
|
remove(Settings.PREF_TOOLBAR_CUSTOM_LONGPRESS_CODES)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val dialog = builder.create()
|
||||||
val cf = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(ContextCompat.getColor(context, R.color.foreground), BlendModeCompat.SRC_IN)
|
val cf = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(ContextCompat.getColor(context, R.color.foreground), BlendModeCompat.SRC_IN)
|
||||||
ToolbarKey.entries.forEach { key ->
|
ToolbarKey.entries.forEach { key ->
|
||||||
val binding = ReorderDialogItemBinding.inflate(LayoutInflater.from(context), ll, true)
|
val binding = ReorderDialogItemBinding.inflate(LayoutInflater.from(context), ll, true)
|
||||||
|
@ -278,13 +288,13 @@ private fun toolbarKeyCustomizer(context: Context, key: ToolbarKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun readCustomKeyCodes(prefs: SharedPreferences) = prefs.getString(Settings.PREF_TOOLBAR_CUSTOM_KEY_CODES, "")!!
|
fun readCustomKeyCodes(prefs: SharedPreferences) = prefs.getString(Settings.PREF_TOOLBAR_CUSTOM_KEY_CODES, "")!!
|
||||||
.split(";").associate {
|
.split(";").filter { it.isNotEmpty()}.associate {
|
||||||
val code = runCatching { it.substringAfter(",").toIntOrNull()?.checkAndConvertCode() }.getOrNull()
|
val code = runCatching { it.substringAfter(",").toIntOrNull()?.checkAndConvertCode() }.getOrNull()
|
||||||
it.substringBefore(",") to code
|
it.substringBefore(",") to code
|
||||||
}
|
}
|
||||||
|
|
||||||
fun readCustomLongpressCodes(prefs: SharedPreferences) = prefs.getString(Settings.PREF_TOOLBAR_CUSTOM_LONGPRESS_CODES, "")!!
|
fun readCustomLongpressCodes(prefs: SharedPreferences) = prefs.getString(Settings.PREF_TOOLBAR_CUSTOM_LONGPRESS_CODES, "")!!
|
||||||
.split(";").associate {
|
.split(";").filter { it.isNotEmpty()}.associate {
|
||||||
val code = runCatching { it.substringAfter(",").toIntOrNull()?.checkAndConvertCode() }.getOrNull()
|
val code = runCatching { it.substringAfter(",").toIntOrNull()?.checkAndConvertCode() }.getOrNull()
|
||||||
it.substringBefore(",") to code
|
it.substringBefore(",") to code
|
||||||
}
|
}
|
||||||
|
|
|
@ -948,6 +948,8 @@ New dictionary:
|
||||||
<string name="var_toolbar_direction_summary">Reverse direction when a right-to-left keyboard subtype is selected</string>
|
<string name="var_toolbar_direction_summary">Reverse direction when a right-to-left keyboard subtype is selected</string>
|
||||||
<!-- Title of the setting to customize toolbar key codes -->
|
<!-- Title of the setting to customize toolbar key codes -->
|
||||||
<string name="customize_toolbar_key_codes">Customize toolbar key codes</string>
|
<string name="customize_toolbar_key_codes">Customize toolbar key codes</string>
|
||||||
|
<!-- Confirmation message when resetting all custom toolbar key codes -->
|
||||||
|
<string name="customize_toolbar_key_code_reset_message">Really clear all customized key codes?</string>
|
||||||
<!-- Text for showing / setting key code -->
|
<!-- Text for showing / setting key code -->
|
||||||
<string name="key_code">Key code</string>
|
<string name="key_code">Key code</string>
|
||||||
<!-- Text for showing / setting long press code -->
|
<!-- Text for showing / setting long press code -->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue