Merge "Landscape grid changes for Workspace/All Apps." into ub-launcher3-dorval-polish

am: 6828cbb751

Change-Id: I3892b4c6d7b0635e7edb7340de0c4f19730c388d
This commit is contained in:
Jon Miranda 2017-06-23 19:04:01 +00:00 committed by android-build-merger
commit e2468d8483
15 changed files with 137 additions and 110 deletions

View File

@ -63,8 +63,8 @@
<com.android.launcher3.pageindicators.PageIndicatorCaretLandscape <com.android.launcher3.pageindicators.PageIndicatorCaretLandscape
android:id="@+id/page_indicator" android:id="@+id/page_indicator"
android:theme="@style/HomeScreenElementTheme" android:theme="@style/HomeScreenElementTheme"
android:layout_width="@dimen/dynamic_grid_page_indicator_height" android:layout_width="@dimen/dynamic_grid_page_indicator_size"
android:layout_height="@dimen/dynamic_grid_page_indicator_height" android:layout_height="@dimen/dynamic_grid_page_indicator_size"
android:layout_gravity="bottom|left"/> android:layout_gravity="bottom|left"/>
<include layout="@layout/widgets_view" <include layout="@layout/widgets_view"

View File

@ -53,9 +53,7 @@
android:clipToPadding="false" android:clipToPadding="false"
android:overScrollMode="never" android:overScrollMode="never"
android:descendantFocusability="afterDescendants" android:descendantFocusability="afterDescendants"
android:focusable="true" android:focusable="true" />
android:paddingStart="@dimen/dynamic_grid_edge_margin"
android:paddingEnd="@dimen/dynamic_grid_edge_margin" />
<!-- Fast scroller popup --> <!-- Fast scroller popup -->
<TextView <TextView

View File

@ -18,7 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:theme="@style/HomeScreenElementTheme" android:theme="@style/HomeScreenElementTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dynamic_grid_page_indicator_height"> android:layout_height="@dimen/dynamic_grid_page_indicator_size">
<ImageView <ImageView
android:id="@+id/all_apps_handle" android:id="@+id/all_apps_handle"
android:layout_width="48dp" android:layout_width="48dp"

View File

@ -24,4 +24,15 @@
<dimen name="fastscroll_popup_padding">10dp</dimen> <dimen name="fastscroll_popup_padding">10dp</dimen>
<dimen name="fastscroll_popup_text_size">24dp</dimen> <dimen name="fastscroll_popup_text_size">24dp</dimen>
<!-- Dynamic grid -->
<dimen name="dynamic_grid_overview_bar_item_width">120dp</dimen>
<dimen name="dynamic_grid_page_indicator_size">24dp</dimen>
<dimen name="dynamic_grid_icon_drawable_padding">8dp</dimen>
<dimen name="dynamic_grid_cell_padding_x">8dp</dimen>
<!-- Hotseat -->
<dimen name="dynamic_grid_hotseat_land_left_nav_bar_right_padding">18dp</dimen>
<dimen name="dynamic_grid_hotseat_land_right_nav_bar_right_padding">6dp</dimen>
<dimen name="dynamic_grid_hotseat_land_left_nav_bar_gutter_width">24dp</dimen>
<dimen name="dynamic_grid_hotseat_land_right_nav_bar_gutter_width">32dp</dimen>
</resources> </resources>

View File

@ -116,9 +116,9 @@
<attr name="numHotseatIcons" format="integer" /> <attr name="numHotseatIcons" format="integer" />
<attr name="iconSize" format="float" /> <attr name="iconSize" format="float" />
<!-- landscapeIconSize defaults to iconSize, if not specified -->
<attr name="landscapeIconSize" format="float" />
<attr name="iconTextSize" format="float" /> <attr name="iconTextSize" format="float" />
<!-- hotseatIconSize defaults to iconSize, if not specified -->
<attr name="hotseatIconSize" format="float" />
<attr name="defaultLayoutId" format="reference" /> <attr name="defaultLayoutId" format="reference" />
</declare-styleable> </declare-styleable>

View File

@ -17,10 +17,9 @@
<resources> <resources>
<!-- Dynamic Grid --> <!-- Dynamic Grid -->
<dimen name="dynamic_grid_edge_margin">16dp</dimen> <dimen name="dynamic_grid_edge_margin">16dp</dimen>
<dimen name="dynamic_grid_page_indicator_height">32dp</dimen> <dimen name="dynamic_grid_page_indicator_size">32dp</dimen>
<dimen name="dynamic_grid_page_indicator_line_height">1dp</dimen> <dimen name="dynamic_grid_page_indicator_line_height">1dp</dimen>
<dimen name="dynamic_grid_page_indicator_gutter_width_left_nav_bar">38dp</dimen> <dimen name="dynamic_grid_page_indicator_gutter_width">50dp</dimen>
<dimen name="dynamic_grid_page_indicator_gutter_width_right_nav_bar">48dp</dimen>
<dimen name="dynamic_grid_icon_drawable_padding">8dp</dimen> <dimen name="dynamic_grid_icon_drawable_padding">8dp</dimen>
<dimen name="dynamic_grid_overview_min_icon_zone_height">80dp</dimen> <dimen name="dynamic_grid_overview_min_icon_zone_height">80dp</dimen>
<dimen name="dynamic_grid_overview_max_icon_zone_height">120dp</dimen> <dimen name="dynamic_grid_overview_max_icon_zone_height">120dp</dimen>
@ -38,7 +37,10 @@
<dimen name="dynamic_grid_hotseat_top_padding">8dp</dimen> <dimen name="dynamic_grid_hotseat_top_padding">8dp</dimen>
<dimen name="dynamic_grid_hotseat_bottom_padding">2dp</dimen> <dimen name="dynamic_grid_hotseat_bottom_padding">2dp</dimen>
<dimen name="dynamic_grid_hotseat_height">80dp</dimen> <dimen name="dynamic_grid_hotseat_height">80dp</dimen>
<dimen name="dynamic_grid_hotseat_land_gutter_width">24dp</dimen> <dimen name="dynamic_grid_hotseat_land_left_nav_bar_right_padding">0dp</dimen>
<dimen name="dynamic_grid_hotseat_land_right_nav_bar_right_padding">0dp</dimen>
<dimen name="dynamic_grid_hotseat_land_left_nav_bar_gutter_width">0dp</dimen>
<dimen name="dynamic_grid_hotseat_land_right_nav_bar_gutter_width">0dp</dimen>
<!-- Drop target bar --> <!-- Drop target bar -->
<dimen name="dynamic_grid_drop_target_size">48dp</dimen> <dimen name="dynamic_grid_drop_target_size">48dp</dimen>
@ -74,7 +76,7 @@
<dimen name="all_apps_caret_stroke_width">2dp</dimen> <dimen name="all_apps_caret_stroke_width">2dp</dimen>
<dimen name="all_apps_caret_shadow_spread">1dp</dimen> <dimen name="all_apps_caret_shadow_spread">1dp</dimen>
<dimen name="all_apps_caret_size">13dp</dimen> <dimen name="all_apps_caret_size">13dp</dimen>
<dimen name="all_apps_caret_workspace_offset">4dp</dimen> <dimen name="all_apps_caret_workspace_offset">18dp</dimen>
<!-- Search bar in All Apps --> <!-- Search bar in All Apps -->
<dimen name="all_apps_header_max_elevation">3dp</dimen> <dimen name="all_apps_header_max_elevation">3dp</dimen>

View File

@ -29,7 +29,6 @@
launcher:iconSize="48" launcher:iconSize="48"
launcher:iconTextSize="13.0" launcher:iconTextSize="13.0"
launcher:numHotseatIcons="3" launcher:numHotseatIcons="3"
launcher:hotseatIconSize="48"
launcher:defaultLayoutId="@xml/default_workspace_3x3" launcher:defaultLayoutId="@xml/default_workspace_3x3"
/> />
@ -45,7 +44,6 @@
launcher:iconSize="48" launcher:iconSize="48"
launcher:iconTextSize="13.0" launcher:iconTextSize="13.0"
launcher:numHotseatIcons="3" launcher:numHotseatIcons="3"
launcher:hotseatIconSize="48"
launcher:defaultLayoutId="@xml/default_workspace_3x3" launcher:defaultLayoutId="@xml/default_workspace_3x3"
/> />
@ -61,7 +59,6 @@
launcher:iconSize="48" launcher:iconSize="48"
launcher:iconTextSize="13.0" launcher:iconTextSize="13.0"
launcher:numHotseatIcons="5" launcher:numHotseatIcons="5"
launcher:hotseatIconSize="48"
launcher:defaultLayoutId="@xml/default_workspace_4x4" launcher:defaultLayoutId="@xml/default_workspace_4x4"
/> />
@ -77,7 +74,6 @@
launcher:iconSize="48" launcher:iconSize="48"
launcher:iconTextSize="13.0" launcher:iconTextSize="13.0"
launcher:numHotseatIcons="5" launcher:numHotseatIcons="5"
launcher:hotseatIconSize="48"
launcher:defaultLayoutId="@xml/default_workspace_4x4" launcher:defaultLayoutId="@xml/default_workspace_4x4"
/> />
@ -93,7 +89,6 @@
launcher:iconSize="48" launcher:iconSize="48"
launcher:iconTextSize="13.0" launcher:iconTextSize="13.0"
launcher:numHotseatIcons="5" launcher:numHotseatIcons="5"
launcher:hotseatIconSize="48"
launcher:defaultLayoutId="@xml/default_workspace_4x4" launcher:defaultLayoutId="@xml/default_workspace_4x4"
/> />
@ -106,10 +101,9 @@
launcher:numFolderRows="4" launcher:numFolderRows="4"
launcher:numFolderColumns="4" launcher:numFolderColumns="4"
launcher:minAllAppsPredictionColumns="4" launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="60" launcher:iconSize="54"
launcher:iconTextSize="13.0" launcher:iconTextSize="13.0"
launcher:numHotseatIcons="5" launcher:numHotseatIcons="5"
launcher:hotseatIconSize="56"
launcher:defaultLayoutId="@xml/default_workspace_4x4" launcher:defaultLayoutId="@xml/default_workspace_4x4"
/> />
@ -122,10 +116,9 @@
launcher:numFolderRows="4" launcher:numFolderRows="4"
launcher:numFolderColumns="4" launcher:numFolderColumns="4"
launcher:minAllAppsPredictionColumns="4" launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="60" launcher:iconSize="54"
launcher:iconTextSize="13.0" launcher:iconTextSize="13.0"
launcher:numHotseatIcons="5" launcher:numHotseatIcons="5"
launcher:hotseatIconSize="56"
launcher:defaultLayoutId="@xml/default_workspace_4x4" launcher:defaultLayoutId="@xml/default_workspace_4x4"
/> />
@ -138,10 +131,9 @@
launcher:numFolderRows="4" launcher:numFolderRows="4"
launcher:numFolderColumns="4" launcher:numFolderColumns="4"
launcher:minAllAppsPredictionColumns="4" launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="64" launcher:iconSize="56"
launcher:iconTextSize="14.4" launcher:iconTextSize="14.4"
launcher:numHotseatIcons="5" launcher:numHotseatIcons="5"
launcher:hotseatIconSize="56"
launcher:defaultLayoutId="@xml/default_workspace_5x5" launcher:defaultLayoutId="@xml/default_workspace_5x5"
/> />
@ -154,10 +146,9 @@
launcher:numFolderRows="4" launcher:numFolderRows="4"
launcher:numFolderColumns="5" launcher:numFolderColumns="5"
launcher:minAllAppsPredictionColumns="4" launcher:minAllAppsPredictionColumns="4"
launcher:iconSize="72" launcher:iconSize="64"
launcher:iconTextSize="14.4" launcher:iconTextSize="14.4"
launcher:numHotseatIcons="7" launcher:numHotseatIcons="7"
launcher:hotseatIconSize="60"
launcher:defaultLayoutId="@xml/default_workspace_5x6" launcher:defaultLayoutId="@xml/default_workspace_5x6"
/> />
@ -173,7 +164,6 @@
launcher:iconSize="76" launcher:iconSize="76"
launcher:iconTextSize="14.4" launcher:iconTextSize="14.4"
launcher:numHotseatIcons="7" launcher:numHotseatIcons="7"
launcher:hotseatIconSize="76"
launcher:defaultLayoutId="@xml/default_workspace_5x6" launcher:defaultLayoutId="@xml/default_workspace_5x6"
/> />
@ -189,7 +179,6 @@
launcher:iconSize="100" launcher:iconSize="100"
launcher:iconTextSize="20.0" launcher:iconTextSize="20.0"
launcher:numHotseatIcons="7" launcher:numHotseatIcons="7"
launcher:hotseatIconSize="72"
launcher:defaultLayoutId="@xml/default_workspace_5x6" launcher:defaultLayoutId="@xml/default_workspace_5x6"
/> />

View File

@ -113,20 +113,18 @@ public abstract class BaseContainerView extends FrameLayout
* Calculate the background padding as it can change due to insets/content padding change. * Calculate the background padding as it can change due to insets/content padding change.
*/ */
private void updatePaddings() { private void updatePaddings() {
Context context = getContext(); DeviceProfile grid = Launcher.getLauncher(getContext()).getDeviceProfile();
int paddingLeft;
int paddingRight;
int paddingTop;
int paddingBottom;
DeviceProfile grid = Launcher.getLauncher(context).getDeviceProfile();
int[] padding = grid.getContainerPadding(); int[] padding = grid.getContainerPadding();
paddingLeft = padding[0] + grid.edgeMarginPx;
paddingRight = padding[1] + grid.edgeMarginPx; int paddingLeft = padding[0];
int paddingRight = padding[1];
int paddingTop = 0;
int paddingBottom = 0;
if (!grid.isVerticalBarLayout()) { if (!grid.isVerticalBarLayout()) {
paddingLeft += grid.edgeMarginPx;
paddingRight += grid.edgeMarginPx;
paddingTop = paddingBottom = grid.edgeMarginPx; paddingTop = paddingBottom = grid.edgeMarginPx;
} else {
paddingTop = paddingBottom = 0;
} }
updateBackground(paddingLeft, paddingTop, paddingRight, paddingBottom); updateBackground(paddingLeft, paddingTop, paddingRight, paddingBottom);
} }

View File

@ -154,7 +154,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
@ContainerType private final int mContainerType; @ContainerType private final int mContainerType;
private final float mChildScale; private final float mChildScale = 1f;
public static final int MODE_SHOW_REORDER_HINT = 0; public static final int MODE_SHOW_REORDER_HINT = 0;
public static final int MODE_DRAG_OVER = 1; public static final int MODE_DRAG_OVER = 1;
@ -218,8 +218,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
mFolderLeaveBehind.delegateCellX = -1; mFolderLeaveBehind.delegateCellX = -1;
mFolderLeaveBehind.delegateCellY = -1; mFolderLeaveBehind.delegateCellY = -1;
mChildScale = mContainerType == HOTSEAT ? grid.inv.hotseatScale : 1f;
setAlwaysDrawnWithCacheEnabled(false); setAlwaysDrawnWithCacheEnabled(false);
final Resources res = getResources(); final Resources res = getResources();

View File

@ -19,6 +19,7 @@ package com.android.launcher3;
import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetHostView;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.PointF; import android.graphics.PointF;
@ -32,7 +33,6 @@ import android.widget.FrameLayout;
import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.badge.BadgeRenderer; import com.android.launcher3.badge.BadgeRenderer;
import com.android.launcher3.config.FeatureFlags;
import java.util.ArrayList; import java.util.ArrayList;
@ -80,9 +80,8 @@ public class DeviceProfile {
public final int workspaceSpringLoadedBottomSpace; public final int workspaceSpringLoadedBottomSpace;
// Page indicator // Page indicator
private final int pageIndicatorHeightPx; private final int pageIndicatorSizePx;
private final int pageIndicatorLandGutterLeftNavBarPx; private final int pageIndicatorLandGutterPx;
private final int pageIndicatorLandGutterRightNavBarPx;
private final int pageIndicatorLandWorkspaceOffsetPx; private final int pageIndicatorLandWorkspaceOffsetPx;
// Workspace icons // Workspace icons
@ -93,7 +92,7 @@ public class DeviceProfile {
public int cellWidthPx; public int cellWidthPx;
public int cellHeightPx; public int cellHeightPx;
public int cellPaddingXPx; public int workspaceCellPaddingXPx;
// Folder // Folder
public int folderBackgroundOffset; public int folderBackgroundOffset;
@ -110,15 +109,17 @@ public class DeviceProfile {
public int folderChildDrawablePaddingPx; public int folderChildDrawablePaddingPx;
// Hotseat // Hotseat
public int hotseatCellWidthPx;
public int hotseatCellHeightPx; public int hotseatCellHeightPx;
public int hotseatIconSizePx;
public int hotseatBarHeightPx; public int hotseatBarHeightPx;
public int hotseatBarTopPaddingPx; public int hotseatBarTopPaddingPx;
public int hotseatBarLeftNavBarRightPaddingPx;
public int hotseatBarRightNavBarRightPaddingPx;
public int hotseatBarBottomPaddingPx; public int hotseatBarBottomPaddingPx;
public int hotseatLandGutterPx; public int hotseatLandLeftNavBarGutterPx;
public int hotseatLandRightNavBarGutterPx;
// All apps // All apps
public int allAppsCellHeightPx;
public int allAppsNumCols; public int allAppsNumCols;
public int allAppsNumPredictiveCols; public int allAppsNumPredictiveCols;
public int allAppsButtonVisualSize; public int allAppsButtonVisualSize;
@ -160,19 +161,22 @@ public class DeviceProfile {
transposeLayoutWithOrientation = transposeLayoutWithOrientation =
res.getBoolean(R.bool.hotseat_transpose_layout_with_orientation); res.getBoolean(R.bool.hotseat_transpose_layout_with_orientation);
context = getContext(context, isVerticalBarLayout()
? Configuration.ORIENTATION_LANDSCAPE
: Configuration.ORIENTATION_PORTRAIT);
res = context.getResources();
ComponentName cn = new ComponentName(context.getPackageName(), ComponentName cn = new ComponentName(context.getPackageName(),
this.getClass().getName()); this.getClass().getName());
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null); defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
desiredWorkspaceLeftRightMarginPx = edgeMarginPx; desiredWorkspaceLeftRightMarginPx = edgeMarginPx;
pageIndicatorHeightPx = pageIndicatorSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_size);
res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_height); pageIndicatorLandGutterPx = res.getDimensionPixelSize(
pageIndicatorLandGutterLeftNavBarPx = res.getDimensionPixelSize( R.dimen.dynamic_grid_page_indicator_gutter_width);
R.dimen.dynamic_grid_page_indicator_gutter_width_left_nav_bar);
pageIndicatorLandWorkspaceOffsetPx = pageIndicatorLandWorkspaceOffsetPx =
res.getDimensionPixelSize(R.dimen.all_apps_caret_workspace_offset); res.getDimensionPixelSize(R.dimen.all_apps_caret_workspace_offset);
pageIndicatorLandGutterRightNavBarPx = res.getDimensionPixelSize(
R.dimen.dynamic_grid_page_indicator_gutter_width_right_nav_bar);
defaultPageSpacingPx = defaultPageSpacingPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_workspace_page_spacing); res.getDimensionPixelSize(R.dimen.dynamic_grid_workspace_page_spacing);
topWorkspacePadding = topWorkspacePadding =
@ -182,8 +186,7 @@ public class DeviceProfile {
overviewModeMaxIconZoneHeightPx = overviewModeMaxIconZoneHeightPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_max_icon_zone_height); res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_max_icon_zone_height);
overviewModeBarItemWidthPx = overviewModeBarItemWidthPx =
(int) (res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_bar_item_width) res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_bar_item_width);
* (isLandscape ? 1.5f : 1f));
overviewModeBarSpacerWidthPx = overviewModeBarSpacerWidthPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_bar_spacer_width); res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_bar_spacer_width);
overviewModeIconZoneRatio = overviewModeIconZoneRatio =
@ -194,15 +197,25 @@ public class DeviceProfile {
workspaceSpringLoadedBottomSpace = workspaceSpringLoadedBottomSpace =
res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space); res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);
cellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x); workspaceCellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x);
hotseatBarTopPaddingPx = hotseatBarTopPaddingPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding); res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
hotseatBarBottomPaddingPx = hotseatBarBottomPaddingPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding); res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
hotseatBarHeightPx = hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx + hotseatBarLeftNavBarRightPaddingPx = res.getDimensionPixelSize(
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_height); R.dimen.dynamic_grid_hotseat_land_left_nav_bar_right_padding);
hotseatLandGutterPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_land_gutter_width); hotseatBarRightNavBarRightPaddingPx = res.getDimensionPixelSize(
R.dimen.dynamic_grid_hotseat_land_right_nav_bar_right_padding);
hotseatBarHeightPx = isVerticalBarLayout()
? res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_height)
: res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_height)
+ hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx;
hotseatLandLeftNavBarGutterPx = res.getDimensionPixelSize(
R.dimen.dynamic_grid_hotseat_land_left_nav_bar_gutter_width);
hotseatLandRightNavBarGutterPx = res.getDimensionPixelSize(
R.dimen.dynamic_grid_hotseat_land_right_nav_bar_gutter_width);
// Determine sizes. // Determine sizes.
widthPx = width; widthPx = width;
@ -263,7 +276,7 @@ public class DeviceProfile {
private void computeAllAppsButtonSize(Context context) { private void computeAllAppsButtonSize(Context context) {
Resources res = context.getResources(); Resources res = context.getResources();
float padding = res.getInteger(R.integer.config_allAppsButtonPaddingPercent) / 100f; float padding = res.getInteger(R.integer.config_allAppsButtonPaddingPercent) / 100f;
allAppsButtonVisualSize = (int) (hotseatIconSizePx * (1 - padding)) - context.getResources() allAppsButtonVisualSize = (int) (iconSizePx * (1 - padding)) - context.getResources()
.getDimensionPixelSize(R.dimen.all_apps_button_scale_down); .getDimensionPixelSize(R.dimen.all_apps_button_scale_down);
} }
@ -281,25 +294,33 @@ public class DeviceProfile {
} }
private void updateIconSize(float scale, Resources res, DisplayMetrics dm) { private void updateIconSize(float scale, Resources res, DisplayMetrics dm) {
iconSizePx = (int) (Utilities.pxFromDp(inv.iconSize, dm) * scale); float invIconSizePx = isVerticalBarLayout() ? inv.landscapeIconSize : inv.iconSize;
iconSizePx = (int) (Utilities.pxFromDp(invIconSizePx, dm) * scale);
iconTextSizePx = (int) (Utilities.pxFromSp(inv.iconTextSize, dm) * scale); iconTextSizePx = (int) (Utilities.pxFromSp(inv.iconTextSize, dm) * scale);
iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * scale); iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * scale);
hotseatIconSizePx = (int) (Utilities.pxFromDp(inv.hotseatIconSize, dm) * scale);
// All apps
allAppsIconTextSizePx = iconTextSizePx;
allAppsIconSizePx = iconSizePx; allAppsIconSizePx = iconSizePx;
allAppsIconDrawablePaddingPx = iconDrawablePaddingPx; allAppsIconDrawablePaddingPx = iconDrawablePaddingPx;
allAppsIconTextSizePx = iconTextSizePx; allAppsCellHeightPx = getCellSize().y;
if (isVerticalBarLayout()) {
// Always hide the Workspace text with vertical bar layout.
iconTextSizePx = 0;
allAppsCellHeightPx += Utilities.calculateTextHeight(allAppsIconTextSizePx);
}
cellWidthPx = iconSizePx + iconDrawablePaddingPx; cellWidthPx = iconSizePx + iconDrawablePaddingPx;
cellHeightPx = iconSizePx + iconDrawablePaddingPx cellHeightPx = iconSizePx + iconDrawablePaddingPx
+ Utilities.calculateTextHeight(iconTextSizePx); + Utilities.calculateTextHeight(iconTextSizePx);
// Hotseat // Hotseat
hotseatCellWidthPx = cellWidthPx;
hotseatCellHeightPx = iconSizePx + iconDrawablePaddingPx; hotseatCellHeightPx = iconSizePx + iconDrawablePaddingPx;
if (!isVerticalBarLayout()) { if (!isVerticalBarLayout()) {
int expectedWorkspaceHeight = availableHeightPx - hotseatBarHeightPx int expectedWorkspaceHeight = availableHeightPx - hotseatBarHeightPx
- pageIndicatorHeightPx - topWorkspacePadding; - pageIndicatorSizePx - topWorkspacePadding;
float minRequiredHeight = dropTargetBarSizePx + workspaceSpringLoadedBottomSpace; float minRequiredHeight = dropTargetBarSizePx + workspaceSpringLoadedBottomSpace;
workspaceSpringLoadShrinkFactor = Math.min( workspaceSpringLoadShrinkFactor = Math.min(
res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f, res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f,
@ -403,22 +424,25 @@ public class DeviceProfile {
/** /**
* Returns the workspace padding in the specified orientation. * Returns the workspace padding in the specified orientation.
* Note that it assumes that while in verticalBarLayout, the nav bar is on the right, as such
* this value is not reliable.
* Use {@link #getTotalWorkspacePadding()} instead.
*/ */
public Rect getWorkspacePadding(Rect recycle) { public Rect getWorkspacePadding(Rect recycle) {
Rect padding = recycle == null ? new Rect() : recycle; Rect padding = recycle == null ? new Rect() : recycle;
if (isVerticalBarLayout()) { if (isVerticalBarLayout()) {
if (mInsets.left > 0) { if (mInsets.left > 0) {
padding.set(mInsets.left + pageIndicatorLandGutterLeftNavBarPx, 0, padding.set(mInsets.left + pageIndicatorLandGutterPx,
hotseatBarHeightPx + hotseatLandGutterPx - mInsets.left, 2 * edgeMarginPx); 0,
hotseatBarHeightPx + hotseatLandLeftNavBarGutterPx
+ hotseatBarLeftNavBarRightPaddingPx - mInsets.left,
edgeMarginPx);
} else { } else {
padding.set(pageIndicatorLandGutterRightNavBarPx, 0, padding.set(pageIndicatorLandGutterPx,
hotseatBarHeightPx + hotseatLandGutterPx, 2 * edgeMarginPx); 0,
hotseatBarHeightPx + hotseatLandRightNavBarGutterPx
+ hotseatBarRightNavBarRightPaddingPx,
edgeMarginPx);
} }
} else { } else {
int paddingBottom = hotseatBarHeightPx + pageIndicatorHeightPx; int paddingBottom = hotseatBarHeightPx + pageIndicatorSizePx;
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
@ -460,7 +484,7 @@ public class DeviceProfile {
return new Rect(mInsets.left, return new Rect(mInsets.left,
mInsets.top + dropTargetBarSizePx + edgeMarginPx, mInsets.top + dropTargetBarSizePx + edgeMarginPx,
mInsets.left + availableWidthPx, mInsets.left + availableWidthPx,
mInsets.top + availableHeightPx - hotseatBarHeightPx - pageIndicatorHeightPx - mInsets.top + availableHeightPx - hotseatBarHeightPx - pageIndicatorSizePx -
edgeMarginPx); edgeMarginPx);
} }
} }
@ -550,7 +574,12 @@ public class DeviceProfile {
lp.gravity = Gravity.RIGHT; lp.gravity = Gravity.RIGHT;
lp.width = hotseatBarHeightPx + mInsets.left + mInsets.right; lp.width = hotseatBarHeightPx + mInsets.left + mInsets.right;
lp.height = LayoutParams.MATCH_PARENT; lp.height = LayoutParams.MATCH_PARENT;
hotseat.getLayout().setPadding(mInsets.left, mInsets.top, mInsets.right,
int paddingRight = mInsets.left > 0
? hotseatBarLeftNavBarRightPaddingPx
: hotseatBarRightNavBarRightPaddingPx;
hotseat.getLayout().setPadding(mInsets.left, mInsets.top, mInsets.right + paddingRight,
workspacePadding.bottom); workspacePadding.bottom);
} else if (isTablet) { } else if (isTablet) {
// Pad the hotseat with the workspace padding calculated above // Pad the hotseat with the workspace padding calculated above
@ -578,17 +607,15 @@ public class DeviceProfile {
lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams(); lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams();
if (isVerticalBarLayout()) { if (isVerticalBarLayout()) {
if (mInsets.left > 0) { if (mInsets.left > 0) {
lp.leftMargin = mInsets.left + pageIndicatorLandGutterLeftNavBarPx - lp.leftMargin = mInsets.left;
lp.width - pageIndicatorLandWorkspaceOffsetPx; } else {
} else if (mInsets.right > 0) { lp.leftMargin = pageIndicatorLandWorkspaceOffsetPx;
lp.leftMargin = pageIndicatorLandGutterRightNavBarPx - lp.width -
pageIndicatorLandWorkspaceOffsetPx;
} }
lp.bottomMargin = workspacePadding.bottom; lp.bottomMargin = workspacePadding.bottom;
} else { } else {
// Put the page indicators above the hotseat // Put the page indicators above the hotseat
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
lp.height = pageIndicatorHeightPx; lp.height = pageIndicatorSizePx;
lp.bottomMargin = hotseatBarHeightPx + mInsets.bottom; lp.bottomMargin = hotseatBarHeightPx + mInsets.bottom;
} }
pageIndicator.setLayoutParams(lp); pageIndicator.setLayoutParams(lp);
@ -607,6 +634,12 @@ public class DeviceProfile {
overviewMode.setLayoutParams(lp); overviewMode.setLayoutParams(lp);
} }
// Layout the AllAppsRecyclerView
View view = launcher.findViewById(R.id.apps_list_view);
int paddingLeftRight = hasVerticalBarLayout ? 0 : edgeMarginPx;
view.setPadding(paddingLeftRight, view.getPaddingTop(), paddingLeftRight,
view.getPaddingBottom());
if (notifyListeners) { if (notifyListeners) {
for (int i = mListeners.size() - 1; i >= 0; i--) { for (int i = mListeners.size() - 1; i >= 0; i--) {
mListeners.get(i).onLauncherLayoutChanged(); mListeners.get(i).onLauncherLayoutChanged();
@ -650,9 +683,8 @@ public class DeviceProfile {
} }
// In landscape, we match the width of the workspace // In landscape, we match the width of the workspace
int padding = (pageIndicatorLandGutterRightNavBarPx + Rect padding = getWorkspacePadding(null);
hotseatBarHeightPx + hotseatLandGutterPx + mInsets.left) / 2; return new int[] { padding.left - mInsets.left, padding.right + mInsets.left};
return new int[]{ padding, padding };
} }
public boolean shouldIgnoreLongPressToOverview(float touchX) { public boolean shouldIgnoreLongPressToOverview(float touchX) {
@ -661,4 +693,11 @@ public class DeviceProfile {
boolean touchedRhsEdge = mInsets.right == 0 && touchX > (widthPx - edgeMarginPx); boolean touchedRhsEdge = mInsets.right == 0 && touchX > (widthPx - edgeMarginPx);
return !inMultiWindowMode && (touchedLhsEdge || touchedRhsEdge); return !inMultiWindowMode && (touchedLhsEdge || touchedRhsEdge);
} }
private static Context getContext(Context c, int orientation) {
Configuration context = new Configuration(c.getResources().getConfiguration());
context.orientation = orientation;
return c.createConfigurationContext(context);
}
} }

View File

@ -753,7 +753,7 @@ public class IconCache {
} }
private static final class IconDB extends SQLiteCacheHelper { private static final class IconDB extends SQLiteCacheHelper {
private final static int DB_VERSION = 15; private final static int DB_VERSION = 16;
private final static int RELEASE_VERSION = DB_VERSION + private final static int RELEASE_VERSION = DB_VERSION +
(FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION ? 0 : 1); (FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION ? 0 : 1);

View File

@ -76,6 +76,7 @@ public class InvariantDeviceProfile {
public int numFolderRows; public int numFolderRows;
public int numFolderColumns; public int numFolderColumns;
public float iconSize; public float iconSize;
public float landscapeIconSize;
public int iconBitmapSize; public int iconBitmapSize;
public int fillResIconDpi; public int fillResIconDpi;
public float iconTextSize; public float iconTextSize;
@ -84,8 +85,6 @@ public class InvariantDeviceProfile {
* Number of icons inside the hotseat area. * Number of icons inside the hotseat area.
*/ */
public int numHotseatIcons; public int numHotseatIcons;
float hotseatIconSize;
public float hotseatScale;
int defaultLayoutId; int defaultLayoutId;
public DeviceProfile landscapeProfile; public DeviceProfile landscapeProfile;
@ -99,12 +98,12 @@ public class InvariantDeviceProfile {
public InvariantDeviceProfile(InvariantDeviceProfile p) { public InvariantDeviceProfile(InvariantDeviceProfile p) {
this(p.name, p.minWidthDps, p.minHeightDps, p.numRows, p.numColumns, this(p.name, p.minWidthDps, p.minHeightDps, p.numRows, p.numColumns,
p.numFolderRows, p.numFolderColumns, p.minAllAppsPredictionColumns, p.numFolderRows, p.numFolderColumns, p.minAllAppsPredictionColumns,
p.iconSize, p.iconTextSize, p.numHotseatIcons, p.hotseatIconSize, p.iconSize, p.landscapeIconSize, p.iconTextSize, p.numHotseatIcons,
p.defaultLayoutId); p.defaultLayoutId);
} }
InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, int maapc, InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, int maapc,
float is, float its, int hs, float his, int dlId) { float is, float lis, float its, int hs, int dlId) {
name = n; name = n;
minWidthDps = w; minWidthDps = w;
minHeightDps = h; minHeightDps = h;
@ -114,12 +113,10 @@ public class InvariantDeviceProfile {
numFolderColumns = fc; numFolderColumns = fc;
minAllAppsPredictionColumns = maapc; minAllAppsPredictionColumns = maapc;
iconSize = is; iconSize = is;
landscapeIconSize = lis;
iconTextSize = its; iconTextSize = its;
numHotseatIcons = hs; numHotseatIcons = hs;
hotseatIconSize = his;
defaultLayoutId = dlId; defaultLayoutId = dlId;
hotseatScale = hotseatIconSize / iconSize;
} }
@TargetApi(23) @TargetApi(23)
@ -152,17 +149,15 @@ public class InvariantDeviceProfile {
minAllAppsPredictionColumns = closestProfile.minAllAppsPredictionColumns; minAllAppsPredictionColumns = closestProfile.minAllAppsPredictionColumns;
iconSize = interpolatedDeviceProfileOut.iconSize; iconSize = interpolatedDeviceProfileOut.iconSize;
landscapeIconSize = interpolatedDeviceProfileOut.landscapeIconSize;
iconBitmapSize = Utilities.pxFromDp(iconSize, dm); iconBitmapSize = Utilities.pxFromDp(iconSize, dm);
iconTextSize = interpolatedDeviceProfileOut.iconTextSize; iconTextSize = interpolatedDeviceProfileOut.iconTextSize;
hotseatIconSize = interpolatedDeviceProfileOut.hotseatIconSize;
fillResIconDpi = getLauncherIconDensity(iconBitmapSize); fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
// If the partner customization apk contains any grid overrides, apply them // If the partner customization apk contains any grid overrides, apply them
// Supported overrides: numRows, numColumns, iconSize // Supported overrides: numRows, numColumns, iconSize
applyPartnerDeviceProfileOverrides(context, dm); applyPartnerDeviceProfileOverrides(context, dm);
hotseatScale = hotseatIconSize / iconSize;
Point realSize = new Point(); Point realSize = new Point();
display.getRealSize(realSize); display.getRealSize(realSize);
// The real size never changes. smallSide and largeSide will remain the // The real size never changes. smallSide and largeSide will remain the
@ -210,9 +205,9 @@ public class InvariantDeviceProfile {
a.getInt(R.styleable.InvariantDeviceProfile_numFolderColumns, numColumns), a.getInt(R.styleable.InvariantDeviceProfile_numFolderColumns, numColumns),
a.getInt(R.styleable.InvariantDeviceProfile_minAllAppsPredictionColumns, numColumns), a.getInt(R.styleable.InvariantDeviceProfile_minAllAppsPredictionColumns, numColumns),
iconSize, iconSize,
a.getFloat(R.styleable.InvariantDeviceProfile_landscapeIconSize, iconSize),
a.getFloat(R.styleable.InvariantDeviceProfile_iconTextSize, 0), a.getFloat(R.styleable.InvariantDeviceProfile_iconTextSize, 0),
a.getInt(R.styleable.InvariantDeviceProfile_numHotseatIcons, numColumns), a.getInt(R.styleable.InvariantDeviceProfile_numHotseatIcons, numColumns),
a.getFloat(R.styleable.InvariantDeviceProfile_hotseatIconSize, iconSize),
a.getResourceId(R.styleable.InvariantDeviceProfile_defaultLayoutId, 0))); a.getResourceId(R.styleable.InvariantDeviceProfile_defaultLayoutId, 0)));
a.recycle(); a.recycle();
} }
@ -304,14 +299,14 @@ public class InvariantDeviceProfile {
private void add(InvariantDeviceProfile p) { private void add(InvariantDeviceProfile p) {
iconSize += p.iconSize; iconSize += p.iconSize;
landscapeIconSize += p.landscapeIconSize;
iconTextSize += p.iconTextSize; iconTextSize += p.iconTextSize;
hotseatIconSize += p.hotseatIconSize;
} }
private InvariantDeviceProfile multiply(float w) { private InvariantDeviceProfile multiply(float w) {
iconSize *= w; iconSize *= w;
landscapeIconSize *= w;
iconTextSize *= w; iconTextSize *= w;
hotseatIconSize *= w;
return this; return this;
} }

View File

@ -120,7 +120,9 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
// Center the icon/folder // Center the icon/folder
int cHeight = getCellContentHeight(); int cHeight = getCellContentHeight();
int cellPaddingY = (int) Math.max(0, ((lp.height - cHeight) / 2f)); int cellPaddingY = (int) Math.max(0, ((lp.height - cHeight) / 2f));
int cellPaddingX = profile.cellPaddingXPx; int cellPaddingX = mContainerType == CellLayout.WORKSPACE
? profile.workspaceCellPaddingXPx
: (int) (profile.edgeMarginPx / 2f);
child.setPadding(cellPaddingX, cellPaddingY, cellPaddingX, 0); child.setPadding(cellPaddingX, cellPaddingY, cellPaddingX, 0);
} }
} else { } else {

View File

@ -111,7 +111,7 @@ public class WidgetPreviewLoader {
* sizes (landscape vs portrait). * sizes (landscape vs portrait).
*/ */
private static class CacheDb extends SQLiteCacheHelper { private static class CacheDb extends SQLiteCacheHelper {
private static final int DB_VERSION = 7; private static final int DB_VERSION = 8;
private static final String TABLE_NAME = "shortcut_and_widget_previews"; private static final String TABLE_NAME = "shortcut_and_widget_previews";
private static final String COLUMN_COMPONENT = "componentName"; private static final String COLUMN_COMPONENT = "componentName";

View File

@ -18,7 +18,6 @@ package com.android.launcher3.allapps;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Point;
import android.support.animation.DynamicAnimation; import android.support.animation.DynamicAnimation;
import android.support.animation.SpringAnimation; import android.support.animation.SpringAnimation;
import android.support.v4.view.accessibility.AccessibilityEventCompat; import android.support.v4.view.accessibility.AccessibilityEventCompat;
@ -298,8 +297,8 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
icon.setLongPressTimeout(ViewConfiguration.getLongPressTimeout()); icon.setLongPressTimeout(ViewConfiguration.getLongPressTimeout());
icon.setOnFocusChangeListener(mIconFocusListener); icon.setOnFocusChangeListener(mIconFocusListener);
// Ensure the all apps icon height matches the workspace icons // Ensure the all apps icon height matches the workspace icons in portrait mode.
icon.getLayoutParams().height = getCellSize().y; icon.getLayoutParams().height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
return new ViewHolder(icon); return new ViewHolder(icon);
case VIEW_TYPE_DISCOVERY_ITEM: case VIEW_TYPE_DISCOVERY_ITEM:
AppDiscoveryItemView appDiscoveryItemView = (AppDiscoveryItemView) mLayoutInflater AppDiscoveryItemView appDiscoveryItemView = (AppDiscoveryItemView) mLayoutInflater
@ -336,10 +335,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
} }
} }
private Point getCellSize() {
return mLauncher.getDeviceProfile().getCellSize();
}
@Override @Override
public void onBindViewHolder(ViewHolder holder, int position) { public void onBindViewHolder(ViewHolder holder, int position) {
switch (holder.getItemViewType()) { switch (holder.getItemViewType()) {