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

Use WindowCompat. #8894

Merged
merged 1 commit into from
Jan 15, 2023
Merged

Use WindowCompat. #8894

merged 1 commit into from
Jan 15, 2023

Conversation

Isira-Seneviratne
Copy link
Member

@Isira-Seneviratne Isira-Seneviratne commented Aug 28, 2022

What is it?

  • Codebase improvement (dev facing)

Description of the changes in your PR

  • Use WindowCompat to replace the deprecated UI visibility flags.

Fixes the following issue(s)

  • Fixes #

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Due diligence

@sonarcloud
Copy link

sonarcloud bot commented Dec 11, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@TeamNewPipe TeamNewPipe deleted a comment from sonarcloud bot Jan 1, 2023
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

In fullscreen the system back&home&recent buttons do not show up when the system ui is shown. I could reproduce on API 27 and 30. I was completely unable to test on API 22 as the player seems to crash when going fullscreen...
Search and keyboard seem to work normally.

In each place where you switched from flags to WindowCompat, could you explain why you expect the two code snippets to do the same thing? I.e. which flag turned into which WindowCompat call, ...

@Isira-Seneviratne
Copy link
Member Author

Isira-Seneviratne commented Jan 2, 2023

In fullscreen the system back&home&recent buttons do not show up when the system ui is shown. I could reproduce on API 27 and 30. I was completely unable to test on API 22 as the player seems to crash when going fullscreen...

I didn't encounter that issue when I tested the changes on my end. I'll check again, thanks for the info.

In each place where you switched from flags to WindowCompat, could you explain why you expect the two code snippets to do the same thing? I.e. which flag turned into which WindowCompat call, ...

Sure, the setDecorFitsSystemWindows call replaces the SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION and SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN flags (the compat call uses them on API 16-29) and the insets controller calls replace the system bar immersive flags.

https://developer.android.com/reference/androidx/core/view/WindowCompat#setDecorFitsSystemWindows(android.view.Window,boolean)
https://developer.android.com/develop/ui/views/layout/immersive

@Isira-Seneviratne
Copy link
Member Author

Isira-Seneviratne commented Jan 10, 2023

In fullscreen the system back&home&recent buttons do not show up when the system ui is shown. I could reproduce on API 27 and 30.

It was already like that in the main player UI (it only shows the status bar when tapping the video view).

@Stypox
Copy link
Member

Stypox commented Jan 11, 2023

That's not true, see this screenshot from nightly-26:
Screenshot_20230111-205745_NewPipe_nightly.png

@Isira-Seneviratne
Copy link
Member Author

Isira-Seneviratne commented Jan 12, 2023

Okay, thanks. I checked on an API 23 emulator and it didn't show the navigation bar (I probably didn't deploy the dev branch correctly). I'll update the flag.

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Everything else seems to work fine now though

@@ -662,15 +662,14 @@ private void showKeyboardSearch() {
if (DEBUG) {
Log.d(TAG, "showKeyboardSearch() called");
}
KeyboardUtil.showKeyboard(activity, searchEditText);
KeyboardUtil.showKeyboard(getActivity(), searchEditText);
Copy link
Member

Choose a reason for hiding this comment

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

The keyboard does not show up when you tap on "search" anymore

Copy link
Member Author

@Isira-Seneviratne Isira-Seneviratne Jan 14, 2023

Choose a reason for hiding this comment

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

That's weird. I checked on API 23 and 31, and the keyboard showed up on both when selecting the search icon.

Update: I think I know what you mean, the cursor isn't showing up in the search bar.

Copy link
Member

Choose a reason for hiding this comment

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

I used API 33, and the keyboard itself wouldn't open

@Isira-Seneviratne Isira-Seneviratne force-pushed the WindowCompat branch 2 times, most recently from 23c7a1b to 15142a8 Compare January 14, 2023 04:51
Comment on lines 27 to 39
if (!imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED)) {
/*
* Sometimes the keyboard can't be shown because Android's ImeFocusController is in
* a incorrect state e.g. when animations are disabled or the unfocus event of the
* previous view arrives in the wrong moment (see #7647 for details).
* The invalid state can be fixed by to re-focusing the editText.
*/
editText.clearFocus();
editText.requestFocus();

// Try again
imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
}
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure we can remove this safely? #7647

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the linked issue. The issue reoccurred on an API 23 emulator, so I reverted it. Only the system UI visibility flags have been replaced.

@sonarcloud
Copy link

sonarcloud bot commented Jan 15, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Thanks for the patience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codequality Improvements to the codebase to improve the code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants