am b6147f85: Merge "Adjusting grid for tablets and fixing incorrect resources for large tablets." into jb-ub-now-kermit

* commit 'b6147f85786c78b3608eabf2286cd9e61c28878d':
  Adjusting grid for tablets and fixing incorrect resources for large tablets.
This commit is contained in:
Winson Chung
2014-02-14 20:38:42 +00:00
committed by Android Git Automerger
12 changed files with 32 additions and 43 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

-2
View File
@@ -18,6 +18,4 @@
<!-- Workspace --> <!-- Workspace -->
<!-- Whether or not the drop targets drop down as opposed to fade in --> <!-- Whether or not the drop targets drop down as opposed to fade in -->
<bool name="config_useDropTargetDownTransition">false</bool> <bool name="config_useDropTargetDownTransition">false</bool>
<!-- Whether or not to fade the side pages -->
<bool name="config_workspaceFadeAdjacentScreens">false</bool>
</resources> </resources>
-3
View File
@@ -15,7 +15,4 @@
--> -->
<resources> <resources>
<!-- Workspace -->
<!-- Whether or not to fade the side pages -->
<bool name="config_workspaceFadeAdjacentScreens">false</bool>
</resources> </resources>
-2
View File
@@ -9,8 +9,6 @@
<!-- Workspace --> <!-- Workspace -->
<!-- Whether or not the drop targets drop down as opposed to fade in --> <!-- Whether or not the drop targets drop down as opposed to fade in -->
<bool name="config_useDropTargetDownTransition">false</bool> <bool name="config_useDropTargetDownTransition">false</bool>
<!-- Whether or not to fade the side pages -->
<bool name="config_workspaceFadeAdjacentScreens">true</bool>
<!-- Camera distance for the overscroll effect --> <!-- Camera distance for the overscroll effect -->
<integer name="config_cameraDistance">18000</integer> <integer name="config_cameraDistance">18000</integer>
-2
View File
@@ -52,8 +52,6 @@
<!-- Workspace --> <!-- Workspace -->
<!-- Whether or not the drop targets drop down as opposed to fade in --> <!-- Whether or not the drop targets drop down as opposed to fade in -->
<bool name="config_useDropTargetDownTransition">false</bool> <bool name="config_useDropTargetDownTransition">false</bool>
<!-- Whether or not to fade the side pages -->
<bool name="config_workspaceFadeAdjacentScreens">false</bool>
<!-- The transition duration for the background of the drop targets --> <!-- The transition duration for the background of the drop targets -->
<integer name="config_dropTargetBgTransitionDuration">0</integer> <integer name="config_dropTargetBgTransitionDuration">0</integer>
+6 -1
View File
@@ -100,6 +100,7 @@ public class CellLayout extends ViewGroup {
private int mForegroundAlpha = 0; private int mForegroundAlpha = 0;
private float mBackgroundAlpha; private float mBackgroundAlpha;
private float mBackgroundAlphaMultiplier = 1.0f; private float mBackgroundAlphaMultiplier = 1.0f;
private boolean mDrawBackground = true;
private Drawable mNormalBackground; private Drawable mNormalBackground;
private Drawable mActiveGlowBackground; private Drawable mActiveGlowBackground;
@@ -388,6 +389,10 @@ public class CellLayout extends ViewGroup {
mUseActiveGlowBackground = use; mUseActiveGlowBackground = use;
} }
void disableBackground() {
mDrawBackground = false;
}
boolean getIsDragOverlapping() { boolean getIsDragOverlapping() {
return mIsDragOverlapping; return mIsDragOverlapping;
} }
@@ -416,7 +421,7 @@ public class CellLayout extends ViewGroup {
// When we're small, we are either drawn normally or in the "accepts drops" state (during // 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 // a drag). However, we also drag the mini hover background *over* one of those two
// backgrounds // backgrounds
if (mBackgroundAlpha > 0.0f) { if (mDrawBackground && mBackgroundAlpha > 0.0f) {
Drawable bg; Drawable bg;
if (mUseActiveGlowBackground) { if (mUseActiveGlowBackground) {
+23 -21
View File
@@ -119,6 +119,8 @@ public class DeviceProfile {
int searchBarHeightPx; int searchBarHeightPx;
int pageIndicatorHeightPx; int pageIndicatorHeightPx;
float dragViewScale;
private ArrayList<DeviceProfileCallbacks> mCallbacks = new ArrayList<DeviceProfileCallbacks>(); private ArrayList<DeviceProfileCallbacks> mCallbacks = new ArrayList<DeviceProfileCallbacks>();
DeviceProfile(String n, float w, float h, float r, float c, DeviceProfile(String n, float w, float h, float r, float c,
@@ -282,11 +284,12 @@ public class DeviceProfile {
// Check to see if the icons fit in the new available height. If not, then we need to // Check to see if the icons fit in the new available height. If not, then we need to
// shrink the icon size. // shrink the icon size.
Rect workspacePadding = getWorkspacePadding();
float scale = 1f; float scale = 1f;
int drawablePadding = iconDrawablePaddingOriginalPx; int drawablePadding = iconDrawablePaddingOriginalPx;
updateIconSize(1f, drawablePadding, resources, dm); updateIconSize(1f, drawablePadding, resources, dm);
float usedHeight = (cellHeightPx * numRows); float usedHeight = (cellHeightPx * numRows);
Rect workspacePadding = getWorkspacePadding();
int maxHeight = (availableHeightPx - workspacePadding.top - workspacePadding.bottom); int maxHeight = (availableHeightPx - workspacePadding.top - workspacePadding.bottom);
if (usedHeight > maxHeight) { if (usedHeight > maxHeight) {
scale = maxHeight / usedHeight; scale = maxHeight / usedHeight;
@@ -319,6 +322,8 @@ public class DeviceProfile {
FontMetrics fm = textPaint.getFontMetrics(); FontMetrics fm = textPaint.getFontMetrics();
cellWidthPx = iconSizePx; cellWidthPx = iconSizePx;
cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top); cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top);
final float scaleDps = resources.getDimensionPixelSize(R.dimen.dragViewScale);
dragViewScale = (iconSizePx + scaleDps) / iconSizePx;
// Hotseat // Hotseat
hotseatBarHeightPx = iconSizePx + 4 * edgeMarginPx; hotseatBarHeightPx = iconSizePx + 4 * edgeMarginPx;
@@ -491,17 +496,21 @@ public class DeviceProfile {
if (isTablet()) { if (isTablet()) {
// Pad the left and right of the workspace to ensure consistent spacing // Pad the left and right of the workspace to ensure consistent spacing
// between all icons // between all icons
float gapScale = 1f + (dragViewScale - 1f) / 2f;
int width = (orientation == CellLayout.LANDSCAPE) int width = (orientation == CellLayout.LANDSCAPE)
? Math.max(widthPx, heightPx) ? Math.max(widthPx, heightPx)
: Math.min(widthPx, heightPx); : Math.min(widthPx, heightPx);
// XXX: If the icon size changes across orientations, we will have to take int height = (orientation != CellLayout.LANDSCAPE)
// that into account here too. ? Math.max(widthPx, heightPx)
int gap = (int) ((width - 2 * edgeMarginPx - : Math.min(widthPx, heightPx);
(numColumns * cellWidthPx)) / (2 * (numColumns + 1))); int paddingTop = searchBarBounds.bottom;
padding.set(edgeMarginPx + gap, int paddingBottom = hotseatBarHeightPx + pageIndicatorHeightPx;
searchBarBounds.bottom, int availableWidth = Math.max(0, width - (int) ((numColumns * cellWidthPx) +
edgeMarginPx + gap, (numColumns * gapScale * cellWidthPx)));
hotseatBarHeightPx + pageIndicatorHeightPx); 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 { } else {
// Pad the top and bottom of the workspace with search/hotseat bar sizes // Pad the top and bottom of the workspace with search/hotseat bar sizes
padding.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left, padding.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left,
@@ -514,8 +523,8 @@ public class DeviceProfile {
} }
int getWorkspacePageSpacing(int orientation) { int getWorkspacePageSpacing(int orientation) {
if (orientation == CellLayout.LANDSCAPE && if ((orientation == CellLayout.LANDSCAPE &&
transposeLayoutWithOrientation) { transposeLayoutWithOrientation) || isLargeTablet()) {
// In landscape mode the page spacing is set to the default. // In landscape mode the page spacing is set to the default.
return defaultPageSpacingPx; return defaultPageSpacingPx;
} else { } else {
@@ -645,19 +654,12 @@ public class DeviceProfile {
lp.height = LayoutParams.MATCH_PARENT; lp.height = LayoutParams.MATCH_PARENT;
hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx); hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx);
} else if (isTablet()) { } else if (isTablet()) {
// Pad the hotseat with the grid gap calculated above // Pad the hotseat with the workspace padding 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));
lp.gravity = Gravity.BOTTOM; lp.gravity = Gravity.BOTTOM;
lp.width = LayoutParams.MATCH_PARENT; lp.width = LayoutParams.MATCH_PARENT;
lp.height = hotseatBarHeightPx; lp.height = hotseatBarHeightPx;
hotseat.setPadding(2 * edgeMarginPx + gridGap + hotseatGap, 0, hotseat.setPadding(edgeMarginPx + padding.left, 0,
2 * edgeMarginPx + gridGap + hotseatGap, edgeMarginPx + padding.right,
2 * edgeMarginPx); 2 * edgeMarginPx);
} else { } else {
// For phones, layout the hotseat without any bottom margin // For phones, layout the hotseat without any bottom margin
+2 -2
View File
@@ -74,10 +74,10 @@ public class DynamicGrid {
// The tablet profile is odd in that the landscape orientation // The tablet profile is odd in that the landscape orientation
// also includes the nav bar on the side // also includes the nav bar on the side
deviceProfiles.add(new DeviceProfile("Nexus 7", deviceProfiles.add(new DeviceProfile("Nexus 7",
575, 904, 5, 5, 72, 14.4f, 7, 60)); 575, 904, 5, 6, 72, 14.4f, 7, 60));
// Larger tablet profiles always have system bars on the top & bottom // Larger tablet profiles always have system bars on the top & bottom
deviceProfiles.add(new DeviceProfile("Nexus 10", deviceProfiles.add(new DeviceProfile("Nexus 10",
727, 1207, 5, 5, 80, 14.4f, 7, 64)); 727, 1207, 5, 6, 76, 14.4f, 7, 64));
/* /*
deviceProfiles.add(new DeviceProfile("Nexus 7", deviceProfiles.add(new DeviceProfile("Nexus 7",
600, 960, 5, 5, 72, 14.4f, 5, 60)); 600, 960, 5, 5, 72, 14.4f, 5, 60));
+1 -10
View File
@@ -565,6 +565,7 @@ public class Workspace extends SmoothPagedView
public void createCustomContentPage() { public void createCustomContentPage() {
CellLayout customScreen = (CellLayout) CellLayout customScreen = (CellLayout)
mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null); mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null);
customScreen.disableBackground();
mWorkspaceScreens.put(CUSTOM_CONTENT_SCREEN_ID, customScreen); mWorkspaceScreens.put(CUSTOM_CONTENT_SCREEN_ID, customScreen);
mScreenOrder.add(0, CUSTOM_CONTENT_SCREEN_ID); mScreenOrder.add(0, CUSTOM_CONTENT_SCREEN_ID);
@@ -1155,11 +1156,6 @@ public class Workspace extends SmoothPagedView
} }
} }
// Only show page outlines as we pan if we are on large screen
if (LauncherAppState.getInstance().isScreenLarge()) {
showOutlines();
}
// If we are not fading in adjacent screens, we still need to restore the alpha in case the // If we are not fading in adjacent screens, we still need to restore the alpha in case the
// user scrolls while we are transitioning (should not affect dispatchDraw optimizations) // user scrolls while we are transitioning (should not affect dispatchDraw optimizations)
if (!mWorkspaceFadeInAdjacentScreens) { if (!mWorkspaceFadeInAdjacentScreens) {
@@ -1184,11 +1180,6 @@ public class Workspace extends SmoothPagedView
// is under a new page (to scroll to) // is under a new page (to scroll to)
mDragController.forceTouchMove(); mDragController.forceTouchMove();
} }
} else {
// If we are not mid-dragging, hide the page outlines if we are on a large screen
if (LauncherAppState.getInstance().isScreenLarge()) {
hideOutlines();
}
} }
if (mDelayedResizeRunnable != null) { if (mDelayedResizeRunnable != null) {