From 695017b3f074df8e264c7519832797f86bb8baed Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Tue, 11 Jun 2024 08:12:36 +0530 Subject: [PATCH 01/22] Update symbols button label to ?123 --- app/src/main/res/xml/keys_letters_hebrew.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/xml/keys_letters_hebrew.xml b/app/src/main/res/xml/keys_letters_hebrew.xml index 69f3b5d7..8e2ecf49 100644 --- a/app/src/main/res/xml/keys_letters_hebrew.xml +++ b/app/src/main/res/xml/keys_letters_hebrew.xml @@ -143,7 +143,7 @@ Date: Wed, 12 Jun 2024 01:24:36 +0530 Subject: [PATCH 02/22] Replace "abc" key label with "ABC" --- app/src/main/res/xml/keys_symbols.xml | 2 +- app/src/main/res/xml/keys_symbols_alt.xml | 2 +- app/src/main/res/xml/keys_symbols_shift.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/xml/keys_symbols.xml b/app/src/main/res/xml/keys_symbols.xml index 9cff78f2..9dfe94ee 100755 --- a/app/src/main/res/xml/keys_symbols.xml +++ b/app/src/main/res/xml/keys_symbols.xml @@ -65,7 +65,7 @@ Date: Wed, 12 Jun 2024 19:21:19 +0530 Subject: [PATCH 03/22] Minor code cleanup --- app/src/main/kotlin/org/fossify/keyboard/helpers/MyKeyboard.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/org/fossify/keyboard/helpers/MyKeyboard.kt b/app/src/main/kotlin/org/fossify/keyboard/helpers/MyKeyboard.kt index 2fafc83b..0e85f200 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/helpers/MyKeyboard.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/helpers/MyKeyboard.kt @@ -300,7 +300,7 @@ class MyKeyboard { row.defaultHorizontalGap = mDefaultHorizontalGap mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightPercentage) - characters.forEachIndexed { index, character -> + characters.forEach { character -> val key = Key(row) if (column >= MAX_KEYS_PER_MINI_ROW) { column = 0 From 893e82b2b7ece1b2361e9c47a0b01012e28b71f2 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Wed, 12 Jun 2024 22:04:09 +0530 Subject: [PATCH 04/22] Fix overlapping between characters --- .../org/fossify/keyboard/views/MyKeyboardView.kt | 11 ++++++++++- app/src/main/res/values/dimens.xml | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) 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 b4a5a895..b6262bbd 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt @@ -616,7 +616,16 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } if (key.topSmallNumber.isNotEmpty() && !(context.config.showNumbersRow && Regex("\\d").matches(key.topSmallNumber))) { - canvas.drawText(key.topSmallNumber, key.width - mTopSmallNumberMarginWidth, mTopSmallNumberMarginHeight, smallLetterPaint) + val bounds = Rect().also { + smallLetterPaint.getTextBounds(key.topSmallNumber, 0, key.topSmallNumber.length, it) + } + + canvas.drawText( + key.topSmallNumber, + key.width - bounds.width() / 2f - mTopSmallNumberMarginWidth, + key.y + mTopSmallNumberSize + mTopSmallNumberMarginHeight, + smallLetterPaint + ) } // Turn off drop shadow diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index b67257d1..0c3d54f6 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,7 +1,7 @@ 60dp - 12dp - 18dp + 5dp + 5dp 46dp 32dp 40dp From 63a66b6c88a2bfedafdc504335c26489b6732185 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 13 Jun 2024 17:50:34 +0530 Subject: [PATCH 05/22] Hide suggestions when emojis palette is visible --- .../main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt | 2 ++ 1 file changed, 2 insertions(+) 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 b6262bbd..ec4a1a91 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt @@ -1514,6 +1514,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut fun openEmojiPalette() { keyboardViewBinding!!.emojiPaletteHolder.beVisible() + keyboardViewBinding!!.suggestionsHolder.hideAllInlineContentViews() setupEmojis() } @@ -1521,6 +1522,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut keyboardViewBinding?.apply { emojiPaletteHolder.beGone() emojisList.scrollToPosition(0) + suggestionsHolder.showAllInlineContentViews() } } From cf0ea9d7947df6c58836c82c895bffb0125ab58c Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 13 Jun 2024 18:21:35 +0530 Subject: [PATCH 06/22] Update keyboard background colors - Update keyboard background color to surface container color - Change navigation bar color when keyboard is shown --- .../fossify/keyboard/extensions/Context.kt | 20 +++++++ .../keyboard/services/SimpleKeyboardIME.kt | 23 ++++++-- .../fossify/keyboard/views/MyKeyboardView.kt | 57 ++++--------------- .../res/layout/keyboard_view_keyboard.xml | 2 - app/src/main/res/values-night-v31/colors.xml | 3 +- app/src/main/res/values-v31/colors.xml | 3 +- gradle/libs.versions.toml | 2 +- 7 files changed, 52 insertions(+), 58 deletions(-) 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 35cb96b6..44876731 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/extensions/Context.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/extensions/Context.kt @@ -57,6 +57,26 @@ fun Context.getCurrentClip(): String? { return clipboardManager.primaryClip?.getItemAt(0)?.text?.toString() } +fun Context.getKeyboardBackgroundColor(): Int { + val color = if (config.isUsingSystemTheme) { + resources.getColor(R.color.you_keyboard_background_color, theme) + } else { + getProperBackgroundColor().darkenColor(2) + } + + // use darker background color when key borders are enabled + if (config.showKeyBorders) { + val darkerColor = color.darkenColor(2) + return if (darkerColor == Color.WHITE) { + resources.getColor(R.color.md_grey_200, theme) + } else { + darkerColor + } + } + + return color +} + fun Context.getStrokeColor(): Int { return if (config.isUsingSystemTheme) { if (isUsingSystemDarkTheme()) { 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 c3836455..54627101 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt @@ -29,15 +29,16 @@ import androidx.autofill.inline.common.TextViewStyle import androidx.autofill.inline.common.ViewStyle import androidx.autofill.inline.v1.InlineSuggestionUi import androidx.core.graphics.drawable.toBitmap -import org.fossify.commons.extensions.applyColorFilter -import org.fossify.commons.extensions.getProperBackgroundColor -import org.fossify.commons.extensions.getProperTextColor -import org.fossify.commons.extensions.getSharedPrefs +import androidx.core.view.WindowCompat +import androidx.core.view.WindowInsetsCompat +import androidx.core.view.updatePadding +import org.fossify.commons.extensions.* import org.fossify.commons.helpers.isNougatPlus import org.fossify.commons.helpers.isPiePlus import org.fossify.keyboard.R import org.fossify.keyboard.databinding.KeyboardViewKeyboardBinding import org.fossify.keyboard.extensions.config +import org.fossify.keyboard.extensions.getKeyboardBackgroundColor import org.fossify.keyboard.extensions.getStrokeColor import org.fossify.keyboard.extensions.safeStorageContext import org.fossify.keyboard.helpers.* @@ -80,6 +81,14 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared } override fun onCreateInputView(): View { + val window = window.window!! + WindowCompat.setDecorFitsSystemWindows(window, false) + window.decorView.setOnApplyWindowInsetsListener { _, insets -> + val bottom = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom + binding.keyboardHolder.updatePadding(bottom = bottom) + insets + } + binding = KeyboardViewKeyboardBinding.inflate(layoutInflater) keyboardView = binding.keyboardView.apply { setKeyboardHolder(binding) @@ -87,9 +96,15 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared setEditorInfo(currentInputEditorInfo) mOnKeyboardActionListener = this@SimpleKeyboardIME } + return binding.root } + override fun onStartInputView(editorInfo: EditorInfo?, restarting: Boolean) { + super.onStartInputView(editorInfo, restarting) + window.window?.updateNavigationBarBackgroundColor(getKeyboardBackgroundColor()) + } + override fun onPress(primaryCode: Int) { if (primaryCode != 0) { keyboardView?.vibrateIfNeeded() 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 ec4a1a91..9d353029 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt @@ -388,27 +388,24 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } val isMainKeyboard = changedView == null || changedView != keyboardPopupBinding?.miniKeyboardView + mKeyColor = getKeyColor() + mKeyColorPressed = mKeyColor.adjustAlpha(0.2f) mKeyBackground = if (mShowKeyBorders && isMainKeyboard) { resources.getDrawable(R.drawable.keyboard_key_selector_outlined, context.theme) } else { resources.getDrawable(R.drawable.keyboard_key_selector, context.theme) } - mKeyColor = getKeyColor() - mKeyColorPressed = mKeyColor.adjustAlpha(0.2f) val strokeColor = context.getStrokeColor() - - val toolbarColor = getToolbarColor() - val darkerColor = getKeyboardBackgroundColor() - val miniKeyboardBackgroundColor = getToolbarColor(4) + val backgroundColor = context.getKeyboardBackgroundColor() if (!isMainKeyboard) { val previewBackground = background as LayerDrawable - previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(miniKeyboardBackgroundColor) + previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(backgroundColor) previewBackground.findDrawableByLayerId(R.id.button_background_stroke).applyColorFilter(strokeColor) background = previewBackground } else { - background.applyColorFilter(darkerColor) + background.applyColorFilter(backgroundColor) } val rippleBg = resources.getDrawable(R.drawable.clipboard_background, context.theme) as RippleDrawable @@ -420,7 +417,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut keyboardViewBinding?.apply { topKeyboardDivider.beGoneIf(wasDarkened) topKeyboardDivider.background = ColorDrawable(strokeColor) - mToolbarHolder?.background = ColorDrawable(toolbarColor) + mToolbarHolder?.background = ColorDrawable(backgroundColor) clipboardValue.apply { background = rippleBg @@ -438,7 +435,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut topClipboardDivider.beGoneIf(wasDarkened) topClipboardDivider.background = ColorDrawable(strokeColor) - clipboardManagerHolder.background = ColorDrawable(toolbarColor) + clipboardManagerHolder.background = ColorDrawable(backgroundColor) clipboardManagerClose.applyColorFilter(mTextColor) clipboardManagerManage.applyColorFilter(mTextColor) @@ -448,7 +445,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut clipboardContentPlaceholder2.setTextColor(mTextColor) } - setupEmojiPalette(toolbarColor = toolbarColor, backgroundColor = mBackgroundColor, textColor = mTextColor) + setupEmojiPalette(toolbarColor = backgroundColor, backgroundColor = mBackgroundColor, textColor = mTextColor) if (context.config.keyboardLanguage == LANGUAGE_VIETNAMESE_TELEX) { setupLanguageTelex() } else { @@ -587,7 +584,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut val key = keys[i] val code = key.code - // TODO: Space key background on a KEYBOARD_PHONE should not be applied setupKeyBackground(key, code, canvas) // Switch the character to uppercase if shift is pressed @@ -906,10 +902,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } } - val previewBackgroundColor = getToolbarColor(4) - val previewBackground = mPreviewText!!.background as LayerDrawable - previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(previewBackgroundColor) + previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(context.getKeyboardBackgroundColor()) previewBackground.findDrawableByLayerId(R.id.button_background_stroke).applyColorFilter(context.getStrokeColor()) mPreviewText!!.background = previewBackground @@ -1660,39 +1654,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } } - private fun maybeDarkenColor(color: Int, factor: Int): Int { - // use darker background color when key borders are enabled - if (context.config.showKeyBorders) { - val darkerColor = color.darkenColor(factor) - return if (darkerColor == Color.WHITE) { - resources.getColor(R.color.md_grey_200, context.theme) - } else { - darkerColor - } - } - return color - } - - private fun getToolbarColor(factor: Int = 8): Int { - val color = if (context.config.isUsingSystemTheme) { - resources.getColor(R.color.you_keyboard_toolbar_color, context.theme) - } else { - mBackgroundColor.darkenColor(factor) - } - return maybeDarkenColor(color, 2) - } - - private fun getKeyboardBackgroundColor(): Int { - val color = if (context.config.isUsingSystemTheme) { - resources.getColor(R.color.you_keyboard_background_color, context.theme) - } else { - mBackgroundColor.darkenColor(2) - } - return maybeDarkenColor(color, 6) - } - private fun getKeyColor(): Int { - val backgroundColor = getKeyboardBackgroundColor() + val backgroundColor = context.getKeyboardBackgroundColor() val lighterColor = backgroundColor.lightenColor() val keyColor = if (context.config.isUsingSystemTheme) { lighterColor diff --git a/app/src/main/res/layout/keyboard_view_keyboard.xml b/app/src/main/res/layout/keyboard_view_keyboard.xml index 2c98b48f..1897354b 100644 --- a/app/src/main/res/layout/keyboard_view_keyboard.xml +++ b/app/src/main/res/layout/keyboard_view_keyboard.xml @@ -9,7 +9,6 @@ android:id="@+id/toolbar_holder" android:layout_width="match_parent" android:layout_height="@dimen/toolbar_height" - android:layout_above="@+id/keyboard_view" app:layout_constraintBottom_toTopOf="@+id/keyboard_view" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"> @@ -70,7 +69,6 @@ - - @android:color/system_neutral1_900 - #151515 + @android:color/system_neutral2_900 diff --git a/app/src/main/res/values-v31/colors.xml b/app/src/main/res/values-v31/colors.xml index 25d6491a..8517cc1d 100644 --- a/app/src/main/res/values-v31/colors.xml +++ b/app/src/main/res/values-v31/colors.xml @@ -1,5 +1,4 @@ - @android:color/system_neutral1_10 - @android:color/system_neutral1_50 + @color/m3_ref_palette_dynamic_neutral_variant96 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d561f17d..563f5e4c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ ksp = "1.9.0-1.0.12" #Room room = "2.6.0-beta01" #Fossify -commons = "f056aa71e7" +commons = "908d6cce56" #Gradle gradlePlugins-agp = "8.2.0" #build From c1823d8a0cc49c1b1abf963e031d8d71640a1866 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 13 Jun 2024 18:28:57 +0530 Subject: [PATCH 07/22] Enable key borders by default --- app/src/main/kotlin/org/fossify/keyboard/helpers/Config.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/org/fossify/keyboard/helpers/Config.kt b/app/src/main/kotlin/org/fossify/keyboard/helpers/Config.kt index cbc73164..c40dfd75 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/helpers/Config.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/helpers/Config.kt @@ -24,7 +24,7 @@ class Config(context: Context) : BaseConfig(context) { set(enableCapitalization) = prefs.edit().putBoolean(SENTENCES_CAPITALIZATION, enableCapitalization).apply() var showKeyBorders: Boolean - get() = prefs.getBoolean(SHOW_KEY_BORDERS, false) + get() = prefs.getBoolean(SHOW_KEY_BORDERS, true) set(showKeyBorders) = prefs.edit().putBoolean(SHOW_KEY_BORDERS, showKeyBorders).apply() var lastExportedClipsFolder: String From 1d8e658c5e958ec04a57175c1c057dec24059642 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 13 Jun 2024 22:09:29 +0530 Subject: [PATCH 08/22] Increase emoji size to 32sp --- app/src/main/res/values/dimens.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 0c3d54f6..f07513b7 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -17,6 +17,6 @@ 22sp 26sp 16sp - 28sp + 32sp 14sp From 90a0c52ad299cb879babb3cfc5e790b8d45e93b5 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 13 Jun 2024 22:45:50 +0530 Subject: [PATCH 09/22] Decrease language change icon size --- .../org/fossify/keyboard/views/MyKeyboardView.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 9d353029..5f6948a9 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt @@ -638,19 +638,19 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut if (code == KEYCODE_ENTER) { key.icon!!.applyColorFilter(mPrimaryColor.getContrastColor()) - key.secondaryIcon?.applyColorFilter(mPrimaryColor.getContrastColor()) + key.secondaryIcon?.applyColorFilter(mPrimaryColor.getContrastColor().adjustAlpha(0.6f)) } else if (code == KEYCODE_DELETE || code == KEYCODE_SHIFT || code == KEYCODE_EMOJI) { key.icon!!.applyColorFilter(mTextColor) - key.secondaryIcon?.applyColorFilter(mTextColor) + key.secondaryIcon?.applyColorFilter(mTextColor.adjustAlpha(0.6f)) } + val keyIcon = key.icon!! val secondaryIcon = key.secondaryIcon - if (secondaryIcon != null) { val keyIconWidth = (keyIcon.intrinsicWidth * 0.9f).toInt() val keyIconHeight = (keyIcon.intrinsicHeight * 0.9f).toInt() - val secondaryIconWidth = (secondaryIcon.intrinsicWidth * .6f).toInt() - val secondaryIconHeight = (secondaryIcon.intrinsicHeight * .6f).toInt() + val secondaryIconWidth = (secondaryIcon.intrinsicWidth * 0.5f).toInt() + val secondaryIconHeight = (secondaryIcon.intrinsicHeight * 0.5f).toInt() val centerX = key.width / 2 val centerY = key.height / 2 From 95576c0a95c4fc7b176e07b207fb6c5fac4c58d7 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 13 Jun 2024 22:51:51 +0530 Subject: [PATCH 10/22] Reduce emoji item size slightly --- app/src/main/res/values/dimens.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index f07513b7..98999f3b 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -8,7 +8,7 @@ 60dp -10dp 28dp - 46dp + 42dp 24dp 4dp 42dp @@ -17,6 +17,6 @@ 22sp 26sp 16sp - 32sp + 30sp 14sp From 1b767ba2fa80034990bc6be8fa2f4ee670d9e321 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 13 Jun 2024 23:06:04 +0530 Subject: [PATCH 11/22] Properly hide suggestions when emojis palette is visible --- .../main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 5f6948a9..95fd21ce 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt @@ -1508,7 +1508,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut fun openEmojiPalette() { keyboardViewBinding!!.emojiPaletteHolder.beVisible() - keyboardViewBinding!!.suggestionsHolder.hideAllInlineContentViews() + keyboardViewBinding!!.suggestionsHolder.beGone() setupEmojis() } @@ -1516,7 +1516,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut keyboardViewBinding?.apply { emojiPaletteHolder.beGone() emojisList.scrollToPosition(0) - suggestionsHolder.showAllInlineContentViews() + suggestionsHolder.beVisible() } } From 5cd0aaf05f4e6a877da93dd037eea83d80c09e94 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 13 Jun 2024 23:45:23 +0530 Subject: [PATCH 12/22] Organize preferences --- app/src/main/res/layout/activity_settings.xml | 138 ++++++++++-------- 1 file changed, 81 insertions(+), 57 deletions(-) diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 25ff292b..3997d55e 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -117,20 +117,54 @@ + + + + + + + + + android:text="@string/manage_keyboard_languages" /> + + + + - - - - - - + + + + + + + + + + + + + + android:text="@string/manage_clipboard_items" /> - - - + android:text="@string/show_clipboard_content" /> - - - - - - - From 2f45c91c355a69ef73a52403d1a14c21eaedbc37 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 13 Jun 2024 23:57:17 +0530 Subject: [PATCH 13/22] Move action buttons back into the option menu --- app/src/main/res/menu/menu_main.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 0d878488..158624cf 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -5,14 +5,14 @@ android:id="@+id/settings" android:icon="@drawable/ic_settings_cog_vector" android:title="@string/settings" - app:showAsAction="always" /> - + app:showAsAction="ifRoom" /> + From f04f1f4a85d210109c30ca88a87ce47c43dc4f35 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 14 Jun 2024 00:04:30 +0530 Subject: [PATCH 14/22] Update space bar color --- .../fossify/keyboard/views/MyKeyboardView.kt | 21 ++++++++--------- ...ard_space_background_material_outlined.xml | 23 ------------------- 2 files changed, 9 insertions(+), 35 deletions(-) delete mode 100644 app/src/main/res/drawable/keyboard_space_background_material_outlined.xml 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 95fd21ce..02e817b8 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt @@ -738,19 +738,16 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } private fun getSpaceKeyBackground(): Drawable? { - val drawableId = if (mUsingSystemTheme) { - if (mShowKeyBorders) { - R.drawable.keyboard_space_background_material_outlined - } else { - R.drawable.keyboard_space_background_material - } - } else { - if (mShowKeyBorders) { - R.drawable.keyboard_key_selector_outlined - } else { - R.drawable.keyboard_space_background - } + if (mShowKeyBorders) { + return mKeyBackground } + + val drawableId = if (mUsingSystemTheme) { + R.drawable.keyboard_space_background_material + } else { + R.drawable.keyboard_space_background + } + return resources.getDrawable(drawableId, context.theme) } diff --git a/app/src/main/res/drawable/keyboard_space_background_material_outlined.xml b/app/src/main/res/drawable/keyboard_space_background_material_outlined.xml deleted file mode 100644 index fcb54960..00000000 --- a/app/src/main/res/drawable/keyboard_space_background_material_outlined.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - From 4947fae5c3e9f48e864562f56bc8ac4e44953691 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 14 Jun 2024 00:08:32 +0530 Subject: [PATCH 15/22] Update dependencies --- gradle/libs.versions.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 563f5e4c..0df55fea 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,13 +1,13 @@ [versions] #jetbrains -kotlin = "1.9.0" +kotlin = "1.9.23" #AndroidX androidx-autofill = "1.1.0" -androidx-emoji2 = "1.2.0" +androidx-emoji2 = "1.4.0" #KSP -ksp = "1.9.0-1.0.12" +ksp = "1.9.23-1.0.19" #Room -room = "2.6.0-beta01" +room = "2.6.1" #Fossify commons = "908d6cce56" #Gradle From ba2f318d4e50a673318281f508ed4ee141ea3559 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 14 Jun 2024 00:09:09 +0530 Subject: [PATCH 16/22] Update AGP --- gradle/libs.versions.toml | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0df55fea..839110d0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ room = "2.6.1" #Fossify commons = "908d6cce56" #Gradle -gradlePlugins-agp = "8.2.0" +gradlePlugins-agp = "8.4.0" #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..c6729007 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.6-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From 557f9563966bcb03409bed7296fe4397b842d4c8 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 14 Jun 2024 12:36:21 +0530 Subject: [PATCH 17/22] Use Window Inset Compat api --- .../kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 54627101..58f972d3 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt @@ -84,7 +84,8 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared val window = window.window!! WindowCompat.setDecorFitsSystemWindows(window, false) window.decorView.setOnApplyWindowInsetsListener { _, insets -> - val bottom = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom + val windowInsets = WindowInsetsCompat.toWindowInsetsCompat(insets) + val bottom = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom binding.keyboardHolder.updatePadding(bottom = bottom) insets } From 5950ef4e1fc8808efb2616083146c12ff3e1a350 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 14 Jun 2024 15:39:25 +0530 Subject: [PATCH 18/22] Minor code improvement --- .../main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 02e817b8..b4bb73b9 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt @@ -144,6 +144,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut private var mKeyBackground: Drawable? = null private var mShowKeyBorders: Boolean = false private var mUsingSystemTheme: Boolean = true + private var mVoiceInputMethod: String = "" private var mToolbarHolder: View? = null private var mClipboardManagerHolder: View? = null @@ -385,6 +386,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mShowKeyBorders = config.showKeyBorders mUsingSystemTheme = config.isUsingSystemTheme + mVoiceInputMethod = config.voiceInputMethod } val isMainKeyboard = changedView == null || changedView != keyboardPopupBinding?.miniKeyboardView @@ -429,7 +431,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut pinnedClipboardItems.applyColorFilter(mTextColor) clipboardClear.applyColorFilter(mTextColor) voiceInputButton.applyColorFilter(mTextColor) - voiceInputButton.beGoneIf(context.config.voiceInputMethod.isEmpty()) + voiceInputButton.beGoneIf(mVoiceInputMethod.isEmpty()) mToolbarHolder?.beInvisibleIf(context.isDeviceLocked) From 49c4421668fb6a661882d25cafe9ce81a9fe76e4 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 14 Jun 2024 21:42:13 +0530 Subject: [PATCH 19/22] Revert "Update AGP" This reverts commit ba2f318d4e50a673318281f508ed4ee141ea3559. --- gradle/libs.versions.toml | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 839110d0..0df55fea 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ room = "2.6.1" #Fossify commons = "908d6cce56" #Gradle -gradlePlugins-agp = "8.4.0" +gradlePlugins-agp = "8.2.0" #build app-build-compileSDKVersion = "34" app-build-targetSDK = "34" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c6729007..e9e32299 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.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From ef7e4050bb9bb97a7906e95a819094d808741888 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 14 Jun 2024 23:06:53 +0530 Subject: [PATCH 20/22] Minor code improvement --- .../fossify/keyboard/views/MyKeyboardView.kt | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) 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 b4bb73b9..157f0ee7 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/views/MyKeyboardView.kt @@ -87,7 +87,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut private var mTextColor = 0 private var mBackgroundColor = 0 + private var mKeyboardBackgroundColor = 0 private var mPrimaryColor = 0 + private var mStrokeColor = 0 private var mKeyColor = 0 private var mKeyColorPressed = 0 @@ -210,7 +212,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut with(context.safeStorageContext) { mTextColor = getProperTextColor() mBackgroundColor = getProperBackgroundColor() + mKeyboardBackgroundColor = getKeyboardBackgroundColor() mPrimaryColor = getProperPrimaryColor() + mStrokeColor = getStrokeColor() } mPreviewPopup = PopupWindow(context) @@ -382,7 +386,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut with(context.safeStorageContext) { mTextColor = getProperTextColor() mBackgroundColor = getProperBackgroundColor() + mKeyboardBackgroundColor = getKeyboardBackgroundColor() mPrimaryColor = getProperPrimaryColor() + mStrokeColor = getStrokeColor() mShowKeyBorders = config.showKeyBorders mUsingSystemTheme = config.isUsingSystemTheme @@ -398,28 +404,25 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut resources.getDrawable(R.drawable.keyboard_key_selector, context.theme) } - val strokeColor = context.getStrokeColor() - val backgroundColor = context.getKeyboardBackgroundColor() - if (!isMainKeyboard) { val previewBackground = background as LayerDrawable - previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(backgroundColor) - previewBackground.findDrawableByLayerId(R.id.button_background_stroke).applyColorFilter(strokeColor) + previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(mKeyboardBackgroundColor) + previewBackground.findDrawableByLayerId(R.id.button_background_stroke).applyColorFilter(mStrokeColor) background = previewBackground } else { - background.applyColorFilter(backgroundColor) + background.applyColorFilter(mKeyboardBackgroundColor) } val rippleBg = resources.getDrawable(R.drawable.clipboard_background, context.theme) as RippleDrawable val layerDrawable = rippleBg.findDrawableByLayerId(R.id.clipboard_background_holder) as LayerDrawable - layerDrawable.findDrawableByLayerId(R.id.clipboard_background_stroke).applyColorFilter(strokeColor) + layerDrawable.findDrawableByLayerId(R.id.clipboard_background_stroke).applyColorFilter(mStrokeColor) layerDrawable.findDrawableByLayerId(R.id.clipboard_background_shape).applyColorFilter(mBackgroundColor) val wasDarkened = mBackgroundColor != mBackgroundColor.darkenColor() keyboardViewBinding?.apply { topKeyboardDivider.beGoneIf(wasDarkened) - topKeyboardDivider.background = ColorDrawable(strokeColor) - mToolbarHolder?.background = ColorDrawable(backgroundColor) + topKeyboardDivider.background = ColorDrawable(mStrokeColor) + mToolbarHolder?.background = ColorDrawable(mKeyboardBackgroundColor) clipboardValue.apply { background = rippleBg @@ -436,8 +439,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mToolbarHolder?.beInvisibleIf(context.isDeviceLocked) topClipboardDivider.beGoneIf(wasDarkened) - topClipboardDivider.background = ColorDrawable(strokeColor) - clipboardManagerHolder.background = ColorDrawable(backgroundColor) + topClipboardDivider.background = ColorDrawable(mStrokeColor) + clipboardManagerHolder.background = ColorDrawable(mKeyboardBackgroundColor) clipboardManagerClose.applyColorFilter(mTextColor) clipboardManagerManage.applyColorFilter(mTextColor) @@ -447,7 +450,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut clipboardContentPlaceholder2.setTextColor(mTextColor) } - setupEmojiPalette(toolbarColor = backgroundColor, backgroundColor = mBackgroundColor, textColor = mTextColor) + setupEmojiPalette(toolbarColor = mKeyboardBackgroundColor, backgroundColor = mBackgroundColor, textColor = mTextColor) if (context.config.keyboardLanguage == LANGUAGE_VIETNAMESE_TELEX) { setupLanguageTelex() } else { @@ -902,8 +905,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } val previewBackground = mPreviewText!!.background as LayerDrawable - previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(context.getKeyboardBackgroundColor()) - previewBackground.findDrawableByLayerId(R.id.button_background_stroke).applyColorFilter(context.getStrokeColor()) + previewBackground.findDrawableByLayerId(R.id.button_background_shape).applyColorFilter(mKeyboardBackgroundColor) + previewBackground.findDrawableByLayerId(R.id.button_background_stroke).applyColorFilter(mStrokeColor) mPreviewText!!.background = previewBackground mPreviewText!!.setTextColor(mTextColor) @@ -1464,7 +1467,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut emojiPaletteClose.applyColorFilter(textColor) emojiPaletteLabel.setTextColor(textColor) - emojiPaletteBottomBar.background = ColorDrawable(backgroundColor) + emojiPaletteBottomBar.background = ColorDrawable(toolbarColor) emojiPaletteModeChange.apply { setTextColor(textColor) setOnClickListener { From 0b345e5578097bf565d4797092e37ef7177bba36 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 14 Jun 2024 23:07:22 +0530 Subject: [PATCH 21/22] Properly handle navigation bar color --- .../keyboard/services/SimpleKeyboardIME.kt | 29 ++++++++++++------- gradle/libs.versions.toml | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) 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 58f972d3..239d60ce 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt @@ -3,6 +3,7 @@ package org.fossify.keyboard.services import android.annotation.SuppressLint import android.content.SharedPreferences import android.graphics.Bitmap +import android.graphics.Color import android.graphics.drawable.Icon import android.graphics.drawable.LayerDrawable import android.graphics.drawable.RippleDrawable @@ -81,29 +82,37 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared } override fun onCreateInputView(): View { - val window = window.window!! - WindowCompat.setDecorFitsSystemWindows(window, false) - window.decorView.setOnApplyWindowInsetsListener { _, insets -> - val windowInsets = WindowInsetsCompat.toWindowInsetsCompat(insets) - val bottom = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom - binding.keyboardHolder.updatePadding(bottom = bottom) - insets - } - binding = KeyboardViewKeyboardBinding.inflate(layoutInflater) + binding.keyboardHolder.setBackgroundColor(safeStorageContext.getKeyboardBackgroundColor()) keyboardView = binding.keyboardView.apply { setKeyboardHolder(binding) setKeyboard(keyboard!!) setEditorInfo(currentInputEditorInfo) + setupNavigationBarPadding() mOnKeyboardActionListener = this@SimpleKeyboardIME } return binding.root } + private fun setupNavigationBarPadding() { + window.window?.apply { + WindowCompat.setDecorFitsSystemWindows(this, false) + decorView.setOnApplyWindowInsetsListener { _, insets -> + val windowInsets = WindowInsetsCompat.toWindowInsetsCompat(insets) + val bottomPadding = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom + binding.keyboardHolder.updatePadding(bottom = bottomPadding) + insets + } + } + } + override fun onStartInputView(editorInfo: EditorInfo?, restarting: Boolean) { super.onStartInputView(editorInfo, restarting) - window.window?.updateNavigationBarBackgroundColor(getKeyboardBackgroundColor()) + window.window?.apply { + navigationBarColor = Color.TRANSPARENT + updateNavigationBarForegroundColor(safeStorageContext.getKeyboardBackgroundColor()) + } } override fun onPress(primaryCode: Int) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0df55fea..1a4b8ece 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ ksp = "1.9.23-1.0.19" #Room room = "2.6.1" #Fossify -commons = "908d6cce56" +commons = "6ee990894c" #Gradle gradlePlugins-agp = "8.2.0" #build From e7313f98c2bc7673b4e778b4a10f8c4fe95da0fb Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 14 Jun 2024 23:13:13 +0530 Subject: [PATCH 22/22] Use proper colors in settings sections --- .../org/fossify/keyboard/activities/SettingsActivity.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/org/fossify/keyboard/activities/SettingsActivity.kt b/app/src/main/kotlin/org/fossify/keyboard/activities/SettingsActivity.kt index 552a2366..ae2465fb 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/activities/SettingsActivity.kt @@ -52,7 +52,12 @@ class SettingsActivity : SimpleActivity() { binding.apply { updateTextColors(settingsNestedScrollview) - arrayOf(settingsColorCustomizationSectionLabel, settingsGeneralSettingsLabel).forEach { + arrayOf( + settingsColorCustomizationSectionLabel, + settingsGeneralSettingsLabel, + settingsKeyboardSettingsLabel, + settingsClipboardSettingsLabel + ).forEach { it.setTextColor(getProperPrimaryColor()) } }