From 27e273da84dabd2f478db504fa681e9f695b869d Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 25 Oct 2024 15:32:38 +0530 Subject: [PATCH] Update dependencies and AGP --- .../keyboard/activities/SimpleActivity.kt | 2 + .../fossify/keyboard/extensions/Context.kt | 102 ++++++++++++++---- .../keyboard/services/SimpleKeyboardIME.kt | 2 +- .../fossify/keyboard/views/MyKeyboardView.kt | 4 +- gradle/libs.versions.toml | 10 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 6 files changed, 92 insertions(+), 30 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/keyboard/activities/SimpleActivity.kt b/app/src/main/kotlin/org/fossify/keyboard/activities/SimpleActivity.kt index 77575117..be1509e3 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/activities/SimpleActivity.kt @@ -27,4 +27,6 @@ open class SimpleActivity : BaseSimpleActivity() { ) override fun getAppLauncherName() = getString(R.string.app_launcher_name) + + override fun getRepositoryName() = "Keyboard" } diff --git a/app/src/main/kotlin/org/fossify/keyboard/extensions/Context.kt b/app/src/main/kotlin/org/fossify/keyboard/extensions/Context.kt index c48c4279..09663d72 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/extensions/Context.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/extensions/Context.kt @@ -7,7 +7,11 @@ import android.graphics.Color import android.inputmethodservice.InputMethodService import android.os.IBinder import android.os.UserManager -import android.view.* +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.view.Window +import android.view.WindowManager import android.view.inputmethod.InputMethodInfo import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodSubtype @@ -16,13 +20,48 @@ import androidx.appcompat.app.AlertDialog import androidx.core.content.res.ResourcesCompat import com.google.android.material.dialog.MaterialAlertDialogBuilder import org.fossify.commons.databinding.DialogTitleBinding -import org.fossify.commons.extensions.* +import org.fossify.commons.extensions.baseConfig +import org.fossify.commons.extensions.darkenColor +import org.fossify.commons.extensions.getColoredDrawableWithColor +import org.fossify.commons.extensions.getProperBackgroundColor +import org.fossify.commons.extensions.getProperPrimaryColor +import org.fossify.commons.extensions.getProperTextColor +import org.fossify.commons.extensions.isBlackAndWhiteTheme +import org.fossify.commons.extensions.isDynamicTheme +import org.fossify.commons.extensions.isSystemInDarkMode +import org.fossify.commons.extensions.lightenColor +import org.fossify.commons.extensions.updateTextColors import org.fossify.commons.helpers.isNougatPlus import org.fossify.commons.models.RadioItem import org.fossify.commons.views.MyTextView import org.fossify.keyboard.R import org.fossify.keyboard.databases.ClipsDatabase -import org.fossify.keyboard.helpers.* +import org.fossify.keyboard.helpers.Config +import org.fossify.keyboard.helpers.INPUT_METHOD_SUBTYPE_VOICE +import org.fossify.keyboard.helpers.LANGUAGE_ARABIC +import org.fossify.keyboard.helpers.LANGUAGE_BENGALI +import org.fossify.keyboard.helpers.LANGUAGE_BULGARIAN +import org.fossify.keyboard.helpers.LANGUAGE_CHUVASH +import org.fossify.keyboard.helpers.LANGUAGE_DANISH +import org.fossify.keyboard.helpers.LANGUAGE_ENGLISH_DVORAK +import org.fossify.keyboard.helpers.LANGUAGE_ENGLISH_QWERTZ +import org.fossify.keyboard.helpers.LANGUAGE_ESPERANTO +import org.fossify.keyboard.helpers.LANGUAGE_FRENCH_AZERTY +import org.fossify.keyboard.helpers.LANGUAGE_FRENCH_BEPO +import org.fossify.keyboard.helpers.LANGUAGE_GERMAN +import org.fossify.keyboard.helpers.LANGUAGE_GREEK +import org.fossify.keyboard.helpers.LANGUAGE_HEBREW +import org.fossify.keyboard.helpers.LANGUAGE_LITHUANIAN +import org.fossify.keyboard.helpers.LANGUAGE_NORWEGIAN +import org.fossify.keyboard.helpers.LANGUAGE_POLISH +import org.fossify.keyboard.helpers.LANGUAGE_ROMANIAN +import org.fossify.keyboard.helpers.LANGUAGE_RUSSIAN +import org.fossify.keyboard.helpers.LANGUAGE_SLOVENIAN +import org.fossify.keyboard.helpers.LANGUAGE_SPANISH +import org.fossify.keyboard.helpers.LANGUAGE_SWEDISH +import org.fossify.keyboard.helpers.LANGUAGE_TURKISH_Q +import org.fossify.keyboard.helpers.LANGUAGE_UKRAINIAN +import org.fossify.keyboard.helpers.LANGUAGE_VIETNAMESE_TELEX import org.fossify.keyboard.interfaces.ClipsDao val Context.config: Config get() = Config.newInstance(applicationContext.safeStorageContext) @@ -58,7 +97,7 @@ fun Context.getCurrentClip(): String? { } fun Context.getKeyboardBackgroundColor(): Int { - val color = if (config.isUsingSystemTheme) { + val color = if (isDynamicTheme()) { resources.getColor(R.color.you_keyboard_background_color, theme) } else { getProperBackgroundColor().darkenColor(2) @@ -78,8 +117,8 @@ fun Context.getKeyboardBackgroundColor(): Int { } fun Context.getStrokeColor(): Int { - return if (config.isUsingSystemTheme) { - if (isUsingSystemDarkTheme()) { + return if (isDynamicTheme()) { + if (isSystemInDarkMode()) { resources.getColor(R.color.md_grey_800, theme) } else { resources.getColor(R.color.md_grey_400, theme) @@ -94,7 +133,7 @@ fun Context.getStrokeColor(): Int { } } -fun Context.getKeyboardDialogBuilder() = if (safeStorageContext.baseConfig.isUsingSystemTheme) { +fun Context.getKeyboardDialogBuilder() = if (safeStorageContext.isDynamicTheme()) { MaterialAlertDialogBuilder(this, R.style.MyKeyboard_Alert) } else { AlertDialog.Builder(this, R.style.MyKeyboard_Alert) @@ -137,9 +176,18 @@ fun Context.setupKeyboardDialogStuff( show() val bgDrawable = when { - isBlackAndWhiteTheme() -> ResourcesCompat.getDrawable(resources, R.drawable.black_dialog_background, theme) - baseConfig.isUsingSystemTheme -> ResourcesCompat.getDrawable(resources, R.drawable.dialog_you_background, theme) - else -> resources.getColoredDrawableWithColor(R.drawable.dialog_bg, baseConfig.backgroundColor) + isBlackAndWhiteTheme() -> ResourcesCompat.getDrawable( + resources, R.drawable.black_dialog_background, theme + ) + + isDynamicTheme() -> ResourcesCompat.getDrawable( + resources, R.drawable.dialog_you_background, theme + ) + + else -> resources.getColoredDrawableWithColor( + drawableId = R.drawable.dialog_bg, + color = baseConfig.backgroundColor + ) } window?.setBackgroundDrawable(bgDrawable) @@ -148,14 +196,17 @@ fun Context.setupKeyboardDialogStuff( } else { var title: TextView? = null if (titleId != 0 || titleText.isNotEmpty()) { - title = DialogTitleBinding.inflate(LayoutInflater.from(this)).dialogTitleTextview.apply { - if (titleText.isNotEmpty()) { - text = titleText - } else { - setText(titleId) - } - setTextColor(textColor) - } + title = + DialogTitleBinding + .inflate(LayoutInflater.from(this)) + .dialogTitleTextview.apply { + if (titleText.isNotEmpty()) { + text = titleText + } else { + setText(titleId) + } + setTextColor(textColor) + } } // if we use the same primary and background color, use the text color for dialog confirmation buttons @@ -183,9 +234,18 @@ fun Context.setupKeyboardDialogStuff( getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(dialogButtonColor) val bgDrawable = when { - isBlackAndWhiteTheme() -> ResourcesCompat.getDrawable(resources, R.drawable.black_dialog_background, theme) - baseConfig.isUsingSystemTheme -> ResourcesCompat.getDrawable(resources, R.drawable.dialog_you_background, theme) - else -> resources.getColoredDrawableWithColor(R.drawable.dialog_bg, baseConfig.backgroundColor) + isBlackAndWhiteTheme() -> ResourcesCompat.getDrawable( + resources, R.drawable.black_dialog_background, theme + ) + + isDynamicTheme() -> ResourcesCompat.getDrawable( + resources, R.drawable.dialog_you_background, theme + ) + + else -> resources.getColoredDrawableWithColor( + drawableId = R.drawable.dialog_bg, + color = baseConfig.backgroundColor + ) } window?.setBackgroundDrawable(bgDrawable) diff --git a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt index d90f1938..de938490 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt @@ -521,7 +521,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared if (key != null && key in arrayOf( SHOW_KEY_BORDERS, KEYBOARD_LANGUAGE, HEIGHT_PERCENTAGE, SHOW_NUMBERS_ROW, VOICE_INPUT_METHOD, TEXT_COLOR, BACKGROUND_COLOR, PRIMARY_COLOR, ACCENT_COLOR, CUSTOM_TEXT_COLOR, CUSTOM_BACKGROUND_COLOR, - CUSTOM_PRIMARY_COLOR, CUSTOM_ACCENT_COLOR, IS_USING_SHARED_THEME, IS_USING_SYSTEM_THEME + CUSTOM_PRIMARY_COLOR, CUSTOM_ACCENT_COLOR, IS_GLOBAL_THEME_ENABLED, IS_SYSTEM_THEME_ENABLED ) ) { keyboardView?.setupKeyboard() diff --git a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt index a9e3a986..9b06189f 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt @@ -388,7 +388,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mStrokeColor = getStrokeColor() mShowKeyBorders = config.showKeyBorders - mUsingSystemTheme = config.isUsingSystemTheme + mUsingSystemTheme = isDynamicTheme() mVoiceInputMethod = config.voiceInputMethod } @@ -1702,7 +1702,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut private fun getKeyColor(): Int { val backgroundColor = safeStorageContext.getKeyboardBackgroundColor() val lighterColor = backgroundColor.lightenColor() - val keyColor = if (context.config.isUsingSystemTheme) { + val keyColor = if (context.isDynamicTheme()) { lighterColor } else { if (backgroundColor == Color.BLACK) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e45f640c..c7c394a4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,19 +1,19 @@ [versions] #jetbrains -kotlin = "1.9.23" +kotlin = "1.9.25" #AndroidX androidx-autofill = "1.1.0" -androidx-emoji2 = "1.4.0" +androidx-emoji2 = "1.5.0" #KSP -ksp = "1.9.23-1.0.19" +ksp = "1.9.25-1.0.20" #Detekt detekt = "1.23.3" #Room room = "2.6.1" #Fossify -commons = "4803866c8b" +commons = "54b78551a4" #Gradle -gradlePlugins-agp = "8.2.0" +gradlePlugins-agp = "8.7.1" #build app-build-compileSDKVersion = "34" app-build-targetSDK = "34" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e9e32299..7667c963 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jan 04 09:48:27 CET 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME