@@ -36,6 +36,7 @@ import com.simplemobiletools.keyboard.adapters.ClipsKeyboardAdapter
3636import com.simplemobiletools.keyboard.extensions.clipsDB
3737import com.simplemobiletools.keyboard.extensions.config
3838import com.simplemobiletools.keyboard.extensions.getCurrentClip
39+ import com.simplemobiletools.keyboard.extensions.getStrokeColor
3940import com.simplemobiletools.keyboard.helpers.*
4041import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_DELETE
4142import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_ENTER
@@ -266,25 +267,46 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
266267 mTextColor = context.getProperTextColor()
267268 mBackgroundColor = context.getProperBackgroundColor()
268269 mPrimaryColor = context.getProperPrimaryColor()
270+ val strokeColor = context.getStrokeColor()
271+
272+ val toolbarColor = if (context.config.isUsingSystemTheme) {
273+ resources.getColor(R .color.you_keyboard_toolbar_color, context.theme)
274+ } else {
275+ mBackgroundColor.darkenColor()
276+ }
277+
278+ val darkerColor = if (context.config.isUsingSystemTheme) {
279+ resources.getColor(R .color.you_keyboard_background_color, context.theme)
280+ } else {
281+ mBackgroundColor.darkenColor(2 )
282+ }
283+
284+ val miniKeyboardBackgroundColor = if (context.config.isUsingSystemTheme) {
285+ resources.getColor(R .color.you_keyboard_toolbar_color, context.theme)
286+ } else {
287+ mBackgroundColor.darkenColor(4 )
288+ }
269289
270290 if (changedView == mini_keyboard_view) {
271291 val previewBackground = background as LayerDrawable
272- previewBackground.findDrawableByLayerId(R .id.button_background_shape).applyColorFilter(mBackgroundColor.darkenColor( 4 ) )
273- previewBackground.findDrawableByLayerId(R .id.button_background_stroke).applyColorFilter(getPreviewStrokeColor() )
292+ previewBackground.findDrawableByLayerId(R .id.button_background_shape).applyColorFilter(miniKeyboardBackgroundColor )
293+ previewBackground.findDrawableByLayerId(R .id.button_background_stroke).applyColorFilter(strokeColor )
274294 background = previewBackground
275295 } else {
276- background.applyColorFilter(mBackgroundColor.darkenColor( 2 ) )
296+ background.applyColorFilter(darkerColor )
277297 }
278298
279299 val rippleBg = resources.getDrawable(R .drawable.clipboard_background, context.theme) as RippleDrawable
280300 val layerDrawable = rippleBg.findDrawableByLayerId(R .id.clipboard_background_holder) as LayerDrawable
301+ layerDrawable.findDrawableByLayerId(R .id.clipboard_background_stroke).applyColorFilter(strokeColor)
281302 layerDrawable.findDrawableByLayerId(R .id.clipboard_background_shape).applyColorFilter(mBackgroundColor)
282303
283304 val wasDarkened = mBackgroundColor != mBackgroundColor.darkenColor()
284305 mToolbarHolder?.apply {
285306 top_keyboard_divider.beGoneIf(wasDarkened)
307+ top_keyboard_divider.background = ColorDrawable (strokeColor)
286308
287- background = ColorDrawable (mBackgroundColor.darkenColor() )
309+ background = ColorDrawable (toolbarColor )
288310 clipboard_value.apply {
289311 background = rippleBg
290312 setTextColor(mTextColor)
@@ -298,7 +320,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
298320
299321 mClipboardManagerHolder?.apply {
300322 top_clipboard_divider.beGoneIf(wasDarkened)
301- clipboard_manager_holder.background = ColorDrawable (mBackgroundColor.darkenColor())
323+ top_clipboard_divider.background = ColorDrawable (strokeColor)
324+ clipboard_manager_holder.background = ColorDrawable (toolbarColor)
302325
303326 clipboard_manager_close.applyColorFilter(mTextColor)
304327 clipboard_manager_manage.applyColorFilter(mTextColor)
@@ -518,7 +541,11 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
518541 val code = key.code
519542 var keyBackground = mKeyBackground
520543 if (code == KEYCODE_SPACE ) {
521- keyBackground = resources.getDrawable(R .drawable.keyboard_space_background, context.theme)
544+ keyBackground = if (context.config.isUsingSystemTheme) {
545+ resources.getDrawable(R .drawable.keyboard_space_background_material, context.theme)
546+ } else {
547+ resources.getDrawable(R .drawable.keyboard_space_background, context.theme)
548+ }
522549 } else if (code == KEYCODE_ENTER ) {
523550 keyBackground = resources.getDrawable(R .drawable.keyboard_enter_background, context.theme)
524551 }
@@ -768,9 +795,15 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
768795 }
769796 }
770797
798+ val previewBackgroundColor = if (context.config.isUsingSystemTheme) {
799+ resources.getColor(R .color.you_keyboard_toolbar_color, context.theme)
800+ } else {
801+ mBackgroundColor.darkenColor(4 )
802+ }
803+
771804 val previewBackground = mPreviewText!! .background as LayerDrawable
772- previewBackground.findDrawableByLayerId(R .id.button_background_shape).applyColorFilter(mBackgroundColor.darkenColor( 4 ) )
773- previewBackground.findDrawableByLayerId(R .id.button_background_stroke).applyColorFilter(getPreviewStrokeColor ())
805+ previewBackground.findDrawableByLayerId(R .id.button_background_shape).applyColorFilter(previewBackgroundColor )
806+ previewBackground.findDrawableByLayerId(R .id.button_background_stroke).applyColorFilter(context.getStrokeColor ())
774807 mPreviewText!! .background = previewBackground
775808
776809 mPreviewText!! .setTextColor(mTextColor)
@@ -1339,15 +1372,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
13391372 mClipboardManagerHolder?.clips_list?.adapter = adapter
13401373 }
13411374
1342- // stroke is usually the lighter version of the background color, but if it becomes white or black, it might be invisible. So use light grey there.
1343- private fun getPreviewStrokeColor (): Int {
1344- var strokeColor = mBackgroundColor.lightenColor()
1345- if (strokeColor == Color .WHITE || strokeColor == Color .BLACK ) {
1346- strokeColor = resources.getColor(R .color.divider_grey)
1347- }
1348- return strokeColor
1349- }
1350-
13511375 private fun closing () {
13521376 if (mPreviewPopup.isShowing) {
13531377 mPreviewPopup.dismiss()
0 commit comments