From e6268ac3cd3df1befde46c3662e6cdd2a51d5928 Mon Sep 17 00:00:00 2001 From: Colton Leighton Date: Mon, 9 Mar 2026 20:04:14 -0700 Subject: [PATCH] Fix duplicate key.focused condition and refactor to 'when' for clarity --- app/src/main/java/be/scri/views/KeyboardView.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/be/scri/views/KeyboardView.kt b/app/src/main/java/be/scri/views/KeyboardView.kt index ed0616d9..91ba0994 100644 --- a/app/src/main/java/be/scri/views/KeyboardView.kt +++ b/app/src/main/java/be/scri/views/KeyboardView.kt @@ -1050,14 +1050,13 @@ class KeyboardView paint.typeface = Typeface.DEFAULT } - paint.color = - if (key.focused) { - Color.WHITE - } else if (key.focused) { - mPrimaryColor.getContrastColor() - } else { - mTextColor - } + // Set key text color based on state: focused keys are white, pressed keys use a contrasting color, otherwise default text color + // Using 'when' makes the logic clearer and avoids evaluating duplicate conditions + paint.color = when { + key.focused -> Color.WHITE + key.pressed -> mPrimaryColor.getContrastColor() + else -> mTextColor + } canvas.drawText( label,