diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-10-09 19:06:53 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-10-09 19:06:53 +0000 |
commit | 5c641f5f5eebc28aa8233830cbcd1255252556fe (patch) | |
tree | 17cc5038139a086ab7126d2b2220f834ff07c26d | |
parent | 155289e6627564b57ac6cfc368d17ba6e422e62a (diff) | |
parent | 31bc3da013475316f7d0c6ac3bcdb5df013b12fe (diff) | |
download | Launcher3-5c641f5f5eebc28aa8233830cbcd1255252556fe.tar.gz |
Snap for 4384531 from 31bc3da013475316f7d0c6ac3bcdb5df013b12fe to oc-m2-release
Change-Id: Icf87b0a4fdb3aed0c92284cb8c1a77a33d988775
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | go/res/values/dimens.xml | 20 | ||||
-rw-r--r-- | go/res/xml/device_profiles.xml | 2 | ||||
-rw-r--r-- | res/layout/search_container_all_apps.xml | 5 | ||||
-rw-r--r-- | res/values/attrs.xml | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/AppInfo.java | 15 | ||||
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 18 | ||||
-rw-r--r-- | src/com/android/launcher3/InvariantDeviceProfile.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherAppWidgetHostView.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherProvider.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher3/PendingAppWidgetHostView.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/UninstallDropTarget.java | 18 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/logging/LoggerUtils.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/qsb/QsbContainerView.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/qsb/QsbWidgetHostView.java | 4 |
17 files changed, 114 insertions, 26 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 7d65bdc0ed..23bddf62f4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -70,7 +70,7 @@ android:launchMode="singleTask" android:clearTaskOnLaunch="true" android:stateNotNeeded="true" - android:windowSoftInputMode="adjustPan|stateUnchanged" + android:windowSoftInputMode="adjustPan" android:screenOrientation="nosensor" android:configChanges="keyboard|keyboardHidden|navigation" android:resizeableActivity="true" diff --git a/go/res/values/dimens.xml b/go/res/values/dimens.xml new file mode 100644 index 0000000000..f1b1053160 --- /dev/null +++ b/go/res/values/dimens.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2017 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <!-- Dynamic Grid --> + <dimen name="dynamic_grid_hotseat_size">60dp</dimen> +</resources>
\ No newline at end of file diff --git a/go/res/xml/device_profiles.xml b/go/res/xml/device_profiles.xml index 094fc745c4..487c026d6d 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/res/layout/search_container_all_apps.xml b/res/layout/search_container_all_apps.xml index c4305214d5..fc07002cb5 100644 --- a/res/layout/search_container_all_apps.xml +++ b/res/layout/search_container_all_apps.xml @@ -19,11 +19,11 @@ android:layout_width="match_parent" android:layout_height="@dimen/all_apps_search_bar_height" android:layout_gravity="center|top" + android:layout_marginBottom="-8dp" android:gravity="center|bottom" - android:saveEnabled="false" android:paddingLeft="@dimen/dynamic_grid_edge_margin" android:paddingRight="@dimen/dynamic_grid_edge_margin" - android:layout_marginBottom="-8dp" > + android:saveEnabled="false" > <!-- Note: The following relation should always be true so that the shadows are aligned properly @@ -45,6 +45,7 @@ android:imeOptions="actionSearch|flagNoExtractUi" android:inputType="text|textNoSuggestions|textCapWords" android:maxLines="1" + android:saveEnabled="false" android:scrollHorizontally="true" android:singleLine="true" android:textColor="?android:attr/textColorSecondary" diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 68b628fb79..5aee715b67 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -123,6 +123,7 @@ <attr name="iconTextSize" format="float" /> <attr name="defaultLayoutId" format="reference" /> + <attr name="demoModeLayoutId" format="reference" /> </declare-styleable> <declare-styleable name="CellLayout"> diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java index 3da199635e..7d2f753852 100644 --- a/src/com/android/launcher3/AppInfo.java +++ b/src/com/android/launcher3/AppInfo.java @@ -19,6 +19,7 @@ package com.android.launcher3; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ApplicationInfo; import android.content.pm.LauncherActivityInfo; import android.os.UserHandle; @@ -31,6 +32,10 @@ import com.android.launcher3.util.PackageManagerHelper; */ public class AppInfo extends ItemInfoWithIcon { + public static final int FLAG_SYSTEM_UNKNOWN = 0; + public static final int FLAG_SYSTEM_YES = 1 << 0; + public static final int FLAG_SYSTEM_NO = 1 << 1; + /** * The intent used to start the application. */ @@ -43,6 +48,11 @@ public class AppInfo extends ItemInfoWithIcon { */ public int isDisabled = ShortcutInfo.DEFAULT; + /** + * Stores if the app is a system app or not. + */ + public int isSystemApp; + public AppInfo() { itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; } @@ -71,6 +81,10 @@ public class AppInfo extends ItemInfoWithIcon { } intent = makeLaunchIntent(info); + + isSystemApp = (info.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0 + ? FLAG_SYSTEM_NO : FLAG_SYSTEM_YES; + } public AppInfo(AppInfo info) { @@ -79,6 +93,7 @@ public class AppInfo extends ItemInfoWithIcon { title = Utilities.trim(info.title); intent = new Intent(info.intent); isDisabled = info.isDisabled; + isSystemApp = info.isSystemApp; } @Override diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index dec0a92a9e..69ee03e9e3 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) { diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index d7bebd1b19..7a431986da 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/Launcher.java b/src/com/android/launcher3/Launcher.java index 1e12b423f8..32af059008 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; @@ -251,6 +253,10 @@ public class Launcher extends BaseActivity // Main container view and the model for the widget tray screen. @Thunk WidgetsContainerView mWidgetsView; + // We need to store the orientation Launcher was created with, due to a bug (b/64916689) + // that results in widgets being inflated in the wrong orientation. + private int mOrientation; + // We set the state in both onCreate and then onNewIntent in some cases, which causes both // scroll issues (because the workspace may not have been measured yet) and extra work. // Instead, just save the state that we need to restore Launcher to, and commit it in onResume. @@ -383,6 +389,7 @@ public class Launcher extends BaseActivity mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize); } + mOrientation = getResources().getConfiguration().orientation; mSharedPrefs = Utilities.getPrefs(this); mIsSafeModeEnabled = getPackageManager().isSafeMode(); mModel = app.setLauncher(this); @@ -1669,6 +1676,8 @@ public class Launcher extends BaseActivity return mSharedPrefs; } + public int getOrientation() { return mOrientation; } + @Override protected void onNewIntent(Intent intent) { long startTime = 0; @@ -3886,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() { diff --git a/src/com/android/launcher3/LauncherAppWidgetHostView.java b/src/com/android/launcher3/LauncherAppWidgetHostView.java index b65b74ea05..7fe1308764 100644 --- a/src/com/android/launcher3/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java @@ -142,9 +142,8 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView return false; } - public boolean isReinflateRequired() { + public boolean isReinflateRequired(int orientation) { // Re-inflate is required if the orientation has changed since last inflated. - int orientation = mContext.getResources().getConfiguration().orientation; if (mPreviousOrientation != orientation) { return true; } diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java index dc83f36adf..b31df98947 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); } diff --git a/src/com/android/launcher3/PendingAppWidgetHostView.java b/src/com/android/launcher3/PendingAppWidgetHostView.java index de424aba1f..c2d5501693 100644 --- a/src/com/android/launcher3/PendingAppWidgetHostView.java +++ b/src/com/android/launcher3/PendingAppWidgetHostView.java @@ -111,7 +111,7 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView } @Override - public boolean isReinflateRequired() { + public boolean isReinflateRequired(int orientation) { // Re inflate is required any time the widget restore status changes return mStartState != mInfo.restoreStatus; } diff --git a/src/com/android/launcher3/UninstallDropTarget.java b/src/com/android/launcher3/UninstallDropTarget.java index 84d6a9b348..902fd3439a 100644 --- a/src/com/android/launcher3/UninstallDropTarget.java +++ b/src/com/android/launcher3/UninstallDropTarget.java @@ -21,6 +21,7 @@ import java.net.URISyntaxException; public class UninstallDropTarget extends ButtonDropTarget { private static final String TAG = "UninstallDropTarget"; + private static Boolean sUninstallDisabled; public UninstallDropTarget(Context context, AttributeSet attrs) { this(context, attrs, 0); @@ -48,13 +49,22 @@ public class UninstallDropTarget extends ButtonDropTarget { } public static boolean supportsDrop(Context context, ItemInfo info) { - UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); - Bundle restrictions = userManager.getUserRestrictions(); - if (restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false) - || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false)) { + if (sUninstallDisabled == null) { + UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); + Bundle restrictions = userManager.getUserRestrictions(); + sUninstallDisabled = restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false) + || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false); + } + if (sUninstallDisabled) { return false; } + if (info instanceof AppInfo) { + AppInfo appInfo = (AppInfo) info; + if (appInfo.isSystemApp != AppInfo.FLAG_SYSTEM_UNKNOWN) { + return (appInfo.isSystemApp & AppInfo.FLAG_SYSTEM_NO) != 0; + } + } return getUninstallTarget(context, info) != null; } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index f8d64984e9..37ee6d751b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1213,7 +1213,7 @@ public class Workspace extends PagedView && v.getTag() instanceof LauncherAppWidgetInfo) { LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) v.getTag(); LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) v; - if (lahv.isReinflateRequired()) { + if (lahv.isReinflateRequired(mLauncher.getOrientation())) { // Remove and rebind the current widget (which was inflated in the wrong // orientation), but don't delete it from the database mLauncher.removeItem(lahv, info, false /* deleteFromDb */); diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java index ebb69c43b2..81333b1a22 100644 --- a/src/com/android/launcher3/logging/LoggerUtils.java +++ b/src/com/android/launcher3/logging/LoggerUtils.java @@ -105,13 +105,13 @@ public class LoggerUtils { private static String getItemStr(Target t) { String typeStr = getFieldName(t.itemType, ItemType.class); if (t.packageNameHash != 0) { - typeStr += ", packageHash=" + t.packageNameHash; + typeStr += ", packageHash=" + t.packageNameHash + ", predictiveRank=" + t.predictedRank; } if (t.componentHash != 0) { - typeStr += ", componentHash=" + t.componentHash; + typeStr += ", componentHash=" + t.componentHash + ", predictiveRank=" + t.predictedRank; } if (t.intentHash != 0) { - typeStr += ", intentHash=" + t.intentHash; + typeStr += ", intentHash=" + t.intentHash + ", predictiveRank=" + t.predictedRank; } return typeStr + ", grid(" + t.gridX + "," + t.gridY + "), span(" + t.spanX + "," + t.spanY + "), pageIdx=" + t.pageIndex; @@ -125,9 +125,11 @@ public class LoggerUtils { public static Target newItemTarget(ItemInfo info) { Target t = newTarget(Target.Type.ITEM); + switch (info.itemType) { case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: t.itemType = ItemType.APP_ICON; + t.predictedRank = -100; // Never assigned break; case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: t.itemType = ItemType.SHORTCUT; diff --git a/src/com/android/launcher3/qsb/QsbContainerView.java b/src/com/android/launcher3/qsb/QsbContainerView.java index d26f9f6463..65acaa9732 100644 --- a/src/com/android/launcher3/qsb/QsbContainerView.java +++ b/src/com/android/launcher3/qsb/QsbContainerView.java @@ -36,6 +36,7 @@ import android.widget.FrameLayout; import com.android.launcher3.AppWidgetResizeFrame; import com.android.launcher3.InvariantDeviceProfile; +import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.Utilities; @@ -79,10 +80,15 @@ public class QsbContainerView extends FrameLayout { private AppWidgetProviderInfo mWidgetInfo; private QsbWidgetHostView mQsb; + // We need to store the orientation here, due to a bug (b/64916689) that results in widgets + // being inflated in the wrong orientation. + private int mOrientation; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mQsbWidgetHost = new QsbWidgetHost(getActivity()); + mOrientation = getContext().getResources().getConfiguration().orientation; } private FrameLayout mWrapper; @@ -193,7 +199,7 @@ public class QsbContainerView extends FrameLayout { @Override public void onResume() { super.onResume(); - if (mQsb != null && mQsb.isReinflateRequired()) { + if (mQsb != null && mQsb.isReinflateRequired(mOrientation)) { rebindFragment(); } } diff --git a/src/com/android/launcher3/qsb/QsbWidgetHostView.java b/src/com/android/launcher3/qsb/QsbWidgetHostView.java index 8b6fa16514..a8a41f664e 100644 --- a/src/com/android/launcher3/qsb/QsbWidgetHostView.java +++ b/src/com/android/launcher3/qsb/QsbWidgetHostView.java @@ -47,9 +47,9 @@ public class QsbWidgetHostView extends AppWidgetHostView { } - public boolean isReinflateRequired() { + public boolean isReinflateRequired(int orientation) { // Re-inflate is required if the orientation has changed since last inflation. - return mPreviousOrientation != getResources().getConfiguration().orientation; + return mPreviousOrientation != orientation; } |