From 56b60d9bdc444602589047bbc384336d7bc465cb Mon Sep 17 00:00:00 2001 From: Prince Yadav <66916296+prince-0408@users.noreply.github.com> Date: Sun, 9 Aug 2026 17:56:01 +0530 Subject: [PATCH 1/2] refactor: deduplicate isTablet method across language subclasses (#426) --- .../keyboards/java/be/scri/services/EnglishKeyboardIME.kt | 6 ------ .../keyboards/java/be/scri/services/FrenchKeyboardIME.kt | 6 ------ .../keyboards/java/be/scri/services/GeneralKeyboardIME.kt | 3 +++ .../keyboards/java/be/scri/services/GermanKeyboardIME.kt | 6 ------ .../keyboards/java/be/scri/services/ItalianKeyboardIME.kt | 6 ------ .../java/be/scri/services/PortugueseKeyboardIME.kt | 6 ------ .../keyboards/java/be/scri/services/RussianKeyboardIME.kt | 6 ------ .../keyboards/java/be/scri/services/SpanishKeyboardIME.kt | 6 ------ .../keyboards/java/be/scri/services/SwedishKeyboardIME.kt | 6 ------ 9 files changed, 3 insertions(+), 48 deletions(-) diff --git a/app/src/keyboards/java/be/scri/services/EnglishKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/EnglishKeyboardIME.kt index 8978d7232..8818bdb97 100644 --- a/app/src/keyboards/java/be/scri/services/EnglishKeyboardIME.kt +++ b/app/src/keyboards/java/be/scri/services/EnglishKeyboardIME.kt @@ -11,12 +11,6 @@ import be.scri.helpers.KeyHandler * The EnglishKeyboardIME class provides the input method for the English language keyboard. */ class EnglishKeyboardIME : GeneralKeyboardIME("English") { - companion object { - const val SMALLEST_SCREEN_WIDTH_TABLET = 600 - } - - private fun isTablet(): Boolean = resources.configuration.smallestScreenWidthDp >= SMALLEST_SCREEN_WIDTH_TABLET - override fun getKeyboardLayoutXML(): Int = when { isTablet() -> R.xml.keys_letters_english_tablet diff --git a/app/src/keyboards/java/be/scri/services/FrenchKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/FrenchKeyboardIME.kt index e389ad15b..fdd265095 100644 --- a/app/src/keyboards/java/be/scri/services/FrenchKeyboardIME.kt +++ b/app/src/keyboards/java/be/scri/services/FrenchKeyboardIME.kt @@ -11,12 +11,6 @@ import be.scri.helpers.KeyHandler * The FrenchKeyboardIME class provides the input method for the French language keyboard. */ class FrenchKeyboardIME : GeneralKeyboardIME("French") { - companion object { - const val SMALLEST_SCREEN_WIDTH_TABLET = 600 - } - - private fun isTablet(): Boolean = resources.configuration.smallestScreenWidthDp >= SMALLEST_SCREEN_WIDTH_TABLET - override fun getKeyboardLayoutXML(): Int = when { isTablet() -> R.xml.keys_letters_french_tablet diff --git a/app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt index 16115def5..a826df992 100644 --- a/app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt +++ b/app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt @@ -186,7 +186,10 @@ abstract class GeneralKeyboardIME( private var currentVerbForConjugation: String? = null private var selectedConjugationSubCategory: String? = null + protected open fun isTablet(): Boolean = resources.configuration.smallestScreenWidthDp >= SMALLEST_SCREEN_WIDTH_TABLET + internal companion object { + const val SMALLEST_SCREEN_WIDTH_TABLET = 600 const val DEFAULT_SHIFT_PERM_TOGGLE_SPEED = 500 const val TEXT_LENGTH = 20 const val NOUN_TYPE_SIZE = 20f diff --git a/app/src/keyboards/java/be/scri/services/GermanKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/GermanKeyboardIME.kt index 618e79f1c..da401d380 100644 --- a/app/src/keyboards/java/be/scri/services/GermanKeyboardIME.kt +++ b/app/src/keyboards/java/be/scri/services/GermanKeyboardIME.kt @@ -12,12 +12,6 @@ import be.scri.helpers.PreferencesHelper.getIsAccentCharacterDisabled * The GermanKeyboardIME class provides the input method for the German language keyboard. */ class GermanKeyboardIME : GeneralKeyboardIME("German") { - companion object { - const val SMALLEST_SCREEN_WIDTH_TABLET = 600 - } - - private fun isTablet(): Boolean = resources.configuration.smallestScreenWidthDp >= SMALLEST_SCREEN_WIDTH_TABLET - override fun getKeyboardLayoutXML(): Int = if (isTablet()) { R.xml.keys_letters_german_tablet diff --git a/app/src/keyboards/java/be/scri/services/ItalianKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/ItalianKeyboardIME.kt index 26826de08..2579944f6 100644 --- a/app/src/keyboards/java/be/scri/services/ItalianKeyboardIME.kt +++ b/app/src/keyboards/java/be/scri/services/ItalianKeyboardIME.kt @@ -11,12 +11,6 @@ import be.scri.helpers.KeyHandler * The ItalianKeyboardIME class provides the input method for the Italian language keyboard. */ class ItalianKeyboardIME : GeneralKeyboardIME("Italian") { - companion object { - const val SMALLEST_SCREEN_WIDTH_TABLET = 600 - } - - private fun isTablet(): Boolean = resources.configuration.smallestScreenWidthDp >= SMALLEST_SCREEN_WIDTH_TABLET - override fun getKeyboardLayoutXML(): Int = when { isTablet() -> R.xml.keys_letters_italian_tablet diff --git a/app/src/keyboards/java/be/scri/services/PortugueseKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/PortugueseKeyboardIME.kt index 05c5c7f0b..ecad059d1 100644 --- a/app/src/keyboards/java/be/scri/services/PortugueseKeyboardIME.kt +++ b/app/src/keyboards/java/be/scri/services/PortugueseKeyboardIME.kt @@ -11,12 +11,6 @@ import be.scri.helpers.KeyHandler * The PortugueseKeyboardIME class provides the input method for the Portuguese language keyboard. */ class PortugueseKeyboardIME : GeneralKeyboardIME("Portuguese") { - companion object { - const val SMALLEST_SCREEN_WIDTH_TABLET = 600 - } - - private fun isTablet(): Boolean = resources.configuration.smallestScreenWidthDp >= SMALLEST_SCREEN_WIDTH_TABLET - override fun getKeyboardLayoutXML(): Int = when { isTablet() -> R.xml.keys_letters_portuguese_tablet diff --git a/app/src/keyboards/java/be/scri/services/RussianKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/RussianKeyboardIME.kt index afb59dbfb..f0f228add 100644 --- a/app/src/keyboards/java/be/scri/services/RussianKeyboardIME.kt +++ b/app/src/keyboards/java/be/scri/services/RussianKeyboardIME.kt @@ -11,12 +11,6 @@ import be.scri.helpers.KeyHandler * The RussianKeyboardIME class provides the input method for the Russian language keyboard. */ class RussianKeyboardIME : GeneralKeyboardIME("Russian") { - companion object { - const val SMALLEST_SCREEN_WIDTH_TABLET = 600 - } - - private fun isTablet(): Boolean = resources.configuration.smallestScreenWidthDp >= SMALLEST_SCREEN_WIDTH_TABLET - override fun getKeyboardLayoutXML(): Int = when { isTablet() -> R.xml.keys_letters_russian_tablet diff --git a/app/src/keyboards/java/be/scri/services/SpanishKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/SpanishKeyboardIME.kt index 605844d65..3227b348d 100644 --- a/app/src/keyboards/java/be/scri/services/SpanishKeyboardIME.kt +++ b/app/src/keyboards/java/be/scri/services/SpanishKeyboardIME.kt @@ -12,12 +12,6 @@ import be.scri.helpers.PreferencesHelper.getIsAccentCharacterDisabled * The SpanishKeyboardIME class provides the input method for the Spanish language keyboard. */ class SpanishKeyboardIME : GeneralKeyboardIME("Spanish") { - companion object { - const val SMALLEST_SCREEN_WIDTH_TABLET = 600 - } - - private fun isTablet(): Boolean = resources.configuration.smallestScreenWidthDp >= SMALLEST_SCREEN_WIDTH_TABLET - override fun getKeyboardLayoutXML(): Int = when { isTablet() -> R.xml.keys_letters_spanish_tablet diff --git a/app/src/keyboards/java/be/scri/services/SwedishKeyboardIME.kt b/app/src/keyboards/java/be/scri/services/SwedishKeyboardIME.kt index f423aae6e..2772ff7fe 100644 --- a/app/src/keyboards/java/be/scri/services/SwedishKeyboardIME.kt +++ b/app/src/keyboards/java/be/scri/services/SwedishKeyboardIME.kt @@ -12,12 +12,6 @@ import be.scri.helpers.PreferencesHelper.getIsAccentCharacterDisabled * The SwedishKeyboardIME class provides the input method for the Swedish language keyboard. */ class SwedishKeyboardIME : GeneralKeyboardIME("Swedish") { - companion object { - const val SMALLEST_SCREEN_WIDTH_TABLET = 600 - } - - private fun isTablet(): Boolean = resources.configuration.smallestScreenWidthDp >= SMALLEST_SCREEN_WIDTH_TABLET - override fun getKeyboardLayoutXML(): Int = when { isTablet() -> R.xml.keys_letters_swedish_tablet From 4341f6cd3641c9221bc936719d9cd7f43525b988 Mon Sep 17 00:00:00 2001 From: Prince Yadav <66916296+prince-0408@users.noreply.github.com> Date: Sun, 9 Aug 2026 18:00:02 +0530 Subject: [PATCH 2/2] refactor: update KeyboardUIManager isTablet check for consistency (#426) --- app/src/keyboards/java/be/scri/helpers/ui/KeyboardUIManager.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/keyboards/java/be/scri/helpers/ui/KeyboardUIManager.kt b/app/src/keyboards/java/be/scri/helpers/ui/KeyboardUIManager.kt index 4ecb128cb..4fe40d65b 100644 --- a/app/src/keyboards/java/be/scri/helpers/ui/KeyboardUIManager.kt +++ b/app/src/keyboards/java/be/scri/helpers/ui/KeyboardUIManager.kt @@ -697,7 +697,8 @@ class KeyboardUIManager( val isTablet = (context.resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK) >= - Configuration.SCREENLAYOUT_SIZE_LARGE + Configuration.SCREENLAYOUT_SIZE_LARGE || + context.resources.configuration.smallestScreenWidthDp >= GeneralKeyboardIME.SMALLEST_SCREEN_WIDTH_TABLET val emojiCount = if (isAutoSuggestEnabled) autoSuggestEmojis?.size ?: 0 else 0