diff options
author | twellington <twellington@chromium.org> | 2016-03-21 10:11:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-21 17:12:29 +0000 |
commit | 5ebf469532e32d536ff43cbac7f556caf0ac4886 (patch) | |
tree | 342782ccbaad90879df0a6835dcb2ae47bf8e43c /ui | |
parent | da0ce8d5f44c0bee79fff8a39a500548d06df79b (diff) | |
download | chromium_src-5ebf469532e32d536ff43cbac7f556caf0ac4886.zip chromium_src-5ebf469532e32d536ff43cbac7f556caf0ac4886.tar.gz chromium_src-5ebf469532e32d536ff43cbac7f556caf0ac4886.tar.bz2 |
Hide toolbar buttons on tablets when available width < 600dp
With the introduction of multi-window on Android N, the toolbar on tablets
may have < 600dp in available width. In order to make the omnibox useable,
the toolbar buttons are moved to the app menu when the Activity width
is < 600dp.
BUG=591109
Review URL: https://codereview.chromium.org/1805563003
Cr-Commit-Position: refs/heads/master@{#382312}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/android/java/src/org/chromium/ui/base/DeviceFormFactor.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/android/java/src/org/chromium/ui/base/DeviceFormFactor.java b/ui/android/java/src/org/chromium/ui/base/DeviceFormFactor.java index b519c3a..580584c 100644 --- a/ui/android/java/src/org/chromium/ui/base/DeviceFormFactor.java +++ b/ui/android/java/src/org/chromium/ui/base/DeviceFormFactor.java @@ -24,6 +24,8 @@ public class DeviceFormFactor { private static Boolean sIsTablet = null; private static Boolean sIsLargeTablet = null; + private static Integer sMinimumTabletWidthPx = null; + private static Float sDensity = null; /** * @param context {@link Context} used to get the Application Context. @@ -77,4 +79,30 @@ public class DeviceFormFactor { return context.getResources().getConfiguration().smallestScreenWidthDp; } } + + /** + * @param context {@link Context} used to get the display density. + * @return The minimum width in px at which the device should be treated like a tablet for + * layout. + */ + public static int getMinimumTabletWidthPx(Context context) { + if (sMinimumTabletWidthPx == null) { + sMinimumTabletWidthPx = Math.round(MINIMUM_TABLET_WIDTH_DP + * context.getResources().getDisplayMetrics().density); + } + return sMinimumTabletWidthPx; + } + + /** + * Resets all cached values if the display density has changed. + */ + public static void resetValuesIfNeeded(Context context) { + float currentDensity = context.getResources().getDisplayMetrics().density; + if (sDensity != null && sDensity != currentDensity) { + sIsTablet = null; + sIsLargeTablet = null; + sMinimumTabletWidthPx = null; + } + sDensity = currentDensity; + } } |