updating some more colors dynamically

This commit is contained in:
tibbi 2022-01-18 09:27:10 +01:00
parent 945c82402a
commit 29057417fd
4 changed files with 9 additions and 20 deletions

View File

@ -13,6 +13,7 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.commons.models.FAQItem
import com.simplemobiletools.keyboard.BuildConfig import com.simplemobiletools.keyboard.BuildConfig
import com.simplemobiletools.keyboard.R import com.simplemobiletools.keyboard.R
import com.simplemobiletools.keyboard.extensions.config
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : SimpleActivity() { class MainActivity : SimpleActivity() {
@ -42,6 +43,7 @@ class MainActivity : SimpleActivity() {
updateTextColors(main_holder) updateTextColors(main_holder)
updateChangeKeyboardColor() updateChangeKeyboardColor()
main_holder.setBackgroundColor(config.backgroundColor.lightenColor(3))
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {

View File

@ -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 package com.simplemobiletools.keyboard.helpers
import android.content.Context import android.content.Context

View File

@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.graphics.* import android.graphics.*
import android.graphics.Paint.Align import android.graphics.Paint.Align
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.inputmethodservice.KeyboardView import android.inputmethodservice.KeyboardView
import android.media.AudioManager import android.media.AudioManager
@ -107,7 +108,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
private var mLabelTextSize = 0 private var mLabelTextSize = 0
private var mKeyTextSize = 0 private var mKeyTextSize = 0
private var mKeyTextColor = 0
private var mShadowRadius = 0f private var mShadowRadius = 0f
private var mShadowColor = 0 private var mShadowColor = 0
private val mBackgroundDimAmount: Float 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_keyPreviewOffset -> mPreviewOffset = attributes.getDimensionPixelOffset(attr, 0)
R.styleable.MyKeyboardView_keyPreviewHeight -> mPreviewHeight = attributes.getDimensionPixelSize(attr, 80) R.styleable.MyKeyboardView_keyPreviewHeight -> mPreviewHeight = attributes.getDimensionPixelSize(attr, 80)
R.styleable.MyKeyboardView_keyTextSize -> mKeyTextSize = attributes.getDimensionPixelSize(attr, 18) 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_labelTextSize -> mLabelTextSize = attributes.getDimensionPixelSize(attr, 14)
R.styleable.MyKeyboardView_popupLayout -> mPopupLayout = attributes.getResourceId(attr, 0) R.styleable.MyKeyboardView_popupLayout -> mPopupLayout = attributes.getResourceId(attr, 0)
R.styleable.MyKeyboardView_shadowColor -> mShadowColor = attributes.getColor(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 mTextColor = context.config.textColor
mBackgroundColor = context.config.backgroundColor mBackgroundColor = context.config.backgroundColor
mPrimaryColor = context.getAdjustedPrimaryColor() mPrimaryColor = context.getAdjustedPrimaryColor()
background = ColorDrawable(mBackgroundColor)
} }
} }
@ -565,7 +565,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
val kbdPaddingTop: Int = paddingTop val kbdPaddingTop: Int = paddingTop
val keys = mKeys val keys = mKeys
val invalidKey = mInvalidatedKey val invalidKey = mInvalidatedKey
paint.color = mKeyTextColor paint.color = mTextColor
val smallLetterPaint = Paint() val smallLetterPaint = Paint()
smallLetterPaint.set(paint) smallLetterPaint.set(paint)
smallLetterPaint.apply { smallLetterPaint.apply {
@ -634,7 +634,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
paint.color = if (key.focused) { paint.color = if (key.focused) {
mPrimaryColor.getContrastColor() mPrimaryColor.getContrastColor()
} else { } else {
mKeyTextColor mTextColor
} }
// Draw the text // Draw the text
@ -661,6 +661,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
if (code == MyKeyboard.KEYCODE_ENTER) { if (code == MyKeyboard.KEYCODE_ENTER) {
key.icon!!.applyColorFilter(mPrimaryColor.getContrastColor()) 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 val drawableX = (key.width - key.icon!!.intrinsicWidth) / 2

View File

@ -4,4 +4,4 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:background="@color/md_grey_800_dark" /> android:background="@color/md_grey_800" />