summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2013-12-10 12:32:14 -0800
committerDanesh M <daneshm90@gmail.com>2014-06-06 22:54:22 -0700
commit59a4fa6a7fdc25ffd87de7392119a0089d14155b (patch)
tree3b776da29c49a59f0a8ee118266f56b1b259b6b6 /src
parentcd0377f2d43d25672cafe04bb546db1603af1c89 (diff)
downloadandroid_packages_apps_Trebuchet-59a4fa6a7fdc25ffd87de7392119a0089d14155b.tar.gz
android_packages_apps_Trebuchet-59a4fa6a7fdc25ffd87de7392119a0089d14155b.tar.bz2
android_packages_apps_Trebuchet-59a4fa6a7fdc25ffd87de7392119a0089d14155b.zip
Adjusting grid for tablets and fixing incorrect resources for large tablets.
Change-Id: I4c2a058da934bef14f5be3c53ebda940aeb990ca
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/CellLayout.java7
-rw-r--r--src/com/android/launcher3/DeviceProfile.java45
-rw-r--r--src/com/android/launcher3/DynamicGrid.java2
-rw-r--r--src/com/android/launcher3/Workspace.java1
4 files changed, 32 insertions, 23 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 5c7c4b36e..f46e77bfa 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -98,6 +98,7 @@ public class CellLayout extends ViewGroup {
private int mForegroundAlpha = 0;
private float mBackgroundAlpha;
private float mBackgroundAlphaMultiplier = 1.0f;
+ private boolean mDrawBackground = true;
private Drawable mNormalBackground;
private Drawable mActiveGlowBackground;
@@ -386,6 +387,10 @@ public class CellLayout extends ViewGroup {
mUseActiveGlowBackground = use;
}
+ void disableBackground() {
+ mDrawBackground = false;
+ }
+
boolean getIsDragOverlapping() {
return mIsDragOverlapping;
}
@@ -414,7 +419,7 @@ public class CellLayout extends ViewGroup {
// When we're small, we are either drawn normally or in the "accepts drops" state (during
// a drag). However, we also drag the mini hover background *over* one of those two
// backgrounds
- if (mBackgroundAlpha > 0.0f) {
+ if (mDrawBackground && mBackgroundAlpha > 0.0f) {
Drawable bg;
if (mUseActiveGlowBackground) {
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index b818dd59e..f0fdedfb0 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -121,8 +121,11 @@ public class DeviceProfile {
int searchBarHeightPx;
int pageIndicatorHeightPx;
+
boolean searchBarVisible;
+ float dragViewScale;
+
private ArrayList<DeviceProfileCallbacks> mCallbacks = new ArrayList<DeviceProfileCallbacks>();
DeviceProfile(String n, float w, float h, float r, float c,
@@ -292,11 +295,12 @@ public class DeviceProfile {
// Check to see if the icons fit in the new available height. If not, then we need to
// shrink the icon size.
- Rect workspacePadding = getWorkspacePadding();
float scale = 1f;
int drawablePadding = iconDrawablePaddingOriginalPx;
updateIconSize(1f, drawablePadding, resources, dm);
float usedHeight = (cellHeightPx * numRows);
+
+ Rect workspacePadding = getWorkspacePadding();
int maxHeight = (availableHeightPx - workspacePadding.top - workspacePadding.bottom);
if (usedHeight > maxHeight) {
scale = maxHeight / usedHeight;
@@ -329,6 +333,8 @@ public class DeviceProfile {
FontMetrics fm = textPaint.getFontMetrics();
cellWidthPx = iconSizePx;
cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top);
+ final float scaleDps = resources.getDimensionPixelSize(R.dimen.dragViewScale);
+ dragViewScale = (iconSizePx + scaleDps) / iconSizePx;
// Hotseat
hotseatBarHeightPx = iconSizePx + 4 * edgeMarginPx;
@@ -508,17 +514,21 @@ public class DeviceProfile {
if (isTablet()) {
// Pad the left and right of the workspace to ensure consistent spacing
// between all icons
+ float gapScale = 1f + (dragViewScale - 1f) / 2f;
int width = (orientation == CellLayout.LANDSCAPE)
? Math.max(widthPx, heightPx)
: Math.min(widthPx, heightPx);
- // XXX: If the icon size changes across orientations, we will have to take
- // that into account here too.
- int gap = (int) ((width - 2 * edgeMarginPx -
- (numColumns * cellWidthPx)) / (2 * (numColumns + 1)));
- padding.set(edgeMarginPx + gap,
- searchBarBounds.bottom,
- edgeMarginPx + gap,
- hotseatBarHeightPx + pageIndicatorHeightPx);
+ int height = (orientation != CellLayout.LANDSCAPE)
+ ? Math.max(widthPx, heightPx)
+ : Math.min(widthPx, heightPx);
+ int paddingTop = searchBarBounds.bottom;
+ int paddingBottom = hotseatBarHeightPx + pageIndicatorHeightPx;
+ int availableWidth = Math.max(0, width - (int) ((numColumns * cellWidthPx) +
+ (numColumns * gapScale * cellWidthPx)));
+ int availableHeight = Math.max(0, height - paddingTop - paddingBottom
+ - (int) (2 * numRows * cellHeightPx));
+ padding.set(availableWidth / 2, paddingTop + availableHeight / 2,
+ availableWidth / 2, paddingBottom + availableHeight / 2);
} else {
// Pad the top and bottom of the workspace with search/hotseat bar sizes
padding.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left,
@@ -531,8 +541,8 @@ public class DeviceProfile {
}
int getWorkspacePageSpacing(int orientation) {
- if (orientation == CellLayout.LANDSCAPE &&
- transposeLayoutWithOrientation) {
+ if ((orientation == CellLayout.LANDSCAPE &&
+ transposeLayoutWithOrientation) || isLargeTablet()) {
// In landscape mode the page spacing is set to the default.
return defaultPageSpacingPx;
} else {
@@ -668,19 +678,12 @@ public class DeviceProfile {
lp.height = LayoutParams.MATCH_PARENT;
hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx);
} else if (isTablet()) {
- // Pad the hotseat with the grid gap calculated above
- int gridGap = (int) ((widthPx - 2 * edgeMarginPx -
- (numColumns * cellWidthPx)) / (2 * (numColumns + 1)));
- int gridWidth = (int) ((numColumns * cellWidthPx) +
- ((numColumns - 1) * gridGap));
- int hotseatGap = (int) Math.max(0,
- (gridWidth - (numHotseatIcons * hotseatCellWidthPx))
- / (numHotseatIcons - 1));
+ // Pad the hotseat with the workspace padding calculated above
lp.gravity = Gravity.BOTTOM;
lp.width = LayoutParams.MATCH_PARENT;
lp.height = hotseatBarHeightPx;
- hotseat.setPadding(2 * edgeMarginPx + gridGap + hotseatGap, 0,
- 2 * edgeMarginPx + gridGap + hotseatGap,
+ hotseat.setPadding(edgeMarginPx + padding.left, 0,
+ edgeMarginPx + padding.right,
2 * edgeMarginPx);
} else {
// For phones, layout the hotseat without any bottom margin
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index 6b7eee83b..e040af6ff 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -80,7 +80,7 @@ public class DynamicGrid {
575, 904, 5, 5, (useLargeIcons ? 72 : 60), 14.4f, 7, (useLargeIcons ? 60 : 52)));
// Larger tablet profiles always have system bars on the top & bottom
deviceProfiles.add(new DeviceProfile("Nexus 10",
- 727, 1207, 5, 8, (useLargeIcons ? 80 : 64), 14.4f, 9, (useLargeIcons ? 64 : 56)));
+ 727, 1207, 5, 8, (useLargeIcons ? 76 : 64), 14.4f, 9, (useLargeIcons ? 64 : 56)));
/*
deviceProfiles.add(new DeviceProfile("Nexus 7",
600, 960, 5, 5, 72, 14.4f, 5, 60));
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 64f6a0ccb..9fa215684 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -611,6 +611,7 @@ public class Workspace extends SmoothPagedView
public void createCustomContentPage() {
CellLayout customScreen = (CellLayout)
mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null);
+ customScreen.disableBackground();
mWorkspaceScreens.put(CUSTOM_CONTENT_SCREEN_ID, customScreen);
mScreenOrder.add(0, CUSTOM_CONTENT_SCREEN_ID);