Merge "Use correct config.smallestScreenWidthDp when creating Resource in DeviceProfile" into tm-dev am: d826f04b93
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/17258303 Change-Id: Ifc38d55099c8398416cec846508bf08c2d9828dc
This commit is contained in:
@@ -257,7 +257,8 @@ public class DeviceProfile {
|
||||
// Some more constants.
|
||||
context = getContext(context, info, isVerticalBarLayout() || (isTablet && isLandscape)
|
||||
? Configuration.ORIENTATION_LANDSCAPE
|
||||
: Configuration.ORIENTATION_PORTRAIT);
|
||||
: Configuration.ORIENTATION_PORTRAIT,
|
||||
windowBounds);
|
||||
final Resources res = context.getResources();
|
||||
mMetrics = res.getDisplayMetrics();
|
||||
|
||||
@@ -1231,10 +1232,11 @@ public class DeviceProfile {
|
||||
writer.println(prefix + pxToDpStr("overviewGridSideMargin", overviewGridSideMargin));
|
||||
}
|
||||
|
||||
private static Context getContext(Context c, Info info, int orientation) {
|
||||
private static Context getContext(Context c, Info info, int orientation, WindowBounds bounds) {
|
||||
Configuration config = new Configuration(c.getResources().getConfiguration());
|
||||
config.orientation = orientation;
|
||||
config.densityDpi = info.densityDpi;
|
||||
config.smallestScreenWidthDp = (int) info.smallestSizeDp(bounds);
|
||||
return c.createConfigurationContext(config);
|
||||
}
|
||||
|
||||
|
||||
@@ -345,16 +345,21 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
* Returns {@code true} if the bounds represent a tablet.
|
||||
*/
|
||||
public boolean isTablet(WindowBounds bounds) {
|
||||
return dpiFromPx(Math.min(bounds.bounds.width(), bounds.bounds.height()),
|
||||
densityDpi) >= MIN_TABLET_WIDTH;
|
||||
return smallestSizeDp(bounds) >= MIN_TABLET_WIDTH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the bounds represent a large tablet.
|
||||
*/
|
||||
public boolean isLargeTablet(WindowBounds bounds) {
|
||||
return dpiFromPx(Math.min(bounds.bounds.width(), bounds.bounds.height()),
|
||||
densityDpi) >= MIN_LARGE_TABLET_WIDTH;
|
||||
return smallestSizeDp(bounds) >= MIN_LARGE_TABLET_WIDTH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns smallest size in dp for given bounds.
|
||||
*/
|
||||
public float smallestSizeDp(WindowBounds bounds) {
|
||||
return dpiFromPx(Math.min(bounds.bounds.width(), bounds.bounds.height()), densityDpi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user