-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: enhance isTablet() on Android #313
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,8 +90,21 @@ private Boolean isEmulator() { | |
} | ||
|
||
private Boolean isTablet() { | ||
int layout = getReactApplicationContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; | ||
return layout == Configuration.SCREENLAYOUT_SIZE_LARGE || layout == Configuration.SCREENLAYOUT_SIZE_XLARGE; | ||
boolean layout = (getReactApplicationContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; | ||
if (layout) { | ||
DisplayMetrics metrics = new DisplayMetrics(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got a build error on this line: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes fixing. |
||
getCurrentActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); | ||
if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT | ||
|| metrics.densityDpi == DisplayMetrics.DENSITY_HIGH | ||
|| metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM | ||
|| metrics.densityDpi == DisplayMetrics.DENSITY_TV | ||
|| metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH) { | ||
return true; | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The else can be dropped, |
||
return false; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
private Boolean is24Hour() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if
Configuration.SCREENLAYOUT_SIZE_LARGE
is 3 andSCREENLAYOUT_SIZE_XLARGE;
is 4, I wouldn't rely on that as we never know what may be added in the future..Can you switch back to testing both values? 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the unnecessary else. What do you meen by switching back to test both. Im doing bigger than or equal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done