From ec1af9dc1ea8bb503103765ec46e2c0b6da79c62 Mon Sep 17 00:00:00 2001 From: vvb2060 Date: Tue, 1 Dec 2020 01:26:58 +0800 Subject: [PATCH] Delete useless arrays --- .../magisk/ui/settings/BaseSettingsItem.kt | 2 +- .../magisk/ui/settings/SettingsItems.kt | 17 ++++++----------- app/src/main/res/values/arrays.xml | 8 -------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/BaseSettingsItem.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/BaseSettingsItem.kt index 1f4907e71..6ed6f0df8 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/BaseSettingsItem.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/BaseSettingsItem.kt @@ -158,7 +158,7 @@ sealed class BaseSettingsItem : ObservableItem() { runCatching { getStringArray(id) }.getOrDefault(emptyArray()) override fun onPressed(view: View, callback: Callback) { - if (entries.isEmpty() || entryValues.isEmpty()) return + if (entries.isEmpty()) return super.onPressed(view, callback) } diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt index 70ccff441..5bec7cefa 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt @@ -256,22 +256,20 @@ object Superuser : BaseSettingsItem.Section() { object AccessMode : BaseSettingsItem.Selector() { override val title = R.string.superuser_access.asTransitive() override val entryRes = R.array.su_access - override val entryValRes = R.array.value_array override var value = Config.rootMode set(value) = setV(value, field, { field = it }) { - Config.rootMode = entryValues[it].toInt() + Config.rootMode = it } } object MultiuserMode : BaseSettingsItem.Selector() { override val title = R.string.multiuser_mode.asTransitive() override val entryRes = R.array.multiuser_mode - override val entryValRes = R.array.value_array override var value = Config.suMultiuserMode set(value) = setV(value, field, { field = it }) { - Config.suMultiuserMode = entryValues[it].toInt() + Config.suMultiuserMode = it } override val description @@ -285,11 +283,10 @@ object MultiuserMode : BaseSettingsItem.Selector() { object MountNamespaceMode : BaseSettingsItem.Selector() { override val title = R.string.mount_namespace_mode.asTransitive() override val entryRes = R.array.namespace - override val entryValRes = R.array.value_array override var value = Config.suMntNamespaceMode set(value) = setV(value, field, { field = it }) { - Config.suMntNamespaceMode = entryValues[it].toInt() + Config.suMntNamespaceMode = it } override val description @@ -299,11 +296,10 @@ object MountNamespaceMode : BaseSettingsItem.Selector() { object AutomaticResponse : BaseSettingsItem.Selector() { override val title = R.string.auto_response.asTransitive() override val entryRes = R.array.auto_response - override val entryValRes = R.array.value_array override var value = Config.suAutoResponse set(value) = setV(value, field, { field = it }) { - Config.suAutoResponse = entryValues[it].toInt() + Config.suAutoResponse = it } } @@ -314,7 +310,7 @@ object RequestTimeout : BaseSettingsItem.Selector() { override var value = selected set(value) = setV(value, field, { field = it }) { - Config.suDefaultTimeout = entryValues[it].toInt() + Config.suDefaultTimeout = it } private val selected: Int @@ -324,10 +320,9 @@ object RequestTimeout : BaseSettingsItem.Selector() { object SUNotification : BaseSettingsItem.Selector() { override val title = R.string.superuser_notification.asTransitive() override val entryRes = R.array.su_notification - override val entryValRes = R.array.value_array override var value = Config.suNotification set(value) = setV(value, field, { field = it }) { - Config.suNotification = entryValues[it].toInt() + Config.suNotification = it } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 4ae643470..ec16d6e45 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -16,14 +16,6 @@ @string/settings_su_app_adb - - 0 - 1 - 2 - 3 - 4 - - @string/settings_su_request_10 @string/settings_su_request_15