adding stroke to keyboard backgrounds

This commit is contained in:
tibbi 2022-01-26 20:26:30 +01:00
parent f68fbbb338
commit dca77e7202
3 changed files with 22 additions and 6 deletions

View File

@ -259,13 +259,15 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
mBackgroundColor = context.config.backgroundColor mBackgroundColor = context.config.backgroundColor
mPrimaryColor = context.getAdjustedPrimaryColor() mPrimaryColor = context.getAdjustedPrimaryColor()
var newBgColor = mBackgroundColor
if (changedView == mini_keyboard_view) { 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 rippleBg = resources.getDrawable(R.drawable.clipboard_background, context.theme) as RippleDrawable
val layerDrawable = rippleBg.findDrawableByLayerId(R.id.clipboard_background_holder) as LayerDrawable val layerDrawable = rippleBg.findDrawableByLayerId(R.id.clipboard_background_holder) as LayerDrawable
layerDrawable.findDrawableByLayerId(R.id.clipboard_background_shape).applyColorFilter(mBackgroundColor) 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!!.setTextColor(mTextColor)
mPreviewText!!.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)) mPreviewText!!.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED))
val popupWidth = Math.max(mPreviewText!!.measuredWidth, key.width) val popupWidth = Math.max(mPreviewText!!.measuredWidth, key.width)

View File

@ -6,4 +6,14 @@
<corners android:radius="@dimen/small_margin" /> <corners android:radius="@dimen/small_margin" />
</shape> </shape>
</item> </item>
<item android:id="@+id/button_background_stroke">
<shape android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/divider_grey" />
<solid android:color="@android:color/transparent" />
<corners android:radius="@dimen/small_margin" />
</shape>
</item>
</layer-list> </layer-list>

View File

@ -3,7 +3,7 @@
<item android:id="@+id/button_background_shape"> <item android:id="@+id/button_background_shape">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="@color/color_primary" /> <solid android:color="@color/color_primary" />
<corners android:radius="4dp" /> <corners android:radius="@dimen/small_margin" />
</shape> </shape>
</item> </item>
</layer-list> </layer-list>