Skip to content

fix(android/engine): Fix OSK widths#10442

Merged
darcywong00 merged 6 commits intomasterfrom
fix/android/landscape-kb-picker-osk
Jan 25, 2024
Merged

fix(android/engine): Fix OSK widths#10442
darcywong00 merged 6 commits intomasterfrom
fix/android/landscape-kb-picker-osk

Conversation

@darcywong00
Copy link
Copy Markdown
Contributor

@darcywong00 darcywong00 commented Jan 19, 2024

Follows #10373 and fixes #10241

This applies two things to fix OSK width to be full screen

  • Disables multi-window mode for the entire Keyman app
  • Refactors detection of device orientation so MainActivity.onResume() has the correct dimensions for the OSK

User Testing

Setup - Install the PR build of Keyman for Android on an Android 12.0 device /emulator (SDK 31)

  • TEST_OSK - Verifies OSK is full width after using keyboard picker
  1. Launch Keyman for Android in landscape
  2. Type some letters on the input text screen.
  3. Longpress the globe key to open the Keyboard picker menu.
  4. Click the default keyboard.
  5. Verify the app shows the OSK full-width.

@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed labels Jan 19, 2024
@keymanapp-test-bot
Copy link
Copy Markdown

keymanapp-test-bot bot commented Jan 19, 2024

User Test Results

Test specification and instructions

  • TEST_OSK (PASSED): Tested with the attached PR build (Keyman 17.0.251-alpha-test-10442) in the Android 12 / API 31 emulator and here is my observation: 1. Launched the Keyman in Landscape. 2. Closed the "Get Started" dialog. 3. Typed some letters on the text input screen. 4. Opened the Keyboard picker menu by long-pressing the globe key. 5. Clicked the default keyboard. 6. Verified that the app shows the OSK in full-width. (notes)

Test Artifacts

mcdurdin
mcdurdin previously approved these changes Jan 19, 2024
@bharanidharanj
Copy link
Copy Markdown

Test Results

  • TEST_OSK (FAILED): Tested with the attached PR build (Keyman 17.0.248-alpha-test-10442) in the Android emulator (ver 12 / AP31) and here is my observation: 1. Keyman app abruptly closed after launching it from the landscape mode. 2. However, it works fine after restarting the emulator. 3. Tried the same steps in the Android Mobile and I am getting the same issue.

@keymanapp-test-bot keymanapp-test-bot bot added user-test-failed and removed user-test-required User tests have not been completed labels Jan 19, 2024
@darcywong00
Copy link
Copy Markdown
Contributor Author

Sigh - this needs more investigation. I also notice when rotating to landscape, the menu options don't display the landscape layout 😖

@darcywong00 darcywong00 marked this pull request as draft January 19, 2024 08:26
@mcdurdin mcdurdin modified the milestones: A17S30, A17S31 Jan 20, 2024
@darcywong00 darcywong00 force-pushed the fix/android/landscape-kb-picker-osk branch from 8f634d6 to 4718b5b Compare January 24, 2024 05:54
@darcywong00 darcywong00 changed the title fix(android/app): Apply resizeableActivity to entire app fix(android/engine): Fix OSK widths Jan 24, 2024
@darcywong00
Copy link
Copy Markdown
Contributor Author

The refactoring of detecting the device orientation seems to work now.

@keymanapp-test-bot retest

@keymanapp-test-bot keymanapp-test-bot bot added user-test-required User tests have not been completed and removed user-test-failed labels Jan 24, 2024
@darcywong00 darcywong00 marked this pull request as ready for review January 24, 2024 06:20

// onConfigurationChanged() only triggers when device is rotated while app is in foreground
// This handles when device is rotated while app is in background
// using KMManager.getOrientation() since getConfiguration().orientation is unreliable #10241
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

getResources().getconfiguration() was sometimes reporting PORTRAIT when the device was in LANDSCAPE orientation.

Comment on lines 271 to 276
Configuration newConfig = this.getResources().getConfiguration();
if (newConfig != null && newConfig.orientation != lastOrientation) {
lastOrientation = newConfig.orientation;
int newOrientation = KMManager.getOrientation(context);
if (newOrientation != lastOrientation) {
lastOrientation = newOrientation;
KMManager.onConfigurationChanged(newConfig);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This retrieves newConfig but never tests it. Given it may have a wrong orientation, is this going to cause grief when passing it to onConfigurationChanged().
Also, I would move line 271 ... newConfig = ... inside the if() { statement before line 275 in order to keep its scope limited

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I retested the scenarios from #8704 and they seemed fine (restarting the app after rotating the device while the app is in the background).
lastOrientation is undefined so the app goes into this branch and refreshes with the correct dimensions. Maybe getOrientation() is the only buggy part?

@darcywong00
Copy link
Copy Markdown
Contributor Author

Answer @mcdurdin 's question from standup:

How is the OSK handled if the device is rotated when the orientation is locked into PORTRAIT or LANDSCAPE?

I tested with my physical device locked in PORTRAIT and then locked in LANDSCAPE. Good news is the app and OSK remain locked in the orientation.

@bharanidharanj
Copy link
Copy Markdown

Test Results

  • TEST_OSK (PASSED): Tested with the attached PR build (Keyman 17.0.251-alpha-test-10442) in the Android 12 / API 31 emulator and here is my observation: 1. Launched the Keyman in Landscape. 2. Closed the "Get Started" dialog. 3. Typed some letters on the text input screen. 4. Opened the Keyboard picker menu by long-pressing the globe key. 5. Clicked the default keyboard. 6. Verified that the app shows the OSK in full-width.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Jan 24, 2024
@darcywong00 darcywong00 dismissed mcdurdin’s stale review January 25, 2024 03:44

Added some refactoring

if (orientation == Configuration.ORIENTATION_PORTRAIT) {
return prefs.getInt(KMManager.KMKey_KeyboardHeightPortrait, defaultHeight);
} else if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do we do if ORIENTATION_UNDEFINED is returned? Seems like we fall into a hole?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The defaultHeight initializes in l. 2023 so that value gets returned in l. 2033. I think typically that will be the portrait dimensions

Co-authored-by: Marc Durdin <marc@durdin.net>
@darcywong00 darcywong00 merged commit 811ea81 into master Jan 25, 2024
@darcywong00 darcywong00 deleted the fix/android/landscape-kb-picker-osk branch January 25, 2024 04:38
@keyman-server
Copy link
Copy Markdown
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.252-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(android): swapping keyboards via picker in landscape results in poor kbd layout

4 participants