summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-06-05 18:09:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-05 18:09:35 +0000
commit6103501fa6c70ca112ac867e18e5f82021bf4f7c (patch)
tree7a371d309afdabb03f7db35bb17288ecc065cdf4
parent7501adf4b71bb17d0785a5939efbcac4b39125c3 (diff)
parent2c6e5ccbcd7c3f87e7e85029782440600dc0a3d8 (diff)
downloadandroid_packages_apps_Trebuchet-6103501fa6c70ca112ac867e18e5f82021bf4f7c.tar.gz
android_packages_apps_Trebuchet-6103501fa6c70ca112ac867e18e5f82021bf4f7c.tar.bz2
android_packages_apps_Trebuchet-6103501fa6c70ca112ac867e18e5f82021bf4f7c.zip
Merge "Ensuring that we use the screen width more optimally in AllApps." into ub-launcher3-burnaby
-rw-r--r--res/layout/all_apps_container.xml1
-rw-r--r--res/layout/all_apps_icon.xml2
-rw-r--r--res/layout/all_apps_prediction_bar_icon.xml2
-rw-r--r--res/values/dimens.xml5
-rw-r--r--src/com/android/launcher3/BubbleTextView.java1
-rw-r--r--src/com/android/launcher3/DeviceProfile.java8
-rw-r--r--src/com/android/launcher3/FolderPagedView.java4
-rw-r--r--src/com/android/launcher3/InvariantDeviceProfile.java36
-rw-r--r--src/com/android/launcher3/Utilities.java11
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java19
-rw-r--r--src/com/android/launcher3/allapps/AllAppsGridAdapter.java5
11 files changed, 58 insertions, 36 deletions
diff --git a/res/layout/all_apps_container.xml b/res/layout/all_apps_container.xml
index a20ab46d8..fc77cd31f 100644
--- a/res/layout/all_apps_container.xml
+++ b/res/layout/all_apps_container.xml
@@ -38,6 +38,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/all_apps_search_bar_height"
+ android:paddingBottom="@dimen/all_apps_prediction_bar_bottom_padding"
android:orientation="horizontal"
android:descendantFocusability="afterDescendants"
android:focusable="true"
diff --git a/res/layout/all_apps_icon.xml b/res/layout/all_apps_icon.xml
index 10ed25c47..0985e95c0 100644
--- a/res/layout/all_apps_icon.xml
+++ b/res/layout/all_apps_icon.xml
@@ -20,7 +20,7 @@
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="left|center_vertical"
+ android:layout_gravity="center"
android:paddingTop="@dimen/all_apps_icon_top_bottom_padding"
android:paddingBottom="@dimen/all_apps_icon_top_bottom_padding"
android:focusable="true"
diff --git a/res/layout/all_apps_prediction_bar_icon.xml b/res/layout/all_apps_prediction_bar_icon.xml
index 1e75d14b6..5f63f6bdb 100644
--- a/res/layout/all_apps_prediction_bar_icon.xml
+++ b/res/layout/all_apps_prediction_bar_icon.xml
@@ -19,7 +19,7 @@
style="@style/Icon.AllApps"
android:id="@+id/icon"
android:layout_width="0dp"
- android:layout_height="match_parent"
+ android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:focusable="true"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 63edd888b..2184eadb3 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -58,9 +58,10 @@
<dimen name="all_apps_grid_section_y_offset">8dp</dimen>
<dimen name="all_apps_grid_section_text_size">24sp</dimen>
<dimen name="all_apps_search_bar_height">52dp</dimen>
+ <dimen name="all_apps_search_bar_prediction_bar_padding">8dp</dimen>
<dimen name="all_apps_icon_top_bottom_padding">8dp</dimen>
- <dimen name="all_apps_icon_left_right_padding">18dp</dimen>
- <dimen name="all_apps_prediction_icon_top_bottom_padding">12dp</dimen>
+ <dimen name="all_apps_icon_width_gap">24dp</dimen>
+ <dimen name="all_apps_prediction_bar_bottom_padding">16dp</dimen>
<dimen name="all_apps_fast_scroll_bar_width">4dp</dimen>
<dimen name="all_apps_fast_scroll_scrubber_touch_inset">-16dp</dimen>
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 6a13f3d69..6c13b4a9b 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 b267f759d..0cd980cb2 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;
@@ -628,6 +627,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 09f6a2c4d..855a4430d 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);
@@ -498,11 +499,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 02a950fde..4b8b2dfc8 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -140,7 +140,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);
@@ -295,6 +295,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;
@@ -337,6 +338,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);
}
/**