Skip to content

Display size calculation fixes#99

Merged
malinajirka merged 5 commits intodevelopfrom
display-size-fixes
Nov 26, 2021
Merged

Display size calculation fixes#99
malinajirka merged 5 commits intodevelopfrom
display-size-fixes

Conversation

@hichamboushaba
Copy link
Copy Markdown
Member

@hichamboushaba hichamboushaba commented Nov 24, 2021

The DisplayUtils is using deprecated functions for calculating the display size, since Android 11, the Android team introduced the notion of WindowMetrics to account for the aspect of resizability of windows in Android in the future, this new API should offer more accurate results, and allow taking the insets (system bars) into account when calculating it.

The change I did here uses the default value returned by getCurrentWindowMetrics without excluding the insets, as it's same as what getDefaultDisplay is giving, in the future, we can decide if we want to update it.

I also included another change, the API currently has two methods called getDisplayPixelWidth, one of them needs a Context, and the other one doesn't, but the real issue is that they give different results when the screen is split, since one will return the actual size of the display, while the one accepting Context will return the size of the app's window, so I renamed the functions a bit to make it clear to getWindowPixelWidth and getWindowPixelHeight.
I deprecated the other ones to avoid breaking anything, but I wonder if this is the right move, or should we remove them and update the clients right away, WDYT?

For testing, please refer to the PR woocommerce/woocommerce-android#5346

Copy link
Copy Markdown
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

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

LGTM, great improvement! :)

@hichamboushaba hichamboushaba removed the request for review from 0nko November 26, 2021 10:59
@hichamboushaba
Copy link
Copy Markdown
Member Author

Thanks for the review @malinajirka, do you have permission to merge, or do we need to ask someone else?

@malinajirka malinajirka merged commit 358e582 into develop Nov 26, 2021
@malinajirka malinajirka deleted the display-size-fixes branch November 26, 2021 11:45
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.

2 participants