From a81e8d855ac697b95941c31c571780bafe71461e Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Fri, 22 Sep 2017 17:10:55 -0700 Subject: Demo mode default layout support b/67062454 Change-Id: Ic060d3d7dba4fffe688dddf7cd04c48e4baaf813 --- res/values/attrs.xml | 1 + src/com/android/launcher3/InvariantDeviceProfile.java | 11 ++++++++--- src/com/android/launcher3/LauncherProvider.java | 9 ++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 68b628fb7..5aee715b6 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -123,6 +123,7 @@ + diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index d7bebd1b1..7a431986d 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -85,7 +85,9 @@ public class InvariantDeviceProfile { * Number of icons inside the hotseat area. */ public int numHotseatIcons; + int defaultLayoutId; + int demoModeLayoutId; public DeviceProfile landscapeProfile; public DeviceProfile portraitProfile; @@ -99,11 +101,11 @@ public class InvariantDeviceProfile { this(p.name, p.minWidthDps, p.minHeightDps, p.numRows, p.numColumns, p.numFolderRows, p.numFolderColumns, p.minAllAppsPredictionColumns, p.iconSize, p.landscapeIconSize, p.iconTextSize, p.numHotseatIcons, - p.defaultLayoutId); + p.defaultLayoutId, p.demoModeLayoutId); } InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, int maapc, - float is, float lis, float its, int hs, int dlId) { + float is, float lis, float its, int hs, int dlId, int dmlId) { name = n; minWidthDps = w; minHeightDps = h; @@ -117,6 +119,7 @@ public class InvariantDeviceProfile { iconTextSize = its; numHotseatIcons = hs; defaultLayoutId = dlId; + demoModeLayoutId = dmlId; } @TargetApi(23) @@ -144,6 +147,7 @@ public class InvariantDeviceProfile { numColumns = closestProfile.numColumns; numHotseatIcons = closestProfile.numHotseatIcons; defaultLayoutId = closestProfile.defaultLayoutId; + demoModeLayoutId = closestProfile.demoModeLayoutId; numFolderRows = closestProfile.numFolderRows; numFolderColumns = closestProfile.numFolderColumns; minAllAppsPredictionColumns = closestProfile.minAllAppsPredictionColumns; @@ -208,7 +212,8 @@ public class InvariantDeviceProfile { a.getFloat(R.styleable.InvariantDeviceProfile_landscapeIconSize, iconSize), a.getFloat(R.styleable.InvariantDeviceProfile_iconTextSize, 0), a.getInt(R.styleable.InvariantDeviceProfile_numHotseatIcons, numColumns), - a.getResourceId(R.styleable.InvariantDeviceProfile_defaultLayoutId, 0))); + a.getResourceId(R.styleable.InvariantDeviceProfile_defaultLayoutId, 0), + a.getResourceId(R.styleable.InvariantDeviceProfile_demoModeLayoutId, 0))); a.recycle(); } } diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java index dc83f36ad..b31df9894 100644 --- a/src/com/android/launcher3/LauncherProvider.java +++ b/src/com/android/launcher3/LauncherProvider.java @@ -552,7 +552,14 @@ public class LauncherProvider extends ContentProvider { } private DefaultLayoutParser getDefaultLayoutParser(AppWidgetHost widgetHost) { - int defaultLayout = LauncherAppState.getIDP(getContext()).defaultLayoutId; + InvariantDeviceProfile idp = LauncherAppState.getIDP(getContext()); + int defaultLayout = idp.defaultLayoutId; + + UserManagerCompat um = UserManagerCompat.getInstance(getContext()); + if (um.isDemoUser() && idp.demoModeLayoutId != 0) { + defaultLayout = idp.demoModeLayoutId; + } + return new DefaultLayoutParser(getContext(), widgetHost, mOpenHelper, getContext().getResources(), defaultLayout); } -- cgit v1.2.3 From 3993348043a950c7decc5c151b8e8165750f0f3c Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Fri, 29 Sep 2017 16:43:51 -0700 Subject: Remove discovery bounce for demo users Bug 67116550 Change-Id: I8a27685f91e201072c0669c102077affe550fab6 --- src/com/android/launcher3/Launcher.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 522e96a12..32af05900 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -91,6 +91,7 @@ import com.android.launcher3.anim.AnimationLayerSet; import com.android.launcher3.compat.AppWidgetManagerCompat; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.compat.LauncherAppsCompatVO; +import com.android.launcher3.compat.UserManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragLayer; @@ -137,6 +138,7 @@ import com.android.launcher3.widget.WidgetAddFlowHandler; import com.android.launcher3.widget.WidgetHostViewLoader; import com.android.launcher3.widget.WidgetsContainerView; + import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; @@ -3893,7 +3895,8 @@ public class Launcher extends BaseActivity } private boolean shouldShowDiscoveryBounce() { - return mState == State.WORKSPACE && !mSharedPrefs.getBoolean(APPS_VIEW_SHOWN, false); + UserManagerCompat um = UserManagerCompat.getInstance(this); + return mState == State.WORKSPACE && !mSharedPrefs.getBoolean(APPS_VIEW_SHOWN, false) && !um.isDemoUser(); } protected void moveWorkspaceToDefaultScreen() { -- cgit v1.2.3 From 846455e1ffdca9bac72b96ba61d2e42cd45cf4ce Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Mon, 2 Oct 2017 14:58:52 -0700 Subject: Larger icons for L3Go and spacing changes. There are cases (ie. smaller devices) where the icon label is closer to the icon below it (rather than its corresponding icon). To fix this, we ensure that the drawable padding (space between the icon and its label) is no larger than the vertical padding of the cell. Bug: 67317867 Change-Id: Ic3729726eebb60b67d658361c4335e724b7d68d7 --- go/res/values/dimens.xml | 20 ++++++++++++++++++++ go/res/xml/device_profiles.xml | 2 +- src/com/android/launcher3/DeviceProfile.java | 18 +++++++++++++++--- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 go/res/values/dimens.xml diff --git a/go/res/values/dimens.xml b/go/res/values/dimens.xml new file mode 100644 index 000000000..f1b105316 --- /dev/null +++ b/go/res/values/dimens.xml @@ -0,0 +1,20 @@ + + + + + + 60dp + \ No newline at end of file diff --git a/go/res/xml/device_profiles.xml b/go/res/xml/device_profiles.xml index 094fc745c..487c026d6 100644 --- a/go/res/xml/device_profiles.xml +++ b/go/res/xml/device_profiles.xml @@ -25,7 +25,7 @@ launcher:numColumns="4" launcher:numFolderRows="4" launcher:numFolderColumns="4" - launcher:iconSize="56" + launcher:iconSize="60" launcher:iconTextSize="14.0" launcher:defaultLayoutId="@xml/default_workspace_4x4" /> diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index dec0a92a9..69ee03e9e 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -350,9 +350,18 @@ public class DeviceProfile { iconTextSizePx = (int) (Utilities.pxFromSp(inv.iconTextSize, dm) * scale); iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * scale); - cellWidthPx = iconSizePx + iconDrawablePaddingPx; cellHeightPx = iconSizePx + iconDrawablePaddingPx + Utilities.calculateTextHeight(iconTextSizePx); + int cellYPadding = (getCellSize().y - cellHeightPx) / 2; + if (iconDrawablePaddingPx > cellYPadding && !isVerticalBarLayout() + && !inMultiWindowMode()) { + // Ensures that the label is closer to its corresponding icon. This is not an issue + // with vertical bar layout or multi-window mode since the issue is handled separately + // with their calls to {@link #adjustToHideWorkspaceLabels}. + cellHeightPx -= (iconDrawablePaddingPx - cellYPadding); + iconDrawablePaddingPx = cellYPadding; + } + cellWidthPx = iconSizePx + iconDrawablePaddingPx; // All apps allAppsIconTextSizePx = iconTextSizePx; @@ -755,11 +764,14 @@ public class DeviceProfile { return new int[] { padding.left - mInsets.left, padding.right + mInsets.left}; } + public boolean inMultiWindowMode() { + return this != inv.landscapeProfile && this != inv.portraitProfile; + } + public boolean shouldIgnoreLongPressToOverview(float touchX) { - boolean inMultiWindowMode = this != inv.landscapeProfile && this != inv.portraitProfile; boolean touchedLhsEdge = mInsets.left == 0 && touchX < 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) { -- cgit v1.2.3