summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/InvariantDeviceProfile.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-05-21 20:46:33 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-05-22 08:46:41 -0700
commitc6205603efe1f2987caf96504c87d720a25b5a94 (patch)
tree19a1c13def0784a3f3edc1e69aab87251820cbcf /src/com/android/launcher3/InvariantDeviceProfile.java
parent2805e639cdea6ae0051155611d122ed27556e658 (diff)
downloadandroid_packages_apps_Trebuchet-c6205603efe1f2987caf96504c87d720a25b5a94.tar.gz
android_packages_apps_Trebuchet-c6205603efe1f2987caf96504c87d720a25b5a94.tar.bz2
android_packages_apps_Trebuchet-c6205603efe1f2987caf96504c87d720a25b5a94.zip
Creating landscape and portrait device profiles at app initialization
Change-Id: Ide9d007adc36b348e19b05cdf49e87f8b02db60e
Diffstat (limited to 'src/com/android/launcher3/InvariantDeviceProfile.java')
-rw-r--r--src/com/android/launcher3/InvariantDeviceProfile.java30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index fcd6d60f6..92fdbde85 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -16,29 +16,25 @@
package com.android.launcher3;
+import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Point;
import android.graphics.PointF;
+import android.os.Build;
import android.util.DisplayMetrics;
-import android.util.TypedValue;
import android.view.Display;
import android.view.WindowManager;
-
import com.android.launcher3.util.Thunk;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class InvariantDeviceProfile {
- private static final String TAG = "InvariantDeviceProfile";
// This is a static that we use for the default icon size on a 4/5-inch phone
- static float DEFAULT_ICON_SIZE_DP = 60;
-
+ private static float DEFAULT_ICON_SIZE_DP = 60;
- static ArrayList<InvariantDeviceProfile> sDeviceProfiles =
- new ArrayList<InvariantDeviceProfile>();
+ private static final ArrayList<InvariantDeviceProfile> sDeviceProfiles = new ArrayList<>();
static {
sDeviceProfiles.add(new InvariantDeviceProfile("Super Short Stubby",
255, 300, 2, 3, 2, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4));
@@ -67,7 +63,7 @@ public class InvariantDeviceProfile {
1527, 2527, 7, 7, 6, 6, 100, 20, 7, 72, R.xml.default_workspace_4x4));
}
- class DeviceProfileQuery {
+ private class DeviceProfileQuery {
InvariantDeviceProfile profile;
float widthDps;
float heightDps;
@@ -100,6 +96,9 @@ public class InvariantDeviceProfile {
// Derived invariant properties
int hotseatAllAppsRank;
+ DeviceProfile landscapeProfile;
+ DeviceProfile portraitProfile;
+
InvariantDeviceProfile() {
}
@@ -124,6 +123,7 @@ public class InvariantDeviceProfile {
defaultLayoutId = dlId;
}
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
InvariantDeviceProfile(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
@@ -179,6 +179,18 @@ public class InvariantDeviceProfile {
// If the partner customization apk contains any grid overrides, apply them
// Supported overrides: numRows, numColumns, iconSize
applyPartnerDeviceProfileOverrides(context, dm);
+
+ Point realSize = new Point();
+ display.getRealSize(realSize);
+ // The real size never changes. smallSide and largeSize will remain the
+ // same in any orientation.
+ int smallSide = Math.min(realSize.x, realSize.y);
+ int largeSide = Math.max(realSize.x, realSize.y);
+
+ landscapeProfile = new DeviceProfile(context, this, smallestSize, largestSize,
+ largeSide, smallSide, true /* isLandscape */);
+ portraitProfile = new DeviceProfile(context, this, smallestSize, largestSize,
+ smallSide, largeSide, false /* isLandscape */);
}
/**