Commit 4da346ef authored by Evan W. Patton's avatar Evan W. Patton Committed by Jeffrey Schiller

Improve app resizing on Chromebooks

Change-Id: I58de7133e0eb76d13353ed152c38137bbdb31a3d
parent ec35256e
// -*- mode: java; c-basic-offset: 2; -*- // -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved // Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2019 MIT, All rights reserved // Copyright 2011-2020 MIT, All rights reserved
// Released under the Apache License, Version 2.0 // Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
...@@ -984,7 +984,8 @@ public final class Compiler { ...@@ -984,7 +984,8 @@ public final class Compiler {
// The keyboard option prevents the app from stopping when a external (bluetooth) // The keyboard option prevents the app from stopping when a external (bluetooth)
// keyboard is attached. // keyboard is attached.
out.write("android:configChanges=\"orientation|screenSize|keyboardHidden|keyboard\">\n"); out.write("android:configChanges=\"orientation|screenSize|keyboardHidden|keyboard|"
+ "screenLayout|smallestScreenSize\">\n");
out.write(" <intent-filter>\n"); out.write(" <intent-filter>\n");
out.write(" <action android:name=\"android.intent.action.MAIN\" />\n"); out.write(" <action android:name=\"android.intent.action.MAIN\" />\n");
......
// -*- mode: java; c-basic-offset: 2; -*- // -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2015 Google, All Rights reserved // Copyright 2009-2015 Google, All Rights reserved
// Copyright 2011-2015 MIT, All rights reserved // Copyright 2011-2020 MIT, All rights reserved
// Released under the Apache License, Version 2.0 // Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
...@@ -13,7 +13,6 @@ import android.util.Log; ...@@ -13,7 +13,6 @@ import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.WindowManager; import android.view.WindowManager;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -75,12 +74,8 @@ public final class ScreenDensityUtil { ...@@ -75,12 +74,8 @@ public final class ScreenDensityUtil {
float sw = width/(float)newWidth; float sw = width/(float)newWidth;
float sh = height/(float)newHeight; float sh = height/(float)newHeight;
float scale = sw < sh ? sw : sh;
if (scale < 1) {
scale = 1;
}
return scale; return Math.max(1, Math.min(Math.min(sw, sh), MAXIMUM_ASPECT_RATIO));
} }
/** /**
...@@ -90,14 +85,19 @@ public final class ScreenDensityUtil { ...@@ -90,14 +85,19 @@ public final class ScreenDensityUtil {
* @param context context to get screen size of. * @param context context to get screen size of.
* @param outSize Set to the real size of the display. * @param outSize Set to the real size of the display.
*/ */
public static void getRawScreenDim(Context context, Point outSize) { private static void getRawScreenDim(Context context, Point outSize) {
final DisplayMetrics metrics = new DisplayMetrics(); final DisplayMetrics metrics = new DisplayMetrics();
final WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); final WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay(); Display display = wm.getDefaultDisplay();
int sdkLevel = SdkLevel.getLevel(); int sdkLevel = SdkLevel.getLevel();
if (sdkLevel >= SdkLevel.LEVEL_JELLYBEAN_MR1) { if (sdkLevel >= SdkLevel.LEVEL_NOUGAT) {
// Needed for multi-window support
display.getMetrics(metrics);
outSize.x = metrics.widthPixels;
outSize.y = metrics.heightPixels;
} else if (sdkLevel >= SdkLevel.LEVEL_JELLYBEAN_MR1) {
// On API level 17, a public method was added to get the actual sizes // On API level 17, a public method was added to get the actual sizes
JellybeanUtil.getRealSize(display, outSize); JellybeanUtil.getRealSize(display, outSize);
} else if ( sdkLevel > SdkLevel.LEVEL_GINGERBREAD_MR1){ } else if ( sdkLevel > SdkLevel.LEVEL_GINGERBREAD_MR1){
......
// -*- mode: java; c-basic-offset: 2; -*- // -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved // Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2012 MIT, All rights reserved // Copyright 2011-2020 MIT, All rights reserved
// Released under the Apache License, Version 2.0 // Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
...@@ -34,6 +34,7 @@ public class SdkLevel { ...@@ -34,6 +34,7 @@ public class SdkLevel {
public static final int LEVEL_KITKAT = 19; // a.k.a. 4.4 public static final int LEVEL_KITKAT = 19; // a.k.a. 4.4
public static final int LEVEL_LOLLIPOP = 21; // a.k.a. 5.0 public static final int LEVEL_LOLLIPOP = 21; // a.k.a. 5.0
public static final int LEVEL_MARSHMALLOW = 23; // a.k.a. 6.0 public static final int LEVEL_MARSHMALLOW = 23; // a.k.a. 6.0
public static final int LEVEL_NOUGAT = 24; // a.k.a. 7.0
private SdkLevel() { private SdkLevel() {
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment