Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 16 additions & 23 deletions app/src/main/java/be/scri/views/KeyboardView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,10 @@ class KeyboardView
} else {
R.color.special_key_light
}
val pressedColorResId = if (isUserDarkMode) R.color.dark_key_press_color else R.color.light_key_press_color
val pressedColor = resources.getColor(pressedColorResId, context.theme)
val specialKeyColorValue = resources.getColor(mSpecialKeyColor!!, context.theme)

paint.color = mTextColor
val keyBackgroundPaint =
Paint().apply {
Expand Down Expand Up @@ -698,25 +702,21 @@ class KeyboardView
(key.y + key.height - keyMargin + shadowOffset - padding).toFloat(),
)
canvas.drawRoundRect(shadowRect, rectRadius, rectRadius, shadowPaint)

val backgroundColor =
when {
key.pressed -> pressedColor
code == KEYCODE_SHIFT && mKeyboard!!.mShiftState == SHIFT_LOCKED -> pressedColor
code in listOf(KEYCODE_DELETE, KEYCODE_SHIFT, KEYCODE_MODE_CHANGE) -> specialKeyColorValue
code == KEYCODE_ENTER -> mEnterKeyColor
else -> keyBackgroundColor
}
keyBackgroundPaint.color = backgroundColor
canvas.drawRoundRect(keyRect, rectRadius, rectRadius, keyBackgroundPaint)

// Switch the character to uppercase if shift is pressed.
val label = adjustCase(key.label)?.toString()

if (key.focused || code == KEYCODE_ENTER) {
keyBackgroundPaint.color = Color.DKGRAY
canvas.drawRoundRect(keyRect, rectRadius, rectRadius, keyBackgroundPaint)
keyBackgroundPaint.color = mEnterKeyColor
canvas.drawRoundRect(keyRect, rectRadius, rectRadius, keyBackgroundPaint)
keyBackgroundPaint.color = keyBackgroundColor
}

if ((code == KEYCODE_DELETE || code == KEYCODE_SHIFT || code == KEYCODE_MODE_CHANGE)) {
keyBackgroundPaint.color = resources.getColor(mSpecialKeyColor!!)
canvas.drawRoundRect(keyRect, rectRadius, rectRadius, keyBackgroundPaint)
keyBackgroundPaint.color = keyBackgroundColor
}

canvas.translate(key.x.toFloat(), key.y.toFloat())
if (label?.isNotEmpty() == true) {
// For characters, use large font. For labels like "Done", use small font.
Expand Down Expand Up @@ -770,6 +770,7 @@ class KeyboardView
else -> R.drawable.ic_caps_lock_off
}
key.icon = resources.getDrawable(drawableId, context.theme)
key.icon!!.applyColorFilter(mTextColor)
}

if (code == KEYCODE_LEFT_ARROW || code == KEYCODE_RIGHT_ARROW) {
Expand Down Expand Up @@ -870,16 +871,8 @@ class KeyboardView
if (mCurrentKeyIndex != NOT_A_KEY && keys.size > mCurrentKeyIndex) {
val newKey = keys[mCurrentKeyIndex]
val code = newKey.code
val pressedKeys =
listOf(
KEYCODE_SHIFT,
KEYCODE_MODE_CHANGE,
KEYCODE_DELETE,
KEYCODE_ENTER,
KEYCODE_SPACE,
)

newKey.pressed = code in pressedKeys
newKey.pressed = true

invalidateKey(mCurrentKeyIndex)
sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED, code)
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/res/drawable/ic_caps_lock_off.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
android:viewportHeight="960">

<path
android:strokeColor="#000000"
android:strokeColor="@color/icon_color"
android:strokeWidth="80"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="#00000000"
android:pathData="M480,100 l-340,340 M480,100 l340,340" />
android:pathData="M480,140 l-300,300 M480,140 l300,300" />

<path
android:strokeColor="#000000"
android:strokeColor="@color/icon_color"
android:strokeWidth="80"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:pathData="M100,669 h760" />

android:pathData="M180,680 h600" />
</vector>
10 changes: 5 additions & 5 deletions app/src/main/res/drawable/ic_caps_lock_on.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
android:viewportHeight="960">

<path
android:fillColor="#000000"
android:strokeColor="#000000"
android:fillColor="@color/icon_color"
android:strokeColor="@color/icon_color"
android:strokeWidth="80"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:pathData="M480,60 L60,480 L480,480 L900,480 L480,60Z" />
android:pathData="M480,140 L180,440 L480,440 L780,440 L480,140Z" />

<path
android:strokeColor="#000000"
android:strokeColor="@color/icon_color"
android:strokeWidth="80"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:pathData="M100,669 h760" />
android:pathData="M180,680 h600" />

</vector>
Loading