From dca77e720286fbd05eb5bbf4734d6dc26269dc57 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 26 Jan 2022 20:26:30 +0100 Subject: [PATCH] adding stroke to keyboard backgrounds --- .../keyboard/views/MyKeyboardView.kt | 16 +++++++++++----- .../res/drawable/minikeyboard_background.xml | 10 ++++++++++ .../minikeyboard_selected_background.xml | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) 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 d84170e..3183e40 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -259,13 +259,15 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mBackgroundColor = context.config.backgroundColor mPrimaryColor = context.getAdjustedPrimaryColor() - var newBgColor = mBackgroundColor if (changedView == mini_keyboard_view) { - newBgColor = newBgColor.darkenColor(4) + val previewBackground = background as LayerDrawable + previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(mBackgroundColor.darkenColor(4)) + previewBackground.findDrawableByLayerId(R.id.button_background_stroke).applyColorFilter(mBackgroundColor.lightenColor()) + background = previewBackground + } else { + background.applyColorFilter(mBackgroundColor.darkenColor(2)) } - background.applyColorFilter(newBgColor.darkenColor(2)) - val rippleBg = resources.getDrawable(R.drawable.clipboard_background, context.theme) as RippleDrawable val layerDrawable = rippleBg.findDrawableByLayerId(R.id.clipboard_background_holder) as LayerDrawable layerDrawable.findDrawableByLayerId(R.id.clipboard_background_shape).applyColorFilter(mBackgroundColor) @@ -755,7 +757,11 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } } - mPreviewText!!.background.applyColorFilter(mBackgroundColor.darkenColor(4)) + val previewBackground = mPreviewText!!.background as LayerDrawable + previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(mBackgroundColor.darkenColor(4)) + previewBackground.findDrawableByLayerId(R.id.button_background_stroke).applyColorFilter(mBackgroundColor.lightenColor()) + + mPreviewText!!.background = previewBackground mPreviewText!!.setTextColor(mTextColor) mPreviewText!!.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)) val popupWidth = Math.max(mPreviewText!!.measuredWidth, key.width) diff --git a/app/src/main/res/drawable/minikeyboard_background.xml b/app/src/main/res/drawable/minikeyboard_background.xml index fd7c32c..1b7bc32 100644 --- a/app/src/main/res/drawable/minikeyboard_background.xml +++ b/app/src/main/res/drawable/minikeyboard_background.xml @@ -6,4 +6,14 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/minikeyboard_selected_background.xml b/app/src/main/res/drawable/minikeyboard_selected_background.xml index 219fb4b..13def77 100644 --- a/app/src/main/res/drawable/minikeyboard_selected_background.xml +++ b/app/src/main/res/drawable/minikeyboard_selected_background.xml @@ -3,7 +3,7 @@ - +