mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 07:22:45 +00:00
reduce code duplication, remove useless string
This commit is contained in:
parent
e1da2ffdc1
commit
7ae0d0783d
3 changed files with 8 additions and 15 deletions
|
@ -96,10 +96,7 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
||||||
colorsPref.apply {
|
colorsPref.apply {
|
||||||
entryValues = if (style == KeyboardTheme.STYLE_HOLO) KeyboardTheme.COLORS
|
entryValues = if (style == KeyboardTheme.STYLE_HOLO) KeyboardTheme.COLORS
|
||||||
else KeyboardTheme.COLORS.filterNot { it == KeyboardTheme.THEME_HOLO_WHITE }.toTypedArray()
|
else KeyboardTheme.COLORS.filterNot { it == KeyboardTheme.THEME_HOLO_WHITE }.toTypedArray()
|
||||||
entries = entryValues.map {
|
entries = entryValues.getNamesFromResourcesIfAvailable("theme_name_")
|
||||||
val resId = resources.getIdentifier("theme_name_$it", "string", requireContext().packageName)
|
|
||||||
if (resId == 0) it else getString(resId)
|
|
||||||
}.toTypedArray()
|
|
||||||
if (value !in entryValues)
|
if (value !in entryValues)
|
||||||
value = entryValues.first().toString()
|
value = entryValues.first().toString()
|
||||||
summary = entries[entryValues.indexOfFirst { it == value }]
|
summary = entries[entryValues.indexOfFirst { it == value }]
|
||||||
|
@ -113,10 +110,7 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
||||||
colorsNightPref?.apply {
|
colorsNightPref?.apply {
|
||||||
entryValues = if (style == KeyboardTheme.STYLE_HOLO) KeyboardTheme.COLORS_DARK
|
entryValues = if (style == KeyboardTheme.STYLE_HOLO) KeyboardTheme.COLORS_DARK
|
||||||
else KeyboardTheme.COLORS_DARK.filterNot { it == KeyboardTheme.THEME_HOLO_WHITE }.toTypedArray()
|
else KeyboardTheme.COLORS_DARK.filterNot { it == KeyboardTheme.THEME_HOLO_WHITE }.toTypedArray()
|
||||||
entries = entryValues.map {
|
entries = entryValues.getNamesFromResourcesIfAvailable("theme_name_")
|
||||||
val resId = resources.getIdentifier("theme_name_$it", "string", requireContext().packageName)
|
|
||||||
if (resId == 0) it else getString(resId)
|
|
||||||
}.toTypedArray()
|
|
||||||
if (value !in entryValues)
|
if (value !in entryValues)
|
||||||
value = entryValues.first().toString()
|
value = entryValues.first().toString()
|
||||||
summary = entries[entryValues.indexOfFirst { it == value }]
|
summary = entries[entryValues.indexOfFirst { it == value }]
|
||||||
|
@ -132,10 +126,7 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
||||||
private fun setupTheme() {
|
private fun setupTheme() {
|
||||||
stylePref.apply {
|
stylePref.apply {
|
||||||
entryValues = KeyboardTheme.STYLES
|
entryValues = KeyboardTheme.STYLES
|
||||||
entries = entryValues.map {
|
entries = entryValues.getNamesFromResourcesIfAvailable("style_name_")
|
||||||
val resId = resources.getIdentifier("style_name_$it", "string", requireContext().packageName)
|
|
||||||
if (resId == 0) it else getString(resId)
|
|
||||||
}.toTypedArray()
|
|
||||||
if (value !in entryValues)
|
if (value !in entryValues)
|
||||||
value = entryValues.first().toString()
|
value = entryValues.first().toString()
|
||||||
|
|
||||||
|
@ -179,6 +170,11 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Array<CharSequence>.getNamesFromResourcesIfAvailable(prefix: String) =
|
||||||
|
map { val resId = resources.getIdentifier("$prefix$it", "string", requireContext().packageName)
|
||||||
|
if (resId == 0) it else getString(resId)
|
||||||
|
}.toTypedArray()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val PERCENTAGE_FLOAT = 100.0f
|
private const val PERCENTAGE_FLOAT = 100.0f
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,8 +238,6 @@
|
||||||
<string name="prefs_keyboard_height_scale">Keyboard height scale</string>
|
<string name="prefs_keyboard_height_scale">Keyboard height scale</string>
|
||||||
<!-- Title of the settings for setting bottom padding height -->
|
<!-- Title of the settings for setting bottom padding height -->
|
||||||
<string name="prefs_bottom_padding_scale">Bottom padding scale</string>
|
<string name="prefs_bottom_padding_scale">Bottom padding scale</string>
|
||||||
<!-- Description of prefs_bottom_padding_scale -->
|
|
||||||
<string name="prefs_bottom_padding_scale_summary">Set size of the empty space below the keyboard</string>
|
|
||||||
<!-- Description for English (UK) keyboard subtype [CHAR LIMIT=25]
|
<!-- Description for English (UK) keyboard subtype [CHAR LIMIT=25]
|
||||||
(UK) should be an abbreviation of United Kingdom to fit in the CHAR LIMIT. -->
|
(UK) should be an abbreviation of United Kingdom to fit in the CHAR LIMIT. -->
|
||||||
<string name="subtype_en_GB">English (UK)</string>
|
<string name="subtype_en_GB">English (UK)</string>
|
||||||
|
|
|
@ -84,7 +84,6 @@
|
||||||
<org.dslul.openboard.inputmethod.latin.settings.SeekBarDialogPreference
|
<org.dslul.openboard.inputmethod.latin.settings.SeekBarDialogPreference
|
||||||
android:key="pref_bottom_padding_scale"
|
android:key="pref_bottom_padding_scale"
|
||||||
android:title="@string/prefs_bottom_padding_scale"
|
android:title="@string/prefs_bottom_padding_scale"
|
||||||
android:summary="@string/prefs_bottom_padding_scale_summary"
|
|
||||||
latin:minValue="0"
|
latin:minValue="0"
|
||||||
latin:maxValue="500" /> <!-- percentage -->
|
latin:maxValue="500" /> <!-- percentage -->
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue