Skip to content

Commit 5b8277b

Browse files
committed
fix: detekt
1 parent 4ed06d2 commit 5b8277b

File tree

4 files changed

+20
-28
lines changed

4 files changed

+20
-28
lines changed

android/src/main/java/com/reactnativekeyboardcontroller/extensions/Context.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,5 @@ fun Context.currentImePackage(): String? {
5454
Settings.Secure.DEFAULT_INPUT_METHOD,
5555
) ?: return null
5656

57-
println(id)
58-
5957
return ComponentName.unflattenFromString(id)?.packageName
6058
}

android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardBackgroundViewManagerImpl.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.facebook.react.bridge.ReactApplicationContext
44
import com.facebook.react.uimanager.ThemedReactContext
55
import com.reactnativekeyboardcontroller.views.background.KeyboardBackgroundViewGroup
66

7+
@Suppress("detekt:UnusedPrivateProperty")
78
class KeyboardBackgroundViewManagerImpl(
89
mReactContext: ReactApplicationContext,
910
) {

android/src/main/java/com/reactnativekeyboardcontroller/views/background/KeyboardBackgroundViewGroup.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import android.view.WindowInsets
66
import com.facebook.react.uimanager.BackgroundStyleApplicator
77
import com.facebook.react.uimanager.ThemedReactContext
88
import com.facebook.react.views.view.ReactViewGroup
9-
import com.reactnativekeyboardcontroller.views.background.Skins.getInputMethodColor
109

1110
@SuppressLint("ViewConstructor")
1211
class KeyboardBackgroundViewGroup(

android/src/main/java/com/reactnativekeyboardcontroller/views/background/Skins.kt

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import com.reactnativekeyboardcontroller.R
1010
import com.reactnativekeyboardcontroller.extensions.currentImePackage
1111
import com.reactnativekeyboardcontroller.extensions.isSystemDarkMode
1212

13+
private const val MAX_RGB_VALUE = 255
14+
1315
object ImePackages {
1416
const val AOSP = "com.android.inputmethod.latin"
1517
const val GBOARD = "com.google.android.inputmethod.latin"
@@ -57,40 +59,32 @@ fun shiftRgbChannels(
5759
@ColorInt color: Int,
5860
shift: Int = 4,
5961
): Int {
60-
// Extract RGB channels and shift each by `shift`
61-
val red = (Color.red(color) + shift).coerceIn(0, 255)
62-
val green = (Color.green(color) + shift).coerceIn(0, 255)
63-
val blue = (Color.blue(color) + shift).coerceIn(0, 255)
62+
val red = (Color.red(color) + shift).coerceIn(0, MAX_RGB_VALUE)
63+
val green = (Color.green(color) + shift).coerceIn(0, MAX_RGB_VALUE)
64+
val blue = (Color.blue(color) + shift).coerceIn(0, MAX_RGB_VALUE)
6465

65-
// Preserve alpha and combine shifted channels
6666
return Color.argb(
67-
Color.alpha(color), // Keep original alpha
67+
Color.alpha(color),
6868
red,
6969
green,
7070
blue,
7171
)
7272
}
7373

74-
// TODO: re-work as extension?
75-
object Skins {
76-
@ColorInt
77-
fun ThemedReactContext.getInputMethodColor(): Int {
78-
val imePackage = currentImePackage()
79-
val isDark = isSystemDarkMode()
80-
81-
println("Current IME: $imePackage")
82-
println(imePackage)
83-
println("isDRK $isDark")
84-
Log.i("Skins", "Current IME: $imePackage")
74+
@ColorInt
75+
fun ThemedReactContext.getInputMethodColor(): Int {
76+
val imePackage = currentImePackage()
77+
val isDark = isSystemDarkMode()
78+
79+
Log.i("Skins", "Current IME: $imePackage")
8580

86-
val (lightColorRes, darkColorRes) =
87-
imeColorMap[imePackage]
88-
?: (R.style.gboard_light to R.style.gboard_dark)
81+
val (lightColorRes, darkColorRes) =
82+
imeColorMap[imePackage]
83+
?: (R.style.gboard_light to R.style.gboard_dark)
8984

90-
// on Android 10 dark theme doesn't affect keyboard color
91-
val resId = if (isDark && Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) darkColorRes else lightColorRes
92-
val color = getColorProperties(resId).blend
85+
// on Android 10 dark theme doesn't affect keyboard color
86+
val resId = if (isDark && Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) darkColorRes else lightColorRes
87+
val color = getColorProperties(resId).blend
9388

94-
return color
95-
}
89+
return color
9690
}

0 commit comments

Comments
 (0)