Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): Replace deprecated APIs for Display, Size, Metrics #11436

Merged
merged 2 commits into from
May 17, 2024

Conversation

darcywong00
Copy link
Contributor

Fixes #9586

Android API 30 deprecated several calls used to determine Window Display, Size, and Metrics. This refactors the calls to KMManager to handle the different API calls.

User Testing

Setup

  • These tests should run the PR builds on an Android Device/emulator of the specified API level to test each side of API 30
    • GROUP_API_28: Android 9.0 Pie
    • GROUP_API_34: Android 14.0 UpsideDown Cake

Tests
TEST_KEYMAN - Verifies orientation and keyboard height for Keyman app

  1. Install Keyman for Android with the device in Portrait orientation
  2. From "Get Started", enable Keyman as the default system keyboard.
  3. Dismiss "Get Started"
  4. Note the current keyboard height.
  5. From Keyman Settings --> Adjust keyboard height
  6. From "Adjust keyboard height" menu, adjust the keyboard height for both portrait and landscape orientation.
  7. From the nav bar, hit back arrow to return to the Keyman app
  8. Verify the keyboard height matches what was set from the "adjust keyboard height" menu for both
  • Portrait orientation
  • Landscape orientation
  1. Launch Chrome browser and select a text area
  2. With Keyman selected as the system keyboard, verify the system keyboard height matches what was set from the "adjust keyboard height" menu for both
  • Portrait orientation
  • Landscape orientation

TEST_FIRSTVOICES - Verifies orientation and keyboard height for FirstVoices app

  1. Install FirstVoices for Android with the device in Portrait orientation
  2. From the FV setup menu, install a keyboard (BC Coast --> SENCOTEN) and enable FirstVoices as the default system keyboard
  3. Launch Chrome browser and select a text area
  4. With FirstVoices selected as the system keyboard, verify the system keyboard appears
  5. Verify the keyboard outputs:
  • Regular key press
  • longpress key
  • suggestion from the suggestion banner (if fv_sencoten is selected and installed dictionary)

@darcywong00 darcywong00 requested a review from sgschantz as a code owner May 14, 2024 02:42
@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed labels May 14, 2024
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented May 14, 2024

User Test Results

Test specification and instructions

  • ✅ GROUP_API_28: Android 9.0 Pie

    2 tests PASSED
    • TEST_KEYMAN (PASSED): I tested this issue with the attached "Keyman 18.0.35-alpha-test-11436" build on an Android 9.0(emulator) environment: Here is my observation. (notes)
    • TEST_FIRSTVOICES (PASSED) (notes)
  • ✅ GROUP_API_34: Android 14.0 UpsideDown Cake

    2 tests PASSED
    • TEST_KEYMAN (PASSED): I retested this issue in the "Keyman 17.0.325 stable" build on an Android 14 (physical device): Here is my observation. (notes)
    • TEST_FIRSTVOICES (PASSED) (notes)

Test Artifacts

@dinakaranr
Copy link

Test Results

GROUP_API_28: Android 9.0 Pie

  • TEST_KEYMAN (PASSED): I tested this issue with the attached "Keyman 18.0.35-alpha-test-11436" build on an Android 9.0(emulator) environment: Here is my observation.
  • Installed the "Keyman 18.0.35.apk" file and gave all permissions to the application.

  • Checked the "Enable Keyman as system-wide keyboard" and set the keyboard as the default keyboard box on the settings page.

  • On portrait view: Change the keyboard height by clicking the three-dot menu/Keyman Settings/Adjust keyboard height.

  • Navigate back to the Keyman app. Here, the keyboard height appeared(increased) in the modified height and the key function works as well.
    Open the Chrome browser, and then enter some text in the address bar and Google search box. Here, keyboard height appeared(increased) in the modified height

  • On landscape view: Change the keyboard height by clicking the three-dot menu/Keyman Settings/Adjust keyboard height.

  • Navigate back to the Keyman app. Here, the keyboard height appeared(increased) in the modified height and key function works as well.
    Open the Chrome browser, and then enter some text in the address bar and Google search box.
    Here, keyboard height appeared(increased) in the modified height.

  • TEST_FIRSTVOICES (PASSED):
    I tested this issue with the attached "firstvoices-18.0.35-alpha-test-11436" build on an Android 9.0(emulator) environment: Here is my observation.
  • Installed the "firstvoices-18.0.35.apk" file and gave all permissions to the application.
  • Checked the "Enable FirstVoices" and then checked the "Choose FirstVoices as current Input method" on the setup dialog.
  • Installed a keyboard (BC Coast --> SENCOTEN)(installed the online dictionary) by clicking the "Select Keyboards" button.
  • Open the Chrome browser, and then enter some text in the address bar and Google search box.
    Here, the FirstVoices keyboard appeared and the key works as well.
    The subkey menu list appeared after the long press key.
    Suggested words appeared on the banner when typing a word.

GROUP_API_34: Android 14.0 UpsideDown Cake

  • TEST_KEYMAN (FAILED):
    I tested this issue with the attached "Keyman 18.0.35-alpha-test-11436" build on an Android 14(physical device): Here is my observation.
    I have followed the steps that mentioned in the "Android 9.0 Pie" here. keyboard height appeared(increased) in the modified height and key function works as well.

On the Chrome browser: the keyboard disappeared when moving portrait to landscape view. the keyboard appeared when clicking in the search box.
Please refer to the screenshot below. Hence, I failed this scenario.
https://github.com/keymanapp/keyman/assets/19683059/48401aa3-5e82-472e-aaa5-a38d0dd16f26

  • TEST_FIRSTVOICES (PASSED):
    I tested this issue with the attached "firstvoices-18.0.35-alpha-test-11436" build on an Android 14(physical device): Here is my observation.
    I have followed the steps that mentioned in the "Android 9.0 Pie" here. keyboard height appeared(increased) in the modified height and the key function works as well.
    The keyboard output is given the subkey after pressing long-press. The suggested word appeared on the banner. Hence, It works well.

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

On the Chrome browser: the keyboard disappeared when moving portrait to landscape view. the keyboard appeared when clicking in the search box.
Please refer to the screenshot below. Hence, I failed this scenario.

@dinakaranr - I retested on emulator and could reproduce what you saw. However, I think that's just the behavior on google.com when you are on the search bar but don't have anything.
On my Android 13 device, the Google Gboard and Samsung keyboards also disappear when rotating the device. And I see this on Keyman 17.0.325 stable.

@keymanapp-test-bot retest GROUP_API_34 TEST_KEYMAN

@keymanapp-test-bot keymanapp-test-bot bot added user-test-required User tests have not been completed and removed user-test-failed labels May 16, 2024
@dinakaranr
Copy link

Test Results

GROUP_API_34: Android 14.0 UpsideDown Cake

  • TEST_KEYMAN (PASSED): I retested this issue in the "Keyman 17.0.325 stable" build on an Android 14 (physical device): Here is my observation.
    I retested this issue in the Firefox browser for Google.com. The search box works correctly when switching from portrait to landscape view on a mobile device. It seems that Chrome browser behaviour is intended as of now. Hence, I passed this test. Thank you

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label May 16, 2024
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Point size = new Point(0, 0);
wm.getDefaultDisplay().getSize(size);
Point size = KMManager.getWindowSize(getApplicationContext());
Copy link
Member

Choose a reason for hiding this comment

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

These new API endpoints need to be documented

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do on help.keyman

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@darcywong00 darcywong00 merged commit 73ca23b into master May 17, 2024
5 checks passed
@darcywong00 darcywong00 deleted the fix/android/deprecated-get-size branch May 17, 2024 04:22
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.38-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.

chore(android): getDefaultDisplay() and getSize() deprecated in Android SDK 30
4 participants