Don't show key borders in mini keyboard

This commit is contained in:
Naveen 2023-02-03 21:43:10 +05:30
parent 9eee610929
commit 2999ccdc08
3 changed files with 8 additions and 15 deletions

View File

@ -378,7 +378,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
mShowKeyBorders = context.config.showKeyBorders mShowKeyBorders = context.config.showKeyBorders
mUsingSystemTheme = context.config.isUsingSystemTheme mUsingSystemTheme = context.config.isUsingSystemTheme
mKeyBackground = if (mShowKeyBorders) {
val isMainKeyboard = changedView == null || changedView != mini_keyboard_view
mKeyBackground = if (mShowKeyBorders && isMainKeyboard) {
resources.getDrawable(R.drawable.keyboard_key_selector_outlined, context.theme) resources.getDrawable(R.drawable.keyboard_key_selector_outlined, context.theme)
} else { } else {
resources.getDrawable(R.drawable.keyboard_key_selector, context.theme) resources.getDrawable(R.drawable.keyboard_key_selector, context.theme)
@ -392,7 +394,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
val darkerColor = getKeyboardBackgroundColor() val darkerColor = getKeyboardBackgroundColor()
val miniKeyboardBackgroundColor = getToolbarColor(4) val miniKeyboardBackgroundColor = getToolbarColor(4)
if (changedView != null && changedView == mini_keyboard_view) { if (!isMainKeyboard) {
val previewBackground = background as LayerDrawable val previewBackground = background as LayerDrawable
previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(miniKeyboardBackgroundColor) previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(miniKeyboardBackgroundColor)
previewBackground.findDrawableByLayerId(R.id.button_background_stroke).applyColorFilter(strokeColor) previewBackground.findDrawableByLayerId(R.id.button_background_stroke).applyColorFilter(strokeColor)
@ -1570,7 +1572,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
private fun maybeDarkenColor(color: Int, factor: Int): Int { private fun maybeDarkenColor(color: Int, factor: Int): Int {
// use darker background color when key borders are enabled // use darker background color when key borders are enabled
if (context.config.showKeyBorders && !context.isUsingSystemDarkTheme()) { if (context.config.showKeyBorders) {
val darkerColor = color.darkenColor(factor) val darkerColor = color.darkenColor(factor)
return if (darkerColor == Color.WHITE) { return if (darkerColor == Color.WHITE) {
resources.getColor(R.color.md_grey_200, context.theme) resources.getColor(R.color.md_grey_200, context.theme)

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--used after long pressing a key to highlight the currently selected key alternative on minikeyboard--> <!--used after long pressing a key to highlight the currently selected key alternative on minikeyboard-->
<item android:drawable="@drawable/minikeyboard_selected_background_outlined" android:state_focused="true"/> <item android:drawable="@drawable/minikeyboard_selected_background" android:state_focused="true" />
<item android:drawable="@drawable/key_background_outlined"/> <item android:drawable="@drawable/key_background_outlined" />
</selector> </selector>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/button_background_shape" android:bottom="@dimen/small_margin" android:left="@dimen/tiny_margin" android:right="@dimen/tiny_margin" android:top="@dimen/small_margin">
<shape android:shape="rectangle">
<solid android:color="@color/color_primary" />
<corners android:radius="@dimen/medium_margin" />
</shape>
</item>
</layer-list>