Skip to content

Conversation

alerque
Copy link
Collaborator

@alerque alerque commented Jun 19, 2025

Closes #1423

At the moment this is just a work in progress that takes over the size setting and does the math as a POC. No matter what size you set the slider it will just recalculate it. UI changes yet to come.

Contributions welcome if anybody wants to fiddle with this against my fork & branch.

@alerque alerque force-pushed the auto-width branch 3 times, most recently from 6d1b598 to c4efdd5 Compare June 19, 2025 23:03
@alerque
Copy link
Collaborator Author

alerque commented Jun 19, 2025

This is now working (at least for me) and ready for review. It a little bit of a departure from the previous default sizing experience but I think it makes a lot more sense now. Given that the potentially auto-calculated size is the width not the height of the keyboard, the height is now the value adjusted when non-square mode is activated instead of the width. Also values the user input are now saved as values in the settings database even if the setting is not currently used enabling the use of their previous value from the database when re-enabling a setting.

I've tried to migrate existing users to a functional equivalent of their current settings by forcing the new feature off for anybody migrating from an old database, but the actual new feature of sizing based on screen size vs. columns is on by default for new users.

I have not tested the behavior of that aspect of the migration yet.

How do you handle localization updates? This PR introduces a new string. I've provided the default and TR translation. Do I need to flesh out the other localization files with empty keys or with copies of the unlocalized English or are you using something that will handle that?

@alerque alerque marked this pull request as ready for review June 19, 2025 23:17
@alerque alerque requested a review from dessalines as a code owner June 19, 2025 23:17
@alerque
Copy link
Collaborator Author

alerque commented Jun 19, 2025

Ya the migrations aren't right. Stand by.

@alerque
Copy link
Collaborator Author

alerque commented Jun 19, 2025

I'm not sure what is wrong with the migrations but a basic upgrade to a device previously running db17 causes crashes. This PR does work if you clear data first if anybody wants to test the new features.

@alerque alerque marked this pull request as draft June 19, 2025 23:34
@alerque
Copy link
Collaborator Author

alerque commented Jun 29, 2025

I'm trying to sort out what to do with columns and migrations. He're a question:

Does it really matter that we even "fix" the columns in the database schema so they have the right defaults? Even if we stop allowing NULL, won't it work out if we just relpace any existing NULLs and then change the usage so we never set another NULL? As in the slider values should always have a value now even if they are not being used at that moment due to some other sizing being in effect.

It rubs me the wrong way to have the schema not reflect actual usage, but so does having defunct columns we can't drop or use and new tables with names that don't match their data mapping. Speaking of dropping, that appears to be possible in SQLite, is it Room that won't let us do that?

@dessalines
Copy link
Owner

dessalines commented Jul 1, 2025

It rubs me the wrong way to have the schema not reflect actual usage, but so does having defunct columns we can't drop or use and new tables with names that don't match their data mapping. Speaking of dropping, that appears to be possible in SQLite, is it Room that won't let us do that?

Correct, but not just room, android in general. You can read some of the comments here, but SQLITE only added drop column in 2021, and not all android versions support the newest sqlite.

I know its annoying, but bc of this I've found its safer and harmless to just have defunct columns around, and only add new column at the end. Changing data types also tends to throw errors. And only if absolutely necessary, do a whole new create table migration with corrected columns and copy the old data over.

The steps forward are:

  • Fill an existing DB (checkout the main branch, load up the app, and set some settings).
  • Switch to your feature branch, with the new migrations
  • Make sure it doesn't crash on startup. If it does the logs should give a hint at what room migration is incorrect.

@alerque
Copy link
Collaborator Author

alerque commented Jul 8, 2025

Thanks for the feedback, I'm working towards that now.

The currently pushed commit (13cf77a) does NOT work, it crashes on opening a v17 database, presumably something to do with migrations. It works fine on its own with data cleared.

I've also tried it without the four UDPATE ... SET ... statements in the migration, and also even without the ALTER TABLE ... RENAME COLUMN entries that add the defunct label.

Unfortunately the debug log I'm seeing with adb logcat is not really showing anything useful:

07-08 15:53:30.293  2050  2809 V SplashScreenExceptionList: SplashScreen checking exception for package com.dessalines.thumbkey.debug (target sdk:35) -> false
07-08 15:53:30.296  2050  2809 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.dessalines.thumbkey.debug/com.dessalines.thumbkey.MainActivity bnds=[324,758][468,891] (has extras)} with LAUNCH_MULTIPLE from uid 10099 (sr=23895376) (BAL_ALLOW_VISIBLE_WINDOW) result code=0
07-08 15:53:30.312  2050  2274 I ActivityManager: Start proc 18555:com.dessalines.thumbkey.debug/u0a139 for next-top-activity {com.dessalines.thumbkey.debug/com.dessalines.thumbkey.MainActivity}
07-08 15:53:30.323  2050  3848 D CoreBackPreview: Window{f48445f u0 Splash Screen com.dessalines.thumbkey.debug}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@9b5430a, mPriority=0, mIsAnimationCallback=false, mOverrideBehavior=0}
07-08 15:53:30.338 18555 18555 I .thumbkey.debug: Late-enabling -Xcheck:jni
07-08 15:53:30.349  2050  2261 V WindowManager:         {WCT{RemoteToken{8832962 Task{b3acf67 #12844 type=standard A=10139:com.dessalines.thumbkey.debug}}} m=OPEN f=MOVE_TO_TOP leash=Surface(name=Task=12844)/@0xd49e5f1 sb=Rect(0, 0 - 1080, 1920) eb=Rect(0, 0 - 1080, 1920) epz=Point(1080, 1920) d=0 taskParent=-1},
07-08 15:53:30.378 18555 18555 I .thumbkey.debug: Using CollectorTypeCC GC.
07-08 15:53:30.410  2050  3856 I ActivityTaskManager: Process com.dessalines.thumbkey.debug restarted
07-08 15:53:30.452 18555 18555 W ziparchive: Unable to open '/data/app/~~UornsqWDnt8h61I_nouatA==/com.dessalines.thumbkey.debug-TTcB-FRLdNcXHn3jSQqC3w==/base.dm': No such file or directory
07-08 15:53:30.453 18555 18555 W ziparchive: Unable to open '/data/app/~~UornsqWDnt8h61I_nouatA==/com.dessalines.thumbkey.debug-TTcB-FRLdNcXHn3jSQqC3w==/base.dm': No such file or directory
07-08 15:53:31.784 18555 18555 D nativeloader: Configuring clns-7 for other apk /data/app/~~UornsqWDnt8h61I_nouatA==/com.dessalines.thumbkey.debug-TTcB-FRLdNcXHn3jSQqC3w==/base.apk. target_sdk_version=35, uses_libraries=, library_path=/data/app/~~UornsqWDnt8h61I_nouatA==/com.dessalines.thumbkey.debug-TTcB-FRLdNcXHn3jSQqC3w==/lib/arm64:/data/app/~~UornsqWDnt8h61I_nouatA==/com.dessalines.thumbkey.debug-TTcB-FRLdNcXHn3jSQqC3w==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.dessalines.thumbkey.debug
07-08 15:53:31.793 18555 18555 I .thumbkey.debug: AssetManager2(0x75515158d8) locale list changing from [] to [en-US]
07-08 15:53:31.803 18555 18555 V GraphicsEnvironment: com.dessalines.thumbkey.debug is not listed in per-application setting
07-08 15:53:31.865  2050  2264 W ActivityTaskManager: Current config: {1.0 286mcc3mnc [en_US,tr_TR,ru_KZ] ldltr sw514dp w514dp h914dp 336dpi lrg long port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 1920) mAppBounds=Rect(0, 0 - 1080, 1920) mMaxBounds=Rect(0, 0 - 1080, 1920) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.3 s.1519 fontWeightAdjustment=0} unchanged for IME proc com.dessalines.thumbkey.debug
07-08 15:53:31.874 18555 18555 I .thumbkey.debug: AssetManager2(0x7551513cb8) locale list changing from [] to [en-US]
07-08 15:53:31.975 18555 18555 I .thumbkey.debug: AssetManager2(0x7551514f78) locale list changing from [] to [en-US]
07-08 15:53:32.164 18555 18555 W .thumbkey.debug: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
07-08 15:53:32.218 18555 18555 I .thumbkey.debug: AssetManager2(0x755151c638) locale list changing from [] to [en-US]
07-08 15:53:32.224 18555 18555 I .thumbkey.debug: AssetManager2(0x755151fb58) locale list changing from [] to [en-US]
07-08 15:53:32.226 18555 18555 D WindowTokenClient: Only apply configuration update to Resources because shouldReportConfigChange is false. context=com.dessalines.thumbkey.IMEService@8cdbf89, config={1.0 286mcc3mnc [en_US,tr_TR,ru_KZ] ldltr sw514dp w514dp h914dp 336dpi lrg long port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 1920) mAppBounds=Rect(0, 0 - 1080, 1920) mMaxBounds=Rect(0, 0 - 1080, 1920) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.3 s.1519 fontWeightAdjustment=0}, display ID=0
07-08 15:53:32.698  2050  2906 I AppsFilter: interaction: PackageSetting{394ffcb com.dessalines.thumbkey.debug/10139} -> PackageSetting{cb76c69 com.android.inputmethod.latin/10063} BLOCKED
07-08 15:53:32.884 18555 18555 D com.thumbkey: Got to settings activity
07-08 15:53:33.354  2050  3856 D CoreBackPreview: Window{8959f5b u0 com.dessalines.thumbkey.debug/com.dessalines.thumbkey.MainActivity}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@d9d4cc5, mPriority=0, mIsAnimationCallback=false, mOverrideBehavior=0}
07-08 15:53:34.068  2050  2261 I ActivityTaskManager: Displayed com.dessalines.thumbkey.debug/com.dessalines.thumbkey.MainActivity for user 0: +3s853ms
07-08 15:53:34.096  2050  2906 D CoreBackPreview: Window{f48445f u0 Splash Screen com.dessalines.thumbkey.debug EXITING}: Setting back callback null
07-08 15:53:34.189 18555 18555 E AndroidRuntime: Process: com.dessalines.thumbkey.debug, PID: 18555
07-08 15:53:34.189 18555 18555 E AndroidRuntime:        at com.dessalines.thumbkey.ui.components.keyboard.KeyboardScreenKt.KeyboardScreen(KeyboardScreen.kt:161)
07-08 15:53:34.189 18555 18555 E AndroidRuntime:        at com.dessalines.thumbkey.ComposeKeyboardView.Content$lambda$6$lambda$5(ComposeKeyboardView.kt:36)
07-08 15:53:34.189 18555 18555 E AndroidRuntime:        at com.dessalines.thumbkey.ComposeKeyboardView.$r8$lambda$18HnNmNHH33aWRGM1qRE6oAMj7Q(Unknown Source:0)
07-08 15:53:34.189 18555 18555 E AndroidRuntime:        at com.dessalines.thumbkey.ComposeKeyboardView$$ExternalSyntheticLambda4.invoke(D8$$SyntheticClass:0)
07-08 15:53:34.189 18555 18555 E AndroidRuntime:        at com.dessalines.thumbkey.ComposeKeyboardView.Content$lambda$6(ComposeKeyboardView.kt:35)
07-08 15:53:34.189 18555 18555 E AndroidRuntime:        at com.dessalines.thumbkey.ComposeKeyboardView.$r8$lambda$i99srvr0MCpPajgxgkJP95-x8Js(Unknown Source:0)
07-08 15:53:34.189 18555 18555 E AndroidRuntime:        at com.dessalines.thumbkey.ComposeKeyboardView$$ExternalSyntheticLambda2.invoke(D8$$SyntheticClass:0)
07-08 15:53:34.189 18555 18555 E AndroidRuntime:        at com.dessalines.thumbkey.ui.theme.ThemeKt.ThumbkeyTheme(Theme.kt:63)
07-08 15:53:34.189 18555 18555 E AndroidRuntime:        at com.dessalines.thumbkey.ComposeKeyboardView.Content(ComposeKeyboardView.kt:32)
07-08 15:53:34.193 18555 18555 E AndroidRuntime:        at com.dessalines.thumbkey.IMEService.onStartInput(IMEService.kt:53)
07-08 15:53:34.197  2050  2809 W ActivityTaskManager:   Force finishing activity com.dessalines.thumbkey.debug/com.dessalines.thumbkey.MainActivity
07-08 15:53:34.205  2050  2262 I ActivityManager: Showing crash dialog for package com.dessalines.thumbkey.debug u0
07-08 15:53:34.240  2050  2262 D CoreBackPreview: Window{79711f7 u0 Application Error: com.dessalines.thumbkey.debug}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.WindowOnBackInvokedDispatcher$OnBackInvokedCallbackWrapper@496d1ce, mPriority=0, mIsAnimationCallback=false, mOverrideBehavior=0}
07-08 15:53:34.248  2050  8413 I ActivityManager: Process com.dessalines.thumbkey.debug (pid 18555) has died: fg  TOP
07-08 15:53:34.250  2050  2906 I WindowManager: WIN DEATH: Window{8959f5b u0 com.dessalines.thumbkey.debug/com.dessalines.thumbkey.MainActivity}
07-08 15:53:34.252  2050  8413 W ActivityManager: Scheduling restart of crashed service com.dessalines.thumbkey.debug/com.dessalines.thumbkey.IMEService in 1800000ms for connection
07-08 15:53:34.261  2050  2265 W ActivityTaskManager: Unable to send transaction to client proc com.dessalines.thumbkey.debug: no app thread
07-08 15:53:34.320  2050  2809 W ActivityManager: Ignoring remove of inactive process: ProcessRecord{c52d8b9 0:com.dessalines.thumbkey.debug/u0a139}
07-08 15:53:34.320  2050  2262 D CoreBackPreview: Window{79711f7 u0 Application Error: com.dessalines.thumbkey.debug}: Setting back callback null
07-08 15:53:34.375  2050  2261 V WindowManager:         {WCT{RemoteToken{8832962 Task{b3acf67 #12844 type=standard A=10139:com.dessalines.thumbkey.debug}}} m=CLOSE f=NONE leash=Surface(name=Task=12844)/@0xd49e5f1 sb=Rect(0, 0 - 1080, 1920) eb=Rect(0, 0 - 1080, 1920) epz=Point(1080, 1920) d=0 taskParent=-1},
07-08 15:53:34.393  2050  2906 W WindowManager: Exception thrown during dispatchAppVisibility Window{8959f5b u0 com.dessalines.thumbkey.debug/com.dessalines.thumbkey.MainActivity EXITING}
07-08 15:53:34.699  2050  2264 W ActivityTaskManager: Activity top resumed state loss timeout for ActivityRecord{176031526 u0 com.dessalines.thumbkey.debug/com.dessalines.thumbkey.MainActivity t-1 f}}

On a quick gander now do you see any obvious bloopers?

@alerque alerque requested a review from Copilot July 8, 2025 13:23
@alerque alerque marked this pull request as ready for review July 8, 2025 13:24
@alerque alerque requested a review from dessalines July 8, 2025 13:25
Copilot

This comment was marked as outdated.

@dessalines
Copy link
Owner

Hrm... none of those errors are DB-related, although they could be downstream.

@alerque
Copy link
Collaborator Author

alerque commented Jul 11, 2025

Hrm... none of those errors are DB-related, although they could be downstream.

Yes I didn't recognize them as being remotely related to what I was working on. The crash definitely happens (and is reproducible for me on two wildly different devices) any time I open a settings db from the last released version in this branch, while it seems to run fine with the settings cleared.

@alerque alerque force-pushed the auto-width branch 2 times, most recently from 4db75c7 to 8cd3fd5 Compare July 11, 2025 14:46
@alerque alerque force-pushed the auto-width branch 4 times, most recently from d501d29 to e25bb6c Compare July 11, 2025 22:54
@dessalines
Copy link
Owner

dessalines commented Jul 12, 2025

Run ./gradlew formatKotlin to pass lint.

LMK when you're ready for me to pull this down and test, or if you can't get past a bug.

@alerque
Copy link
Collaborator Author

alerque commented Jul 12, 2025

Run ./gradlew formatKotlin to pass lint.

LMK when you're ready for me to pull this down and test, or if you can't get past a bug.

Thanks for the patience on this one. I think I've finally squashed the migration bugs and I can reliably set settings in a build from main, then open a build of this PR and have the relevant settings come in without crashes.

I think this is ready for actual review with an eye to merger.

@alerque alerque enabled auto-merge July 12, 2025 09:18
@alerque alerque requested a review from dessalines July 12, 2025 09:19
@alerque
Copy link
Collaborator Author

alerque commented Jul 12, 2025

I'm marking this as draft again, hopefully briefly, because I see you merged #1443 already and the column calculation needs to be adapted here to do something sensible in the event of double-the-trouble.

@alerque alerque marked this pull request as draft July 12, 2025 09:24
auto-merge was automatically disabled July 12, 2025 09:24

Pull request was converted to draft

@alerque
Copy link
Collaborator Author

alerque commented Jul 12, 2025

And we're back in business. When the dual position is activated we double the expected column count and adjust the width so that both layouts fit.

@alerque alerque marked this pull request as ready for review July 12, 2025 09:43
@alerque alerque enabled auto-merge July 12, 2025 09:43
Copy link
Owner

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and everything works great, including migrations, and the settings. thx a ton for this.

I'm a little bit iffy on having the auto-width being default (for example I tested this on my tablet in landscape mode and it took up the entire screen and was unusable. Any device in landscape mode, or where the width >= height will have that problem). But I think having auto-width default is still probably the best option for 99% of users, and the others can use defined sizes.

I'll make a release for this shortly.

@alerque alerque merged commit 811fd45 into dessalines:main Jul 12, 2025
1 check passed
@alerque
Copy link
Collaborator Author

alerque commented Jul 12, 2025

Yes, the default for landscape mode anything is a bit aggressive, especially with the typical 4x4 square layout. It's marginally better for some of the new wider layouts or the dual mode, which is probably what you want for a tablet in landscape mode anyway. That or setup a corner layout with no background. But I agree defaulting to something nice for phones and typical usage made sense to me, and whatever tweaks need to be made for other situations seemed like an okay cost.

@alerque alerque deleted the auto-width branch July 12, 2025 18:39
@st-bender st-bender mentioned this pull request Jul 17, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a setting to auto-size the keyboard to available space
2 participants