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 DisplayCompat.getMode(). #8484

Closed

Conversation

Isira-Seneviratne
Copy link
Member

@Isira-Seneviratne Isira-Seneviratne commented Jun 5, 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 DisplayCompat.getMode() to get the current display mode. This method provides workarounds for retrieving the display size for Android TV devices.

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 Jun 5, 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

@AudricV AudricV added the codequality Improvements to the codebase to improve the code quality label Jun 5, 2022
@Stypox
Copy link
Member

Stypox commented Jul 6, 2022

Please, provide a "why" to your changes when opening PRs. I have no idea what DisplayCompat does and why this change would be an improvement, I only know it increases code size.

@Stypox Stypox added the waiting for author If the author doesn't respond, the issue will be auto-closed. Otherwise the label will be removed. label Jul 6, 2022
@Isira-Seneviratne
Copy link
Member Author

Please, provide a "why" to your changes when opening PRs. I have no idea what DisplayCompat does and why this change would be an improvement, I only know it increases code size.

Sorry about that, I amended the change description.

@github-actions github-actions bot removed the waiting for author If the author doesn't respond, the issue will be auto-closed. Otherwise the label will be removed. label Jul 6, 2022
@Stypox
Copy link
Member

Stypox commented Jul 6, 2022

Thank you

This method provides workarounds for retrieving the display size for Android TV devices.

Didn't it already work before, or is there an issue this PR fixes? What is the difference in behaviour?

@Isira-Seneviratne
Copy link
Member Author

Thank you

This method provides workarounds for retrieving the display size for Android TV devices.

Didn't it already work before, or is there an issue this PR fixes? What is the difference in behaviour?

The documentation mentions that some 4K TVs might have trouble running the framework code, so a workaround is provided in the method.

@Stypox
Copy link
Member

Stypox commented Jul 13, 2022

According to the Android docs, Display.getSize() does something different than DisplayCompat.getMode().getPhysicalHeight()/display.getMode().getPhysicalHeight(). The first one gets the size of the screen used by the app (so removing system parts), while getPhysicalHeight() just returns the full screen size.

@Isira-Seneviratne
Copy link
Member Author

According to the Android docs, Display.getSize() does something different than DisplayCompat.getMode().getPhysicalHeight()/display.getMode().getPhysicalHeight(). The first one gets the size of the screen used by the app (so removing system parts), while getPhysicalHeight() just returns the full screen size.

You're right, my bad. The backport implementation calls Display#getRealSize() on API levels 17-22 and Display#getSize() below API 17.

The documentation recommends using WindowManager#getCurrentWìndowMetrics() instead of Display#getSize(). I'll update this PR.

@Isira-Seneviratne
Copy link
Member Author

I created a separate PR for the change I mentioned here: #8656

@Isira-Seneviratne Isira-Seneviratne deleted the Use_DisplayCompat branch July 20, 2022 23:45
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