From ca0f87b7c187c5df773bcbf6dac088c444a325d8 Mon Sep 17 00:00:00 2001 From: WhiredPlanck Date: Mon, 9 Jan 2023 20:24:31 +0800 Subject: [PATCH] build,refactor(ime,ui,util): eliminate warnings during build - Suppress unchecked casts - Eliminate implicit casts - Remove redundant parameters --- .../com/osfans/trime/ime/keyboard/KeyboardSwitcher.kt | 1 + app/src/main/java/com/osfans/trime/ui/setup/SetupPage.kt | 8 +++++--- .../main/java/com/osfans/trime/util/CollectionUtils.kt | 1 + .../main/java/com/osfans/trime/util/InputMethodUtils.kt | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardSwitcher.kt b/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardSwitcher.kt index daf85d0ab5..fc0855ff7f 100644 --- a/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardSwitcher.kt +++ b/app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardSwitcher.kt @@ -27,6 +27,7 @@ object KeyboardSwitcher { newOrReset() } + @Suppress("UNCHECKED_CAST") @JvmStatic fun newOrReset() { Timber.d("Refreshing keyboard padding ...") diff --git a/app/src/main/java/com/osfans/trime/ui/setup/SetupPage.kt b/app/src/main/java/com/osfans/trime/ui/setup/SetupPage.kt index d864dc0ba2..92b3392b4d 100644 --- a/app/src/main/java/com/osfans/trime/ui/setup/SetupPage.kt +++ b/app/src/main/java/com/osfans/trime/ui/setup/SetupPage.kt @@ -28,9 +28,11 @@ enum class SetupPage { } ) - fun getButtonAction(context: Context) = when (this) { - Enable -> InputMethodUtils.showImeEnablerActivity(context) - Select -> InputMethodUtils.showImePicker(context) + fun getButtonAction(context: Context) { + when (this) { + Enable -> InputMethodUtils.showImeEnablerActivity(context) + Select -> InputMethodUtils.showImePicker() + } } fun isDone() = when (this) { diff --git a/app/src/main/java/com/osfans/trime/util/CollectionUtils.kt b/app/src/main/java/com/osfans/trime/util/CollectionUtils.kt index d7b7cf2223..4bac763d72 100644 --- a/app/src/main/java/com/osfans/trime/util/CollectionUtils.kt +++ b/app/src/main/java/com/osfans/trime/util/CollectionUtils.kt @@ -4,6 +4,7 @@ object CollectionUtils { @JvmStatic fun getOrDefault(map: Map, key: K, defaultValue: V): V = map[key] ?: defaultValue + @Suppress("UNCHECKED_CAST") @JvmStatic fun obtainValue(map: Map?, vararg: String?): Any? { if (map.isNullOrEmpty() || vararg == null) return null diff --git a/app/src/main/java/com/osfans/trime/util/InputMethodUtils.kt b/app/src/main/java/com/osfans/trime/util/InputMethodUtils.kt index 25e8108ac1..6c9f5e3194 100644 --- a/app/src/main/java/com/osfans/trime/util/InputMethodUtils.kt +++ b/app/src/main/java/com/osfans/trime/util/InputMethodUtils.kt @@ -33,7 +33,7 @@ object InputMethodUtils { fun showImeEnablerActivity(context: Context) = context.startActivity(Intent(Settings.ACTION_INPUT_METHOD_SETTINGS)) - fun showImePicker(context: Context): Boolean { + fun showImePicker(): Boolean { inputMethodManager.showInputMethodPicker() return true }