summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout-land/launcher.xml3
-rw-r--r--res/layout-port/launcher.xml2
-rw-r--r--res/layout/apps_customize_pane.xml8
-rw-r--r--res/values-sw600dp-land/dimens.xml6
-rw-r--r--res/values/config.xml6
-rw-r--r--res/values/dimens.xml1
-rw-r--r--src/com/android/launcher3/AppsCustomizePagedView.java10
-rw-r--r--src/com/android/launcher3/DynamicGrid.java84
-rw-r--r--src/com/android/launcher3/PagedViewIcon.java8
9 files changed, 101 insertions, 27 deletions
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index f76ae0dde..a50fc5d67 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -36,8 +36,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
- launcher:defaultScreen="@integer/config_workspaceDefaultScreen"
- launcher:pageIndicator="@id/page_indicator" />
+ launcher:defaultScreen="@integer/config_workspaceDefaultScreen" />
<include layout="@layout/hotseat"
android:id="@+id/hotseat"
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 7eb0d2b64..a3e646388 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -35,7 +35,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
launcher:defaultScreen="@integer/config_workspaceDefaultScreen"
- launcher:pageIndicator="@id/page_indicator">
+ launcher:pageIndicator="@+id/page_indicator">
</com.android.launcher3.Workspace>
<include layout="@layout/hotseat"
diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml
index bc10e708a..1352e1904 100644
--- a/res/layout/apps_customize_pane.xml
+++ b/res/layout/apps_customize_pane.xml
@@ -27,19 +27,17 @@
android:id="@+id/apps_customize_pane_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginBottom="@dimen/apps_customize_page_indicator_offset"
launcher:widgetCountX="@integer/apps_customize_widget_cell_count_x"
launcher:widgetCountY="@integer/apps_customize_widget_cell_count_y"
launcher:clingFocusedX="@integer/apps_customize_cling_focused_x"
launcher:clingFocusedY="@integer/apps_customize_cling_focused_y"
launcher:maxGap="@dimen/workspace_max_gap"
- launcher:pageIndicator="@+id/page_indicator" />
+ launcher:pageIndicator="@+id/apps_customize_page_indicator" />
<include
- android:id="@+id/page_indicator"
+ android:id="@+id/apps_customize_page_indicator"
layout="@layout/page_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom|center_horizontal"
- android:layout_marginBottom="@dimen/apps_customize_page_indicator_margin" />
+ android:layout_gravity="center_horizontal|bottom" />
</FrameLayout>
</com.android.launcher3.AppsCustomizeLayout>
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index 7f5594de3..f9ca01bee 100644
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -15,12 +15,6 @@
-->
<resources>
-<!-- AppsCustomize -->
- <dimen name="apps_customize_pageLayoutWidthGap">36dp</dimen>
- <dimen name="apps_customize_pageLayoutHeightGap">8dp</dimen>
- <dimen name="apps_customize_pageLayoutPaddingTop">20dp</dimen>
- <dimen name="apps_customize_pageLayoutPaddingBottom">14dp</dimen>
-
<!-- QSB -->
<dimen name="toolbar_button_vertical_padding">12dip</dimen>
<dimen name="toolbar_button_horizontal_padding">20dip</dimen>
diff --git a/res/values/config.xml b/res/values/config.xml
index 9ad34b52b..c4bec6040 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -1,4 +1,10 @@
<resources>
+<!-- Dynamic Grid -->
+ <integer name="config_dynamic_grid_max_long_edge_cell_count">6</integer>
+ <integer name="config_dynamic_grid_max_short_edge_cell_count">5</integer>
+ <integer name="config_dynamic_grid_min_edge_cell_count">3</integer>
+
+<!-- Miscellaneous -->
<bool name="config_largeHeap">false</bool>
<bool name="is_tablet">false</bool>
<bool name="is_large_tablet">false</bool>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index e783e6dd0..c1adc736e 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -21,6 +21,7 @@
<dimen name="dynamic_grid_search_bar_height">48dp</dimen>
<dimen name="dynamic_grid_page_indicator_height">24dp</dimen>
<dimen name="dynamic_grid_icon_drawable_padding">4dp</dimen>
+ <dimen name="dynamic_grid_all_apps_cell_padding">18dp</dimen>
<dimen name="dynamic_grid_workspace_page_spacing">8dp</dimen>
<!-- Wallpaper picker -->
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index 253ee2e29..6d8ad0f1e 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -216,6 +216,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private PagedViewCellLayout mWidgetSpacingLayout;
private int mNumAppsPages;
private int mNumWidgetPages;
+ private Rect mAllAppsPadding = new Rect();
// Animation states
enum State { NORMAL, OVERVIEW};
@@ -361,6 +362,13 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
grid.edgeMarginPx, 2 * grid.edgeMarginPx);
}
+ void setAllAppsPadding(Rect r) {
+ mAllAppsPadding.set(r);
+ }
+ void setWidgetsPageIndicatorPadding(int pageIndicatorHeight) {
+ mPageLayoutPaddingBottom = pageIndicatorHeight;
+ }
+
/** Returns the item index of the center item on this page so that we can restore to this
* item index when we rotate. */
private int getMiddleComponentIndexOnCurrentPage() {
@@ -1083,6 +1091,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST);
layout.setMinimumWidth(getPageContentWidth());
layout.measure(widthSpec, heightSpec);
+ layout.setPadding(mAllAppsPadding.left, mAllAppsPadding.top, mAllAppsPadding.right,
+ mAllAppsPadding.bottom);
setVisibilityOnChildren(layout, View.VISIBLE);
}
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index 99a59bedf..67925d99a 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -94,6 +94,11 @@ class DeviceProfile {
int iconDrawablePaddingPx;
int cellWidthPx;
int cellHeightPx;
+ int allAppsIconSizePx;
+ int allAppsIconTextSizePx;
+ int allAppsCellWidthPx;
+ int allAppsCellHeightPx;
+ int allAppsCellPaddingPx;
int folderBackgroundOffset;
int folderIconSizePx;
int folderCellWidthPx;
@@ -155,6 +160,8 @@ class DeviceProfile {
res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_height);
defaultPageSpacingPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_workspace_page_spacing);
+ allAppsCellPaddingPx =
+ res.getDimensionPixelSize(R.dimen.dynamic_grid_all_apps_cell_padding);
// Interpolate the rows
for (DeviceProfile p : profiles) {
@@ -181,6 +188,8 @@ class DeviceProfile {
points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.iconSize));
}
iconSize = invDistWeightedInterpolate(minWidth, minHeight, points);
+ // AllApps uses the original non-scaled icon size
+ allAppsIconSizePx = DynamicGrid.pxFromDp(iconSize, dm);
// Interpolate the icon text size
points.clear();
@@ -190,6 +199,8 @@ class DeviceProfile {
iconTextSize = invDistWeightedInterpolate(minWidth, minHeight, points);
iconDrawablePaddingOriginalPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding);
+ // AllApps uses the original non-scaled icon text size
+ allAppsIconTextSizePx = DynamicGrid.pxFromDp(iconTextSize, dm);
// Interpolate the hotseat icon size
points.clear();
@@ -315,21 +326,30 @@ class DeviceProfile {
CellLayout.LANDSCAPE : CellLayout.PORTRAIT);
int pageIndicatorOffset =
resources.getDimensionPixelSize(R.dimen.apps_customize_page_indicator_offset);
- if (isLandscape) {
- allAppsNumRows = (availableHeightPx - pageIndicatorOffset - 4 * edgeMarginPx) /
- (iconSizePx + iconTextSizePx + 2 * edgeMarginPx);
- } else {
- allAppsNumRows = (int) numRows + 1;
- }
- allAppsNumCols = (availableWidthPx - padding.left - padding.right - 2 * edgeMarginPx) /
- (iconSizePx + 2 * edgeMarginPx);
- allAppsNumCols = (int) Math.min(numColumns, allAppsNumCols);
if (isPhone()) {
searchBarSpaceWidthPx = Math.min(searchBarSpaceMaxWidthPx, widthPx);
} else {
searchBarSpaceWidthPx = widthPx - (isLandscape ? 3 : 1) * iconSizePx;
}
+
+ allAppsCellWidthPx = allAppsIconSizePx;
+ allAppsCellHeightPx = allAppsIconSizePx + drawablePadding + iconTextSizePx;
+ int maxLongEdgeCellCount =
+ resources.getInteger(R.integer.config_dynamic_grid_max_long_edge_cell_count);
+ int maxShortEdgeCellCount =
+ resources.getInteger(R.integer.config_dynamic_grid_max_short_edge_cell_count);
+ int minEdgeCellCount =
+ resources.getInteger(R.integer.config_dynamic_grid_min_edge_cell_count);
+ int maxRows = (isLandscape ? maxShortEdgeCellCount : maxLongEdgeCellCount);
+ int maxCols = (isLandscape ? maxLongEdgeCellCount : maxShortEdgeCellCount);
+
+ allAppsNumRows = (availableHeightPx - pageIndicatorHeightPx) /
+ (allAppsCellHeightPx + allAppsCellPaddingPx);
+ allAppsNumRows = Math.max(minEdgeCellCount, Math.min(maxRows, allAppsNumRows));
+ allAppsNumCols = (availableWidthPx) /
+ (allAppsCellWidthPx + allAppsCellPaddingPx);
+ allAppsNumCols = Math.max(minEdgeCellCount, Math.min(maxCols, allAppsNumCols));
}
void updateFromConfiguration(Context context, Resources resources, int wPx, int hPx,
@@ -613,6 +633,45 @@ class DeviceProfile {
lp = (FrameLayout.LayoutParams) appsCustomize.getLayoutParams();
lp.gravity = Gravity.CENTER;
appsCustomize.setLayoutParams(lp);
+
+ AppsCustomizeLayout host = (AppsCustomizeLayout)
+ launcher.findViewById(R.id.apps_customize_pane);
+ if (host != null) {
+ // Center the all apps page indicator
+ int pageIndicatorHeight = (int) (pageIndicatorHeightPx * Math.min(1f,
+ (allAppsIconSizePx / DynamicGrid.DEFAULT_ICON_SIZE_PX)));
+ pageIndicator = host.findViewById(R.id.apps_customize_page_indicator);
+ if (pageIndicator != null) {
+ lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams();
+ lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
+ lp.width = LayoutParams.WRAP_CONTENT;
+ lp.height = pageIndicatorHeight;
+ pageIndicator.setLayoutParams(lp);
+ }
+
+ AppsCustomizePagedView pagedView = (AppsCustomizePagedView)
+ host.findViewById(R.id.apps_customize_pane_content);
+ padding = new Rect();
+ if (pagedView != null) {
+ // Constrain the dimensions of all apps so that it does not span the full width
+ int paddingLR = (availableWidthPx - (allAppsCellWidthPx * allAppsNumCols)) /
+ (2 * (allAppsNumCols + 1));
+ int paddingTB = (availableHeightPx - (allAppsCellHeightPx * allAppsNumRows)) /
+ (2 * (allAppsNumRows + 1));
+ paddingLR = Math.min(paddingLR, (int)((paddingLR + paddingTB) * 0.75f));
+ paddingTB = Math.min(paddingTB, (int)((paddingLR + paddingTB) * 0.75f));
+ int maxAllAppsWidth = (allAppsNumCols * (allAppsCellWidthPx + 2 * paddingLR));
+ int gridPaddingLR = (availableWidthPx - maxAllAppsWidth) / 2;
+ if (gridPaddingLR > (allAppsCellWidthPx / 4)) {
+ padding.left = padding.right = gridPaddingLR;
+ }
+ // The icons are centered, so we can't just offset by the page indicator height
+ // because the empty space will actually be pageIndicatorHeight + paddingTB
+ padding.bottom = Math.max(0, pageIndicatorHeight - paddingTB);
+ pagedView.setAllAppsPadding(padding);
+ pagedView.setWidgetsPageIndicatorPadding(pageIndicatorHeight);
+ }
+ }
}
}
@@ -624,6 +683,10 @@ public class DynamicGrid {
private float mMinWidth;
private float mMinHeight;
+ // 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;
+ static float DEFAULT_ICON_SIZE_PX = 0;
+
public static float dpiFromPx(int size, DisplayMetrics metrics){
float densityRatio = (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT;
return (size / densityRatio);
@@ -647,6 +710,7 @@ public class DynamicGrid {
boolean hasAA = !AppsCustomizePagedView.DISABLE_ALL_APPS;
boolean useLargeIcons = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE,
R.bool.preferences_interface_general_icons_large_default);
+ DEFAULT_ICON_SIZE_PX = pxFromDp(DEFAULT_ICON_SIZE_DP, dm);
// Our phone profiles include the bar sizes in each orientation
deviceProfiles.add(new DeviceProfile("Super Short Stubby",
255, 300, 2, 3, (useLargeIcons ? 54 : 48), 13, (hasAA ? 5 : 4), (useLargeIcons ? 54 : 48)));
@@ -659,7 +723,7 @@ public class DynamicGrid {
deviceProfiles.add(new DeviceProfile("Nexus S",
296, 491.33f, 4, 4, (useLargeIcons ? 56 : 48), 13, (hasAA ? 5 : 4), (useLargeIcons ? 56 : 48)));
deviceProfiles.add(new DeviceProfile("Nexus 4",
- 359, 518, 4, 4, (useLargeIcons ? 60 : 52), 13, (hasAA ? 5 : 4), (useLargeIcons ? 56 : 48)));
+ 359, 518, 4, 4, (useLargeIcons ? DEFAULT_ICON_SIZE_DP : 52), 13, (hasAA ? 5 : 4), (useLargeIcons ? 56 : 48)));
// The tablet profile is odd in that the landscape orientation
// also includes the nav bar on the side
deviceProfiles.add(new DeviceProfile("Nexus 7",
diff --git a/src/com/android/launcher3/PagedViewIcon.java b/src/com/android/launcher3/PagedViewIcon.java
index 282d794a7..01e41078b 100644
--- a/src/com/android/launcher3/PagedViewIcon.java
+++ b/src/com/android/launcher3/PagedViewIcon.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Region;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.TextView;
@@ -64,7 +65,7 @@ public class PagedViewIcon extends TextView {
// Ensure we are using the right text size
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
- setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx);
+ setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
mTextColor = getCurrentTextColor();
mIsTextVisible = mTextColor != getResources().getColor(android.R.color.transparent);
}
@@ -76,8 +77,9 @@ public class PagedViewIcon extends TextView {
mIcon = info.iconBitmap;
mPressedCallback = cb;
- setCompoundDrawables(null, Utilities.createIconDrawable(mIcon),
- null, null);
+ Drawable icon = Utilities.createIconDrawable(mIcon);
+ icon.setBounds(0, 0, grid.allAppsIconSizePx, grid.allAppsIconSizePx);
+ setCompoundDrawables(null, icon, null, null);
setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
setText(info.title);
setTag(info);