Merge "No need to override the isImeEnabledOnSwipeUp flag in Launcher3." into tm-qpr-dev
diff --git a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
index bdac88a..a645e58 100644
--- a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
+++ b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
@@ -210,12 +210,19 @@
}
case TestProtocol.REQUEST_USE_TEST_WORKSPACE_LAYOUT: {
- useTestWorkspaceLayout(true);
+ useTestWorkspaceLayout(
+ LauncherSettings.Settings.ARG_DEFAULT_WORKSPACE_LAYOUT_TEST);
+ return response;
+ }
+
+ case TestProtocol.REQUEST_USE_TEST2_WORKSPACE_LAYOUT: {
+ useTestWorkspaceLayout(
+ LauncherSettings.Settings.ARG_DEFAULT_WORKSPACE_LAYOUT_TEST2);
return response;
}
case TestProtocol.REQUEST_USE_DEFAULT_WORKSPACE_LAYOUT: {
- useTestWorkspaceLayout(false);
+ useTestWorkspaceLayout(null);
return response;
}
@@ -257,12 +264,17 @@
}
}
- private void useTestWorkspaceLayout(boolean useTestWorkspaceLayout) {
+ private void useTestWorkspaceLayout(String layout) {
final long identity = Binder.clearCallingIdentity();
try {
- LauncherSettings.Settings.call(mContext.getContentResolver(), useTestWorkspaceLayout
- ? LauncherSettings.Settings.METHOD_SET_USE_TEST_WORKSPACE_LAYOUT_FLAG
- : LauncherSettings.Settings.METHOD_CLEAR_USE_TEST_WORKSPACE_LAYOUT_FLAG);
+ if (layout != null) {
+ LauncherSettings.Settings.call(mContext.getContentResolver(),
+ LauncherSettings.Settings.METHOD_SET_USE_TEST_WORKSPACE_LAYOUT_FLAG,
+ layout);
+ } else {
+ LauncherSettings.Settings.call(mContext.getContentResolver(),
+ LauncherSettings.Settings.METHOD_CLEAR_USE_TEST_WORKSPACE_LAYOUT_FLAG);
+ }
} finally {
Binder.restoreCallingIdentity(identity);
}
diff --git a/protos/launcher_atom.proto b/protos/launcher_atom.proto
index 151ec5a..677c992 100644
--- a/protos/launcher_atom.proto
+++ b/protos/launcher_atom.proto
@@ -130,7 +130,7 @@
optional int32 cardinality = 2;
}
-// Next value 40
+// Next value 41
enum Attribute {
UNKNOWN = 0;
DEFAULT_LAYOUT = 1; // icon automatically placed in workspace, folder, hotseat
@@ -186,6 +186,7 @@
WEB_SEARCH_RESULT_PERSONAL = 36;
WEB_SEARCH_RESULT_CALCULATOR = 37;
WEB_SEARCH_RESULT_URL = 38;
+ WEB_SEARCH_RESULT_RICH_ANSWER = 40;
WIDGETS_BOTTOM_TRAY = 28;
WIDGETS_TRAY_PREDICTION = 29;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index e944480..87e2ab9 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -270,14 +270,13 @@
}
private void updateIconSize(Resources resources) {
- float taskbarIconSize = resources.getDimension(DisplayController.isTransientTaskbar(this)
- ? mDeviceProfile.isTwoPanels
- ? R.dimen.transient_taskbar_two_panels_icon_size
- : R.dimen.transient_taskbar_icon_size
- : R.dimen.taskbar_icon_size);
- mDeviceProfile.updateIconSize(1, resources);
- float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
- mDeviceProfile.updateIconSize(iconScale, resources);
+ mDeviceProfile.iconSizePx = resources.getDimensionPixelSize(
+ DisplayController.isTransientTaskbar(this)
+ ? mDeviceProfile.isTwoPanels
+ ? R.dimen.transient_taskbar_two_panels_icon_size
+ : R.dimen.transient_taskbar_icon_size
+ : R.dimen.taskbar_icon_size);
+ mDeviceProfile.updateIconSize(1f, resources);
}
/**
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index b58b6b5..168c353 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -428,8 +428,8 @@
}
public void onRotationChanged(DeviceProfile deviceProfile) {
- if (mControllers.taskbarStashController.isInApp()) {
- // We only translate on rotation when on home
+ if (!mControllers.uiController.isIconAlignedWithHotseat()) {
+ // We only translate on rotation when icon is aligned with hotseat
return;
}
mActivity.setTaskbarWindowHeight(
diff --git a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java
index 1d421b2..75a8ea2 100644
--- a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java
@@ -28,6 +28,7 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.statemanager.StatefulActivity;
+import com.android.launcher3.taskbar.TaskbarActivityContext;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.views.BaseDragLayer;
@@ -85,6 +86,7 @@
private PagedOrientationHandler mOrientationHandler;
@SplitConfigurationOptions.StagePosition
private int mStagePosition;
+ private final Rect mTmpRect = new Rect();
public FloatingTaskView(Context context) {
this(context, null);
@@ -158,10 +160,24 @@
}
public void updateInitialPositionForView(View originalView) {
- Rect viewBounds = new Rect(0, 0, originalView.getWidth(), originalView.getHeight());
- Utilities.getBoundsForViewInDragLayer(mActivity.getDragLayer(), originalView, viewBounds,
- false /* ignoreTransform */, null /* recycle */,
- mStartingPosition);
+ if (originalView.getContext() instanceof TaskbarActivityContext) {
+ // If original View is a button on the Taskbar, find the on-screen bounds and calculate
+ // the equivalent bounds in the DragLayer, so we can set the initial position of
+ // this FloatingTaskView and start the split animation at the correct spot.
+ originalView.getBoundsOnScreen(mTmpRect);
+ mStartingPosition.set(mTmpRect);
+ int[] dragLayerPositionRelativeToScreen =
+ mActivity.getDragLayer().getLocationOnScreen();
+ mStartingPosition.offset(
+ -dragLayerPositionRelativeToScreen[0],
+ -dragLayerPositionRelativeToScreen[1]);
+ } else {
+ Rect viewBounds = new Rect(0, 0, originalView.getWidth(), originalView.getHeight());
+ Utilities.getBoundsForViewInDragLayer(mActivity.getDragLayer(), originalView,
+ viewBounds, false /* ignoreTransform */, null /* recycle */,
+ mStartingPosition);
+ }
+
final BaseDragLayer.LayoutParams lp = new BaseDragLayer.LayoutParams(
Math.round(mStartingPosition.width()),
Math.round(mStartingPosition.height()));
diff --git a/res/color-night-v31/widgets_picker_scrim.xml b/res/color-night-v31/widgets_picker_scrim.xml
deleted file mode 100644
index be7010b..0000000
--- a/res/color-night-v31/widgets_picker_scrim.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2021, 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.
-*/
--->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:color="@android:color/system_neutral1_900" android:alpha="0.8" />
-</selector>
diff --git a/res/color-v31/widgets_picker_scrim.xml b/res/color-v31/widgets_picker_scrim.xml
deleted file mode 100644
index 648824a..0000000
--- a/res/color-v31/widgets_picker_scrim.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2021, 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.
-*/
--->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:color="@android:color/system_neutral1_200" android:alpha="0.8" />
-</selector>
diff --git a/res/color/widgets_picker_scrim.xml b/res/color/widgets_picker_scrim.xml
index 1cf97f6..5d51300 100644
--- a/res/color/widgets_picker_scrim.xml
+++ b/res/color/widgets_picker_scrim.xml
@@ -18,5 +18,5 @@
*/
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:color="#000000" android:alpha="0.32" />
+ <item android:color="#000000" android:alpha="0.65" />
</selector>
diff --git a/res/xml/default_test2_workspace.xml b/res/xml/default_test2_workspace.xml
new file mode 100644
index 0000000..c560104
--- /dev/null
+++ b/res/xml/default_test2_workspace.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Split display specific version of Launcher3/res/xml/default_workspace_4x4.xml -->
+<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3" >
+
+ <!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
+ <!-- Dialer Messaging Chrome Camera -->
+ <favorite
+ launcher:container="-101"
+ launcher:screen="0"
+ launcher:x="0"
+ launcher:y="0"
+ launcher:className="com.google.android.dialer.extensions.GoogleDialtactsActivity"
+ launcher:packageName="com.google.android.dialer" />
+
+ <favorite
+ launcher:container="-101"
+ launcher:screen="1"
+ launcher:x="1"
+ launcher:y="0"
+ launcher:className="com.google.android.apps.messaging.ui.ConversationListActivity"
+ launcher:packageName="com.google.android.apps.messaging" />
+
+ <favorite
+ launcher:container="-101"
+ launcher:screen="2"
+ launcher:x="2"
+ launcher:y="0"
+ launcher:className="com.google.android.apps.chrome.Main"
+ launcher:packageName="com.android.chrome" />
+
+ <favorite
+ launcher:container="-101"
+ launcher:screen="3"
+ launcher:x="3"
+ launcher:y="0"
+ launcher:className="com.android.camera.CameraLauncher"
+ launcher:packageName="com.google.android.GoogleCamera" />
+
+ <!-- Bottom row -->
+ <!-- Maps [space] [space] Play -->
+ <favorite
+ launcher:className="com.google.android.maps.MapsActivity"
+ launcher:packageName="com.google.android.apps.maps"
+ launcher:screen="0"
+ launcher:x="0"
+ launcher:y="-1" />
+
+ <favorite
+ launcher:className="com.android.vending.AssetBrowserActivity"
+ launcher:packageName="com.android.vending"
+ launcher:screen="0"
+ launcher:x="3"
+ launcher:y="-1" />
+
+ <!-- TODO: Place weather widget when it's available -->
+
+</favorites>
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index fdc52b5..ecfd230 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -2716,6 +2716,7 @@
*/
void onDragEnter() {
mDragging = true;
+ mPreviousSolution = null;
}
/**
@@ -2730,6 +2731,7 @@
}
// Invalidate the drag data
+ mPreviousSolution = null;
mDragCell[0] = mDragCell[1] = -1;
mDragCellSpan[0] = mDragCellSpan[1] = -1;
mDragOutlineAnims[mDragOutlineCurrent].animateOut();
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index bfde8da..7ccd195 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -817,6 +817,11 @@
* Returns the amount of extra (or unused) vertical space.
*/
private int updateAvailableDimensions(Resources res) {
+ float invIconSizeDp = inv.iconSize[mTypeIndex];
+ float invIconTextSizeSp = inv.iconTextSize[mTypeIndex];
+ iconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics));
+ iconTextSizePx = pxFromSp(invIconTextSizeSp, mMetrics);
+
updateIconSize(1f, res);
updateWorkspacePadding();
@@ -873,13 +878,7 @@
// Workspace
final boolean isVerticalLayout = isVerticalBarLayout();
- float invIconSizeDp = inv.iconSize[mTypeIndex];
- float invIconTextSizeSp = inv.iconTextSize[mTypeIndex];
-
- iconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics));
- iconTextSizePx = pxFromSp(invIconTextSizeSp, mMetrics);
iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * iconScale);
-
cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv, scale);
if (isScalableGrid) {
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 8ddbbaa..f4c0501 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -106,6 +106,7 @@
public static final String KEY_LAYOUT_PROVIDER_AUTHORITY = "KEY_LAYOUT_PROVIDER_AUTHORITY";
private static final int TEST_WORKSPACE_LAYOUT_RES_XML = R.xml.default_test_workspace;
+ private static final int TEST2_WORKSPACE_LAYOUT_RES_XML = R.xml.default_test2_workspace;
static final String EMPTY_DATABASE_CREATED = "EMPTY_DATABASE_CREATED";
@@ -114,7 +115,7 @@
private long mLastRestoreTimestamp = 0L;
- private boolean mUseTestWorkspaceLayout;
+ private int mDefaultWorkspaceLayoutOverride = 0;
/**
* $ adb shell dumpsys activity provider com.android.launcher3
@@ -402,11 +403,21 @@
return null;
}
case LauncherSettings.Settings.METHOD_SET_USE_TEST_WORKSPACE_LAYOUT_FLAG: {
- mUseTestWorkspaceLayout = true;
+ switch (arg) {
+ case LauncherSettings.Settings.ARG_DEFAULT_WORKSPACE_LAYOUT_TEST:
+ mDefaultWorkspaceLayoutOverride = TEST_WORKSPACE_LAYOUT_RES_XML;
+ break;
+ case LauncherSettings.Settings.ARG_DEFAULT_WORKSPACE_LAYOUT_TEST2:
+ mDefaultWorkspaceLayoutOverride = TEST2_WORKSPACE_LAYOUT_RES_XML;
+ break;
+ default:
+ mDefaultWorkspaceLayoutOverride = 0;
+ break;
+ }
return null;
}
case LauncherSettings.Settings.METHOD_CLEAR_USE_TEST_WORKSPACE_LAYOUT_FLAG: {
- mUseTestWorkspaceLayout = false;
+ mDefaultWorkspaceLayoutOverride = 0;
return null;
}
case LauncherSettings.Settings.METHOD_LOAD_DEFAULT_FAVORITES: {
@@ -628,8 +639,8 @@
private DefaultLayoutParser getDefaultLayoutParser(LauncherWidgetHolder widgetHolder) {
InvariantDeviceProfile idp = LauncherAppState.getIDP(getContext());
- int defaultLayout = mUseTestWorkspaceLayout
- ? TEST_WORKSPACE_LAYOUT_RES_XML : idp.defaultLayoutId;
+ int defaultLayout = mDefaultWorkspaceLayoutOverride > 0
+ ? mDefaultWorkspaceLayoutOverride : idp.defaultLayoutId;
if (getContext().getSystemService(UserManager.class).isDemoUser()
&& idp.demoModeLayoutId != 0) {
diff --git a/src/com/android/launcher3/LauncherSettings.java b/src/com/android/launcher3/LauncherSettings.java
index 4c8f2d9..932f98a 100644
--- a/src/com/android/launcher3/LauncherSettings.java
+++ b/src/com/android/launcher3/LauncherSettings.java
@@ -377,6 +377,8 @@
public static final String METHOD_SET_USE_TEST_WORKSPACE_LAYOUT_FLAG =
"set_use_test_workspace_layout_flag";
+ public static final String ARG_DEFAULT_WORKSPACE_LAYOUT_TEST = "default_test_workspace";
+ public static final String ARG_DEFAULT_WORKSPACE_LAYOUT_TEST2 = "default_test2_workspace";
public static final String METHOD_CLEAR_USE_TEST_WORKSPACE_LAYOUT_FLAG =
"clear_use_test_workspace_layout_flag";
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java
index 4cb4348..3e2d051 100644
--- a/src/com/android/launcher3/settings/SettingsActivity.java
+++ b/src/com/android/launcher3/settings/SettingsActivity.java
@@ -53,6 +53,7 @@
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.states.RotationHelper;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
+import com.android.launcher3.util.DisplayController;
import java.util.Collections;
import java.util.List;
@@ -267,15 +268,14 @@
return !WidgetsModel.GO_DISABLE_NOTIFICATION_DOTS;
case ALLOW_ROTATION_PREFERENCE_KEY:
- DeviceProfile deviceProfile = InvariantDeviceProfile.INSTANCE.get(
- getContext()).getDeviceProfile(getContext());
- if (deviceProfile.isTablet) {
+ DisplayController.Info info = InvariantDeviceProfile.INSTANCE.get(
+ getContext()).getDeviceProfile(getContext()).getDisplayInfo();
+ if (info.isTablet(info.realBounds)) {
// Launcher supports rotation by default. No need to show this setting.
return false;
}
// Initialize the UI once
- preference.setDefaultValue(
- RotationHelper.getAllowRotationDefaultValue(deviceProfile));
+ preference.setDefaultValue(RotationHelper.getAllowRotationDefaultValue(info));
return true;
case FLAGS_PREFERENCE_KEY:
diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java
index 642bdcd..e5b4eba 100644
--- a/src/com/android/launcher3/states/RotationHelper.java
+++ b/src/com/android/launcher3/states/RotationHelper.java
@@ -35,7 +35,6 @@
import androidx.annotation.WorkerThread;
import com.android.launcher3.BaseActivity;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.util.DisplayController;
@@ -50,11 +49,11 @@
/**
* Returns the default value of {@link #ALLOW_ROTATION_PREFERENCE_KEY} preference.
*/
- public static boolean getAllowRotationDefaultValue(DeviceProfile deviceProfile) {
+ public static boolean getAllowRotationDefaultValue(DisplayController.Info info) {
// If the device's pixel density was scaled (usually via settings for A11y), use the
// original dimensions to determine if rotation is allowed of not.
- float originalSmallestWidth = dpiFromPx(
- Math.min(deviceProfile.widthPx, deviceProfile.heightPx), DENSITY_DEVICE_STABLE);
+ float originalSmallestWidth = dpiFromPx(Math.min(info.currentSize.x, info.currentSize.y),
+ DENSITY_DEVICE_STABLE);
return originalSmallestWidth >= MIN_TABLET_WIDTH;
}
@@ -99,7 +98,8 @@
new Handler(UI_HELPER_EXECUTOR.getLooper(), this::setOrientationAsync);
}
- private void setIgnoreAutoRotateSettings(boolean ignoreAutoRotateSettings) {
+ private void setIgnoreAutoRotateSettings(boolean ignoreAutoRotateSettings,
+ DisplayController.Info info) {
// On large devices we do not handle auto-rotate differently.
mIgnoreAutoRotateSettings = ignoreAutoRotateSettings;
if (!mIgnoreAutoRotateSettings) {
@@ -108,7 +108,7 @@
mSharedPrefs.registerOnSharedPreferenceChangeListener(this);
}
mHomeRotationEnabled = mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY,
- getAllowRotationDefaultValue(mActivity.getDeviceProfile()));
+ getAllowRotationDefaultValue(info));
} else {
if (mSharedPrefs != null) {
mSharedPrefs.unregisterOnSharedPreferenceChangeListener(this);
@@ -122,7 +122,7 @@
if (mDestroyed || mIgnoreAutoRotateSettings) return;
boolean wasRotationEnabled = mHomeRotationEnabled;
mHomeRotationEnabled = mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY,
- getAllowRotationDefaultValue(mActivity.getDeviceProfile()));
+ getAllowRotationDefaultValue(mActivity.getDeviceProfile().getDisplayInfo()));
if (mHomeRotationEnabled != wasRotationEnabled) {
notifyChange();
}
@@ -132,7 +132,7 @@
public void onDisplayInfoChanged(Context context, DisplayController.Info info, int flags) {
boolean ignoreAutoRotateSettings = info.isTablet(info.realBounds);
if (mIgnoreAutoRotateSettings != ignoreAutoRotateSettings) {
- setIgnoreAutoRotateSettings(ignoreAutoRotateSettings);
+ setIgnoreAutoRotateSettings(ignoreAutoRotateSettings, info);
notifyChange();
}
}
@@ -169,7 +169,7 @@
mInitialized = true;
DisplayController displayController = DisplayController.INSTANCE.get(mActivity);
DisplayController.Info info = displayController.getInfo();
- setIgnoreAutoRotateSettings(info.isTablet(info.realBounds));
+ setIgnoreAutoRotateSettings(info.isTablet(info.realBounds), info);
displayController.addChangeListener(this);
notifyChange();
}
diff --git a/src/com/android/launcher3/testing/shared/TestProtocol.java b/src/com/android/launcher3/testing/shared/TestProtocol.java
index 46e5891..1deb23d 100644
--- a/src/com/android/launcher3/testing/shared/TestProtocol.java
+++ b/src/com/android/launcher3/testing/shared/TestProtocol.java
@@ -106,6 +106,7 @@
public static final String REQUEST_STOP_EVENT_LOGGING = "stop-event-logging";
public static final String REQUEST_CLEAR_DATA = "clear-data";
public static final String REQUEST_USE_TEST_WORKSPACE_LAYOUT = "use-test-workspace-layout";
+ public static final String REQUEST_USE_TEST2_WORKSPACE_LAYOUT = "use-test2-workspace-layout";
public static final String REQUEST_USE_DEFAULT_WORKSPACE_LAYOUT =
"use-default-workspace-layout";
public static final String REQUEST_HOTSEAT_ICON_NAMES = "get-hotseat-icon-names";
diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
index 820162c..097823b 100644
--- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
@@ -432,10 +432,10 @@
int drawableWidth, int drawableHeight, DeviceProfile dp,
@StagePosition int stagePosition) {
float insetAdjustment = getPlaceholderSizeAdjustment(dp) / 2f;
- out.setX(Math.round(onScreenRectCenterX / fullscreenScaleX
- - 1.0f * drawableWidth / 2));
- out.setY(Math.round((onScreenRectCenterY + insetAdjustment) / fullscreenScaleY
- - 1.0f * drawableHeight / 2));
+ out.setX(onScreenRectCenterX / fullscreenScaleX
+ - 1.0f * drawableWidth / 2);
+ out.setY((onScreenRectCenterY + insetAdjustment) / fullscreenScaleY
+ - 1.0f * drawableHeight / 2);
}
/**
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index 78e17d8..316cf0e 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -463,20 +463,20 @@
boolean pinToRight = stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT;
float insetAdjustment = getPlaceholderSizeAdjustment(dp, pinToRight) / 2f;
if (!dp.isLandscape) {
- out.setX(Math.round(onScreenRectCenterX / fullscreenScaleX
- - 1.0f * drawableWidth / 2));
- out.setY(Math.round((onScreenRectCenterY + insetAdjustment) / fullscreenScaleY
- - 1.0f * drawableHeight / 2));
+ out.setX(onScreenRectCenterX / fullscreenScaleX
+ - 1.0f * drawableWidth / 2);
+ out.setY((onScreenRectCenterY + insetAdjustment) / fullscreenScaleY
+ - 1.0f * drawableHeight / 2);
} else {
if (pinToRight) {
- out.setX(Math.round((onScreenRectCenterX - insetAdjustment) / fullscreenScaleX
- - 1.0f * drawableWidth / 2));
+ out.setX((onScreenRectCenterX - insetAdjustment) / fullscreenScaleX
+ - 1.0f * drawableWidth / 2);
} else {
- out.setX(Math.round((onScreenRectCenterX + insetAdjustment) / fullscreenScaleX
- - 1.0f * drawableWidth / 2));
+ out.setX((onScreenRectCenterX + insetAdjustment) / fullscreenScaleX
+ - 1.0f * drawableWidth / 2);
}
- out.setY(Math.round(onScreenRectCenterY / fullscreenScaleY
- - 1.0f * drawableHeight / 2));
+ out.setY(onScreenRectCenterY / fullscreenScaleY
+ - 1.0f * drawableHeight / 2);
}
}
diff --git a/src/com/android/launcher3/views/ArrowTipView.java b/src/com/android/launcher3/views/ArrowTipView.java
index 8d16a8d..73c5ad4 100644
--- a/src/com/android/launcher3/views/ArrowTipView.java
+++ b/src/com/android/launcher3/views/ArrowTipView.java
@@ -162,6 +162,7 @@
params.gravity = gravity;
params.leftMargin = mArrowMinOffset + grid.getInsets().left;
params.rightMargin = mArrowMinOffset + grid.getInsets().right;
+ params.width = LayoutParams.MATCH_PARENT;
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mArrowView.getLayoutParams();
lp.gravity = gravity;
diff --git a/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
index b7ad7f2..6a938da 100644
--- a/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
@@ -21,8 +21,6 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
-import android.view.View;
-
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
@@ -33,6 +31,7 @@
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.ui.TaplTestsLauncher3;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -53,22 +52,24 @@
@Before
public void setUp() throws Exception {
super.setUp();
+ mLauncher.useTest2WorkspaceLayoutOnReload();
TaplTestsLauncher3.initialize(this);
assumeTrue(mLauncher.isTwoPanels());
- // Removing the Gmail widget so there are space in the right panel to run the test.
- Workspace workspace = mLauncher.getWorkspace();
- workspace.deleteWidget(workspace.tryGetWidget("Gmail", DEFAULT_UI_TIMEOUT));
-
// Pre verifying the screens
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "Photos", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
+ assertItemsOnPage(launcher, 0, "Play Store", "Maps");
+ assertPageEmpty(launcher, 1);
});
}
+ @After
+ public void tearDown() {
+ mLauncher.useDefaultWorkspaceLayoutOnReload();
+ }
+
@Test
@PortraitLandscape
public void testDragIconToRightPanel() {
@@ -78,8 +79,8 @@
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "Photos", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather", "Chrome");
+ assertItemsOnPage(launcher, 0, "Maps", "Play Store");
+ assertItemsOnPage(launcher, 1, "Chrome");
});
}
@@ -92,39 +93,39 @@
workspace.flingBackward();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 3);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Chrome");
- assertItemsOnPage(launcher, 3, "Photos");
+ assertItemsOnPage(launcher, 3, "Maps");
});
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 3);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Chrome");
assertPageEmpty(launcher, 3);
assertPageEmpty(launcher, 4);
- assertItemsOnPage(launcher, 5, "Photos");
+ assertItemsOnPage(launcher, 5, "Maps");
});
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), -1);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Chrome");
- assertItemsOnPage(launcher, 3, "Photos");
+ assertItemsOnPage(launcher, 3, "Maps");
});
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), -1);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
workspace.flingForward();
@@ -132,8 +133,8 @@
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1);
- assertItemsOnPage(launcher, 0, "Chrome", "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather", "Photos");
+ assertItemsOnPage(launcher, 0, "Chrome", "Play Store");
+ assertItemsOnPage(launcher, 1, "Maps");
});
}
@@ -142,13 +143,13 @@
public void testDragIconToPage2() {
Workspace workspace = mLauncher.getWorkspace();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 2);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
- assertItemsOnPage(launcher, 2, "Photos");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertPageEmpty(launcher, 1);
+ assertItemsOnPage(launcher, 2, "Maps");
assertPageEmpty(launcher, 3);
});
}
@@ -162,8 +163,8 @@
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "Photos", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
+ assertItemsOnPage(launcher, 0, "Play Store", "Maps");
+ assertPageEmpty(launcher, 1);
assertPageEmpty(launcher, 2);
assertItemsOnPage(launcher, 3, "Phone");
});
@@ -178,16 +179,16 @@
workspace.flingBackward();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 5);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 5);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Messages");
assertPageEmpty(launcher, 3);
assertPageEmpty(launcher, 4);
- assertItemsOnPage(launcher, 5, "Photos");
+ assertItemsOnPage(launcher, 5, "Maps");
});
workspace.flingBackward();
@@ -196,10 +197,10 @@
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 4, 5, 6, 7);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertPageEmpty(launcher, 1);
assertPageEmpty(launcher, 4);
- assertItemsOnPage(launcher, 5, "Photos");
+ assertItemsOnPage(launcher, 5, "Maps");
assertItemsOnPage(launcher, 6, "Messages");
assertPageEmpty(launcher, 7);
});
@@ -208,10 +209,10 @@
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 4, 5);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather", "Messages");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 1, "Messages");
assertPageEmpty(launcher, 4);
- assertItemsOnPage(launcher, 5, "Photos");
+ assertItemsOnPage(launcher, 5, "Maps");
});
}
@@ -220,23 +221,23 @@
public void testEmptyPageDoesNotGetRemovedIfPagePairIsNotEmpty() {
Workspace workspace = mLauncher.getWorkspace();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 3);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 0);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Chrome");
- assertItemsOnPage(launcher, 3, "Photos");
+ assertItemsOnPage(launcher, 3, "Maps");
});
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), -1);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather", "Photos");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 1, "Maps");
assertItemsOnPage(launcher, 2, "Chrome");
assertPageEmpty(launcher, 3);
});
@@ -248,8 +249,8 @@
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather", "Photos");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 1, "Maps");
assertPageEmpty(launcher, 2);
assertItemsOnPage(launcher, 3, "Chrome");
});
@@ -265,8 +266,8 @@
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Gmail", "Photos", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
+ assertItemsOnPage(launcher, 0, "Maps");
+ assertPageEmpty(launcher, 1);
assertItemsOnPage(launcher, 2, "Play Store");
assertItemsOnPage(launcher, 3, "Chrome");
});
@@ -277,8 +278,8 @@
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "Photos", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather", "Chrome");
+ assertItemsOnPage(launcher, 0, "Play Store", "Maps");
+ assertItemsOnPage(launcher, 1, "Chrome");
});
}
@@ -287,27 +288,27 @@
public void testMiddleEmptyPagesGetRemoved() {
Workspace workspace = mLauncher.getWorkspace();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 2);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
workspace.dragIcon(workspace.getHotseatAppIcon("Messages"), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
- assertItemsOnPage(launcher, 2, "Photos");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertPageEmpty(launcher, 1);
+ assertItemsOnPage(launcher, 2, "Maps");
assertPageEmpty(launcher, 3);
assertPageEmpty(launcher, 4);
assertItemsOnPage(launcher, 5, "Messages");
});
workspace.flingBackward();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Photos"), 2);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 4, 5);
- assertItemsOnPage(launcher, 0, "Play Store", "Gmail", "YouTube");
- assertItemsOnPage(launcher, 1, "Weather");
- assertItemsOnPage(launcher, 4, "Photos");
+ assertItemsOnPage(launcher, 0, "Play Store");
+ assertPageEmpty(launcher, 1);
+ assertItemsOnPage(launcher, 4, "Maps");
assertItemsOnPage(launcher, 5, "Messages");
});
}
@@ -335,21 +336,14 @@
CellLayout page = launcher.getWorkspace().getScreenWithId(pageId);
int itemCount = page.getShortcutsAndWidgets().getChildCount();
for (int i = 0; i < itemCount; i++) {
- CharSequence title = null;
- View child = page.getShortcutsAndWidgets().getChildAt(i);
- ItemInfo itemInfo = (ItemInfo) child.getTag();
+ ItemInfo itemInfo = (ItemInfo) page.getShortcutsAndWidgets().getChildAt(i).getTag();
if (itemInfo != null) {
- title = itemInfo.title;
- }
- if (title == null) {
- title = child.getContentDescription();
- }
- if (title != null) {
- assertTrue("There was an extra item on page " + pageId + ": " + title,
- itemTitleSet.remove(title));
+ assertTrue("There was an extra item on page " + pageId + ": " + itemInfo.title,
+ itemTitleSet.remove(itemInfo.title));
}
}
assertTrue("Could NOT find some of the items on page " + pageId + ": "
- + String.join(",", itemTitleSet), itemTitleSet.isEmpty());
+ + itemTitleSet.stream().collect(Collectors.joining(",")),
+ itemTitleSet.isEmpty());
}
-}
+}
\ No newline at end of file
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index fcff3fa..302fabd 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -1848,6 +1848,14 @@
getTestInfo(TestProtocol.REQUEST_USE_TEST_WORKSPACE_LAYOUT);
}
+ /**
+ * Reloads the workspace with a test layout that includes Maps/Play on workspace, and
+ * Dialer/Messaging/Chrome/Camera on hotseat.
+ */
+ public void useTest2WorkspaceLayoutOnReload() {
+ getTestInfo(TestProtocol.REQUEST_USE_TEST2_WORKSPACE_LAYOUT);
+ }
+
/** Reloads the workspace with the default layout defined by the user's grid size selection. */
public void useDefaultWorkspaceLayoutOnReload() {
getTestInfo(TestProtocol.REQUEST_USE_DEFAULT_WORKSPACE_LAYOUT);
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 7ed5788..b2a2937 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -334,28 +334,14 @@
* @return validated workspace after the existing appIcon being deleted.
*/
public Workspace deleteAppIcon(HomeAppIcon homeAppIcon) {
- return deleteLaunchable(homeAppIcon, LONG_CLICK_EVENT);
- }
-
- /**
- * Delete the widget from the workspace.
- *
- * @param widget to be deleted.
- * @return validated workspace after the existing widget being deleted.
- */
- public Workspace deleteWidget(Widget widget) {
- return deleteLaunchable(widget, Widget.LONG_CLICK_EVENT);
- }
-
- private Workspace deleteLaunchable(Launchable launchable, Pattern longClickEvent) {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"removing app icon from workspace")) {
dragIconToWorkspace(
mLauncher,
- launchable,
+ homeAppIcon,
() -> getDropPointFromDropTargetBar(mLauncher, DELETE_TARGET_TEXT_ID),
- () -> mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, longClickEvent),
+ () -> mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT),
/* expectDropEvents= */ null);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(