mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 15:32:48 +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 {
|
||||
entryValues = if (style == KeyboardTheme.STYLE_HOLO) KeyboardTheme.COLORS
|
||||
else KeyboardTheme.COLORS.filterNot { it == KeyboardTheme.THEME_HOLO_WHITE }.toTypedArray()
|
||||
entries = entryValues.map {
|
||||
val resId = resources.getIdentifier("theme_name_$it", "string", requireContext().packageName)
|
||||
if (resId == 0) it else getString(resId)
|
||||
}.toTypedArray()
|
||||
entries = entryValues.getNamesFromResourcesIfAvailable("theme_name_")
|
||||
if (value !in entryValues)
|
||||
value = entryValues.first().toString()
|
||||
summary = entries[entryValues.indexOfFirst { it == value }]
|
||||
|
@ -113,10 +110,7 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
|||
colorsNightPref?.apply {
|
||||
entryValues = if (style == KeyboardTheme.STYLE_HOLO) KeyboardTheme.COLORS_DARK
|
||||
else KeyboardTheme.COLORS_DARK.filterNot { it == KeyboardTheme.THEME_HOLO_WHITE }.toTypedArray()
|
||||
entries = entryValues.map {
|
||||
val resId = resources.getIdentifier("theme_name_$it", "string", requireContext().packageName)
|
||||
if (resId == 0) it else getString(resId)
|
||||
}.toTypedArray()
|
||||
entries = entryValues.getNamesFromResourcesIfAvailable("theme_name_")
|
||||
if (value !in entryValues)
|
||||
value = entryValues.first().toString()
|
||||
summary = entries[entryValues.indexOfFirst { it == value }]
|
||||
|
@ -132,10 +126,7 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
|||
private fun setupTheme() {
|
||||
stylePref.apply {
|
||||
entryValues = KeyboardTheme.STYLES
|
||||
entries = entryValues.map {
|
||||
val resId = resources.getIdentifier("style_name_$it", "string", requireContext().packageName)
|
||||
if (resId == 0) it else getString(resId)
|
||||
}.toTypedArray()
|
||||
entries = entryValues.getNamesFromResourcesIfAvailable("style_name_")
|
||||
if (value !in entryValues)
|
||||
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 {
|
||||
private const val PERCENTAGE_FLOAT = 100.0f
|
||||
}
|
||||
|
|
|
@ -238,8 +238,6 @@
|
|||
<string name="prefs_keyboard_height_scale">Keyboard height scale</string>
|
||||
<!-- Title of the settings for setting bottom padding height -->
|
||||
<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]
|
||||
(UK) should be an abbreviation of United Kingdom to fit in the CHAR LIMIT. -->
|
||||
<string name="subtype_en_GB">English (UK)</string>
|
||||
|
|
|
@ -84,7 +84,6 @@
|
|||
<org.dslul.openboard.inputmethod.latin.settings.SeekBarDialogPreference
|
||||
android:key="pref_bottom_padding_scale"
|
||||
android:title="@string/prefs_bottom_padding_scale"
|
||||
android:summary="@string/prefs_bottom_padding_scale_summary"
|
||||
latin:minValue="0"
|
||||
latin:maxValue="500" /> <!-- percentage -->
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue