Merge "Report when a notification is shown in the popup" into ub-launcher3-edmonton-polish
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b7c5793..3212980 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -56,7 +56,7 @@
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher_home"
android:label="@string/derived_app_name"
- android:theme="@style/LauncherTheme"
+ android:theme="@style/AppTheme"
android:largeHeap="@bool/config_largeHeap"
android:restoreAnyVersion="true"
android:supportsRtl="true" >
diff --git a/go/AndroidManifest.xml b/go/AndroidManifest.xml
index fbaf981..0a9ad7b 100644
--- a/go/AndroidManifest.xml
+++ b/go/AndroidManifest.xml
@@ -31,7 +31,7 @@
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher_home"
android:label="@string/derived_app_name"
- android:theme="@style/LauncherTheme"
+ android:theme="@style/AppTheme"
android:largeHeap="@bool/config_largeHeap"
android:restoreAnyVersion="true"
android:supportsRtl="true" >
diff --git a/proguard.flags b/proguard.flags
index 555d13e..e401116 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -112,6 +112,11 @@
public <init>(...);
}
+# UserEventDispatcherExtension
+-keep class com.android.quickstep.logging.UserEventDispatcherExtension {
+ public <init>(...);
+}
+
-keep interface com.android.launcher3.userevent.nano.LauncherLogProto.** {
*;
}
diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml
index 778866d..cb74855 100644
--- a/quickstep/AndroidManifest.xml
+++ b/quickstep/AndroidManifest.xml
@@ -31,7 +31,7 @@
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher_home"
android:label="@string/derived_app_name"
- android:theme="@style/LauncherTheme"
+ android:theme="@style/AppTheme"
android:largeHeap="@bool/config_largeHeap"
android:restoreAnyVersion="true"
android:supportsRtl="true" >
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index 53a6ceb..27de1e9 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/res/drawable/ic_split_screen.xml b/quickstep/res/drawable/ic_split_screen.xml
index 77bd333..110af91 100644
--- a/quickstep/res/drawable/ic_split_screen.xml
+++ b/quickstep/res/drawable/ic_split_screen.xml
@@ -13,33 +13,16 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="88.0dp"
- android:height="88.0dp"
- android:viewportWidth="88.0"
- android:viewportHeight="88.0" >
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
<path
- android:pathData="M 32,11
- C 32,11 68,11 68,11
- 76.74,11.06 76.98,12.76 77,21
- 77.01,25.97 78.50,38.23 73.85,40.98
- 71.80,42.19 68.35,42 66,42
- 66,42 22,42 22,42
- 18.82,41.99 14.87,42.38 12.60,39.69
- 10.71,37.44 11.01,33.77 11,31
- 10.99,25.54 9.53,16.08 13.31,12.02
- 18.07,10.21 26.66,11 32,11 Z
- M 32,46
- C 32,46 68,46 68,46
- 76.74,46.06 76.98,47.76 77,56
- 77.01,60.97 78.50,73.23 73.85,75.98
- 71.80,77.19 68.35,77 66,77
- 66,77 22,77 22,77
- 18.82,76.99 14.87,77.38 12.60,74.69
- 10.71,72.44 11.01,68.77 11,66
- 10.99,60.54 9.53,51.08 13.31,47.02
- 18.07,45.21 26.66,46 32,46 Z"
- android:fillColor="@android:color/white" />
-</vector>
\ No newline at end of file
+ android:fillColor="@android:color/white"
+ android:pathData="M18,4v5H6V4H18 M18,2H6C4.9,2,4,2.9,4,4v5c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V4C20,2.9,19.1,2,18,2L18,2z" />
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M18,15v5H6v-5H18 M18,13H6c-1.1,0-2,0.9-2,2v5c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-5C20,13.9,19.1,13,18,13L18,13z" />
+</vector>
diff --git a/quickstep/res/drawable/task_menu_bg.xml b/quickstep/res/drawable/task_menu_bg.xml
new file mode 100644
index 0000000..d5597a9
--- /dev/null
+++ b/quickstep/res/drawable/task_menu_bg.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 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.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:gravity="bottom">
+ <!-- Shadow -->
+ <shape>
+ <gradient android:angle="270"
+ android:endColor="@android:color/transparent"
+ android:startColor="#26000000" />
+ <size android:height="@dimen/task_card_menu_shadow_height" />
+ </shape>
+ </item>
+ <item android:bottom="@dimen/task_card_menu_shadow_height">
+ <!-- Background -->
+ <shape>
+ <corners
+ android:topLeftRadius="@dimen/task_corner_radius"
+ android:topRightRadius="@dimen/task_corner_radius"
+ android:bottomLeftRadius="0dp"
+ android:bottomRightRadius="0dp" />
+ <solid android:color="?attr/popupColorPrimary" />
+ </shape>
+ </item>
+</layer-list>
diff --git a/quickstep/res/layout/fallback_recents_activity.xml b/quickstep/res/layout/fallback_recents_activity.xml
index 7ecab32..ef272ed 100644
--- a/quickstep/res/layout/fallback_recents_activity.xml
+++ b/quickstep/res/layout/fallback_recents_activity.xml
@@ -20,23 +20,12 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true">
- <com.android.quickstep.views.RecentsViewContainer
- android:id="@+id/overview_panel_container"
+ <com.android.quickstep.fallback.FallbackRecentsView
+ android:id="@id/overview_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
- >
- <include layout="@layout/overview_clear_all_button"/>
-
- <com.android.quickstep.fallback.FallbackRecentsView
- android:id="@id/overview_panel"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clipChildren="false"
- android:clipToPadding="false"
- android:focusableInTouchMode="true"
- android:theme="@style/HomeScreenElementTheme"
- >
-
- </com.android.quickstep.fallback.FallbackRecentsView>
- </com.android.quickstep.views.RecentsViewContainer>
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ android:outlineProvider="none"
+ android:theme="@style/HomeScreenElementTheme" />
</com.android.quickstep.fallback.RecentsRootView>
diff --git a/quickstep/res/layout/overview_clear_all_button.xml b/quickstep/res/layout/overview_clear_all_button.xml
index 25615e0..ea7a494 100644
--- a/quickstep/res/layout/overview_clear_all_button.xml
+++ b/quickstep/res/layout/overview_clear_all_button.xml
@@ -1,15 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 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.
+-->
<com.android.quickstep.views.ClearAllButton
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/clear_all_button"
style="@android:style/Widget.DeviceDefault.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="start|top"
android:text="@string/recents_clear_all"
android:textColor="?attr/workspaceTextColor"
- android:visibility="invisible"
android:textSize="14sp"
- android:importantForAccessibility="no"
-/>
\ No newline at end of file
+ android:translationY="@dimen/task_thumbnail_half_top_margin"
+ />
\ No newline at end of file
diff --git a/quickstep/res/layout/overview_panel.xml b/quickstep/res/layout/overview_panel.xml
index 919afdb..7f1425b 100644
--- a/quickstep/res/layout/overview_panel.xml
+++ b/quickstep/res/layout/overview_panel.xml
@@ -14,24 +14,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<com.android.quickstep.views.RecentsViewContainer
+<com.android.quickstep.views.LauncherRecentsView
xmlns:android="http://schemas.android.com/apk/res/android"
+ android:theme="@style/HomeScreenElementTheme"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="invisible"
->
- <include layout="@layout/overview_clear_all_button"/>
-
- <com.android.quickstep.views.LauncherRecentsView
- android:id="@id/overview_panel"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clipChildren="false"
- android:clipToPadding="false"
- android:focusableInTouchMode="true"
- android:accessibilityPaneTitle="@string/accessibility_recent_apps"
- android:theme="@style/HomeScreenElementTheme"
- >
-
- </com.android.quickstep.views.LauncherRecentsView>
-</com.android.quickstep.views.RecentsViewContainer>
\ No newline at end of file
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ android:accessibilityPaneTitle="@string/accessibility_recent_apps"
+ android:visibility="invisible" />
\ No newline at end of file
diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml
index f163872..36d327d 100644
--- a/quickstep/res/layout/task.xml
+++ b/quickstep/res/layout/task.xml
@@ -17,8 +17,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:focusable="false"
- android:elevation="4dp">
+ android:defaultFocusHighlightEnabled="false"
+ android:elevation="4dp"
+ android:focusable="true">
<com.android.quickstep.views.TaskThumbnailView
android:id="@+id/snapshot"
@@ -30,7 +31,7 @@
android:id="@+id/icon"
android:layout_width="@dimen/task_thumbnail_icon_size"
android:layout_height="@dimen/task_thumbnail_icon_size"
- android:importantForAccessibility="no"
+ android:layout_gravity="top|center_horizontal"
android:focusable="false"
- android:layout_gravity="top|center_horizontal" />
+ android:importantForAccessibility="no" />
</com.android.quickstep.views.TaskView>
\ No newline at end of file
diff --git a/quickstep/res/layout/task_menu.xml b/quickstep/res/layout/task_menu.xml
index b846665..bf55ece 100644
--- a/quickstep/res/layout/task_menu.xml
+++ b/quickstep/res/layout/task_menu.xml
@@ -16,21 +16,31 @@
-->
<com.android.quickstep.views.TaskMenuView
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="@dimen/bg_popup_item_width"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:visibility="invisible"
- android:elevation="@dimen/deep_shortcuts_elevation"
+ android:animateLayoutChanges="true"
+ android:background="@drawable/task_menu_bg"
+ android:paddingBottom="@dimen/task_card_menu_shadow_height"
android:orientation="vertical"
- android:background="?attr/popupColorPrimary"
- android:divider="@drawable/all_apps_divider"
- android:showDividers="middle"
- android:animateLayoutChanges="true">
- <TextView
- android:id="@+id/task_icon_and_name"
- android:layout_width="match_parent"
- android:layout_height="112dp"
- android:textSize="14sp"
- android:paddingTop="18dp"
- android:drawablePadding="8dp"
- android:gravity="center_horizontal"/>
+ android:visibility="invisible">
+
+ <TextView
+ android:id="@+id/task_icon_and_name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:drawablePadding="@dimen/deep_shortcut_drawable_padding"
+ android:gravity="center_horizontal"
+ android:layout_marginBottom="16dp"
+ android:textSize="12sp"/>
+
+ <LinearLayout
+ android:id="@+id/menu_option_layout"
+ style="@style/TaskMenu"
+ android:divider="@drawable/all_apps_divider"
+ android:showDividers="beginning"
+ android:paddingStart="@dimen/task_card_menu_horizontal_padding"
+ android:paddingEnd="@dimen/task_card_menu_horizontal_padding"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
</com.android.quickstep.views.TaskMenuView>
\ No newline at end of file
diff --git a/quickstep/res/layout/task_view_menu_option.xml b/quickstep/res/layout/task_view_menu_option.xml
new file mode 100644
index 0000000..102ae9b
--- /dev/null
+++ b/quickstep/res/layout/task_view_menu_option.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/TaskMenu.Option"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:orientation="vertical"
+ android:paddingTop="@dimen/task_card_menu_option_vertical_padding"
+ android:paddingBottom="@dimen/task_card_menu_option_vertical_padding"
+ android:background="?android:attr/selectableItemBackground"
+ android:theme="@style/PopupItem" >
+
+ <View
+ android:id="@+id/icon"
+ android:layout_width="@dimen/system_shortcut_icon_size"
+ android:layout_height="@dimen/system_shortcut_icon_size"
+ android:layout_marginTop="@dimen/system_shortcut_header_icon_padding"
+ android:layout_marginBottom="@dimen/deep_shortcut_drawable_padding"
+ android:layout_gravity="center_horizontal"
+ android:backgroundTint="?android:attr/textColorTertiary"/>
+
+ <TextView
+ style="@style/BaseIcon"
+ android:id="@+id/text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="@dimen/popup_padding_end"
+ android:textSize="12sp"
+ android:textColor="?android:attr/textColorPrimary"
+ android:fontFamily="sans-serif"
+ android:gravity="center_horizontal"
+ android:layout_gravity="center_horizontal"
+ android:focusable="false" />
+
+</LinearLayout>
diff --git a/quickstep/res/values-land/dimens.xml b/quickstep/res/values-land/dimens.xml
new file mode 100644
index 0000000..c03eaa2
--- /dev/null
+++ b/quickstep/res/values-land/dimens.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <dimen name="task_card_menu_horizontal_padding">24dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/quickstep/res/values-land/styles.xml b/quickstep/res/values-land/styles.xml
new file mode 100644
index 0000000..0824b4f
--- /dev/null
+++ b/quickstep/res/values-land/styles.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <!-- Task Menu layout styles. -->
+ <style name="TaskMenu">
+ <item name="android:orientation">horizontal</item>
+ </style>
+
+ <!-- Task Menu Option layout styles. -->
+ <style name="TaskMenu.Option">
+ <item name="android:layout_width">0dp</item>
+ <item name="android:layout_weight">1</item>
+ </style>
+</resources>
\ No newline at end of file
diff --git a/quickstep/res/values/config.xml b/quickstep/res/values/config.xml
index 7673f69..c294376 100644
--- a/quickstep/res/values/config.xml
+++ b/quickstep/res/values/config.xml
@@ -18,5 +18,5 @@
<string name="overview_callbacks_class" translatable="false"></string>
- <string name="user_event_dispatcher_class" translatable="false">com.google.quickstep.logging.UserEventDispatcherExtension</string>
+ <string name="user_event_dispatcher_class" translatable="false">com.android.quickstep.logging.UserEventDispatcherExtension</string>
</resources>
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index ed18bf5..afaad38 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -17,8 +17,8 @@
<resources>
<dimen name="task_thumbnail_top_margin">24dp</dimen>
+ <dimen name="task_thumbnail_half_top_margin">12dp</dimen>
<dimen name="task_thumbnail_icon_size">48dp</dimen>
- <dimen name="task_menu_background_radius">12dp</dimen>
<dimen name="task_corner_radius">2dp</dimen>
<dimen name="recents_page_spacing">10dp</dimen>
<dimen name="quickscrub_adjacent_visible_width">20dp</dimen>
@@ -41,6 +41,9 @@
<!-- Total space (start + end) between the task card and the edge of the screen
in various configurations -->
<dimen name="task_card_vert_space">40dp</dimen>
+ <dimen name="task_card_menu_option_vertical_padding">8dp</dimen>
+ <dimen name="task_card_menu_shadow_height">3dp</dimen>
+ <dimen name="task_card_menu_horizontal_padding">0dp</dimen>
<dimen name="portrait_task_card_horz_space">136dp</dimen>
<dimen name="landscape_task_card_horz_space">200dp</dimen>
<dimen name="multi_window_task_card_horz_space">100dp</dimen>
@@ -48,8 +51,7 @@
docked_stack_divider_thickness - 2 * docked_stack_divider_insets -->
<dimen name="multi_window_task_divider_size">10dp</dimen>
- <!-- Width of the space behind the last task in Overview. In the center of it, there is "Clear all" button. -->
- <dimen name="clear_all_container_width">168dp</dimen>
-
<dimen name="shelf_surface_radius">16dp</dimen>
+ <!-- same as vertical_drag_handle_size -->
+ <dimen name="shelf_surface_offset">24dp</dimen>
</resources>
diff --git a/quickstep/res/values/styles.xml b/quickstep/res/values/styles.xml
new file mode 100644
index 0000000..bb364ff
--- /dev/null
+++ b/quickstep/res/values/styles.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <!-- Task Menu layout styles. -->
+ <style name="TaskMenu">
+ <item name="android:orientation">vertical</item>
+ </style>
+
+ <!-- Task Menu Option layout styles. -->
+ <style name="TaskMenu.Option">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ </style>
+</resources>
\ No newline at end of file
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
index eea71ca..13530b2 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
@@ -18,6 +18,8 @@
import static com.android.launcher3.BaseActivity.INVISIBLE_ALL;
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_APP_TRANSITIONS;
+import static com.android.launcher3.BaseActivity.INVISIBLE_BY_PENDING_FLAGS;
+import static com.android.launcher3.BaseActivity.PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
@@ -31,8 +33,6 @@
import static com.android.quickstep.TaskUtils.findTaskViewToLaunch;
import static com.android.quickstep.TaskUtils.getRecentsWindowAnimator;
import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
-import static com.android.systemui.shared.recents.utilities.Utilities.getNextFrameNumber;
-import static com.android.systemui.shared.recents.utilities.Utilities.getSurface;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;
@@ -53,9 +53,7 @@
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Looper;
-import android.util.Log;
import android.util.Pair;
-import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
@@ -72,6 +70,7 @@
import com.android.quickstep.util.ClipAnimationHelper;
import com.android.quickstep.util.MultiValueUpdateListener;
import com.android.quickstep.util.RemoteAnimationProvider;
+import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.system.ActivityCompat;
@@ -80,7 +79,8 @@
import com.android.systemui.shared.system.RemoteAnimationDefinitionCompat;
import com.android.systemui.shared.system.RemoteAnimationRunnerCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
-import com.android.systemui.shared.system.TransactionCompat;
+import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplier;
+import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplier.SurfaceParams;
import com.android.systemui.shared.system.WindowManagerWrapper;
/**
@@ -92,8 +92,16 @@
implements OnDeviceProfileChangeListener {
private static final String TAG = "LauncherTransition";
+
+ /** Duration of status bar animations. */
public static final int STATUS_BAR_TRANSITION_DURATION = 120;
+ /**
+ * Since our animations decelerate heavily when finishing, we want to start status bar animations
+ * x ms before the ending.
+ */
+ public static final int STATUS_BAR_TRANSITION_PRE_DELAY = 96;
+
private static final String CONTROL_REMOTE_APP_TRANSITION_PERMISSION =
"android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS";
@@ -210,9 +218,14 @@
}
};
- int duration = findTaskViewToLaunch(launcher, v, null) != null
- ? RECENTS_LAUNCH_DURATION : APP_LAUNCH_DURATION;
- int statusBarTransitionDelay = duration - STATUS_BAR_TRANSITION_DURATION;
+ boolean fromRecents = mLauncher.getStateManager().getState().overviewUi
+ && findTaskViewToLaunch(launcher, v, null) != null;
+ int duration = fromRecents
+ ? RECENTS_LAUNCH_DURATION
+ : APP_LAUNCH_DURATION;
+
+ int statusBarTransitionDelay = duration - STATUS_BAR_TRANSITION_DURATION
+ - STATUS_BAR_TRANSITION_PRE_DELAY;
return ActivityOptionsCompat.makeRemoteAnimation(new RemoteAnimationAdapterCompat(
runner, duration, statusBarTransitionDelay));
}
@@ -369,8 +382,9 @@
launcherAnimator.play(ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS,
allAppsController.getProgress(), ALL_APPS_PROGRESS_OFF_SCREEN));
- View overview = mLauncher.getOverviewPanelContainer();
- ObjectAnimator alpha = ObjectAnimator.ofFloat(overview, View.ALPHA, alphas);
+ RecentsView overview = mLauncher.getOverviewPanel();
+ ObjectAnimator alpha = ObjectAnimator.ofFloat(overview,
+ RecentsView.CONTENT_ALPHA, alphas);
alpha.setDuration(217);
alpha.setInterpolator(LINEAR);
launcherAnimator.play(alpha);
@@ -380,14 +394,7 @@
transY.setDuration(350);
launcherAnimator.play(transY);
- overview.setLayerType(View.LAYER_TYPE_HARDWARE, null);
-
- endListener = () -> {
- overview.setLayerType(View.LAYER_TYPE_NONE, null);
- overview.setAlpha(1f);
- overview.setTranslationY(0f);
- mLauncher.getStateManager().reapplyState();
- };
+ endListener = mLauncher.getStateManager()::reapplyState;
} else {
mDragLayerAlpha.setValue(alphas[0]);
ObjectAnimator alpha =
@@ -558,22 +565,21 @@
Rect crop = new Rect();
Matrix matrix = new Matrix();
+ RemoteAnimationTargetSet openingTargets = new RemoteAnimationTargetSet(targets,
+ MODE_OPENING);
+ RemoteAnimationTargetSet closingTargets = new RemoteAnimationTargetSet(targets,
+ MODE_CLOSING);
+ SyncRtSurfaceTransactionApplier surfaceApplier = new SyncRtSurfaceTransactionApplier(
+ mFloatingView);
+
ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
appAnimator.setDuration(APP_LAUNCH_DURATION);
appAnimator.addUpdateListener(new MultiValueUpdateListener() {
// Fade alpha for the app window.
FloatProp mAlpha = new FloatProp(0f, 1f, 0, 60, LINEAR);
- boolean isFirstFrame = true;
@Override
public void onUpdate(float percent) {
- final Surface surface = getSurface(mFloatingView);
- final long frameNumber = surface != null ? getNextFrameNumber(surface) : -1;
- if (frameNumber == -1) {
- // Booo, not cool! Our surface got destroyed, so no reason to animate anything.
- Log.w(TAG, "Failed to animate, surface got destroyed.");
- return;
- }
final float easePercent = AGGRESSIVE_EASE.getInterpolation(percent);
// Calculate app icon size.
@@ -584,7 +590,6 @@
float scaleX = iconWidth / windowTargetBounds.width();
float scaleY = iconHeight / windowTargetBounds.height();
float scale = Math.min(1f, Math.min(scaleX, scaleY));
- matrix.setScale(scale, scale);
// Position the scaled window on top of the icon
int windowWidth = windowTargetBounds.width();
@@ -594,14 +599,10 @@
float offsetX = (scaledWindowWidth - iconWidth) / 2;
float offsetY = (scaledWindowHeight - iconHeight) / 2;
- if (mLauncher.isInMultiWindowModeCompat()) {
- mFloatingView.getLocationOnScreen(floatingViewBounds);
- } else {
- mFloatingView.getLocationInWindow(floatingViewBounds);
- }
+ mFloatingView.getLocationOnScreen(floatingViewBounds);
+
float transX0 = floatingViewBounds[0] - offsetX;
float transY0 = floatingViewBounds[1] - offsetY;
- matrix.postTranslate(transX0, transY0);
// Animate the window crop so that it starts off as a square, and then reveals
// horizontally.
@@ -612,23 +613,27 @@
crop.right = windowWidth;
crop.bottom = (int) (crop.top + cropHeight);
- TransactionCompat t = new TransactionCompat();
- if (isFirstFrame) {
- RemoteAnimationProvider.prepareTargetsForFirstFrame(targets, t, MODE_OPENING);
- isFirstFrame = false;
- }
- for (RemoteAnimationTargetCompat target : targets) {
- if (target.mode == MODE_OPENING) {
- t.setAlpha(target.leash, mAlpha.value);
- t.setMatrix(target.leash, matrix);
- t.setWindowCrop(target.leash, crop);
- t.deferTransactionUntil(target.leash, surface, getNextFrameNumber(surface));
- }
- }
- t.setEarlyWakeup();
- t.apply();
+ SurfaceParams[] params = new SurfaceParams[targets.length];
+ for (int i = targets.length - 1; i >= 0; i--) {
+ RemoteAnimationTargetCompat target = targets[i];
- matrix.reset();
+ Rect targetCrop;
+ float alpha;
+ if (target.mode == MODE_OPENING) {
+ matrix.setScale(scale, scale);
+ matrix.postTranslate(transX0, transY0);
+ targetCrop = crop;
+ alpha = mAlpha.value;
+ } else {
+ matrix.setTranslate(target.position.x, target.position.y);
+ alpha = 1f;
+ targetCrop = target.sourceContainerBounds;
+ }
+
+ params[i] = new SurfaceParams(target.leash, alpha, matrix, targetCrop,
+ RemoteAnimationProvider.getLayer(target, MODE_OPENING));
+ }
+ surfaceApplier.scheduleApply(params);
}
});
return appAnimator;
@@ -672,6 +677,11 @@
return;
}
+ if (mLauncher.hasSomeInvisibleFlag(PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION)) {
+ mLauncher.addForceInvisibleFlag(INVISIBLE_BY_PENDING_FLAGS);
+ mLauncher.getStateManager().moveToRestState();
+ }
+
AnimatorSet anim = null;
RemoteAnimationProvider provider = mRemoteAnimationProvider;
if (provider != null) {
@@ -708,6 +718,8 @@
* Animator that controls the transformations of the windows the targets that are closing.
*/
private Animator getClosingWindowAnimators(RemoteAnimationTargetCompat[] targets) {
+ SyncRtSurfaceTransactionApplier surfaceApplier =
+ new SyncRtSurfaceTransactionApplier(mDragLayer);
Matrix matrix = new Matrix();
ValueAnimator closingAnimator = ValueAnimator.ofFloat(0, 1);
int duration = CLOSING_TRANSITION_DURATION_MS;
@@ -717,30 +729,28 @@
FloatProp mScale = new FloatProp(1f, 1f, 0, duration, DEACCEL_1_7);
FloatProp mAlpha = new FloatProp(1f, 0f, 25, 125, LINEAR);
- boolean isFirstFrame = true;
-
@Override
public void onUpdate(float percent) {
- TransactionCompat t = new TransactionCompat();
- if (isFirstFrame) {
- RemoteAnimationProvider.prepareTargetsForFirstFrame(targets, t, MODE_CLOSING);
- isFirstFrame = false;
- }
- for (RemoteAnimationTargetCompat app : targets) {
- if (app.mode == RemoteAnimationTargetCompat.MODE_CLOSING) {
- t.setAlpha(app.leash, mAlpha.value);
+ SurfaceParams[] params = new SurfaceParams[targets.length];
+ for (int i = targets.length - 1; i >= 0; i--) {
+ RemoteAnimationTargetCompat target = targets[i];
+ float alpha;
+ if (target.mode == MODE_CLOSING) {
matrix.setScale(mScale.value, mScale.value,
- app.sourceContainerBounds.centerX(),
- app.sourceContainerBounds.centerY());
+ target.sourceContainerBounds.centerX(),
+ target.sourceContainerBounds.centerY());
matrix.postTranslate(0, mDy.value);
- matrix.postTranslate(app.position.x, app.position.y);
- t.setMatrix(app.leash, matrix);
+ matrix.postTranslate(target.position.x, target.position.y);
+ alpha = mAlpha.value;
+ } else {
+ matrix.setTranslate(target.position.x, target.position.y);
+ alpha = 1f;
}
+ params[i] = new SurfaceParams(target.leash, alpha, matrix,
+ target.sourceContainerBounds,
+ RemoteAnimationProvider.getLayer(target, MODE_CLOSING));
}
- t.setEarlyWakeup();
- t.apply();
-
- matrix.reset();
+ surfaceApplier.scheduleApply(params);
}
});
diff --git a/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java b/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java
index 2e6dcc0..722f51b 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java
@@ -16,6 +16,8 @@
package com.android.launcher3.uioverrides;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import com.android.launcher3.Launcher;
@@ -56,6 +58,13 @@
final float alpha = (float) valueAnimator.getAnimatedValue();
mOverviewInteractionState.setBackButtonAlpha(alpha, false);
});
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ // Reapply the final alpha in case some state (e.g. window focus) changed.
+ UiFactory.onLauncherStateOrFocusChanged(mLauncher);
+ }
+ });
builder.play(anim);
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java
index cd92314..2645302 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java
@@ -34,7 +34,7 @@
/**
* Vertical transition of the task previews relative to the full container.
*/
- public static final float OVERVIEW_TRANSLATION_FACTOR = 0.5f;
+ public static final float OVERVIEW_TRANSLATION_FACTOR = 0.4f;
private static final int STATE_FLAGS = FLAG_DISABLE_RESTORE | FLAG_DISABLE_INTERACTION
| FLAG_OVERVIEW_UI | FLAG_HIDE_BACK_BUTTON | FLAG_DISABLE_ACCESSIBILITY;
diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
index 9169ffb..1e10319 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
@@ -25,6 +25,7 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.R;
import com.android.launcher3.Workspace;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -118,6 +119,11 @@
/ launcher.getAllAppsController().getShiftRange());
}
+ @Override
+ public String getDescription(Launcher launcher) {
+ return launcher.getString(R.string.accessibility_desc_recent_apps);
+ }
+
public static float getDefaultSwipeHeight(Launcher launcher) {
DeviceProfile dp = launcher.getDeviceProfile();
return dp.allAppsCellHeightPx - dp.allAppsIconTextSizePx;
diff --git a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
index 3fb7cd4..512d19a 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
@@ -25,7 +25,6 @@
import android.animation.ValueAnimator;
import android.view.MotionEvent;
import android.view.animation.Interpolator;
-import android.view.animation.OvershootInterpolator;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
@@ -140,9 +139,11 @@
cancelPendingAnim();
RecentsView recentsView = mLauncher.getOverviewPanel();
- TaskView taskView = (TaskView) recentsView.getChildAt(recentsView.getNextPage());
+ TaskView taskView = recentsView.getTaskViewAt(recentsView.getNextPage());
if (recentsView.shouldSwipeDownLaunchApp() && mFromState == OVERVIEW && mToState == NORMAL
&& taskView != null) {
+ // Reset the state manager, when changing the interaction mode
+ mLauncher.getStateManager().goToState(OVERVIEW, false /* animate */);
mPendingAnimation = recentsView.createTaskLauncherAnimation(taskView, maxAccuracy);
mPendingAnimation.anim.setInterpolator(Interpolators.ZOOM_IN);
@@ -190,7 +191,7 @@
// Update all apps interpolator to add a bit of overshoot starting from currFraction
final float currFraction = mCurrentAnimation.getProgressFraction();
mAllAppsInterpolatorWrapper.baseInterpolator = Interpolators.clampToProgress(
- new OvershootInterpolator(Math.min(Math.abs(velocity), 3f)), currFraction, 1);
+ Interpolators.overshootInterpolatorForVelocity(velocity), currFraction, 1);
animator.setDuration(Math.min(expectedDuration, ATOMIC_DURATION))
.setInterpolator(LINEAR);
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
index ea27eb2..abd2846 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -25,7 +25,7 @@
import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_START_INTERPOLATOR;
import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_TRANSLATION_Y_FACTOR;
import static com.android.quickstep.views.LauncherRecentsView.TRANSLATION_Y_FACTOR;
-import static com.android.quickstep.views.RecentsViewContainer.CONTENT_ALPHA;
+import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
@@ -40,24 +40,21 @@
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.PropertySetter;
import com.android.quickstep.views.LauncherRecentsView;
-import com.android.quickstep.views.RecentsViewContainer;
@TargetApi(Build.VERSION_CODES.O)
public class RecentsViewStateController implements StateHandler {
private final Launcher mLauncher;
private final LauncherRecentsView mRecentsView;
- private final RecentsViewContainer mRecentsViewContainer;
public RecentsViewStateController(Launcher launcher) {
mLauncher = launcher;
mRecentsView = launcher.getOverviewPanel();
- mRecentsViewContainer = launcher.getOverviewPanelContainer();
}
@Override
public void setState(LauncherState state) {
- mRecentsViewContainer.setContentAlpha(state.overviewUi ? 1 : 0);
+ mRecentsView.setContentAlpha(state.overviewUi ? 1 : 0);
float[] scaleTranslationYFactor = state.getOverviewScaleAndTranslationYFactor(mLauncher);
SCALE_PROPERTY.set(mRecentsView, scaleTranslationYFactor[0]);
mRecentsView.setTranslationYFactor(scaleTranslationYFactor[1]);
@@ -86,7 +83,7 @@
scaleAndTransYInterpolator);
setter.setFloat(mRecentsView, TRANSLATION_Y_FACTOR, scaleTranslationYFactor[1],
scaleAndTransYInterpolator);
- setter.setFloat(mRecentsViewContainer, CONTENT_ALPHA, toState.overviewUi ? 1 : 0,
+ setter.setFloat(mRecentsView, CONTENT_ALPHA, toState.overviewUi ? 1 : 0,
builder.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
if (!toState.overviewUi) {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
index a405735..cfd4119 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
@@ -115,8 +115,8 @@
} else {
mTaskBeingDragged = null;
- for (int i = 0; i < mRecentsView.getChildCount(); i++) {
- TaskView view = mRecentsView.getPageAt(i);
+ for (int i = 0; i < mRecentsView.getTaskViewCount(); i++) {
+ TaskView view = mRecentsView.getTaskViewAt(i);
if (mRecentsView.isTaskViewVisible(view) && mActivity.getDragLayer()
.isEventOverView(view, ev)) {
mTaskBeingDragged = view;
@@ -241,16 +241,16 @@
if (blockedFling) {
fling = false;
}
+ float progress = mCurrentAnimation.getProgressFraction();
+ float interpolatedProgress = mCurrentAnimation.getInterpolator().getInterpolation(progress);
if (fling) {
logAction = Touch.FLING;
boolean goingUp = velocity < 0;
goingToEnd = goingUp == mCurrentAnimationIsGoingUp;
} else {
logAction = Touch.SWIPE;
- goingToEnd = mCurrentAnimation.getProgressFraction() > SUCCESS_TRANSITION_PROGRESS;
+ goingToEnd = interpolatedProgress > SUCCESS_TRANSITION_PROGRESS;
}
-
- float progress = mCurrentAnimation.getProgressFraction();
long animationDuration = SwipeDetector.calculateDuration(
velocity, goingToEnd ? (1 - progress) : progress);
if (blockedFling && !goingToEnd) {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index dd5dcbe..ac9f863 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -25,7 +25,6 @@
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_SEEN;
import static com.android.launcher3.allapps.DiscoveryBounce.SHELF_BOUNCE_SEEN;
-import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
@@ -46,7 +45,6 @@
import com.android.launcher3.util.TouchController;
import com.android.quickstep.OverviewInteractionState;
import com.android.quickstep.RecentsModel;
-import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.quickstep.util.RemoteFadeOutAnimationListener;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.ActivityCompat;
@@ -171,7 +169,8 @@
LauncherState state = launcher.getStateManager().getState();
DeviceProfile profile = launcher.getDeviceProfile();
WindowManagerWrapper.getInstance().setShelfHeight(
- state != ALL_APPS && launcher.isUserActive() && !profile.isVerticalBarLayout(),
+ (state == NORMAL || state == OVERVIEW) && launcher.isUserActive()
+ && !profile.isVerticalBarLayout(),
profile.hotseatBarSizePx);
if (state == NORMAL) {
diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java
index e202c57..275075f 100644
--- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java
+++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java
@@ -15,16 +15,21 @@
*/
package com.android.quickstep;
+import static android.view.View.TRANSLATION_Y;
+
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
+import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherState.FAST_OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB;
+import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_BACK;
import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_ROTATION;
+import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
@@ -46,22 +51,24 @@
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherInitListener;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.DiscoveryBounce;
+import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.uioverrides.FastOverviewState;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.quickstep.TouchConsumer.InteractionType;
+import com.android.quickstep.util.ClipAnimationHelper;
import com.android.quickstep.util.LayoutUtils;
-import com.android.quickstep.util.TransformedRect;
import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.quickstep.util.RemoteAnimationTargetSet;
+import com.android.quickstep.util.TransformedRect;
import com.android.quickstep.views.LauncherLayoutListener;
-import com.android.quickstep.views.LauncherRecentsView;
import com.android.quickstep.views.RecentsView;
-import com.android.quickstep.views.RecentsViewContainer;
+import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import java.util.Objects;
@@ -82,7 +89,8 @@
void onQuickInteractionStart(T activity, @Nullable RunningTaskInfo taskInfo,
boolean activityVisible);
- float getTranslationYForQuickScrub(T activity);
+ float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp,
+ Context context);
void executeOnWindowAvailable(T activity, Runnable action);
@@ -151,10 +159,15 @@
}
@Override
- public float getTranslationYForQuickScrub(Launcher activity) {
- LauncherRecentsView recentsView = activity.getOverviewPanel();
- return recentsView.computeTranslationYForFactor(
- FastOverviewState.OVERVIEW_TRANSLATION_FACTOR);
+ public float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp,
+ Context context) {
+ // The padding calculations are exactly same as that of RecentsView.setInsets
+ int topMargin = context.getResources()
+ .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin);
+ int paddingTop = targetRect.rect.top - topMargin - dp.getInsets().top;
+ int paddingBottom = dp.availableHeightPx + dp.getInsets().top - targetRect.rect.bottom;
+
+ return FastOverviewState.OVERVIEW_TRANSLATION_FACTOR * (paddingBottom - paddingTop);
}
@Override
@@ -172,9 +185,11 @@
if (dp.isVerticalBarLayout()) {
Rect targetInsets = dp.getInsets();
int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right;
- return dp.hotseatBarSizePx + dp.hotseatBarSidePaddingPx + hotseatInset;
+ return dp.hotseatBarSizePx + hotseatInset;
} else {
- return dp.heightPx - outRect.rect.bottom;
+ int shelfHeight = dp.hotseatBarSizePx + dp.getInsets().bottom;
+ // Track slightly below the top of the shelf (between top and content).
+ return shelfHeight - dp.edgeMarginPx * 2;
}
}
@@ -236,34 +251,65 @@
if (wasVisible) {
DeviceProfile dp = activity.getDeviceProfile();
long accuracy = 2 * Math.max(dp.widthPx, dp.heightPx);
- activity.getStateManager().goToState(startState, false);
callback.accept(activity.getStateManager()
- .createAnimationToNewWorkspace(endState, accuracy));
+ .createAnimationToNewWorkspace(startState, endState, accuracy));
return;
}
- if (activity.getDeviceProfile().isVerticalBarLayout()) {
- return;
- }
-
- AllAppsTransitionController controller = activity.getAllAppsController();
AnimatorSet anim = new AnimatorSet();
- float scrollRange = Math.max(controller.getShiftRange(), 1);
- float progressDelta = (transitionLength / scrollRange);
+ if (!activity.getDeviceProfile().isVerticalBarLayout()) {
+ AllAppsTransitionController controller = activity.getAllAppsController();
+ float scrollRange = Math.max(controller.getShiftRange(), 1);
+ float progressDelta = (transitionLength / scrollRange);
- float endProgress = endState.getVerticalProgress(activity);
- float startProgress = endProgress + progressDelta;
- ObjectAnimator shiftAnim = ObjectAnimator.ofFloat(
- controller, ALL_APPS_PROGRESS, startProgress, endProgress);
- shiftAnim.setInterpolator(LINEAR);
- anim.play(shiftAnim);
+ float endProgress = endState.getVerticalProgress(activity);
+ float startProgress = endProgress + progressDelta;
+ ObjectAnimator shiftAnim = ObjectAnimator.ofFloat(
+ controller, ALL_APPS_PROGRESS, startProgress, endProgress);
+ shiftAnim.setInterpolator(LINEAR);
+ anim.play(shiftAnim);
+
+ // Since we are changing the start position of the UI, reapply the state, at the end
+ anim.addListener(new AnimationSuccessListener() {
+ @Override
+ public void onAnimationSuccess(Animator animator) {
+ activity.getStateManager().reapplyState();
+ }
+ });
+ }
+
+ if (interactionType == INTERACTION_NORMAL) {
+ playScaleDownAnim(anim, activity);
+ }
anim.setDuration(transitionLength * 2);
activity.getStateManager().setCurrentAnimation(anim);
callback.accept(AnimatorPlaybackController.wrap(anim, transitionLength * 2));
}
+ /**
+ * Scale down recents from the center task being full screen to being in overview.
+ */
+ private void playScaleDownAnim(AnimatorSet anim, Launcher launcher) {
+ RecentsView recentsView = launcher.getOverviewPanel();
+ TaskView v = recentsView.getTaskViewAt(recentsView.getCurrentPage());
+ ClipAnimationHelper clipHelper = new ClipAnimationHelper();
+ clipHelper.fromTaskThumbnailView(v.getThumbnail(), (RecentsView) v.getParent(), null);
+ if (!clipHelper.getSourceRect().isEmpty() && !clipHelper.getTargetRect().isEmpty()) {
+ float fromScale = clipHelper.getSourceRect().width()
+ / clipHelper.getTargetRect().width();
+ float fromTranslationY = clipHelper.getSourceRect().centerY()
+ - clipHelper.getTargetRect().centerY();
+ Animator scale = ObjectAnimator.ofFloat(recentsView, SCALE_PROPERTY, fromScale, 1);
+ Animator translateY = ObjectAnimator.ofFloat(recentsView, TRANSLATION_Y,
+ fromTranslationY, 0);
+ scale.setInterpolator(LINEAR);
+ translateY.setInterpolator(LINEAR);
+ anim.playTogether(scale, translateY);
+ }
+ }
+
@Override
public ActivityInitListener createActivityInitListener(
BiPredicate<Launcher, Boolean> onInitListener) {
@@ -380,7 +426,8 @@
}
@Override
- public float getTranslationYForQuickScrub(RecentsActivity activity) {
+ public float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp,
+ Context context) {
return 0;
}
@@ -401,7 +448,7 @@
if (dp.isVerticalBarLayout()) {
Rect targetInsets = dp.getInsets();
int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right;
- return dp.hotseatBarSizePx + dp.hotseatBarSidePaddingPx + hotseatInset;
+ return dp.hotseatBarSizePx + hotseatInset;
} else {
return dp.heightPx - outRect.rect.bottom;
}
@@ -419,7 +466,7 @@
return (transitionLength, interactionType) -> { };
}
- RecentsViewContainer rv = activity.getOverviewPanelContainer();
+ RecentsView rv = activity.getOverviewPanel();
rv.setContentAlpha(0);
return new AnimationFactory() {
@@ -443,8 +490,7 @@
return;
}
- ObjectAnimator anim = ObjectAnimator
- .ofFloat(rv, RecentsViewContainer.CONTENT_ALPHA, 0, 1);
+ ObjectAnimator anim = ObjectAnimator.ofFloat(rv, CONTENT_ALPHA, 0, 1);
anim.setDuration(transitionLength).setInterpolator(LINEAR);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(anim);
diff --git a/quickstep/src/com/android/quickstep/AnimatedFloat.java b/quickstep/src/com/android/quickstep/AnimatedFloat.java
index 84dfa45..84dfdbd 100644
--- a/quickstep/src/com/android/quickstep/AnimatedFloat.java
+++ b/quickstep/src/com/android/quickstep/AnimatedFloat.java
@@ -46,9 +46,9 @@
mUpdateCallback = updateCallback;
}
- public ObjectAnimator animateToValue(float v) {
+ public ObjectAnimator animateToValue(float start, float end) {
cancelAnimation();
- mValueAnimator = ObjectAnimator.ofFloat(this, VALUE, v);
+ mValueAnimator = ObjectAnimator.ofFloat(this, VALUE, start, end);
mValueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
diff --git a/quickstep/src/com/android/quickstep/DeferredTouchConsumer.java b/quickstep/src/com/android/quickstep/DeferredTouchConsumer.java
index b92678a..8e83bd0 100644
--- a/quickstep/src/com/android/quickstep/DeferredTouchConsumer.java
+++ b/quickstep/src/com/android/quickstep/DeferredTouchConsumer.java
@@ -64,6 +64,16 @@
}
@Override
+ public void onQuickStep(MotionEvent ev) {
+ mTarget.onQuickStep(ev);
+ }
+
+ @Override
+ public void onCommand(int command) {
+ mTarget.onCommand(command);
+ }
+
+ @Override
public void preProcessMotionEvent(MotionEvent ev) {
mVelocityTracker.addMovement(ev);
}
@@ -92,6 +102,11 @@
return target == null ? true : target.deferNextEventToMainThread();
}
+ @Override
+ public void onShowOverviewFromAltTab() {
+ mTarget.onShowOverviewFromAltTab();
+ }
+
public interface DeferredTouchProvider {
TouchConsumer createTouchConsumer(VelocityTracker tracker);
diff --git a/quickstep/src/com/android/quickstep/LongSwipeHelper.java b/quickstep/src/com/android/quickstep/LongSwipeHelper.java
index fbcde8b..336be2b 100644
--- a/quickstep/src/com/android/quickstep/LongSwipeHelper.java
+++ b/quickstep/src/com/android/quickstep/LongSwipeHelper.java
@@ -20,11 +20,8 @@
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.quickstep.WindowTransformSwipeHandler.MAX_SWIPE_DURATION;
-import static com.android.systemui.shared.recents.utilities.Utilities.getNextFrameNumber;
-import static com.android.systemui.shared.recents.utilities.Utilities.getSurface;
import android.animation.ValueAnimator;
-import android.view.Surface;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
@@ -39,7 +36,6 @@
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
-import com.android.systemui.shared.system.TransactionCompat;
/**
* Utility class to handle long swipe from an app.
@@ -65,7 +61,6 @@
}
private void init() {
- setTargetAlpha(0, true);
mFlingBlockCheck.blockFling();
// Init animations
@@ -83,8 +78,7 @@
}
public void destroy() {
- // TODO: We can probably also hide the task view
- setTargetAlpha(1, false);
+ // TODO: We can probably also show the task view
mLauncher.getStateManager().goToState(OVERVIEW, false);
}
@@ -136,31 +130,6 @@
animator.start();
}
- private void setTargetAlpha(float alpha, boolean defer) {
- final Surface surface = getSurface(mLauncher.getDragLayer());
- final long frameNumber = defer && surface != null ? getNextFrameNumber(surface) : -1;
- if (defer) {
- if (frameNumber == -1) {
- defer = false;
- } else {
- mLauncher.getDragLayer().invalidate();
- }
- }
-
- TransactionCompat transaction = new TransactionCompat();
- for (RemoteAnimationTargetCompat app : mTargetSet.apps) {
- if (!(app.isNotInRecents
- || app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME)) {
- transaction.setAlpha(app.leash, alpha);
- if (defer) {
- transaction.deferTransactionUntil(app.leash, surface, frameNumber);
- }
- }
- }
- transaction.setEarlyWakeup();
- transaction.apply();
- }
-
private void onSwipeAnimationComplete(boolean toAllApps, boolean isFling, Runnable callback) {
mLauncher.getStateManager().goToState(toAllApps ? ALL_APPS : OVERVIEW, false);
if (!toAllApps) {
@@ -176,4 +145,12 @@
callback.run();
}
+
+ public float getTargetAlpha(RemoteAnimationTargetCompat app, Float expectedAlpha) {
+ if (!(app.isNotInRecents
+ || app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME)) {
+ return 0;
+ }
+ return expectedAlpha;
+ }
}
diff --git a/quickstep/src/com/android/quickstep/MotionEventQueue.java b/quickstep/src/com/android/quickstep/MotionEventQueue.java
index 15f5aa5..f73be6c 100644
--- a/quickstep/src/com/android/quickstep/MotionEventQueue.java
+++ b/quickstep/src/com/android/quickstep/MotionEventQueue.java
@@ -55,6 +55,8 @@
ACTION_VIRTUAL | (6 << ACTION_POINTER_INDEX_SHIFT);
private static final int ACTION_QUICK_STEP =
ACTION_VIRTUAL | (7 << ACTION_POINTER_INDEX_SHIFT);
+ private static final int ACTION_COMMAND =
+ ACTION_VIRTUAL | (8 << ACTION_POINTER_INDEX_SHIFT);
private final EventArray mEmptyArray = new EventArray();
private final Object mExecutionLock = new Object();
@@ -165,6 +167,9 @@
case ACTION_QUICK_STEP:
mConsumer.onQuickStep(event);
break;
+ case ACTION_COMMAND:
+ mConsumer.onCommand(event.getSource());
+ break;
default:
Log.e(TAG, "Invalid virtual event: " + event.getAction());
}
@@ -222,6 +227,12 @@
queueVirtualAction(ACTION_DEFER_INIT, 0);
}
+ public void onCommand(int command) {
+ MotionEvent ev = MotionEvent.obtain(0, 0, ACTION_COMMAND, 0, 0, 0);
+ ev.setSource(command);
+ queueNoPreProcess(ev);
+ }
+
public TouchConsumer getConsumer() {
return mConsumer;
}
diff --git a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java
index 9ba3328..c856282 100644
--- a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java
+++ b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java
@@ -37,6 +37,7 @@
import android.os.Bundle;
import android.os.Looper;
import android.os.SystemClock;
+import android.util.SparseArray;
import android.view.Choreographer;
import android.view.Display;
import android.view.MotionEvent;
@@ -69,6 +70,7 @@
private static final long LAUNCHER_DRAW_TIMEOUT_MS = 150;
+ private final SparseArray<RecentsAnimationState> mAnimationStates = new SparseArray<>();
private final RunningTaskInfo mRunningTask;
private final RecentsModel mRecentsModel;
private final Intent mHomeIntent;
@@ -183,7 +185,7 @@
case ACTION_UP: {
TraceHelper.endSection("TouchInt");
- finishTouchTracking();
+ finishTouchTracking(ev);
break;
}
}
@@ -212,8 +214,9 @@
private void startTouchTrackingForWindowAnimation(long touchTimeMs) {
// Create the shared handler
+ RecentsAnimationState animationState = new RecentsAnimationState();
final WindowTransformSwipeHandler handler = new WindowTransformSwipeHandler(
- mRunningTask, this, touchTimeMs, mActivityControlHelper);
+ animationState.id, mRunningTask, this, touchTimeMs, mActivityControlHelper);
// Preload the plan
mRecentsModel.loadTasks(mRunningTask.id, null);
@@ -237,31 +240,7 @@
public void onHandleAssistData(Bundle bundle) {
mRecentsModel.preloadAssistData(mRunningTask.id, bundle);
}
- },
- new RecentsAnimationListener() {
- public void onAnimationStart(
- RecentsAnimationControllerCompat controller,
- RemoteAnimationTargetCompat[] apps, Rect homeContentInsets,
- Rect minimizedHomeBounds) {
- if (mInteractionHandler == handler) {
- TraceHelper.partitionSection("RecentsController", "Received");
- handler.onRecentsAnimationStart(controller,
- new RemoteAnimationTargetSet(apps, MODE_CLOSING),
- homeContentInsets, minimizedHomeBounds);
- } else {
- TraceHelper.endSection("RecentsController", "Finishing no handler");
- controller.finish(false /* toHome */);
- }
- }
-
- public void onAnimationCanceled() {
- TraceHelper.endSection("RecentsController",
- "Cancelled: " + mInteractionHandler);
- if (mInteractionHandler == handler) {
- handler.onRecentsAnimationCanceled();
- }
- }
- }, null, null);
+ }, animationState, null, null);
if (Looper.myLooper() != Looper.getMainLooper()) {
startActivity.run();
@@ -277,12 +256,22 @@
}
}
+ @Override
+ public void onCommand(int command) {
+ RecentsAnimationState state = mAnimationStates.get(command);
+ if (state != null) {
+ state.execute();
+ }
+ }
+
/**
* Called when the gesture has ended. Does not correlate to the completion of the interaction as
* the animation can still be running.
*/
- private void finishTouchTracking() {
+ private void finishTouchTracking(MotionEvent ev) {
if (mPassedInitialSlop && mInteractionHandler != null) {
+ mInteractionHandler.updateDisplacement(getDisplacement(ev) - mStartDisplacement);
+
mVelocityTracker.computeCurrentVelocity(1000,
ViewConfiguration.get(this).getScaledMaximumFlingVelocity());
@@ -398,4 +387,55 @@
// TODO: Consider also check if the eventQueue is using mainThread of not.
return mInteractionHandler != null;
}
+
+ private class RecentsAnimationState implements RecentsAnimationListener {
+
+ private final int id;
+
+ private RecentsAnimationControllerCompat mController;
+ private RemoteAnimationTargetSet mTargets;
+ private Rect mHomeContentInsets;
+ private Rect mMinimizedHomeBounds;
+ private boolean mCancelled;
+
+ public RecentsAnimationState() {
+ id = mAnimationStates.size();
+ mAnimationStates.put(id, this);
+ }
+
+ @Override
+ public void onAnimationStart(
+ RecentsAnimationControllerCompat controller,
+ RemoteAnimationTargetCompat[] apps, Rect homeContentInsets,
+ Rect minimizedHomeBounds) {
+ mController = controller;
+ mTargets = new RemoteAnimationTargetSet(apps, MODE_CLOSING);
+ mHomeContentInsets = homeContentInsets;
+ mMinimizedHomeBounds = minimizedHomeBounds;
+ mEventQueue.onCommand(id);
+ }
+
+ @Override
+ public void onAnimationCanceled() {
+ mCancelled = true;
+ mEventQueue.onCommand(id);
+ }
+
+ public void execute() {
+ if (mInteractionHandler == null || mInteractionHandler.id != id) {
+ if (!mCancelled && mController != null) {
+ TraceHelper.endSection("RecentsController", "Finishing no handler");
+ mController.finish(false /* toHome */);
+ }
+ } else if (mCancelled) {
+ TraceHelper.endSection("RecentsController",
+ "Cancelled: " + mInteractionHandler);
+ mInteractionHandler.onRecentsAnimationCanceled();
+ } else {
+ TraceHelper.partitionSection("RecentsController", "Received");
+ mInteractionHandler.onRecentsAnimationStart(mController, mTargets,
+ mHomeContentInsets, mMinimizedHomeBounds);
+ }
+ }
+ }
}
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
index 41a4550..eff94fc 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
@@ -67,6 +67,7 @@
import com.android.systemui.shared.system.LatencyTrackerCompat;
import com.android.systemui.shared.system.PackageManagerWrapper;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
+import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplier;
import com.android.systemui.shared.system.TransactionCompat;
import java.util.ArrayList;
@@ -350,11 +351,14 @@
clipHelper.updateTargetRect(targetRect);
clipHelper.prepareAnimation(false /* isOpening */);
+ SyncRtSurfaceTransactionApplier syncTransactionApplier =
+ new SyncRtSurfaceTransactionApplier(rootView);
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
valueAnimator.setDuration(RECENTS_LAUNCH_DURATION);
valueAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
valueAnimator.addUpdateListener((v) ->
- clipHelper.applyTransform(targetSet, (float) v.getAnimatedValue()));
+ clipHelper.applyTransform(targetSet, (float) v.getAnimatedValue(),
+ syncTransactionApplier));
if (targetSet.isAnimatingHome()) {
// If we are animating home, fade in the opening targets
diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java
index 7a79c6f..cbc7a67 100644
--- a/quickstep/src/com/android/quickstep/QuickScrubController.java
+++ b/quickstep/src/com/android/quickstep/QuickScrubController.java
@@ -98,7 +98,7 @@
}
int page = mRecentsView.getNextPage();
Runnable launchTaskRunnable = () -> {
- TaskView taskView = mRecentsView.getPageAt(page);
+ TaskView taskView = mRecentsView.getTaskViewAt(page);
if (taskView != null) {
mWaitingForTaskLaunch = true;
taskView.launchTask(true, (result) -> {
@@ -108,7 +108,7 @@
} else {
mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(Touch.DRAGDROP,
LauncherLogProto.Action.Direction.NONE, page,
- TaskUtils.getComponentKeyForTask(taskView.getTask().key));
+ TaskUtils.getLaunchComponentKeyForTask(taskView.getTask().key));
}
mWaitingForTaskLaunch = false;
}, taskView.getHandler());
@@ -222,7 +222,7 @@
private void goToPageWithHaptic(int pageToGoTo, int overrideDuration, boolean forceHaptic,
Interpolator interpolator) {
- pageToGoTo = Utilities.boundToRange(pageToGoTo, 0, mRecentsView.getPageCount() - 1);
+ pageToGoTo = Utilities.boundToRange(pageToGoTo, 0, mRecentsView.getTaskViewCount() - 1);
boolean snappingToPage = pageToGoTo != mRecentsView.getNextPage();
if (snappingToPage) {
int duration = overrideDuration > -1 ? overrideDuration
@@ -246,7 +246,7 @@
return;
}
if (mQuickScrubSection == QUICK_SCRUB_THRESHOLDS.length
- && currPage < mRecentsView.getPageCount() - 1) {
+ && currPage < mRecentsView.getTaskViewCount() - 1) {
goToPageWithHaptic(currPage + 1);
} else if (mQuickScrubSection == 0 && currPage > 0) {
goToPageWithHaptic(currPage - 1);
diff --git a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java
index aed9959..2c3f77f 100644
--- a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java
+++ b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java
@@ -20,6 +20,7 @@
import com.android.launcher3.MainProcessInitializer;
import com.android.systemui.shared.system.ThreadedRendererCompat;
+@SuppressWarnings("unused")
public class QuickstepProcessInitializer extends MainProcessInitializer {
public QuickstepProcessInitializer(Context context) { }
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index 3adb290..ed8b4d2 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -20,6 +20,7 @@
import static com.android.launcher3.LauncherAppTransitionManagerImpl.RECENTS_LAUNCH_DURATION;
import static com.android.launcher3.LauncherAppTransitionManagerImpl.STATUS_BAR_TRANSITION_DURATION;
+import static com.android.launcher3.LauncherAppTransitionManagerImpl.STATUS_BAR_TRANSITION_PRE_DELAY;
import static com.android.quickstep.TaskUtils.getRecentsWindowAnimator;
import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
@@ -52,7 +53,6 @@
import com.android.quickstep.fallback.FallbackRecentsView;
import com.android.quickstep.fallback.RecentsRootView;
import com.android.quickstep.util.ClipAnimationHelper;
-import com.android.quickstep.views.RecentsViewContainer;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.system.ActivityOptionsCompat;
import com.android.systemui.shared.system.RemoteAnimationAdapterCompat;
@@ -70,7 +70,6 @@
private Handler mUiHandler = new Handler(Looper.getMainLooper());
private RecentsRootView mRecentsRootView;
private FallbackRecentsView mFallbackRecentsView;
- private RecentsViewContainer mOverviewPanelContainer;
private Configuration mOldConfig;
@@ -84,7 +83,6 @@
setContentView(R.layout.fallback_recents_activity);
mRecentsRootView = findViewById(R.id.drag_layer);
mFallbackRecentsView = findViewById(R.id.overview_panel);
- mOverviewPanelContainer = findViewById(R.id.overview_panel_container);
mRecentsRootView.setup();
@@ -166,10 +164,6 @@
return (T) mFallbackRecentsView;
}
- public RecentsViewContainer getOverviewPanelContainer() {
- return mOverviewPanelContainer;
- }
-
@Override
public BadgeInfo getBadgeInfoForItem(ItemInfo info) {
return null;
@@ -193,7 +187,8 @@
};
return ActivityOptionsCompat.makeRemoteAnimation(new RemoteAnimationAdapterCompat(
runner, RECENTS_LAUNCH_DURATION,
- RECENTS_LAUNCH_DURATION - STATUS_BAR_TRANSITION_DURATION));
+ RECENTS_LAUNCH_DURATION - STATUS_BAR_TRANSITION_DURATION
+ - STATUS_BAR_TRANSITION_PRE_DELAY));
}
/**
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java b/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java
index 30b10b0..b0313fc 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java
@@ -20,6 +20,8 @@
import com.android.launcher3.util.UiThreadHelper;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.systemui.shared.system.RecentsAnimationControllerCompat;
+
+import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
/**
@@ -27,6 +29,10 @@
*/
public class RecentsAnimationWrapper {
+ // A list of callbacks to run when we receive the recents animation target. There are different
+ // than the state callbacks as these run on the current worker thread.
+ private final ArrayList<Runnable> mCallbacks = new ArrayList<>();
+
public RemoteAnimationTargetSet targetSet;
private RecentsAnimationControllerCompat mController;
@@ -43,9 +49,27 @@
this.mController = controller;
this.targetSet = targetSet;
+ if (controller == null) {
+ return;
+ }
if (mInputConsumerEnabled) {
enableInputConsumer();
}
+
+ if (!mCallbacks.isEmpty()) {
+ for (Runnable action : new ArrayList<>(mCallbacks)) {
+ action.run();
+ }
+ mCallbacks.clear();
+ }
+ }
+
+ public synchronized void runOnInit(Runnable action) {
+ if (targetSet == null) {
+ mCallbacks.add(action);
+ } else {
+ action.run();
+ }
}
/**
diff --git a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
index f82ff8c..c77d0c7 100644
--- a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
+++ b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java
@@ -152,8 +152,7 @@
}
};
- AbstractFloatingView.closeOpenViews(activity, true,
- AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE);
+ dismissTaskMenuView(activity);
final int navBarPosition = WindowManagerWrapper.getInstance().getNavBarPosition();
if (navBarPosition == WindowManagerWrapper.NAV_BAR_POS_INVALID) {
@@ -246,6 +245,7 @@
}
};
taskView.launchTask(true, resultCallback, mHandler);
+ dismissTaskMenuView(activity);
};
}
}
@@ -265,4 +265,9 @@
return null;
}
}
+
+ private static void dismissTaskMenuView(BaseDraggingActivity activity) {
+ AbstractFloatingView.closeOpenViews(activity, true,
+ AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE);
+ }
}
diff --git a/quickstep/src/com/android/quickstep/TaskUtils.java b/quickstep/src/com/android/quickstep/TaskUtils.java
index 2b0c98f..f9b5e30 100644
--- a/quickstep/src/com/android/quickstep/TaskUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskUtils.java
@@ -46,6 +46,7 @@
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
+import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplier;
import java.util.List;
@@ -74,8 +75,11 @@
applicationInfo.loadLabel(packageManager), user);
}
- public static ComponentKey getComponentKeyForTask(Task.TaskKey taskKey) {
- return new ComponentKey(taskKey.getComponent(), UserHandle.of(taskKey.userId));
+ public static ComponentKey getLaunchComponentKeyForTask(Task.TaskKey taskKey) {
+ final ComponentName cn = taskKey.sourceComponent != null
+ ? taskKey.sourceComponent
+ : taskKey.getComponent();
+ return new ComponentKey(cn, UserHandle.of(taskKey.userId));
}
@@ -100,8 +104,8 @@
ComponentName componentName = itemInfo.getTargetComponent();
int userId = itemInfo.user.getIdentifier();
if (componentName != null) {
- for (int i = 0; i < recentsView.getChildCount(); i++) {
- TaskView taskView = recentsView.getPageAt(i);
+ for (int i = 0; i < recentsView.getTaskViewCount(); i++) {
+ TaskView taskView = recentsView.getTaskViewAt(i);
if (recentsView.isTaskViewVisible(taskView)) {
Task.TaskKey key = taskView.getTask().key;
if (componentName.equals(key.getComponent()) && userId == key.userId) {
@@ -144,6 +148,8 @@
*/
public static ValueAnimator getRecentsWindowAnimator(TaskView v, boolean skipViewChanges,
RemoteAnimationTargetCompat[] targets, final ClipAnimationHelper inOutHelper) {
+ SyncRtSurfaceTransactionApplier syncTransactionApplier =
+ new SyncRtSurfaceTransactionApplier(v);
final ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
appAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
appAnimator.addUpdateListener(new MultiValueUpdateListener() {
@@ -155,18 +161,10 @@
final RemoteAnimationTargetSet mTargetSet;
final RectF mThumbnailRect;
- private Surface mSurface;
- private long mFrameNumber;
{
mTargetSet = new RemoteAnimationTargetSet(targets, MODE_OPENING);
- inOutHelper.setTaskTransformCallback((t, app) -> {
- t.setAlpha(app.leash, mTaskAlpha.value);
-
- if (!skipViewChanges) {
- t.deferTransactionUntil(app.leash, mSurface, mFrameNumber);
- }
- });
+ inOutHelper.setTaskAlphaCallback((t, alpha) -> mTaskAlpha.value);
inOutHelper.prepareAnimation(true /* isOpening */);
inOutHelper.fromTaskThumbnailView(v.getThumbnail(), (RecentsView) v.getParent(),
@@ -179,15 +177,8 @@
@Override
public void onUpdate(float percent) {
- mSurface = getSurface(v);
- mFrameNumber = mSurface != null ? getNextFrameNumber(mSurface) : -1;
- if (mFrameNumber == -1) {
- // Booo, not cool! Our surface got destroyed, so no reason to animate anything.
- Log.w(TAG, "Failed to animate, surface got destroyed.");
- return;
- }
-
- RectF taskBounds = inOutHelper.applyTransform(mTargetSet, 1 - percent);
+ RectF taskBounds = inOutHelper.applyTransform(mTargetSet, 1 - percent,
+ syncTransactionApplier);
if (!skipViewChanges) {
float scale = taskBounds.width() / mThumbnailRect.width();
v.setScaleX(scale);
diff --git a/quickstep/src/com/android/quickstep/TouchConsumer.java b/quickstep/src/com/android/quickstep/TouchConsumer.java
index aa844d8..4cecffa 100644
--- a/quickstep/src/com/android/quickstep/TouchConsumer.java
+++ b/quickstep/src/com/android/quickstep/TouchConsumer.java
@@ -48,6 +48,8 @@
default void onQuickStep(MotionEvent ev) { }
+ default void onCommand(int command) { }
+
/**
* Called on the binder thread to allow the consumer to process the motion event before it is
* posted on a handler thread.
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index aecb66c..49a4ac8 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -49,6 +49,7 @@
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.ActivityManagerWrapper;
+import com.android.systemui.shared.system.ChoreographerCompat;
import com.android.systemui.shared.system.NavigationBarCompat.HitTarget;
/**
@@ -406,6 +407,6 @@
sRemoteUiThread.start();
}
new Handler(sRemoteUiThread.getLooper()).post(() ->
- mBackgroundThreadChoreographer = Choreographer.getInstance());
+ mBackgroundThreadChoreographer = ChoreographerCompat.getSfInstance());
}
}
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index d171f69..703ea2e 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -16,12 +16,15 @@
package com.android.quickstep;
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_STATE_HANDLER;
+import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS;
+import static com.android.launcher3.Utilities.SINGLE_FRAME_MS;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_FROM_APP_START_DURATION;
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB;
+import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -29,6 +32,7 @@
import android.annotation.TargetApi;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
@@ -36,10 +40,12 @@
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
+import android.os.UserHandle;
import android.support.annotation.AnyThread;
import android.support.annotation.UiThread;
import android.support.annotation.WorkerThread;
import android.util.Log;
+import android.view.HapticFeedbackConstants;
import android.view.View;
import android.view.ViewTreeObserver.OnDrawListener;
import android.view.WindowManager;
@@ -51,8 +57,10 @@
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
+import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
@@ -65,19 +73,22 @@
import com.android.quickstep.ActivityControlHelper.LayoutListener;
import com.android.quickstep.TouchConsumer.InteractionType;
import com.android.quickstep.util.ClipAnimationHelper;
-import com.android.quickstep.util.TransformedRect;
import com.android.quickstep.util.RemoteAnimationTargetSet;
+import com.android.quickstep.util.TransformedRect;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.ThumbnailData;
+import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.InputConsumerController;
import com.android.systemui.shared.system.LatencyTrackerCompat;
import com.android.systemui.shared.system.RecentsAnimationControllerCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
+import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplier;
import com.android.systemui.shared.system.WindowCallbacksCompat;
import com.android.systemui.shared.system.WindowManagerWrapper;
import java.util.StringJoiner;
+import java.util.function.BiFunction;
@TargetApi(Build.VERSION_CODES.O)
public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
@@ -148,7 +159,7 @@
public static final long MAX_SWIPE_DURATION = 350;
public static final long MIN_SWIPE_DURATION = 80;
- private static final float MIN_PROGRESS_FOR_OVERVIEW = 0.5f;
+ public static final float MIN_PROGRESS_FOR_OVERVIEW = 0.5f;
private static final float SWIPE_DURATION_MULTIPLIER =
Math.min(1 / MIN_PROGRESS_FOR_OVERVIEW, 1 / (1 - MIN_PROGRESS_FOR_OVERVIEW));
@@ -167,6 +178,12 @@
private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
+ // An increasing identifier per single instance of OtherActivityTouchConsumer. Generally one
+ // instance of OtherActivityTouchConsumer will only have one swipe handle, but sometimes we can
+ // end up with multiple handlers if we get recents command in the middle of a swipe gesture.
+ // This is used to match the corresponding activity manager callbacks in
+ // OtherActivityTouchConsumer
+ public final int id;
private final Context mContext;
private final ActivityControlHelper<T> mActivityControlHelper;
private final ActivityInitListener mActivityInitListener;
@@ -181,6 +198,7 @@
private T mActivity;
private LayoutListener mLayoutListener;
private RecentsView mRecentsView;
+ private SyncRtSurfaceTransactionApplier mSyncTransactionApplier;
private QuickScrubController mQuickScrubController;
private AnimationFactory mAnimationFactory = (t, i) -> { };
@@ -188,6 +206,7 @@
private boolean mWasLauncherAlreadyVisible;
+ private boolean mPassedOverviewThreshold;
private boolean mGestureStarted;
private int mLogAction = Touch.SWIPE;
private float mCurrentQuickScrubProgress;
@@ -199,6 +218,7 @@
InputConsumerController.getRecentsAnimationInputConsumer();
private final RecentsAnimationWrapper mRecentsAnimationWrapper = new RecentsAnimationWrapper();
+
private final long mTouchTimeMs;
private long mLauncherFrameDrawnTime;
@@ -207,8 +227,9 @@
private float mLongSwipeDisplacement = 0;
private LongSwipeHelper mLongSwipeController;
- WindowTransformSwipeHandler(RunningTaskInfo runningTaskInfo, Context context, long touchTimeMs,
- ActivityControlHelper<T> controller) {
+ WindowTransformSwipeHandler(int id, RunningTaskInfo runningTaskInfo, Context context,
+ long touchTimeMs, ActivityControlHelper<T> controller) {
+ this.id = id;
mContext = context;
mRunningTaskInfo = runningTaskInfo;
mRunningTaskId = runningTaskInfo.id;
@@ -341,12 +362,13 @@
// Override the visibility of the activity until the gesture actually starts and we swipe
// up, or until we transition home and the home animation is composed
if (alreadyOnHome) {
- mActivity.clearForceInvisibleFlag(INVISIBLE_BY_STATE_HANDLER);
+ mActivity.clearForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
} else {
- mActivity.addForceInvisibleFlag(INVISIBLE_BY_STATE_HANDLER);
+ mActivity.addForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
}
mRecentsView = activity.getOverviewPanel();
+ mSyncTransactionApplier = new SyncRtSurfaceTransactionApplier(mRecentsView);
mQuickScrubController = mRecentsView.getQuickScrubController();
mLayoutListener = mActivityControlHelper.createLayoutListener(mActivity);
@@ -453,11 +475,40 @@
"Can't change interaction type to " + interactionType);
}
mInteractionType = interactionType;
+ mRecentsAnimationWrapper.runOnInit(this::shiftAnimationDestinationForQuickscrub);
setStateOnUiThread(STATE_QUICK_SCRUB_START | STATE_GESTURE_COMPLETED);
// Start the window animation without waiting for launcher.
- animateToProgress(1f, QUICK_SCRUB_FROM_APP_START_DURATION, LINEAR);
+ animateToProgress(mCurrentShift.value, 1f, QUICK_SCRUB_FROM_APP_START_DURATION, LINEAR);
+ }
+
+ private void shiftAnimationDestinationForQuickscrub() {
+ TransformedRect tempRect = new TransformedRect();
+ mActivityControlHelper
+ .getSwipeUpDestinationAndLength(mDp, mContext, mInteractionType, tempRect);
+ mClipAnimationHelper.updateTargetRect(tempRect);
+
+ float offsetY =
+ mActivityControlHelper.getTranslationYForQuickScrub(tempRect, mDp, mContext);
+ float scale, offsetX;
+ Resources res = mContext.getResources();
+
+ if (ActivityManagerWrapper.getInstance().getRecentTasks(2, UserHandle.myUserId()).size()
+ < 2) {
+ // There are not enough tasks, we don't need to shift
+ offsetX = 0;
+ scale = 1;
+ } else {
+ offsetX = res.getDimensionPixelSize(R.dimen.recents_page_spacing)
+ + tempRect.rect.width();
+ float distanceToReachEdge = mDp.widthPx / 2 + tempRect.rect.width() / 2 +
+ res.getDimensionPixelSize(R.dimen.recents_page_spacing);
+ float interpolation = Math.min(1, offsetX / distanceToReachEdge);
+ scale = TaskView.getCurveScaleForInterpolation(interpolation);
+ }
+ mClipAnimationHelper.offsetTarget(scale, Utilities.isRtl(res) ? -offsetX : offsetX, offsetY,
+ QuickScrubController.QUICK_SCRUB_START_INTERPOLATOR);
}
@WorkerThread
@@ -504,10 +555,13 @@
RecentsAnimationControllerCompat controller = mRecentsAnimationWrapper.getController();
if (controller != null) {
- mClipAnimationHelper.applyTransform(mRecentsAnimationWrapper.targetSet, shift);
- // TODO: This logic is spartanic!
- boolean passedThreshold = shift > 0.12f;
+ mClipAnimationHelper.applyTransform(mRecentsAnimationWrapper.targetSet, shift,
+ Looper.myLooper() == mMainThreadHandler.getLooper()
+ ? mSyncTransactionApplier
+ : null);
+
+ boolean passedThreshold = shift > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD;
mRecentsAnimationWrapper.setAnimationTargetsBehindSystemBars(!passedThreshold);
if (mActivityControlHelper.shouldMinimizeSplitScreen()) {
mRecentsAnimationWrapper.setSplitScreenMinimizedForTransaction(passedThreshold);
@@ -518,7 +572,17 @@
}
private void updateFinalShiftUi() {
- if (mLauncherTransitionController == null) {
+ final boolean passed = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW;
+ if (passed != mPassedOverviewThreshold) {
+ mPassedOverviewThreshold = passed;
+ if (mInteractionType == INTERACTION_NORMAL && mRecentsView != null) {
+ mRecentsView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
+ HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
+ }
+ }
+
+ if (mLauncherTransitionController == null || mLauncherTransitionController
+ .getAnimationPlayer().isStarted()) {
return;
}
mLauncherTransitionController.setPlayFraction(mCurrentShift.value);
@@ -540,7 +604,15 @@
new Point(minimizedHomeBounds.width(), minimizedHomeBounds.height()));
dp.updateInsets(homeContentInsets);
} else {
- overviewStackBounds = new Rect(0, 0, dp.widthPx, dp.heightPx);
+ if (mActivity != null) {
+ int loc[] = new int[2];
+ View rootView = mActivity.getRootView();
+ rootView.getLocationOnScreen(loc);
+ overviewStackBounds = new Rect(loc[0], loc[1], loc[0] + rootView.getWidth(),
+ loc[1] + rootView.getHeight());
+ } else {
+ overviewStackBounds = new Rect(0, 0, dp.widthPx, dp.heightPx);
+ }
// If we are not in multi-window mode, home insets should be same as system insets.
Rect insets = new Rect();
WindowManagerWrapper.getInstance().getStableInsets(insets);
@@ -557,6 +629,8 @@
mRecentsAnimationWrapper.setController(controller, targets);
setStateOnUiThread(STATE_APP_CONTROLLER_RECEIVED);
+
+ mPassedOverviewThreshold = false;
}
public void onRecentsAnimationCanceled() {
@@ -583,7 +657,7 @@
if (curActivity != null) {
// Once the gesture starts, we can no longer transition home through the button, so
// reset the force override of the activity visibility
- mActivity.clearForceInvisibleFlag(INVISIBLE_BY_STATE_HANDLER);
+ mActivity.clearForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
}
}
@@ -604,15 +678,23 @@
}
private void handleNormalGestureEnd(float endVelocity, boolean isFling) {
+ float velocityPxPerMs = endVelocity / 1000;
long duration = MAX_SWIPE_DURATION;
final float endShift;
+ final float startShift;
+ final Interpolator interpolator;
if (!isFling) {
endShift = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW && mGestureStarted ? 1 : 0;
long expectedDuration = Math.abs(Math.round((endShift - mCurrentShift.value)
* MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);
+ startShift = mCurrentShift.value;
+ interpolator = DEACCEL;
} else {
endShift = endVelocity < 0 ? 1 : 0;
+ interpolator = endVelocity < 0
+ ? Interpolators.overshootInterpolatorForVelocity(velocityPxPerMs, 2f)
+ : DEACCEL;
float minFlingVelocity = mContext.getResources()
.getDimension(R.dimen.quickstep_fling_min_velocity);
if (Math.abs(endVelocity) > minFlingVelocity && mTransitionDragLength > 0) {
@@ -621,24 +703,30 @@
// we want the page's snap velocity to approximately match the velocity at
// which the user flings, so we scale the duration by a value near to the
// derivative of the scroll interpolator at zero, ie. 2.
- long baseDuration = Math.round(1000 * Math.abs(distanceToTravel / endVelocity));
+ long baseDuration = Math.round(Math.abs(distanceToTravel / velocityPxPerMs));
duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration);
}
+ startShift = Utilities.boundToRange(mCurrentShift.value - velocityPxPerMs
+ * SINGLE_FRAME_MS / (mTransitionDragLength), 0, 1);
}
-
- animateToProgress(endShift, duration, DEACCEL);
+ animateToProgress(startShift, endShift, duration, interpolator);
}
private void doLogGesture(boolean toLauncher) {
+ DeviceProfile dp = mDp;
+ if (dp == null) {
+ // We probably never received an animation controller, skip logging.
+ return;
+ }
final int direction;
- if (mDp.isVerticalBarLayout()) {
- direction = (mDp.isSeascape() ^ toLauncher) ? Direction.LEFT : Direction.RIGHT;
+ if (dp.isVerticalBarLayout()) {
+ direction = (dp.isSeascape() ^ toLauncher) ? Direction.LEFT : Direction.RIGHT;
} else {
direction = toLauncher ? Direction.UP : Direction.DOWN;
}
int dstContainerType = toLauncher ? ContainerType.TASKSWITCHER : ContainerType.APP;
- UserEventDispatcher.newInstance(mContext, mDp).logStateChangeAction(
+ UserEventDispatcher.newInstance(mContext, dp).logStateChangeAction(
mLogAction, direction,
ContainerType.NAVBAR, ContainerType.APP,
dstContainerType,
@@ -646,9 +734,16 @@
}
/** Animates to the given progress, where 0 is the current app and 1 is overview. */
- private void animateToProgress(float progress, long duration, Interpolator interpolator) {
- mIsGoingToHome = Float.compare(progress, 1) == 0;
- ObjectAnimator anim = mCurrentShift.animateToValue(progress).setDuration(duration);
+ private void animateToProgress(float start, float end, long duration,
+ Interpolator interpolator) {
+ mRecentsAnimationWrapper.runOnInit(() -> animateToProgressInternal(start, end, duration,
+ interpolator));
+ }
+
+ private void animateToProgressInternal(float start, float end, long duration,
+ Interpolator interpolator) {
+ mIsGoingToHome = Float.compare(end, 1) == 0;
+ ObjectAnimator anim = mCurrentShift.animateToValue(start, end).setDuration(duration);
anim.setInterpolator(interpolator);
anim.addListener(new AnimationSuccessListener() {
@Override
@@ -659,6 +754,25 @@
}
});
anim.start();
+ long startMillis = SystemClock.uptimeMillis();
+ executeOnUiThread(() -> {
+ // Animate the launcher components at the same time as the window, always on UI thread.
+ if (mLauncherTransitionController != null && !mWasLauncherAlreadyVisible
+ && start != end && duration > 0) {
+ // Adjust start progress and duration in case we are on a different thread.
+ long elapsedMillis = SystemClock.uptimeMillis() - startMillis;
+ elapsedMillis = Utilities.boundToRange(elapsedMillis, 0, duration);
+ float elapsedProgress = (float) elapsedMillis / duration;
+ float adjustedStart = Utilities.mapRange(elapsedProgress, start, end);
+ long adjustedDuration = duration - elapsedMillis;
+ // We want to use the same interpolator as the window, but need to adjust it to
+ // interpolate over the remaining progress (end - start).
+ mLauncherTransitionController.dispatchSetInterpolator(Interpolators.mapToProgress(
+ interpolator, adjustedStart, end));
+ mLauncherTransitionController.getAnimationPlayer().setDuration(adjustedDuration);
+ mLauncherTransitionController.getAnimationPlayer().start();
+ }
+ });
}
@UiThread
@@ -710,6 +824,9 @@
private void resetStateForAnimationCancel() {
boolean wasVisible = mWasLauncherAlreadyVisible || mGestureStarted;
mActivityControlHelper.onTransitionCancelled(mActivity, wasVisible);
+
+ // Leave the pending invisible flag, as it may be used by wallpaper open animation.
+ mActivity.clearForceInvisibleFlag(INVISIBLE_BY_STATE_HANDLER);
}
public void layoutListenerClosed() {
@@ -786,30 +903,6 @@
// Inform the last progress in case we skipped before.
mQuickScrubController.onQuickScrubProgress(mCurrentQuickScrubProgress);
-
- // Make sure the window follows the first task if it moves, e.g. during quick scrub.
- TaskView firstTask = mRecentsView.getPageAt(0);
- // The first task may be null if we are swiping up from a task that does not
- // appear in the list (i.e. the assistant)
- if (firstTask != null) {
- int scrollForFirstTask = mRecentsView.getScrollForPage(0);
- int scrollForSecondTask = mRecentsView.getChildCount() > 1
- ? mRecentsView.getScrollForPage(1) : scrollForFirstTask;
- float offsetFromFirstTask = scrollForFirstTask - scrollForSecondTask;
-
- TransformedRect tempRect = new TransformedRect();
- mActivityControlHelper
- .getSwipeUpDestinationAndLength(mDp, mContext, mInteractionType, tempRect);
- float distanceToReachEdge = mDp.widthPx / 2 + tempRect.rect.width() / 2 +
- mContext.getResources().getDimensionPixelSize(R.dimen.recents_page_spacing);
- float interpolation = Math.min(1,
- Math.abs(offsetFromFirstTask) / distanceToReachEdge);
-
- mClipAnimationHelper.offsetTarget(
- firstTask.getCurveScaleForInterpolation(interpolation), offsetFromFirstTask,
- mActivityControlHelper.getTranslationYForQuickScrub(mActivity),
- QuickScrubController.QUICK_SCRUB_START_INTERPOLATOR);
- }
}
private void onFinishedTransitionToQuickScrub() {
@@ -880,6 +973,7 @@
if (mLongSwipeController != null) {
mLongSwipeController.destroy();
+ setTargetAlphaProvider((t, a1) -> a1);
// Rebuild animations
buildAnimationController();
@@ -921,6 +1015,7 @@
mLongSwipeController = mActivityControlHelper.getLongSwipeController(
mActivity, mRecentsAnimationWrapper.targetSet);
onLongSwipeDisplacementUpdated();
+ setTargetAlphaProvider(mLongSwipeController::getTargetAlpha);
}
private void onLongSwipeGestureFinishUi(float velocity, boolean isFling) {
@@ -935,4 +1030,10 @@
() -> setStateOnUiThread(STATE_HANDLER_INVALIDATED));
}
+
+ private void setTargetAlphaProvider(
+ BiFunction<RemoteAnimationTargetCompat, Float, Float> provider) {
+ mClipAnimationHelper.setTaskAlphaCallback(provider);
+ updateFinalShift();
+ }
}
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
index c5d74c7..9e2de33 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
@@ -20,10 +20,8 @@
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
-import android.view.accessibility.AccessibilityNodeInfo;
import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.R;
import com.android.quickstep.RecentsActivity;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.views.RecentsView;
@@ -73,21 +71,4 @@
// Just use the activity task size for multi-window as well.
return false;
}
-
- @Override
- public void addTaskAccessibilityActionsExtra(AccessibilityNodeInfo info) {
- info.addAction(
- new AccessibilityNodeInfo.AccessibilityAction(
- R.string.recents_clear_all,
- getContext().getText(R.string.recents_clear_all)));
- }
-
- @Override
- public boolean performTaskAccessibilityActionExtra(int action) {
- if (action == R.string.recents_clear_all) {
- dismissAllTasks();
- return true;
- }
- return false;
- }
}
diff --git a/quickstep/src/com/android/quickstep/logging/UserEventDispatcherExtension.java b/quickstep/src/com/android/quickstep/logging/UserEventDispatcherExtension.java
index 04153cc..6dff187 100644
--- a/quickstep/src/com/android/quickstep/logging/UserEventDispatcherExtension.java
+++ b/quickstep/src/com/android/quickstep/logging/UserEventDispatcherExtension.java
@@ -15,10 +15,9 @@
*/
package com.android.quickstep.logging;
+import android.content.Context;
import android.util.Log;
-import static com.android.launcher3.logging.LoggerUtils.newAction;
-import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
import static com.android.launcher3.logging.LoggerUtils.newLauncherEvent;
import static com.android.launcher3.userevent.nano.LauncherLogProto.ControlType.CANCEL_TARGET;
import static com.android.systemui.shared.system.LauncherEventUtil.VISIBLE;
@@ -27,20 +26,20 @@
import static com.android.systemui.shared.system.LauncherEventUtil.RECENTS_SWIPE_UP_ONBOARDING_TIP;
import com.android.launcher3.logging.UserEventDispatcher;
-import com.android.launcher3.model.nano.LauncherDumpProto;
-import com.android.launcher3.userevent.nano.LauncherLogExtensions;
import com.android.launcher3.userevent.nano.LauncherLogProto;
-import com.android.systemui.shared.system.LauncherEventUtil;
import com.android.systemui.shared.system.MetricsLoggerCompat;
/**
* This class handles AOSP MetricsLogger function calls and logging around
* quickstep interactions.
*/
+@SuppressWarnings("unused")
public class UserEventDispatcherExtension extends UserEventDispatcher {
private static final String TAG = "UserEventDispatcher";
+ public UserEventDispatcherExtension(Context context) { }
+
public void logStateChangeAction(int action, int dir, int srcChildTargetType,
int srcParentContainerType, int dstContainerType,
int pageIndex) {
diff --git a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
index a654482..df70a8a 100644
--- a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
+++ b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
@@ -30,6 +30,7 @@
import android.os.Build;
import android.os.RemoteException;
import android.support.annotation.Nullable;
+import android.view.Surface;
import android.view.animation.Interpolator;
import com.android.launcher3.BaseDraggingActivity;
@@ -44,10 +45,13 @@
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.utilities.RectFEvaluator;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
+import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplier;
+import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplier.SurfaceParams;
import com.android.systemui.shared.system.TransactionCompat;
import com.android.systemui.shared.system.WindowManagerWrapper;
import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
/**
* Utility class to handle window clip animation
@@ -90,8 +94,8 @@
// Wether or not applyTransform has been called yet since prepareAnimation()
private boolean mIsFirstFrame = true;
- private BiConsumer<TransactionCompat, RemoteAnimationTargetCompat> mTaskTransformCallback =
- (t, a) -> { };
+ private BiFunction<RemoteAnimationTargetCompat, Float, Float> mTaskAlphaCallback =
+ (t, a1) -> a1;
private void updateSourceStack(RemoteAnimationTargetCompat target) {
mSourceInsets.set(target.contentInsets);
@@ -134,11 +138,11 @@
}
public void prepareAnimation(boolean isOpening) {
- mIsFirstFrame = true;
mBoostModeTargetLayers = isOpening ? MODE_OPENING : MODE_CLOSING;
}
- public RectF applyTransform(RemoteAnimationTargetSet targetSet, float progress) {
+ public RectF applyTransform(RemoteAnimationTargetSet targetSet, float progress,
+ @Nullable SyncRtSurfaceTransactionApplier syncTransactionApplier) {
RectF currentRect;
mTmpRectF.set(mTargetRect);
Utilities.scaleRectFAboutCenter(mTmpRectF, mTargetScale);
@@ -159,35 +163,51 @@
mClipRect.bottom = (int)
(mSourceStackBounds.height() - (mSourceWindowClipInsets.bottom * progress));
- TransactionCompat transaction = new TransactionCompat();
- if (mIsFirstFrame) {
- RemoteAnimationProvider.prepareTargetsForFirstFrame(targetSet.unfilteredApps,
- transaction, mBoostModeTargetLayers);
- mIsFirstFrame = false;
- }
- for (RemoteAnimationTargetCompat app : targetSet.apps) {
- if (app.activityType != RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
- mTmpMatrix.setRectToRect(mSourceRect, currentRect, ScaleToFit.FILL);
- mTmpMatrix.postTranslate(app.position.x, app.position.y);
- transaction.setMatrix(app.leash, mTmpMatrix)
- .setWindowCrop(app.leash, mClipRect);
+ SurfaceParams[] params = new SurfaceParams[targetSet.unfilteredApps.length];
+ for (int i = 0; i < targetSet.unfilteredApps.length; i++) {
+ RemoteAnimationTargetCompat app = targetSet.unfilteredApps[i];
+ mTmpMatrix.setTranslate(app.position.x, app.position.y);
+ Rect crop = app.sourceContainerBounds;
+ float alpha = 1f;
+ if (app.mode == targetSet.targetMode) {
+ if (app.activityType != RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
+ mTmpMatrix.setRectToRect(mSourceRect, currentRect, ScaleToFit.FILL);
+ mTmpMatrix.postTranslate(app.position.x, app.position.y);
+ crop = mClipRect;
+ }
+
+ if (app.isNotInRecents
+ || app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
+ alpha = 1 - progress;
+ }
+
+ alpha = mTaskAlphaCallback.apply(app, alpha);
}
- if (app.isNotInRecents
- || app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
- transaction.setAlpha(app.leash, 1 - progress);
- }
-
- mTaskTransformCallback.accept(transaction, app);
+ params[i] = new SurfaceParams(app.leash, alpha, mTmpMatrix, crop,
+ RemoteAnimationProvider.getLayer(app, mBoostModeTargetLayers));
}
- transaction.setEarlyWakeup();
- transaction.apply();
+ applyParams(syncTransactionApplier, params);
return currentRect;
}
- public void setTaskTransformCallback
- (BiConsumer<TransactionCompat, RemoteAnimationTargetCompat> callback) {
- mTaskTransformCallback = callback;
+ private void applyParams(@Nullable SyncRtSurfaceTransactionApplier syncTransactionApplier,
+ SurfaceParams[] params) {
+ if (syncTransactionApplier != null) {
+ syncTransactionApplier.scheduleApply(params);
+ } else {
+ TransactionCompat t = new TransactionCompat();
+ for (SurfaceParams param : params) {
+ SyncRtSurfaceTransactionApplier.applyParams(t, param);
+ }
+ t.setEarlyWakeup();
+ t.apply();
+ }
+ }
+
+ public void setTaskAlphaCallback(
+ BiFunction<RemoteAnimationTargetCompat, Float, Float> callback) {
+ mTaskAlphaCallback = callback;
}
public void offsetTarget(float scale, float offsetX, float offsetY, Interpolator interpolator) {
diff --git a/quickstep/src/com/android/quickstep/util/RemoteAnimationProvider.java b/quickstep/src/com/android/quickstep/util/RemoteAnimationProvider.java
index bbf223d..a7e6d74 100644
--- a/quickstep/src/com/android/quickstep/util/RemoteAnimationProvider.java
+++ b/quickstep/src/com/android/quickstep/util/RemoteAnimationProvider.java
@@ -28,6 +28,8 @@
@FunctionalInterface
public interface RemoteAnimationProvider {
+ static final int Z_BOOST_BASE = 800570000;
+
AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] targets);
default ActivityOptions toActivityOptions(Handler handler, long duration) {
@@ -54,11 +56,14 @@
static void prepareTargetsForFirstFrame(RemoteAnimationTargetCompat[] targets,
TransactionCompat t, int boostModeTargets) {
for (RemoteAnimationTargetCompat target : targets) {
- int layer = target.mode == boostModeTargets
- ? Integer.MAX_VALUE
- : target.prefixOrderIndex;
- t.setLayer(target.leash, layer);
+ t.setLayer(target.leash, getLayer(target, boostModeTargets));
t.show(target.leash);
}
}
+
+ static int getLayer(RemoteAnimationTargetCompat target, int boostModeTarget) {
+ return target.mode == boostModeTarget
+ ? Z_BOOST_BASE + target.prefixOrderIndex
+ : target.prefixOrderIndex;
+ }
}
diff --git a/quickstep/src/com/android/quickstep/util/RemoteAnimationTargetSet.java b/quickstep/src/com/android/quickstep/util/RemoteAnimationTargetSet.java
index 04b8be5..c372485 100644
--- a/quickstep/src/com/android/quickstep/util/RemoteAnimationTargetSet.java
+++ b/quickstep/src/com/android/quickstep/util/RemoteAnimationTargetSet.java
@@ -26,6 +26,7 @@
public final RemoteAnimationTargetCompat[] unfilteredApps;
public final RemoteAnimationTargetCompat[] apps;
+ public final int targetMode;
public RemoteAnimationTargetSet(RemoteAnimationTargetCompat[] apps, int targetMode) {
ArrayList<RemoteAnimationTargetCompat> filteredApps = new ArrayList<>();
@@ -39,6 +40,7 @@
this.unfilteredApps = apps;
this.apps = filteredApps.toArray(new RemoteAnimationTargetCompat[filteredApps.size()]);
+ this.targetMode = targetMode;
}
public RemoteAnimationTargetCompat findTask(int taskId) {
diff --git a/quickstep/src/com/android/quickstep/views/ClearAllButton.java b/quickstep/src/com/android/quickstep/views/ClearAllButton.java
index 25e3dc6..3911931 100644
--- a/quickstep/src/com/android/quickstep/views/ClearAllButton.java
+++ b/quickstep/src/com/android/quickstep/views/ClearAllButton.java
@@ -16,40 +16,58 @@
package com.android.quickstep.views;
-import static android.view.accessibility.AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS;
-
import android.content.Context;
-import android.graphics.Rect;
-import android.os.Bundle;
-import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.Button;
-public class ClearAllButton extends Button {
- RecentsView mRecentsView;
+import com.android.launcher3.Utilities;
+import com.android.quickstep.views.RecentsView.PageCallbacks;
+import com.android.quickstep.views.RecentsView.ScrollState;
- public ClearAllButton(Context context, @Nullable AttributeSet attrs) {
+public class ClearAllButton extends Button implements PageCallbacks {
+
+ private float mScrollAlpha = 1;
+ private float mContentAlpha = 1;
+
+ private final boolean mIsRtl;
+
+ private int mScrollOffset;
+
+ public ClearAllButton(Context context, AttributeSet attrs) {
super(context, attrs);
- }
-
- public void setRecentsView(RecentsView recentsView) {
- mRecentsView = recentsView;
+ mIsRtl = Utilities.isRtl(context.getResources());
}
@Override
- public boolean performAccessibilityAction(int action, Bundle arguments) {
- final boolean res = super.performAccessibilityAction(action, arguments);
- if (action == ACTION_ACCESSIBILITY_FOCUS) {
- mRecentsView.revealClearAllButton();
- }
- return res;
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+
+ RecentsView parent = (RecentsView) getParent();
+ mScrollOffset = mIsRtl ? parent.getPaddingRight() / 2 : - parent.getPaddingLeft() / 2;
}
@Override
- protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
- super.onFocusChanged(focused, direction, previouslyFocusedRect);
- if (focused) {
- mRecentsView.revealClearAllButton();
+ public boolean hasOverlappingRendering() {
+ return false;
+ }
+
+ public void setContentAlpha(float alpha) {
+ if (mContentAlpha != alpha) {
+ mContentAlpha = alpha;
+ setAlpha(mScrollAlpha * mContentAlpha);
}
}
+
+ @Override
+ public void onPageScroll(ScrollState scrollState) {
+ float width = getWidth();
+ if (width == 0) {
+ return;
+ }
+
+ float shift = Math.min(scrollState.scrollFromEdge, width);
+ setTranslationX(mIsRtl ? (mScrollOffset - shift) : (mScrollOffset + shift));
+ mScrollAlpha = 1 - shift / width;
+ setAlpha(mScrollAlpha * mContentAlpha);
+ }
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 02cdd3a..f7f496f 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -16,13 +16,14 @@
package com.android.quickstep.views;
-import static com.android.launcher3.BaseActivity.INVISIBLE_BY_STATE_HANDLER;
+import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW;
import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId;
+import static com.android.quickstep.WindowTransformSwipeHandler.MIN_PROGRESS_FOR_OVERVIEW;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -47,7 +48,9 @@
import android.text.TextPaint;
import android.util.ArraySet;
import android.util.AttributeSet;
+import android.util.FloatProperty;
import android.util.SparseBooleanArray;
+import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -97,11 +100,24 @@
private static final String TAG = RecentsView.class.getSimpleName();
+ public static final FloatProperty<RecentsView> CONTENT_ALPHA =
+ new FloatProperty<RecentsView>("contentAlpha") {
+ @Override
+ public void setValue(RecentsView view, float v) {
+ view.setContentAlpha(v);
+ }
+
+ @Override
+ public Float get(RecentsView view) {
+ return view.getContentAlpha();
+ }
+ };
+
private final Rect mTempRect = new Rect();
private static final int DISMISS_TASK_DURATION = 300;
// The threshold at which we update the SystemUI flags when animating from the task into the app
- private static final float UPDATE_SYSUI_FLAGS_THRESHOLD = 0.6f;
+ public static final float UPDATE_SYSUI_FLAGS_THRESHOLD = 0.85f;
private static final float[] sTempFloatArray = new float[3];
@@ -110,13 +126,12 @@
private final float mFastFlingVelocity;
private final RecentsModel mModel;
private final int mTaskTopMargin;
+ private final ClearAllButton mClearAllButton;
private final ScrollState mScrollState = new ScrollState();
// Keeps track of the previously known visible tasks for purposes of loading/unloading task data
private final SparseBooleanArray mHasVisibleTaskData = new SparseBooleanArray();
- private boolean mIsClearAllButtonFullyRevealed;
-
/**
* TODO: Call reloadIdNeeded in onTaskStackChanged.
*/
@@ -198,7 +213,7 @@
public void onPinnedStackAnimationStarted() {
// Needed for activities that auto-enter PiP, which will not trigger a remote
// animation to be created
- mActivity.clearForceInvisibleFlag(INVISIBLE_BY_STATE_HANDLER);
+ mActivity.clearForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
}
};
@@ -224,8 +239,6 @@
// Keeps track of task views whose visual state should not be reset
private ArraySet<TaskView> mIgnoreResetTaskViews = new ArraySet<>();
- private View mClearAllButton;
-
// Variables for empty state
private final Drawable mEmptyIcon;
private final CharSequence mEmptyMessage;
@@ -246,8 +259,8 @@
public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setPageSpacing(getResources().getDimensionPixelSize(R.dimen.recents_page_spacing));
- enableFreeScroll(true);
- setClipToOutline(true);
+ setEnableFreeScroll(true);
+ setEnableOverscroll(true);
mFastFlingVelocity = getResources()
.getDimensionPixelSize(R.dimen.recents_fast_fling_velocity);
@@ -255,6 +268,10 @@
mQuickScrubController = new QuickScrubController(mActivity, this);
mModel = RecentsModel.getInstance(context);
+ mClearAllButton = (ClearAllButton) LayoutInflater.from(context)
+ .inflate(R.layout.overview_clear_all_button, this, false);
+ mClearAllButton.setOnClickListener(this::dismissAllTasks);
+
mIsRtl = !Utilities.isRtl(getResources());
setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
mTaskTopMargin = getResources()
@@ -271,7 +288,6 @@
.getDimensionPixelSize(R.dimen.recents_empty_message_text_padding);
setWillNotDraw(false);
updateEmptyMessage();
- setFocusable(false);
}
public boolean isRtl() {
@@ -313,14 +329,15 @@
super.onViewRemoved(child);
// Clear the task data for the removed child if it was visible
- Task task = ((TaskView) child).getTask();
- if (mHasVisibleTaskData.get(task.key.id)) {
- mHasVisibleTaskData.delete(task.key.id);
- RecentsTaskLoader loader = mModel.getRecentsTaskLoader();
- loader.unloadTaskData(task);
- loader.getHighResThumbnailLoader().onTaskInvisible(task);
+ if (child != mClearAllButton) {
+ Task task = ((TaskView) child).getTask();
+ if (mHasVisibleTaskData.get(task.key.id)) {
+ mHasVisibleTaskData.delete(task.key.id);
+ RecentsTaskLoader loader = mModel.getRecentsTaskLoader();
+ loader.unloadTaskData(task);
+ loader.getHighResThumbnailLoader().onTaskInvisible(task);
+ }
}
- onChildViewsChanged();
}
public boolean isTaskViewVisible(TaskView tv) {
@@ -329,7 +346,7 @@
}
public TaskView getTaskView(int taskId) {
- for (int i = 0; i < getChildCount(); i++) {
+ for (int i = 0; i < getTaskViewCount(); i++) {
TaskView tv = (TaskView) getChildAt(i);
if (tv.getTask().key.id == taskId) {
return tv;
@@ -359,69 +376,14 @@
}
}
- private int getScrollEnd() {
- return mIsRtl ? 0 : mMaxScrollX;
- }
-
- private float calculateClearAllButtonAlpha() {
- final int childCount = getChildCount();
- if (mShowEmptyMessage || childCount == 0 || mPageScrolls == null
- || childCount != mPageScrolls.length) {
- return 0;
- }
-
- final int scrollEnd = getScrollEnd();
- final int oldestChildScroll = getScrollForPage(childCount - 1);
-
- final int clearAllButtonMotionRange = scrollEnd - oldestChildScroll;
- if (clearAllButtonMotionRange == 0) return 0;
-
- final float alphaUnbound = ((float) (getScrollX() - oldestChildScroll)) /
- clearAllButtonMotionRange;
- if (alphaUnbound > 1) return 0;
-
- return Math.max(alphaUnbound, 0);
- }
-
- private void updateClearAllButtonAlpha() {
- if (mClearAllButton != null) {
- final float alpha = calculateClearAllButtonAlpha();
- mIsClearAllButtonFullyRevealed = alpha == 1;
- mClearAllButton.setAlpha(alpha * mContentAlpha);
- }
- }
-
- @Override
- protected void onScrollChanged(int l, int t, int oldl, int oldt) {
- super.onScrollChanged(l, t, oldl, oldt);
- updateClearAllButtonAlpha();
- }
-
- @Override
- protected void restoreScrollOnLayout() {
- if (mIsClearAllButtonFullyRevealed) {
- scrollAndForceFinish(getScrollEnd());
- } else {
- super.restoreScrollOnLayout();
- }
- }
-
@Override
public boolean onTouchEvent(MotionEvent ev) {
- if (ev.getAction() == MotionEvent.ACTION_DOWN && mTouchState == TOUCH_STATE_REST
- && mScroller.isFinished() && mIsClearAllButtonFullyRevealed) {
- mClearAllButton.getHitRect(mTempRect);
- mTempRect.offset(-getLeft(), -getTop());
- if (mTempRect.contains((int) ev.getX(), (int) ev.getY())) {
- // If nothing is in motion, let the Clear All button process the event.
- return false;
- }
- }
-
+ super.onTouchEvent(ev);
if (ev.getAction() == MotionEvent.ACTION_UP && mShowEmptyMessage) {
onAllTasksRemoved();
}
- return super.onTouchEvent(ev);
+ // Do not let touch escape to siblings below this view.
+ return true;
}
private void applyLoadPlan(RecentsTaskLoadPlan loadPlan) {
@@ -443,22 +405,30 @@
final LayoutInflater inflater = LayoutInflater.from(getContext());
final ArrayList<Task> tasks = new ArrayList<>(stack.getTasks());
- final int requiredChildCount = tasks.size();
- for (int i = getChildCount(); i < requiredChildCount; i++) {
- final TaskView taskView = (TaskView) inflater.inflate(R.layout.task, this, false);
- addView(taskView);
- }
- while (getChildCount() > requiredChildCount) {
- final TaskView taskView = (TaskView) getChildAt(getChildCount() - 1);
- removeView(taskView);
+ final int requiredTaskCount = tasks.size();
+ if (getTaskViewCount() != requiredTaskCount) {
+ if (oldChildCount > 0) {
+ removeView(mClearAllButton);
+ }
+ for (int i = getChildCount(); i < requiredTaskCount; i++) {
+ final TaskView taskView = (TaskView) inflater.inflate(R.layout.task, this, false);
+ addView(taskView);
+ }
+ while (getChildCount() > requiredTaskCount) {
+ final TaskView taskView = (TaskView) getChildAt(getChildCount() - 1);
+ removeView(taskView);
+ }
+ if (requiredTaskCount > 0) {
+ addView(mClearAllButton);
+ }
}
// Unload existing visible task data
unloadVisibleTaskData();
// Rebind and reset all task views
- for (int i = requiredChildCount - 1; i >= 0; i--) {
- final int pageIndex = requiredChildCount - i - 1;
+ for (int i = requiredTaskCount - 1; i >= 0; i--) {
+ final int pageIndex = requiredTaskCount - i - 1;
final Task task = tasks.get(i);
final TaskView taskView = (TaskView) getChildAt(pageIndex);
taskView.bind(task);
@@ -471,10 +441,16 @@
onTaskStackUpdated();
}
+ public int getTaskViewCount() {
+ // Account for the clear all button.
+ int childCount = getChildCount();
+ return childCount == 0 ? 0 : childCount - 1;
+ }
+
protected void onTaskStackUpdated() { }
public void resetTaskVisuals() {
- for (int i = getChildCount() - 1; i >= 0; i--) {
+ for (int i = getTaskViewCount() - 1; i >= 0; i--) {
TaskView taskView = (TaskView) getChildAt(i);
if (!mIgnoreResetTaskViews.contains(taskView)) {
taskView.resetVisualProperties();
@@ -507,6 +483,7 @@
DeviceProfile dp = mActivity.getDeviceProfile();
getTaskSize(dp, mTempRect);
+ // Keep this logic in sync with ActivityControlHelper.getTranslationYForQuickScrub.
mTempRect.top -= mTaskTopMargin;
setPadding(mTempRect.left - mInsets.left, mTempRect.top - mInsets.top,
dp.availableWidthPx + mInsets.left - mTempRect.right,
@@ -547,10 +524,12 @@
if (getPageCount() == 0 || getPageAt(0).getMeasuredWidth() == 0) {
return;
}
+ int scrollX = getScrollX();
final int halfPageWidth = getNormalChildWidth() / 2;
- final int screenCenter = mInsets.left + getPaddingLeft() + getScrollX() + halfPageWidth;
+ final int screenCenter = mInsets.left + getPaddingLeft() + scrollX + halfPageWidth;
final int halfScreenWidth = getMeasuredWidth() / 2;
final int pageSpacing = mPageSpacing;
+ mScrollState.scrollFromEdge = mIsRtl ? scrollX : (mMaxScrollX - scrollX);
final int pageCount = getPageCount();
for (int i = 0; i < pageCount; i++) {
@@ -576,9 +555,9 @@
RecentsTaskLoader loader = mModel.getRecentsTaskLoader();
int centerPageIndex = getPageNearestToCenterOfScreen();
+ int numChildren = getTaskViewCount();
int lower = Math.max(0, centerPageIndex - 2);
- int upper = Math.min(centerPageIndex + 2, getChildCount() - 1);
- int numChildren = getChildCount();
+ int upper = Math.min(centerPageIndex + 2, numChildren - 1);
// Update the task data for the in/visible children
for (int i = 0; i < numChildren; i++) {
@@ -656,12 +635,14 @@
final TaskView taskView = (TaskView) LayoutInflater.from(getContext())
.inflate(R.layout.task, this, false);
addView(taskView);
+ addView(mClearAllButton);
// The temporary running task is only used for the duration between the start of the
// gesture and the task list is loaded and applied
- mTmpRunningTask = new Task(new Task.TaskKey(runningTaskId, 0, new Intent(), 0, 0), null,
- null, "", "", 0, 0, false, true, false, false,
- new ActivityManager.TaskDescription(), 0, new ComponentName("", ""), false);
+ mTmpRunningTask = new Task(new Task.TaskKey(runningTaskId, 0, new Intent(),
+ new ComponentName(getContext(), getClass()), 0, 0), null, null, "", "", 0, 0,
+ false, true, false, false, new ActivityManager.TaskDescription(), 0,
+ new ComponentName("", ""), false);
taskView.bind(mTmpRunningTask);
}
setCurrentTask(runningTaskId);
@@ -701,14 +682,14 @@
TaskView runningTaskView = getTaskView(mRunningTaskId);
if (runningTaskView == null) {
// Launch the first task
- if (getChildCount() > 0) {
+ if (getTaskViewCount() > 0) {
((TaskView) getChildAt(0)).launchTask(true /* animate */);
}
} else {
// Get the next launch task
int runningTaskIndex = indexOfChild(runningTaskView);
- int nextTaskIndex = Math.max(0, Math.min(getChildCount() - 1, runningTaskIndex + 1));
- if (nextTaskIndex < getChildCount()) {
+ int nextTaskIndex = Math.max(0, Math.min(getTaskViewCount() - 1, runningTaskIndex + 1));
+ if (nextTaskIndex < getTaskViewCount()) {
((TaskView) getChildAt(nextTaskIndex)).launchTask(true /* animate */);
}
}
@@ -751,7 +732,7 @@
/**
* Updates the page UI based on scroll params.
*/
- default void onPageScroll(ScrollState scrollState) {};
+ default void onPageScroll(ScrollState scrollState) {}
}
public static class ScrollState {
@@ -761,6 +742,11 @@
* of the screen and 1 is the edge of the screen.
*/
public float linearInterpolation;
+
+ /**
+ * The amount by which all the content is scrolled relative to the end of the list.
+ */
+ public float scrollFromEdge;
}
public void addIgnoreResetTask(TaskView taskView) {
@@ -784,7 +770,7 @@
if (shouldLog) {
mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(
onEndListener.logAction, Direction.UP, index,
- TaskUtils.getComponentKeyForTask(task.key));
+ TaskUtils.getLaunchComponentKeyForTask(task.key));
}
}
}
@@ -797,7 +783,7 @@
AnimatorSet anim = new AnimatorSet();
PendingAnimation pendingAnimation = new PendingAnimation(anim);
- int count = getChildCount();
+ int count = getPageCount();
if (count == 0) {
return pendingAnimation;
}
@@ -808,12 +794,10 @@
int[] newScroll = new int[count];
getPageScrolls(newScroll, false, (v) -> v.getVisibility() != GONE && v != taskView);
+ int taskCount = getTaskViewCount();
int scrollDiffPerPage = 0;
- int leftmostPage = mIsRtl ? count -1 : 0;
- int rightmostPage = mIsRtl ? 0 : count - 1;
if (count > 1) {
- int secondRightmostPage = mIsRtl ? 1 : count - 2;
- scrollDiffPerPage = oldScroll[rightmostPage] - oldScroll[secondRightmostPage];
+ scrollDiffPerPage = Math.abs(oldScroll[1] - oldScroll[0]);
}
int draggedIndex = indexOfChild(taskView);
@@ -833,7 +817,7 @@
// - Dragging an adjacent page on the left side (right side for RTL)
int offset = mIsRtl ? scrollDiffPerPage : 0;
if (mCurrentPage == draggedIndex) {
- int lastPage = mIsRtl ? leftmostPage : rightmostPage;
+ int lastPage = taskCount - 1;
if (mCurrentPage == lastPage) {
offset += mIsRtl ? -scrollDiffPerPage : scrollDiffPerPage;
}
@@ -871,13 +855,15 @@
removeTask(taskView.getTask(), draggedIndex, onEndListener, true);
}
int pageToSnapTo = mCurrentPage;
- if (draggedIndex < pageToSnapTo) {
+ if (draggedIndex < pageToSnapTo || pageToSnapTo == (getTaskViewCount() - 1)) {
pageToSnapTo -= 1;
}
removeView(taskView);
- if (getChildCount() == 0) {
+
+ if (getTaskViewCount() == 0) {
+ removeView(mClearAllButton);
onAllTasksRemoved();
- } else if (!mIsClearAllButtonFullyRevealed) {
+ } else {
snapToPageImmediately(pageToSnapTo);
}
}
@@ -894,7 +880,7 @@
AnimatorSet anim = new AnimatorSet();
PendingAnimation pendingAnimation = new PendingAnimation(anim);
- int count = getChildCount();
+ int count = getTaskViewCount();
for (int i = 0; i < count; i++) {
addDismissedTaskAnimations(getChildAt(i), anim, duration);
}
@@ -902,11 +888,11 @@
mPendingAnimation = pendingAnimation;
mPendingAnimation.addEndListener((onEndListener) -> {
if (onEndListener.isSuccess) {
- while (getChildCount() != 0) {
- TaskView taskView = getPageAt(getChildCount() - 1);
- removeTask(taskView.getTask(), -1, onEndListener, false);
- removeView(taskView);
+ int taskViewCount = getTaskViewCount();
+ for (int i = 0; i < taskViewCount; i++) {
+ removeTask(getTaskViewAt(i).getTask(), -1, onEndListener, false);
}
+ removeAllViews();
onAllTasksRemoved();
}
mPendingAnimation = null;
@@ -920,15 +906,16 @@
set.play(anim);
}
- private boolean snapToPageRelative(int delta, boolean cycle) {
- if (getPageCount() == 0) {
+ private boolean snapToPageRelative(int pageCount, int delta, boolean cycle) {
+ if (pageCount == 0) {
return false;
}
final int newPageUnbound = getNextPage() + delta;
- if (!cycle && (newPageUnbound < 0 || newPageUnbound >= getChildCount())) {
+ if (!cycle && (newPageUnbound < 0 || newPageUnbound >= pageCount)) {
return false;
}
- snapToPage((newPageUnbound + getPageCount()) % getPageCount());
+ snapToPage((newPageUnbound + pageCount) % pageCount);
+ getChildAt(getNextPage()).requestFocus();
return true;
}
@@ -946,31 +933,37 @@
DISMISS_TASK_DURATION));
}
- public void dismissAllTasks() {
+ @SuppressWarnings("unused")
+ private void dismissAllTasks(View view) {
runDismissAnimation(createAllTasksDismissAnimation(DISMISS_TASK_DURATION));
}
+ private void dismissCurrentTask() {
+ TaskView taskView = getTaskView(getNextPage());
+ if (taskView != null) {
+ dismissTask(taskView, true /*animateTaskView*/, true /*removeTask*/);
+ }
+ }
+
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_TAB:
- return snapToPageRelative(event.isShiftPressed() ? -1 : 1,
+ return snapToPageRelative(getTaskViewCount(), event.isShiftPressed() ? -1 : 1,
event.isAltPressed() /* cycle */);
case KeyEvent.KEYCODE_DPAD_RIGHT:
- return snapToPageRelative(mIsRtl ? -1 : 1, false /* cycle */);
+ return snapToPageRelative(getPageCount(), mIsRtl ? -1 : 1, false /* cycle */);
case KeyEvent.KEYCODE_DPAD_LEFT:
- return snapToPageRelative(mIsRtl ? 1 : -1, false /* cycle */);
+ return snapToPageRelative(getPageCount(), mIsRtl ? 1 : -1, false /* cycle */);
case KeyEvent.KEYCODE_DEL:
case KeyEvent.KEYCODE_FORWARD_DEL:
- dismissTask((TaskView) getChildAt(getNextPage()), true /*animateTaskView*/,
- true /*removeTask*/);
+ dismissCurrentTask();
return true;
case KeyEvent.KEYCODE_NUMPAD_DOT:
if (event.isAltPressed()) {
// Numpad DEL pressed while holding Alt.
- dismissTask((TaskView) getChildAt(getNextPage()), true /*animateTaskView*/,
- true /*removeTask*/);
+ dismissCurrentTask();
return true;
}
}
@@ -1001,19 +994,24 @@
}
public void setContentAlpha(float alpha) {
+ if (alpha == mContentAlpha) {
+ return;
+ }
alpha = Utilities.boundToRange(alpha, 0, 1);
mContentAlpha = alpha;
- for (int i = getChildCount() - 1; i >= 0; i--) {
- TaskView child = getPageAt(i);
+ for (int i = getTaskViewCount() - 1; i >= 0; i--) {
+ TaskView child = getTaskViewAt(i);
if (!mRunningTaskTileHidden || child.getTask().key.id != mRunningTaskId) {
getChildAt(i).setAlpha(alpha);
}
}
+ mClearAllButton.setContentAlpha(mContentAlpha);
int alphaInt = Math.round(alpha * 255);
mEmptyMessagePaint.setAlpha(alphaInt);
mEmptyIcon.setAlpha(alphaInt);
- updateClearAllButtonAlpha();
+
+ setVisibility(alpha > 0 ? VISIBLE : GONE);
}
private float[] getAdjacentScaleAndTranslation(TaskView currTask,
@@ -1029,12 +1027,11 @@
public void onViewAdded(View child) {
super.onViewAdded(child);
child.setAlpha(mContentAlpha);
- onChildViewsChanged();
}
- @Override
- public TaskView getPageAt(int index) {
- return (TaskView) getChildAt(index);
+ public TaskView getTaskViewAt(int index) {
+ View child = getChildAt(index);
+ return child == mClearAllButton ? null : (TaskView) child;
}
public void updateEmptyMessage() {
@@ -1068,7 +1065,6 @@
mEmptyTextLayout = null;
mLastMeasureSize.set(getWidth(), getHeight());
}
- updateClearAllButtonAlpha();
if (mShowEmptyMessage && hasValidSize && mEmptyTextLayout == null) {
int availableWidth = mLastMeasureSize.x - mEmptyMessagePadding - mEmptyMessagePadding;
@@ -1126,16 +1122,16 @@
float toTranslationY = clipAnimationHelper.getSourceRect().centerY()
- clipAnimationHelper.getTargetRect().centerY();
if (launchingCenterTask) {
- TaskView centerTask = getPageAt(centerTaskIndex);
+ TaskView centerTask = getTaskViewAt(centerTaskIndex);
if (taskIndex - 1 >= 0) {
- TaskView adjacentTask = getPageAt(taskIndex - 1);
+ TaskView adjacentTask = getTaskViewAt(taskIndex - 1);
float[] scaleAndTranslation = getAdjacentScaleAndTranslation(centerTask,
toScale, toTranslationY);
scaleAndTranslation[1] = -scaleAndTranslation[1];
anim.play(createAnimForChild(adjacentTask, scaleAndTranslation));
}
- if (taskIndex + 1 < getPageCount()) {
- TaskView adjacentTask = getPageAt(taskIndex + 1);
+ if (taskIndex + 1 < getTaskViewCount()) {
+ TaskView adjacentTask = getTaskViewAt(taskIndex + 1);
float[] scaleAndTranslation = getAdjacentScaleAndTranslation(centerTask,
toScale, toTranslationY);
anim.play(createAnimForChild(adjacentTask, scaleAndTranslation));
@@ -1184,6 +1180,7 @@
TaskViewDrawable drawable = new TaskViewDrawable(tv, this);
getOverlay().add(drawable);
+ final boolean[] passedOverviewThreshold = new boolean[] {false};
ObjectAnimator drawableAnim =
ObjectAnimator.ofFloat(drawable, TaskViewDrawable.PROGRESS, 1, 0);
drawableAnim.setInterpolator(LINEAR);
@@ -1194,6 +1191,14 @@
animator.getAnimatedFraction() > UPDATE_SYSUI_FLAGS_THRESHOLD
? targetSysUiFlags
: 0);
+
+ // Passing the threshold from taskview to fullscreen app will vibrate
+ final boolean passed = animator.getAnimatedFraction() >= MIN_PROGRESS_FOR_OVERVIEW;
+ if (passed != passedOverviewThreshold[0]) {
+ passedOverviewThreshold[0] = passed;
+ performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
+ HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
+ }
});
AnimatorSet anim = createAdjacentPageAnimForTaskLaunch(tv,
@@ -1221,7 +1226,7 @@
if (task != null) {
mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(
onEndListener.logAction, Direction.DOWN, indexOfChild(tv),
- TaskUtils.getComponentKeyForTask(task.key));
+ TaskUtils.getLaunchComponentKeyForTask(task.key));
}
} else {
onTaskLaunchFinish.accept(false);
@@ -1248,44 +1253,9 @@
return "";
}
- private int additionalScrollForClearAllButton() {
- return (int) getResources().getDimension(
- R.dimen.clear_all_container_width) - getPaddingEnd();
- }
-
- @Override
- protected int computeMaxScrollX() {
- if (getChildCount() == 0) {
- return super.computeMaxScrollX();
- }
-
- // Allow a clear_all_container_width-sized gap after the last task.
- return super.computeMaxScrollX() + (mIsRtl ? 0 : additionalScrollForClearAllButton());
- }
-
- @Override
- protected int offsetForPageScrolls() {
- return mIsRtl ? additionalScrollForClearAllButton() : 0;
- }
-
- public void setClearAllButton(View clearAllButton) {
- mClearAllButton = clearAllButton;
- updateClearAllButtonAlpha();
- }
-
- private void onChildViewsChanged() {
- final int childCount = getChildCount();
- mClearAllButton.setVisibility(childCount == 0 ? INVISIBLE : VISIBLE);
- setFocusable(childCount != 0);
- }
-
- public void revealClearAllButton() {
- setCurrentPage(getChildCount() - 1); // Loads tasks info if needed.
- scrollTo(mIsRtl ? 0 : computeMaxScrollX(), 0);
- }
-
@Override
public void addChildrenForAccessibility(ArrayList<View> outChildren) {
+ // Add children in reverse order
for (int i = getChildCount() - 1; i >= 0; --i) {
outChildren.add(getChildAt(i));
}
@@ -1294,10 +1264,9 @@
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
-
final AccessibilityNodeInfo.CollectionInfo
collectionInfo = AccessibilityNodeInfo.CollectionInfo.obtain(
- 1, getChildCount(), false,
+ 1, getTaskViewCount(), false,
AccessibilityNodeInfo.CollectionInfo.SELECTION_MODE_NONE);
info.setCollectionInfo(collectionInfo);
}
@@ -1306,12 +1275,14 @@
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
+ final int taskViewCount = getTaskViewCount();
+ event.setScrollable(taskViewCount > 0);
+
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
- final int childCount = getChildCount();
final int[] visibleTasks = getVisibleChildrenRange();
- event.setFromIndex(childCount - visibleTasks[1] - 1);
- event.setToIndex(childCount - visibleTasks[0] - 1);
- event.setItemCount(childCount);
+ event.setFromIndex(taskViewCount - visibleTasks[1] - 1);
+ event.setToIndex(taskViewCount - visibleTasks[0] - 1);
+ event.setItemCount(taskViewCount);
}
}
@@ -1325,11 +1296,4 @@
protected boolean isPageOrderFlipped() {
return true;
}
-
- public void addTaskAccessibilityActionsExtra(AccessibilityNodeInfo info) {
- }
-
- public boolean performTaskAccessibilityActionExtra(int action) {
- return false;
- }
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java
deleted file mode 100644
index 31c8b64..0000000
--- a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2018 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.views;
-
-import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.TAP;
-import static com.android.launcher3.userevent.nano.LauncherLogProto.ControlType.CLEAR_ALL_BUTTON;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.util.FloatProperty;
-import android.view.MotionEvent;
-import android.view.View;
-
-import com.android.launcher3.InsettableFrameLayout;
-import com.android.launcher3.R;
-
-import java.util.ArrayList;
-
-public class RecentsViewContainer extends InsettableFrameLayout {
- public static final FloatProperty<RecentsViewContainer> CONTENT_ALPHA =
- new FloatProperty<RecentsViewContainer>("contentAlpha") {
- @Override
- public void setValue(RecentsViewContainer view, float v) {
- view.setContentAlpha(v);
- }
-
- @Override
- public Float get(RecentsViewContainer view) {
- return view.mRecentsView.getContentAlpha();
- }
- };
-
- private final Rect mTempRect = new Rect();
-
- private RecentsView mRecentsView;
- private ClearAllButton mClearAllButton;
-
- public RecentsViewContainer(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- mClearAllButton = findViewById(R.id.clear_all_button);
- mClearAllButton.setOnClickListener((v) -> {
- mRecentsView.mActivity.getUserEventDispatcher()
- .logActionOnControl(TAP, CLEAR_ALL_BUTTON);
- mRecentsView.dismissAllTasks();
- });
-
- mRecentsView = findViewById(R.id.overview_panel);
- mClearAllButton.forceHasOverlappingRendering(false);
-
- mRecentsView.setClearAllButton(mClearAllButton);
- mClearAllButton.setRecentsView(mRecentsView);
-
- if (mRecentsView.isRtl()) {
- mClearAllButton.setNextFocusRightId(mRecentsView.getId());
- mRecentsView.setNextFocusLeftId(mClearAllButton.getId());
- } else {
- mClearAllButton.setNextFocusLeftId(mRecentsView.getId());
- mRecentsView.setNextFocusRightId(mClearAllButton.getId());
- }
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
-
- mRecentsView.getTaskSize(mTempRect);
-
- mClearAllButton.setTranslationX(
- (mRecentsView.isRtl() ? 1 : -1) *
- (getResources().getDimension(R.dimen.clear_all_container_width)
- - mClearAllButton.getMeasuredWidth()) / 2);
- mClearAllButton.setTranslationY(
- mTempRect.top + (mTempRect.height() - mClearAllButton.getMeasuredHeight()) / 2
- - mClearAllButton.getTop());
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- super.onTouchEvent(ev);
- // Do not let touch escape to siblings below this view. This prevents scrolling of the
- // workspace while in Recents.
- return true;
- }
-
- public void setContentAlpha(float alpha) {
- if (alpha == mRecentsView.getContentAlpha()) {
- return;
- }
- mRecentsView.setContentAlpha(alpha);
- setVisibility(alpha > 0 ? VISIBLE : GONE);
- }
-
- @Override
- public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
- if (mRecentsView.getChildCount() > 0) {
- // Carousel is first in tab order.
- views.add(mRecentsView);
- views.add(mClearAllButton);
- }
- }
-
- public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
- return mRecentsView.requestFocus(direction, previouslyFocusedRect) ||
- super.requestFocus(direction, previouslyFocusedRect);
- }
-}
\ No newline at end of file
diff --git a/quickstep/src/com/android/quickstep/views/ShelfScrimView.java b/quickstep/src/com/android/quickstep/views/ShelfScrimView.java
index aca8351..d7e527c 100644
--- a/quickstep/src/com/android/quickstep/views/ShelfScrimView.java
+++ b/quickstep/src/com/android/quickstep/views/ShelfScrimView.java
@@ -15,11 +15,11 @@
*/
package com.android.quickstep.views;
-import static android.support.v4.graphics.ColorUtils.compositeColors;
import static android.support.v4.graphics.ColorUtils.setAlphaComponent;
import static com.android.launcher3.LauncherState.OVERVIEW;
-import static com.android.launcher3.anim.Interpolators.ACCEL_2;
+import static com.android.launcher3.anim.Interpolators.ACCEL;
+import static com.android.launcher3.anim.Interpolators.LINEAR;
import android.content.Context;
import android.graphics.Canvas;
@@ -28,14 +28,11 @@
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.Path.Op;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
import android.util.AttributeSet;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
-import com.android.launcher3.uioverrides.OverviewState;
+import com.android.launcher3.Utilities;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ScrimView;
@@ -48,27 +45,30 @@
*/
public class ShelfScrimView extends ScrimView {
- private static final int THRESHOLD_ALPHA_DARK = 102;
- private static final int THRESHOLD_ALPHA_LIGHT = 46;
- private static final int THRESHOLD_ALPHA_SUPER_LIGHT = 128;
- private static final int CLEAR_ALL_TASKS = R.string.recents_clear_all;
+ // If the progress is more than this, shelf follows the finger, otherwise it moves faster to
+ // cover the whole screen
+ private static final float SCRIM_CATCHUP_THRESHOLD = 0.2f;
// In transposed layout, we simply draw a flat color.
private boolean mDrawingFlatColor;
// For shelf mode
private final int mEndAlpha;
- private final int mThresholdAlpha;
private final float mRadius;
private final float mMaxScrimAlpha;
private final Paint mPaint;
- // Max vertical progress after which the scrim stops moving.
- private float mMoveThreshold;
- // Minimum visible size of the scrim.
- private int mMinSize;
+ // Mid point where the alpha changes
+ private int mMidAlpha;
+ private float mMidProgress;
- private float mScrimMoveFactor = 0;
+ private float mShiftRange;
+
+ private final float mShelfOffset;
+ private float mTopOffset;
+ private float mShelfTop;
+ private float mShelfTopAtThreshold;
+
private int mShelfColor;
private int mRemainingScreenColor;
@@ -81,16 +81,10 @@
mMaxScrimAlpha = OVERVIEW.getWorkspaceScrimAlpha(mLauncher);
mEndAlpha = Color.alpha(mEndScrim);
- if (Themes.getAttrBoolean(mLauncher, R.attr.isMainColorDark)) {
- mThresholdAlpha = THRESHOLD_ALPHA_DARK;
- } else if (Themes.getAttrBoolean(mLauncher, R.attr.isWorkspaceDarkText)) {
- mThresholdAlpha = THRESHOLD_ALPHA_SUPER_LIGHT;
- } else {
- mThresholdAlpha = THRESHOLD_ALPHA_LIGHT;
- }
mRadius = mLauncher.getResources().getDimension(R.dimen.shelf_surface_radius);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mShelfOffset = context.getResources().getDimension(R.dimen.shelf_surface_offset);
// Just assume the easiest UI for now, until we have the proper layout information.
mDrawingFlatColor = true;
}
@@ -107,10 +101,15 @@
mDrawingFlatColor = dp.isVerticalBarLayout();
if (!mDrawingFlatColor) {
- float swipeLength = OverviewState.getDefaultSwipeHeight(mLauncher);
- mMoveThreshold = 1 - swipeLength / mLauncher.getAllAppsController().getShiftRange();
- mMinSize = dp.hotseatBarSizePx + dp.getInsets().bottom;
mRemainingScreenPathValid = false;
+ mShiftRange = mLauncher.getAllAppsController().getShiftRange();
+
+ mMidProgress = OVERVIEW.getVerticalProgress(mLauncher);
+ mMidAlpha = mMidProgress >= 1 ? 0
+ : Themes.getAttrInteger(getContext(), R.attr.allAppsInterimScrimAlpha);
+
+ mTopOffset = dp.getInsets().top - mShelfOffset;
+ mShelfTopAtThreshold = mShiftRange * SCRIM_CATCHUP_THRESHOLD + mTopOffset;
updateColors();
}
updateDragHandleAlpha();
@@ -121,82 +120,79 @@
public void updateColors() {
super.updateColors();
if (mDrawingFlatColor) {
+ mDragHandleOffset = 0;
return;
}
- if (mProgress >= mMoveThreshold) {
- mScrimMoveFactor = 1;
-
- if (mProgress >= 1) {
- mShelfColor = 0;
- } else {
- int alpha = Math.round(mThresholdAlpha * ACCEL_2.getInterpolation(
- (1 - mProgress) / (1 - mMoveThreshold)));
- mShelfColor = setAlphaComponent(mEndScrim, alpha);
- }
-
- mRemainingScreenColor = 0;
- } else if (mProgress <= 0) {
- mScrimMoveFactor = 0;
- mShelfColor = mCurrentFlatColor;
- mRemainingScreenColor = 0;
-
+ mDragHandleOffset = mShelfOffset - mDragHandleSize;
+ if (mProgress >= SCRIM_CATCHUP_THRESHOLD) {
+ mShelfTop = mShiftRange * mProgress + mTopOffset;
} else {
- mScrimMoveFactor = mProgress / mMoveThreshold;
- mRemainingScreenColor = setAlphaComponent(mScrimColor,
- Math.round((1 - mScrimMoveFactor) * mMaxScrimAlpha * 255));
+ mShelfTop = Utilities.mapRange(mProgress / SCRIM_CATCHUP_THRESHOLD, -mRadius,
+ mShelfTopAtThreshold);
+ }
- // Merge the remainingScreenColor and shelfColor in one to avoid overdraw.
- int alpha = mEndAlpha - Math.round((mEndAlpha - mThresholdAlpha) * mScrimMoveFactor);
- mShelfColor = compositeColors(setAlphaComponent(mEndScrim, alpha),
- mRemainingScreenColor);
+ if (mProgress >= 1) {
+ mRemainingScreenColor = 0;
+ mShelfColor = 0;
+ } else if (mProgress >= mMidProgress) {
+ mRemainingScreenColor = 0;
+
+ int alpha = Math.round(Utilities.mapToRange(
+ mProgress, mMidProgress, 1, mMidAlpha, 0, ACCEL));
+ mShelfColor = setAlphaComponent(mEndScrim, alpha);
+ } else {
+ mDragHandleOffset += mShiftRange * (mMidProgress - mProgress);
+
+ int alpha = Math.round(
+ Utilities.mapToRange(mProgress, (float) 0, mMidProgress, (float) mEndAlpha,
+ (float) mMidAlpha, LINEAR));
+ mShelfColor = setAlphaComponent(mEndScrim, alpha);
+
+ int remainingScrimAlpha = Math.round(
+ Utilities.mapToRange(mProgress, (float) 0, mMidProgress, mMaxScrimAlpha,
+ (float) 0, LINEAR));
+ mRemainingScreenColor = setAlphaComponent(mScrimColor, remainingScrimAlpha);
}
}
@Override
protected void onDraw(Canvas canvas) {
- float translate = drawBackground(canvas);
-
- if (mDragHandle != null) {
- canvas.translate(0, -translate);
- mDragHandle.draw(canvas);
- canvas.translate(0, translate);
- }
+ drawBackground(canvas);
+ drawDragHandle(canvas);
}
- private float drawBackground(Canvas canvas) {
+ private void drawBackground(Canvas canvas) {
if (mDrawingFlatColor) {
if (mCurrentFlatColor != 0) {
canvas.drawColor(mCurrentFlatColor);
}
- return 0;
+ return;
}
- if (mShelfColor == 0) {
- return 0;
- } else if (mScrimMoveFactor <= 0) {
+ if (Color.alpha(mShelfColor) == 0) {
+ return;
+ } else if (mProgress <= 0) {
canvas.drawColor(mShelfColor);
- return getHeight();
+ return;
}
- float minTop = getHeight() - mMinSize;
- float top = minTop * mScrimMoveFactor - mDragHandleSize;
-
+ int height = getHeight();
+ int width = getWidth();
// Draw the scrim over the remaining screen if needed.
if (mRemainingScreenColor != 0) {
if (!mRemainingScreenPathValid) {
mTempPath.reset();
// Using a arbitrary '+10' in the bottom to avoid any left-overs at the
// corners due to rounding issues.
- mTempPath.addRoundRect(0, minTop, getWidth(), getHeight() + mRadius + 10,
+ mTempPath.addRoundRect(0, height - mRadius, width, height + mRadius + 10,
mRadius, mRadius, Direction.CW);
-
mRemainingScreenPath.reset();
- mRemainingScreenPath.addRect(0, 0, getWidth(), getHeight(), Direction.CW);
+ mRemainingScreenPath.addRect(0, 0, width, height, Direction.CW);
mRemainingScreenPath.op(mTempPath, Op.DIFFERENCE);
}
- float offset = minTop - top;
+ float offset = height - mRadius - mShelfTop;
canvas.translate(0, -offset);
mPaint.setColor(mRemainingScreenColor);
canvas.drawPath(mRemainingScreenPath, mPaint);
@@ -204,47 +200,6 @@
}
mPaint.setColor(mShelfColor);
- canvas.drawRoundRect(0, top, getWidth(), getHeight() + mRadius,
- mRadius, mRadius, mPaint);
- return minTop - mDragHandleSize - top;
- }
-
- @NonNull
- @Override
- protected AccessibilityHelper createAccessibilityHelper() {
- return new ShelfScrimAccessibilityHelper();
- }
-
- protected class ShelfScrimAccessibilityHelper extends AccessibilityHelper {
- @Override
- protected void onPopulateNodeForVirtualView(int virtualViewId,
- AccessibilityNodeInfoCompat node) {
- super.onPopulateNodeForVirtualView(virtualViewId, node);
-
- if (mLauncher.isInState(OVERVIEW)) {
- final RecentsView overviewPanel = mLauncher.getOverviewPanel();
- if (overviewPanel.getChildCount() != 0) {
- node.addAction(
- new AccessibilityNodeInfoCompat.AccessibilityActionCompat(
- CLEAR_ALL_TASKS,
- getContext().getText(CLEAR_ALL_TASKS)));
- }
- }
- }
-
- @Override
- protected boolean onPerformActionForVirtualView(
- int virtualViewId, int action, Bundle arguments) {
- if (super.onPerformActionForVirtualView(virtualViewId, action, arguments)) return true;
-
- if (action == CLEAR_ALL_TASKS) {
- if (mLauncher.isInState(OVERVIEW)) {
- mLauncher.<RecentsView>getOverviewPanel().dismissAllTasks();
- }
- return true;
- }
-
- return false;
- }
+ canvas.drawRoundRect(0, mShelfTop, width, height + mRadius, mRadius, mRadius, mPaint);
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
index dd90c88..6eb6854 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
@@ -16,19 +16,20 @@
package com.android.quickstep.views;
+import static com.android.quickstep.views.TaskThumbnailView.DIM_ALPHA;
+
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
-import android.graphics.Outline;
-import android.graphics.Point;
+import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.view.Gravity;
import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewOutlineProvider;
-import android.view.animation.AccelerateDecelerateInterpolator;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.launcher3.AbstractFloatingView;
@@ -37,8 +38,8 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
+import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
-import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.TaskSystemShortcut;
import com.android.quickstep.TaskUtils;
@@ -58,12 +59,14 @@
new TaskSystemShortcut.Install(),
};
- private static final long OPEN_CLOSE_DURATION = 220;
+ private static final int REVEAL_OPEN_DURATION = 150;
+ private static final int REVEAL_CLOSE_DURATION = 100;
private BaseDraggingActivity mActivity;
private TextView mTaskIconAndName;
private AnimatorSet mOpenCloseAnimator;
private TaskView mTaskView;
+ private LinearLayout mOptionLayout;
public TaskMenuView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -73,20 +76,13 @@
super(context, attrs, defStyleAttr);
mActivity = BaseDraggingActivity.fromContext(context);
- setClipToOutline(true);
- setOutlineProvider(new ViewOutlineProvider() {
- @Override
- public void getOutline(View view, Outline outline) {
- float r = getResources().getDimensionPixelSize(R.dimen.task_menu_background_radius);
- outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), r);
- }
- });
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mTaskIconAndName = findViewById(R.id.task_icon_and_name);
+ mOptionLayout = findViewById(R.id.menu_option_layout);
}
@Override
@@ -148,6 +144,12 @@
mTaskIconAndName.setText(TaskUtils.getTitle(getContext(), taskView.getTask()));
mTaskIconAndName.setOnClickListener(v -> close(true));
+ // Move the icon and text up half an icon size to lay over the TaskView
+ LinearLayout.LayoutParams params =
+ (LinearLayout.LayoutParams) mTaskIconAndName.getLayoutParams();
+ params.topMargin = (int) -getResources().getDimension(R.dimen.task_thumbnail_top_margin);
+ mTaskIconAndName.setLayoutParams(params);
+
for (TaskSystemShortcut menuOption : MENU_OPTIONS) {
OnClickListener onClickListener = menuOption.getOnClickListener(mActivity, taskView);
if (onClickListener != null) {
@@ -157,21 +159,25 @@
}
private void addMenuOption(TaskSystemShortcut menuOption, OnClickListener onClickListener) {
- DeepShortcutView menuOptionView = (DeepShortcutView) mActivity.getLayoutInflater().inflate(
- R.layout.system_shortcut, this, false);
- menuOptionView.getIconView().setBackgroundResource(menuOption.iconResId);
- menuOptionView.getBubbleText().setText(menuOption.labelResId);
+ ViewGroup menuOptionView = (ViewGroup) mActivity.getLayoutInflater().inflate(
+ R.layout.task_view_menu_option, this, false);
+ menuOptionView.findViewById(R.id.icon).setBackgroundResource(menuOption.iconResId);
+ ((TextView) menuOptionView.findViewById(R.id.text)).setText(menuOption.labelResId);
menuOptionView.setOnClickListener(onClickListener);
- addView(menuOptionView);
+ mOptionLayout.addView(menuOptionView);
}
private void orientAroundTaskView(TaskView taskView) {
measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
mActivity.getDragLayer().getDescendantRectRelativeToSelf(taskView, sTempRect);
Rect insets = mActivity.getDragLayer().getInsets();
- int x = sTempRect.left + (sTempRect.width() - getMeasuredWidth()) / 2 - insets.left;
- setX(Utilities.isRtl(getResources()) ? -x : x);
- setY(sTempRect.top - mTaskIconAndName.getPaddingTop() - insets.top);
+ BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
+ params.width = sTempRect.width();
+ params.gravity = Gravity.LEFT;
+ setLayoutParams(params);
+ setX(sTempRect.left - insets.left);
+ setY(sTempRect.top + getResources().getDimension(R.dimen.task_thumbnail_top_margin)
+ - insets.top);
}
private void animateOpen() {
@@ -188,8 +194,13 @@
return;
}
mOpenCloseAnimator = LauncherAnimUtils.createAnimatorSet();
- mOpenCloseAnimator.play(createOpenCloseOutlineProvider()
- .createRevealAnimator(this, closing));
+
+ final Animator revealAnimator = createOpenCloseOutlineProvider()
+ .createRevealAnimator(this, closing);
+ revealAnimator.setInterpolator(Interpolators.DEACCEL);
+ mOpenCloseAnimator.play(revealAnimator);
+ mOpenCloseAnimator.play(ObjectAnimator.ofFloat(mTaskView.getThumbnail(), DIM_ALPHA,
+ closing ? 0 : TaskView.MAX_PAGE_SCRIM_ALPHA));
mOpenCloseAnimator.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -204,8 +215,7 @@
}
});
mOpenCloseAnimator.play(ObjectAnimator.ofFloat(this, ALPHA, closing ? 0 : 1));
- mOpenCloseAnimator.setDuration(OPEN_CLOSE_DURATION);
- mOpenCloseAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
+ mOpenCloseAnimator.setDuration(closing ? REVEAL_CLOSE_DURATION: REVEAL_OPEN_DURATION);
mOpenCloseAnimator.start();
}
@@ -215,18 +225,9 @@
}
private RoundedRectRevealOutlineProvider createOpenCloseOutlineProvider() {
- int iconSize = getResources().getDimensionPixelSize(R.dimen.task_thumbnail_icon_size);
- float fromRadius = iconSize / 2;
- float toRadius = getResources().getDimensionPixelSize(
- R.dimen.task_menu_background_radius);
- Point iconCenter = new Point(getWidth() / 2, mTaskIconAndName.getPaddingTop() + iconSize / 2);
- Rect fromRect = new Rect(iconCenter.x, iconCenter.y, iconCenter.x, iconCenter.y);
+ float radius = getResources().getDimension(R.dimen.task_corner_radius);
+ Rect fromRect = new Rect(0, 0, getWidth(), 0);
Rect toRect = new Rect(0, 0, getWidth(), getHeight());
- return new RoundedRectRevealOutlineProvider(fromRadius, toRadius, fromRect, toRect) {
- @Override
- public boolean shouldRemoveElevationDuringAnimation() {
- return true;
- }
- };
+ return new RoundedRectRevealOutlineProvider(radius, radius, fromRect, toRect);
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index 128a19e..07f22aa 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -37,8 +37,10 @@
import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.SystemUiController;
+import com.android.launcher3.util.Themes;
import com.android.quickstep.TaskOverlayFactory;
import com.android.quickstep.TaskOverlayFactory.TaskOverlay;
import com.android.systemui.shared.recents.model.Task;
@@ -50,6 +52,7 @@
public class TaskThumbnailView extends View {
private static final LightingColorFilter[] sDimFilterCache = new LightingColorFilter[256];
+ private static final LightingColorFilter[] sHighlightFilterCache = new LightingColorFilter[256];
public static final Property<TaskThumbnailView, Float> DIM_ALPHA_MULTIPLIER =
new FloatProperty<TaskThumbnailView>("dimAlphaMultiplier") {
@@ -64,10 +67,24 @@
}
};
+ public static final Property<TaskThumbnailView, Float> DIM_ALPHA =
+ new FloatProperty<TaskThumbnailView>("dimAlpha") {
+ @Override
+ public void setValue(TaskThumbnailView thumbnail, float dimAlpha) {
+ thumbnail.setDimAlpha(dimAlpha);
+ }
+
+ @Override
+ public Float get(TaskThumbnailView thumbnailView) {
+ return thumbnailView.mDimAlpha;
+ }
+ };
+
private final float mCornerRadius;
private final BaseActivity mActivity;
private final TaskOverlay mOverlay;
+ private final boolean mIsDarkTextTheme;
private final Paint mPaint = new Paint();
private final Paint mBackgroundPaint = new Paint();
@@ -97,6 +114,7 @@
mPaint.setFilterBitmap(true);
mBackgroundPaint.setColor(Color.WHITE);
mActivity = BaseActivity.fromContext(context);
+ mIsDarkTextTheme = Themes.getAttrBoolean(mActivity, R.attr.isWorkspaceDarkText);
}
public void bind() {
@@ -198,7 +216,7 @@
private void updateThumbnailPaintFilter() {
int mul = (int) ((1 - mDimAlpha * mDimAlphaMultiplier) * 255);
if (mBitmapShader != null) {
- LightingColorFilter filter = getLightingColorFilter(mul);
+ LightingColorFilter filter = getDimmingColorFilter(mul, mIsDarkTextTheme);
mPaint.setColorFilter(filter);
mBackgroundPaint.setColorFilter(filter);
} else {
@@ -287,16 +305,25 @@
updateThumbnailMatrix();
}
- private static LightingColorFilter getLightingColorFilter(int dimColor) {
- if (dimColor < 0) {
- dimColor = 0;
- } else if (dimColor > 255) {
- dimColor = 255;
+ private static LightingColorFilter getDimmingColorFilter(int intensity, boolean shouldLighten) {
+ intensity = Utilities.boundToRange(intensity, 0, 255);
+ if (intensity == 255) {
+ return null;
}
- if (sDimFilterCache[dimColor] == null) {
- sDimFilterCache[dimColor] =
- new LightingColorFilter(Color.argb(255, dimColor, dimColor, dimColor), 0);
+ if (shouldLighten) {
+ if (sHighlightFilterCache[intensity] == null) {
+ int colorAdd = 255 - intensity;
+ sHighlightFilterCache[intensity] = new LightingColorFilter(
+ Color.argb(255, intensity, intensity, intensity),
+ Color.argb(255, colorAdd, colorAdd, colorAdd));
+ }
+ return sHighlightFilterCache[intensity];
+ } else {
+ if (sDimFilterCache[intensity] == null) {
+ sDimFilterCache[intensity] = new LightingColorFilter(
+ Color.argb(255, intensity, intensity, intensity), 0);
+ }
+ return sDimFilterCache[intensity];
}
- return sDimFilterCache[dimColor];
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 5413a13..c4ccd96 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -71,7 +71,7 @@
* The alpha of a black scrim on a page in the carousel as it leaves the screen.
* In the resting position of the carousel, the adjacent pages have about half this scrim.
*/
- private static final float MAX_PAGE_SCRIM_ALPHA = 0.4f;
+ public static final float MAX_PAGE_SCRIM_ALPHA = 0.4f;
/**
* How much to scale down pages near the edge of the screen.
@@ -118,9 +118,10 @@
launchTask(true /* animate */);
BaseActivity.fromContext(context).getUserEventDispatcher().logTaskLaunchOrDismiss(
Touch.TAP, Direction.NONE, getRecentsView().indexOfChild(this),
- TaskUtils.getComponentKeyForTask(getTask().key));
+ TaskUtils.getLaunchComponentKeyForTask(getTask().key));
});
setOutlineProvider(new TaskOutlineProvider(getResources()));
+ setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
}
@Override
@@ -250,12 +251,12 @@
setPivotY(mSnapshotView.getTop() + mSnapshotView.getHeight() * 0.5f);
}
- public float getCurveScaleForInterpolation(float linearInterpolation) {
+ public static float getCurveScaleForInterpolation(float linearInterpolation) {
float curveInterpolation = CURVE_INTERPOLATOR.getInterpolation(linearInterpolation);
return getCurveScaleForCurveInterpolation(curveInterpolation);
}
- private float getCurveScaleForCurveInterpolation(float curveInterpolation) {
+ private static float getCurveScaleForCurveInterpolation(float curveInterpolation) {
return 1 - curveInterpolation * EDGE_SCALE_DOWN_FACTOR;
}
@@ -321,8 +322,6 @@
}
final RecentsView recentsView = getRecentsView();
- recentsView.addTaskAccessibilityActionsExtra(info);
-
final AccessibilityNodeInfo.CollectionItemInfo itemInfo =
AccessibilityNodeInfo.CollectionItemInfo.obtain(
0, 1, recentsView.getChildCount() - recentsView.indexOfChild(this) - 1, 1,
@@ -349,8 +348,6 @@
}
}
- if (getRecentsView().performTaskAccessibilityActionExtra(action)) return true;
-
return super.performAccessibilityAction(action, arguments);
}
diff --git a/res/drawable/ic_info_no_shadow.xml b/res/drawable/ic_info_no_shadow.xml
index b5512c3..d816f12 100644
--- a/res/drawable/ic_info_no_shadow.xml
+++ b/res/drawable/ic_info_no_shadow.xml
@@ -16,12 +16,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/textColorPrimary" >
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/textColorPrimary">
+
<path
- android:fillColor="#FFFFFFFF"
- android:pathData="M12,17L12,17c0.55,0,1-0.45,1-1v-4c0-0.55-0.45-1-1-1l0,0c-0.55,0-1,0.45-1,1v4C11,16.55,11.45,17,12,17z M12,2C6.48,
- 2,2,6.48,2,12s4.48,10,10,10s10-4.48,10-10S17.52,2,12,2z M12,20c-4.41,0-8-3.59-8-8s3.59-8,8-8s8,3.59,8,8S16.41,20,12,20zM12,
- 9.1L12,9.1c0.61,0,1.1-0.49,1.1-1.1l0,0c0-0.61-0.49-1.1-1.1-1.1l0,0c-0.61,0-1.1,0.49-1.1,1.1l0,0C10.9,8.61,11.39,9.1,12,9.1z"/>
+ android:fillColor="#FFFFFF"
+ android:pathData="M 11 7 H 13 V 9 H 11 V 7 Z" />
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M 11 11 H 13 V 17 H 11 V 11 Z" />
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M12,2C6.48,2,2,6.48,2,12c0,5.52,4.48,10,10,10s10-4.48,10-10C22,6.48,17.52,2,12,2z M12,20c-4.41,0-8-3.59-8-8 c0-4.41,3.59-8,8-8s8,3.59,8,8C20,16.41,16.41,20,12,20z" />
</vector>
diff --git a/res/layout/launcher.xml b/res/layout/launcher.xml
index da17b2b..17361ac 100644
--- a/res/layout/launcher.xml
+++ b/res/layout/launcher.xml
@@ -39,7 +39,7 @@
launcher:pageIndicator="@+id/page_indicator" />
<include
- android:id="@+id/overview_panel_container"
+ android:id="@+id/overview_panel"
layout="@layout/overview_panel"
android:visibility="gone" />
diff --git a/res/layout/longpress_options_menu.xml b/res/layout/longpress_options_menu.xml
index 168dbc3..20bb5b8 100644
--- a/res/layout/longpress_options_menu.xml
+++ b/res/layout/longpress_options_menu.xml
@@ -22,4 +22,5 @@
android:clipToPadding="false"
android:clipChildren="false"
android:elevation="@dimen/deep_shortcuts_elevation"
+ android:importantForAccessibility="yes"
android:orientation="vertical" />
diff --git a/res/values-v26/styles.xml b/res/values-v26/styles.xml
index b25f46a..e810ab2 100644
--- a/res/values-v26/styles.xml
+++ b/res/values-v26/styles.xml
@@ -21,7 +21,7 @@
<style name="WidgetContainerTheme" parent="@android:style/Theme.DeviceDefault.Settings">
<item name="android:colorEdgeEffect">?android:attr/textColorSecondary</item>
</style>
- <style name="WidgetContainerTheme.Dark" parent="LauncherThemeDark">
+ <style name="WidgetContainerTheme.Dark" parent="AppTheme.Dark">
<item name="android:colorEdgeEffect">?android:attr/textColorSecondary</item>
<item name="android:colorPrimaryDark">#616161</item> <!-- Gray 700 -->
</style>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 64ca05e..30091a5 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -20,6 +20,7 @@
<!-- Attributes used for launcher theme -->
<attr name="allAppsScrimColor" format="color" />
+ <attr name="allAppsInterimScrimAlpha" format="integer" />
<attr name="allAppsNavBarScrimColor" format="color" />
<attr name="popupColorPrimary" format="color" />
<attr name="popupColorSecondary" format="color" />
diff --git a/res/values/config.xml b/res/values/config.xml
index d5bb131..f2d6c21 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -149,4 +149,5 @@
<integer name="config_recentsMaxThumbnailCacheSize">6</integer>
<integer name="config_recentsMaxIconCacheSize">12</integer>
+ <item name="workspace_page_container" type="id" />
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 2b760f3..07bd800 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -29,6 +29,7 @@
<style name="BaseLauncherThemeWithCustomAttrs" parent="@style/BaseLauncherTheme">
<item name="allAppsScrimColor">#EAFFFFFF</item>
+ <item name="allAppsInterimScrimAlpha">46</item>
<item name="allAppsNavBarScrimColor">#66FFFFFF</item>
<item name="popupColorPrimary">#FFF</item>
<item name="popupColorSecondary">#F5F5F5</item> <!-- Gray 100 -->
@@ -47,6 +48,7 @@
<style name="LauncherTheme.DarkText" parent="@style/LauncherTheme">
<item name="workspaceTextColor">#FF212121</item>
+ <item name="allAppsInterimScrimAlpha">128</item>
<item name="workspaceShadowColor">@android:color/transparent</item>
<item name="workspaceAmbientShadowColor">@android:color/transparent</item>
<item name="workspaceKeyShadowColor">@android:color/transparent</item>
@@ -54,7 +56,7 @@
<item name="workspaceStatusBarScrim">@null</item>
</style>
- <style name="LauncherThemeDark" parent="@style/LauncherTheme">
+ <style name="LauncherTheme.Dark" parent="@style/LauncherTheme">
<item name="android:textColorPrimary">#FFFFFFFF</item>
<item name="android:textColorSecondary">#FFFFFFFF</item>
<item name="android:textColorTertiary">#CCFFFFFF</item>
@@ -62,6 +64,7 @@
<item name="android:colorControlHighlight">#A0FFFFFF</item>
<item name="android:colorPrimary">#FF212121</item>
<item name="allAppsScrimColor">#EA212121</item>
+ <item name="allAppsInterimScrimAlpha">102</item>
<item name="allAppsNavBarScrimColor">#80000000</item>
<item name="popupColorPrimary">?android:attr/colorPrimary</item>
<item name="popupColorSecondary">#424242</item> <!-- Gray 800 -->
@@ -70,7 +73,8 @@
<item name="isMainColorDark">true</item>
</style>
- <style name="LauncherThemeDark.DarKText" parent="@style/LauncherThemeDark">
+ <style name="LauncherTheme.Dark.DarkText" parent="@style/LauncherTheme.Dark">
+ <item name="allAppsInterimScrimAlpha">25</item>
<item name="workspaceTextColor">#FF212121</item>
<item name="workspaceShadowColor">@android:color/transparent</item>
<item name="workspaceAmbientShadowColor">@android:color/transparent</item>
@@ -79,6 +83,13 @@
<item name="workspaceStatusBarScrim">@null</item>
</style>
+ <!-- A derivative project can extend these themes to customize the application theme without
+ affecting the base theme -->
+ <style name="AppTheme" parent="@style/LauncherTheme" />
+ <style name="AppTheme.DarkText" parent="@style/LauncherTheme.DarkText" />
+ <style name="AppTheme.Dark" parent="@style/LauncherTheme.Dark" />
+ <style name="AppTheme.Dark.DarkText" parent="@style/LauncherTheme.Dark.DarkText" />
+
<!--
Theme overrides to element on homescreen, i.e., which are drawn on top on wallpaper.
Various foreground colors are overridden to be workspaceTextColor so that they are properly
@@ -111,6 +122,7 @@
<item name="android:saveEnabled">false</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:includeFontPadding">false</item>
+ <item name="android:importantForAccessibility">no</item>
</style>
<!-- Base theme for BubbleTextView and sub classes -->
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index e117deb..a4b6f5b 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -44,13 +44,25 @@
public static final int INVISIBLE_BY_STATE_HANDLER = 1 << 0;
public static final int INVISIBLE_BY_APP_TRANSITIONS = 1 << 1;
+ public static final int INVISIBLE_BY_PENDING_FLAGS = 1 << 2;
+
+ // This is not treated as invisibility flag, but adds as a hint for an incomplete transition.
+ // When the wallpaper animation runs, it replaces this flag with a proper invisibility
+ // flag, INVISIBLE_BY_PENDING_FLAGS only for the duration of that animation.
+ public static final int PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION = 1 << 3;
+
+ private static final int INVISIBLE_FLAGS =
+ INVISIBLE_BY_STATE_HANDLER | INVISIBLE_BY_APP_TRANSITIONS | INVISIBLE_BY_PENDING_FLAGS;
+ public static final int STATE_HANDLER_INVISIBILITY_FLAGS =
+ INVISIBLE_BY_STATE_HANDLER | PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION;
public static final int INVISIBLE_ALL =
- INVISIBLE_BY_STATE_HANDLER | INVISIBLE_BY_APP_TRANSITIONS;
+ INVISIBLE_FLAGS | PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION;
@Retention(SOURCE)
@IntDef(
flag = true,
- value = {INVISIBLE_BY_STATE_HANDLER, INVISIBLE_BY_APP_TRANSITIONS})
+ value = {INVISIBLE_BY_STATE_HANDLER, INVISIBLE_BY_APP_TRANSITIONS,
+ INVISIBLE_BY_PENDING_FLAGS, PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION})
public @interface InvisibilityFlags{}
private final ArrayList<OnDeviceProfileChangeListener> mDPChangeListeners = new ArrayList<>();
@@ -208,7 +220,7 @@
/**
* Used to set the override visibility state, used only to handle the transition home with the
* recents animation.
- * @see LauncherAppTransitionManagerImpl.getWallpaperOpenRunner()
+ * @see LauncherAppTransitionManagerImpl#getWallpaperOpenRunner()
*/
public void addForceInvisibleFlag(@InvisibilityFlags int flag) {
mForceInvisible |= flag;
@@ -218,12 +230,15 @@
mForceInvisible &= ~flag;
}
-
/**
* @return Wether this activity should be considered invisible regardless of actual visibility.
*/
public boolean isForceInvisible() {
- return mForceInvisible != 0;
+ return hasSomeInvisibleFlag(INVISIBLE_FLAGS);
+ }
+
+ public boolean hasSomeInvisibleFlag(int mask) {
+ return (mForceInvisible & mask) != 0;
}
public interface MultiWindowModeChangedListener {
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index 8af9acc..eec196e 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -61,7 +61,7 @@
private OnStartCallback mOnStartCallback;
- private int mThemeRes = R.style.LauncherTheme;
+ private int mThemeRes = R.style.AppTheme;
private DisplayRotationListener mRotationListener;
@@ -91,10 +91,10 @@
protected int getThemeRes(WallpaperColorInfo wallpaperColorInfo) {
if (wallpaperColorInfo.isDark()) {
return wallpaperColorInfo.supportsDarkText() ?
- R.style.LauncherThemeDark_DarKText : R.style.LauncherThemeDark;
+ R.style.AppTheme_Dark_DarkText : R.style.AppTheme_Dark;
} else {
return wallpaperColorInfo.supportsDarkText() ?
- R.style.LauncherTheme_DarkText : R.style.LauncherTheme;
+ R.style.AppTheme_DarkText : R.style.AppTheme;
}
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 2f47728..20c4a5f 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -102,7 +102,9 @@
public int hotseatBarSizePx;
public final int hotseatBarTopPaddingPx;
public final int hotseatBarBottomPaddingPx;
- public final int hotseatBarSidePaddingPx;
+ // Start is the side next to the nav bar, end is the side next to the workspace
+ public final int hotseatBarSidePaddingStartPx;
+ public final int hotseatBarSidePaddingEndPx;
// All apps
public int allAppsCellHeightPx;
@@ -178,10 +180,14 @@
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
hotseatBarBottomPaddingPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
- hotseatBarSidePaddingPx =
+ hotseatBarSidePaddingEndPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
+ // Add a bit of space between nav bar and hotseat in multi-window vertical bar layout.
+ hotseatBarSidePaddingStartPx = isMultiWindowMode && isVerticalBarLayout()
+ ? edgeMarginPx : 0;
hotseatBarSizePx = isVerticalBarLayout()
- ? Utilities.pxFromDp(inv.iconSize, dm)
+ ? Utilities.pxFromDp(inv.iconSize, dm) + hotseatBarSidePaddingStartPx
+ + hotseatBarSidePaddingEndPx
: res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_size)
+ hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx;
@@ -326,7 +332,8 @@
// Hotseat
if (isVerticalLayout) {
- hotseatBarSizePx = iconSizePx;
+ hotseatBarSizePx = iconSizePx + hotseatBarSidePaddingStartPx
+ + hotseatBarSidePaddingEndPx;
}
hotseatCellHeightPx = iconSizePx;
@@ -425,14 +432,12 @@
if (isVerticalBarLayout()) {
padding.top = 0;
padding.bottom = edgeMarginPx;
- padding.left = hotseatBarSidePaddingPx;
- padding.right = hotseatBarSidePaddingPx;
if (isSeascape()) {
- padding.left += hotseatBarSizePx;
- padding.right += verticalDragHandleSizePx;
+ padding.left = hotseatBarSizePx;
+ padding.right = verticalDragHandleSizePx;
} else {
- padding.left += verticalDragHandleSizePx;
- padding.right += hotseatBarSizePx;
+ padding.left = verticalDragHandleSizePx;
+ padding.right = hotseatBarSizePx;
}
} else {
int paddingBottom = hotseatBarSizePx + verticalDragHandleSizePx;
@@ -462,11 +467,11 @@
public Rect getHotseatLayoutPadding() {
if (isVerticalBarLayout()) {
if (isSeascape()) {
- mHotseatPadding.set(
- mInsets.left, mInsets.top, hotseatBarSidePaddingPx, mInsets.bottom);
+ mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx,
+ mInsets.top, hotseatBarSidePaddingEndPx, mInsets.bottom);
} else {
- mHotseatPadding.set(
- hotseatBarSidePaddingPx, mInsets.top, mInsets.right, mInsets.bottom);
+ mHotseatPadding.set(hotseatBarSidePaddingEndPx, mInsets.top,
+ mInsets.right + hotseatBarSidePaddingStartPx, mInsets.bottom);
}
} else {
diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java
index 403c8b8..4e0f2e7 100644
--- a/src/com/android/launcher3/ExtendedEditText.java
+++ b/src/com/android/launcher3/ExtendedEditText.java
@@ -99,6 +99,10 @@
mShowImeAfterFirstLayout = !showSoftInput();
}
+ public void hideKeyboard() {
+ UiThreadHelper.hideKeyboardAsync(getContext(), getWindowToken());
+ }
+
private boolean showSoftInput() {
return requestFocus() &&
((InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
@@ -106,7 +110,7 @@
}
public void dispatchBackKey() {
- UiThreadHelper.hideKeyboardAsync(getContext(), getWindowToken());
+ hideKeyboard();
if (mBackKeyListener != null) {
mBackKeyListener.onBackKey();
}
@@ -135,6 +139,6 @@
nextFocus.requestFocus();
}
}
- UiThreadHelper.hideKeyboardAsync(getContext(), getWindowToken());
+ hideKeyboard();
}
}
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java
index 1b91e88..9217ca9 100644
--- a/src/com/android/launcher3/FastBitmapDrawable.java
+++ b/src/com/android/launcher3/FastBitmapDrawable.java
@@ -261,7 +261,7 @@
/**
* Updates the paint to reflect the current brightness and saturation.
*/
- private void updateFilter() {
+ protected void updateFilter() {
boolean usePorterDuffFilter = false;
int key = -1;
if (mDesaturation > 0) {
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index ee4b113..6668f2c 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -157,10 +157,10 @@
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
if (grid.isSeascape()) {
lp.gravity = Gravity.LEFT;
- lp.width = grid.hotseatBarSizePx + insets.left + grid.hotseatBarSidePaddingPx;
+ lp.width = grid.hotseatBarSizePx + insets.left;
} else {
lp.gravity = Gravity.RIGHT;
- lp.width = grid.hotseatBarSizePx + insets.right + grid.hotseatBarSidePaddingPx;
+ lp.width = grid.hotseatBarSizePx + insets.right;
}
} else {
lp.gravity = Gravity.BOTTOM;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 3eaead1..3a8679e 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -214,8 +214,6 @@
// UI and state for the overview panel
private View mOverviewPanel;
- private View mOverviewPanelContainer;
-
@Thunk boolean mWorkspaceLoading = true;
private OnResumeCallback mOnResumeCallback;
@@ -913,7 +911,6 @@
mWorkspace = mDragLayer.findViewById(R.id.workspace);
mWorkspace.initParentViews(mDragLayer);
mOverviewPanel = findViewById(R.id.overview_panel);
- mOverviewPanelContainer = findViewById(R.id.overview_panel_container);
mHotseat = findViewById(R.id.hotseat);
mHotseatSearchBox = findViewById(R.id.search_container_hotseat);
@@ -1174,10 +1171,6 @@
return (T) mOverviewPanel;
}
- public <T extends View> T getOverviewPanelContainer() {
- return (T) mOverviewPanelContainer;
- }
-
public DropTargetBar getDropTargetBar() {
return mDropTargetBar;
}
@@ -2335,6 +2328,8 @@
if (isInState(NORMAL)) {
shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.all_apps_button_label),
KeyEvent.KEYCODE_A, KeyEvent.META_CTRL_ON));
+ shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.widget_button_text),
+ KeyEvent.KEYCODE_W, KeyEvent.META_CTRL_ON));
}
final View currentFocus = getCurrentFocus();
if (currentFocus != null) {
@@ -2383,6 +2378,12 @@
return true;
}
break;
+ case KeyEvent.KEYCODE_W:
+ if (isInState(NORMAL)) {
+ OptionsPopupView.openWidgets(this);
+ return true;
+ }
+ break;
}
}
return super.onKeyShortcut(keyCode, event);
diff --git a/src/com/android/launcher3/LauncherScroller.java b/src/com/android/launcher3/LauncherScroller.java
index a9b4955..af87550 100644
--- a/src/com/android/launcher3/LauncherScroller.java
+++ b/src/com/android/launcher3/LauncherScroller.java
@@ -459,13 +459,13 @@
return Math.log(INFLEXION * Math.abs(velocity) / (mFlingFriction * mPhysicalCoeff));
}
- private int getSplineFlingDuration(float velocity) {
+ public int getSplineFlingDuration(float velocity) {
final double l = getSplineDeceleration(velocity);
final double decelMinusOne = DECELERATION_RATE - 1.0;
return (int) (1000.0 * Math.exp(l / decelMinusOne));
}
- private double getSplineFlingDistance(float velocity) {
+ public double getSplineFlingDistance(float velocity) {
final double l = getSplineDeceleration(velocity);
final double decelMinusOne = DECELERATION_RATE - 1.0;
return mFlingFriction * mPhysicalCoeff * Math.exp(DECELERATION_RATE / decelMinusOne * l);
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 5b010dc..8a15b24 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -242,8 +242,10 @@
* Called when the start transition ends and the user settles on this particular state.
*/
public void onStateTransitionEnd(Launcher launcher) {
- if (this == NORMAL) {
+ if (this == NORMAL || this == SPRING_LOADED) {
UiFactory.resetOverview(launcher);
+ }
+ if (this == NORMAL) {
// Clear any rotation locks when going to normal state
launcher.getRotationHelper().setCurrentStateRequest(REQUEST_NONE);
}
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index b5eef8b..8b415d6 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -17,7 +17,6 @@
package com.android.launcher3;
import static android.view.View.VISIBLE;
-
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
@@ -222,7 +221,8 @@
}
}
- // Cancel the current animation
+ // Cancel the current animation. This will reset mState to mCurrentStableState, so store it.
+ LauncherState fromState = mState;
mConfig.reset();
if (!animated) {
@@ -245,10 +245,10 @@
// Since state NORMAL can be reached from multiple states, just assume that the
// transition plays in reverse and use the same duration as previous state.
- mConfig.duration = state == NORMAL ? mState.transitionDuration : state.transitionDuration;
+ mConfig.duration = state == NORMAL ? fromState.transitionDuration : state.transitionDuration;
AnimatorSetBuilder builder = new AnimatorSetBuilder();
- prepareForAtomicAnimation(mState, state, builder);
+ prepareForAtomicAnimation(fromState, state, builder);
AnimatorSet animation = createAnimationToNewWorkspaceInternal(
state, builder, onCompleteRunnable);
Runnable runnable = new StartAnimRunnable(animation);
@@ -298,6 +298,24 @@
/**
* Creates a {@link AnimatorPlaybackController} that can be used for a controlled
+ * state transition. The UI is force-set to fromState before creating the controller.
+ * @param fromState the initial state for the transition.
+ * @param state the final state for the transition.
+ * @param duration intended duration for normal playback. Use higher duration for better
+ * accuracy.
+ */
+ public AnimatorPlaybackController createAnimationToNewWorkspace(
+ LauncherState fromState, LauncherState state, long duration) {
+ mConfig.reset();
+ for (StateHandler handler : getStateHandlers()) {
+ handler.setState(fromState);
+ }
+
+ return createAnimationToNewWorkspace(state, duration);
+ }
+
+ /**
+ * Creates a {@link AnimatorPlaybackController} that can be used for a controlled
* state transition.
* @param state the final state for the transition.
* @param duration intended duration for normal playback. Use higher duration for better
@@ -533,6 +551,9 @@
@Override
public void onAnimationEnd(Animator animation) {
+ if (playbackController != null && playbackController.getTarget() == animation) {
+ playbackController = null;
+ }
if (mCurrentAnimation == animation) {
mCurrentAnimation = null;
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 62b581f..0cb6539 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -24,7 +24,6 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
-import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Bundle;
import android.provider.Settings;
@@ -64,7 +63,6 @@
protected static final ComputePageScrollsLogic SIMPLE_SCROLL_LOGIC = (v) -> v.getVisibility() != GONE;
public static final int PAGE_SNAP_ANIMATION_DURATION = 750;
- public static final int SLOW_PAGE_SNAP_ANIMATION_DURATION = 950;
// OverScroll constants
private final static int OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION = 270;
@@ -84,7 +82,6 @@
public static final int INVALID_RESTORE_PAGE = -1001;
private boolean mFreeScroll = false;
- private boolean mSettleOnPageInFreeScroll = false;
protected int mFlingThresholdVelocity;
protected int mMinFlingVelocity;
@@ -142,8 +139,6 @@
protected T mPageIndicator;
// Convenience/caching
- private static final Matrix sTmpInvMatrix = new Matrix();
- private static final float[] sTmpPoint = new float[2];
private static final Rect sTmpRect = new Rect();
protected final Rect mInsets = new Rect();
@@ -242,12 +237,6 @@
return index;
}
- protected void scrollAndForceFinish(int scrollX) {
- scrollTo(scrollX, 0);
- mScroller.setFinalX(scrollX);
- forceFinishScroller(true);
- }
-
/**
* Updates the scroll of the current page immediately to its final scroll position. We use this
* in CustomizePagedView to allow tabs to share the same PagedView while resetting the scroll of
@@ -259,7 +248,9 @@
if (0 <= mCurrentPage && mCurrentPage < getPageCount()) {
newX = getScrollForPage(mCurrentPage);
}
- scrollAndForceFinish(newX);
+ scrollTo(newX, 0);
+ mScroller.setFinalX(newX);
+ forceFinishScroller(true);
}
private void abortScrollerAnimation(boolean resetNextPage) {
@@ -363,17 +354,6 @@
@Override
public void scrollTo(int x, int y) {
- // In free scroll mode, we clamp the scrollX
- if (mFreeScroll) {
- // If the scroller is trying to move to a location beyond the maximum allowed
- // in the free scroll mode, we make sure to end the scroll operation.
- if (!mScroller.isFinished() && (x > mMaxScrollX || x < 0)) {
- forceFinishScroller(false);
- }
-
- x = Utilities.boundToRange(x, 0, mMaxScrollX);
- }
-
mUnboundedScrollX = x;
boolean isXBeforeFirstPage = mIsRtl ? (x > mMaxScrollX) : (x < 0);
@@ -544,10 +524,6 @@
setMeasuredDimension(widthSize, heightSize);
}
- protected void restoreScrollOnLayout() {
- setCurrentPage(getNextPage());
- }
-
@SuppressLint("DrawAllocation")
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
@@ -599,7 +575,7 @@
}
if (mScroller.isFinished() && pageScrollChanged) {
- restoreScrollOnLayout();
+ setCurrentPage(getNextPage());
}
}
@@ -620,23 +596,26 @@
- mInsets.bottom - getPaddingBottom()) / 2;
final int scrollOffsetLeft = mInsets.left + getPaddingLeft();
+ final int scrollOffsetRight = getWidth() - getPaddingRight() - mInsets.right;
boolean pageScrollChanged = false;
- for (int i = startIndex, childLeft = scrollOffsetLeft + offsetForPageScrolls();
- i != endIndex;
- i += delta) {
+ for (int i = startIndex, childLeft = scrollOffsetLeft; i != endIndex; i += delta) {
final View child = getPageAt(i);
if (scrollLogic.shouldIncludeView(child)) {
- final int childTop = verticalCenter - child.getMeasuredHeight() / 2;
final int childWidth = child.getMeasuredWidth();
+ final int childRight = childLeft + childWidth;
if (layoutChildren) {
final int childHeight = child.getMeasuredHeight();
- child.layout(childLeft, childTop,
- childLeft + child.getMeasuredWidth(), childTop + childHeight);
+ final int childTop = verticalCenter - childHeight / 2;
+ child.layout(childLeft, childTop, childRight, childTop + childHeight);
}
- final int pageScroll = childLeft - scrollOffsetLeft;
+ // In case the pages are of different width, align the page to left or right edge
+ // based on the orientation.
+ final int pageScroll = mIsRtl
+ ? (childLeft - scrollOffsetLeft)
+ : Math.max(0, childRight - scrollOffsetRight);
if (outPageScrolls[i] != pageScroll) {
pageScrollChanged = true;
outPageScrolls[i] = pageScroll;
@@ -666,10 +645,6 @@
}
}
- protected int offsetForPageScrolls() {
- return 0;
- }
-
public void setPageSpacing(int pageSpacing) {
mPageSpacing = pageSpacing;
requestLayout();
@@ -747,11 +722,13 @@
if (direction == View.FOCUS_LEFT) {
if (getCurrentPage() > 0) {
snapToPage(getCurrentPage() - 1);
+ getChildAt(getCurrentPage() - 1).requestFocus(direction);
return true;
}
} else if (direction == View.FOCUS_RIGHT) {
if (getCurrentPage() < getPageCount() - 1) {
snapToPage(getCurrentPage() + 1);
+ getChildAt(getCurrentPage() + 1).requestFocus(direction);
return true;
}
}
@@ -1036,13 +1013,7 @@
dampedOverScroll(amount);
}
-
- protected void enableFreeScroll(boolean settleOnPageInFreeScroll) {
- setEnableFreeScroll(true);
- mSettleOnPageInFreeScroll = settleOnPageInFreeScroll;
- }
-
- private void setEnableFreeScroll(boolean freeScroll) {
+ protected void setEnableFreeScroll(boolean freeScroll) {
boolean wasFreeScroll = mFreeScroll;
mFreeScroll = freeScroll;
@@ -1051,8 +1022,6 @@
} else if (wasFreeScroll) {
snapToPage(getNextPage());
}
-
- setEnableOverscroll(!freeScroll);
}
protected void setEnableOverscroll(boolean enable) {
@@ -1165,42 +1134,15 @@
snapToDestination();
}
} else {
- if (!mScroller.isFinished()) {
- abortScrollerAnimation(true);
+ int unscaledScrollX = getScrollX() - (int) Math.round(
+ mScroller.getSplineFlingDistance(velocityX) * Math.signum(velocityX));
+ int duration = mScroller.getSplineFlingDuration(velocityX);
+ int finalPage = getPageNearestToCenterOfScreen(unscaledScrollX);
+ if ((isFling || isSignificantMove) && (finalPage != mCurrentPage)) {
+ snapToPage(finalPage, duration);
+ } else {
+ snapToDestination();
}
-
- float scaleX = getScaleX();
- int vX = (int) (-velocityX * scaleX);
- int initialScrollX = (int) (getScrollX() * scaleX);
-
- mScroller.setInterpolator(mDefaultInterpolator);
- mScroller.fling(initialScrollX,
- getScrollY(), vX, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0);
- int unscaledScrollX = (int) (mScroller.getFinalX() / scaleX);
- mNextPage = getPageNearestToCenterOfScreen(unscaledScrollX);
- int firstPageScroll = getScrollForPage(!mIsRtl ? 0 : getPageCount() - 1);
- int lastPageScroll = getScrollForPage(!mIsRtl ? getPageCount() - 1 : 0);
- if (mSettleOnPageInFreeScroll && unscaledScrollX > 0
- && unscaledScrollX < mMaxScrollX) {
- // If scrolling ends in the half of the added space that is closer to the
- // end, settle to the end. Otherwise snap to the nearest page.
- // If flinging past one of the ends, don't change the velocity as it will
- // get stopped at the end anyway.
- final int finalX = unscaledScrollX < firstPageScroll / 2 ?
- 0 :
- unscaledScrollX > (lastPageScroll + mMaxScrollX) / 2 ?
- mMaxScrollX :
- getScrollForPage(mNextPage);
-
- mScroller.setFinalX((int) (finalX * getScaleX()));
- // Ensure the scroll/snap doesn't happen too fast;
- int extraScrollDuration = OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION
- - mScroller.getDuration();
- if (extraScrollDuration > 0) {
- mScroller.extendDuration(extraScrollDuration);
- }
- }
- invalidate();
}
onScrollInteractionEnd();
} else if (mTouchState == TOUCH_STATE_PREV_PAGE) {
@@ -1450,6 +1392,10 @@
protected boolean snapToPage(int whichPage, int delta, int duration, boolean immediate,
TimeInterpolator interpolator) {
+ if (mFirstLayout) {
+ setCurrentPage(whichPage);
+ return false;
+ }
if (FeatureFlags.IS_DOGFOOD_BUILD) {
duration *= Settings.System.getFloat(getContext().getContentResolver(),
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 4bd9a9b..7fe8d35 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -48,6 +48,7 @@
import android.util.Pair;
import android.util.TypedValue;
import android.view.View;
+import android.view.animation.Interpolator;
import com.android.launcher3.config.FeatureFlags;
@@ -272,6 +273,25 @@
return scale;
}
+ /**
+ * Maps t from one range to another range.
+ * @param t The value to map.
+ * @param fromMin The lower bound of the range that t is being mapped from.
+ * @param fromMax The upper bound of the range that t is being mapped from.
+ * @param toMin The lower bound of the range that t is being mapped to.
+ * @param toMax The upper bound of the range that t is being mapped to.
+ * @return The mapped value of t.
+ */
+ public static float mapToRange(float t, float fromMin, float fromMax, float toMin, float toMax,
+ Interpolator interpolator) {
+ if (fromMin == fromMax || toMin == toMax) {
+ Log.e(TAG, "mapToRange: range has 0 length");
+ return toMin;
+ }
+ float progress = Math.abs(t - fromMin) / Math.abs(fromMax - fromMin);
+ return mapRange(interpolator.getInterpolation(progress), toMin, toMax);
+ }
+
public static float mapRange(float value, float min, float max) {
return min + (value * (max - min));
}
@@ -463,6 +483,13 @@
}
/**
+ * @see #boundToRange(int, int, int).
+ */
+ public static long boundToRange(long value, long lowerBound, long upperBound) {
+ return Math.max(lowerBound, Math.min(value, upperBound));
+ }
+
+ /**
* Wraps a message with a TTS span, so that a different message is spoken than
* what is getting displayed.
* @param msg original message
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 66fb3c6..3188e6e 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -547,6 +547,7 @@
// created CellLayout.
CellLayout newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
R.layout.workspace_screen, this, false /* attachToRoot */);
+ newScreen.getShortcutsAndWidgets().setId(R.id.workspace_page_container);
int paddingLeftRight = mLauncher.getDeviceProfile().cellLayoutPaddingLeftRightPx;
int paddingBottom = mLauncher.getDeviceProfile().cellLayoutBottomPaddingPx;
newScreen.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 72ba418..8993978 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -490,6 +490,12 @@
});
}
+ @Override
+ public void getDrawingRect(Rect outRect) {
+ super.getDrawingRect(outRect);
+ outRect.offset(0, (int) getTranslationY());
+ }
+
public class AdapterHolder {
public static final int MAIN = 0;
public static final int WORK = 1;
diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
index e83904f..dcc4554 100644
--- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
+++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
@@ -21,6 +21,8 @@
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
+import android.view.View;
+import android.view.View.OnFocusChangeListener;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
@@ -37,7 +39,8 @@
* An interface to a search box that AllApps can command.
*/
public class AllAppsSearchBarController
- implements TextWatcher, OnEditorActionListener, ExtendedEditText.OnBackKeyListener {
+ implements TextWatcher, OnEditorActionListener, ExtendedEditText.OnBackKeyListener,
+ OnFocusChangeListener {
protected Launcher mLauncher;
protected Callbacks mCb;
@@ -62,6 +65,7 @@
mInput.addTextChangedListener(this);
mInput.setOnEditorActionListener(this);
mInput.setOnBackKeyListener(this);
+ mInput.setOnFocusChangeListener(this);
mSearchAlgorithm = searchAlgorithm;
}
@@ -123,6 +127,13 @@
return false;
}
+ @Override
+ public void onFocusChange(View view, boolean hasFocus) {
+ if (!hasFocus) {
+ mInput.hideKeyboard();
+ }
+ }
+
/**
* Resets the search bar state.
*/
diff --git a/src/com/android/launcher3/anim/AnimatorPlaybackController.java b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
index 84085cb..164728a 100644
--- a/src/com/android/launcher3/anim/AnimatorPlaybackController.java
+++ b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.anim;
+import static com.android.launcher3.anim.Interpolators.LINEAR;
+
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
@@ -72,7 +74,7 @@
mOnCancelRunnable = onCancelRunnable;
mAnimationPlayer = ValueAnimator.ofFloat(0, 1);
- mAnimationPlayer.setInterpolator(Interpolators.LINEAR);
+ mAnimationPlayer.setInterpolator(LINEAR);
mAnimationPlayer.addListener(new OnAnimationEndDispatcher());
mAnimationPlayer.addUpdateListener(this);
@@ -107,6 +109,10 @@
return mDuration;
}
+ public TimeInterpolator getInterpolator() {
+ return mAnim.getInterpolator() != null ? mAnim.getInterpolator() : LINEAR;
+ }
+
/**
* Starts playing the animation forward from current position.
*/
@@ -202,6 +208,19 @@
}
}
+ public void dispatchSetInterpolator(TimeInterpolator interpolator) {
+ dispatchSetInterpolatorRecursively(mAnim, interpolator);
+ }
+
+ private void dispatchSetInterpolatorRecursively(Animator anim, TimeInterpolator interpolator) {
+ anim.setInterpolator(interpolator);
+ if (anim instanceof AnimatorSet) {
+ for (Animator child : nonNullList(((AnimatorSet) anim).getChildAnimations())) {
+ dispatchSetInterpolatorRecursively(child, interpolator);
+ }
+ }
+ }
+
public void setOnCancelRunnable(Runnable runnable) {
mOnCancelRunnable = runnable;
}
diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java
index bace7df..a4cba4f 100644
--- a/src/com/android/launcher3/anim/Interpolators.java
+++ b/src/com/android/launcher3/anim/Interpolators.java
@@ -24,6 +24,8 @@
import android.view.animation.OvershootInterpolator;
import android.view.animation.PathInterpolator;
+import com.android.launcher3.Utilities;
+
/**
* Common interpolators used in Launcher
@@ -116,6 +118,19 @@
return Math.abs(velocity) > FAST_FLING_PX_MS ? SCROLL : SCROLL_CUBIC;
}
+ public static Interpolator overshootInterpolatorForVelocity(float velocity) {
+ return overshootInterpolatorForVelocity(velocity, 1f);
+ }
+
+ /**
+ * Create an OvershootInterpolator with tension directly related to the velocity (in px/ms).
+ * @param velocity The start velocity of the animation we want to overshoot.
+ * @param dampFactor An optional factor to reduce the amount of tension (how far we overshoot).
+ */
+ public static Interpolator overshootInterpolatorForVelocity(float velocity, float dampFactor) {
+ return new OvershootInterpolator(Math.min(Math.abs(velocity), 3f) / dampFactor);
+ }
+
/**
* Runs the given interpolator such that the entire progress is set between the given bounds.
* That is, we set the interpolation to 0 until lowerBound and reach 1 by upperBound.
@@ -135,4 +150,14 @@
return interpolator.getInterpolation((t - lowerBound) / (upperBound - lowerBound));
};
}
+
+ /**
+ * Runs the given interpolator such that the interpolated value is mapped to the given range.
+ * This is useful, for example, if we only use this interpolator for part of the animation,
+ * such as to take over a user-controlled animation when they let go.
+ */
+ public static Interpolator mapToProgress(Interpolator interpolator, float lowerBound,
+ float upperBound) {
+ return t -> Utilities.mapRange(interpolator.getInterpolation(t), lowerBound, upperBound);
+ }
}
\ No newline at end of file
diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java
index f020d2d..89ba72a 100644
--- a/src/com/android/launcher3/graphics/LauncherIcons.java
+++ b/src/com/android/launcher3/graphics/LauncherIcons.java
@@ -330,9 +330,9 @@
mOldBounds.set(icon.getBounds());
if (Utilities.ATLEAST_OREO && icon instanceof AdaptiveIconDrawable) {
- int offset = Math.max((int)(BLUR_FACTOR * textureWidth), Math.min(left, top));
+ int offset = Math.max((int) Math.ceil(BLUR_FACTOR * textureWidth), Math.max(left, top));
int size = Math.max(width, height);
- icon.setBounds(offset, offset, size, size);
+ icon.setBounds(offset, offset, offset + size, offset + size);
} else {
icon.setBounds(left, top, left+width, top+height);
}
diff --git a/src/com/android/launcher3/graphics/PreloadIconDrawable.java b/src/com/android/launcher3/graphics/PreloadIconDrawable.java
index 42ba191..d3a7955 100644
--- a/src/com/android/launcher3/graphics/PreloadIconDrawable.java
+++ b/src/com/android/launcher3/graphics/PreloadIconDrawable.java
@@ -77,7 +77,7 @@
private final Matrix mTmpMatrix = new Matrix();
private final PathMeasure mPathMeasure = new PathMeasure();
- private final Context mContext;
+ private final ItemInfoWithIcon mItem;
// Path in [0, 100] bounds.
private final Path mProgressPath;
@@ -106,7 +106,7 @@
*/
public PreloadIconDrawable(ItemInfoWithIcon info, Path progressPath, Context context) {
super(info);
- mContext = context;
+ mItem = info;
mProgressPath = progressPath;
mScaledTrackPath = new Path();
mScaledProgressPath = new Path();
@@ -274,7 +274,7 @@
mTrackAlpha = MAX_PAINT_ALPHA;
setIsDisabled(true);
} else if (progress >= 1) {
- setIsDisabled(false);
+ setIsDisabled(mItem.isDisabled());
mScaledTrackPath.set(mScaledProgressPath);
float fraction = (progress - 1) / COMPLETE_ANIM_FRACTION;
diff --git a/src/com/android/launcher3/model/PackageUpdatedTask.java b/src/com/android/launcher3/model/PackageUpdatedTask.java
index 089303e..977dcd7 100644
--- a/src/com/android/launcher3/model/PackageUpdatedTask.java
+++ b/src/com/android/launcher3/model/PackageUpdatedTask.java
@@ -18,7 +18,6 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.graphics.Bitmap;
import android.os.Process;
import android.os.UserHandle;
import android.util.ArrayMap;
@@ -42,6 +41,9 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.BitmapInfo;
import com.android.launcher3.graphics.LauncherIcons;
+import com.android.launcher3.logging.FileLog;
+import com.android.launcher3.shortcuts.DeepShortcutManager;
+import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LongArrayMap;
@@ -52,6 +54,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
/**
* Handles updates due to changes in package manager (app installed/updated/removed)
@@ -162,12 +165,7 @@
final ArrayMap<ComponentName, AppInfo> addedOrUpdatedApps = new ArrayMap<>();
if (!addedOrModified.isEmpty()) {
- scheduleCallbackTask(new CallbackTask() {
- @Override
- public void execute(Callbacks callbacks) {
- callbacks.bindAppsAddedOrUpdated(addedOrModified);
- }
- });
+ scheduleCallbackTask((callbacks) -> callbacks.bindAppsAddedOrUpdated(addedOrModified));
for (AppInfo ai : addedOrModified) {
addedOrUpdatedApps.put(ai.componentName, ai);
}
@@ -213,11 +211,26 @@
}
if (si.isPromise() && isNewApkAvailable) {
+ boolean isTargetValid = true;
+ if (si.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
+ List<ShortcutInfoCompat> shortcut = DeepShortcutManager
+ .getInstance(context).queryForPinnedShortcuts(
+ cn.getPackageName(),
+ Arrays.asList(si.getDeepShortcutId()), mUser);
+ if (shortcut.isEmpty()) {
+ isTargetValid = false;
+ } else {
+ si.updateFromDeepShortcutInfo(shortcut.get(0), context);
+ infoUpdated = true;
+ }
+ } else if (!cn.getClassName().equals(IconCache.EMPTY_CLASS_NAME)) {
+ isTargetValid = LauncherAppsCompat.getInstance(context)
+ .isActivityEnabledForProfile(cn, mUser);
+ }
+
if (si.hasStatusFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)) {
// Auto install icon
- LauncherAppsCompat launcherApps
- = LauncherAppsCompat.getInstance(context);
- if (!launcherApps.isActivityEnabledForProfile(cn, mUser)) {
+ if (!isTargetValid) {
// Try to find the best match activity.
Intent intent = new PackageManagerHelper(context)
.getAppLaunchIntent(cn.getPackageName(), mUser);
@@ -235,6 +248,11 @@
continue;
}
}
+ } else if (!isTargetValid) {
+ removedShortcuts.put(si.id, true);
+ FileLog.e(TAG, "Restored shortcut no longer valid "
+ + si.intent);
+ continue;
} else {
si.status = ShortcutInfo.DEFAULT;
infoUpdated = true;
diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java
index 9098777..be666a6 100644
--- a/src/com/android/launcher3/popup/ArrowPopup.java
+++ b/src/com/android/launcher3/popup/ArrowPopup.java
@@ -266,11 +266,7 @@
}
// Insets are added later, so subtract them now.
- if (mIsRtl) {
- x += insets.right;
- } else {
- x -= insets.left;
- }
+ x -= insets.left;
y -= insets.top;
mGravity = 0;
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index f276fbf..172cf41 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -527,6 +527,7 @@
protected void closeComplete() {
super.closeComplete();
mOriginalIcon.setTextVisibility(mOriginalIcon.shouldTextBeVisible());
+ mOriginalIcon.forceHideBadge(false);
}
@Override
diff --git a/src/com/android/launcher3/provider/ImportDataTask.java b/src/com/android/launcher3/provider/ImportDataTask.java
index b83d3c0..b1dd003 100644
--- a/src/com/android/launcher3/provider/ImportDataTask.java
+++ b/src/com/android/launcher3/provider/ImportDataTask.java
@@ -142,6 +142,8 @@
// First row of first screen is not empty
createEmptyRowOnFirstScreen = c.moveToNext();
}
+ } else {
+ createEmptyRowOnFirstScreen = false;
}
ArrayList<ContentProviderOperation> insertOperations = new ArrayList<>(BATCH_INSERT_SIZE);
diff --git a/src/com/android/launcher3/qsb/QsbContainerView.java b/src/com/android/launcher3/qsb/QsbContainerView.java
index 65acaa9..b26d39f 100644
--- a/src/com/android/launcher3/qsb/QsbContainerView.java
+++ b/src/com/android/launcher3/qsb/QsbContainerView.java
@@ -36,7 +36,6 @@
import com.android.launcher3.AppWidgetResizeFrame;
import com.android.launcher3.InvariantDeviceProfile;
-import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -68,6 +67,10 @@
super.setPadding(0, 0, 0, 0);
}
+ protected void setPaddingUnchecked(int left, int top, int right, int bottom) {
+ super.setPadding(left, top, right, bottom);
+ }
+
/**
* A fragment to display the QSB.
*/
@@ -100,7 +103,7 @@
mWrapper = new FrameLayout(getActivity());
// Only add the view when enabled
- if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
+ if (isQsbEnabled()) {
mWrapper.addView(createQsb(mWrapper));
}
return mWrapper;
@@ -212,7 +215,7 @@
private void rebindFragment() {
// Exit if the embedded qsb is disabled
- if (!FeatureFlags.QSB_ON_FIRST_SCREEN) {
+ if (!isQsbEnabled()) {
return;
}
@@ -221,6 +224,10 @@
mWrapper.addView(createQsb(mWrapper));
}
}
+
+ public boolean isQsbEnabled() {
+ return FeatureFlags.QSB_ON_FIRST_SCREEN;
+ }
}
/**
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
index f44f5c8..24e2e2f 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
@@ -181,7 +181,12 @@
* If packageName is null, returns all pinned shortcuts regardless of package.
*/
public List<ShortcutInfoCompat> queryForPinnedShortcuts(String packageName, UserHandle user) {
- return query(ShortcutQuery.FLAG_MATCH_PINNED, packageName, null, null, user);
+ return queryForPinnedShortcuts(packageName, null, user);
+ }
+
+ public List<ShortcutInfoCompat> queryForPinnedShortcuts(String packageName,
+ List<String> shortcutIds, UserHandle user) {
+ return query(ShortcutQuery.FLAG_MATCH_PINNED, packageName, null, shortcutIds, user);
}
public List<ShortcutInfoCompat> queryForAllShortcuts(UserHandle user) {
diff --git a/src/com/android/launcher3/states/InternalStateHandler.java b/src/com/android/launcher3/states/InternalStateHandler.java
index cf7c6ba..c6370c5 100644
--- a/src/com/android/launcher3/states/InternalStateHandler.java
+++ b/src/com/android/launcher3/states/InternalStateHandler.java
@@ -96,10 +96,12 @@
private WeakReference<InternalStateHandler> mPendingHandler = new WeakReference<>(null);
private MainThreadExecutor mMainThreadExecutor;
- public synchronized void schedule(InternalStateHandler handler) {
- mPendingHandler = new WeakReference<>(handler);
- if (mMainThreadExecutor == null) {
- mMainThreadExecutor = new MainThreadExecutor();
+ public void schedule(InternalStateHandler handler) {
+ synchronized (this) {
+ mPendingHandler = new WeakReference<>(handler);
+ if (mMainThreadExecutor == null) {
+ mMainThreadExecutor = new MainThreadExecutor();
+ }
}
mMainThreadExecutor.execute(this);
}
@@ -118,23 +120,25 @@
initIfPending(launcher, launcher.isStarted());
}
- public synchronized boolean initIfPending(Launcher launcher, boolean alreadyOnHome) {
+ public boolean initIfPending(Launcher launcher, boolean alreadyOnHome) {
InternalStateHandler pendingHandler = mPendingHandler.get();
if (pendingHandler != null) {
if (!pendingHandler.init(launcher, alreadyOnHome)) {
- mPendingHandler.clear();
+ clearReference(pendingHandler);
}
return true;
}
return false;
}
- public synchronized boolean clearReference(InternalStateHandler handler) {
- if (mPendingHandler.get() == handler) {
- mPendingHandler.clear();
- return true;
+ public boolean clearReference(InternalStateHandler handler) {
+ synchronized (this) {
+ if (mPendingHandler.get() == handler) {
+ mPendingHandler.clear();
+ return true;
+ }
+ return false;
}
- return false;
}
public boolean hasPending() {
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index 453810c..955177a 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -29,6 +29,7 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
+import android.os.SystemClock;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
@@ -86,6 +87,10 @@
private FlingBlockCheck mFlingBlockCheck = new FlingBlockCheck();
private AnimatorSet mAtomicAnim;
+ // True if we want to resume playing atomic components when mAtomicAnim completes.
+ private boolean mScheduleResumeAtomicComponent;
+ private AutoPlayAtomicAnimationInfo mAtomicAnimAutoPlayInfo;
+
private boolean mPassedOverviewAtomicThreshold;
// mAtomicAnim plays the atomic components of the state animations when we pass the threshold.
// However, if we reinit to transition to a new state (e.g. OVERVIEW -> ALL_APPS) before the
@@ -93,6 +98,8 @@
// interfere with the atomic animation. When the atomic animation ends, we start controlling
// the atomic components as well, using this controller.
private AnimatorPlaybackController mAtomicComponentsController;
+ private LauncherState mAtomicComponentsTargetState = NORMAL;
+
private float mAtomicComponentsStartProgress;
public AbstractStateChangeTouchController(Launcher l, SwipeDetector.Direction dir) {
@@ -191,27 +198,21 @@
}
int animComponents = goingBetweenNormalAndOverview(mFromState, mToState)
? NON_ATOMIC_COMPONENT : ANIM_ALL;
+ mScheduleResumeAtomicComponent = false;
if (mAtomicAnim != null) {
+ animComponents = NON_ATOMIC_COMPONENT;
// Control the non-atomic components until the atomic animation finishes, then control
// the atomic components as well.
- animComponents = NON_ATOMIC_COMPONENT;
- mAtomicAnim.addListener(new AnimationSuccessListener() {
- @Override
- public void onAnimationSuccess(Animator animation) {
- cancelAtomicComponentsController();
- if (mCurrentAnimation != null) {
- mAtomicComponentsStartProgress = mCurrentAnimation.getProgressFraction();
- long duration = (long) (getShiftRange() * 2);
- mAtomicComponentsController = AnimatorPlaybackController.wrap(
- createAtomicAnimForState(mFromState, mToState, duration), duration);
- mAtomicComponentsController.dispatchOnStart();
- }
- }
- });
+ mScheduleResumeAtomicComponent = true;
}
- if (goingBetweenNormalAndOverview(mFromState, mToState)) {
+ if (goingBetweenNormalAndOverview(mFromState, mToState)
+ || mAtomicComponentsTargetState != mToState) {
cancelAtomicComponentsController();
}
+
+ if (mAtomicComponentsController != null) {
+ animComponents &= ~ATOMIC_COMPONENT;
+ }
mProgressMultiplier = initCurrentAnimation(animComponents);
mCurrentAnimation.dispatchOnStart();
return true;
@@ -236,12 +237,17 @@
if (mCurrentAnimation == null) {
mFromState = mStartState;
mToState = null;
- mAtomicComponentsController = null;
+ cancelAnimationControllers();
reinitCurrentAnimation(false, mDetector.wasInitialTouchPositive());
mDisplacementShift = 0;
} else {
mCurrentAnimation.pause();
mStartProgress = mCurrentAnimation.getProgressFraction();
+
+ mAtomicAnimAutoPlayInfo = null;
+ if (mAtomicComponentsController != null) {
+ mAtomicComponentsController.pause();
+ }
}
mCanBlockFling = mFromState == NORMAL;
mFlingBlockCheck.unblockFling();
@@ -302,14 +308,34 @@
mAtomicAnim.cancel();
}
mAtomicAnim = createAtomicAnimForState(atomicFromState, atomicToState, ATOMIC_DURATION);
- mAtomicAnim.addListener(new AnimatorListenerAdapter() {
+ mAtomicAnim.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationEnd(Animator animation) {
+ super.onAnimationEnd(animation);
mAtomicAnim = null;
+ mScheduleResumeAtomicComponent = false;
+ }
+
+ @Override
+ public void onAnimationSuccess(Animator animator) {
+ if (!mScheduleResumeAtomicComponent) {
+ return;
+ }
+ cancelAtomicComponentsController();
+
+ if (mCurrentAnimation != null) {
+ mAtomicComponentsStartProgress = mCurrentAnimation.getProgressFraction();
+ long duration = (long) (getShiftRange() * 2);
+ mAtomicComponentsController = AnimatorPlaybackController.wrap(
+ createAtomicAnimForState(mFromState, mToState, duration), duration);
+ mAtomicComponentsController.dispatchOnStart();
+ mAtomicComponentsTargetState = mToState;
+ maybeAutoPlayAtomicComponentsAnim();
+ }
}
});
mAtomicAnim.start();
- mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK);
+ mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
}
@@ -337,6 +363,8 @@
final LauncherState targetState;
final float progress = mCurrentAnimation.getProgressFraction();
+ final float interpolatedProgress = mCurrentAnimation.getInterpolator()
+ .getInterpolation(progress);
if (fling) {
targetState =
Float.compare(Math.signum(velocity), Math.signum(mProgressMultiplier)) == 0
@@ -345,7 +373,7 @@
} else {
float successProgress = mToState == ALL_APPS
? MIN_PROGRESS_TO_ALL_APPS : SUCCESS_TRANSITION_PROGRESS;
- targetState = (progress > successProgress) ? mToState : mFromState;
+ targetState = (interpolatedProgress > successProgress) ? mToState : mFromState;
}
final float endProgress;
@@ -397,16 +425,8 @@
mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity);
}
anim.start();
- if (mAtomicAnim == null) {
- startAtomicComponentsAnim(endProgress, anim.getDuration());
- } else {
- mAtomicAnim.addListener(new AnimationSuccessListener() {
- @Override
- public void onAnimationSuccess(Animator animator) {
- startAtomicComponentsAnim(endProgress, anim.getDuration());
- }
- });
- }
+ mAtomicAnimAutoPlayInfo = new AutoPlayAtomicAnimationInfo(endProgress, anim.getDuration());
+ maybeAutoPlayAtomicComponentsAnim();
}
/**
@@ -416,18 +436,32 @@
* the non-atomic components, which only happens if we reinit before the atomic animation
* finishes.
*/
- private void startAtomicComponentsAnim(float toProgress, long duration) {
- if (mAtomicComponentsController != null) {
- ValueAnimator atomicAnim = mAtomicComponentsController.getAnimationPlayer();
- atomicAnim.setFloatValues(mAtomicComponentsController.getProgressFraction(), toProgress);
- atomicAnim.setDuration(duration);
+ private void maybeAutoPlayAtomicComponentsAnim() {
+ if (mAtomicComponentsController == null || mAtomicAnimAutoPlayInfo == null) {
+ return;
+ }
+
+ final AnimatorPlaybackController controller = mAtomicComponentsController;
+ ValueAnimator atomicAnim = controller.getAnimationPlayer();
+ atomicAnim.setFloatValues(controller.getProgressFraction(),
+ mAtomicAnimAutoPlayInfo.toProgress);
+ long duration = mAtomicAnimAutoPlayInfo.endTime - SystemClock.elapsedRealtime();
+ mAtomicAnimAutoPlayInfo = null;
+ if (duration <= 0) {
atomicAnim.start();
+ atomicAnim.end();
+ mAtomicComponentsController = null;
+ } else {
+ atomicAnim.setDuration(duration);
atomicAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- mAtomicComponentsController = null;
+ if (mAtomicComponentsController == controller) {
+ mAtomicComponentsController = null;
+ }
}
});
+ atomicAnim.start();
}
}
@@ -457,7 +491,11 @@
}
protected void onSwipeInteractionCompleted(LauncherState targetState, int logAction) {
- clearState();
+ if (mAtomicComponentsController != null) {
+ mAtomicComponentsController.getAnimationPlayer().end();
+ mAtomicComponentsController = null;
+ }
+ cancelAnimationControllers();
boolean shouldGoToTargetState = true;
if (mPendingAnimation != null) {
boolean reachedTarget = mToState == targetState;
@@ -484,6 +522,15 @@
}
protected void clearState() {
+ cancelAnimationControllers();
+ if (mAtomicAnim != null) {
+ mAtomicAnim.cancel();
+ mAtomicAnim = null;
+ }
+ mScheduleResumeAtomicComponent = false;
+ }
+
+ private void cancelAnimationControllers() {
mCurrentAnimation = null;
cancelAtomicComponentsController();
mDetector.finishedScrolling();
@@ -495,5 +542,17 @@
mAtomicComponentsController.getAnimationPlayer().cancel();
mAtomicComponentsController = null;
}
+ mAtomicAnimAutoPlayInfo = null;
+ }
+
+ private static class AutoPlayAtomicAnimationInfo {
+
+ public final float toProgress;
+ public final long endTime;
+
+ AutoPlayAtomicAnimationInfo(float toProgress, long duration) {
+ this.toProgress = toProgress;
+ this.endTime = duration + SystemClock.elapsedRealtime();
+ }
}
}
diff --git a/src/com/android/launcher3/util/Themes.java b/src/com/android/launcher3/util/Themes.java
index d225093..5f965a3 100644
--- a/src/com/android/launcher3/util/Themes.java
+++ b/src/com/android/launcher3/util/Themes.java
@@ -52,6 +52,13 @@
return value;
}
+ public static int getAttrInteger(Context context, int attr) {
+ TypedArray ta = context.obtainStyledAttributes(new int[]{attr});
+ int value = ta.getInteger(0, 0);
+ ta.recycle();
+ return value;
+ }
+
/**
* Returns the alpha corresponding to the theme attribute {@param attr}, in the range [0, 255].
*/
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java
index c17857f..db4c492 100644
--- a/src/com/android/launcher3/views/OptionsPopupView.java
+++ b/src/com/android/launcher3/views/OptionsPopupView.java
@@ -153,7 +153,10 @@
}
public static boolean onWidgetsClicked(View view) {
- Launcher launcher = Launcher.getLauncher(view.getContext());
+ return openWidgets(Launcher.getLauncher(view.getContext()));
+ }
+
+ public static boolean openWidgets(Launcher launcher) {
if (launcher.getPackageManager().isSafeMode()) {
Toast.makeText(launcher, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
return false;
diff --git a/src/com/android/launcher3/views/ScrimView.java b/src/com/android/launcher3/views/ScrimView.java
index 6e3ef07..7066980 100644
--- a/src/com/android/launcher3/views/ScrimView.java
+++ b/src/com/android/launcher3/views/ScrimView.java
@@ -109,6 +109,7 @@
protected int mEndFlatColorAlpha;
protected final int mDragHandleSize;
+ protected float mDragHandleOffset;
private final Rect mDragHandleBounds;
private final RectF mHitRect = new RectF();
@@ -223,8 +224,14 @@
if (mCurrentFlatColor != 0) {
canvas.drawColor(mCurrentFlatColor);
}
+ drawDragHandle(canvas);
+ }
+
+ protected void drawDragHandle(Canvas canvas) {
if (mDragHandle != null) {
+ canvas.translate(0, -mDragHandleOffset);
mDragHandle.draw(canvas);
+ canvas.translate(0, mDragHandleOffset);
}
}
@@ -237,20 +244,23 @@
final Drawable drawable = mDragHandle;
mDragHandle = null;
- drawable.setBounds(mDragHandleBounds);
- Rect topBounds = new Rect(mDragHandleBounds);
- topBounds.offset(0, -mDragHandleBounds.height() / 2);
+ Rect bounds = new Rect(mDragHandleBounds);
+ bounds.offset(0, -(int) mDragHandleOffset);
+ drawable.setBounds(bounds);
- Rect invalidateRegion = new Rect(mDragHandleBounds);
+ Rect topBounds = new Rect(bounds);
+ topBounds.offset(0, -bounds.height() / 2);
+
+ Rect invalidateRegion = new Rect(bounds);
invalidateRegion.top = topBounds.top;
Keyframe frameTop = Keyframe.ofObject(0.6f, topBounds);
frameTop.setInterpolator(DEACCEL);
- Keyframe frameBot = Keyframe.ofObject(1, mDragHandleBounds);
+ Keyframe frameBot = Keyframe.ofObject(1, bounds);
frameBot.setInterpolator(ACCEL);
PropertyValuesHolder holder = PropertyValuesHolder .ofKeyframe("bounds",
- Keyframe.ofObject(0, mDragHandleBounds), frameTop, frameBot);
+ Keyframe.ofObject(0, bounds), frameTop, frameBot);
holder.setEvaluator(new RectEvaluator());
ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(drawable, holder);