From 12c4fb3d2d232c20c982abf001cfad954313b6be Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 17 Jan 2022 12:17:47 +0100 Subject: [PATCH] adding some initial styling things --- .../keyboard/views/MyKeyboardView.kt | 26 +++++++----------- .../main/res/drawable/btn_keyboard_key.xml | 5 ---- .../drawable/btn_keyboard_key_normal.9.png | Bin 715 -> 0 bytes .../drawable/btn_keyboard_key_pressed.9.png | Bin 745 -> 0 bytes .../drawable/keyboard_enter_background.xml | 11 ++++++-- .../drawable/keyboard_space_background.xml | 11 ++++++-- ...ground.xml => minikeyboard_background.xml} | 2 +- .../drawable/minikeyboard_key_selector.xml | 4 +++ .../minikeyboard_selected_background.xml | 9 ++++++ .../main/res/layout/keyboard_key_preview.xml | 2 +- .../res/layout/keyboard_popup_keyboard.xml | 2 +- app/src/main/res/values/styles.xml | 2 +- 12 files changed, 43 insertions(+), 31 deletions(-) delete mode 100644 app/src/main/res/drawable/btn_keyboard_key.xml delete mode 100644 app/src/main/res/drawable/btn_keyboard_key_normal.9.png delete mode 100644 app/src/main/res/drawable/btn_keyboard_key_pressed.9.png rename app/src/main/res/drawable/{keyboard_key_feedback_background.xml => minikeyboard_background.xml} (82%) create mode 100644 app/src/main/res/drawable/minikeyboard_key_selector.xml create mode 100644 app/src/main/res/drawable/minikeyboard_selected_background.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt index d0910cc..e8f217c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -538,7 +538,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut val canvas = mCanvas canvas!!.clipRect(mDirtyRect) val paint = mPaint - val keyBackground = mKeyBackground val clipRegion = mClipRegion val padding = mPadding val kbdPaddingLeft: Int = paddingLeft @@ -574,6 +573,13 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut continue } + var keyBackground = mKeyBackground + if (key.codes.firstOrNull() == MyKeyboard.KEYCODE_SPACE) { + keyBackground = resources.getDrawable(R.drawable.keyboard_space_background, context.theme) + } else if (key.codes.firstOrNull() == MyKeyboard.KEYCODE_ENTER) { + keyBackground = resources.getDrawable(R.drawable.keyboard_enter_background, context.theme) + } + // Switch the character to uppercase if shift is pressed val label = adjustCase(key.label)?.toString() val bounds = keyBackground!!.bounds @@ -623,22 +629,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut key.icon = resources.getDrawable(drawableId) } - val iconWidthToUse = if (key.codes.firstOrNull() == MyKeyboard.KEYCODE_ENTER) { - (key.icon!!.intrinsicWidth * 1.2).toInt() - } else { - key.icon!!.intrinsicWidth - } - - val iconHeightToUse = if (key.codes.firstOrNull() == MyKeyboard.KEYCODE_ENTER) { - (key.icon!!.intrinsicHeight * 1.2).toInt() - } else { - key.icon!!.intrinsicHeight - } - - val drawableX = (key.width - iconWidthToUse) / 2 - val drawableY = (key.height - iconHeightToUse) / 2 + val drawableX = (key.width - key.icon!!.intrinsicWidth) / 2 + val drawableY = (key.height - key.icon!!.intrinsicHeight) / 2 canvas.translate(drawableX.toFloat(), drawableY.toFloat()) - key.icon!!.setBounds(0, 0, iconWidthToUse, iconHeightToUse) + key.icon!!.setBounds(0, 0, key.icon!!.intrinsicWidth, key.icon!!.intrinsicHeight) key.icon!!.draw(canvas) canvas.translate(-drawableX.toFloat(), -drawableY.toFloat()) } diff --git a/app/src/main/res/drawable/btn_keyboard_key.xml b/app/src/main/res/drawable/btn_keyboard_key.xml deleted file mode 100644 index 2a74309..0000000 --- a/app/src/main/res/drawable/btn_keyboard_key.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/app/src/main/res/drawable/btn_keyboard_key_normal.9.png b/app/src/main/res/drawable/btn_keyboard_key_normal.9.png deleted file mode 100644 index 42c7c146d67525b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B$m)Xk bM}PqUY?J9Njve6W00000NkvXXu0mjf+J0A` diff --git a/app/src/main/res/drawable/keyboard_enter_background.xml b/app/src/main/res/drawable/keyboard_enter_background.xml index 3006236..5bf8f3e 100644 --- a/app/src/main/res/drawable/keyboard_enter_background.xml +++ b/app/src/main/res/drawable/keyboard_enter_background.xml @@ -1,9 +1,14 @@ - + - - + + diff --git a/app/src/main/res/drawable/keyboard_space_background.xml b/app/src/main/res/drawable/keyboard_space_background.xml index 3006236..cfb061b 100644 --- a/app/src/main/res/drawable/keyboard_space_background.xml +++ b/app/src/main/res/drawable/keyboard_space_background.xml @@ -1,9 +1,14 @@ - + - - + + diff --git a/app/src/main/res/drawable/keyboard_key_feedback_background.xml b/app/src/main/res/drawable/minikeyboard_background.xml similarity index 82% rename from app/src/main/res/drawable/keyboard_key_feedback_background.xml rename to app/src/main/res/drawable/minikeyboard_background.xml index 3006236..67572b9 100644 --- a/app/src/main/res/drawable/keyboard_key_feedback_background.xml +++ b/app/src/main/res/drawable/minikeyboard_background.xml @@ -2,7 +2,7 @@ - + diff --git a/app/src/main/res/drawable/minikeyboard_key_selector.xml b/app/src/main/res/drawable/minikeyboard_key_selector.xml new file mode 100644 index 0000000..e081682 --- /dev/null +++ b/app/src/main/res/drawable/minikeyboard_key_selector.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/drawable/minikeyboard_selected_background.xml b/app/src/main/res/drawable/minikeyboard_selected_background.xml new file mode 100644 index 0000000..8227077 --- /dev/null +++ b/app/src/main/res/drawable/minikeyboard_selected_background.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/app/src/main/res/layout/keyboard_key_preview.xml b/app/src/main/res/layout/keyboard_key_preview.xml index 608279c..ddcee79 100644 --- a/app/src/main/res/layout/keyboard_key_preview.xml +++ b/app/src/main/res/layout/keyboard_key_preview.xml @@ -1,7 +1,7 @@