From 29057417fdf0c4fcccaf37e7493e3b7dcda5cabe Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 18 Jan 2022 09:27:10 +0100 Subject: [PATCH] updating some more colors dynamically --- .../keyboard/activities/MainActivity.kt | 2 ++ .../keyboard/helpers/MyKeyboard.kt | 15 --------------- .../keyboard/views/MyKeyboardView.kt | 10 ++++++---- .../main/res/layout/keyboard_view_keyboard.xml | 2 +- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/MainActivity.kt index fc97d735..aaecc8bf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/MainActivity.kt @@ -13,6 +13,7 @@ import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.keyboard.BuildConfig import com.simplemobiletools.keyboard.R +import com.simplemobiletools.keyboard.extensions.config import kotlinx.android.synthetic.main.activity_main.* class MainActivity : SimpleActivity() { @@ -42,6 +43,7 @@ class MainActivity : SimpleActivity() { updateTextColors(main_holder) updateChangeKeyboardColor() + main_holder.setBackgroundColor(config.backgroundColor.lightenColor(3)) } override fun onCreateOptionsMenu(menu: Menu): Boolean { diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt index a0b74858..1956b496 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt @@ -1,18 +1,3 @@ -/* - * Copyright (C) 2008-2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ package com.simplemobiletools.keyboard.helpers import android.content.Context 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 f7114aec..3748ebdb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.content.Context import android.graphics.* import android.graphics.Paint.Align +import android.graphics.drawable.ColorDrawable import android.graphics.drawable.Drawable import android.inputmethodservice.KeyboardView import android.media.AudioManager @@ -107,7 +108,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut private var mLabelTextSize = 0 private var mKeyTextSize = 0 - private var mKeyTextColor = 0 private var mShadowRadius = 0f private var mShadowColor = 0 private val mBackgroundDimAmount: Float @@ -273,7 +273,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut R.styleable.MyKeyboardView_keyPreviewOffset -> mPreviewOffset = attributes.getDimensionPixelOffset(attr, 0) R.styleable.MyKeyboardView_keyPreviewHeight -> mPreviewHeight = attributes.getDimensionPixelSize(attr, 80) R.styleable.MyKeyboardView_keyTextSize -> mKeyTextSize = attributes.getDimensionPixelSize(attr, 18) - R.styleable.MyKeyboardView_keyTextColor -> mKeyTextColor = attributes.getColor(attr, -0x1000000) R.styleable.MyKeyboardView_labelTextSize -> mLabelTextSize = attributes.getDimensionPixelSize(attr, 14) R.styleable.MyKeyboardView_popupLayout -> mPopupLayout = attributes.getResourceId(attr, 0) R.styleable.MyKeyboardView_shadowColor -> mShadowColor = attributes.getColor(attr, 0) @@ -350,6 +349,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mTextColor = context.config.textColor mBackgroundColor = context.config.backgroundColor mPrimaryColor = context.getAdjustedPrimaryColor() + background = ColorDrawable(mBackgroundColor) } } @@ -565,7 +565,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut val kbdPaddingTop: Int = paddingTop val keys = mKeys val invalidKey = mInvalidatedKey - paint.color = mKeyTextColor + paint.color = mTextColor val smallLetterPaint = Paint() smallLetterPaint.set(paint) smallLetterPaint.apply { @@ -634,7 +634,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut paint.color = if (key.focused) { mPrimaryColor.getContrastColor() } else { - mKeyTextColor + mTextColor } // Draw the text @@ -661,6 +661,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut if (code == MyKeyboard.KEYCODE_ENTER) { key.icon!!.applyColorFilter(mPrimaryColor.getContrastColor()) + } else if (code == MyKeyboard.KEYCODE_DELETE || code == MyKeyboard.KEYCODE_SHIFT) { + key.icon!!.applyColorFilter(mTextColor) } val drawableX = (key.width - key.icon!!.intrinsicWidth) / 2 diff --git a/app/src/main/res/layout/keyboard_view_keyboard.xml b/app/src/main/res/layout/keyboard_view_keyboard.xml index f8df7171..24501c88 100644 --- a/app/src/main/res/layout/keyboard_view_keyboard.xml +++ b/app/src/main/res/layout/keyboard_view_keyboard.xml @@ -4,4 +4,4 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" - android:background="@color/md_grey_800_dark" /> + android:background="@color/md_grey_800" />