diff options
author | Winson Chung <winsonc@google.com> | 2015-06-01 14:38:24 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2015-06-05 09:49:12 -0700 |
commit | 2c6e5ccbcd7c3f87e7e85029782440600dc0a3d8 (patch) | |
tree | f181fbee9f46ddf18adc42a4d9c823ccd2f1b5fe /src/com | |
parent | a56eab41fbfe26b185cc8240d50d231d0db41837 (diff) | |
download | android_packages_apps_Trebuchet-2c6e5ccbcd7c3f87e7e85029782440600dc0a3d8.tar.gz android_packages_apps_Trebuchet-2c6e5ccbcd7c3f87e7e85029782440600dc0a3d8.tar.bz2 android_packages_apps_Trebuchet-2c6e5ccbcd7c3f87e7e85029782440600dc0a3d8.zip |
Ensuring that we use the screen width more optimally in AllApps.
- Fixing issue with prediction bar height being calculated incorrectly
- Fixing issue where the prediction bar divider was not drawn exactly
between the bar and the first row of apps
- Removing padding to allow scrollbars to reach full height
Bug: 20222023
Bug: 21335377
Change-Id: I2c0614a36e2294d0d6184a6bff4847876ffe971e
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/FolderPagedView.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/InvariantDeviceProfile.java | 36 | ||||
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsContainerView.java | 19 | ||||
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsGridAdapter.java | 5 |
7 files changed, 52 insertions, 32 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index f4e306af3..9a59feb04 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -52,7 +52,6 @@ public class BubbleTextView extends TextView { private static final float SHADOW_Y_OFFSET = 2.0f; private static final int SHADOW_LARGE_COLOUR = 0xDD000000; private static final int SHADOW_SMALL_COLOUR = 0xCC000000; - static final float PADDING_V = 3.0f; private static final int DISPLAY_WORKSPACE = 0; private static final int DISPLAY_ALL_APPS = 1; diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 82be409dd..9c59dab53 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -230,12 +230,12 @@ public class DeviceProfile { public boolean updateAppsViewNumCols(Resources res, int containerWidth) { int appsViewLeftMarginPx = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin); - int allAppsCellPaddingPx = - res.getDimensionPixelSize(R.dimen.all_apps_icon_left_right_padding); + int allAppsCellWidthGap = + res.getDimensionPixelSize(R.dimen.all_apps_icon_width_gap); int availableAppsWidthPx = (containerWidth > 0) ? containerWidth : availableWidthPx; int numAppsCols = (availableAppsWidthPx - appsViewLeftMarginPx) / - (allAppsIconSizePx + 2 * allAppsCellPaddingPx); - int numPredictiveAppCols = isPhone ? 4 : numAppsCols; + (allAppsIconSizePx + allAppsCellWidthGap); + int numPredictiveAppCols = Math.max(inv.minAllAppsPredictionColumns, numAppsCols); if ((numAppsCols != allAppsNumCols) || (numPredictiveAppCols != allAppsNumPredictiveCols)) { allAppsNumCols = numAppsCols; diff --git a/src/com/android/launcher3/FolderPagedView.java b/src/com/android/launcher3/FolderPagedView.java index 7d90ba2f7..b7a5aa8cf 100644 --- a/src/com/android/launcher3/FolderPagedView.java +++ b/src/com/android/launcher3/FolderPagedView.java @@ -87,8 +87,8 @@ public class FolderPagedView extends PagedView { LauncherAppState app = LauncherAppState.getInstance(); InvariantDeviceProfile profile = app.getInvariantDeviceProfile(); - mMaxCountX = (int) profile.numFolderColumns; - mMaxCountY = (int) profile.numFolderRows; + mMaxCountX = profile.numFolderColumns; + mMaxCountY = profile.numFolderRows; mMaxItemsPerPage = mMaxCountX * mMaxCountY; diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index fcaf834a2..ae204c40c 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -57,6 +57,11 @@ public class InvariantDeviceProfile { public int numColumns; /** + * The minimum number of predicted apps in all apps. + */ + int minAllAppsPredictionColumns; + + /** * Number of icons per row and column in the folder. */ public int numFolderRows; @@ -84,11 +89,12 @@ public class InvariantDeviceProfile { public InvariantDeviceProfile(InvariantDeviceProfile p) { this(p.name, p.minWidthDps, p.minHeightDps, p.numRows, p.numColumns, - p.numFolderRows, p.numFolderColumns, p.iconSize, p.iconTextSize, p.numHotseatIcons, - p.hotseatIconSize, p.defaultLayoutId); + p.numFolderRows, p.numFolderColumns, p.minAllAppsPredictionColumns, + p.iconSize, p.iconTextSize, p.numHotseatIcons, p.hotseatIconSize, + p.defaultLayoutId); } - InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, + InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, int maapc, float is, float its, float hs, float his, int dlId) { // Ensure that we have an odd number of hotseat items (since we need to place all apps) if (hs % 2 == 0) { @@ -102,6 +108,7 @@ public class InvariantDeviceProfile { numColumns = c; numFolderRows = fr; numFolderColumns = fc; + minAllAppsPredictionColumns = maapc; iconSize = is; iconTextSize = its; numHotseatIcons = hs; @@ -137,6 +144,7 @@ public class InvariantDeviceProfile { defaultLayoutId = closestProfile.defaultLayoutId; numFolderRows = closestProfile.numFolderRows; numFolderColumns = closestProfile.numFolderColumns; + minAllAppsPredictionColumns = closestProfile.minAllAppsPredictionColumns; iconSize = interpolatedDeviceProfileOut.iconSize; iconBitmapSize = Utilities.pxFromDp(iconSize, dm); @@ -166,30 +174,30 @@ public class InvariantDeviceProfile { // width, height, #rows, #columns, #folder rows, #folder columns, // iconSize, iconTextSize, #hotseat, #hotseatIconSize, defaultLayoutId. predefinedDeviceProfiles.add(new InvariantDeviceProfile("Super Short Stubby", - 255, 300, 2, 3, 2, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4)); + 255, 300, 2, 3, 2, 3, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4)); predefinedDeviceProfiles.add(new InvariantDeviceProfile("Shorter Stubby", - 255, 400, 3, 3, 3, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4)); + 255, 400, 3, 3, 3, 3, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4)); predefinedDeviceProfiles.add(new InvariantDeviceProfile("Short Stubby", - 275, 420, 3, 4, 3, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4)); + 275, 420, 3, 4, 3, 4, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4)); predefinedDeviceProfiles.add(new InvariantDeviceProfile("Stubby", - 255, 450, 3, 4, 3, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4)); + 255, 450, 3, 4, 3, 4, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4)); predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus S", - 296, 491.33f, 4, 4, 4, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4)); + 296, 491.33f, 4, 4, 4, 4, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4)); predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus 4", - 335, 567, 4, 4, 4, 4, DEFAULT_ICON_SIZE_DP, 13, 5, 56, R.xml.default_workspace_4x4)); + 335, 567, 4, 4, 4, 4, 4, DEFAULT_ICON_SIZE_DP, 13, 5, 56, R.xml.default_workspace_4x4)); predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus 5", - 359, 567, 4, 4, 4, 4, DEFAULT_ICON_SIZE_DP, 13, 5, 56, R.xml.default_workspace_4x4)); + 359, 567, 4, 4, 4, 4, 4, DEFAULT_ICON_SIZE_DP, 13, 5, 56, R.xml.default_workspace_4x4)); predefinedDeviceProfiles.add(new InvariantDeviceProfile("Large Phone", - 406, 694, 5, 5, 4, 4, 64, 14.4f, 5, 56, R.xml.default_workspace_5x5)); + 406, 694, 5, 5, 4, 4, 4, 64, 14.4f, 5, 56, R.xml.default_workspace_5x5)); // The tablet profile is odd in that the landscape orientation // also includes the nav bar on the side predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus 7", - 575, 904, 5, 6, 4, 5, 72, 14.4f, 7, 60, R.xml.default_workspace_5x6)); + 575, 904, 5, 6, 4, 5, 4, 72, 14.4f, 7, 60, R.xml.default_workspace_5x6)); // Larger tablet profiles always have system bars on the top & bottom predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus 10", - 727, 1207, 5, 6, 4, 5, 76, 14.4f, 7, 64, R.xml.default_workspace_5x6)); + 727, 1207, 5, 6, 4, 5, 4, 76, 14.4f, 7, 64, R.xml.default_workspace_5x6)); predefinedDeviceProfiles.add(new InvariantDeviceProfile("20-inch Tablet", - 1527, 2527, 7, 7, 6, 6, 100, 20, 7, 72, R.xml.default_workspace_4x4)); + 1527, 2527, 7, 7, 6, 6, 4, 100, 20, 7, 72, R.xml.default_workspace_4x4)); return predefinedDeviceProfiles; } diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index cffcd3445..0877b4527 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -54,7 +54,6 @@ import android.util.SparseArray; import android.util.TypedValue; import android.view.View; import android.widget.Toast; - import junit.framework.Assert; import java.io.ByteArrayOutputStream; @@ -625,6 +624,16 @@ public final class Utilities { return m.replaceAll("$1"); } + /** + * Calculates the height of a given string at a specific text size. + */ + public static float calculateTextHeight(float textSizePx) { + Paint p = new Paint(); + p.setTextSize(textSizePx); + Paint.FontMetrics fm = p.getFontMetrics(); + return -fm.top + fm.bottom; + } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static boolean isRtl(Resources res) { return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) && diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 9386500be..76ca9633d 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -20,6 +20,7 @@ import android.annotation.TargetApi; import android.content.ComponentName; import android.content.Context; import android.content.res.Resources; +import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -239,11 +240,11 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc mLauncher = (Launcher) context; DeviceProfile grid = mLauncher.getDeviceProfile(); - mContainerInset = context.getResources().getDimensionPixelSize( - R.dimen.all_apps_container_inset); - mPredictionBarHeight = grid.allAppsIconSizePx + grid.iconDrawablePaddingOriginalPx + - grid.allAppsIconTextSizePx + - 2 * res.getDimensionPixelSize(R.dimen.all_apps_prediction_icon_top_bottom_padding); + mContainerInset = res.getDimensionPixelSize(R.dimen.all_apps_container_inset); + mPredictionBarHeight = (int) (grid.allAppsIconSizePx + grid.iconDrawablePaddingOriginalPx + + Utilities.calculateTextHeight(grid.allAppsIconTextSizePx) + + 2 * res.getDimensionPixelSize(R.dimen.all_apps_icon_top_bottom_padding) + + res.getDimensionPixelSize(R.dimen.all_apps_prediction_bar_bottom_padding)); mLayoutInflater = LayoutInflater.from(context); @@ -497,11 +498,11 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc int startMargin = grid.isPhone ? mContentMarginStart : 0; int inset = mFixedBounds.isEmpty() ? mContainerInset : mFixedBoundsContainerInset; if (isRtl) { - mAppsRecyclerView.setPadding(inset + mAppsRecyclerView.getScrollbarWidth(), inset, - inset + startMargin, inset); + mAppsRecyclerView.setPadding(inset + mAppsRecyclerView.getScrollbarWidth(), 0, + inset + startMargin, 0); } else { - mAppsRecyclerView.setPadding(inset + startMargin, inset, - inset + mAppsRecyclerView.getScrollbarWidth(), inset); + mAppsRecyclerView.setPadding(inset + startMargin, 0, + inset + mAppsRecyclerView.getScrollbarWidth(), 0); } // Update the header bar diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index 307d9403d..102e7ae8d 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -139,7 +139,7 @@ class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.ViewHol if (shouldDrawItemDivider(holder, items) && !hasDrawnPredictedAppsDivider) { // Draw the divider under the predicted apps - int top = child.getTop() + child.getHeight(); + int top = child.getTop() + child.getHeight() - mPredictionBarBottomPadding / 2; c.drawLine(mBackgroundPadding.left, top, parent.getWidth() - mBackgroundPadding.right, top, mPredictedAppsDividerPaint); @@ -294,6 +294,7 @@ class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.ViewHol private View.OnLongClickListener mIconLongClickListener; @Thunk final Rect mBackgroundPadding = new Rect(); @Thunk int mPredictionBarHeight; + @Thunk int mPredictionBarBottomPadding; @Thunk int mAppsPerRow; @Thunk boolean mIsRtl; private String mEmptySearchText; @@ -336,6 +337,8 @@ class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.ViewHol mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics())); mPredictedAppsDividerPaint.setColor(0x1E000000); mPredictedAppsDividerPaint.setAntiAlias(true); + mPredictionBarBottomPadding = + res.getDimensionPixelSize(R.dimen.all_apps_prediction_bar_bottom_padding); } /** |