From 715abaf3714daaab1bfff05388eaaa6e451f6219 Mon Sep 17 00:00:00 2001 From: LeanBitLab Date: Mon, 16 Nov 2026 19:33:21 +0530 Subject: [PATCH 1/2] fix(screen): keep phones with a small display size on the compact profile Since 4.3.2 any screen with 500dp or more in both dimensions counted as large, which defaults to the split keyboard. A regular phone with a small display size setting reaches that, so it got a split keyboard it never had before. The relaxed 500dp limit (added for unfolded foldables such as 588x706dp) now also requires a nearly square screen. --- .../keyboard/latin/utils/ScreenProfile.kt | 6 +++++- .../keyboard/latin/utils/ScreenProfileTest.kt | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/helium314/keyboard/latin/utils/ScreenProfile.kt b/app/src/main/java/helium314/keyboard/latin/utils/ScreenProfile.kt index 0f00d2500..6cd9f3266 100644 --- a/app/src/main/java/helium314/keyboard/latin/utils/ScreenProfile.kt +++ b/app/src/main/java/helium314/keyboard/latin/utils/ScreenProfile.kt @@ -58,7 +58,11 @@ object ScreenProfileProvider { val availableHeightDp = if (config.screenHeightDp > 0) config.screenHeightDp else if (density > 0f) (heightPx / density).roundToInt() else 0 val isFoldable = isFoldableDevice(context) - val isBothDimensionsLarge = (availableWidthDp >= 500 && availableHeightDp >= 500) + // Unfolded foldables are nearly square (e.g. 588x706dp), but a phone with a small display size setting can also + // be 500dp or more in both dimensions. Phones are tall and narrow, so they must not get the relaxed 500dp limit. + val isNearlySquare = maxOf(availableWidthDp, availableHeightDp) * 10 <= minOf(availableWidthDp, availableHeightDp) * 16 + val isBothDimensionsLarge = (availableWidthDp >= 600 && availableHeightDp >= 600) + || (isNearlySquare && availableWidthDp >= 500 && availableHeightDp >= 500) || (isFoldable && availableWidthDp >= 500 && availableHeightDp >= 450) val isSmallestWidthLarge = config.smallestScreenWidthDp >= 600 diff --git a/app/src/test/java/helium314/keyboard/latin/utils/ScreenProfileTest.kt b/app/src/test/java/helium314/keyboard/latin/utils/ScreenProfileTest.kt index 3f4dfc8d7..e66cbc5e6 100644 --- a/app/src/test/java/helium314/keyboard/latin/utils/ScreenProfileTest.kt +++ b/app/src/test/java/helium314/keyboard/latin/utils/ScreenProfileTest.kt @@ -85,6 +85,23 @@ class ScreenProfileTest { assertEquals(ScreenProfile.LARGE, profile) } + @Test + fun testScreenProfilePhoneWithSmallDisplaySizeIsCompact() { + // Regular phone (not a foldable) with a small "display size" setting: 500dp or more in both dimensions, but tall and narrow + val portrait = Configuration().apply { + screenWidthDp = 520 + screenHeightDp = 1150 + smallestScreenWidthDp = 520 + } + assertEquals(ScreenProfile.COMPACT, ScreenProfileProvider.getScreenProfile(context, portrait)) + val landscape = Configuration().apply { + screenWidthDp = 1150 + screenHeightDp = 520 + smallestScreenWidthDp = 520 + } + assertEquals(ScreenProfile.COMPACT, ScreenProfileProvider.getScreenProfile(context, landscape)) + } + @Test fun testScreenProfileFoldableFoldedLandscapeIsCompact() { // Foldable device when folded in landscape (width >= 600, but height < 600 and smallestScreenWidthDp < 600) gets COMPACT profile From 52e09a64d32c106ba448ec284f4ca092602dcc44 Mon Sep 17 00:00:00 2001 From: LeanBitLab Date: Mon, 16 Nov 2026 19:33:21 +0530 Subject: [PATCH 2/2] chore(log): record device model and screen size in the exported log The screen profile line was written with android.util.Log, which the exported log does not contain, so reports could not be matched to a screen. Route it through the app logger and add the device model and screen size to the startup lines. --- app/src/main/java/helium314/keyboard/latin/App.kt | 5 +++++ .../java/helium314/keyboard/latin/utils/ScreenProfile.kt | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/helium314/keyboard/latin/App.kt b/app/src/main/java/helium314/keyboard/latin/App.kt index e321ce3cf..4afce1ab8 100644 --- a/app/src/main/java/helium314/keyboard/latin/App.kt +++ b/app/src/main/java/helium314/keyboard/latin/App.kt @@ -57,6 +57,11 @@ class App : Application(), Configuration.Provider { packageInfo.versionCode }) on Android ${android.os.Build.VERSION.RELEASE} (SDK ${android.os.Build.VERSION.SDK_INT})" ) + val config = resources.configuration + Log.i( + "startup", "Device ${android.os.Build.MANUFACTURER} ${android.os.Build.MODEL}, screen ${config.screenWidthDp}x${config.screenHeightDp}dp " + + "(smallest ${config.smallestScreenWidthDp}dp, density ${resources.displayMetrics.densityDpi}dpi)" + ) } companion object { diff --git a/app/src/main/java/helium314/keyboard/latin/utils/ScreenProfile.kt b/app/src/main/java/helium314/keyboard/latin/utils/ScreenProfile.kt index 6cd9f3266..f393f020a 100644 --- a/app/src/main/java/helium314/keyboard/latin/utils/ScreenProfile.kt +++ b/app/src/main/java/helium314/keyboard/latin/utils/ScreenProfile.kt @@ -3,7 +3,6 @@ package helium314.keyboard.latin.utils import android.content.Context import android.content.res.Configuration -import android.util.Log import androidx.annotation.VisibleForTesting import kotlin.math.roundToInt