Merge "Removing unused wallpaper-scrim feature" into udc-dev
diff --git a/protos/launcher_atom.proto b/protos/launcher_atom.proto
index 55301ff..cebcd42 100644
--- a/protos/launcher_atom.proto
+++ b/protos/launcher_atom.proto
@@ -135,7 +135,7 @@
}
}
-// Next value 45
+// Next value 48
enum Attribute {
option allow_alias = true;
@@ -187,6 +187,11 @@
ALL_APPS_SEARCH_RESULT_SYSTEM_POINTER = 42;
ALL_APPS_SEARCH_RESULT_EDUCARD = 43;
+ // Result sources
+ DATA_SOURCE_APPSEARCH_APP_PREVIEW = 45;
+ DATA_SOURCE_APPSEARCH_APP_SRP_PREVIEW = 46;
+ DATA_SOURCE_AIAI_SEARCH_ROOT = 47;
+
// Web suggestions provided by AGA
ALL_APPS_SEARCH_RESULT_WEB_SUGGEST = 39;
diff --git a/quickstep/res/drawable-sw600dp-land/gesture_tutorial_home_step_shape.xml b/quickstep/res/drawable-sw600dp-land/gesture_tutorial_home_step_shape.xml
index 4cccd09..fd14d34 100644
--- a/quickstep/res/drawable-sw600dp-land/gesture_tutorial_home_step_shape.xml
+++ b/quickstep/res/drawable-sw600dp-land/gesture_tutorial_home_step_shape.xml
@@ -17,11 +17,7 @@
android:height="67dp"
android:viewportWidth="232"
android:viewportHeight="67">
- <group>
- <clip-path
- android:pathData="M0,0h232v67h-232z"/>
- <path
- android:pathData="M180.9,0.6H51.1C22.9,0.6 0,23.4 0,51.7V67.6H232V51.7C232,23.4 209.1,0.6 180.9,0.6Z"
- android:fillColor="#4B67AE"/>
- </group>
+ <path
+ android:pathData="M180.9,0.6H51.1C22.9,0.6 0,23.4 0,51.7V67.6H232V51.7C232,23.4 209.1,0.6 180.9,0.6Z"
+ android:fillColor="#4B67AE"/>
</vector>
diff --git a/quickstep/res/drawable-sw600dp-land/gesture_tutorial_overview_step_shape.xml b/quickstep/res/drawable-sw600dp-land/gesture_tutorial_overview_step_shape.xml
index 7011f6c..f271c47 100644
--- a/quickstep/res/drawable-sw600dp-land/gesture_tutorial_overview_step_shape.xml
+++ b/quickstep/res/drawable-sw600dp-land/gesture_tutorial_overview_step_shape.xml
@@ -17,11 +17,7 @@
android:height="94dp"
android:viewportWidth="194"
android:viewportHeight="94">
- <group>
- <clip-path
- android:pathData="M0,0h194v94.09h-194z"/>
- <path
- android:pathData="M185.56,76.95C184.79,75.3 184.3,73.56 184.21,71.81L182.85,55.81C182.46,51.34 180.13,47.27 176.45,44.65L163.25,35.44C161.8,34.37 160.54,33.11 159.47,31.65L150.16,18.46C147.54,14.77 143.47,12.45 139,12.06L123,10.6C121.25,10.41 119.51,10.02 117.86,9.24L103.31,2.45C101.27,1.49 99.04,1 96.91,1C94.77,1 92.54,1.49 90.5,2.45L75.95,9.24C74.31,10.02 72.56,10.51 70.81,10.6L54.81,11.96C50.35,12.35 46.27,14.68 43.65,18.36L34.44,31.56C33.37,33.01 32.11,34.27 30.66,35.34L17.27,44.65C13.58,47.27 11.26,51.34 10.87,55.81L9.41,71.81C9.22,73.56 8.83,75.3 8.05,76.95L1.26,91.5C0.78,92.67 0.39,93.83 0.1,94.99H193.52C193.32,93.83 192.94,92.57 192.35,91.5L185.56,76.95Z"
- android:fillColor="#7E44AD"/>
- </group>
+ <path
+ android:pathData="M185.56,76.95C184.79,75.3 184.3,73.56 184.21,71.81L182.85,55.81C182.46,51.34 180.13,47.27 176.45,44.65L163.25,35.44C161.8,34.37 160.54,33.11 159.47,31.65L150.16,18.46C147.54,14.77 143.47,12.45 139,12.06L123,10.6C121.25,10.41 119.51,10.02 117.86,9.24L103.31,2.45C101.27,1.49 99.04,1 96.91,1C94.77,1 92.54,1.49 90.5,2.45L75.95,9.24C74.31,10.02 72.56,10.51 70.81,10.6L54.81,11.96C50.35,12.35 46.27,14.68 43.65,18.36L34.44,31.56C33.37,33.01 32.11,34.27 30.66,35.34L17.27,44.65C13.58,47.27 11.26,51.34 10.87,55.81L9.41,71.81C9.22,73.56 8.83,75.3 8.05,76.95L1.26,91.5C0.78,92.67 0.39,93.83 0.1,94.99H193.52C193.32,93.83 192.94,92.57 192.35,91.5L185.56,76.95Z"
+ android:fillColor="#7E44AD"/>
</vector>
diff --git a/quickstep/res/drawable-sw720dp-land/gesture_tutorial_home_step_shape.xml b/quickstep/res/drawable-sw720dp-land/gesture_tutorial_home_step_shape.xml
index 5becb8b..3e71a3d 100644
--- a/quickstep/res/drawable-sw720dp-land/gesture_tutorial_home_step_shape.xml
+++ b/quickstep/res/drawable-sw720dp-land/gesture_tutorial_home_step_shape.xml
@@ -17,11 +17,7 @@
android:height="73dp"
android:viewportWidth="362"
android:viewportHeight="73">
- <group>
- <clip-path
- android:pathData="M0,0h362v73h-362z"/>
- <path
- android:pathData="M282.3,0H79.7C38,0 3.7,32.1 0.3,73H361.7C358.3,32.1 324,0 282.3,0Z"
- android:fillColor="#4B67AE"/>
- </group>
+ <path
+ android:pathData="M282.3,0H79.7C38,0 3.7,32.1 0.3,73H361.7C358.3,32.1 324,0 282.3,0Z"
+ android:fillColor="#4B67AE"/>
</vector>
diff --git a/quickstep/res/drawable-sw720dp-land/gesture_tutorial_overview_step_shape.xml b/quickstep/res/drawable-sw720dp-land/gesture_tutorial_overview_step_shape.xml
index 7143089..2f11192 100644
--- a/quickstep/res/drawable-sw720dp-land/gesture_tutorial_overview_step_shape.xml
+++ b/quickstep/res/drawable-sw720dp-land/gesture_tutorial_overview_step_shape.xml
@@ -17,11 +17,7 @@
android:height="144dp"
android:viewportWidth="297"
android:viewportHeight="144">
- <group>
- <clip-path
- android:pathData="M0,0h297v144.04h-297z"/>
- <path
- android:pathData="M284.38,116.48C283.19,113.95 282.45,111.28 282.3,108.61L280.22,84.1C279.63,77.27 276.06,71.03 270.42,67.03L250.22,52.92C247.99,51.28 246.06,49.35 244.43,47.13L230.18,26.93C226.16,21.29 219.93,17.72 213.1,17.13L188.6,14.9C185.92,14.6 183.25,14.01 180.72,12.82L158.45,2.43C155.33,0.94 151.91,0.2 148.65,0.2C145.38,0.2 141.97,0.94 138.85,2.43L116.57,12.82C114.05,14.01 111.38,14.75 108.7,14.9L84.2,16.98C77.37,17.57 71.13,21.14 67.12,26.78L53.01,46.98C51.38,49.21 49.45,51.14 47.22,52.77L26.73,67.03C21.09,71.03 17.52,77.27 16.93,84.1L14.7,108.61C14.4,111.28 13.81,113.95 12.62,116.48L2.23,138.75C1.48,140.53 0.89,142.32 0.45,144.1H296.55C296.26,142.32 295.66,140.38 294.77,138.75L284.38,116.48Z"
- android:fillColor="#7E44AD"/>
- </group>
+ <path
+ android:pathData="M284.38,116.48C283.19,113.95 282.45,111.28 282.3,108.61L280.22,84.1C279.63,77.27 276.06,71.03 270.42,67.03L250.22,52.92C247.99,51.28 246.06,49.35 244.43,47.13L230.18,26.93C226.16,21.29 219.93,17.72 213.1,17.13L188.6,14.9C185.92,14.6 183.25,14.01 180.72,12.82L158.45,2.43C155.33,0.94 151.91,0.2 148.65,0.2C145.38,0.2 141.97,0.94 138.85,2.43L116.57,12.82C114.05,14.01 111.38,14.75 108.7,14.9L84.2,16.98C77.37,17.57 71.13,21.14 67.12,26.78L53.01,46.98C51.38,49.21 49.45,51.14 47.22,52.77L26.73,67.03C21.09,71.03 17.52,77.27 16.93,84.1L14.7,108.61C14.4,111.28 13.81,113.95 12.62,116.48L2.23,138.75C1.48,140.53 0.89,142.32 0.45,144.1H296.55C296.26,142.32 295.66,140.38 294.77,138.75L284.38,116.48Z"
+ android:fillColor="#7E44AD"/>
</vector>
diff --git a/quickstep/res/drawable/gesture_tutorial_back_step_shape.xml b/quickstep/res/drawable/gesture_tutorial_back_step_shape.xml
index 68c5eb1..5f951e4 100644
--- a/quickstep/res/drawable/gesture_tutorial_back_step_shape.xml
+++ b/quickstep/res/drawable/gesture_tutorial_back_step_shape.xml
@@ -17,11 +17,7 @@
android:height="208dp"
android:viewportWidth="83"
android:viewportHeight="208">
- <group>
- <clip-path
- android:pathData="M0,0h83.95v208h-83.95z"/>
- <path
- android:pathData="M23.53,169.2L31.09,165.56C76.7,143.55 76.7,64.45 31.09,42.35L23.53,38.71C13.55,33.95 5.06,25.56 -1,14.92V193.08C5.06,182.44 13.55,174.05 23.53,169.2Z"
- android:fillColor="#217500"/>
- </group>
+ <path
+ android:pathData="M23.53,169.2L31.09,165.56C76.7,143.55 76.7,64.45 31.09,42.35L23.53,38.71C13.55,33.95 5.06,25.56 -1,14.92V193.08C5.06,182.44 13.55,174.05 23.53,169.2Z"
+ android:fillColor="#217500"/>
</vector>
diff --git a/quickstep/res/layout-sw600dp-land/gesture_tutorial_step_menu.xml b/quickstep/res/layout-sw600dp-land/gesture_tutorial_step_menu.xml
index 39c7e73..d24219d 100644
--- a/quickstep/res/layout-sw600dp-land/gesture_tutorial_step_menu.xml
+++ b/quickstep/res/layout-sw600dp-land/gesture_tutorial_step_menu.xml
@@ -28,11 +28,13 @@
android:layout_width="0dp"
android:layout_height="@dimen/gesture_tutorial_menu_button_height"
android:layout_marginEnd="@dimen/gesture_tutorial_menu_button_spacing"
+ android:layout_marginBottom="24dp"
android:background="@drawable/gesture_tutorial_menu_button_background"
android:clipToOutline="true"
android:backgroundTint="@color/gesture_home_tutorial_background"
app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/guideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/gesture_tutorial_menu_back_button">
@@ -40,6 +42,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gesture_tutorial_home_step_shape"
+ android:scaleType="fitXY"
+ android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -64,11 +68,13 @@
android:layout_width="0dp"
android:layout_height="@dimen/gesture_tutorial_menu_button_height"
android:layout_marginEnd="@dimen/gesture_tutorial_menu_button_spacing"
+ android:layout_marginBottom="24dp"
android:background="@drawable/gesture_tutorial_menu_button_background"
android:clipToOutline="true"
android:backgroundTint="@color/gesture_back_tutorial_exiting_app"
app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/guideline"
app:layout_constraintStart_toEndOf="@id/gesture_tutorial_menu_home_button"
app:layout_constraintEnd_toStartOf="@id/gesture_tutorial_menu_overview_button">
@@ -77,6 +83,8 @@
android:layout_height="wrap_content"
android:src="@drawable/gesture_tutorial_back_step_shape"
android:layout_marginBottom="@dimen/gesture_tutorial_menu_back_shape_bottom_margin"
+ android:scaleType="fitXY"
+ android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
@@ -99,11 +107,13 @@
android:id="@+id/gesture_tutorial_menu_overview_button"
android:layout_width="0dp"
android:layout_height="@dimen/gesture_tutorial_menu_button_height"
+ android:layout_marginBottom="24dp"
android:background="@drawable/gesture_tutorial_menu_button_background"
android:clipToOutline="true"
android:backgroundTint="@color/gesture_overview_tutorial_background"
app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/guideline"
app:layout_constraintStart_toEndOf="@id/gesture_tutorial_menu_back_button"
app:layout_constraintEnd_toEndOf="parent">
@@ -111,6 +121,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gesture_tutorial_overview_step_shape"
+ android:scaleType="fitXY"
+ android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -142,10 +154,8 @@
style="@style/TextAppearance.GestureTutorial.ButtonLabel"
android:id="@+id/gesture_tutorial_menu_done_button"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingVertical="16dp"
- android:paddingHorizontal="26dp"
- android:layout_marginVertical="@dimen/gesture_tutorial_menu_done_button_margin"
+ android:layout_height="40dp"
+ android:layout_marginVertical="16dp"
android:text="@string/gesture_tutorial_action_button_label"
android:background="@drawable/gesture_tutorial_action_button_background"
android:stateListAnimator="@null"
diff --git a/quickstep/res/layout/gesture_tutorial_step_menu.xml b/quickstep/res/layout/gesture_tutorial_step_menu.xml
index 2836259..cf1e4d7 100644
--- a/quickstep/res/layout/gesture_tutorial_step_menu.xml
+++ b/quickstep/res/layout/gesture_tutorial_step_menu.xml
@@ -42,6 +42,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gesture_tutorial_home_step_shape"
+ android:scaleType="fitXY"
+ android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -79,6 +81,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gesture_tutorial_back_step_shape"
+ android:scaleType="fitXY"
+ android:adjustViewBounds="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
@@ -116,6 +120,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gesture_tutorial_overview_step_shape"
+ android:scaleType="fitXY"
+ android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -147,9 +153,8 @@
style="@style/TextAppearance.GestureTutorial.ButtonLabel"
android:id="@+id/gesture_tutorial_menu_done_button"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingVertical="16dp"
- android:paddingHorizontal="26dp"
+ android:layout_height="40dp"
+ android:layout_marginVertical="16dp"
android:text="@string/gesture_tutorial_action_button_label"
android:background="@drawable/gesture_tutorial_action_button_background"
android:stateListAnimator="@null"
diff --git a/quickstep/res/layout/transient_taskbar.xml b/quickstep/res/layout/transient_taskbar.xml
index 62c6933..bf4b811 100644
--- a/quickstep/res/layout/transient_taskbar.xml
+++ b/quickstep/res/layout/transient_taskbar.xml
@@ -38,6 +38,20 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>
+ <com.android.launcher3.taskbar.bubbles.BubbleBarView
+ android:id="@+id/taskbar_bubbles"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/bubblebar_size"
+ android:layout_gravity="bottom|end"
+ android:layout_marginEnd="@dimen/transient_taskbar_bottom_margin"
+ android:layout_marginBottom="@dimen/transient_taskbar_bottom_margin"
+ android:paddingEnd="@dimen/taskbar_icon_spacing"
+ android:paddingStart="@dimen/taskbar_icon_spacing"
+ android:visibility="gone"
+ android:gravity="center"
+ android:clipChildren="false"
+ />
+
<FrameLayout
android:id="@+id/navbuttons_view"
android:layout_width="match_parent"
@@ -74,10 +88,20 @@
<com.android.launcher3.taskbar.StashedHandleView
android:id="@+id/stashed_handle"
tools:comment1="The actual size and shape will be set as a ViewOutlineProvider at runtime"
- android:layout_width="match_parent"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/taskbar_stashed_handle_dark_color"
android:clipToOutline="true"
android:layout_gravity="bottom"/>
+ <com.android.launcher3.taskbar.StashedHandleView
+ android:id="@+id/stashed_bubble_handle"
+ tools:comment1="The actual size and shape will be set as a ViewOutlineProvider at runtime"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ android:background="@color/taskbar_stashed_handle_dark_color"
+ android:clipToOutline="true"
+ android:layout_gravity="bottom"/>
+
</com.android.launcher3.taskbar.TaskbarDragLayer>
\ No newline at end of file
diff --git a/quickstep/res/values-sw600dp-land/dimens.xml b/quickstep/res/values-sw600dp-land/dimens.xml
index 9853140..9cb3fec 100644
--- a/quickstep/res/values-sw600dp-land/dimens.xml
+++ b/quickstep/res/values-sw600dp-land/dimens.xml
@@ -26,6 +26,5 @@
<dimen name="gesture_tutorial_menu_button_spacing">24dp</dimen>
<dimen name="gesture_tutorial_menu_done_button_top_spacing">40dp</dimen>
<dimen name="gesture_tutorial_menu_back_shape_bottom_margin">49dp</dimen>
- <dimen name="gesture_tutorial_menu_done_button_margin">16dp</dimen>
</resources>
diff --git a/quickstep/res/values-sw720dp-land/dimens.xml b/quickstep/res/values-sw720dp-land/dimens.xml
index 1d02ab5..4634a2d 100644
--- a/quickstep/res/values-sw720dp-land/dimens.xml
+++ b/quickstep/res/values-sw720dp-land/dimens.xml
@@ -21,7 +21,5 @@
<dimen name="gesture_tutorial_menu_button_spacing">49dp</dimen>
<dimen name="gesture_tutorial_menu_done_button_top_spacing">24dp</dimen>
<dimen name="gesture_tutorial_menu_back_shape_bottom_margin">21dp</dimen>
- <dimen name="gesture_tutorial_menu_done_button_spacing">80dp</dimen>
- <dimen name="gesture_tutorial_menu_done_button_margin">0dp</dimen>
</resources>
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 6c7decd..d69b155 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -134,7 +134,6 @@
<dimen name="gesture_tutorial_menu_done_button_top_spacing">0dp</dimen>
<dimen name="gesture_tutorial_menu_back_shape_bottom_margin">0dp</dimen>
<dimen name="gesture_tutorial_menu_done_button_spacing">72dp</dimen>
- <dimen name="gesture_tutorial_menu_done_button_margin">0dp</dimen>
<!-- Gesture Tutorial mock conversations -->
<dimen name="gesture_tutorial_message_icon_size">44dp</dimen>
@@ -292,6 +291,8 @@
<dimen name="taskbar_stashed_small_screen">108dp</dimen>
<dimen name="taskbar_unstash_input_area">316dp</dimen>
<dimen name="taskbar_stashed_handle_height">4dp</dimen>
+ <dimen name="taskbar_stashed_screen_edge_hover_deadzone_height">10dp</dimen>
+ <dimen name="taskbar_stashed_below_hover_deadzone_height">1dp</dimen>
<dimen name="taskbar_edu_horizontal_margin">112dp</dimen>
<dimen name="taskbar_nav_buttons_width_kids">88dp</dimen>
<dimen name="taskbar_nav_buttons_height_kids">40dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index 45163cb..682fccd 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -1086,7 +1086,7 @@
* Adds remote animations to a {@link RemoteAnimationDefinition}. May be overridden to add
* additional animations.
*/
- protected void addRemoteAnimations(RemoteAnimationDefinition definition) {
+ private void addRemoteAnimations(RemoteAnimationDefinition definition) {
mWallpaperOpenRunner = createWallpaperOpenRunner(false /* fromUnlock */);
definition.addRemoteAnimation(WindowManager.TRANSIT_OLD_WALLPAPER_OPEN,
WindowConfiguration.ACTIVITY_TYPE_STANDARD,
@@ -1151,7 +1151,7 @@
SystemUiProxy.INSTANCE.get(mLauncher).setStartingWindowListener(null);
}
- protected void unregisterRemoteAnimations() {
+ private void unregisterRemoteAnimations() {
if (SEPARATE_RECENTS_ACTIVITY.get()) {
return;
}
@@ -1165,7 +1165,7 @@
}
}
- private void unregisterRemoteTransitions() {
+ protected void unregisterRemoteTransitions() {
if (ENABLE_SHELL_TRANSITIONS) {
SystemUiProxy.INSTANCE.get(mLauncher).unshareTransactionQueue();
}
@@ -1448,7 +1448,6 @@
*/
private Animator getFallbackClosingWindowAnimators(RemoteAnimationTarget[] appTargets) {
final int rotationChange = getRotationChange(appTargets);
- SurfaceTransactionApplier surfaceApplier = new SurfaceTransactionApplier(mDragLayer);
Matrix matrix = new Matrix();
Point tmpPos = new Point();
Rect tmpRect = new Rect();
@@ -1504,7 +1503,7 @@
.setAlpha(1f);
}
}
- surfaceApplier.scheduleApply(transaction);
+ transaction.getTransaction().apply();
}
});
@@ -1592,7 +1591,8 @@
boolean playFallBackAnimation = (launcherView == null
&& launcherIsForceInvisibleOrOpening)
|| mLauncher.getWorkspace().isOverlayShown()
- || hasMultipleTargetsWithMode(appTargets, MODE_CLOSING);
+ || hasMultipleTargetsWithMode(appTargets, MODE_CLOSING)
+ || mLauncher.isDestroyed();
boolean playWorkspaceReveal = true;
boolean skipAllAppsScale = false;
diff --git a/quickstep/src/com/android/launcher3/taskbar/DesktopNavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/DesktopNavbarButtonsViewController.java
index 268024f..885afff 100644
--- a/quickstep/src/com/android/launcher3/taskbar/DesktopNavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/DesktopNavbarButtonsViewController.java
@@ -47,9 +47,7 @@
mStartContextualContainer = mNavButtonsView.findViewById(R.id.start_contextual_buttons);
mAllAppsButton = LayoutInflater.from(context)
.inflate(R.layout.taskbar_all_apps_button, mStartContextualContainer, false);
- mAllAppsButton.setOnClickListener((View v) -> {
- mControllers.taskbarAllAppsController.show();
- });
+ mAllAppsButton.setOnClickListener(v -> mControllers.taskbarAllAppsController.toggle());
}
/**
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 7e0530b..d94d8f7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -24,6 +24,7 @@
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
+import static com.android.launcher3.AbstractFloatingView.TYPE_TASKBAR_OVERLAY_PROXY;
import static com.android.launcher3.Utilities.isRunningInTestHarness;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING;
@@ -83,6 +84,12 @@
import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.AutohideSuspendFlag;
import com.android.launcher3.taskbar.TaskbarTranslationController.TransitionCallback;
import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController;
+import com.android.launcher3.taskbar.bubbles.BubbleBarController;
+import com.android.launcher3.taskbar.bubbles.BubbleBarView;
+import com.android.launcher3.taskbar.bubbles.BubbleBarViewController;
+import com.android.launcher3.taskbar.bubbles.BubbleControllers;
+import com.android.launcher3.taskbar.bubbles.BubbleStashController;
+import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.shared.TestProtocol;
@@ -106,6 +113,7 @@
import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;
import java.io.PrintWriter;
+import java.util.Optional;
/**
* The {@link ActivityContext} with which we inflate Taskbar-related Views. This allows UI elements
@@ -195,11 +203,23 @@
TaskbarScrimView taskbarScrimView = mDragLayer.findViewById(R.id.taskbar_scrim);
FrameLayout navButtonsView = mDragLayer.findViewById(R.id.navbuttons_view);
StashedHandleView stashedHandleView = mDragLayer.findViewById(R.id.stashed_handle);
+ BubbleBarView bubbleBarView = mDragLayer.findViewById(R.id.taskbar_bubbles);
+ StashedHandleView bubbleHandleView = mDragLayer.findViewById(R.id.stashed_bubble_handle);
mAccessibilityDelegate = new TaskbarShortcutMenuAccessibilityDelegate(this);
final boolean isDesktopMode = getPackageManager().hasSystemFeature(FEATURE_PC);
+ // If Bubble bar is present, TaskbarControllers depends on it so build it first.
+ Optional<BubbleControllers> bubbleControllersOptional = Optional.empty();
+ if (BubbleBarController.BUBBLE_BAR_ENABLED) {
+ bubbleControllersOptional = Optional.of(new BubbleControllers(
+ new BubbleBarController(this, bubbleBarView),
+ new BubbleBarViewController(this, bubbleBarView),
+ new BubbleStashController(this),
+ new BubbleStashedHandleViewController(this, bubbleHandleView)));
+ }
+
// Construct controllers.
mControllers = new TaskbarControllers(this,
new TaskbarDragController(this),
@@ -239,7 +259,8 @@
: TaskbarRecentAppsController.DEFAULT,
new TaskbarEduTooltipController(this),
new KeyboardQuickSwitchController(),
- new TaskbarDividerPopupController(this));
+ new TaskbarDividerPopupController(this),
+ bubbleControllersOptional);
}
public void init(@NonNull TaskbarSharedState sharedState) {
@@ -661,7 +682,10 @@
void onDragEndOrViewRemoved() {
boolean isDragInProgress = mControllers.taskbarDragController.isSystemDragInProgress();
- if (!isDragInProgress && !AbstractFloatingView.hasOpenView(this, TYPE_ALL)) {
+ // Overlay AFVs are in a separate window and do not require Taskbar to be fullscreen.
+ if (!isDragInProgress
+ && !AbstractFloatingView.hasOpenView(
+ this, TYPE_ALL & ~TYPE_TASKBAR_OVERLAY_PROXY)) {
// Reverts Taskbar window to its original size
setTaskbarWindowFullscreen(false);
}
@@ -773,6 +797,7 @@
}
protected void onTaskbarIconClicked(View view) {
+ boolean shouldCloseAllOpenViews = true;
Object tag = view.getTag();
if (tag instanceof Task) {
Task task = (Task) tag;
@@ -780,6 +805,7 @@
ActivityOptions.makeBasic());
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
} else if (tag instanceof FolderInfo) {
+ shouldCloseAllOpenViews = false;
FolderIcon folderIcon = (FolderIcon) view;
Folder folder = folderIcon.getFolder();
@@ -876,7 +902,9 @@
Log.e(TAG, "Unknown type clicked: " + tag);
}
- AbstractFloatingView.closeAllOpenViews(this);
+ if (shouldCloseAllOpenViews) {
+ AbstractFloatingView.closeAllOpenViews(this);
+ }
}
/**
@@ -929,6 +957,13 @@
}
/**
+ * Returns whether the taskbar is currently visually stashed.
+ */
+ public boolean isTaskbarStashed() {
+ return mControllers.taskbarStashController.isStashed();
+ }
+
+ /**
* Called when we detect a long press in the nav region before passing the gesture slop.
* @return Whether taskbar handled the long press, and thus should cancel the gesture.
*/
@@ -972,10 +1007,23 @@
/**
* Called when we detect a motion down or up/cancel in the nav region while stashed.
+ *
* @param animateForward Whether to animate towards the unstashed hint state or back to stashed.
*/
public void startTaskbarUnstashHint(boolean animateForward) {
- mControllers.taskbarStashController.startUnstashHint(animateForward);
+ // TODO(b/270395798): Clean up forceUnstash after removing long-press unstashing code.
+ startTaskbarUnstashHint(animateForward, /* forceUnstash = */ false);
+ }
+
+ /**
+ * Called when we detect a motion down or up/cancel in the nav region while stashed.
+ *
+ * @param animateForward Whether to animate towards the unstashed hint state or back to stashed.
+ * @param forceUnstash Whether we force the unstash hint.
+ */
+ public void startTaskbarUnstashHint(boolean animateForward, boolean forceUnstash) {
+ // TODO(b/270395798): Clean up forceUnstash after removing long-press unstashing code.
+ mControllers.taskbarStashController.startUnstashHint(animateForward, forceUnstash);
}
/**
@@ -1123,4 +1171,9 @@
public int getTaskbarAllAppsScroll() {
return mControllers.taskbarAllAppsController.getTaskbarAllAppsScroll();
}
+
+ @VisibleForTesting
+ public float getStashedTaskbarScale() {
+ return mControllers.stashedHandleViewController.getStashedHandleHintScale().value;
+ }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
index 1cd6f50..66c2eb3 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
@@ -23,12 +23,14 @@
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController;
+import com.android.launcher3.taskbar.bubbles.BubbleControllers;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController;
import com.android.systemui.shared.rotation.RotationButtonController;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
/**
* Hosts various taskbar controllers to facilitate passing between one another.
@@ -61,6 +63,7 @@
public final TaskbarEduTooltipController taskbarEduTooltipController;
public final KeyboardQuickSwitchController keyboardQuickSwitchController;
public final TaskbarDividerPopupController taskbarPinningController;
+ public final Optional<BubbleControllers> bubbleControllers;
@Nullable private LoggableTaskbarController[] mControllersToLog = null;
@Nullable private BackgroundRendererController[] mBackgroundRendererControllers = null;
@@ -107,7 +110,8 @@
TaskbarRecentAppsController taskbarRecentAppsController,
TaskbarEduTooltipController taskbarEduTooltipController,
KeyboardQuickSwitchController keyboardQuickSwitchController,
- TaskbarDividerPopupController taskbarPinningController) {
+ TaskbarDividerPopupController taskbarPinningController,
+ Optional<BubbleControllers> bubbleControllers) {
this.taskbarActivityContext = taskbarActivityContext;
this.taskbarDragController = taskbarDragController;
this.navButtonController = navButtonController;
@@ -133,6 +137,7 @@
this.taskbarEduTooltipController = taskbarEduTooltipController;
this.keyboardQuickSwitchController = keyboardQuickSwitchController;
this.taskbarPinningController = taskbarPinningController;
+ this.bubbleControllers = bubbleControllers;
}
/**
@@ -167,6 +172,7 @@
taskbarEduTooltipController.init(this);
keyboardQuickSwitchController.init(this);
taskbarPinningController.init(this);
+ bubbleControllers.ifPresent(controllers -> controllers.init(this));
mControllersToLog = new LoggableTaskbarController[] {
taskbarDragController, navButtonController, navbarButtonsViewController,
@@ -226,6 +232,7 @@
taskbarRecentAppsController.onDestroy();
keyboardQuickSwitchController.onDestroy();
taskbarStashController.onDestroy();
+ bubbleControllers.ifPresent(controllers -> controllers.onDestroy());
mControllersToLog = null;
mBackgroundRendererControllers = null;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
index 41093bd..72add4f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
@@ -308,15 +308,12 @@
// Pre-drag has ended, start the global system drag.
if (mDisallowGlobalDrag) {
AbstractFloatingView.closeAllOpenViewsExcept(mActivity, TYPE_TASKBAR_ALL_APPS);
- } else {
- AbstractFloatingView.closeAllOpenViews(mActivity);
+ return;
}
-
startSystemDrag((BubbleTextView) mDragObject.originalView);
}
private void startSystemDrag(BubbleTextView btv) {
- if (mDisallowGlobalDrag) return;
View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(btv) {
@Override
@@ -412,6 +409,9 @@
.log(StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED);
}
}
+
+ // Wait to close until after system drag has started, if applicable.
+ AbstractFloatingView.closeAllOpenViews(mActivity);
}
private void onSystemDragStarted(BubbleTextView btv) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
index 19b9a18..4422fd4 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
@@ -34,8 +34,6 @@
import android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD
import android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION
import com.android.internal.policy.GestureNavigationSettingsObserver
-import com.android.launcher3.AbstractFloatingView
-import com.android.launcher3.AbstractFloatingView.TYPE_TASKBAR_OVERLAY_PROXY
import com.android.launcher3.DeviceProfile
import com.android.launcher3.R
import com.android.launcher3.anim.AlphaUpdateListener
@@ -190,7 +188,7 @@
/**
* Called to update the touchable insets.
*
- * @see InternalInsetsInfo.setTouchableInsets
+ * @see ViewTreeObserver.InternalInsetsInfo.setTouchableInsets
*/
fun updateInsetsTouchability(insetsInfo: ViewTreeObserver.InternalInsetsInfo) {
insetsInfo.touchableRegion.setEmpty()
@@ -205,7 +203,7 @@
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
} else if (
controllers.navbarButtonsViewController.isImeVisible &&
- controllers.taskbarStashController.isStashed()
+ controllers.taskbarStashController.isStashed
) {
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
} else if (!controllers.uiController.isTaskbarTouchable) {
@@ -214,26 +212,16 @@
} else if (controllers.taskbarDragController.isSystemDragInProgress) {
// Let touches pass through us.
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
- } else if (AbstractFloatingView.hasOpenView(context, TYPE_TASKBAR_OVERLAY_PROXY)) {
- // Let touches pass through us if icons are hidden.
- if (controllers.taskbarViewController.areIconsVisible()) {
- insetsInfo.touchableRegion.set(touchableRegion)
- }
- insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
+ } else if (context.isTaskbarWindowFullscreen) {
+ // Intercept entire fullscreen window.
+ insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_FRAME)
+ insetsIsTouchableRegion = false
} else if (
- controllers.taskbarViewController.areIconsVisible() ||
- AbstractFloatingView.hasOpenView(context, AbstractFloatingView.TYPE_ALL) ||
- context.isNavBarKidsModeActive
+ controllers.taskbarViewController.areIconsVisible() || context.isNavBarKidsModeActive
) {
// Taskbar has some touchable elements, take over the full taskbar area
- insetsInfo.setTouchableInsets(
- if (context.isTaskbarWindowFullscreen) {
- TOUCHABLE_INSETS_FRAME
- } else {
- insetsInfo.touchableRegion.set(touchableRegion)
- TOUCHABLE_INSETS_REGION
- }
- )
+ insetsInfo.touchableRegion.set(touchableRegion)
+ insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
insetsIsTouchableRegion = false
} else {
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index ed78e2d..75cfd05 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -207,6 +207,10 @@
com.android.launcher3.taskbar.Utilities.setOverviewDragState(
mControllers, finalState.disallowTaskbarGlobalDrag(),
disallowLongClick, finalState.allowTaskbarInitialSplitSelection());
+ // LauncherTaskbarUIController depends on the state when checking whether
+ // to handle resume, so it should also be poked if current state changes
+ mLauncher.getTaskbarUIController().onLauncherResumedOrPaused(
+ mLauncher.hasBeenResumed());
}
};
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
index 5abeac7..a442849 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
@@ -176,9 +176,9 @@
deepShortcutCount,
mPopupDataProvider.getNotificationKeysForItem(item),
systemShortcuts);
- icon.clearAccessibilityFocus();
}
+ icon.clearAccessibilityFocus();
container.addOnAttachStateChangeListener(
new PopupLiveUpdateHandler<BaseTaskbarContext>(context, container) {
@Override
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index b2f9378..c2175f2 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -856,15 +856,18 @@
/**
* Creates and starts a partial unstash animation, hinting at the new state that will trigger
* when long press is detected.
+ *
* @param animateForward Whether we are going towards the new unstashed state or returning to
* the stashed state.
+ * @param forceUnstash Whether we force the unstash hint to animate.
*/
- public void startUnstashHint(boolean animateForward) {
+ protected void startUnstashHint(boolean animateForward, boolean forceUnstash) {
if (!isStashed()) {
// Already unstashed, no need to hint in that direction.
return;
}
- if (!canCurrentlyManuallyUnstash()) {
+ // TODO(b/270395798): Clean up after removing long-press unstashing code path.
+ if (!canCurrentlyManuallyUnstash() && !forceUnstash) {
// If any other flags are causing us to be stashed, long press won't cause us to
// unstash, so don't hint that it will.
return;
@@ -931,20 +934,6 @@
}
/**
- * Resets the flag if no system gesture is in progress.
- * <p>
- * Otherwise, the reset should be deferred until after the gesture is finished.
- *
- * @see #setSystemGestureInProgress
- */
- public void resetFlagIfNoGestureInProgress(int flag) {
- if (!mIsSystemGestureInProgress) {
- updateStateForFlag(flag, false);
- applyState(mControllers.taskbarOverlayController.getCloseDuration());
- }
- }
-
- /**
* When hiding the IME, delay the unstash animation to align with the end of the transition.
*/
private long getTaskbarStashStartDelayForIme() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt
index 2373142..1cc6672 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt
@@ -25,7 +25,7 @@
import com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL
import com.android.launcher3.util.DisplayController
import com.android.launcher3.util.TouchController
-import com.android.quickstep.inputconsumers.TaskbarStashInputConsumer
+import com.android.quickstep.inputconsumers.TaskbarUnstashInputConsumer
/**
* A helper [TouchController] for [TaskbarDragLayerController], specifically to handle touch events
@@ -34,7 +34,7 @@
* or [MotionEvent.ACTION_OUTSIDE].
* - Touches inside Transient Taskbar bounds will stash if it is detected as a swipe down gesture.
*
- * Note: touches to *unstash* Taskbar are handled by [TaskbarStashInputConsumer].
+ * Note: touches to *unstash* Taskbar are handled by [TaskbarUnstashInputConsumer].
*/
class TaskbarStashViaTouchController(val controllers: TaskbarControllers) : TouchController {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index a7e2daa..7429185 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -639,7 +639,7 @@
public View.OnClickListener getAllAppsButtonClickListener() {
return v -> {
mActivity.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP);
- mControllers.taskbarAllAppsController.show();
+ mControllers.taskbarAllAppsController.toggle();
};
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
index 623e234..b4b83f6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java
@@ -19,15 +19,21 @@
import android.util.AttributeSet;
import android.view.View;
+import androidx.annotation.Nullable;
+
import com.android.launcher3.R;
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext;
+import java.util.Optional;
+
/** All apps container accessible from taskbar. */
public class TaskbarAllAppsContainerView extends
ActivityAllAppsContainerView<TaskbarOverlayContext> {
+ private @Nullable OnInvalidateHeaderListener mOnInvalidateHeaderListener;
+
public TaskbarAllAppsContainerView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -36,6 +42,10 @@
super(context, attrs, defStyleAttr);
}
+ void setOnInvalidateHeaderListener(OnInvalidateHeaderListener onInvalidateHeaderListener) {
+ mOnInvalidateHeaderListener = onInvalidateHeaderListener;
+ }
+
@Override
protected View inflateSearchBox() {
if (isSearchSupported()) {
@@ -54,6 +64,13 @@
}
@Override
+ public void invalidateHeader() {
+ super.invalidateHeader();
+ Optional.ofNullable(mOnInvalidateHeaderListener).ifPresent(
+ OnInvalidateHeaderListener::onInvalidateHeader);
+ }
+
+ @Override
protected boolean isSearchSupported() {
return FeatureFlags.ENABLE_ALL_APPS_SEARCH_IN_TASKBAR.get();
}
@@ -63,4 +80,8 @@
// All apps is always open
return true;
}
+
+ interface OnInvalidateHeaderListener {
+ void onInvalidateHeader();
+ }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
index 4266c71..459a658 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
@@ -100,9 +100,13 @@
}
}
- /** Opens the {@link TaskbarAllAppsContainerView} in a new window. */
- public void show() {
- show(true);
+ /** Toggles visibility of {@link TaskbarAllAppsContainerView} in the overlay window. */
+ public void toggle() {
+ if (isOpen()) {
+ mSlideInView.close(true);
+ } else {
+ show(true);
+ }
}
/** Returns {@code true} if All Apps is open. */
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java
index f0d28df..cfa1027 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java
@@ -19,6 +19,7 @@
import android.animation.PropertyValuesHolder;
import android.content.Context;
+import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
@@ -99,12 +100,13 @@
mAppsView = findViewById(R.id.apps_view);
mContent = mAppsView;
+ // Setup header protection for search bar, if enabled.
+ if (FeatureFlags.ENABLE_ALL_APPS_SEARCH_IN_TASKBAR.get()) {
+ mAppsView.setOnInvalidateHeaderListener(this::invalidate);
+ }
+
DeviceProfile dp = mActivityContext.getDeviceProfile();
setShiftRange(dp.allAppsShiftRange);
-
- setContentBackgroundWithParent(
- getContext().getDrawable(R.drawable.bg_rounded_corner_bottom_sheet),
- mAppsView.getBottomSheetBackground());
}
@Override
@@ -137,6 +139,12 @@
}
@Override
+ protected void dispatchDraw(Canvas canvas) {
+ mAppsView.drawOnScrimWithScale(canvas, mSlideInViewScale.value);
+ super.dispatchDraw(canvas);
+ }
+
+ @Override
protected void onScaleProgressChanged() {
super.onScaleProgressChanged();
mAppsView.setClipChildren(!mIsBackProgressing);
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
index 7a3b3e8..01342af 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
@@ -16,7 +16,6 @@
package com.android.launcher3.taskbar.allapps;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_IN_TASKBAR_ALL_APPS;
-import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
import com.android.launcher3.AbstractFloatingView;
@@ -88,8 +87,10 @@
}
private void setUpTaskbarStashing() {
- mTaskbarStashController.updateStateForFlag(FLAG_STASHED_IN_TASKBAR_ALL_APPS, true);
- mTaskbarStashController.applyState(mOverlayController.getOpenDuration());
+ if (DisplayController.isTransientTaskbar(mContext)) {
+ mTaskbarStashController.updateStateForFlag(FLAG_STASHED_IN_TASKBAR_ALL_APPS, true);
+ mTaskbarStashController.applyState(mOverlayController.getOpenDuration());
+ }
mNavbarButtonsViewController.setSlideInViewVisible(true);
mSlideInView.setOnCloseBeginListener(() -> {
@@ -100,11 +101,6 @@
if (DisplayController.isTransientTaskbar(mContext)) {
mTaskbarStashController.updateStateForFlag(FLAG_STASHED_IN_TASKBAR_ALL_APPS, false);
mTaskbarStashController.applyState(mOverlayController.getCloseDuration());
- } else {
- // Post in case view is closing due to gesture navigation. If a gesture is in
- // progress, wait to unstash until after the gesture is finished.
- MAIN_EXECUTOR.post(() -> mTaskbarStashController.resetFlagIfNoGestureInProgress(
- FLAG_STASHED_IN_TASKBAR_ALL_APPS));
}
});
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBubble.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBubble.kt
index b1633e7..3cd5f75 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBubble.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBubble.kt
@@ -30,7 +30,5 @@
val appName: String
) {
- fun getKey(): String {
- return info.key
- }
+ val key: String = info.key
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
index 228aabd..6d19692 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
@@ -152,7 +152,9 @@
mContext = context;
mBarView = bubbleView; // Need the view for inflating bubble views.
- // TODO: register the listener with SysUiProxu
+ if (BUBBLE_BAR_ENABLED) {
+ SystemUiProxy.INSTANCE.get(context).setBubblesListener(this);
+ }
mMainExecutor = MAIN_EXECUTOR;
mLauncherApps = context.getSystemService(LauncherApps.class);
mIconFactory = new BubbleIconFactory(context,
@@ -164,7 +166,7 @@
}
public void onDestroy() {
- // TODO: unregister the listener with SysUiProxy
+ SystemUiProxy.INSTANCE.get(mContext).setBubblesListener(null);
}
public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers) {
@@ -358,7 +360,7 @@
Path dotPath;
int dotColor;
- boolean isImportantConvo = false; // TODO: (b/269671451) needs to be added to BubbleInfo
+ boolean isImportantConvo = b.isImportantConversation();
ShortcutRequest.QueryResult result = new ShortcutRequest(context,
new UserHandle(b.getUserId()))
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
index 0afc2cb..82494c6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
@@ -30,6 +30,7 @@
import com.android.launcher3.taskbar.TaskbarControllers;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiValueAlpha;
+import com.android.quickstep.SystemUiProxy;
import java.util.List;
import java.util.Objects;
@@ -42,6 +43,7 @@
private static final String TAG = BubbleBarViewController.class.getSimpleName();
+ private final SystemUiProxy mSystemUiProxy;
private final TaskbarActivityContext mActivity;
private final BubbleBarView mBarView;
private final int mIconSize;
@@ -69,6 +71,7 @@
public BubbleBarViewController(TaskbarActivityContext activity, BubbleBarView barView) {
mActivity = activity;
mBarView = barView;
+ mSystemUiProxy = SystemUiProxy.INSTANCE.get(mActivity);
mBubbleBarAlpha = new MultiValueAlpha(mBarView, 1 /* num alpha channels */);
mBubbleBarAlpha.setUpdateVisibility(true);
mIconSize = activity.getResources().getDimensionPixelSize(R.dimen.bubblebar_icon_size);
@@ -101,7 +104,8 @@
mBubbleStashController.stashBubbleBar();
} else {
mBubbleBarController.setSelectedBubble(bubble);
- // TODO: Tell SysUi to show the expanded view for this bubble.
+ mSystemUiProxy.showBubble(bubble.getKey(),
+ mBubbleStashController.isBubblesShowingOnHome());
}
}
@@ -270,11 +274,12 @@
if (isExpanded != mBarView.isExpanded()) {
mBarView.setExpanded(isExpanded);
if (!isExpanded) {
- // TODO: Tell SysUi to collapse the bubble
+ mSystemUiProxy.collapseBubbles();
} else {
final String selectedKey = mBubbleBarController.getSelectedBubbleKey();
if (selectedKey != null) {
- // TODO: Tell SysUi to show the bubble
+ mSystemUiProxy.showBubble(selectedKey,
+ mBubbleStashController.isBubblesShowingOnHome());
} else {
Log.w(TAG, "trying to expand bubbles when there isn't one selected");
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java
index 66d5918..5902912 100644
--- a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java
@@ -80,12 +80,23 @@
return mOverlayController;
}
+ /** Returns {@code true} if overlay or Taskbar windows are handling a system drag. */
+ boolean isAnySystemDragInProgress() {
+ return mDragController.isSystemDragInProgress()
+ || mTaskbarContext.getDragController().isSystemDragInProgress();
+ }
+
@Override
public DeviceProfile getDeviceProfile() {
return mOverlayController.getLauncherDeviceProfile();
}
@Override
+ public View.AccessibilityDelegate getAccessibilityDelegate() {
+ return mTaskbarContext.getAccessibilityDelegate();
+ }
+
+ @Override
public TaskbarDragController getDragController() {
return mDragController;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java
index 476e0a8..8de0e40 100644
--- a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java
@@ -36,6 +36,7 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.taskbar.TaskbarActivityContext;
import com.android.launcher3.taskbar.TaskbarControllers;
+import com.android.quickstep.views.DesktopTaskView;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
@@ -65,7 +66,9 @@
@Override
public void onTaskMovedToFront(int taskId) {
- mProxyView.close(false);
+ if (DesktopTaskView.DESKTOP_MODE_SUPPORTED) {
+ mProxyView.close(false);
+ }
}
};
diff --git a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayDragLayer.java b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayDragLayer.java
index 2c3e1ac..b4ec682 100644
--- a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayDragLayer.java
+++ b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayDragLayer.java
@@ -112,7 +112,7 @@
@Override
public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo inoutInfo) {
- if (mActivity.getDragController().isSystemDragInProgress()) {
+ if (mActivity.isAnySystemDragInProgress()) {
inoutInfo.touchableRegion.setEmpty();
inoutInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java b/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
index e1ce9b1..b901a87 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
@@ -359,18 +359,6 @@
return true;
});
sandboxCategory.addPreference(launchOverviewTutorialPreference);
- Preference launchSandboxModeTutorialPreference = new Preference(context);
- launchSandboxModeTutorialPreference.setKey("launchSandboxMode");
- launchSandboxModeTutorialPreference.setTitle("Launch Sandbox Mode");
- launchSandboxModeTutorialPreference.setSummary("Practice navigation gestures");
- launchSandboxModeTutorialPreference.setOnPreferenceClickListener(preference -> {
- startActivity(launchSandboxIntent
- .putExtra("use_tutorial_menu", false)
- .putExtra("tutorial_steps", new String[] {"SANDBOX_MODE"}));
- return true;
- });
- sandboxCategory.addPreference(launchSandboxModeTutorialPreference);
-
Preference launchSecondaryDisplayPreference = new Preference(context);
launchSecondaryDisplayPreference.setKey("launchSecondaryDisplay");
launchSecondaryDisplayPreference.setTitle("Launch Secondary Display");
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 5333cbe..7d47945 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -2114,12 +2114,11 @@
}
protected void linkRecentsViewScroll() {
- SurfaceTransactionApplier.create(mRecentsView, applier -> {
- runActionOnRemoteHandles(remoteTargetHandle -> remoteTargetHandle.getTransformParams()
- .setSyncTransactionApplier(applier));
- runOnRecentsAnimationAndLauncherBound(() ->
- mRecentsAnimationTargets.addReleaseCheck(applier));
- });
+ SurfaceTransactionApplier applier = new SurfaceTransactionApplier(mRecentsView);
+ runActionOnRemoteHandles(remoteTargetHandle -> remoteTargetHandle.getTransformParams()
+ .setSyncTransactionApplier(applier));
+ runOnRecentsAnimationAndLauncherBound(() ->
+ mRecentsAnimationTargets.addReleaseCheck(applier));
mRecentsView.addOnScrollChangedListener(mOnRecentsScrollListener);
runOnRecentsAnimationAndLauncherBound(() ->
diff --git a/quickstep/src/com/android/quickstep/InputConsumer.java b/quickstep/src/com/android/quickstep/InputConsumer.java
index 64c9295..6b189cf 100644
--- a/quickstep/src/com/android/quickstep/InputConsumer.java
+++ b/quickstep/src/com/android/quickstep/InputConsumer.java
@@ -41,6 +41,7 @@
int TYPE_ONE_HANDED = 1 << 11;
int TYPE_TASKBAR_STASH = 1 << 12;
int TYPE_STATUS_BAR = 1 << 13;
+ int TYPE_CURSOR_HOVER = 1 << 14;
String[] NAMES = new String[] {
"TYPE_NO_OP", // 0
@@ -57,6 +58,7 @@
"TYPE_ONE_HANDED", // 11
"TYPE_TASKBAR_STASH", // 12
"TYPE_STATUS_BAR", // 13
+ "TYPE_CURSOR_HOVER", // 14
};
InputConsumer NO_OP = () -> TYPE_NO_OP;
diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
index ab3ae9f..4c9cf8b 100644
--- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
+++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
@@ -116,6 +116,16 @@
return response;
}
+ case TestProtocol.REQUEST_STASHED_TASKBAR_SCALE: {
+ runOnTISBinder(tisBinder -> {
+ response.putFloat(TestProtocol.TEST_INFO_RESPONSE_FIELD,
+ tisBinder.getTaskbarManager()
+ .getCurrentActivityContext()
+ .getStashedTaskbarScale());
+ });
+ return response;
+ }
+
case TestProtocol.REQUEST_TASKBAR_ALL_APPS_TOP_PADDING: {
return getTISBinderUIProperty(Bundle::putInt, tisBinder ->
tisBinder.getTaskbarManager()
diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java
index 913f08f..d798e62 100644
--- a/quickstep/src/com/android/quickstep/RecentsModel.java
+++ b/quickstep/src/com/android/quickstep/RecentsModel.java
@@ -145,6 +145,9 @@
* @param filter Returns true if GroupTask should be in the list of considerations
*/
public void isTaskRemoved(int taskId, Consumer<Boolean> callback, Predicate<GroupTask> filter) {
+ // Invalidate the existing list before checking to ensure this reflects the current state in
+ // the system
+ mTaskList.onRecentTasksChanged();
mTaskList.getTasks(true /* loadKeysOnly */, (taskGroups) -> {
for (GroupTask group : taskGroups) {
if (group.containsTask(taskId)) {
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index 89f06f6..0549d9f 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -51,6 +51,7 @@
import android.window.TaskSnapshot;
import android.window.TransitionFilter;
+import androidx.annotation.MainThread;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
@@ -58,6 +59,7 @@
import com.android.internal.util.ScreenshotRequest;
import com.android.internal.view.AppearanceRegion;
import com.android.launcher3.util.MainThreadInitializedObject;
+import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -69,6 +71,8 @@
import com.android.systemui.unfold.progress.IUnfoldAnimation;
import com.android.systemui.unfold.progress.IUnfoldTransitionListener;
import com.android.wm.shell.back.IBackAnimation;
+import com.android.wm.shell.bubbles.IBubbles;
+import com.android.wm.shell.bubbles.IBubblesListener;
import com.android.wm.shell.desktopmode.IDesktopMode;
import com.android.wm.shell.draganddrop.IDragAndDrop;
import com.android.wm.shell.onehanded.IOneHanded;
@@ -101,6 +105,7 @@
private ISystemUiProxy mSystemUiProxy;
private IPip mPip;
+ private IBubbles mBubbles;
private ISysuiUnlockAnimationController mSysuiUnlockAnimationController;
private ISplitScreen mSplitScreen;
private IOneHanded mOneHanded;
@@ -119,6 +124,7 @@
// up to the caller to clear the listeners to prevent leaks as these can be held indefinitely
// in case SysUI needs to rebind.
private IPipAnimationListener mPipAnimationListener;
+ private IBubblesListener mBubblesListener;
private ISplitScreenListener mSplitScreenListener;
private IStartingWindowListener mStartingWindowListener;
private ILauncherUnlockAnimationController mLauncherUnlockAnimationController;
@@ -200,15 +206,21 @@
return null;
}
- public void setProxy(ISystemUiProxy proxy, IPip pip, ISplitScreen splitScreen,
+ /**
+ * Sets proxy state, including death linkage, various listeners, and other configuration objects
+ */
+ @MainThread
+ public void setProxy(ISystemUiProxy proxy, IPip pip, IBubbles bubbles, ISplitScreen splitScreen,
IOneHanded oneHanded, IShellTransitions shellTransitions,
IStartingWindow startingWindow, IRecentTasks recentTasks,
ISysuiUnlockAnimationController sysuiUnlockAnimationController,
IBackAnimation backAnimation, IDesktopMode desktopMode,
IUnfoldAnimation unfoldAnimation, IDragAndDrop dragAndDrop) {
+ Preconditions.assertUIThread();
unlinkToDeath();
mSystemUiProxy = proxy;
mPip = pip;
+ mBubbles = bubbles;
mSplitScreen = splitScreen;
mOneHanded = oneHanded;
mShellTransitions = shellTransitions;
@@ -222,6 +234,7 @@
linkToDeath();
// re-attach the listeners once missing due to setProxy has not been initialized yet.
setPipAnimationListener(mPipAnimationListener);
+ setBubblesListener(mBubblesListener);
registerSplitScreenListener(mSplitScreenListener);
setStartingWindowListener(mStartingWindowListener);
setLauncherUnlockAnimationController(mLauncherUnlockAnimationController);
@@ -232,8 +245,12 @@
setUnfoldAnimationListener(mUnfoldAnimationListener);
}
+ /**
+ * Clear the proxy to release held resources and turn the majority of its operations into no-ops
+ */
+ @MainThread
public void clearProxy() {
- setProxy(null, null, null, null, null, null, null, null, null, null, null, null);
+ setProxy(null, null, null, null, null, null, null, null, null, null, null, null, null);
}
// TODO(141886704): Find a way to remove this
@@ -292,8 +309,10 @@
}
}
+ @MainThread
@Override
public void onStatusBarMotionEvent(MotionEvent event) {
+ Preconditions.assertUIThread();
if (mSystemUiProxy != null) {
try {
mSystemUiProxy.onStatusBarMotionEvent(event);
@@ -572,6 +591,59 @@
}
//
+ // Bubbles
+ //
+
+ /**
+ * Sets the listener to be notified of bubble state changes.
+ */
+ public void setBubblesListener(IBubblesListener listener) {
+ if (mBubbles != null) {
+ try {
+ if (mBubblesListener != null) {
+ // Clear out any previous listener
+ mBubbles.unregisterBubbleListener(mBubblesListener);
+ }
+ if (listener != null) {
+ mBubbles.registerBubbleListener(listener);
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed call registerBubblesListener");
+ }
+ }
+ mBubblesListener = listener;
+ }
+
+ /**
+ * Tells SysUI to show the bubble with the provided key.
+ * @param key the key of the bubble to show.
+ * @param onLauncherHome whether the bubble is showing on launcher home or not (modifies where
+ * the expanded bubble view is placed).
+ */
+ public void showBubble(String key, boolean onLauncherHome) {
+ if (mBubbles != null) {
+ try {
+ mBubbles.showBubble(key, onLauncherHome);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed call showBubble");
+ }
+ }
+ }
+
+ /**
+ * Tells SysUI to collapse the bubbles.
+ */
+ public void collapseBubbles() {
+ if (mBubbles != null) {
+ try {
+ mBubbles.collapseBubbles();
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed call collapseBubbles");
+ }
+ }
+ }
+
+ //
// Splitscreen
//
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 6ea171e..682763f 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -29,6 +29,7 @@
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.quickstep.GestureState.DEFAULT_STATE;
import static com.android.quickstep.GestureState.TrackpadGestureType.getTrackpadGestureType;
+import static com.android.quickstep.InputConsumer.TYPE_CURSOR_HOVER;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.FLAG_USING_OTHER_ACTIVITY_INPUT_CONSUMER;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.MOTION_DOWN;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.MOTION_MOVE;
@@ -42,6 +43,7 @@
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_TRACING_ENABLED;
import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_BACK_ANIMATION;
+import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_BUBBLES;
import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_DESKTOP_MODE;
import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_DRAG_AND_DROP;
import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_ONE_HANDED;
@@ -110,7 +112,7 @@
import com.android.quickstep.inputconsumers.ScreenPinnedInputConsumer;
import com.android.quickstep.inputconsumers.StatusBarInputConsumer;
import com.android.quickstep.inputconsumers.SysUiOverlayInputConsumer;
-import com.android.quickstep.inputconsumers.TaskbarStashInputConsumer;
+import com.android.quickstep.inputconsumers.TaskbarUnstashInputConsumer;
import com.android.quickstep.util.ActiveGestureLog;
import com.android.quickstep.util.ActiveGestureLog.CompoundString;
import com.android.quickstep.util.ProtoTracer;
@@ -125,6 +127,7 @@
import com.android.systemui.shared.tracing.ProtoTraceable;
import com.android.systemui.unfold.progress.IUnfoldAnimation;
import com.android.wm.shell.back.IBackAnimation;
+import com.android.wm.shell.bubbles.IBubbles;
import com.android.wm.shell.desktopmode.IDesktopMode;
import com.android.wm.shell.draganddrop.IDragAndDrop;
import com.android.wm.shell.onehanded.IOneHanded;
@@ -168,6 +171,7 @@
ISystemUiProxy proxy = ISystemUiProxy.Stub.asInterface(
bundle.getBinder(KEY_EXTRA_SYSUI_PROXY));
IPip pip = IPip.Stub.asInterface(bundle.getBinder(KEY_EXTRA_SHELL_PIP));
+ IBubbles bubbles = IBubbles.Stub.asInterface(bundle.getBinder(KEY_EXTRA_SHELL_BUBBLES));
ISplitScreen splitscreen = ISplitScreen.Stub.asInterface(bundle.getBinder(
KEY_EXTRA_SHELL_SPLIT_SCREEN));
IOneHanded onehanded = IOneHanded.Stub.asInterface(
@@ -191,7 +195,7 @@
bundle.getBinder(KEY_EXTRA_SHELL_DRAG_AND_DROP));
MAIN_EXECUTOR.execute(() -> {
SystemUiProxy.INSTANCE.get(TouchInteractionService.this).setProxy(proxy, pip,
- splitscreen, onehanded, shellTransitions, startingWindow,
+ bubbles, splitscreen, onehanded, shellTransitions, startingWindow,
recentTasks, launcherUnlockAnimationController, backAnimation, desktopMode,
unfoldTransition, dragAndDrop);
TouchInteractionService.this.initInputMonitor("TISBinder#onInitialize()");
@@ -641,12 +645,17 @@
TraceHelper.FLAG_ALLOW_BINDER_TRACKING);
final int action = event.getActionMasked();
- if (action == ACTION_DOWN) {
+ // Note this will create a new consumer every mouse click, as after ACTION_UP from the click
+ // an ACTION_HOVER_ENTER will fire as well.
+ boolean isHoverActionWithoutConsumer =
+ event.isHoverEvent() && (mUncheckedConsumer.getType() & TYPE_CURSOR_HOVER) == 0;
+ if (action == ACTION_DOWN || isHoverActionWithoutConsumer) {
mRotationTouchHelper.setOrientationTransformIfNeeded(event);
- if (!mDeviceState.isOneHandedModeActive()
+ if ((!mDeviceState.isOneHandedModeActive()
&& mRotationTouchHelper.isInSwipeUpTouchRegion(event,
- mOverviewComponentObserver.getActivityInterface())) {
+ mOverviewComponentObserver.getActivityInterface()))
+ || isHoverActionWithoutConsumer) {
// Clone the previous gesture state since onConsumerAboutToBeSwitched might trigger
// onConsumerInactive and wipe the previous gesture state
GestureState prevGestureState = new GestureState(mGestureState);
@@ -723,6 +732,8 @@
if (action == ACTION_POINTER_DOWN) {
mGestureState.setTrackpadGestureType(getTrackpadGestureType(event));
}
+ } else if (event.isHoverEvent()) {
+ mUncheckedConsumer.onHoverEvent(event);
} else {
mUncheckedConsumer.onMotionEvent(event);
}
@@ -846,7 +857,7 @@
base = tryCreateAssistantInputConsumer(base, newGestureState, event, reasonString);
}
- // If Taskbar is present, we listen for long press to unstash it.
+ // If Taskbar is present, we listen for long press or cursor hover events to unstash it.
TaskbarActivityContext tac = mTaskbarManager.getCurrentActivityContext();
if (tac != null) {
// Present always on large screen or on small screen w/ flag
@@ -857,8 +868,8 @@
.append(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("TaskbarActivityContext != null, "
- + "using TaskbarStashInputConsumer");
- base = new TaskbarStashInputConsumer(this, base, mInputMonitorCompat, tac);
+ + "using TaskbarUnstashInputConsumer");
+ base = new TaskbarUnstashInputConsumer(this, base, mInputMonitorCompat, tac);
}
}
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
index 4b1dd43..074aedd 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
@@ -79,7 +79,7 @@
}
@Override
- public void startHome() {
+ public void startHome(boolean animated) {
mActivity.startHome();
AbstractFloatingView.closeAllOpenViews(mActivity, mActivity.isStarted());
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java
similarity index 69%
rename from quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java
rename to quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java
index 51c2b48..65c825c 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarStashInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java
@@ -19,17 +19,20 @@
import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent;
import static com.android.launcher3.Utilities.squaredHypot;
+import static com.android.launcher3.config.FeatureFlags.ENABLE_CURSOR_HOVER_STATES;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_TOUCHING;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.PointF;
+import android.graphics.Rect;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import androidx.annotation.Nullable;
+import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.taskbar.TaskbarActivityContext;
@@ -40,9 +43,11 @@
import com.android.systemui.shared.system.InputMonitorCompat;
/**
- * Listens for a long press, and cancels the current gesture if that causes Taskbar to be unstashed.
+ * Listens for touch and hover events to unstash the Taskbar.
+ *
+ * <p>Cancels the current gesture if the long press causes the Taskbar to be unstashed.
*/
-public class TaskbarStashInputConsumer extends DelegateInputConsumer {
+public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
private final TaskbarActivityContext mTaskbarActivityContext;
private final GestureDetector mLongPressDetector;
@@ -64,9 +69,15 @@
private final boolean mIsTransientTaskbar;
+ private boolean mIsStashedTaskbarHovered = false;
+ private final Rect mStashedTaskbarHandleBounds = new Rect();
+ private final Rect mBottomEdgeBounds = new Rect();
+ private final int mBottomScreenEdge;
+ private final int mStashedTaskbarBottomEdge;
+
private final @Nullable TransitionCallback mTransitionCallback;
- public TaskbarStashInputConsumer(Context context, InputConsumer delegate,
+ public TaskbarUnstashInputConsumer(Context context, InputConsumer delegate,
InputMonitorCompat inputMonitor, TaskbarActivityContext taskbarActivityContext) {
super(delegate, inputMonitor);
mTaskbarActivityContext = taskbarActivityContext;
@@ -90,6 +101,11 @@
}
});
+ mBottomScreenEdge = res.getDimensionPixelSize(
+ R.dimen.taskbar_stashed_screen_edge_hover_deadzone_height);
+ mStashedTaskbarBottomEdge =
+ res.getDimensionPixelSize(R.dimen.taskbar_stashed_below_hover_deadzone_height);
+
mTransitionCallback = mIsTransientTaskbar
? taskbarActivityContext.getTranslationCallbacks()
: null;
@@ -97,7 +113,7 @@
@Override
public int getType() {
- return TYPE_TASKBAR_STASH | mDelegate.getType();
+ return TYPE_TASKBAR_STASH | TYPE_CURSOR_HOVER | mDelegate.getType();
}
@Override
@@ -213,4 +229,73 @@
}
}
}
+
+ /**
+ * Listen for hover events for the stashed taskbar.
+ *
+ * <p>When hovered over the stashed taskbar handle, show the unstash hint.
+ * <p>When the cursor is touching the bottom edge below the stashed taskbar, unstash it.
+ * <p>When the cursor is within a defined threshold of the screen's bottom edge outside of
+ * the stashed taskbar, unstash it.
+ */
+ @Override
+ public void onHoverEvent(MotionEvent ev) {
+ if (!ENABLE_CURSOR_HOVER_STATES.get() || mTaskbarActivityContext == null
+ || !mTaskbarActivityContext.isTaskbarStashed()) {
+ return;
+ }
+
+ if (mIsStashedTaskbarHovered) {
+ updateHoveredTaskbarState((int) ev.getX(), (int) ev.getY());
+ } else {
+ updateUnhoveredTaskbarState((int) ev.getX(), (int) ev.getY());
+ }
+ }
+
+ private void updateHoveredTaskbarState(int x, int y) {
+ DeviceProfile dp = mTaskbarActivityContext.getDeviceProfile();
+ mStashedTaskbarHandleBounds.set(
+ (dp.widthPx - (int) mUnstashArea) / 2,
+ dp.heightPx - dp.stashedTaskbarHeight,
+ (int) (((dp.widthPx - mUnstashArea) / 2) + mUnstashArea),
+ dp.heightPx);
+ mBottomEdgeBounds.set(mStashedTaskbarHandleBounds);
+ mBottomEdgeBounds.top = dp.heightPx - mStashedTaskbarBottomEdge;
+
+ if (mBottomEdgeBounds.contains(x, y)) {
+ // If hovering stashed taskbar and then hover screen bottom edge, unstash it.
+ mTaskbarActivityContext.onSwipeToUnstashTaskbar();
+ mIsStashedTaskbarHovered = false;
+ } else if (!mStashedTaskbarHandleBounds.contains(x, y)) {
+ // If exit hovering stashed taskbar, remove hint.
+ startStashedTaskbarHover(/* isHovered = */ false);
+ }
+ }
+
+ private void updateUnhoveredTaskbarState(int x, int y) {
+ DeviceProfile dp = mTaskbarActivityContext.getDeviceProfile();
+ mStashedTaskbarHandleBounds.set(
+ (dp.widthPx - (int) mUnstashArea) / 2,
+ dp.heightPx - dp.stashedTaskbarHeight,
+ (int) (((dp.widthPx - mUnstashArea) / 2) + mUnstashArea),
+ dp.heightPx);
+ mBottomEdgeBounds.set(
+ 0,
+ dp.heightPx - mBottomScreenEdge,
+ dp.widthPx,
+ dp.heightPx);
+
+ if (mStashedTaskbarHandleBounds.contains(x, y)) {
+ // If enter hovering stashed taskbar, start hint.
+ startStashedTaskbarHover(/* isHovered = */ true);
+ } else if (mBottomEdgeBounds.contains(x, y)) {
+ // If hover screen's bottom edge not below the stashed taskbar, unstash it.
+ mTaskbarActivityContext.onSwipeToUnstashTaskbar();
+ }
+ }
+
+ private void startStashedTaskbarHover(boolean isHovered) {
+ mTaskbarActivityContext.startTaskbarUnstashHint(isHovered, /* forceUnstash = */ true);
+ mIsStashedTaskbarHovered = isHovered;
+ }
}
diff --git a/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java b/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
index 1ac0742..aeac760 100644
--- a/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
@@ -186,7 +186,8 @@
public void launchTutorialMenu() {
mFragment = new MenuFragment();
getSupportFragmentManager().beginTransaction()
- .add(R.id.gesture_tutorial_fragment_container, mFragment)
+ .replace(R.id.gesture_tutorial_fragment_container, mFragment)
+ .runOnCommit(() -> mFragment.onAttachedToWindow())
.commit();
}
diff --git a/quickstep/src/com/android/quickstep/interaction/MenuFragment.java b/quickstep/src/com/android/quickstep/interaction/MenuFragment.java
index ccff30d..46f79b1 100644
--- a/quickstep/src/com/android/quickstep/interaction/MenuFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/MenuFragment.java
@@ -19,6 +19,7 @@
import static com.android.quickstep.interaction.GestureSandboxActivity.KEY_TUTORIAL_TYPE;
import static com.android.quickstep.interaction.GestureSandboxActivity.KEY_USE_TUTORIAL_MENU;
+import android.graphics.Rect;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -27,17 +28,33 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.R;
/** Displays the gesture nav tutorial menu. */
public final class MenuFragment extends GestureSandboxFragment {
+ @NonNull private Rect mInsets = new Rect();
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mInsets = InvariantDeviceProfile.INSTANCE.get(getContext())
+ .getDeviceProfile(getContext()).getInsets();
+ }
+
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View root = inflater.inflate(
R.layout.gesture_tutorial_step_menu, container, false);
+ root.setPadding(
+ root.getPaddingLeft() + mInsets.left,
+ root.getPaddingTop() + mInsets.top,
+ root.getPaddingRight() + mInsets.right,
+ root.getPaddingBottom() + mInsets.bottom);
+
root.findViewById(R.id.gesture_tutorial_menu_home_button).setOnClickListener(
v -> launchTutorialStep(TutorialController.TutorialType.HOME_NAVIGATION));
root.findViewById(R.id.gesture_tutorial_menu_back_button).setOnClickListener(
diff --git a/quickstep/src/com/android/quickstep/interaction/SandboxModeTutorialController.java b/quickstep/src/com/android/quickstep/interaction/SandboxModeTutorialController.java
deleted file mode 100644
index f0bd4f9..0000000
--- a/quickstep/src/com/android/quickstep/interaction/SandboxModeTutorialController.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2020 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.quickstep.interaction;
-
-import android.graphics.PointF;
-
-import com.android.launcher3.R;
-import com.android.quickstep.interaction.EdgeBackGestureHandler.BackGestureResult;
-import com.android.quickstep.interaction.NavBarGestureHandler.NavBarGestureResult;
-
-/** A {@link TutorialController} for the Sandbox Mode. */
-public class SandboxModeTutorialController extends SwipeUpGestureTutorialController {
-
- SandboxModeTutorialController(SandboxModeTutorialFragment fragment, TutorialType tutorialType) {
- super(fragment, tutorialType);
- }
-
- @Override
- public void onBackGestureAttempted(BackGestureResult result) {
- switch (result) {
- case BACK_COMPLETED_FROM_LEFT:
- case BACK_COMPLETED_FROM_RIGHT:
- showRippleEffect(null);
- showFeedback(R.string.sandbox_mode_back_gesture_feedback_successful);
- break;
- case BACK_CANCELLED_FROM_LEFT:
- case BACK_CANCELLED_FROM_RIGHT:
- showFeedback(R.string.back_gesture_feedback_cancelled);
- break;
- case BACK_NOT_STARTED_TOO_FAR_FROM_EDGE:
- showFeedback(R.string.sandbox_mode_back_gesture_feedback_swipe_too_far_from_edge);
- break;
- }
- }
-
- @Override
- public void onNavBarGestureAttempted(NavBarGestureResult result, PointF finalVelocity) {
- switch (result) {
- case HOME_GESTURE_COMPLETED:
- animateFakeTaskViewHome(finalVelocity, () -> {
- showFeedback(R.string.sandbox_mode_home_gesture_feedback_successful);
- });
- break;
- case OVERVIEW_GESTURE_COMPLETED:
- fadeOutFakeTaskView(true, true, () -> {
- showFeedback(R.string.sandbox_mode_overview_gesture_feedback_successful);
- });
- break;
- case HOME_OR_OVERVIEW_NOT_STARTED_WRONG_SWIPE_DIRECTION:
- case HOME_OR_OVERVIEW_CANCELLED:
- case HOME_NOT_STARTED_TOO_FAR_FROM_EDGE:
- case OVERVIEW_NOT_STARTED_TOO_FAR_FROM_EDGE:
- showFeedback(R.string.home_gesture_feedback_swipe_too_far_from_edge);
- break;
- }
- }
-}
diff --git a/quickstep/src/com/android/quickstep/interaction/SandboxModeTutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/SandboxModeTutorialFragment.java
deleted file mode 100644
index 7bd52f7..0000000
--- a/quickstep/src/com/android/quickstep/interaction/SandboxModeTutorialFragment.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2020 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.quickstep.interaction;
-
-import android.view.MotionEvent;
-import android.view.View;
-
-import androidx.annotation.NonNull;
-
-import com.android.launcher3.logging.StatsLogManager;
-import com.android.quickstep.interaction.TutorialController.TutorialType;
-
-/** Shows the general navigation gesture sandbox environment. */
-public class SandboxModeTutorialFragment extends TutorialFragment {
-
- public SandboxModeTutorialFragment(boolean fromTutorialMenu) {
- super(fromTutorialMenu);
- }
-
- @Override
- TutorialController createController(TutorialType type) {
- return new SandboxModeTutorialController(this, type);
- }
-
- @Override
- Class<? extends TutorialController> getControllerClass() {
- return SandboxModeTutorialController.class;
- }
-
- @Override
- public boolean onTouch(View view, MotionEvent motionEvent) {
- if (motionEvent.getAction() == MotionEvent.ACTION_DOWN && mTutorialController != null) {
- mTutorialController.setRippleHotspot(motionEvent.getX(), motionEvent.getY());
- }
- return super.onTouch(view, motionEvent);
- }
-
- @Override
- void logTutorialStepShown(@NonNull StatsLogManager statsLogManager) {
- // No-Op: tutorial step not currently shown to users
- }
-
- @Override
- void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager) {
- // No-Op: tutorial step not currently shown to users
- }
-}
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialController.java b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
index 6efdb07..d4ff457 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
@@ -829,9 +829,6 @@
HOME_NAVIGATION,
HOME_NAVIGATION_COMPLETE,
OVERVIEW_NAVIGATION,
- OVERVIEW_NAVIGATION_COMPLETE,
- ASSISTANT,
- ASSISTANT_COMPLETE,
- SANDBOX_MODE
+ OVERVIEW_NAVIGATION_COMPLETE
}
}
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
index 25de605..9f15e19 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
@@ -117,8 +117,6 @@
case OVERVIEW_NAVIGATION:
case OVERVIEW_NAVIGATION_COMPLETE:
return new OverviewGestureTutorialFragment(fromTutorialMenu);
- case SANDBOX_MODE:
- return new SandboxModeTutorialFragment(fromTutorialMenu);
default:
Log.e(LOG_TAG, "Failed to find an appropriate fragment for " + tutorialType.name());
}
diff --git a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java
index 95473dc..bb028a7 100644
--- a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java
+++ b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java
@@ -22,13 +22,11 @@
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.View;
+import android.view.View.OnAttachStateChangeListener;
import android.view.ViewRootImpl;
import com.android.quickstep.RemoteAnimationTargets.ReleaseCheck;
-import java.util.function.Consumer;
-
-
/**
* Helper class to apply surface transactions in sync with RenderThread similar to
* android.view.SyncRtSurfaceTransactionApplier
@@ -39,22 +37,47 @@
private static final int MSG_UPDATE_SEQUENCE_NUMBER = 0;
- private final SurfaceControl mBarrierSurfaceControl;
- private final ViewRootImpl mTargetViewRootImpl;
private final Handler mApplyHandler;
+ private boolean mInitialized;
+ private SurfaceControl mBarrierSurfaceControl;
+ private ViewRootImpl mTargetViewRootImpl;
+
private int mLastSequenceNumber = 0;
/**
* @param targetView The view in the surface that acts as synchronization anchor.
*/
public SurfaceTransactionApplier(View targetView) {
- mTargetViewRootImpl = targetView.getViewRootImpl();
- mBarrierSurfaceControl = mTargetViewRootImpl.getSurfaceControl();
+ if (targetView.isAttachedToWindow()) {
+ initialize(targetView);
+ } else {
+ mInitialized = false;
+ targetView.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
+ @Override
+ public void onViewAttachedToWindow(View v) {
+ if (!mInitialized) {
+ targetView.removeOnAttachStateChangeListener(this);
+ initialize(targetView);
+ }
+ }
+
+ @Override
+ public void onViewDetachedFromWindow(View v) {
+ // Do nothing
+ }
+ });
+ }
mApplyHandler = new Handler(this::onApplyMessage);
setCanRelease(true);
}
+ private void initialize(View view) {
+ mTargetViewRootImpl = view.getViewRootImpl();
+ mBarrierSurfaceControl = mTargetViewRootImpl.getSurfaceControl();
+ mInitialized = true;
+ }
+
protected boolean onApplyMessage(Message msg) {
if (msg.what == MSG_UPDATE_SEQUENCE_NUMBER) {
setCanRelease(msg.arg1 == mLastSequenceNumber);
@@ -70,6 +93,10 @@
* this method to avoid synchronization issues.
*/
public void scheduleApply(SurfaceTransaction params) {
+ if (!mInitialized) {
+ params.getTransaction().apply();
+ return;
+ }
View view = mTargetViewRootImpl.getView();
if (view == null) {
return;
@@ -93,33 +120,4 @@
// Make sure a frame gets scheduled.
view.invalidate();
}
-
- /**
- * Creates an instance of SurfaceTransactionApplier, deferring until the target view is
- * attached if necessary.
- */
- public static void create(
- final View targetView, final Consumer<SurfaceTransactionApplier> callback) {
- if (targetView == null) {
- // No target view, no applier
- callback.accept(null);
- } else if (targetView.isAttachedToWindow()) {
- // Already attached, we're good to go
- callback.accept(new SurfaceTransactionApplier(targetView));
- } else {
- // Haven't been attached before we can get the view root
- targetView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
- @Override
- public void onViewAttachedToWindow(View v) {
- targetView.removeOnAttachStateChangeListener(this);
- callback.accept(new SurfaceTransactionApplier(targetView));
- }
-
- @Override
- public void onViewDetachedFromWindow(View v) {
- // Do nothing
- }
- });
- }
- }
}
diff --git a/quickstep/src/com/android/quickstep/util/TaskRemovedDuringLaunchListener.java b/quickstep/src/com/android/quickstep/util/TaskRemovedDuringLaunchListener.java
new file mode 100644
index 0000000..c22e0bc
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/util/TaskRemovedDuringLaunchListener.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2023 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.quickstep.util;
+
+import static android.app.ActivityTaskManager.INVALID_TASK_ID;
+
+import android.app.Activity;
+
+import androidx.annotation.NonNull;
+
+import com.android.launcher3.util.ActivityLifecycleCallbacksAdapter;
+import com.android.quickstep.RecentsModel;
+
+/**
+ * This class tracks the failure of a task launch through the TaskView.launchTask() call, in an
+ * edge case in which starting a new task may initially succeed (startActivity returns true), but
+ * the launch ultimately fails if the activity finishes while it is resuming.
+ *
+ * There are two signals this class checks, the launcher lifecycle and the transition completion.
+ * If we hit either of those signals and the task is no longer valid, then the registered failure
+ * callback will be notified.
+ */
+public class TaskRemovedDuringLaunchListener implements ActivityLifecycleCallbacksAdapter {
+
+ private Activity mActivity;
+ private int mLaunchedTaskId = INVALID_TASK_ID;
+ private Runnable mTaskLaunchFailedCallback = null;
+
+ /**
+ * Registers a failure listener callback if it detects a scenario in which an app launch
+ * failed before the transition finished.
+ */
+ public void register(Activity activity, int launchedTaskId,
+ @NonNull Runnable taskLaunchFailedCallback) {
+ activity.registerActivityLifecycleCallbacks(this);
+ mActivity = activity;
+ mLaunchedTaskId = launchedTaskId;
+ mTaskLaunchFailedCallback = taskLaunchFailedCallback;
+ }
+
+ /**
+ * Unregisters the failure listener.
+ */
+ private void unregister() {
+ mActivity.unregisterActivityLifecycleCallbacks(this);
+ mActivity = null;
+ mLaunchedTaskId = INVALID_TASK_ID;
+ mTaskLaunchFailedCallback = null;
+ }
+
+ /**
+ * Called when the transition finishes.
+ */
+ public void onTransitionFinished() {
+ // The transition finished and Launcher was not stopped, check if the launch failed
+ checkTaskLaunchFailed();
+ }
+
+ @Override
+ public void onActivityStopped(Activity activity) {
+ // The normal task launch case, Launcher stops and updates its state correctly
+ unregister();
+ }
+
+ @Override
+ public void onActivityResumed(Activity activity) {
+ // The transition hasn't finished but Launcher was resumed, check if the launch failed
+ checkTaskLaunchFailed();
+ }
+
+ @Override
+ public void onActivityDestroyed(Activity activity) {
+ // If we somehow don't get any of the above signals, then just unregister this listener
+ unregister();
+ }
+
+ private void checkTaskLaunchFailed() {
+ if (mLaunchedTaskId != INVALID_TASK_ID) {
+ final int launchedTaskId = mLaunchedTaskId;
+ final Runnable taskLaunchFailedCallback = mTaskLaunchFailedCallback;
+ RecentsModel.INSTANCE.getNoCreate().isTaskRemoved(mLaunchedTaskId, (taskRemoved) -> {
+ if (taskRemoved) {
+ ActiveGestureLog.INSTANCE.addLog("Launch failed, task (id=" + launchedTaskId
+ + ") finished mid transition");
+ taskLaunchFailedCallback.run();
+ }
+ }, (task) -> true /* filter */);
+ unregister();
+ }
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java
index 379722b..1cfaf14 100644
--- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java
@@ -321,7 +321,7 @@
}
@Override
- public void launchTask(@NonNull Consumer<Boolean> callback, boolean freezeTaskList) {
+ public void launchTask(@NonNull Consumer<Boolean> callback, boolean isQuickswitch) {
launchTasks();
callback.accept(true);
}
diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
index 5bfd035..c6c84bd 100644
--- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
@@ -237,9 +237,9 @@
}
@Override
- public void launchTask(@NonNull Consumer<Boolean> callback, boolean freezeTaskList) {
+ public void launchTask(@NonNull Consumer<Boolean> callback, boolean isQuickswitch) {
getRecentsView().getSplitSelectController().launchTasks(mTask.key.id, mSecondaryTask.key.id,
- SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT, callback, freezeTaskList,
+ SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT, callback, isQuickswitch,
getSplitRatio());
}
diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
index 8ff0e9b..2008129 100644
--- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -39,6 +39,7 @@
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statehandlers.DesktopVisibilityController;
+import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.PendingSplitSelectInfo;
@@ -79,9 +80,11 @@
}
@Override
- public void startHome() {
- mActivity.getStateManager().goToState(NORMAL);
- AbstractFloatingView.closeAllOpenViews(mActivity, mActivity.isStarted());
+ public void startHome(boolean animated) {
+ StateManager stateManager = mActivity.getStateManager();
+ animated &= stateManager.shouldAnimateStateChange();
+ stateManager.goToState(NORMAL, animated);
+ AbstractFloatingView.closeAllOpenViews(mActivity, animated);
}
@Override
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index f0afa69..f17f074 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -213,6 +213,7 @@
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
+import java.util.stream.Collectors;
/**
* A list of recent tasks.
@@ -1320,6 +1321,29 @@
return null;
}
+ /**
+ * Returns a {@link TaskView} that has taskIds matching {@code taskIds} or null if no match.
+ */
+ @Nullable
+ public TaskView getTaskViewByTaskIds(int[] taskIds) {
+ if (!hasAnyValidTaskIds(taskIds)) {
+ return null;
+ }
+
+ for (int i = 0; i < getTaskViewCount(); i++) {
+ TaskView taskView = requireTaskViewAt(i);
+ if (Arrays.equals(taskIds, taskView.getTaskIds())) {
+ return taskView;
+ }
+ }
+ return null;
+ }
+
+ /** Returns false if {@code taskIds} is null or contains invalid values, true otherwise */
+ private boolean hasAnyValidTaskIds(int[] taskIds) {
+ return taskIds != null && !Arrays.equals(taskIds, INVALID_TASK_IDS);
+ }
+
public void setOverviewStateEnabled(boolean enabled) {
mOverviewStateEnabled = enabled;
updateTaskStackListenerState();
@@ -1589,10 +1613,10 @@
return;
}
- int currentTaskId = INVALID_TASK_ID;
+ int[] currentTaskId = INVALID_TASK_IDS;
TaskView currentTaskView = getTaskViewAt(mCurrentPage);
if (currentTaskView != null && currentTaskView.getTask() != null) {
- currentTaskId = currentTaskView.getTask().key.id;
+ currentTaskId = currentTaskView.getTaskIds();
}
// Unload existing visible task data
@@ -1604,8 +1628,8 @@
// Save running task ID if it exists before rebinding all taskViews, otherwise the task from
// the runningTaskView currently bound could get assigned to another TaskView
- int runningTaskId = getTaskIdsForTaskViewId(mRunningTaskViewId)[0];
- int focusedTaskId = getTaskIdsForTaskViewId(mFocusedTaskViewId)[0];
+ int[] runningTaskId = getTaskIdsForTaskViewId(mRunningTaskViewId);
+ int[] focusedTaskId = getTaskIdsForTaskViewId(mFocusedTaskViewId);
// Removing views sets the currentPage to 0, so we save this and restore it after
// the new set of views are added
@@ -1699,7 +1723,7 @@
}
// Keep same previous focused task
- TaskView newFocusedTaskView = getTaskViewByTaskId(focusedTaskId);
+ TaskView newFocusedTaskView = getTaskViewByTaskIds(focusedTaskId);
// If the list changed, maybe the focused task doesn't exist anymore
if (newFocusedTaskView == null && getTaskViewCount() > 0) {
newFocusedTaskView = getTaskViewAt(0);
@@ -1716,10 +1740,10 @@
updateChildTaskOrientations();
TaskView newRunningTaskView = null;
- if (runningTaskId != INVALID_TASK_ID) {
+ if (hasAnyValidTaskIds(runningTaskId)) {
// Update mRunningTaskViewId to be the new TaskView that was assigned by binding
// the full list of tasks to taskViews
- newRunningTaskView = getTaskViewByTaskId(runningTaskId);
+ newRunningTaskView = getTaskViewByTaskIds(runningTaskId);
if (newRunningTaskView != null) {
mRunningTaskViewId = newRunningTaskView.getTaskViewId();
} else {
@@ -1731,15 +1755,15 @@
if (mNextPage != INVALID_PAGE) {
// Restore mCurrentPage but don't call setCurrentPage() as that clobbers the scroll.
mCurrentPage = previousCurrentPage;
- if (currentTaskId != INVALID_TASK_ID) {
- currentTaskView = getTaskViewByTaskId(currentTaskId);
+ if (hasAnyValidTaskIds(currentTaskId)) {
+ currentTaskView = getTaskViewByTaskIds(currentTaskId);
if (currentTaskView != null) {
targetPage = indexOfChild(currentTaskView);
}
}
} else {
// Set the current page to the running task, but not if settling on new task.
- if (runningTaskId != INVALID_TASK_ID) {
+ if (hasAnyValidTaskIds(runningTaskId)) {
targetPage = indexOfChild(newRunningTaskView);
} else if (getTaskViewCount() > 0) {
TaskView taskView = requireTaskViewAt(0);
@@ -2210,8 +2234,8 @@
// Update the task data for the in/visible children
for (int i = 0; i < getTaskViewCount(); i++) {
TaskView taskView = requireTaskViewAt(i);
- Task task = taskView.getTask();
- if (task == null) {
+ TaskIdAttributeContainer[] containers = taskView.getTaskIdAttributeContainers();
+ if (containers[0] == null && containers[1] == null) {
continue;
}
int index = indexOfChild(taskView);
@@ -2222,34 +2246,43 @@
visible = lower <= index && index <= upper;
}
if (visible) {
- boolean skipLoadingTask = false;
+ // Default update all non-null tasks, then remove running ones
+ List<Task> tasksToUpdate = Arrays.stream(containers).filter(Objects::nonNull)
+ .map(TaskIdAttributeContainer::getTask)
+ .collect(Collectors.toCollection(ArrayList::new));
if (mTmpRunningTasks != null) {
for (Task t : mTmpRunningTasks) {
- if (task == t) {
- // Skip loading if this is the task that we are animating into
- skipLoadingTask = true;
- break;
- }
+ // Skip loading if this is the task that we are animating into
+ // TODO(b/280812109) change this equality check to use A.equals(B)
+ tasksToUpdate.removeIf(task -> task == t);
}
}
- if (skipLoadingTask) {
+ if (tasksToUpdate.isEmpty()) {
continue;
}
- if (!mHasVisibleTaskData.get(task.key.id)) {
- // Ignore thumbnail update if it's current running task during the gesture
- // We snapshot at end of gesture, it will update then
- int changes = dataChanges;
- if (taskView == getRunningTaskView() && mGestureActive) {
- changes &= ~TaskView.FLAG_UPDATE_THUMBNAIL;
+ for (Task task : tasksToUpdate) {
+ if (!mHasVisibleTaskData.get(task.key.id)) {
+ // Ignore thumbnail update if it's current running task during the gesture
+ // We snapshot at end of gesture, it will update then
+ int changes = dataChanges;
+ if (taskView == getRunningTaskView() && mGestureActive) {
+ changes &= ~TaskView.FLAG_UPDATE_THUMBNAIL;
+ }
+ taskView.onTaskListVisibilityChanged(true /* visible */, changes);
}
- taskView.onTaskListVisibilityChanged(true /* visible */, changes);
+ mHasVisibleTaskData.put(task.key.id, visible);
}
- mHasVisibleTaskData.put(task.key.id, visible);
} else {
- if (mHasVisibleTaskData.get(task.key.id)) {
- taskView.onTaskListVisibilityChanged(false /* visible */, dataChanges);
+ for (TaskIdAttributeContainer container : containers) {
+ if (container == null) {
+ continue;
+ }
+
+ if (mHasVisibleTaskData.get(container.getTask().key.id)) {
+ taskView.onTaskListVisibilityChanged(false /* visible */, dataChanges);
+ }
+ mHasVisibleTaskData.delete(container.getTask().key.id);
}
- mHasVisibleTaskData.delete(task.key.id);
}
}
}
@@ -2285,7 +2318,11 @@
}
}
- public abstract void startHome();
+ public void startHome() {
+ startHome(mActivity.isStarted());
+ }
+
+ public abstract void startHome(boolean animated);
public void reset() {
setCurrentTask(-1);
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 53660b5..134ef6c 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -92,6 +92,7 @@
import com.android.quickstep.RecentsModel;
import com.android.quickstep.RemoteAnimationTargets;
import com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle;
+import com.android.quickstep.TaskAnimationManager;
import com.android.quickstep.TaskIconCache;
import com.android.quickstep.TaskOverlayFactory;
import com.android.quickstep.TaskThumbnailCache;
@@ -102,6 +103,7 @@
import com.android.quickstep.util.RecentsOrientedState;
import com.android.quickstep.util.SplitSelectStateController;
import com.android.quickstep.util.TaskCornerRadius;
+import com.android.quickstep.util.TaskRemovedDuringLaunchListener;
import com.android.quickstep.util.TransformParams;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -651,7 +653,7 @@
* index 0 will contain the taskId, index 1 will be -1 indicating a null taskID value
*/
public int[] getTaskIds() {
- return mTaskIdContainer;
+ return Arrays.copyOf(mTaskIdContainer, mTaskIdContainer.length);
}
public boolean containsMultipleTasks() {
@@ -801,6 +803,14 @@
recentsView.addSideTaskLaunchCallback(callbackList);
return callbackList;
}
+ if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) {
+ // If the recents transition is running (ie. in live tile mode), then the start
+ // of a new task will merge into the existing transition and it currently will
+ // not be run independently, so we need to rely on the onTaskAppeared() call
+ // for the new task to trigger the side launch callback to flush this runnable
+ // list (which is usually flushed when the app launch animation finishes)
+ recentsView.addSideTaskLaunchCallback(opts.onEndCallback);
+ }
return opts.onEndCallback;
} else {
notifyTaskLaunchFailed(TAG);
@@ -815,23 +825,44 @@
* Starts the task associated with this view without any animation
*/
public void launchTask(@NonNull Consumer<Boolean> callback) {
- launchTask(callback, false /* freezeTaskList */);
+ launchTask(callback, false /* isQuickswitch */);
}
/**
* Starts the task associated with this view without any animation
*/
- public void launchTask(@NonNull Consumer<Boolean> callback, boolean freezeTaskList) {
+ public void launchTask(@NonNull Consumer<Boolean> callback, boolean isQuickswitch) {
if (mTask != null) {
TestLogging.recordEvent(
TestProtocol.SEQUENCE_MAIN, "startActivityFromRecentsAsync", mTask);
+ final TaskRemovedDuringLaunchListener
+ failureListener = new TaskRemovedDuringLaunchListener();
+ if (isQuickswitch) {
+ // We only listen for failures to launch in quickswitch because the during this
+ // gesture launcher is in the background state, vs other launches which are in
+ // the actual overview state
+ failureListener.register(mActivity, mTask.key.id, () -> {
+ notifyTaskLaunchFailed(TAG);
+ // Disable animations for now, as it is an edge case and the app usually covers
+ // launcher and also any state transition animation also gets clobbered by
+ // QuickstepTransitionManager.createWallpaperOpenAnimations when launcher
+ // shows again
+ getRecentsView().startHome(false /* animated */);
+ });
+ }
// Indicate success once the system has indicated that the transition has started
- ActivityOptions opts = makeCustomAnimation(getContext(), 0, 0,
- () -> callback.accept(true), MAIN_EXECUTOR.getHandler());
+ ActivityOptions opts = ActivityOptions.makeCustomTaskAnimation(getContext(), 0, 0,
+ MAIN_EXECUTOR.getHandler(),
+ elapsedRealTime -> {
+ callback.accept(true);
+ },
+ elapsedRealTime -> {
+ failureListener.onTransitionFinished();
+ });
opts.setLaunchDisplayId(
getDisplay() == null ? DEFAULT_DISPLAY : getDisplay().getDisplayId());
- if (freezeTaskList) {
+ if (isQuickswitch) {
opts.setFreezeRecentTasksReordering();
}
opts.setDisableStartingWindow(mSnapshotView.shouldShowSplashView());
diff --git a/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarBaseTestCase.kt b/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarBaseTestCase.kt
index 20466ad..2c16c15 100644
--- a/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarBaseTestCase.kt
+++ b/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarBaseTestCase.kt
@@ -16,8 +16,10 @@
package com.android.launcher3.taskbar
import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController
+import com.android.launcher3.taskbar.bubbles.BubbleControllers
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController
import com.android.systemui.shared.rotation.RotationButtonController
+import java.util.Optional
import org.junit.Before
import org.mockito.Mock
import org.mockito.MockitoAnnotations
@@ -54,6 +56,7 @@
@Mock lateinit var taskbarEduTooltipController: TaskbarEduTooltipController
@Mock lateinit var keyboardQuickSwitchController: KeyboardQuickSwitchController
@Mock lateinit var taskbarPinningController: TaskbarDividerPopupController
+ @Mock lateinit var optionalBubbleControllers: Optional<BubbleControllers>
lateinit var taskbarControllers: TaskbarControllers
@@ -94,6 +97,7 @@
taskbarEduTooltipController,
keyboardQuickSwitchController,
taskbarPinningController,
+ optionalBubbleControllers,
)
}
}
diff --git a/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
new file mode 100644
index 0000000..9c0b2bf
--- /dev/null
+++ b/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
@@ -0,0 +1,102 @@
+/*
+ * 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.quickstep;
+
+import static androidx.test.InstrumentationRegistry.getInstrumentation;
+
+import static junit.framework.TestCase.assertEquals;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.android.launcher3.tapl.LauncherInstrumentation;
+import com.android.launcher3.tapl.Taskbar;
+import com.android.launcher3.ui.AbstractLauncherUiTest;
+import com.android.launcher3.ui.TaplTestsLauncher3;
+import com.android.launcher3.util.DisplayController;
+import com.android.launcher3.util.LauncherLayoutBuilder;
+import com.android.launcher3.util.TestUtil;
+
+import org.junit.After;
+import org.junit.Assume;
+
+import java.util.List;
+
+public class AbstractTaplTestsTaskbar extends AbstractQuickStepTest {
+
+ protected static final String TEST_APP_NAME = "LauncherTestApp";
+ protected static final String TEST_APP_PACKAGE =
+ getInstrumentation().getContext().getPackageName();
+ protected static final String CALCULATOR_APP_PACKAGE =
+ resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR);
+
+ protected AutoCloseable mLauncherLayout;
+ protected boolean mTaskbarWasInTransientMode;
+
+
+ @Override
+ public void setUp() throws Exception {
+ Assume.assumeTrue(mLauncher.isTablet());
+ super.setUp();
+
+ LauncherLayoutBuilder layoutBuilder = new LauncherLayoutBuilder().atHotseat(0).putApp(
+ "com.google.android.apps.nexuslauncher.tests",
+ "com.android.launcher3.testcomponent.BaseTestingActivity");
+ mLauncherLayout = TestUtil.setLauncherDefaultLayout(mTargetContext, layoutBuilder);
+ TaplTestsLauncher3.initialize(this);
+
+ startAppFast(CALCULATOR_APP_PACKAGE);
+ mLauncher.enableBlockTimeout(true);
+ mLauncher.showTaskbarIfHidden();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ setTaskbarMode(mLauncher, mTaskbarWasInTransientMode);
+ mLauncher.enableBlockTimeout(false);
+ if (mLauncherLayout != null) {
+ mLauncherLayout.close();
+ }
+ }
+
+ protected static boolean isTaskbarInTransientMode(Context context) {
+ return DisplayController.isTransientTaskbar(context);
+ }
+
+ protected Taskbar getTaskbar() {
+ Taskbar taskbar = mLauncher.getLaunchedAppState().getTaskbar();
+ List<String> taskbarIconNames = taskbar.getIconNames();
+ List<String> hotseatIconNames = mLauncher.getHotseatIconNames();
+
+ assertEquals("Taskbar and hotseat icon counts do not match",
+ taskbarIconNames.size(), hotseatIconNames.size());
+
+ for (int i = 0; i < taskbarIconNames.size(); i++) {
+ assertEquals("Taskbar and Hotseat icons do not match",
+ taskbarIconNames, hotseatIconNames);
+ }
+
+ return taskbar;
+ }
+
+ protected static void setTaskbarMode(LauncherInstrumentation launcher,
+ boolean expectTransientTaskbar) {
+ launcher.enableTransientTaskbar(expectTransientTaskbar);
+ launcher.recreateTaskbar();
+ launcher.checkForAnomaly(true, true);
+ AbstractLauncherUiTest.checkDetectedLeaks(launcher);
+ }
+}
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsPersistentTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsPersistentTaskbar.java
new file mode 100644
index 0000000..ee0eeb2
--- /dev/null
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsPersistentTaskbar.java
@@ -0,0 +1,53 @@
+/*
+ * 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.quickstep;
+
+import static com.android.quickstep.TaskbarModeSwitchRule.Mode.PERSISTENT;
+
+import androidx.test.filters.LargeTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@LargeTest
+@RunWith(AndroidJUnit4.class)
+public class TaplTestsPersistentTaskbar extends AbstractTaplTestsTaskbar {
+
+ @Override
+ public void setUp() throws Exception {
+ mTaskbarWasInTransientMode = isTaskbarInTransientMode(mTargetContext);
+ setTaskbarMode(mLauncher, false);
+ super.setUp();
+ }
+
+ @Test
+ @TaskbarModeSwitch(mode = PERSISTENT)
+ public void testHideShowTaskbar() {
+ getTaskbar().hide();
+ mLauncher.getLaunchedAppState().showTaskbar();
+ }
+
+ @Test
+ @TaskbarModeSwitch(mode = PERSISTENT)
+ public void testHideTaskbarPersistsOnRecreate() {
+ getTaskbar().hide();
+ mLauncher.recreateTaskbar();
+ mLauncher.getLaunchedAppState().assertTaskbarHidden();
+ }
+}
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
index 6243471..021e118 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
@@ -15,120 +15,68 @@
*/
package com.android.quickstep;
-import static androidx.test.InstrumentationRegistry.getInstrumentation;
-
-import static com.android.quickstep.TaskbarModeSwitchRule.Mode.PERSISTENT;
-import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;
-
-import static junit.framework.TestCase.assertEquals;
-
-import android.content.Intent;
+import static com.android.quickstep.TaplTestsTaskbar.TaskbarMode.PERSISTENT;
+import static com.android.quickstep.TaplTestsTaskbar.TaskbarMode.TRANSIENT;
import androidx.test.filters.LargeTest;
-import androidx.test.runner.AndroidJUnit4;
-import com.android.launcher3.tapl.Taskbar;
-import com.android.launcher3.ui.TaplTestsLauncher3;
-import com.android.launcher3.util.LauncherLayoutBuilder;
-import com.android.launcher3.util.TestUtil;
+import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
-import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
-import org.junit.After;
-import org.junit.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
-import java.util.List;
+import java.util.Arrays;
+import java.util.Collection;
@LargeTest
-@RunWith(AndroidJUnit4.class)
-public class TaplTestsTaskbar extends AbstractQuickStepTest {
+@RunWith(Parameterized.class)
+public class TaplTestsTaskbar extends AbstractTaplTestsTaskbar {
- private static final String TEST_APP_NAME = "LauncherTestApp";
- private static final String TEST_APP_PACKAGE =
- getInstrumentation().getContext().getPackageName();
- private static final String CALCULATOR_APP_PACKAGE =
- resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR);
+ private final TaplTestsTaskbar.TaskbarMode mTaskbarMode;
- private AutoCloseable mLauncherLayout;
+ public enum TaskbarMode {
+ TRANSIENT, PERSISTENT
+ }
+
+ @Parameterized.Parameters(name = "{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {PERSISTENT}, {TRANSIENT}
+ });
+ }
+
+ public TaplTestsTaskbar(TaskbarMode mode) {
+ mTaskbarMode = mode;
+ }
@Override
public void setUp() throws Exception {
- Assume.assumeTrue(mLauncher.isTablet());
+ mTaskbarWasInTransientMode = isTaskbarInTransientMode(mTargetContext);
+ setTaskbarMode(mLauncher, isTaskbarTestModeTransient());
super.setUp();
-
- LauncherLayoutBuilder layoutBuilder = new LauncherLayoutBuilder().atHotseat(0).putApp(
- "com.google.android.apps.nexuslauncher.tests",
- "com.android.launcher3.testcomponent.BaseTestingActivity");
- mLauncherLayout = TestUtil.setLauncherDefaultLayout(mTargetContext, layoutBuilder);
- TaplTestsLauncher3.initialize(this);
-
- startAppFast(CALCULATOR_APP_PACKAGE);
- mLauncher.enableBlockTimeout(true);
- mLauncher.showTaskbarIfHidden();
}
- @After
- public void tearDown() throws Exception {
- mLauncher.enableBlockTimeout(false);
- if (mLauncherLayout != null) {
- mLauncherLayout.close();
+ @Test
+ public void testLaunchApp() {
+ getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
+ // We are using parameterized test runner to share code between different test cases with
+ // taskbar variants. But, sometimes we only need to assert things for particular Taskbar
+ // variants.
+ if (isTaskbarTestModeTransient() && mLauncher.getNavigationModel()
+ != LauncherInstrumentation.NavigationModel.THREE_BUTTON) {
+ mLauncher.getLaunchedAppState().assertTaskbarHidden();
}
}
@Test
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testHideShowTaskbar() {
- getTaskbar().hide();
- mLauncher.getLaunchedAppState().showTaskbar();
- }
-
- @Test
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testHideTaskbarPersistsOnRecreate() {
- getTaskbar().hide();
- mLauncher.recreateTaskbar();
- mLauncher.getLaunchedAppState().assertTaskbarHidden();
- }
-
- @Test
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testLaunchApp() throws Exception {
- getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
- }
-
- @Test
- @TaskbarModeSwitch(mode = TRANSIENT)
- public void testTransientLaunchApp() throws Exception {
- getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
- mLauncher.getLaunchedAppState().assertTaskbarHidden();
- }
-
- @Test
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testOpenMenu() throws Exception {
+ public void testOpenMenu() {
getTaskbar().getAppIcon(TEST_APP_NAME).openMenu();
}
@Test
- @TaskbarModeSwitch(mode = TRANSIENT)
- public void testTransientOpenMenu() throws Exception {
- getTaskbar().getAppIcon(TEST_APP_NAME).openMenu();
- }
-
- @Test
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testLaunchShortcut() throws Exception {
- getTaskbar().getAppIcon(TEST_APP_NAME)
- .openDeepShortcutMenu()
- .getMenuItem("Shortcut 1")
- .launch(TEST_APP_PACKAGE);
- }
-
- @Test
- @TaskbarModeSwitch(mode = TRANSIENT)
- public void testTransientLaunchShortcut() throws Exception {
+ public void testLaunchShortcut() {
getTaskbar().getAppIcon(TEST_APP_NAME)
.openDeepShortcutMenu()
.getMenuItem("Shortcut 1")
@@ -138,145 +86,67 @@
@Test
@ScreenRecord // b/231615831
@PortraitLandscape
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testLaunchAppInSplitscreen() throws Exception {
+ public void testLaunchAppInSplitscreen() {
getTaskbar().getAppIcon(TEST_APP_NAME).dragToSplitscreen(
TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
- }
-
- @Test
- @ScreenRecord // b/231615831
- @PortraitLandscape
- @TaskbarModeSwitch(mode = TRANSIENT)
- public void testTransientLaunchAppInSplitscreen() throws Exception {
- getTaskbar().getAppIcon(TEST_APP_NAME).dragToSplitscreen(
- TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
- mLauncher.getLaunchedAppState().assertTaskbarHidden();
- }
-
- @Test
- @ScreenRecord // b/231615831
- @PortraitLandscape
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testLaunchShortcutInSplitscreen() throws Exception {
- getTaskbar().getAppIcon(TEST_APP_NAME)
- .openDeepShortcutMenu()
- .getMenuItem("Shortcut 1")
- .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
- }
-
- @Test
- @ScreenRecord // b/231615831
- @PortraitLandscape
- @TaskbarModeSwitch(mode = TRANSIENT)
- public void testTransientLaunchShortcutInSplitscreen() throws Exception {
- getTaskbar().getAppIcon(TEST_APP_NAME)
- .openDeepShortcutMenu()
- .getMenuItem("Shortcut 1")
- .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
- }
-
- @Test
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testLaunchApp_FromTaskbarAllApps() throws Exception {
- getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
- }
-
- @Test
- @TaskbarModeSwitch(mode = TRANSIENT)
- public void testTransientLaunchApp_FromTaskbarAllApps() throws Exception {
- getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
- }
-
- @Test
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testOpenMenu_FromTaskbarAllApps() throws Exception {
- getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).openMenu();
- }
-
- @Test
- @TaskbarModeSwitch(mode = TRANSIENT)
- public void testTransientOpenMenu_FromTaskbarAllApps() throws Exception {
- getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).openMenu();
- }
-
- @Test
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testLaunchShortcut_FromTaskbarAllApps() throws Exception {
- getTaskbar().openAllApps()
- .getAppIcon(TEST_APP_NAME)
- .openDeepShortcutMenu()
- .getMenuItem("Shortcut 1")
- .launch(TEST_APP_PACKAGE);
- }
-
- @Test
- @TaskbarModeSwitch(mode = TRANSIENT)
- public void testTransientLaunchShortcut_FromTaskbarAllApps() throws Exception {
- getTaskbar().openAllApps()
- .getAppIcon(TEST_APP_NAME)
- .openDeepShortcutMenu()
- .getMenuItem("Shortcut 1")
- .launch(TEST_APP_PACKAGE);
- }
-
- @Test
- @ScreenRecord // b/231615831
- @PortraitLandscape
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testLaunchAppInSplitscreen_FromTaskbarAllApps() throws Exception {
- getTaskbar().openAllApps()
- .getAppIcon(TEST_APP_NAME)
- .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
- }
-
- @Test
- @ScreenRecord // b/231615831
- @PortraitLandscape
- @TaskbarModeSwitch(mode = TRANSIENT)
- public void testTransientLaunchAppInSplitscreen_FromTaskbarAllApps() throws Exception {
- getTaskbar().openAllApps()
- .getAppIcon(TEST_APP_NAME)
- .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
- }
-
- @Test
- @ScreenRecord // b/231615831
- @PortraitLandscape
- @TaskbarModeSwitch(mode = PERSISTENT)
- public void testLaunchShortcutInSplitscreen_FromTaskbarAllApps() throws Exception {
- getTaskbar().openAllApps()
- .getAppIcon(TEST_APP_NAME)
- .openDeepShortcutMenu()
- .getMenuItem("Shortcut 1")
- .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
- }
-
- @Test
- @ScreenRecord // b/231615831
- @PortraitLandscape
- @TaskbarModeSwitch(mode = TRANSIENT)
- public void testTransientLaunchShortcutInSplitscreen_FromTaskbarAllApps() throws Exception {
- getTaskbar().openAllApps()
- .getAppIcon(TEST_APP_NAME)
- .openDeepShortcutMenu()
- .getMenuItem("Shortcut 1")
- .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
- }
-
- private Taskbar getTaskbar() {
- Taskbar taskbar = mLauncher.getLaunchedAppState().getTaskbar();
- List<String> taskbarIconNames = taskbar.getIconNames();
- List<String> hotseatIconNames = mLauncher.getHotseatIconNames();
-
- assertEquals("Taskbar and hotseat icon counts do not match",
- taskbarIconNames.size(), hotseatIconNames.size());
-
- for (int i = 0; i < taskbarIconNames.size(); i++) {
- assertEquals("Taskbar and Hotseat icons do not match",
- taskbarIconNames, hotseatIconNames);
+ // We are using parameterized test runner to share code between different test cases with
+ // taskbar variants. But, sometimes we only need to assert things for particular Taskbar
+ // variants.
+ if (isTaskbarTestModeTransient()) {
+ mLauncher.getLaunchedAppState().assertTaskbarHidden();
}
+ }
- return taskbar;
+ @Test
+ @ScreenRecord // b/231615831
+ @PortraitLandscape
+ public void testLaunchShortcutInSplitscreen() {
+ getTaskbar().getAppIcon(TEST_APP_NAME)
+ .openDeepShortcutMenu()
+ .getMenuItem("Shortcut 1")
+ .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
+ }
+
+ @Test
+ public void testLaunchApp_fromTaskbarAllApps() {
+ getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
+ }
+
+ @Test
+ public void testOpenMenu_fromTaskbarAllApps() {
+ getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).openMenu();
+ }
+
+ @Test
+ public void testLaunchShortcut_fromTaskbarAllApps() {
+ getTaskbar().openAllApps()
+ .getAppIcon(TEST_APP_NAME)
+ .openDeepShortcutMenu()
+ .getMenuItem("Shortcut 1")
+ .launch(TEST_APP_PACKAGE);
+ }
+
+ @Test
+ @ScreenRecord // b/231615831
+ @PortraitLandscape
+ public void testLaunchAppInSplitscreen_fromTaskbarAllApps() {
+ getTaskbar().openAllApps()
+ .getAppIcon(TEST_APP_NAME)
+ .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
+ }
+
+ @Test
+ @ScreenRecord // b/231615831
+ @PortraitLandscape
+ public void testLaunchShortcutInSplitscreen_fromTaskbarAllApps() {
+ getTaskbar().openAllApps()
+ .getAppIcon(TEST_APP_NAME)
+ .openDeepShortcutMenu()
+ .getMenuItem("Shortcut 1")
+ .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
+ }
+
+ private boolean isTaskbarTestModeTransient() {
+ return TRANSIENT == mTaskbarMode;
}
}
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java
new file mode 100644
index 0000000..6b61f18
--- /dev/null
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java
@@ -0,0 +1,74 @@
+/*
+ * 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.quickstep;
+
+import static com.android.launcher3.config.FeatureFlags.ENABLE_CURSOR_HOVER_STATES;
+import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;
+
+
+import androidx.test.filters.LargeTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import com.android.launcher3.util.TestUtil;
+import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@LargeTest
+@RunWith(AndroidJUnit4.class)
+public class TaplTestsTransientTaskbar extends AbstractTaplTestsTaskbar {
+
+ @Override
+ public void setUp() throws Exception {
+ mTaskbarWasInTransientMode = isTaskbarInTransientMode(mTargetContext);
+ setTaskbarMode(mLauncher, true);
+ super.setUp();
+ }
+
+ @Test
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testShowTaskbarUnstashHintOnHover() {
+ try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_CURSOR_HOVER_STATES, true)) {
+ getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
+ mLauncher.getLaunchedAppState().hoverToShowTaskbarUnstashHint();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Test
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testUnstashTaskbarOnScreenBottomEdgeHover() {
+ try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_CURSOR_HOVER_STATES, true)) {
+ getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
+ mLauncher.getLaunchedAppState().hoverScreenBottomEdgeToUnstashTaskbar();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Test
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testHoverBelowHintedTaskbarToUnstash() {
+ try (AutoCloseable flag = TestUtil.overrideFlag(ENABLE_CURSOR_HOVER_STATES, true)) {
+ getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
+ mLauncher.getLaunchedAppState().hoverBelowHintedTaskbarToUnstash();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/quickstep/tests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt b/quickstep/tests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt
index acfd54c..65542cf 100644
--- a/quickstep/tests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt
@@ -33,14 +33,10 @@
import com.android.launcher3.statemanager.StateManager
import com.android.launcher3.util.ComponentKey
import com.android.launcher3.util.SplitConfigurationOptions
-import com.android.launcher3.util.SplitConfigurationOptions.StagePosition
-import com.android.launcher3.util.mock
import com.android.launcher3.util.withArgCaptor
import com.android.quickstep.RecentsModel
import com.android.quickstep.SystemUiProxy
import com.android.systemui.shared.recents.model.Task
-import java.util.ArrayList
-import java.util.function.Consumer
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
@@ -50,7 +46,9 @@
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito.verify
+import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
+import java.util.function.Consumer
@RunWith(AndroidJUnit4::class)
class SplitSelectStateControllerTest {
@@ -355,6 +353,7 @@
@Test
fun secondPendingIntentSet() {
val itemInfo = ItemInfo()
+ `when`(pendingIntent.creatorUserHandle).thenReturn(primaryUserHandle)
splitSelectStateController.setInitialTaskSelect(null, 0, itemInfo, null, 1)
splitSelectStateController.setSecondTask(pendingIntent)
assertTrue(splitSelectStateController.isBothSplitAppsConfirmed)
diff --git a/res/layout/widget_cell_content.xml b/res/layout/widget_cell_content.xml
index 3f61aaa..6db4fb5 100644
--- a/res/layout/widget_cell_content.xml
+++ b/res/layout/widget_cell_content.xml
@@ -24,6 +24,7 @@
android:layout_weight="1"
android:importantForAccessibility="noHideDescendants"
android:hapticFeedbackEnabled="false"
+ android:clipChildren="false"
android:layout_marginVertical="8dp">
<!-- The image of the widget. This view does not support padding. Any placement adjustment
should be done using margins. Width & height are set at runtime after scaling the
diff --git a/res/layout/widgets_bottom_sheet_content.xml b/res/layout/widgets_bottom_sheet_content.xml
index b76eef7..065c2ed 100644
--- a/res/layout/widgets_bottom_sheet_content.xml
+++ b/res/layout/widgets_bottom_sheet_content.xml
@@ -42,7 +42,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadeScrollbars="false"
- android:layout_marginVertical="16dp">
+ android:layout_marginTop="16dp">
<include layout="@layout/widgets_table_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0714863..11861b9 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -314,6 +314,7 @@
<style name="DropTargetButtonBase" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:drawablePadding">@dimen/drop_target_button_drawable_padding</item>
<item name="android:padding">14dp</item>
+ <item name="android:includeFontPadding">false</item>
<item name="android:textColor">@color/drop_target_text</item>
<item name="android:textSize">@dimen/drop_target_text_size</item>
<item name="android:singleLine">true</item>
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index fc7f614..1a86009 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.InputType;
@@ -58,8 +59,6 @@
public static final int TOOLTIP_LEFT = 1;
public static final int TOOLTIP_RIGHT = 2;
- private final Rect mTempRect = new Rect();
-
protected final ActivityContext mActivityContext;
protected final DropTargetHandler mDropTargetHandler;
protected DropTargetBar mDropTargetBar;
@@ -417,15 +416,11 @@
*/
@VisibleForTesting
protected boolean isTextClippedVertically(int availableHeight) {
- availableHeight -= getPaddingTop() + getPaddingBottom();
- if (availableHeight <= 0) {
- return true;
- }
+ Paint.FontMetricsInt fontMetricsInt = getPaint().getFontMetricsInt();
+ int lineCount = (getLineCount() <= 0) ? 1 : getLineCount();
+ int textHeight = lineCount * (fontMetricsInt.bottom - fontMetricsInt.top);
- getPaint().getTextBounds(mText.toString(), 0, mText.length(), mTempRect);
- // Add bounds bottom to height, as text bounds height measures from the text baseline and
- // above, which characters can descend below
- return mTempRect.bottom + mTempRect.height() >= availableHeight;
+ return textHeight + getPaddingTop() + getPaddingBottom() >= availableHeight;
}
/**
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index bb6d8b0..addcac9 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -152,6 +152,7 @@
firstButton.setTextVisible(true);
firstButton.setIconVisible(true);
firstButton.measure(widthSpec, heightSpec);
+ firstButton.resizeTextToFit();
} else if (visibleCount == 2) {
DeviceProfile dp = mLauncher.getDeviceProfile();
int verticalPadding = dp.dropTargetVerticalPaddingPx;
diff --git a/src/com/android/launcher3/DropTargetHandler.kt b/src/com/android/launcher3/DropTargetHandler.kt
index 277f8b3..6560e16 100644
--- a/src/com/android/launcher3/DropTargetHandler.kt
+++ b/src/com/android/launcher3/DropTargetHandler.kt
@@ -6,7 +6,6 @@
import com.android.launcher3.SecondaryDropTarget.DeferredOnComplete
import com.android.launcher3.dragndrop.DragLayer
import com.android.launcher3.logging.StatsLogManager.LauncherEvent
-import com.android.launcher3.model.ModelWriter
import com.android.launcher3.model.data.ItemInfo
import com.android.launcher3.model.data.LauncherAppWidgetInfo
import com.android.launcher3.util.IntSet
@@ -22,8 +21,6 @@
class DropTargetHandler(launcher: Launcher) {
val mLauncher: Launcher = launcher
- val modelWriter: ModelWriter = mLauncher.modelWriter
-
fun onDropAnimationComplete() {
mLauncher.stateManager.goToState(LauncherState.NORMAL)
}
@@ -87,7 +84,7 @@
else mLauncher.workspace.currentPageScreenIds
val onUndoClicked = Runnable {
mLauncher.setPagesToBindSynchronously(pageIds)
- modelWriter.abortDelete()
+ mLauncher.modelWriter.abortDelete()
mLauncher.statsLogManager.logger().log(LauncherEvent.LAUNCHER_UNDO)
}
@@ -95,7 +92,7 @@
mLauncher,
R.string.item_removed,
R.string.undo,
- modelWriter::commitDelete,
+ mLauncher.modelWriter::commitDelete,
onUndoClicked
)
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 86a5f9f..29b0f08 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1621,6 +1621,9 @@
return mModel;
}
+ /**
+ * Returns the ModelWriter writer, make sure to call the function every time you want to use it.
+ */
public ModelWriter getModelWriter() {
return mModelWriter;
}
@@ -3160,6 +3163,16 @@
}
@Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_ESCAPE) {
+ // Close any open floating views.
+ closeOpenViews();
+ return true;
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+ @Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
// KEYCODE_MENU is sent by some tests, for example
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 01a4876..21dfbe1 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -871,8 +871,8 @@
boolean visible = deviceProfile.isTablet || mForceBottomSheetVisible;
mBottomSheetBackground.setVisibility(visible ? View.VISIBLE : View.GONE);
// Note: For tablets, the opaque background and header protection are added in drawOnScrim.
- // For the taskbar entrypoint, the scrim is drawn differently, so a static background is
- // added in TaskbarAllAppsContainerView and header protection is not yet supported.
+ // For the taskbar entrypoint, the scrim is drawn by its abstract slide in view container,
+ // so its header protection is derived from this scrim instead.
}
private void setBottomSheetAlpha(float alpha) {
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index d7bafab..8250a99 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -253,7 +253,7 @@
"COLLECT_SEARCH_HISTORY", DISABLED, "Allow launcher to collect search history for log");
public static final BooleanFlag ENABLE_TWOLINE_ALLAPPS = getDebugFlag(270390937,
- "ENABLE_TWOLINE_ALLAPPS", DISABLED, "Enables two line label inside all apps.");
+ "ENABLE_TWOLINE_ALLAPPS", TEAMFOOD, "Enables two line label inside all apps.");
public static final BooleanFlag IME_STICKY_SNACKBAR_EDU = getDebugFlag(270391693,
"IME_STICKY_SNACKBAR_EDU", ENABLED, "Show sticky IME edu in AllApps");
@@ -411,7 +411,7 @@
// TODO(Block 31)
public static final BooleanFlag ENABLE_SPLIT_LAUNCH_DATA_REFACTOR = getDebugFlag(279494325,
- "ENABLE_SPLIT_LAUNCH_DATA_REFACTOR", DISABLED,
+ "ENABLE_SPLIT_LAUNCH_DATA_REFACTOR", ENABLED,
"Use refactored split launching code path");
// TODO(Block 32): Empty block
diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java
index 4906c1d..00f4285 100644
--- a/src/com/android/launcher3/dragndrop/AddItemActivity.java
+++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java
@@ -304,7 +304,8 @@
mWidgetOptions = pendingInfo.getDefaultSizeOptions(this);
mWidgetCell.getWidgetView().setTag(pendingInfo);
- applyWidgetItemAsync(() -> new WidgetItem(widgetInfo, mIdp, mApp.getIconCache()));
+ applyWidgetItemAsync(() -> new WidgetItem(
+ widgetInfo, mIdp, mApp.getIconCache(), mApp.getContext()));
return WidgetsModel.newPendingItemInfo(this, widgetInfo.getComponent(),
widgetInfo.getUser());
}
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 48239ae..2c1100f 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -74,7 +74,6 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemFactory;
import com.android.launcher3.model.data.WorkspaceItemInfo;
-import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.MultiTranslateDelegate;
import com.android.launcher3.util.Thunk;
diff --git a/src/com/android/launcher3/logging/StartupLatencyLogger.kt b/src/com/android/launcher3/logging/StartupLatencyLogger.kt
index 27b8c3b..93e9de5 100644
--- a/src/com/android/launcher3/logging/StartupLatencyLogger.kt
+++ b/src/com/android/launcher3/logging/StartupLatencyLogger.kt
@@ -21,14 +21,13 @@
const val UNSET_LONG = -1L
}
- @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
+ @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
val startTimeByEvent = SparseLongArray()
- @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
+ @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
val endTimeByEvent = SparseLongArray()
- @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
- var cardinality: Int = UNSET_INT
- @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
+ @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) var cardinality: Int = UNSET_INT
+ @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
var workspaceLoadStartTime: Long = UNSET_LONG
private var isInTest = false
diff --git a/src/com/android/launcher3/model/WidgetItem.java b/src/com/android/launcher3/model/WidgetItem.java
index 7198d54..c99b889 100644
--- a/src/com/android/launcher3/model/WidgetItem.java
+++ b/src/com/android/launcher3/model/WidgetItem.java
@@ -3,6 +3,7 @@
import static com.android.launcher3.Utilities.ATLEAST_S;
import android.annotation.SuppressLint;
+import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
@@ -25,13 +26,15 @@
public final ShortcutConfigActivityInfo activityInfo;
public final String label;
+ public final CharSequence description;
public final int spanX, spanY;
public WidgetItem(LauncherAppWidgetProviderInfo info,
- InvariantDeviceProfile idp, IconCache iconCache) {
+ InvariantDeviceProfile idp, IconCache iconCache, Context context) {
super(info.provider, info.getProfile());
label = iconCache.getTitleNoCache(info);
+ description = ATLEAST_S ? info.loadDescription(context) : null;
widgetInfo = info;
activityInfo = null;
@@ -43,6 +46,7 @@
super(info.getComponent(), info.getUser());
label = info.isPersistable() ? iconCache.getTitleNoCache(info) :
Utilities.trim(info.getLabel(pm));
+ description = null;
widgetInfo = null;
activityInfo = info;
spanX = spanY = 1;
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index bc492fd..8274789 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -241,8 +241,8 @@
deepShortcutCount,
popupDataProvider.getNotificationKeysForItem(item),
systemShortcuts);
- launcher.tryClearAccessibilityFocus(icon);
}
+ launcher.tryClearAccessibilityFocus(icon);
launcher.refreshAndBindWidgetsForPackageUser(PackageUserKey.fromItemInfo(item));
container.requestFocus();
return container;
diff --git a/src/com/android/launcher3/util/LogConfig.java b/src/com/android/launcher3/util/LogConfig.java
index 5abf95c..04f83b9 100644
--- a/src/com/android/launcher3/util/LogConfig.java
+++ b/src/com/android/launcher3/util/LogConfig.java
@@ -55,4 +55,9 @@
* When turned on, we enable quick launch v2 related logging.
*/
public static final String QUICK_LAUNCH_V2 = "QuickLaunchV2";
+
+ /**
+ * When turned on, we enable Gms Play related logging.
+ */
+ public static final String GMS_PLAY = "GmsPlay";
}
diff --git a/src/com/android/launcher3/views/AbstractSlideInView.java b/src/com/android/launcher3/views/AbstractSlideInView.java
index 99616f1..ec7ec0b 100644
--- a/src/com/android/launcher3/views/AbstractSlideInView.java
+++ b/src/com/android/launcher3/views/AbstractSlideInView.java
@@ -99,7 +99,7 @@
protected @Nullable OnCloseListener mOnCloseBeginListener;
protected List<OnCloseListener> mOnCloseListeners = new ArrayList<>();
- private final AnimatedFloat mSlideInViewScale =
+ protected final AnimatedFloat mSlideInViewScale =
new AnimatedFloat(this::onScaleProgressChanged, VIEW_NO_SCALE);
protected boolean mIsBackProgressing;
@Nullable private Drawable mContentBackground;
diff --git a/src/com/android/launcher3/widget/PendingItemDragHelper.java b/src/com/android/launcher3/widget/PendingItemDragHelper.java
index 67d21f7..f269434 100644
--- a/src/com/android/launcher3/widget/PendingItemDragHelper.java
+++ b/src/com/android/launcher3/widget/PendingItemDragHelper.java
@@ -157,8 +157,15 @@
previewBounds.right -= padding;
}
if (mAppWidgetHostViewPreview != null) {
- previewWidth = mAppWidgetHostViewPreview.getMeasuredWidth();
- previewHeight = mAppWidgetHostViewPreview.getMeasuredHeight();
+ float previewScale = mAppWidgetHostViewPreview.getScaleX();
+ int widgetWidth = mAppWidgetHostViewPreview.getMeasuredWidth();
+ int widgetHeight = mAppWidgetHostViewPreview.getMeasuredHeight();
+ previewWidth = Math.round(widgetWidth * previewScale);
+ previewHeight = Math.round(widgetHeight * previewScale);
+
+ previewBounds.offset(
+ Math.round(widgetWidth * (previewScale - 1) / 2),
+ Math.round(widgetHeight * (previewScale - 1) / 2));
} else {
previewWidth = preview.getIntrinsicWidth();
previewHeight = preview.getIntrinsicHeight();
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index 80bc1a7..c30342a 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -16,18 +16,15 @@
package com.android.launcher3.widget;
-import static android.view.View.MeasureSpec.makeMeasureSpec;
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
-
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY;
-import static com.android.launcher3.Utilities.ATLEAST_S;
-import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_WIDGET_CENTERING;
+import static com.android.launcher3.widget.LauncherAppWidgetProviderInfo.fromProviderInfo;
+import static com.android.launcher3.widget.util.WidgetSizes.getWidgetItemSizePx;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Process;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Size;
@@ -47,7 +44,6 @@
import androidx.annotation.Nullable;
import com.android.launcher3.CheckLongPressHelper;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.icons.FastBitmapDrawable;
@@ -55,7 +51,6 @@
import com.android.launcher3.icons.cache.HandlerRunnable;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.views.ActivityContext;
-import com.android.launcher3.widget.util.WidgetSizes;
import java.util.function.Consumer;
@@ -75,40 +70,8 @@
private static final int FADE_IN_DURATION_MS = 90;
- /** Widget cell width is calculated by multiplying this factor to grid cell width. */
- private static final float WIDTH_SCALE = 3f;
-
- /** Widget preview width is calculated by multiplying this factor to the widget cell width. */
- private static final float PREVIEW_SCALE = 0.8f;
-
/**
- * The maximum dimension that can be used as the size in
- * {@link android.view.View.MeasureSpec#makeMeasureSpec(int, int)}.
- *
- * <p>This is equal to (1 << MeasureSpec.MODE_SHIFT) - 1.
- */
- private static final int MAX_MEASURE_SPEC_DIMENSION = (1 << 30) - 1;
-
- /**
- * The target preview width, in pixels, of a widget or a shortcut.
- *
- * <p>The actual preview width may be smaller than or equal to this value subjected to scaling.
- */
- protected int mTargetPreviewWidth;
-
- /**
- * The target preview height, in pixels, of a widget or a shortcut.
- *
- * <p>The actual preview height may be smaller than or equal to this value subjected to scaling.
- */
- protected int mTargetPreviewHeight;
-
- protected int mPresetPreviewSize;
-
- private int mCellSize;
-
- /**
- * The scale of the preview container.
+ * The requested scale of the preview container. It can be lower than this as well.
*/
private float mPreviewContainerScale = 1f;
@@ -119,7 +82,8 @@
private TextView mWidgetDims;
private TextView mWidgetDescription;
- protected WidgetItem mItem;
+ private WidgetItem mItem;
+ private Size mWidgetSize;
private final DatabaseWidgetPreviewLoader mWidgetPreviewLoader;
@@ -150,18 +114,11 @@
mWidgetPreviewLoader = new DatabaseWidgetPreviewLoader(context);
mLongPressHelper = new CheckLongPressHelper(this);
mLongPressHelper.setLongPressTimeoutFactor(1);
+ mEnforcedCornerRadius = RoundedCornerEnforcement.computeEnforcedRadius(context);
+ mWidgetSize = new Size(0, 0);
- setContainerWidth();
- setWillNotDraw(false);
setClipToPadding(false);
setAccessibilityDelegate(mActivity.getAccessibilityDelegate());
- mEnforcedCornerRadius = RoundedCornerEnforcement.computeEnforcedRadius(context);
- }
-
- private void setContainerWidth() {
- mCellSize = (int) (mActivity.getDeviceProfile().allAppsIconSizePx * WIDTH_SCALE);
- mPresetPreviewSize = (int) (mCellSize * PREVIEW_SCALE);
- mTargetPreviewWidth = mTargetPreviewHeight = mPresetPreviewSize;
}
@Override
@@ -206,7 +163,6 @@
mWidgetDims.setText(null);
mWidgetDescription.setText(null);
mWidgetDescription.setVisibility(GONE);
- mTargetPreviewWidth = mTargetPreviewHeight = mPresetPreviewSize;
if (mActiveRequest != null) {
mActiveRequest.cancel();
@@ -218,7 +174,9 @@
}
mAppWidgetHostViewPreview = null;
mAppWidgetHostViewScale = 1f;
+ mPreviewContainerScale = 1f;
mItem = null;
+ mWidgetSize = new Size(0, 0);
}
public void setSourceContainer(int sourceContainer) {
@@ -248,17 +206,12 @@
*/
public void applyFromCellItem(WidgetItem item, float previewScale,
@NonNull Consumer<Bitmap> callback, @Nullable Bitmap cachedPreview) {
- // setPreviewSize
- DeviceProfile deviceProfile = mActivity.getDeviceProfile();
- Size widgetSize = WidgetSizes.getWidgetItemSizePx(getContext(), deviceProfile, item);
- mTargetPreviewWidth = widgetSize.getWidth();
- mTargetPreviewHeight = widgetSize.getHeight();
mPreviewContainerScale = previewScale;
- applyPreviewOnAppWidgetHostView(item);
-
Context context = getContext();
mItem = item;
+ mWidgetSize = getWidgetItemSizePx(getContext(), mActivity.getDeviceProfile(), mItem);
+
mWidgetName.setText(mItem.label);
mWidgetName.setContentDescription(
context.getString(R.string.widget_preview_context_description, mItem.label));
@@ -266,14 +219,11 @@
mItem.spanX, mItem.spanY));
mWidgetDims.setContentDescription(context.getString(
R.string.widget_accessible_dims_format, mItem.spanX, mItem.spanY));
- if (ATLEAST_S && mItem.widgetInfo != null) {
- CharSequence description = mItem.widgetInfo.loadDescription(context);
- if (description != null && description.length() > 0) {
- mWidgetDescription.setText(description);
- mWidgetDescription.setVisibility(VISIBLE);
- } else {
- mWidgetDescription.setVisibility(GONE);
- }
+ if (!TextUtils.isEmpty(mItem.description)) {
+ mWidgetDescription.setText(mItem.description);
+ mWidgetDescription.setVisibility(VISIBLE);
+ } else {
+ mWidgetDescription.setVisibility(GONE);
}
if (item.activityInfo != null) {
@@ -282,68 +232,31 @@
setTag(new PendingAddWidgetInfo(item.widgetInfo, mSourceContainer));
}
- ensurePreviewWithCallback(callback, cachedPreview);
- }
-
- private static class ScaledAppWidgetHostView extends LauncherAppWidgetHostView {
- private boolean mKeepOrigForDragging = true;
-
- ScaledAppWidgetHostView(Context context) {
- super(context);
- }
-
- /**
- * Set if the view will keep its original scale when dragged
- * @param isKeepOrig True if keep original scale when dragged, false otherwise
- */
- public void setKeepOrigForDragging(boolean isKeepOrig) {
- mKeepOrigForDragging = isKeepOrig;
- }
-
- /**
- * @return True if the view is set to preserve original scale when dragged, false otherwise
- */
- public boolean isKeepOrigForDragging() {
- return mKeepOrigForDragging;
- }
-
- @Override
- public void startDrag() {
- super.startDrag();
- if (!isKeepOrigForDragging()) {
- // restore to original scale when being dragged, if set to do so
- setScaleToFit(1.0f);
- }
- // When the drag start, translations need to be set to zero to center the view
- getTranslateDelegate().setTranslation(INDEX_WIDGET_CENTERING, 0f, 0f);
- }
- }
-
- private void applyPreviewOnAppWidgetHostView(WidgetItem item) {
if (mRemoteViewsPreview != null) {
- mAppWidgetHostViewPreview = createAppWidgetHostView(getContext());
+ mAppWidgetHostViewPreview = createAppWidgetHostView(context);
setAppWidgetHostViewPreview(mAppWidgetHostViewPreview, item.widgetInfo,
mRemoteViewsPreview);
- return;
+ } else if (item.hasPreviewLayout()) {
+ // If the context is a Launcher activity, DragView will show mAppWidgetHostViewPreview
+ // as a preview during drag & drop. And thus, we should use LauncherAppWidgetHostView,
+ // which supports applying local color extraction during drag & drop.
+ mAppWidgetHostViewPreview = isLauncherContext(context)
+ ? new LauncherAppWidgetHostView(context)
+ : createAppWidgetHostView(context);
+ LauncherAppWidgetProviderInfo providerInfo =
+ fromProviderInfo(context, item.widgetInfo.clone());
+ // A hack to force the initial layout to be the preview layout since there is no API for
+ // rendering a preview layout for work profile apps yet. For non-work profile layout, a
+ // proper solution is to use RemoteViews(PackageName, LayoutId).
+ providerInfo.initialLayout = item.widgetInfo.previewLayout;
+ setAppWidgetHostViewPreview(mAppWidgetHostViewPreview, providerInfo, null);
+ } else if (cachedPreview != null) {
+ applyPreview(cachedPreview);
+ } else {
+ if (mActiveRequest == null) {
+ mActiveRequest = mWidgetPreviewLoader.loadPreview(mItem, mWidgetSize, callback);
+ }
}
-
- if (!item.hasPreviewLayout()) return;
-
- Context context = getContext();
- // If the context is a Launcher activity, DragView will show mAppWidgetHostViewPreview as
- // a preview during drag & drop. And thus, we should use LauncherAppWidgetHostView, which
- // supports applying local color extraction during drag & drop.
- mAppWidgetHostViewPreview = isLauncherContext(context)
- ? new ScaledAppWidgetHostView(context)
- : createAppWidgetHostView(context);
- LauncherAppWidgetProviderInfo launcherAppWidgetProviderInfo =
- LauncherAppWidgetProviderInfo.fromProviderInfo(context, item.widgetInfo.clone());
- // A hack to force the initial layout to be the preview layout since there is no API for
- // rendering a preview layout for work profile apps yet. For non-work profile layout, a
- // proper solution is to use RemoteViews(PackageName, LayoutId).
- launcherAppWidgetProviderInfo.initialLayout = item.widgetInfo.previewLayout;
- setAppWidgetHostViewPreview(mAppWidgetHostViewPreview,
- launcherAppWidgetProviderInfo, /* remoteViews= */ null);
}
private void setAppWidgetHostViewPreview(
@@ -353,6 +266,43 @@
appWidgetHostViewPreview.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
appWidgetHostViewPreview.setAppWidget(/* appWidgetId= */ -1, providerInfo);
appWidgetHostViewPreview.updateAppWidget(remoteViews);
+ appWidgetHostViewPreview.setClipToPadding(false);
+ appWidgetHostViewPreview.setClipChildren(false);
+
+ FrameLayout.LayoutParams widgetHostLP = new FrameLayout.LayoutParams(
+ mWidgetSize.getWidth(), mWidgetSize.getHeight(), Gravity.CENTER);
+ mWidgetImageContainer.addView(appWidgetHostViewPreview, /* index= */ 0, widgetHostLP);
+ mWidgetImage.setVisibility(View.GONE);
+ applyPreview(null);
+
+ appWidgetHostViewPreview.addOnLayoutChangeListener(
+ (v, l, t, r, b, ol, ot, or, ob) ->
+ updateAppWidgetHostScale(appWidgetHostViewPreview));
+ }
+
+ private void updateAppWidgetHostScale(NavigableAppWidgetHostView view) {
+ // Scale the content such that all of the content is visible
+ int contentWidth = view.getWidth();
+ int contentHeight = view.getHeight();
+
+ if (view.getChildCount() == 1) {
+ View content = view.getChildAt(0);
+ // Take the content width based on the edge furthest from the center, so that when
+ // scaling the hostView, the farthest edge is still visible.
+ contentWidth = 2 * Math.max(contentWidth / 2 - content.getLeft(),
+ content.getRight() - contentWidth / 2);
+ contentHeight = 2 * Math.max(contentHeight / 2 - content.getTop(),
+ content.getBottom() - contentHeight / 2);
+ }
+
+ if (contentWidth <= 0 || contentHeight <= 0) {
+ mAppWidgetHostViewScale = 1;
+ } else {
+ float pWidth = mWidgetImageContainer.getWidth();
+ float pHeight = mWidgetImageContainer.getHeight();
+ mAppWidgetHostViewScale = Math.min(pWidth / contentWidth, pHeight / contentHeight);
+ }
+ view.setScaleToFit(mAppWidgetHostViewScale);
}
public WidgetImageView getWidgetView() {
@@ -372,17 +322,6 @@
if (bitmap != null) {
Drawable drawable = new RoundDrawableWrapper(
new FastBitmapDrawable(bitmap), mEnforcedCornerRadius);
-
- // Scale down the preview size if it's wider than the cell.
- float scale = 1f;
- if (mTargetPreviewWidth > 0) {
- float maxWidth = mTargetPreviewWidth;
- float previewWidth = drawable.getIntrinsicWidth() * mPreviewContainerScale;
- scale = Math.min(maxWidth / previewWidth, 1);
- }
- setContainerSize(
- Math.round(drawable.getIntrinsicWidth() * scale * mPreviewContainerScale),
- Math.round(drawable.getIntrinsicHeight() * scale * mPreviewContainerScale));
mWidgetImage.setDrawable(drawable);
mWidgetImage.setVisibility(View.VISIBLE);
if (mAppWidgetHostViewPreview != null) {
@@ -415,76 +354,6 @@
}
}
- private void setContainerSize(int width, int height) {
- LayoutParams layoutParams = (LayoutParams) mWidgetImageContainer.getLayoutParams();
- layoutParams.width = width;
- layoutParams.height = height;
- mWidgetImageContainer.setLayoutParams(layoutParams);
- }
-
- /**
- * Ensures that the preview is already loaded or being loaded. If the preview is not loaded,
- * it applies the provided cachedPreview. If that is null, it starts a loader and notifies the
- * callback on successful load.
- */
- private void ensurePreviewWithCallback(Consumer<Bitmap> callback,
- @Nullable Bitmap cachedPreview) {
- if (mAppWidgetHostViewPreview != null) {
- int containerWidth = (int) (mTargetPreviewWidth * mPreviewContainerScale);
- int containerHeight = (int) (mTargetPreviewHeight * mPreviewContainerScale);
- setContainerSize(containerWidth, containerHeight);
- boolean shouldMeasureAndScale = false;
- if (mAppWidgetHostViewPreview.getChildCount() == 1) {
- View widgetContent = mAppWidgetHostViewPreview.getChildAt(0);
- ViewGroup.LayoutParams layoutParams = widgetContent.getLayoutParams();
- // We only scale preview if both the width & height of the outermost view group are
- // not set to MATCH_PARENT.
- shouldMeasureAndScale =
- layoutParams.width != MATCH_PARENT && layoutParams.height != MATCH_PARENT;
- if (shouldMeasureAndScale) {
- setNoClip(mWidgetImageContainer);
- setNoClip(mAppWidgetHostViewPreview);
- mAppWidgetHostViewScale = measureAndComputeWidgetPreviewScale();
- }
- }
-
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
- mTargetPreviewWidth, mTargetPreviewHeight, Gravity.FILL);
- mAppWidgetHostViewPreview.setLayoutParams(params);
-
- if (!shouldMeasureAndScale
- && mAppWidgetHostViewPreview instanceof ScaledAppWidgetHostView) {
- // If the view is not measured & scaled, at least one side will match the grid size,
- // so it should be safe to restore the original scale once it is dragged.
- ScaledAppWidgetHostView tempView =
- (ScaledAppWidgetHostView) mAppWidgetHostViewPreview;
- tempView.setKeepOrigForDragging(false);
- tempView.setScaleToFit(mPreviewContainerScale);
- } else if (!shouldMeasureAndScale) {
- mAppWidgetHostViewPreview.setScaleToFit(mPreviewContainerScale);
- } else {
- mAppWidgetHostViewPreview.setScaleToFit(mAppWidgetHostViewScale);
- }
- mAppWidgetHostViewPreview.getTranslateDelegate().setTranslation(
- INDEX_WIDGET_CENTERING,
- -(params.width - (params.width * mPreviewContainerScale)) / 2.0f,
- -(params.height - (params.height * mPreviewContainerScale)) / 2.0f);
- mWidgetImageContainer.addView(mAppWidgetHostViewPreview, /* index= */ 0);
- mWidgetImage.setVisibility(View.GONE);
- applyPreview(null);
- return;
- }
- if (cachedPreview != null) {
- applyPreview(cachedPreview);
- return;
- }
- if (mActiveRequest != null) {
- return;
- }
- mActiveRequest = mWidgetPreviewLoader.loadPreview(
- mItem, new Size(mTargetPreviewWidth, mTargetPreviewHeight), callback);
- }
-
@Override
public boolean onTouchEvent(MotionEvent ev) {
super.onTouchEvent(ev);
@@ -522,61 +391,20 @@
info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK);
}
- private static void setNoClip(ViewGroup view) {
- view.setClipChildren(false);
- view.setClipToPadding(false);
- }
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ ViewGroup.LayoutParams containerLp = mWidgetImageContainer.getLayoutParams();
- private float measureAndComputeWidgetPreviewScale() {
- if (mAppWidgetHostViewPreview.getChildCount() != 1) {
- return 1f;
+ mAppWidgetHostViewScale = mPreviewContainerScale;
+ int maxWidth = MeasureSpec.getSize(widthMeasureSpec);
+ containerLp.width = Math.round(mWidgetSize.getWidth() * mAppWidgetHostViewScale);
+ if (containerLp.width > maxWidth) {
+ containerLp.width = maxWidth;
+ mAppWidgetHostViewScale = (float) containerLp.width / mWidgetSize.getWidth();
}
+ containerLp.height = Math.round(mWidgetSize.getHeight() * mAppWidgetHostViewScale);
+ // No need to call mWidgetImageContainer.setLayoutParams as we are in measure pass
- // Measure the largest possible width & height that the app widget wants to display.
- mAppWidgetHostViewPreview.measure(
- makeMeasureSpec(MAX_MEASURE_SPEC_DIMENSION, MeasureSpec.UNSPECIFIED),
- makeMeasureSpec(MAX_MEASURE_SPEC_DIMENSION, MeasureSpec.UNSPECIFIED));
- if (mRemoteViewsPreview != null) {
- // If RemoteViews contains multiple sizes, the best fit sized RemoteViews will be
- // selected in onLayout. To work out the right measurement, let's layout and then
- // measure again.
- mAppWidgetHostViewPreview.layout(
- /* left= */ 0,
- /* top= */ 0,
- /* right= */ mTargetPreviewWidth,
- /* bottom= */ mTargetPreviewHeight);
- mAppWidgetHostViewPreview.measure(
- makeMeasureSpec(mTargetPreviewWidth, MeasureSpec.UNSPECIFIED),
- makeMeasureSpec(mTargetPreviewHeight, MeasureSpec.UNSPECIFIED));
-
- }
- View widgetContent = mAppWidgetHostViewPreview.getChildAt(0);
- int appWidgetContentWidth = widgetContent.getMeasuredWidth();
- int appWidgetContentHeight = widgetContent.getMeasuredHeight();
- if (appWidgetContentWidth == 0 || appWidgetContentHeight == 0) {
- return 1f;
- }
-
- // If the width / height of the widget content is set to wrap content, overrides the width /
- // height with the measured dimension. This avoids incorrect measurement after scaling.
- FrameLayout.LayoutParams layoutParam =
- (FrameLayout.LayoutParams) widgetContent.getLayoutParams();
- if (layoutParam.width == WRAP_CONTENT) {
- layoutParam.width = widgetContent.getMeasuredWidth();
- }
- if (layoutParam.height == WRAP_CONTENT) {
- layoutParam.height = widgetContent.getMeasuredHeight();
- }
- widgetContent.setLayoutParams(layoutParam);
-
- int horizontalPadding = mAppWidgetHostViewPreview.getPaddingStart()
- + mAppWidgetHostViewPreview.getPaddingEnd();
- int verticalPadding = mAppWidgetHostViewPreview.getPaddingTop()
- + mAppWidgetHostViewPreview.getPaddingBottom();
- return Math.min(
- (mTargetPreviewWidth - horizontalPadding) * mPreviewContainerScale
- / appWidgetContentWidth,
- (mTargetPreviewHeight - verticalPadding) * mPreviewContainerScale
- / appWidgetContentHeight);
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index 23cdae9..846dafd 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -252,8 +252,11 @@
super.setInsets(insets);
int bottomPadding = Math.max(insets.bottom, mNavBarScrimHeight);
- mContent.setPadding(mContent.getPaddingStart(),
- mContent.getPaddingTop(), mContent.getPaddingEnd(),
+ View widgetsTable = findViewById(R.id.widgets_table);
+ widgetsTable.setPadding(
+ widgetsTable.getPaddingLeft(),
+ widgetsTable.getPaddingTop(),
+ widgetsTable.getPaddingRight(),
bottomPadding);
if (bottomPadding > 0) {
setupNavBarColor();
diff --git a/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java b/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java
index 1b743e8..2f16065 100644
--- a/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java
+++ b/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java
@@ -129,7 +129,7 @@
LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo);
widgetsAndShortcuts.add(new WidgetItem(
- launcherWidgetInfo, idp, app.getIconCache()));
+ launcherWidgetInfo, idp, app.getIconCache(), app.getContext()));
updatedItems.add(launcherWidgetInfo);
}
@@ -200,7 +200,8 @@
app.getContext().getPackageManager()));
} else {
items.set(i, new WidgetItem(item.widgetInfo,
- app.getInvariantDeviceProfile(), app.getIconCache()));
+ app.getInvariantDeviceProfile(), app.getIconCache(),
+ app.getContext()));
}
}
}
diff --git a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java
index b472cdb..601b07e 100644
--- a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java
+++ b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java
@@ -90,6 +90,7 @@
public static final String REQUEST_DISABLE_TRANSIENT_TASKBAR = "disable-transient-taskbar";
public static final String REQUEST_UNSTASH_TASKBAR_IF_STASHED = "unstash-taskbar-if-stashed";
public static final String REQUEST_STASHED_TASKBAR_HEIGHT = "stashed-taskbar-height";
+ public static final String REQUEST_STASHED_TASKBAR_SCALE = "taskbar-stash-handle-scale";
public static final String REQUEST_RECREATE_TASKBAR = "recreate-taskbar";
public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags";
public static final String REQUEST_APPS_LIST_SCROLL_Y = "apps-list-scroll-y";
diff --git a/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java b/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java
index 76492ba..8fc4481 100644
--- a/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java
+++ b/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java
@@ -147,7 +147,7 @@
widgetItems.add(new WidgetItem(
LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, widgetInfo),
- mTestProfile, mIconCache));
+ mTestProfile, mIconCache, mContext));
}
return widgetItems;
}
diff --git a/tests/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinderTest.java b/tests/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinderTest.java
index e0101f5..60590e7 100644
--- a/tests/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinderTest.java
+++ b/tests/src/com/android/launcher3/widget/picker/WidgetsListTableViewHolderBinderTest.java
@@ -144,7 +144,7 @@
widgetItems.add(new WidgetItem(
LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, widgetInfo),
- mTestProfile, mIconCache));
+ mTestProfile, mIconCache, mContext));
}
return widgetItems;
}
diff --git a/tests/src/com/android/launcher3/widget/picker/model/WidgetsListContentEntryTest.java b/tests/src/com/android/launcher3/widget/picker/model/WidgetsListContentEntryTest.java
index d8f1f14..7552619 100644
--- a/tests/src/com/android/launcher3/widget/picker/model/WidgetsListContentEntryTest.java
+++ b/tests/src/com/android/launcher3/widget/picker/model/WidgetsListContentEntryTest.java
@@ -26,6 +26,7 @@
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
+import android.content.Context;
import android.os.UserHandle;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -249,12 +250,13 @@
String label = mWidgetsToLabels.get(componentName);
AppWidgetProviderInfo widgetInfo = createAppWidgetProviderInfo(componentName);
+ Context context = getApplicationContext();
LauncherAppWidgetProviderInfo launcherAppWidgetProviderInfo =
- LauncherAppWidgetProviderInfo.fromProviderInfo(getApplicationContext(), widgetInfo);
+ LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo);
launcherAppWidgetProviderInfo.spanX = spanX;
launcherAppWidgetProviderInfo.spanY = spanY;
launcherAppWidgetProviderInfo.label = label;
- return new WidgetItem(launcherAppWidgetProviderInfo, mTestProfile, mIconCache);
+ return new WidgetItem(launcherAppWidgetProviderInfo, mTestProfile, mIconCache, context);
}
}
diff --git a/tests/src/com/android/launcher3/widget/picker/search/SimpleWidgetsSearchAlgorithmTest.java b/tests/src/com/android/launcher3/widget/picker/search/SimpleWidgetsSearchAlgorithmTest.java
index 0124f73..9c03ccf 100644
--- a/tests/src/com/android/launcher3/widget/picker/search/SimpleWidgetsSearchAlgorithmTest.java
+++ b/tests/src/com/android/launcher3/widget/picker/search/SimpleWidgetsSearchAlgorithmTest.java
@@ -202,7 +202,7 @@
WidgetItem widgetItem = new WidgetItem(
LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, widgetInfo),
- mTestProfile, mIconCache);
+ mTestProfile, mIconCache, mContext);
widgetItems.add(widgetItem);
}
return widgetItems;
diff --git a/tests/src/com/android/launcher3/widget/picker/util/WidgetsTableUtilsTest.java b/tests/src/com/android/launcher3/widget/picker/util/WidgetsTableUtilsTest.java
index 834f851..2c5a396 100644
--- a/tests/src/com/android/launcher3/widget/picker/util/WidgetsTableUtilsTest.java
+++ b/tests/src/com/android/launcher3/widget/picker/util/WidgetsTableUtilsTest.java
@@ -218,19 +218,18 @@
new Point(2, 4), new Point(4, 4));
ArrayList<WidgetItem> widgetItems = new ArrayList<>();
- widgetSizes.stream().forEach(
- widgetSize -> {
- AppWidgetProviderInfo info = createAppWidgetProviderInfo(
- ComponentName.createRelative(
- TEST_PACKAGE,
- ".WidgetProvider_" + widgetSize.x + "x" + widgetSize.y));
- LauncherAppWidgetProviderInfo widgetInfo =
- LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
- widgetInfo.spanX = widgetSize.x;
- widgetInfo.spanY = widgetSize.y;
- widgetItems.add(new WidgetItem(widgetInfo, mTestInvariantProfile, mIconCache));
- }
- );
+ widgetSizes.stream().forEach(widgetSize -> {
+ AppWidgetProviderInfo info = createAppWidgetProviderInfo(
+ ComponentName.createRelative(
+ TEST_PACKAGE,
+ ".WidgetProvider_" + widgetSize.x + "x" + widgetSize.y));
+ LauncherAppWidgetProviderInfo widgetInfo =
+ LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
+ widgetInfo.spanX = widgetSize.x;
+ widgetInfo.spanY = widgetSize.y;
+ widgetItems.add(new WidgetItem(
+ widgetInfo, mTestInvariantProfile, mIconCache, mContext));
+ });
mWidget1x1 = widgetItems.get(0);
mWidget2x2 = widgetItems.get(1);
mWidget2x3 = widgetItems.get(2);
diff --git a/tests/tapl/com/android/launcher3/tapl/AppIcon.java b/tests/tapl/com/android/launcher3/tapl/AppIcon.java
index 2687b28..0a0cf07 100644
--- a/tests/tapl/com/android/launcher3/tapl/AppIcon.java
+++ b/tests/tapl/com/android/launcher3/tapl/AppIcon.java
@@ -37,7 +37,8 @@
}
static BySelector getAppIconSelector(String appName, LauncherInstrumentation launcher) {
- return By.clazz(TextView.class).text(appName).pkg(launcher.getLauncherPackageName());
+ return By.clazz(TextView.class).textContains(appName)
+ .pkg(launcher.getLauncherPackageName());
}
static BySelector getAnyAppIconSelector() {
diff --git a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java
index 58d5a36..a59eff7 100644
--- a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java
+++ b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java
@@ -25,13 +25,17 @@
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_SHELL_DRAG_READY;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_STASHED_TASKBAR_HEIGHT;
+import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_STASHED_TASKBAR_SCALE;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.SystemClock;
import android.view.MotionEvent;
+import android.view.ViewConfiguration;
import androidx.test.uiautomator.By;
+import androidx.test.uiautomator.Condition;
+import androidx.test.uiautomator.UiDevice;
import com.android.launcher3.testing.shared.TestProtocol;
@@ -43,6 +47,18 @@
// More drag steps than Launchables to give the window manager time to register the drag.
private static final int DEFAULT_DRAG_STEPS = 35;
+ // UNSTASHED_TASKBAR_HANDLE_HINT_SCALE value from TaskbarStashController.
+ private static final float UNSTASHED_TASKBAR_HANDLE_HINT_SCALE = 1.1f;
+
+ private final Condition<UiDevice, Boolean> mStashedTaskbarHintScaleCondition =
+ device -> mLauncher.getTestInfo(REQUEST_STASHED_TASKBAR_SCALE).getFloat(
+ TestProtocol.TEST_INFO_RESPONSE_FIELD) - UNSTASHED_TASKBAR_HANDLE_HINT_SCALE
+ < 0.00001f;
+
+ private final Condition<UiDevice, Boolean> mStashedTaskbarDefaultScaleCondition =
+ device -> mLauncher.getTestInfo(REQUEST_STASHED_TASKBAR_SCALE).getFloat(
+ TestProtocol.TEST_INFO_RESPONSE_FIELD) - 1f < 0.00001f;
+
LaunchedAppState(LauncherInstrumentation launcher) {
super(launcher);
}
@@ -187,4 +203,89 @@
}
}
}
+
+ /**
+ * Emulate the cursor hovering the screen edge to unstash the taskbar.
+ *
+ * <p>This unstashing occurs when not actively hovering the taskbar.
+ */
+ public void hoverScreenBottomEdgeToUnstashTaskbar() {
+ try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
+ LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "cursor hover entering screen edge to unstash taskbar")) {
+ mLauncher.getDevice().wait(mStashedTaskbarDefaultScaleCondition,
+ ViewConfiguration.DEFAULT_LONG_PRESS_TIMEOUT);
+
+ long downTime = SystemClock.uptimeMillis();
+ int leftEdge = 10;
+ Point taskbarUnstashArea = new Point(leftEdge, mLauncher.getRealDisplaySize().y - 1);
+ mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_ENTER,
+ new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null);
+
+ mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID);
+
+ mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_EXIT,
+ new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null);
+ }
+ }
+
+ /**
+ * Emulate the cursor hovering the taskbar to get unstash hint, then hovering below to unstash.
+ */
+ public void hoverBelowHintedTaskbarToUnstash() {
+ try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
+ LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "cursor hover entering stashed taskbar")) {
+ long downTime = SystemClock.uptimeMillis();
+ Point stashedTaskbarHintArea = new Point(mLauncher.getRealDisplaySize().x / 2,
+ mLauncher.getRealDisplaySize().y - 1);
+ mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_ENTER,
+ new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), null);
+
+ mLauncher.getDevice().wait(mStashedTaskbarHintScaleCondition,
+ LauncherInstrumentation.WAIT_TIME_MS);
+
+ try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
+ "cursor hover enter below taskbar to unstash")) {
+ downTime = SystemClock.uptimeMillis();
+ Point taskbarUnstashArea = new Point(mLauncher.getRealDisplaySize().x / 2,
+ mLauncher.getRealDisplaySize().y - 1);
+ mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_EXIT,
+ new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null);
+
+ mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID);
+ }
+ }
+ }
+
+ /**
+ * Emulate the cursor entering and exiting a hover over the taskbar.
+ */
+ public void hoverToShowTaskbarUnstashHint() {
+ try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
+ LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "cursor hover entering stashed taskbar")) {
+ long downTime = SystemClock.uptimeMillis();
+ Point stashedTaskbarHintArea = new Point(mLauncher.getRealDisplaySize().x / 2,
+ mLauncher.getRealDisplaySize().y - 1);
+ mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_ENTER,
+ new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), null);
+
+ mLauncher.getDevice().wait(mStashedTaskbarHintScaleCondition,
+ LauncherInstrumentation.WAIT_TIME_MS);
+
+ try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
+ "cursor hover exiting stashed taskbar")) {
+ Point outsideStashedTaskbarHintArea = new Point(
+ mLauncher.getRealDisplaySize().x / 2,
+ mLauncher.getRealDisplaySize().y - 500);
+ mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_EXIT,
+ new Point(outsideStashedTaskbarHintArea.x, outsideStashedTaskbarHintArea.y),
+ null);
+
+ mLauncher.getDevice().wait(mStashedTaskbarDefaultScaleCondition,
+ LauncherInstrumentation.WAIT_TIME_MS);
+ }
+ }
+ }
}