Merge "Import translations. DO NOT MERGE ANYWHERE" into tm-qpr-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index 13943a7..17da0d9 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -108,8 +108,6 @@
private static final int FLAG_SCREEN_PINNING_ACTIVE = 1 << 11;
private static final int FLAG_VOICE_INTERACTION_WINDOW_SHOWING = 1 << 12;
- private static final int MASK_IME_SWITCHER_VISIBLE = FLAG_SWITCHER_SUPPORTED | FLAG_IME_VISIBLE;
-
private static final String NAV_BUTTONS_SEPARATE_WINDOW_TITLE = "Taskbar Nav Buttons";
public static final int ALPHA_INDEX_IMMERSIVE_MODE = 0;
@@ -191,7 +189,7 @@
isThreeButtonNav ? mStartContextualContainer : mEndContextualContainer,
mControllers.navButtonController, R.id.ime_switcher);
mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton,
- flags -> ((flags & MASK_IME_SWITCHER_VISIBLE) != 0)
+ flags -> ((flags & FLAG_SWITCHER_SUPPORTED) != 0)
&& ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0)));
}
@@ -507,6 +505,13 @@
}
/**
+ * Returns true if IME switcher is visible
+ */
+ public boolean isImeSwitcherVisible() {
+ return (mState & FLAG_SWITCHER_SUPPORTED) != 0;
+ }
+
+ /**
* Returns true if the home button is disabled
*/
public boolean isHomeDisabled() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index d86fa16..439490e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -464,6 +464,8 @@
fromInit);
mControllers.taskbarViewController.setImeIsVisible(
mControllers.navbarButtonsViewController.isImeVisible());
+ mControllers.taskbarViewController.setIsImeSwitcherVisible(
+ mControllers.navbarButtonsViewController.isImeSwitcherVisible());
int shadeExpandedFlags = SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED
| SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
onNotificationShadeExpandChanged((systemUiStateFlags & shadeExpandedFlags) != 0, fromInit);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index 0cbd0d1..23a0334 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -68,7 +68,8 @@
public static final int ALPHA_INDEX_RECENTS_DISABLED = 3;
public static final int ALPHA_INDEX_NOTIFICATION_EXPANDED = 4;
public static final int ALPHA_INDEX_ASSISTANT_INVOKED = 5;
- private static final int NUM_ALPHA_CHANNELS = 6;
+ public static final int ALPHA_INDEX_IME_BUTTON_NAV = 6;
+ private static final int NUM_ALPHA_CHANNELS = 7;
private final TaskbarActivityContext mActivity;
private final TaskbarView mTaskbarView;
@@ -143,6 +144,14 @@
}
/**
+ * Should be called when the IME switcher visibility changes.
+ */
+ public void setIsImeSwitcherVisible(boolean isImeSwitcherVisible) {
+ mTaskbarIconAlpha.getProperty(ALPHA_INDEX_IME_BUTTON_NAV).setValue(
+ isImeSwitcherVisible ? 0 : 1);
+ }
+
+ /**
* Should be called when the recents button is disabled, so we can hide taskbar icons as well.
*/
public void setRecentsButtonDisabled(boolean isDisabled) {
diff --git a/res/layout/widgets_full_sheet_paged_view.xml b/res/layout/widgets_full_sheet_paged_view.xml
index dfe226a..24028fa 100644
--- a/res/layout/widgets_full_sheet_paged_view.xml
+++ b/res/layout/widgets_full_sheet_paged_view.xml
@@ -16,37 +16,35 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto">
- <com.android.launcher3.workprofile.PersonalWorkPagedView
+ <com.android.launcher3.widget.picker.WidgetPagedView
android:id="@+id/widgets_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:layout_below="@id/collapse_handle"
android:descendantFocusability="afterDescendants"
- launcher:pageIndicator="@+id/tabs">
+ android:paddingHorizontal="@dimen/widget_list_horizontal_margin"
+ launcher:pageIndicator="@+id/tabs" >
<com.android.launcher3.widget.picker.WidgetsRecyclerView
android:id="@+id/primary_widgets_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingHorizontal="@dimen/widget_list_horizontal_margin"
android:clipToPadding="false" />
<com.android.launcher3.widget.picker.WidgetsRecyclerView
android:id="@+id/work_widgets_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingHorizontal="@dimen/widget_list_horizontal_margin"
android:clipToPadding="false" />
- </com.android.launcher3.workprofile.PersonalWorkPagedView>
+ </com.android.launcher3.widget.picker.WidgetPagedView>
<!-- SearchAndRecommendationsView contains the tab layout as well -->
<com.android.launcher3.widget.picker.SearchAndRecommendationsView
android:id="@+id/search_and_recommendations_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
android:layout_below="@id/collapse_handle"
android:paddingBottom="0dp"
android:orientation="vertical">
@@ -58,6 +56,7 @@
android:gravity="center_horizontal"
android:textSize="24sp"
android:layout_marginTop="24dp"
+ android:paddingHorizontal="@dimen/widget_list_horizontal_margin"
android:textColor="?android:attr/textColorSecondary"
android:text="@string/widget_button_text"/>
@@ -68,6 +67,7 @@
android:elevation="0.1dp"
android:background="?android:attr/colorBackground"
android:paddingBottom="8dp"
+ android:paddingHorizontal="@dimen/widget_list_horizontal_margin"
android:clipToPadding="false">
<include layout="@layout/widgets_search_bar" />
</FrameLayout>
@@ -79,6 +79,7 @@
android:layout_marginTop="8dp"
android:background="@drawable/widgets_recommendation_background"
android:paddingVertical="@dimen/recommended_widgets_table_vertical_padding"
+ android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
android:visibility="gone" />
<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip
diff --git a/res/layout/widgets_full_sheet_recyclerview.xml b/res/layout/widgets_full_sheet_recyclerview.xml
index 6a5d6cb..f4b5a0a 100644
--- a/res/layout/widgets_full_sheet_recyclerview.xml
+++ b/res/layout/widgets_full_sheet_recyclerview.xml
@@ -19,7 +19,7 @@
android:layout_below="@id/collapse_handle"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingHorizontal="@dimen/widget_list_horizontal_margin"
+ android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
android:clipToPadding="false" />
<!-- SearchAndRecommendationsView without the tab layout as well -->
@@ -27,7 +27,6 @@
android:id="@+id/search_and_recommendations_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
android:layout_below="@id/collapse_handle"
android:paddingBottom="16dp"
android:orientation="vertical">
@@ -40,6 +39,7 @@
android:textSize="24sp"
android:layout_marginTop="24dp"
android:textColor="?android:attr/textColorSecondary"
+ android:paddingHorizontal="@dimen/widget_list_horizontal_margin"
android:text="@string/widget_button_text"/>
<FrameLayout
@@ -48,6 +48,7 @@
android:layout_height="wrap_content"
android:elevation="0.1dp"
android:background="?android:attr/colorBackground"
+ android:paddingHorizontal="@dimen/widget_list_horizontal_margin"
android:paddingBottom="8dp"
android:clipToPadding="false">
<include layout="@layout/widgets_search_bar" />
@@ -60,6 +61,7 @@
android:layout_marginTop="8dp"
android:background="@drawable/widgets_recommendation_background"
android:paddingVertical="@dimen/recommended_widgets_table_vertical_padding"
+ android:paddingHorizontal="@dimen/widget_list_horizontal_margin"
android:visibility="gone" />
</com.android.launcher3.widget.picker.SearchAndRecommendationsView>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index cc57a7b..a93b40d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -305,7 +305,6 @@
Workspace<?> mWorkspace;
@Thunk
DragLayer mDragLayer;
- private DragController mDragController;
private WidgetManagerHelper mAppWidgetManager;
private LauncherAppWidgetHost mAppWidgetHost;
@@ -369,6 +368,7 @@
private RotationHelper mRotationHelper;
protected LauncherOverlayManager mOverlayManager;
+ protected DragController mDragController;
// If true, overlay callbacks are deferred
private boolean mDeferOverlayCallbacks;
private final Runnable mDeferredOverlayCallbacks = this::checkIfOverlayStillDeferred;
@@ -465,7 +465,7 @@
mIconCache = app.getIconCache();
mAccessibilityDelegate = createAccessibilityDelegate();
- mDragController = new LauncherDragController(this);
+ initDragController();
mAllAppsController = new AllAppsTransitionController(this);
mStateManager = new StateManager<>(this, NORMAL);
@@ -614,6 +614,13 @@
super.onConfigurationChanged(newConfig);
}
+ /**
+ * Initializes the drag controller.
+ */
+ protected void initDragController() {
+ mDragController = new LauncherDragController(this);
+ }
+
@Override
public void onIdpChanged(boolean modelPropertiesChanged) {
initDeviceProfile(mDeviceProfile.inv);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index c482ed5..e6dea8f 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -159,7 +159,7 @@
private LayoutTransition mLayoutTransition;
@Thunk final WallpaperManager mWallpaperManager;
- private ShortcutAndWidgetContainer mDragSourceInternal;
+ protected ShortcutAndWidgetContainer mDragSourceInternal;
@Thunk final IntSparseArrayMap<CellLayout> mWorkspaceScreens = new IntSparseArrayMap<>();
@Thunk final IntArray mScreenOrder = new IntArray();
@@ -195,7 +195,7 @@
@Thunk final Launcher mLauncher;
@Thunk DragController mDragController;
- private final int[] mTempXY = new int[2];
+ protected final int[] mTempXY = new int[2];
private final float[] mTempFXY = new float[2];
private final Rect mTempRect = new Rect();
@Thunk float[] mDragViewVisualCenter = new float[2];
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java
index 0264ae2..09fe740 100644
--- a/src/com/android/launcher3/dragndrop/DragView.java
+++ b/src/com/android/launcher3/dragndrop/DragView.java
@@ -363,7 +363,10 @@
// If the content is already removed, ignore
return;
}
- View newContent = getViewFromDrawable(getContext(), crossFadeDrawable);
+ ImageView newContent = getViewFromDrawable(getContext(), crossFadeDrawable);
+ // We need to fill the ImageView with the content, otherwise the shapes of the final view
+ // and the drag view might not match exactly
+ newContent.setScaleType(ImageView.ScaleType.FIT_XY);
newContent.measure(makeMeasureSpec(mWidth, EXACTLY), makeMeasureSpec(mHeight, EXACTLY));
newContent.layout(0, 0, mWidth, mHeight);
addViewInLayout(newContent, 0, new LayoutParams(mWidth, mHeight));
@@ -573,7 +576,7 @@
}
}
- private static View getViewFromDrawable(Context context, Drawable drawable) {
+ private static ImageView getViewFromDrawable(Context context, Drawable drawable) {
ImageView iv = new ImageView(context);
iv.setImageDrawable(drawable);
return iv;
diff --git a/src/com/android/launcher3/testing/HotseatCellCenterRequest.java b/src/com/android/launcher3/testing/HotseatCellCenterRequest.java
new file mode 100644
index 0000000..cbb847e
--- /dev/null
+++ b/src/com/android/launcher3/testing/HotseatCellCenterRequest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package com.android.launcher3.testing;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Request object for querying a hotseat cell region in Rect.
+ */
+public class HotseatCellCenterRequest implements TestInformationRequest {
+ public final int cellInd;
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(cellInd);
+ }
+
+ @Override
+ public String getRequestName() {
+ return TestProtocol.REQUEST_HOTSEAT_CELL_CENTER;
+ }
+
+ public static final Parcelable.Creator<HotseatCellCenterRequest> CREATOR =
+ new Parcelable.Creator<HotseatCellCenterRequest>() {
+
+ @Override
+ public HotseatCellCenterRequest createFromParcel(Parcel source) {
+ return new HotseatCellCenterRequest(source);
+ }
+
+ @Override
+ public HotseatCellCenterRequest[] newArray(int size) {
+ return new HotseatCellCenterRequest[size];
+ }
+ };
+
+ private HotseatCellCenterRequest(int cellInd) {
+ this.cellInd = cellInd;
+ }
+
+ private HotseatCellCenterRequest(Parcel in) {
+ this(in.readInt());
+ }
+
+ /**
+ * Create a builder for HotseatCellCenterRequest.
+ *
+ * @return HotseatCellCenterRequest builder.
+ */
+ public static HotseatCellCenterRequest.Builder builder() {
+ return new HotseatCellCenterRequest.Builder();
+ }
+
+ /**
+ * HotseatCellCenterRequest Builder.
+ */
+ public static final class Builder {
+ private int mCellInd;
+
+ private Builder() {
+ mCellInd = 0;
+ }
+
+ /**
+ * Set the index of hotseat cells.
+ */
+ public HotseatCellCenterRequest.Builder setCellInd(int i) {
+ this.mCellInd = i;
+ return this;
+ }
+
+ /**
+ * build the HotseatCellCenterRequest.
+ */
+ public HotseatCellCenterRequest build() {
+ return new HotseatCellCenterRequest(mCellInd);
+ }
+ }
+}
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
index 242d2d4..af4fb26 100644
--- a/src/com/android/launcher3/testing/TestInformationHandler.java
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -33,6 +33,7 @@
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.Hotseat;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
@@ -185,7 +186,7 @@
return new int[]{cellLayout.getCountX(), cellLayout.getCountY()};
});
- case TestProtocol.REQUEST_WORKSPACE_CELL_CENTER:
+ case TestProtocol.REQUEST_WORKSPACE_CELL_CENTER: {
final WorkspaceCellCenterRequest request = extra.getParcelable(
TestProtocol.TEST_INFO_REQUEST_FIELD);
return getLauncherUIProperty(Bundle::putParcelable, launcher -> {
@@ -197,6 +198,21 @@
cellLayout, request.cellX, request.cellY, request.spanX, request.spanY);
return new Point(cellRect.centerX(), cellRect.centerY());
});
+ }
+
+ case TestProtocol.REQUEST_HOTSEAT_CELL_CENTER: {
+ final HotseatCellCenterRequest request = extra.getParcelable(
+ TestProtocol.TEST_INFO_REQUEST_FIELD);
+ return getLauncherUIProperty(Bundle::putParcelable, launcher -> {
+ final Hotseat hotseat = launcher.getHotseat();
+ final Rect cellRect = getDescendantRectRelativeToDragLayerForCell(launcher,
+ hotseat, request.cellInd, /* cellY= */ 0,
+ /* spanX= */ 1, /* spanY= */ 1);
+ // TODO(b/234322284): return the real center point.
+ return new Point(cellRect.left + (cellRect.right - cellRect.left) / 3,
+ cellRect.centerY());
+ });
+ }
case TestProtocol.REQUEST_HAS_TIS: {
response.putBoolean(
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index b76e9d5..ca824e3 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -115,6 +115,8 @@
public static final String REQUEST_WORKSPACE_CELL_LAYOUT_SIZE = "workspace-cell-layout-size";
public static final String REQUEST_WORKSPACE_CELL_CENTER = "workspace-cell-center";
+ public static final String REQUEST_HOTSEAT_CELL_CENTER = "hotseat-cell-center";
+
public static final String REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET =
"get-focused-task-height-for-tablet";
public static final String REQUEST_GET_GRID_TASK_SIZE_RECT_FOR_TABLET =
diff --git a/src/com/android/launcher3/widget/picker/WidgetPagedView.java b/src/com/android/launcher3/widget/picker/WidgetPagedView.java
new file mode 100644
index 0000000..c95ec5f
--- /dev/null
+++ b/src/com/android/launcher3/widget/picker/WidgetPagedView.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+package com.android.launcher3.widget.picker;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+
+import com.android.launcher3.PagedView;
+import com.android.launcher3.workprofile.PersonalWorkPagedView;
+
+/**
+ * A {@link PagedView} for showing different widgets for the personal and work profile.
+ */
+public class WidgetPagedView extends PersonalWorkPagedView {
+
+ public WidgetPagedView(Context context) {
+ this(context, null);
+ }
+
+ public WidgetPagedView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public WidgetPagedView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ setPageSpacing(getPaddingLeft());
+ }
+
+ @Override
+ public void getDrawingRect(Rect outRect) {
+ super.getDrawingRect(outRect);
+ outRect.left += getPaddingLeft();
+ outRect.right -= getPaddingRight();
+ }
+}
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index ca39d2b..03bf4af 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -554,6 +554,18 @@
}
}
+ @Test
+ @PortraitLandscape
+ public void testAddDeleteShortcutOnHotseat() {
+ mLauncher.getWorkspace()
+ .deleteAppIcon(mLauncher.getWorkspace().getHotseatAppIcon(0))
+ .switchToAllApps()
+ .getAppIcon(APP_NAME)
+ .dragToHotseat(0);
+ mLauncher.getWorkspace().deleteAppIcon(
+ mLauncher.getWorkspace().getHotseatAppIcon(APP_NAME));
+ }
+
/**
* @return List of workspace grid coordinates. Those are not pixels. See {@link
* Workspace#getIconGridDimensions()}
diff --git a/tests/tapl/com/android/launcher3/tapl/HomeAppIcon.java b/tests/tapl/com/android/launcher3/tapl/HomeAppIcon.java
index 7546504..693baa0 100644
--- a/tests/tapl/com/android/launcher3/tapl/HomeAppIcon.java
+++ b/tests/tapl/com/android/launcher3/tapl/HomeAppIcon.java
@@ -22,6 +22,8 @@
import androidx.annotation.NonNull;
import androidx.test.uiautomator.UiObject2;
+import java.util.function.Supplier;
+
/**
* App icon on the workspace or all apps.
*/
@@ -100,9 +102,46 @@
}
}
+ /**
+ * Drag an object to the given cell in hotseat. The target cell should be expected to be empty.
+ *
+ * @param cellInd zero based index number of the hotseat cells.
+ * @return the workspace app icon.
+ */
+ @NonNull
+ public WorkspaceAppIcon dragToHotseat(int cellInd) {
+ try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
+ LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ String.format("want to drag the icon to hotseat cell %d", cellInd))
+ ) {
+ final Supplier<Point> dest = () -> Workspace.getHotseatCellCenter(mLauncher, cellInd);
+
+ Workspace.dragIconToHotseat(
+ mLauncher,
+ this,
+ dest,
+ () -> addExpectedEventsForLongClick(),
+ /*expectDropEvents= */ null);
+ try (LauncherInstrumentation.Closable ignore = mLauncher.addContextLayer("dragged")) {
+ WorkspaceAppIcon appIcon =
+ (WorkspaceAppIcon) mLauncher.getWorkspace().getHotseatAppIcon(mAppName);
+ mLauncher.assertTrue(
+ String.format("The %s icon should be in the hotseat cell %d.", mAppName,
+ cellInd),
+ appIcon.isInHotseatCell(cellInd));
+ return appIcon;
+ }
+ }
+ }
+
/** This method requires public access, however should not be called in tests. */
@Override
public Launchable getLaunchable() {
return this;
}
+
+ boolean isInHotseatCell(int cellInd) {
+ final Point center = Workspace.getHotseatCellCenter(mLauncher, cellInd);
+ return mObject.getVisibleBounds().contains(center.x, center.y);
+ }
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 42ba18c..5e5fdec 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -39,6 +39,7 @@
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
+import com.android.launcher3.testing.HotseatCellCenterRequest;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.testing.WorkspaceCellCenterRequest;
@@ -251,6 +252,24 @@
}
/**
+ * Returns an icon for the given cell; fails if the icon doesn't exist.
+ *
+ * @param cellInd zero based index number of the hotseat cells.
+ * @return app icon.
+ */
+ @NonNull
+ public HomeAppIcon getHotseatAppIcon(int cellInd) {
+ List<UiObject2> icons = mHotseat.findObjects(AppIcon.getAnyAppIconSelector());
+ final Point center = getHotseatCellCenter(mLauncher, cellInd);
+ return icons.stream()
+ .filter(icon -> icon.getVisibleBounds().contains(center.x, center.y))
+ .findFirst()
+ .map(icon -> new WorkspaceAppIcon(mLauncher, icon))
+ .orElseThrow(() ->
+ new AssertionError("Unable to get a hotseat icon on " + cellInd));
+ }
+
+ /**
* @return map of text -> center of the view. In case of icons with the same name, the one with
* lower x coordinate is selected.
*/
@@ -360,6 +379,11 @@
TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
+ static Point getHotseatCellCenter(LauncherInstrumentation launcher, int cellInd) {
+ return launcher.getTestInfo(HotseatCellCenterRequest.builder()
+ .setCellInd(cellInd).build()).getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ }
+
/**
* Finds folder icons in the current workspace.
*
@@ -471,6 +495,25 @@
() -> "Page scroll didn't happen", "Scrolling page");
}
+ static void dragIconToHotseat(
+ LauncherInstrumentation launcher,
+ Launchable launchable,
+ Supplier<Point> dest,
+ Runnable expectLongClickEvents,
+ @Nullable Runnable expectDropEvents) {
+ final long downTime = SystemClock.uptimeMillis();
+ Point dragStart = launchable.startDrag(
+ downTime,
+ expectLongClickEvents,
+ /* runToSpringLoadedState= */ true);
+ Point targetDest = dest.get();
+
+ launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, true,
+ downTime, SystemClock.uptimeMillis(), false,
+ LauncherInstrumentation.GestureScope.INSIDE);
+ dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents);
+ }
+
/**
* Flings to get to screens on the right. Waits for scrolling and a possible overscroll
* recoil to complete.