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 WindowMetrics API. #8656

Merged
merged 1 commit into from
Aug 4, 2022
Merged

Conversation

Isira-Seneviratne
Copy link
Member

@Isira-Seneviratne Isira-Seneviratne commented Jul 19, 2022

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • Use Android R's WindowMetrics API in VideoDetailFragment and PopupPlayerUi, as Display#getSize() and Display#getMetrics() have been deprecated in favor of it.

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

@Isira-Seneviratne Isira-Seneviratne force-pushed the Use_WindowMetrics branch 2 times, most recently from b1a1ccf to 3f9caca Compare July 20, 2022 02:46
@Isira-Seneviratne Isira-Seneviratne changed the title Use WindowMetrics API in VideoDetailFragment. Use WindowMetrics API. Jul 20, 2022
@Isira-Seneviratne Isira-Seneviratne marked this pull request as ready for review July 20, 2022 02:48
@Stypox
Copy link
Member

Stypox commented Jul 20, 2022

Mmmh, why is the new library needed? According to the docs:

Use WindowMetrics instead. Obtain a WindowMetrics instance by calling WindowManager#getCurrentWindowMetrics(), then call WindowMetrics#getBounds() to get the dimensions of the application window.

All of the mentioned functions belong to the official Android API, so there shouldn't be a need to use libraries. Anyway, how many Kb does the library add to the app?

@Stypox Stypox closed this Jul 20, 2022
@Stypox Stypox reopened this Jul 20, 2022
@Isira-Seneviratne
Copy link
Member Author

Mmmh, why is the new library needed? According to the docs:

Use WindowMetrics instead. Obtain a WindowMetrics instance by calling WindowManager#getCurrentWindowMetrics(), then call WindowMetrics#getBounds() to get the dimensions of the application window.

All of the mentioned functions belong to the official Android API, so there shouldn't be a need to use libraries.

I tried using the Android API, but faced some SonarQube issues.

Anyway, how many Kb does the library add to the app?

I believe around 5 KB.

@Stypox
Copy link
Member

Stypox commented Jul 22, 2022

I tried using the Android API, but faced some SonarQube issues

Oh, which was the issue?

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.

I tested and it works fine. Thank you for implementing this without libraries. The Sonar warnings are normal, because the usage of deprecated methods was not removed, but that's normal in this case, as the deprecated methods are only used on older devices.

@@ -1078,6 +1077,20 @@ public void updateTabLayoutVisibility() {
}
}

private int getWindowHeight(@NonNull final WindowManager windowManager) {
Copy link
Member

Choose a reason for hiding this comment

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

Put this method in util/DeviceUtils

@triallax triallax added the codequality Improvements to the codebase to improve the code quality label Jul 26, 2022
@sonarcloud
Copy link

sonarcloud bot commented Jul 30, 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 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Stypox Stypox mentioned this pull request Aug 4, 2022
5 tasks
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.

Works, thanks

@Stypox Stypox merged commit ffc1d9a into TeamNewPipe:dev Aug 4, 2022
@Isira-Seneviratne Isira-Seneviratne deleted the Use_WindowMetrics branch August 4, 2022 23:29
@Stypox Stypox mentioned this pull request Aug 27, 2022
9 tasks
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