You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Fix all locale issues
This commit is contained in:
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import androidx.annotation.ArrayRes
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.databinding.Bindable
|
||||
import androidx.databinding.ViewDataBinding
|
||||
@@ -145,13 +146,19 @@ sealed class SettingsItem : ObservableItem<SettingsItem>() {
|
||||
|
||||
protected val resources get() = get<Resources>()
|
||||
|
||||
abstract val entries: Array<out CharSequence>
|
||||
abstract val entryValues: Array<out CharSequence>
|
||||
@ArrayRes open val entryRes = -1
|
||||
@ArrayRes open val entryValRes = -1
|
||||
|
||||
open val entries get() = resources.getArrayOrEmpty(entryRes)
|
||||
open val entryValues get() = resources.getArrayOrEmpty(entryValRes)
|
||||
|
||||
@get:Bindable
|
||||
val selectedEntry
|
||||
get() = entries.getOrNull(value)
|
||||
|
||||
private fun Resources.getArrayOrEmpty(id: Int): Array<String> =
|
||||
runCatching { getStringArray(id) }.getOrDefault(emptyArray())
|
||||
|
||||
override fun onPressed(view: View, callback: Callback) {
|
||||
if (entries.isEmpty() || entryValues.isEmpty()) return
|
||||
callback.onItemPressed(view, this)
|
||||
|
||||
Reference in New Issue
Block a user