summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable-hdpi/ic_all_apps_bg_hand.pngbin11386 -> 10044 bytes
-rw-r--r--res/drawable-hdpi/ic_all_apps_bg_icon_1.pngbin2512 -> 0 bytes
-rw-r--r--res/drawable-hdpi/ic_all_apps_bg_icon_2.pngbin2740 -> 0 bytes
-rw-r--r--res/drawable-hdpi/ic_all_apps_bg_icon_3.pngbin3397 -> 0 bytes
-rw-r--r--res/drawable-hdpi/ic_all_apps_bg_icon_4.pngbin2627 -> 0 bytes
-rw-r--r--res/drawable-mdpi/ic_all_apps_bg_hand.pngbin6951 -> 6593 bytes
-rw-r--r--res/drawable-mdpi/ic_all_apps_bg_icon_1.pngbin1540 -> 0 bytes
-rw-r--r--res/drawable-mdpi/ic_all_apps_bg_icon_2.pngbin1924 -> 0 bytes
-rw-r--r--res/drawable-mdpi/ic_all_apps_bg_icon_3.pngbin2361 -> 0 bytes
-rw-r--r--res/drawable-mdpi/ic_all_apps_bg_icon_4.pngbin1944 -> 0 bytes
-rw-r--r--res/drawable-xhdpi/ic_all_apps_bg_hand.pngbin16156 -> 13864 bytes
-rw-r--r--res/drawable-xhdpi/ic_all_apps_bg_icon_1.pngbin3595 -> 0 bytes
-rw-r--r--res/drawable-xhdpi/ic_all_apps_bg_icon_2.pngbin3441 -> 0 bytes
-rw-r--r--res/drawable-xhdpi/ic_all_apps_bg_icon_3.pngbin4551 -> 0 bytes
-rw-r--r--res/drawable-xhdpi/ic_all_apps_bg_icon_4.pngbin3299 -> 0 bytes
-rw-r--r--res/drawable-xxhdpi/ic_all_apps_bg_hand.pngbin28211 -> 21354 bytes
-rw-r--r--res/drawable-xxhdpi/ic_all_apps_bg_icon_1.pngbin5089 -> 0 bytes
-rw-r--r--res/drawable-xxhdpi/ic_all_apps_bg_icon_2.pngbin5339 -> 0 bytes
-rw-r--r--res/drawable-xxhdpi/ic_all_apps_bg_icon_3.pngbin7192 -> 0 bytes
-rw-r--r--res/drawable-xxhdpi/ic_all_apps_bg_icon_4.pngbin4967 -> 0 bytes
-rw-r--r--res/drawable-xxxhdpi/ic_all_apps_bg_hand.pngbin30824 -> 29820 bytes
-rw-r--r--res/drawable-xxxhdpi/ic_all_apps_bg_icon_1.pngbin5187 -> 0 bytes
-rw-r--r--res/drawable-xxxhdpi/ic_all_apps_bg_icon_2.pngbin5348 -> 0 bytes
-rw-r--r--res/drawable-xxxhdpi/ic_all_apps_bg_icon_3.pngbin6816 -> 0 bytes
-rw-r--r--res/drawable-xxxhdpi/ic_all_apps_bg_icon_4.pngbin5269 -> 0 bytes
-rw-r--r--res/drawable/bg_pill_focused.xml25
-rw-r--r--res/drawable/ic_all_apps_bg_icon_1.xml31
-rw-r--r--res/drawable/ic_all_apps_bg_icon_2.xml33
-rw-r--r--res/drawable/ic_all_apps_bg_icon_3.xml36
-rw-r--r--res/drawable/ic_all_apps_bg_icon_4.xml34
-rw-r--r--res/drawable/ic_setting.xml2
-rw-r--r--res/layout-port/launcher.xml6
-rw-r--r--res/layout-sw720dp/launcher.xml6
-rw-r--r--res/layout/deep_shortcut.xml3
-rw-r--r--res/layout/page_indicator.xml27
-rw-r--r--res/layout/user_folder.xml13
-rw-r--r--res/layout/user_folder_icon_normalized.xml16
-rw-r--r--res/layout/widgets_list_row_view.xml4
-rw-r--r--res/values/attrs.xml3
-rw-r--r--res/values/dimens.xml11
-rw-r--r--res/values/strings.xml2
-rw-r--r--res/values/styles.xml4
-rw-r--r--src/com/android/launcher3/AppInfo.java9
-rw-r--r--src/com/android/launcher3/BubbleTextView.java4
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java17
-rw-r--r--src/com/android/launcher3/CellLayout.java1
-rw-r--r--src/com/android/launcher3/DeleteDropTarget.java7
-rw-r--r--src/com/android/launcher3/DeviceProfile.java35
-rw-r--r--src/com/android/launcher3/DragSource.java3
-rw-r--r--src/com/android/launcher3/DropTarget.java5
-rw-r--r--src/com/android/launcher3/DropTargetBar.java9
-rw-r--r--src/com/android/launcher3/ExtendedEditText.java32
-rw-r--r--src/com/android/launcher3/FolderInfo.java8
-rw-r--r--src/com/android/launcher3/HolographicOutlineHelper.java50
-rw-r--r--src/com/android/launcher3/Hotseat.java3
-rw-r--r--src/com/android/launcher3/IconCache.java3
-rw-r--r--src/com/android/launcher3/InfoDropTarget.java3
-rw-r--r--src/com/android/launcher3/InstallShortcutReceiver.java10
-rw-r--r--src/com/android/launcher3/ItemInfo.java22
-rw-r--r--src/com/android/launcher3/Launcher.java517
-rw-r--r--src/com/android/launcher3/LauncherAppWidgetInfo.java4
-rw-r--r--src/com/android/launcher3/LauncherCallbacks.java8
-rw-r--r--src/com/android/launcher3/LauncherExterns.java2
-rw-r--r--src/com/android/launcher3/PendingAddItemInfo.java5
-rw-r--r--src/com/android/launcher3/PinchToOverviewListener.java4
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java10
-rw-r--r--src/com/android/launcher3/Utilities.java61
-rw-r--r--src/com/android/launcher3/Workspace.java152
-rw-r--r--src/com/android/launcher3/accessibility/AccessibileDragListenerAdapter.java66
-rw-r--r--src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java36
-rw-r--r--src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java6
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java20
-rw-r--r--src/com/android/launcher3/allapps/AllAppsRecyclerView.java16
-rw-r--r--src/com/android/launcher3/allapps/AllAppsSearchBarController.java8
-rw-r--r--src/com/android/launcher3/allapps/AllAppsTransitionController.java3
-rw-r--r--src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java82
-rw-r--r--src/com/android/launcher3/compat/UserManagerCompat.java8
-rw-r--r--src/com/android/launcher3/compat/UserManagerCompatV16.java5
-rw-r--r--src/com/android/launcher3/compat/UserManagerCompatVL.java4
-rw-r--r--src/com/android/launcher3/compat/UserManagerCompatVM.java34
-rw-r--r--src/com/android/launcher3/compat/UserManagerCompatVN.java13
-rw-r--r--src/com/android/launcher3/compat/UserManagerCompatVNMr1.java34
-rw-r--r--src/com/android/launcher3/dragndrop/AnotherWindowDragSource.java76
-rw-r--r--src/com/android/launcher3/dragndrop/DragController.java87
-rw-r--r--src/com/android/launcher3/dragndrop/DragDriver.java165
-rw-r--r--src/com/android/launcher3/dragndrop/DragLayer.java136
-rw-r--r--src/com/android/launcher3/dragndrop/DragOptions.java31
-rw-r--r--src/com/android/launcher3/dragndrop/ExternalDragPreviewProvider.java79
-rw-r--r--src/com/android/launcher3/folder/Folder.java159
-rw-r--r--src/com/android/launcher3/folder/FolderIcon.java28
-rw-r--r--src/com/android/launcher3/folder/FolderPagedView.java2
-rw-r--r--src/com/android/launcher3/graphics/DragPreviewProvider.java7
-rw-r--r--src/com/android/launcher3/logging/LoggerUtils.java63
-rw-r--r--src/com/android/launcher3/logging/UserEventDispatcher.java106
-rw-r--r--src/com/android/launcher3/model/PackageItemInfo.java9
-rw-r--r--src/com/android/launcher3/pageindicators/CaretDrawable.java13
-rw-r--r--src/com/android/launcher3/pageindicators/PageIndicator.java5
-rw-r--r--src/com/android/launcher3/pageindicators/PageIndicatorDots.java5
-rw-r--r--src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java55
-rw-r--r--src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java21
-rw-r--r--src/com/android/launcher3/shortcuts/ShortcutDragPreviewProvider.java14
-rw-r--r--src/com/android/launcher3/testing/LauncherExtension.java7
-rw-r--r--src/com/android/launcher3/util/ActivityResultInfo.java70
-rw-r--r--src/com/android/launcher3/util/PackageManagerHelper.java54
-rw-r--r--src/com/android/launcher3/util/PendingRequestArgs.java127
-rw-r--r--src/com/android/launcher3/util/TransformingTouchDelegate.java29
-rw-r--r--src/com/android/launcher3/util/VerticalFlingDetector.java88
-rw-r--r--src/com/android/launcher3/widget/PendingAddShortcutInfo.java6
-rw-r--r--src/com/android/launcher3/widget/PendingAddWidgetInfo.java6
-rw-r--r--src/com/android/launcher3/widget/PendingItemPreviewProvider.java6
-rw-r--r--src/com/android/launcher3/widget/WidgetCell.java2
-rw-r--r--src/com/android/launcher3/widget/WidgetHostViewLoader.java4
-rw-r--r--src/com/android/launcher3/widget/WidgetsContainerView.java43
-rw-r--r--src_config/com/android/launcher3/config/FeatureFlags.java6
-rw-r--r--tests/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithmTest.java78
115 files changed, 2085 insertions, 1077 deletions
diff --git a/res/drawable-hdpi/ic_all_apps_bg_hand.png b/res/drawable-hdpi/ic_all_apps_bg_hand.png
index 43b1bedab..dff2f546f 100644
--- a/res/drawable-hdpi/ic_all_apps_bg_hand.png
+++ b/res/drawable-hdpi/ic_all_apps_bg_hand.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_all_apps_bg_icon_1.png b/res/drawable-hdpi/ic_all_apps_bg_icon_1.png
deleted file mode 100644
index d2c4cc123..000000000
--- a/res/drawable-hdpi/ic_all_apps_bg_icon_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_all_apps_bg_icon_2.png b/res/drawable-hdpi/ic_all_apps_bg_icon_2.png
deleted file mode 100644
index 57b74565b..000000000
--- a/res/drawable-hdpi/ic_all_apps_bg_icon_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_all_apps_bg_icon_3.png b/res/drawable-hdpi/ic_all_apps_bg_icon_3.png
deleted file mode 100644
index 54fe70b13..000000000
--- a/res/drawable-hdpi/ic_all_apps_bg_icon_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_all_apps_bg_icon_4.png b/res/drawable-hdpi/ic_all_apps_bg_icon_4.png
deleted file mode 100644
index 9c0f7773b..000000000
--- a/res/drawable-hdpi/ic_all_apps_bg_icon_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_all_apps_bg_hand.png b/res/drawable-mdpi/ic_all_apps_bg_hand.png
index 8868d6b7c..0d1d7bb81 100644
--- a/res/drawable-mdpi/ic_all_apps_bg_hand.png
+++ b/res/drawable-mdpi/ic_all_apps_bg_hand.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_all_apps_bg_icon_1.png b/res/drawable-mdpi/ic_all_apps_bg_icon_1.png
deleted file mode 100644
index 4c78288b4..000000000
--- a/res/drawable-mdpi/ic_all_apps_bg_icon_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_all_apps_bg_icon_2.png b/res/drawable-mdpi/ic_all_apps_bg_icon_2.png
deleted file mode 100644
index 0ed311bcd..000000000
--- a/res/drawable-mdpi/ic_all_apps_bg_icon_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_all_apps_bg_icon_3.png b/res/drawable-mdpi/ic_all_apps_bg_icon_3.png
deleted file mode 100644
index 2aa3d4e43..000000000
--- a/res/drawable-mdpi/ic_all_apps_bg_icon_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_all_apps_bg_icon_4.png b/res/drawable-mdpi/ic_all_apps_bg_icon_4.png
deleted file mode 100644
index 2cdea9cb2..000000000
--- a/res/drawable-mdpi/ic_all_apps_bg_icon_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_all_apps_bg_hand.png b/res/drawable-xhdpi/ic_all_apps_bg_hand.png
index 8a672451d..e727d3785 100644
--- a/res/drawable-xhdpi/ic_all_apps_bg_hand.png
+++ b/res/drawable-xhdpi/ic_all_apps_bg_hand.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_all_apps_bg_icon_1.png b/res/drawable-xhdpi/ic_all_apps_bg_icon_1.png
deleted file mode 100644
index c0ebaed5a..000000000
--- a/res/drawable-xhdpi/ic_all_apps_bg_icon_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_all_apps_bg_icon_2.png b/res/drawable-xhdpi/ic_all_apps_bg_icon_2.png
deleted file mode 100644
index 71cf250ee..000000000
--- a/res/drawable-xhdpi/ic_all_apps_bg_icon_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_all_apps_bg_icon_3.png b/res/drawable-xhdpi/ic_all_apps_bg_icon_3.png
deleted file mode 100644
index 3c69fc58b..000000000
--- a/res/drawable-xhdpi/ic_all_apps_bg_icon_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_all_apps_bg_icon_4.png b/res/drawable-xhdpi/ic_all_apps_bg_icon_4.png
deleted file mode 100644
index 5f6ca38db..000000000
--- a/res/drawable-xhdpi/ic_all_apps_bg_icon_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_all_apps_bg_hand.png b/res/drawable-xxhdpi/ic_all_apps_bg_hand.png
index ed694f846..fffcc6bb6 100644
--- a/res/drawable-xxhdpi/ic_all_apps_bg_hand.png
+++ b/res/drawable-xxhdpi/ic_all_apps_bg_hand.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_all_apps_bg_icon_1.png b/res/drawable-xxhdpi/ic_all_apps_bg_icon_1.png
deleted file mode 100644
index 5cb042786..000000000
--- a/res/drawable-xxhdpi/ic_all_apps_bg_icon_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_all_apps_bg_icon_2.png b/res/drawable-xxhdpi/ic_all_apps_bg_icon_2.png
deleted file mode 100644
index cd0322ba5..000000000
--- a/res/drawable-xxhdpi/ic_all_apps_bg_icon_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_all_apps_bg_icon_3.png b/res/drawable-xxhdpi/ic_all_apps_bg_icon_3.png
deleted file mode 100644
index 19ffc2dcc..000000000
--- a/res/drawable-xxhdpi/ic_all_apps_bg_icon_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_all_apps_bg_icon_4.png b/res/drawable-xxhdpi/ic_all_apps_bg_icon_4.png
deleted file mode 100644
index 311c3df27..000000000
--- a/res/drawable-xxhdpi/ic_all_apps_bg_icon_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_all_apps_bg_hand.png b/res/drawable-xxxhdpi/ic_all_apps_bg_hand.png
index 615374a78..4d065d806 100644
--- a/res/drawable-xxxhdpi/ic_all_apps_bg_hand.png
+++ b/res/drawable-xxxhdpi/ic_all_apps_bg_hand.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_all_apps_bg_icon_1.png b/res/drawable-xxxhdpi/ic_all_apps_bg_icon_1.png
deleted file mode 100644
index 10f8c4169..000000000
--- a/res/drawable-xxxhdpi/ic_all_apps_bg_icon_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_all_apps_bg_icon_2.png b/res/drawable-xxxhdpi/ic_all_apps_bg_icon_2.png
deleted file mode 100644
index 102d9251f..000000000
--- a/res/drawable-xxxhdpi/ic_all_apps_bg_icon_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_all_apps_bg_icon_3.png b/res/drawable-xxxhdpi/ic_all_apps_bg_icon_3.png
deleted file mode 100644
index 9be5b7a12..000000000
--- a/res/drawable-xxxhdpi/ic_all_apps_bg_icon_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_all_apps_bg_icon_4.png b/res/drawable-xxxhdpi/ic_all_apps_bg_icon_4.png
deleted file mode 100644
index d7fb29baf..000000000
--- a/res/drawable-xxxhdpi/ic_all_apps_bg_icon_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/bg_pill_focused.xml b/res/drawable/bg_pill_focused.xml
new file mode 100644
index 000000000..37afad037
--- /dev/null
+++ b/res/drawable/bg_pill_focused.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_focused="true">
+ <shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <stroke android:color="#616161" android:width="2dp"/>
+ <corners android:radius="@dimen/bg_pill_radius" />
+ </shape>
+ </item>
+</selector> \ No newline at end of file
diff --git a/res/drawable/ic_all_apps_bg_icon_1.xml b/res/drawable/ic_all_apps_bg_icon_1.xml
new file mode 100644
index 000000000..c9c0a7549
--- /dev/null
+++ b/res/drawable/ic_all_apps_bg_icon_1.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48.0"
+ android:viewportHeight="48.0">
+
+ <path
+ android:fillColor="#1A000000"
+ android:pathData="M44.28,30.96c4.84-10.68,0.09-23.27-10.59-28.11S10.42,2.74,5.58,13.42
+ C1,23.54,6.5,35.92,16.62,40.51l0,0l-3.23,7.12C27.84,47,39.79,40.86,44.28,30.96z" />
+ <path
+ android:fillColor="#E0E0E0"
+ android:pathData="M41.75,30.05c4.84-10.68,0.09-23.27-10.59-28.11S7.9,1.83,3.06,12.51
+ c-4.59,10.12,0.92,22.5,11.03,27.09l0,0l-3.23,7.12C25.31,46.09,37.26,39.94,41.75,30.05z" />
+</vector> \ No newline at end of file
diff --git a/res/drawable/ic_all_apps_bg_icon_2.xml b/res/drawable/ic_all_apps_bg_icon_2.xml
new file mode 100644
index 000000000..b6269e3ab
--- /dev/null
+++ b/res/drawable/ic_all_apps_bg_icon_2.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48.0"
+ android:viewportHeight="48.0">
+
+ <path
+ android:fillColor="#1A000000"
+ android:pathData="M20.54,44.59c0.57-0.04,1.15-0.38,1.67-1.04l24.23-30.62c0.62-0.78,0.77-1.54,0.52-2.12
+ c-0.25-0.58-0.9-0.99-1.89-1.1L6.2,5.99C5.39,5.91,4.74,6.08,4.32,6.44l0,0C3.7,6.97,3.55,7.88,4.01,8.96l14.54,34.09
+ C19,44.13,19.75,44.65,20.54,44.59L20.54,44.59z" />
+ <path
+ android:fillColor="#E0E0E0"
+ android:pathData="M18.49,43.22c0.57-0.04,1.15-0.38,1.67-1.04l24.23-30.62c0.62-0.78,0.77-1.54,0.52-2.12
+ c-0.25-0.58-0.9-0.99-1.89-1.1L4.15,4.62C3.34,4.54,2.69,4.71,2.27,5.08l0,0C1.65,5.6,1.5,6.52,1.96,7.6L16.5,41.69
+ C16.96,42.76,17.7,43.28,18.49,43.22L18.49,43.22z" />
+</vector> \ No newline at end of file
diff --git a/res/drawable/ic_all_apps_bg_icon_3.xml b/res/drawable/ic_all_apps_bg_icon_3.xml
new file mode 100644
index 000000000..4c255a909
--- /dev/null
+++ b/res/drawable/ic_all_apps_bg_icon_3.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48.0"
+ android:viewportHeight="48.0">
+
+ <path
+ android:fillColor="#1A000000"
+ android:pathData="M25.18,1.27c-12.32,0-23.41,9.99-23.41,22.31s11.09,22.31,23.41,22.31
+ s22.31-9.99,22.31-22.31S37.5,1.27,25.18,1.27z M25.18,33.55c-5.5,0-14.35-5.1-14.35-10.6s8.32-12.19,13.82-12.19
+ c5.5,0,10.49,7.33,10.49,12.83S30.68,33.55,25.18,33.55z" />
+ <path
+ android:fillColor="#E0E0E0"
+ android:pathData="M22.93,0.22c-12.32,0-22.31,9.99-22.31,22.31s9.99,22.31,22.31,22.31
+ s22.31-9.99,22.31-22.31S35.25,0.22,22.93,0.22z M22.93,32.5c-5.5,0-9.97-4.46-9.97-9.97s4.46-9.97,9.97-9.97
+ c5.5,0,9.97,4.46,9.97,9.97S28.43,32.5,22.93,32.5z" />
+ <path
+ android:fillColor="#E0E0E0"
+ android:pathData="M14.81,22.53a8.12,8.12 0 1,0 16.24,0a8.12,8.12 0 1,0 -16.24,0z" />
+</vector>
diff --git a/res/drawable/ic_all_apps_bg_icon_4.xml b/res/drawable/ic_all_apps_bg_icon_4.xml
new file mode 100644
index 000000000..12e05bc6b
--- /dev/null
+++ b/res/drawable/ic_all_apps_bg_icon_4.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48.0"
+ android:viewportHeight="48.0">
+
+ <path
+ android:fillColor="#1A000000"
+ android:pathData="M11.53,8.02l23.39-5.73c1.61-0.39,3.25,0.6,3.64,2.21l7.64,31.19
+ c0.39,1.61-0.6,3.25-2.21,3.64L12.8,46.97c-1.61,0.39-3.25-0.6-3.64-2.21L3.43,21.37L11.53,8.02z" />
+ <path
+ android:fillColor="#E0E0E0"
+ android:pathData="M9.2,6.53L32.59,0.8C34.2,0.4,35.84,1.4,36.23,3l7.64,31.19c0.39,1.61-0.6,3.25-2.21,3.64
+ l-31.19,7.64c-1.61,0.39-3.25-0.6-3.64-2.21L1.11,19.87L9.2,6.53z" />
+ <path
+ android:fillColor="#1A000000"
+ android:pathData="M9.27,6.47l1.91,7.8c0.4,1.62-0.59,3.24-2.21,3.64l-7.8,1.91L9.27,6.47z" />
+</vector> \ No newline at end of file
diff --git a/res/drawable/ic_setting.xml b/res/drawable/ic_setting.xml
index 256d24ca7..8a50c0c78 100644
--- a/res/drawable/ic_setting.xml
+++ b/res/drawable/ic_setting.xml
@@ -20,5 +20,5 @@ Copyright (C) 2016 The Android Open Source Project
android:viewportHeight="48.0">
<path
android:fillColor="#FFFFFFFF"
- android:pathData="M38.86 25.95c.08-.64.14-1.29.14-1.95s-.06-1.31-.14-1.95l4.23-3.31c.38-.3.49-.84.24-1.28l-4-6.93c-.25-.43-.77-.61-1.22-.43l-4.98 2.01c-1.03-.79-2.16-1.46-3.38-1.97L29 4.84c-.09-.47-.5-.84-1-.84h-8c-.5 0-.91.37-.99.84l-.75 5.3c-1.22.51-2.35 1.17-3.38 1.97L9.9 10.1c-.45-.17-.97 0-1.22.43l-4 6.93c-.25.43-.14.97.24 1.28l4.22 3.31C9.06 22.69 9 23.34 9 24s.06 1.31.14 1.95l-4.22 3.31c-.38.3-.49.84-.24 1.28l4 6.93c.25.43.77.61 1.22.43l4.98-2.01c1.03.79 2.16 1.46 3.38 1.97l.75 5.3c.08.47.49.84.99.84h8c.5 0 .91-.37.99-.84l.75-5.3c1.22-.51 2.35-1.17 3.38-1.97l4.98 2.01c.45.17.97 0 1.22-.43l4-6.93c.25-.43.14-.97-.24-1.28l-4.22-3.31zM24 31c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"/>
+ android:pathData="M38.86 25.95c.08-.64 .14-1.29 .14-1.95s-.06-1.31-.14-1.95l4.23-3.31c.38-.3 .49-.84 .24-1.28l-4-6.93c-.25-.43-.77-.61-1.22-.43l-4.98 2.01c-1.03-.79-2.16-1.46-3.38-1.97L29 4.84c-.09-.47-.5-.84-1-.84h-8c-.5 0-.91 .37-.99 .84l-.75 5.3c-1.22 .51-2.35 1.17-3.38 1.97L9.9 10.1c-.45-.17-.97 0-1.22 .43l-4 6.93c-.25 .43-.14 .97 .24 1.28l4.22 3.31C9.06 22.69 9 23.34 9 24s.06 1.31 .14 1.95l-4.22 3.31c-.38 .3-.49 .84-.24 1.28l4 6.93c.25 .43 .77 .61 1.22 .43l4.98-2.01c1.03 .79 2.16 1.46 3.38 1.97l.75 5.3c.08 .47 .49 .84 .99 .84h8c.5 0 .91-.37 .99-.84l.75-5.3c1.22-.51 2.35-1.17 3.38-1.97l4.98 2.01c.45 .17 .97 0 1.22-.43l4-6.93c.25-.43 .14-.97-.24-1.28l-4.22-3.31zM24 31c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"/>
</vector>
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 49bac3bcc..a2e2f9bba 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -56,10 +56,8 @@
<!-- Keep these behind the workspace so that they are not visible when
we go into AllApps -->
- <com.android.launcher3.pageindicators.PageIndicatorLineCaret
- android:id="@+id/page_indicator"
- android:layout_width="match_parent"
- android:layout_height="@dimen/dynamic_grid_page_indicator_height" />
+ <include layout="@layout/page_indicator"
+ android:id="@+id/page_indicator" />
<include
android:id="@+id/drop_target_bar"
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index 81d2e1b8f..12c01b77d 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -59,10 +59,8 @@
<!-- Keep these behind the workspace so that they are not visible when
we go into AllApps -->
- <com.android.launcher3.pageindicators.PageIndicatorLineCaret
- android:id="@+id/page_indicator"
- android:layout_width="match_parent"
- android:layout_height="@dimen/dynamic_grid_page_indicator_height" />
+ <include layout="@layout/page_indicator"
+ android:id="@+id/page_indicator" />
<include
layout="@layout/qsb_container"
diff --git a/res/layout/deep_shortcut.xml b/res/layout/deep_shortcut.xml
index 2d66d728f..7b42ec70e 100644
--- a/res/layout/deep_shortcut.xml
+++ b/res/layout/deep_shortcut.xml
@@ -26,7 +26,8 @@
style="@style/Icon.DeepShortcut"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:focusable="true" />
+ android:focusable="true"
+ android:background="@drawable/bg_pill_focused" />
<View
android:id="@+id/deep_shortcut_icon"
diff --git a/res/layout/page_indicator.xml b/res/layout/page_indicator.xml
new file mode 100644
index 000000000..2e1b57f56
--- /dev/null
+++ b/res/layout/page_indicator.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.launcher3.pageindicators.PageIndicatorLineCaret
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dynamic_grid_page_indicator_height">
+ <ImageView
+ android:id="@+id/all_apps_handle"
+ android:layout_width="48dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:scaleType="centerInside"/>
+</com.android.launcher3.pageindicators.PageIndicatorLineCaret>
diff --git a/res/layout/user_folder.xml b/res/layout/user_folder.xml
index d95075058..50bd89699 100644
--- a/res/layout/user_folder.xml
+++ b/res/layout/user_folder.xml
@@ -28,7 +28,7 @@
android:layout_height="match_parent"
android:paddingLeft="4dp"
android:paddingRight="4dp"
- android:paddingTop="8dp"
+ android:paddingTop="4dp"
launcher:pageIndicator="@+id/folder_page_indicator" />
<LinearLayout
@@ -37,8 +37,8 @@
android:layout_height="wrap_content"
android:clipChildren="false"
android:orientation="horizontal"
- android:paddingLeft="8dp"
- android:paddingRight="8dp" >
+ android:paddingLeft="12dp"
+ android:paddingRight="12dp" >
<com.android.launcher3.ExtendedEditText
android:id="@+id/folder_name"
@@ -51,13 +51,14 @@
android:gravity="center_horizontal"
android:hint="@string/folder_hint_text"
android:imeOptions="flagNoExtractUi"
- android:paddingBottom="8dp"
- android:paddingTop="4dp"
+ android:paddingBottom="@dimen/folder_label_padding"
+ android:paddingTop="@dimen/folder_label_padding"
android:singleLine="true"
android:textColor="#ff777777"
+ android:includeFontPadding="false"
android:textColorHighlight="#ffCCCCCC"
android:textColorHint="#ff808080"
- android:textSize="14sp" />
+ android:textSize="@dimen/folder_label_text_size" />
<com.android.launcher3.pageindicators.PageIndicatorDots
android:id="@+id/folder_page_indicator"
diff --git a/res/layout/user_folder_icon_normalized.xml b/res/layout/user_folder_icon_normalized.xml
index bb6bd765b..16e618a80 100644
--- a/res/layout/user_folder_icon_normalized.xml
+++ b/res/layout/user_folder_icon_normalized.xml
@@ -26,9 +26,9 @@
android:id="@+id/folder_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingLeft="8dp"
- android:paddingRight="8dp"
- android:paddingTop="8dp"
+ android:paddingLeft="4dp"
+ android:paddingRight="4dp"
+ android:paddingTop="4dp"
launcher:pageIndicator="@+id/folder_page_indicator" />
<LinearLayout
@@ -37,8 +37,8 @@
android:layout_height="wrap_content"
android:clipChildren="false"
android:orientation="horizontal"
- android:paddingLeft="8dp"
- android:paddingRight="8dp" >
+ android:paddingLeft="12dp"
+ android:paddingRight="12dp" >
<com.android.launcher3.ExtendedEditText
android:id="@+id/folder_name"
@@ -52,13 +52,13 @@
android:gravity="center_horizontal"
android:hint="@string/folder_hint_text"
android:imeOptions="flagNoExtractUi"
- android:paddingBottom="12dp"
- android:paddingTop="4dp"
+ android:paddingBottom="@dimen/folder_label_padding"
+ android:paddingTop="@dimen/folder_label_padding"
android:singleLine="true"
android:textColor="#EE777777"
android:textColorHighlight="#ffCCCCCC"
android:textColorHint="#ff808080"
- android:textSize="14sp" />
+ android:textSize="@dimen/folder_label_text_size" />
<com.android.launcher3.pageindicators.PageIndicatorDots
android:id="@+id/folder_page_indicator"
diff --git a/res/layout/widgets_list_row_view.xml b/res/layout/widgets_list_row_view.xml
index 4687b3891..30a34d4f9 100644
--- a/res/layout/widgets_list_row_view.xml
+++ b/res/layout/widgets_list_row_view.xml
@@ -59,8 +59,8 @@
android:id="@+id/widgets_cell_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/widget_row_padding"
- android:layout_marginLeft="@dimen/widget_row_padding"
+ android:paddingStart="@dimen/widget_row_padding"
+ android:paddingEnd="0dp"
android:orientation="horizontal"
android:divider="@drawable/widgets_row_divider"
android:showDividers="middle"/>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 3cfaf02d0..3423835a9 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -25,7 +25,8 @@
<attr name="iconDisplay" format="integer">
<enum name="workspace" value="0" />
<enum name="all_apps" value="1" />
- <enum name="widget_section" value="2" />
+ <enum name="folder" value="2" />
+ <enum name="widget_section" value="3" />
</attr>
<attr name="deferShadowGeneration" format="boolean" />
<attr name="customShadows" format="boolean" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 87ef78b2e..33466a813 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -4,9 +4,9 @@
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.
@@ -19,7 +19,6 @@
<dimen name="dynamic_grid_edge_margin">8dp</dimen>
<dimen name="dynamic_grid_page_indicator_height">28dp</dimen>
<dimen name="dynamic_grid_page_indicator_line_height">1dp</dimen>
- <dimen name="dynamic_grid_page_indicator_extra_touch_height">12dp</dimen>
<dimen name="dynamic_grid_page_indicator_gutter_width_left_nav_bar">38dp</dimen>
<dimen name="dynamic_grid_page_indicator_gutter_width_right_nav_bar">48dp</dimen>
<dimen name="dynamic_grid_icon_drawable_padding">8dp</dimen>
@@ -138,6 +137,12 @@
<dimen name="folder_preview_padding">6dp</dimen>
<dimen name="page_indicator_dot_size">8dp</dimen>
+ <dimen name="folder_cell_x_padding">9dp</dimen>
+ <dimen name="folder_cell_y_padding">8dp</dimen>
+ <dimen name="folder_child_text_size">13sp</dimen>
+ <dimen name="folder_label_padding">12dp</dimen>
+ <dimen name="folder_label_text_size">14sp</dimen>
+
<!-- Sizes for managed profile badges -->
<dimen name="profile_badge_size">24dp</dimen>
<dimen name="profile_badge_margin">5dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d11d5a56d..60a37e5ef 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -46,6 +46,8 @@
<!-- The format string for the dimensions of a widget in the drawer -->
<!-- There is a special version of this format string for Farsi -->
<string name="widget_dims_format">%1$d \u00d7 %2$d</string>
+ <!-- Accessibility spoken message format for the dimensions of a widget in the drawer -->
+ <string name="widget_accessible_dims_format">%1$d wide by %2$d high</string>
<!-- All Apps -->
<!-- Search bar text in the apps view. [CHAR_LIMIT=50] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index f0297654b..ecc11b0ee 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -74,7 +74,11 @@
<item name="android:background">@null</item>
<item name="android:textColor">@color/quantum_panel_text_color</item>
<item name="android:shadowRadius">0</item>
+ <item name="android:textSize">@dimen/folder_child_text_size</item>
+ <item name="android:gravity">center</item>
+ <item name="android:includeFontPadding">false</item>
<item name="customShadows">false</item>
+ <item name="iconDisplay">folder</item>
</style>
<style name="Icon.DeepShortcut">
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index e0694f3cf..4c4d67c59 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -62,7 +62,7 @@ public class AppInfo extends ItemInfo {
*/
int isDisabled = ShortcutInfo.DEFAULT;
- AppInfo() {
+ public AppInfo() {
itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
}
@@ -125,11 +125,8 @@ public class AppInfo extends ItemInfo {
}
@Override
- public String toString() {
- return "ApplicationInfo(title=" + title + " id=" + this.id
- + " type=" + this.itemType + " container=" + this.container
- + " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY
- + " spanX=" + spanX + " spanY=" + spanY + " user=" + user + ")";
+ protected String dumpProperties() {
+ return super.dumpProperties() + " componentName=" + componentName;
}
/**
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 33b3ad347..a294fa538 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -65,6 +65,7 @@ public class BubbleTextView extends TextView
private static final int DISPLAY_WORKSPACE = 0;
private static final int DISPLAY_ALL_APPS = 1;
+ private static final int DISPLAY_FOLDER = 2;
private final Launcher mLauncher;
private Drawable mIcon;
@@ -125,12 +126,13 @@ public class BubbleTextView extends TextView
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx);
defaultIconSize = grid.allAppsIconSizePx;
+ } else if (display == DISPLAY_FOLDER) {
+ setCompoundDrawablePadding(grid.folderChildDrawablePaddingPx);
}
mCenterVertically = a.getBoolean(R.styleable.BubbleTextView_centerVertically, false);
mIconSize = a.getDimensionPixelSize(R.styleable.BubbleTextView_iconSizeOverride,
defaultIconSize);
-
a.recycle();
if (mCustomShadowsEnabled) {
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 0f6073eee..cf8abae2e 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -43,6 +43,7 @@ import android.widget.TextView;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.util.Thunk;
@@ -199,8 +200,8 @@ public abstract class ButtonDropTarget extends TextView
}
@Override
- public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
- mActive = supportsDrop(source, info);
+ public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
+ mActive = supportsDrop(dragObject.dragSource, dragObject.dragInfo);
mDrawable.setColorFilter(null);
if (mCurrentColorAnim != null) {
mCurrentColorAnim.cancel();
@@ -209,6 +210,9 @@ public abstract class ButtonDropTarget extends TextView
setTextColor(mOriginalTextColor);
(mHideParentOnDisable ? ((ViewGroup) getParent()) : this)
.setVisibility(mActive ? View.VISIBLE : View.GONE);
+
+ mAccessibleDrag = options.isAccessibleDrag;
+ setOnClickListener(mAccessibleDrag ? this : null);
}
@Override
@@ -227,6 +231,7 @@ public abstract class ButtonDropTarget extends TextView
@Override
public void onDragEnd() {
mActive = false;
+ setOnClickListener(null);
}
/**
@@ -254,7 +259,8 @@ public abstract class ButtonDropTarget extends TextView
}
};
dragLayer.animateView(d.dragView, from, to, scale, 1f, 1f, 0.1f, 0.1f,
- DRAG_VIEW_DROP_DURATION, new DecelerateInterpolator(2),
+ mLauncher.getDragController().isExternalDrag() ? 1 : DRAG_VIEW_DROP_DURATION,
+ new DecelerateInterpolator(2),
new LinearInterpolator(), onAnimationEndRunnable,
DragLayer.ANIMATION_END_DISAPPEAR, null);
}
@@ -308,11 +314,6 @@ public abstract class ButtonDropTarget extends TextView
return to;
}
- public void enableAccessibleDrag(boolean enable) {
- mAccessibleDrag = enable;
- setOnClickListener(enable ? this : null);
- }
-
@Override
public void onClick(View v) {
mLauncher.getAccessibilityDelegate().handleAccessibleDrop(this, null, null);
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index baccfd157..6714d9f17 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -236,6 +236,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
for (int i = 0; i < mDragOutlines.length; i++) {
mDragOutlines[i] = new Rect(-1, -1, -1, -1);
}
+ mDragOutlinePaint.setColor(getResources().getColor(R.color.outline_color));
// When dragging things around the home screens, we show a green outline of
// where the item will land. The outlines gradually fade out, leaving a trail
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index f24e00b5c..705f84101 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -25,6 +25,7 @@ import android.view.View;
import android.view.animation.AnimationUtils;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.util.FlingAnimation;
import com.android.launcher3.util.Thunk;
@@ -49,9 +50,9 @@ public class DeleteDropTarget extends ButtonDropTarget {
}
@Override
- public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
- super.onDragStart(source, info, dragAction);
- setTextBasedOnDragSource(source);
+ public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
+ super.onDragStart(dragObject, options);
+ setTextBasedOnDragSource(dragObject.dragSource);
}
/** @return true for items that should have a "Remove" action in accessibility. */
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index e6802bd27..c4e6ed119 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -20,8 +20,6 @@ import android.appwidget.AppWidgetHostView;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
-import android.graphics.Paint;
-import android.graphics.Paint.FontMetrics;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.DisplayMetrics;
@@ -100,6 +98,7 @@ public class DeviceProfile {
public int folderIconPreviewPadding;
public int folderCellWidthPx;
public int folderCellHeightPx;
+ public int folderChildDrawablePaddingPx;
// Hotseat
public int hotseatCellWidthPx;
@@ -255,12 +254,9 @@ public class DeviceProfile {
allAppsIconDrawablePaddingPx = iconDrawablePaddingPx;
allAppsIconTextSizePx = iconTextSizePx;
- // Calculate the actual text height
- Paint textPaint = new Paint();
- textPaint.setTextSize(iconTextSizePx);
- FontMetrics fm = textPaint.getFontMetrics();
cellWidthPx = iconSizePx;
- cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top);
+ cellHeightPx = iconSizePx + iconDrawablePaddingPx
+ + Utilities.calculateTextHeight(iconTextSizePx);
final float scaleDps = !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND ? 0f
: res.getDimensionPixelSize(R.dimen.dragViewScale);
dragViewScale = (iconSizePx + scaleDps) / iconSizePx;
@@ -281,12 +277,25 @@ public class DeviceProfile {
res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
}
- // Folder
- int folderCellPadding = isTablet || isLandscape ? 6 * edgeMarginPx : 3 * edgeMarginPx;
+ // Folder cell
+ int cellPaddingX = res.getDimensionPixelSize(R.dimen.folder_cell_x_padding);
+ int cellPaddingY = res.getDimensionPixelSize(R.dimen.folder_cell_y_padding);
+ final int folderChildTextSize =
+ Utilities.calculateTextHeight(res.getDimension(R.dimen.folder_child_text_size));
+
+ final int folderBottomPanelSize =
+ 2 * res.getDimensionPixelSize(R.dimen.folder_label_padding)
+ + Utilities.calculateTextHeight(res.getDimension(R.dimen.folder_label_text_size));
+
// Don't let the folder get too close to the edges of the screen.
- folderCellWidthPx = Math.min(cellWidthPx + folderCellPadding,
+ folderCellWidthPx = Math.min(iconSizePx + 2 * cellPaddingX,
(availableWidthPx - 4 * edgeMarginPx) / inv.numFolderColumns);
- folderCellHeightPx = cellHeightPx + edgeMarginPx;
+ folderCellHeightPx = Math.min(iconSizePx + 3 * cellPaddingY + folderChildTextSize,
+ (availableHeightPx - 4 * edgeMarginPx - folderBottomPanelSize) / inv.numFolderRows);
+ folderChildDrawablePaddingPx = Math.max(0,
+ (folderCellHeightPx - iconSizePx - folderChildTextSize) / 3);
+
+ // Folder icon
folderBackgroundOffset = -edgeMarginPx;
folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset;
folderIconPreviewPadding = res.getDimensionPixelSize(R.dimen.folder_preview_padding);
@@ -296,9 +305,6 @@ public class DeviceProfile {
mInsets.set(insets);
}
- /**
- * @param recyclerViewWidth the available width of the AllAppsRecyclerView
- */
public void updateAppsViewNumCols() {
allAppsNumCols = allAppsNumPredictiveCols = inv.numColumns;
}
@@ -533,7 +539,6 @@ public class DeviceProfile {
} else {
// Put the page indicators above the hotseat
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
- lp.width = LayoutParams.WRAP_CONTENT;
lp.height = pageIndicatorHeightPx;
lp.bottomMargin = hotseatBarHeightPx + mInsets.bottom;
}
diff --git a/src/com/android/launcher3/DragSource.java b/src/com/android/launcher3/DragSource.java
index da32d82a6..efbb9d7b6 100644
--- a/src/com/android/launcher3/DragSource.java
+++ b/src/com/android/launcher3/DragSource.java
@@ -19,11 +19,12 @@ package com.android.launcher3;
import android.view.View;
import com.android.launcher3.DropTarget.DragObject;
+import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider;
/**
* Interface defining an object that can originate a drag.
*/
-public interface DragSource {
+public interface DragSource extends LaunchSourceProvider {
/**
* @return whether items dragged from this source supports
diff --git a/src/com/android/launcher3/DropTarget.java b/src/com/android/launcher3/DropTarget.java
index 90b8f1c75..efdeb1fa3 100644
--- a/src/com/android/launcher3/DropTarget.java
+++ b/src/com/android/launcher3/DropTarget.java
@@ -48,9 +48,12 @@ public interface DropTarget {
/** The view that moves around while you drag. */
public DragView dragView = null;
- /** The data associated with the object being dragged */
+ /** The data associated with the object, after item is dropped. */
public ItemInfo dragInfo = null;
+ /** The data associated with the object being dragged */
+ public ItemInfo originalDragInfo = null;
+
/** Where the drag originated */
public DragSource dragSource = null;
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index 5966af51c..42bab4705 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -27,6 +27,7 @@ import android.view.animation.AccelerateInterpolator;
import android.widget.LinearLayout;
import com.android.launcher3.dragndrop.DragController;
+import com.android.launcher3.dragndrop.DragOptions;
/*
* The top bar containing various drop targets: Delete/App Info/Uninstall.
@@ -120,17 +121,11 @@ public class DropTargetBar extends LinearLayout implements DragController.DragLi
}
}
- public void enableAccessibleDrag(boolean enable) {
- mDeleteDropTarget.enableAccessibleDrag(enable);
- mAppInfoDropTarget.enableAccessibleDrag(enable);
- mUninstallDropTarget.enableAccessibleDrag(enable);
- }
-
/*
* DragController.DragListener implementation
*/
@Override
- public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
+ public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
animateToVisibility(true);
}
diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java
index bf4551b26..f7737f423 100644
--- a/src/com/android/launcher3/ExtendedEditText.java
+++ b/src/com/android/launcher3/ExtendedEditText.java
@@ -19,6 +19,7 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.DragEvent;
import android.view.KeyEvent;
+import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
@@ -27,6 +28,8 @@ import android.widget.EditText;
*/
public class ExtendedEditText extends EditText {
+ private boolean mShowImeAfterFirstLayout;
+
/**
* Implemented by listeners of the back key.
*/
@@ -37,11 +40,11 @@ public class ExtendedEditText extends EditText {
private OnBackKeyListener mBackKeyListener;
public ExtendedEditText(Context context) {
- super(context);
+ this(context, null, 0);
}
public ExtendedEditText(Context context, AttributeSet attrs) {
- super(context, attrs);
+ this(context, attrs, 0);
}
public ExtendedEditText(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -69,4 +72,29 @@ public class ExtendedEditText extends EditText {
// We don't want this view to interfere with Launcher own drag and drop.
return false;
}
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ if (mShowImeAfterFirstLayout) {
+ // soft input only shows one frame after the layout of the EditText happens,
+ post(new Runnable() {
+ @Override
+ public void run() {
+ showSoftInput();
+ mShowImeAfterFirstLayout = false;
+ }
+ });
+ }
+ }
+
+ public void showKeyboard() {
+ mShowImeAfterFirstLayout = !showSoftInput();
+ }
+
+ private boolean showSoftInput() {
+ return requestFocus() &&
+ ((InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
+ .showSoftInput(this, InputMethodManager.SHOW_FORCED);
+ }
}
diff --git a/src/com/android/launcher3/FolderInfo.java b/src/com/android/launcher3/FolderInfo.java
index 9a9985211..c0a8caaa3 100644
--- a/src/com/android/launcher3/FolderInfo.java
+++ b/src/com/android/launcher3/FolderInfo.java
@@ -126,14 +126,6 @@ public class FolderInfo extends ItemInfo {
public void onItemsChanged(boolean animate);
}
- @Override
- public String toString() {
- return "FolderInfo(id=" + this.id + " type=" + this.itemType
- + " container=" + this.container + " screen=" + screenId
- + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX
- + " spanY=" + spanY + ")";
- }
-
public boolean hasOption(int optionFlag) {
return (options & optionFlag) != 0;
}
diff --git a/src/com/android/launcher3/HolographicOutlineHelper.java b/src/com/android/launcher3/HolographicOutlineHelper.java
index 682231198..9dec7d9e4 100644
--- a/src/com/android/launcher3/HolographicOutlineHelper.java
+++ b/src/com/android/launcher3/HolographicOutlineHelper.java
@@ -29,6 +29,10 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.SparseArray;
+import com.android.launcher3.config.ProviderConfig;
+
+import java.nio.ByteBuffer;
+
/**
* Utility class to generate shadow and outline effect, which are used for click feedback
* and drag-n-drop respectively.
@@ -79,50 +83,53 @@ public class HolographicOutlineHelper {
* Applies a more expensive and accurate outline to whatever is currently drawn in a specified
* bitmap.
*/
- public void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color,
- int outlineColor) {
- applyExpensiveOutlineWithBlur(srcDst, srcDstCanvas, color, outlineColor, true);
+ public void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas) {
+ applyExpensiveOutlineWithBlur(srcDst, srcDstCanvas, true);
}
- public void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color,
- int outlineColor, boolean clipAlpha) {
+ public void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas,
+ boolean clipAlpha) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD && srcDst.getConfig() != Bitmap.Config.ALPHA_8) {
+ throw new RuntimeException("Outline blue is only supported on alpha bitmaps");
+ }
// We start by removing most of the alpha channel so as to ignore shadows, and
// other types of partial transparency when defining the shape of the object
if (clipAlpha) {
- int[] srcBuffer = new int[srcDst.getWidth() * srcDst.getHeight()];
- srcDst.getPixels(srcBuffer,
- 0, srcDst.getWidth(), 0, 0, srcDst.getWidth(), srcDst.getHeight());
- for (int i = 0; i < srcBuffer.length; i++) {
- final int alpha = srcBuffer[i] >>> 24;
- if (alpha < 188) {
- srcBuffer[i] = 0;
+ byte[] pixels = new byte[srcDst.getWidth() * srcDst.getHeight()];
+ ByteBuffer buffer = ByteBuffer.wrap(pixels);
+ buffer.rewind();
+ srcDst.copyPixelsToBuffer(buffer);
+
+ for (int i = 0; i < pixels.length; i++) {
+ if ((pixels[i] & 0xFF) < 188) {
+ pixels[i] = 0;
}
}
- srcDst.setPixels(srcBuffer,
- 0, srcDst.getWidth(), 0, 0, srcDst.getWidth(), srcDst.getHeight());
+
+ buffer.rewind();
+ srcDst.copyPixelsFromBuffer(buffer);
}
- Bitmap glowShape = srcDst.extractAlpha();
// calculate the outer blur first
mBlurPaint.setMaskFilter(mMediumOuterBlurMaskFilter);
int[] outerBlurOffset = new int[2];
- Bitmap thickOuterBlur = glowShape.extractAlpha(mBlurPaint, outerBlurOffset);
+ Bitmap thickOuterBlur = srcDst.extractAlpha(mBlurPaint, outerBlurOffset);
mBlurPaint.setMaskFilter(mThinOuterBlurMaskFilter);
int[] brightOutlineOffset = new int[2];
- Bitmap brightOutline = glowShape.extractAlpha(mBlurPaint, brightOutlineOffset);
+ Bitmap brightOutline = srcDst.extractAlpha(mBlurPaint, brightOutlineOffset);
// calculate the inner blur
- srcDstCanvas.setBitmap(glowShape);
+ srcDstCanvas.setBitmap(srcDst);
srcDstCanvas.drawColor(0xFF000000, PorterDuff.Mode.SRC_OUT);
mBlurPaint.setMaskFilter(mMediumInnerBlurMaskFilter);
int[] thickInnerBlurOffset = new int[2];
- Bitmap thickInnerBlur = glowShape.extractAlpha(mBlurPaint, thickInnerBlurOffset);
+ Bitmap thickInnerBlur = srcDst.extractAlpha(mBlurPaint, thickInnerBlurOffset);
// mask out the inner blur
srcDstCanvas.setBitmap(thickInnerBlur);
- srcDstCanvas.drawBitmap(glowShape, -thickInnerBlurOffset[0],
+ srcDstCanvas.drawBitmap(srcDst, -thickInnerBlurOffset[0],
-thickInnerBlurOffset[1], mErasePaint);
srcDstCanvas.drawRect(0, 0, -thickInnerBlurOffset[0], thickInnerBlur.getHeight(),
mErasePaint);
@@ -132,14 +139,12 @@ public class HolographicOutlineHelper {
// draw the inner and outer blur
srcDstCanvas.setBitmap(srcDst);
srcDstCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
- mDrawPaint.setColor(color);
srcDstCanvas.drawBitmap(thickInnerBlur, thickInnerBlurOffset[0], thickInnerBlurOffset[1],
mDrawPaint);
srcDstCanvas.drawBitmap(thickOuterBlur, outerBlurOffset[0], outerBlurOffset[1],
mDrawPaint);
// draw the bright outline
- mDrawPaint.setColor(outlineColor);
srcDstCanvas.drawBitmap(brightOutline, brightOutlineOffset[0], brightOutlineOffset[1],
mDrawPaint);
@@ -148,7 +153,6 @@ public class HolographicOutlineHelper {
brightOutline.recycle();
thickOuterBlur.recycle();
thickInnerBlur.recycle();
- glowShape.recycle();
}
Bitmap createMediumDropShadow(BubbleTextView view) {
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index c738480fe..f9424d483 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -25,6 +25,7 @@ import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -69,7 +70,7 @@ public class Hotseat extends FrameLayout
mLauncher = (Launcher) context;
mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
mBackgroundColor = ColorUtils.setAlphaComponent(
- context.getColor(R.color.all_apps_container_color), 0);
+ ContextCompat.getColor(context, R.color.all_apps_container_color), 0);
mBackground = new ColorDrawable(mBackgroundColor);
setBackground(mBackground);
}
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index a49162c8b..d3fb38ede 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -853,8 +853,7 @@ public class IconCache {
values.put(IconDB.COLUMN_ICON_LOW_RES, Utilities.flattenBitmap(lowResIcon));
values.put(IconDB.COLUMN_LABEL, label);
- values.put(IconDB.COLUMN_SYSTEM_STATE,
- mIconProvider.getIconSystemState(mIconProvider.getIconSystemState(packageName)));
+ values.put(IconDB.COLUMN_SYSTEM_STATE, mIconProvider.getIconSystemState(packageName));
return values;
}
diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java
index e136bcd99..398c9d2a2 100644
--- a/src/com/android/launcher3/InfoDropTarget.java
+++ b/src/com/android/launcher3/InfoDropTarget.java
@@ -100,6 +100,7 @@ public class InfoDropTarget extends UninstallDropTarget {
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1;
return developmentSettingsEnabled
&& (info instanceof AppInfo || info instanceof ShortcutInfo
- || info instanceof PendingAddItemInfo || info instanceof LauncherAppWidgetInfo);
+ || info instanceof PendingAddItemInfo || info instanceof LauncherAppWidgetInfo)
+ && info.itemType != LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
}
}
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index df87cc204..d8e58d829 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -33,6 +33,7 @@ import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.Thunk;
import org.json.JSONException;
@@ -146,6 +147,15 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
}
PendingInstallShortcutInfo info = createPendingInfo(context, data);
if (info != null) {
+ if (!info.isLauncherActivity()) {
+ // Since its a custom shortcut, verify that it is safe to launch.
+ if (!PackageManagerHelper.hasPermissionForActivity(
+ context, info.launchIntent, null)) {
+ // Target cannot be launched, or requires some special permission to launch
+ Log.e(TAG, "Ignoring malicious intent " + info.launchIntent.toUri(0));
+ return;
+ }
+ }
queuePendingShortcutInfo(info, context);
}
}
diff --git a/src/com/android/launcher3/ItemInfo.java b/src/com/android/launcher3/ItemInfo.java
index 2a94e55c0..c0c22a325 100644
--- a/src/com/android/launcher3/ItemInfo.java
+++ b/src/com/android/launcher3/ItemInfo.java
@@ -189,10 +189,24 @@ public class ItemInfo {
}
@Override
- public String toString() {
- return "Item(id=" + this.id + " type=" + this.itemType + " container=" + this.container
- + " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX
- + " spanY=" + spanY + " user=" + user + ")";
+ public final String toString() {
+ return getClass().getSimpleName() + "(" + dumpProperties() + ")";
+ }
+
+ protected String dumpProperties() {
+ return "id=" + id
+ + " type=" + itemType
+ + " container=" + container
+ + " screen=" + screenId
+ + " cellX=" + cellX
+ + " cellY=" + cellY
+ + " spanX=" + spanX
+ + " spanY=" + spanY
+ + " minSpanX=" + minSpanX
+ + " minSpanY=" + minSpanY
+ + " rank=" + rank
+ + " user=" + user
+ + " title=" + title;
}
/**
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index e1c64a72d..123c7d8bf 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -35,7 +35,6 @@ import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentCallbacks2;
import android.content.ComponentName;
-import android.content.ContentValues;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.DialogInterface;
@@ -102,6 +101,7 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.dynamicui.ExtractedColors;
import com.android.launcher3.folder.Folder;
@@ -115,10 +115,12 @@ import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.DeepShortcutsContainer;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.util.ActivityResultInfo;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.PackageManagerHelper;
+import com.android.launcher3.util.PendingRequestArgs;
import com.android.launcher3.util.TestingUtils;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.ViewOnDrawExecutor;
@@ -183,12 +185,10 @@ public class Launcher extends Activity
private static final String RUNTIME_STATE_CURRENT_SCREEN = "launcher.current_screen";
// Type: int
private static final String RUNTIME_STATE = "launcher.state";
- // Type: Content Values / parcelable
- private static final String RUNTIME_STATE_PENDING_ADD_ITEM = "launcher.add_item";
- // Type: parcelable
- private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_INFO = "launcher.add_widget_info";
- // Type: parcelable
- private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_ID = "launcher.add_widget_id";
+ // Type: PendingRequestArgs
+ private static final String RUNTIME_STATE_PENDING_REQUEST_ARGS = "launcher.request_args";
+ // Type: ActivityResultInfo
+ private static final String RUNTIME_STATE_PENDING_ACTIVITY_RESULT = "launcher.activity_result";
static final String APPS_VIEW_SHOWN = "launcher.apps_view_shown";
@@ -236,10 +236,6 @@ public class Launcher extends Activity
private AppWidgetManagerCompat mAppWidgetManager;
private LauncherAppWidgetHost mAppWidgetHost;
- @Thunk final ItemInfo mPendingAddInfo = new ItemInfo();
- private LauncherAppWidgetProviderInfo mPendingAddWidgetInfo;
- private int mPendingAddWidgetId = -1;
-
private int[] mTmpAddItemCellCoordinates = new int[2];
@Thunk Hotseat mHotseat;
@@ -269,8 +265,6 @@ public class Launcher extends Activity
@Thunk boolean mWorkspaceLoading = true;
private boolean mPaused = true;
- private boolean mRestoring;
- private boolean mWaitingForResult;
private boolean mOnResumeNeedsLoad;
private ArrayList<Runnable> mBindOnResumeCallbacks = new ArrayList<Runnable>();
@@ -307,7 +301,6 @@ public class Launcher extends Activity
private static final int RESTORE_SCREEN_ORIENTATION_DELAY = 500;
private final ArrayList<Integer> mSynchronouslyBoundPages = new ArrayList<Integer>();
- private static final boolean DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE = false;
// We only want to get the SharedPreferences once since it does an FS stat each time we get
// it from the context.
@@ -351,17 +344,13 @@ public class Launcher extends Activity
}
};
- private static PendingAddArguments sPendingAddItem;
-
- @Thunk static class PendingAddArguments {
- int requestCode;
- Intent intent;
- long container;
- long screenId;
- int cellX;
- int cellY;
- int appWidgetId;
- }
+ // Activity result which needs to be processed after workspace has loaded.
+ private ActivityResultInfo mPendingActivityResult;
+ /**
+ * Holds extra information required to handle a result from an external call, like
+ * {@link #startActivityForResult(Intent, int)} or {@link #requestPermissions(String[], int)}
+ */
+ private PendingRequestArgs mPendingRequestArgs;
private UserEventDispatcher mUserEventDispatcher;
@@ -452,20 +441,14 @@ public class Launcher extends Activity
Trace.endSection();
}
- if (!mRestoring) {
- if (DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE) {
- // If the user leaves launcher, then we should just load items asynchronously when
- // they return.
- mModel.startLoader(PagedView.INVALID_RESTORE_PAGE);
- } else {
- // We only load the page synchronously if the user rotates (or triggers a
- // configuration change) while launcher is in the foreground
- if (!mModel.startLoader(mWorkspace.getRestorePage())) {
- // If we are not binding synchronously, show a fade in animation when
- // the first page bind completes.
- mDragLayer.setAlpha(0);
- }
- }
+ // We only load the page synchronously if the user rotates (or triggers a
+ // configuration change) while launcher is in the foreground
+ if (!mModel.startLoader(mWorkspace.getRestorePage())) {
+ // If we are not binding synchronously, show a fade in animation when
+ // the first page bind completes.
+ mDragLayer.setAlpha(0);
+ } else {
+ setWorkspaceLoading(true);
}
// For handling default keys
@@ -658,53 +641,61 @@ public class Launcher extends Activity
* Returns whether we should delay spring loaded mode -- for shortcuts and widgets that have
* a configuration step, this allows the proper animations to run after other transitions.
*/
- private long completeAdd(PendingAddArguments args) {
- long screenId = args.screenId;
- if (args.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
+ private long completeAdd(
+ int requestCode, Intent intent, int appWidgetId, PendingRequestArgs info) {
+ long screenId = info.screenId;
+ if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
// When the screen id represents an actual screen (as opposed to a rank) we make sure
// that the drop page actually exists.
- screenId = ensurePendingDropLayoutExists(args.screenId);
+ screenId = ensurePendingDropLayoutExists(info.screenId);
}
- switch (args.requestCode) {
+ switch (requestCode) {
case REQUEST_CREATE_SHORTCUT:
- completeAddShortcut(args.intent, args.container, screenId, args.cellX,
- args.cellY);
+ completeAddShortcut(intent, info.container, screenId, info.cellX, info.cellY, info);
break;
case REQUEST_CREATE_APPWIDGET:
- completeAddAppWidget(args.appWidgetId, args.container, screenId, null, null);
+ completeAddAppWidget(appWidgetId, info, null, null);
break;
case REQUEST_RECONFIGURE_APPWIDGET:
- completeRestoreAppWidget(args.appWidgetId, LauncherAppWidgetInfo.RESTORE_COMPLETED);
+ completeRestoreAppWidget(appWidgetId, LauncherAppWidgetInfo.RESTORE_COMPLETED);
break;
case REQUEST_BIND_PENDING_APPWIDGET: {
- int widgetId = args.appWidgetId;
- LauncherAppWidgetInfo info =
+ int widgetId = appWidgetId;
+ LauncherAppWidgetInfo widgetInfo =
completeRestoreAppWidget(widgetId, LauncherAppWidgetInfo.FLAG_UI_NOT_READY);
- if (info != null) {
+ if (widgetInfo != null) {
// Since the view was just bound, also launch the configure activity if needed
LauncherAppWidgetProviderInfo provider = mAppWidgetManager
.getLauncherAppWidgetInfo(widgetId);
if (provider != null && provider.configure != null) {
- startRestoredWidgetReconfigActivity(provider, info);
+ startRestoredWidgetReconfigActivity(provider, widgetInfo);
}
}
break;
}
}
- // Before adding this resetAddInfo(), after a shortcut was added to a workspace screen,
- // if you turned the screen off and then back while in All Apps, Launcher would not
- // return to the workspace. Clearing mAddInfo.container here fixes this issue
- resetAddInfo();
+
return screenId;
}
private void handleActivityResult(
final int requestCode, final int resultCode, final Intent data) {
+ if (isWorkspaceLoading()) {
+ // process the result once the workspace has loaded.
+ mPendingActivityResult = new ActivityResultInfo(requestCode, resultCode, data);
+ return;
+ }
+ mPendingActivityResult = null;
+
// Reset the startActivity waiting flag
- setWaitingForResult(false);
- final int pendingAddWidgetId = mPendingAddWidgetId;
- mPendingAddWidgetId = -1;
+ final PendingRequestArgs requestArgs = mPendingRequestArgs;
+ setWaitingForResult(null);
+ if (requestArgs == null) {
+ return;
+ }
+
+ final int pendingAddWidgetId = requestArgs.getWidgetId();
Runnable exitSpringLoaded = new Runnable() {
@Override
@@ -719,12 +710,14 @@ public class Launcher extends Activity
final int appWidgetId = data != null ?
data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1;
if (resultCode == RESULT_CANCELED) {
- completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId);
+ completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId, requestArgs);
mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
} else if (resultCode == RESULT_OK) {
- addAppWidgetImpl(appWidgetId, mPendingAddInfo, null,
- mPendingAddWidgetInfo, ON_ACTIVITY_RESULT_ANIMATION_DELAY);
+ addAppWidgetImpl(
+ appWidgetId, requestArgs, null,
+ requestArgs.getWidgetProvider(),
+ ON_ACTIVITY_RESULT_ANIMATION_DELAY);
}
return;
} else if (requestCode == REQUEST_PICK_WALLPAPER) {
@@ -740,7 +733,6 @@ public class Launcher extends Activity
boolean isWidgetDrop = (requestCode == REQUEST_PICK_APPWIDGET ||
requestCode == REQUEST_CREATE_APPWIDGET);
- final boolean workspaceLocked = isWorkspaceLocked();
// We have special handling for widgets
if (isWidgetDrop) {
final int appWidgetId;
@@ -757,46 +749,36 @@ public class Launcher extends Activity
Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not " +
"returned from the widget configuration activity.");
result = RESULT_CANCELED;
- completeTwoStageWidgetDrop(result, appWidgetId);
+ completeTwoStageWidgetDrop(result, appWidgetId, requestArgs);
final Runnable onComplete = new Runnable() {
@Override
public void run() {
exitSpringLoadedDragModeDelayed(false, 0, null);
}
};
- if (workspaceLocked) {
- // No need to remove the empty screen if we're mid-binding, as the
- // the bind will not add the empty screen.
- mWorkspace.postDelayed(onComplete, ON_ACTIVITY_RESULT_ANIMATION_DELAY);
- } else {
- mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete,
- ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
- }
- } else {
- if (!workspaceLocked) {
- if (mPendingAddInfo.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
- // When the screen id represents an actual screen (as opposed to a rank)
- // we make sure that the drop page actually exists.
- mPendingAddInfo.screenId =
- ensurePendingDropLayoutExists(mPendingAddInfo.screenId);
- }
- final CellLayout dropLayout = mWorkspace.getScreenWithId(mPendingAddInfo.screenId);
- dropLayout.setDropPending(true);
- final Runnable onComplete = new Runnable() {
- @Override
- public void run() {
- completeTwoStageWidgetDrop(resultCode, appWidgetId);
- dropLayout.setDropPending(false);
- }
- };
- mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete,
- ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
- } else {
- PendingAddArguments args = preparePendingAddArgs(requestCode, data, appWidgetId,
- mPendingAddInfo);
- sPendingAddItem = args;
+ mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete,
+ ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
+ } else {
+ if (requestArgs.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
+ // When the screen id represents an actual screen (as opposed to a rank)
+ // we make sure that the drop page actually exists.
+ requestArgs.screenId =
+ ensurePendingDropLayoutExists(requestArgs.screenId);
}
+ final CellLayout dropLayout =
+ mWorkspace.getScreenWithId(requestArgs.screenId);
+
+ dropLayout.setDropPending(true);
+ final Runnable onComplete = new Runnable() {
+ @Override
+ public void run() {
+ completeTwoStageWidgetDrop(resultCode, appWidgetId, requestArgs);
+ dropLayout.setDropPending(false);
+ }
+ };
+ mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete,
+ ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
}
return;
}
@@ -805,13 +787,7 @@ public class Launcher extends Activity
|| requestCode == REQUEST_BIND_PENDING_APPWIDGET) {
if (resultCode == RESULT_OK) {
// Update the widget view.
- PendingAddArguments args = preparePendingAddArgs(requestCode, data,
- pendingAddWidgetId, mPendingAddInfo);
- if (workspaceLocked) {
- sPendingAddItem = args;
- } else {
- completeAdd(args);
- }
+ completeAdd(requestCode, data, pendingAddWidgetId, requestArgs);
}
// Leave the widget in the pending state if the user canceled the configure.
return;
@@ -819,23 +795,17 @@ public class Launcher extends Activity
if (requestCode == REQUEST_CREATE_SHORTCUT) {
// Handle custom shortcuts created using ACTION_CREATE_SHORTCUT.
- if (resultCode == RESULT_OK && mPendingAddInfo.container != ItemInfo.NO_ID) {
- final PendingAddArguments args = preparePendingAddArgs(requestCode, data, -1,
- mPendingAddInfo);
- if (isWorkspaceLocked()) {
- sPendingAddItem = args;
- } else {
- completeAdd(args);
- mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
- ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
- }
+ if (resultCode == RESULT_OK && requestArgs.container != ItemInfo.NO_ID) {
+ completeAdd(requestCode, data, -1, requestArgs);
+ mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
+ ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
+
} else if (resultCode == RESULT_CANCELED) {
mWorkspace.removeExtraEmptyScreenDelayed(true, exitSpringLoaded,
ON_ACTIVITY_RESULT_ANIMATION_DELAY, false);
}
}
mDragLayer.clearAnimatedView();
-
}
@Override
@@ -850,15 +820,18 @@ public class Launcher extends Activity
/** @Override for MNC */
public void onRequestPermissionsResult(int requestCode, String[] permissions,
int[] grantResults) {
- if (requestCode == REQUEST_PERMISSION_CALL_PHONE && sPendingAddItem != null
- && sPendingAddItem.requestCode == REQUEST_PERMISSION_CALL_PHONE) {
+ PendingRequestArgs pendingArgs = mPendingRequestArgs;
+ if (requestCode == REQUEST_PERMISSION_CALL_PHONE && pendingArgs != null
+ && pendingArgs.getRequestCode() == REQUEST_PERMISSION_CALL_PHONE) {
+ setWaitingForResult(null);
+
View v = null;
- CellLayout layout = getCellLayout(sPendingAddItem.container, sPendingAddItem.screenId);
+ CellLayout layout = getCellLayout(pendingArgs.container, pendingArgs.screenId);
if (layout != null) {
- v = layout.getChildAt(sPendingAddItem.cellX, sPendingAddItem.cellY);
+ v = layout.getChildAt(pendingArgs.cellX, pendingArgs.cellY);
}
- Intent intent = sPendingAddItem.intent;
- sPendingAddItem = null;
+ Intent intent = pendingArgs.getPendingIntent();
+
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startActivitySafely(v, intent, null);
@@ -874,19 +847,6 @@ public class Launcher extends Activity
}
}
- private PendingAddArguments preparePendingAddArgs(int requestCode, Intent data, int
- appWidgetId, ItemInfo info) {
- PendingAddArguments args = new PendingAddArguments();
- args.requestCode = requestCode;
- args.intent = data;
- args.container = info.container;
- args.screenId = info.screenId;
- args.cellX = info.cellX;
- args.cellY = info.cellY;
- args.appWidgetId = appWidgetId;
- return args;
- }
-
/**
* Check to see if a given screen id exists. If not, create it at the end, return the new id.
*
@@ -905,8 +865,9 @@ public class Launcher extends Activity
}
}
- @Thunk void completeTwoStageWidgetDrop(final int resultCode, final int appWidgetId) {
- CellLayout cellLayout = mWorkspace.getScreenWithId(mPendingAddInfo.screenId);
+ @Thunk void completeTwoStageWidgetDrop(
+ final int resultCode, final int appWidgetId, final PendingRequestArgs requestArgs) {
+ CellLayout cellLayout = mWorkspace.getScreenWithId(requestArgs.screenId);
Runnable onCompleteRunnable = null;
int animationType = 0;
@@ -914,13 +875,12 @@ public class Launcher extends Activity
if (resultCode == RESULT_OK) {
animationType = Workspace.COMPLETE_TWO_STAGE_WIDGET_DROP_ANIMATION;
final AppWidgetHostView layout = mAppWidgetHost.createView(this, appWidgetId,
- mPendingAddWidgetInfo);
+ requestArgs.getWidgetProvider());
boundWidget = layout;
onCompleteRunnable = new Runnable() {
@Override
public void run() {
- completeAddAppWidget(appWidgetId, mPendingAddInfo.container,
- mPendingAddInfo.screenId, layout, null);
+ completeAddAppWidget(appWidgetId, requestArgs, layout, null);
exitSpringLoadedDragModeDelayed((resultCode != RESULT_CANCELED),
EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null);
}
@@ -930,7 +890,7 @@ public class Launcher extends Activity
animationType = Workspace.CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION;
}
if (mDragLayer.getAnimatedView() != null) {
- mWorkspace.animateWidgetDrop(mPendingAddInfo, cellLayout,
+ mWorkspace.animateWidgetDrop(requestArgs, cellLayout,
(DragView) mDragLayer.getAnimatedView(), onCompleteRunnable,
animationType, boundWidget, true);
} else if (onCompleteRunnable != null) {
@@ -991,17 +951,16 @@ public class Launcher extends Activity
// view after launching an app, as they may be depending on the UI to be static to
// switch to another app, otherwise, if it was
showAppsView(false /* animated */, !launchedFromApp /* updatePredictedApps */,
- false /* focusSearchBar */);
+ mAppsView.shouldRestoreImeState() /* focusSearchBar */);
} else if (mOnResumeState == State.WIDGETS) {
showWidgetsView(false, false);
}
mOnResumeState = State.NONE;
mPaused = false;
- if (mRestoring || mOnResumeNeedsLoad) {
+ if (mOnResumeNeedsLoad) {
setWorkspaceLoading(true);
mModel.startLoader(getCurrentWorkspaceScreen());
- mRestoring = false;
mOnResumeNeedsLoad = false;
}
if (mBindOnResumeCallbacks.size() > 0) {
@@ -1273,7 +1232,8 @@ public class Launcher extends Activity
return mDefaultKeySsb.toString();
}
- private void clearTypedText() {
+ @Override
+ public void clearTypedText() {
mDefaultKeySsb.clear();
mDefaultKeySsb.clearSpans();
Selection.setSelection(mDefaultKeySsb, 0);
@@ -1316,18 +1276,12 @@ public class Launcher extends Activity
mWorkspace.setRestorePage(currentScreen);
}
- ContentValues itemValues = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_ITEM);
- if (itemValues != null) {
- mPendingAddInfo.readFromValues(itemValues);
- AppWidgetProviderInfo info = savedState.getParcelable(
- RUNTIME_STATE_PENDING_ADD_WIDGET_INFO);
- mPendingAddWidgetInfo = info == null ?
- null : LauncherAppWidgetProviderInfo.fromProviderInfo(this, info);
-
- mPendingAddWidgetId = savedState.getInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID);
- setWaitingForResult(true);
- mRestoring = true;
+ PendingRequestArgs requestArgs = savedState.getParcelable(RUNTIME_STATE_PENDING_REQUEST_ARGS);
+ if (requestArgs != null) {
+ setWaitingForResult(requestArgs);
}
+
+ mPendingActivityResult = savedState.getParcelable(RUNTIME_STATE_PENDING_ACTIVITY_RESULT);
}
/**
@@ -1503,12 +1457,19 @@ public class Launcher extends Activity
* @param data The intent describing the shortcut.
*/
private void completeAddShortcut(Intent data, long container, long screenId, int cellX,
- int cellY) {
+ int cellY, PendingRequestArgs args) {
int[] cellXY = mTmpAddItemCellCoordinates;
CellLayout layout = getCellLayout(container, screenId);
ShortcutInfo info = InstallShortcutReceiver.fromShortcutIntent(this, data);
- if (info == null) {
+ if (info == null || args.getRequestCode() != REQUEST_CREATE_SHORTCUT ||
+ args.getPendingIntent().getComponent() == null) {
+ return;
+ }
+ if (!PackageManagerHelper.hasPermissionForActivity(
+ this, info.intent, args.getPendingIntent().getComponent().getPackageName())) {
+ // The app is trying to add a shortcut without sufficient permissions
+ Log.e(TAG, "Ignoring malicious intent " + info.intent.toUri(0));
return;
}
final View view = createShortcut(info);
@@ -1542,10 +1503,8 @@ public class Launcher extends Activity
LauncherModel.addItemToDatabase(this, info, container, screenId, cellXY[0], cellXY[1]);
- if (!mRestoring) {
- mWorkspace.addInScreen(view, container, screenId, cellXY[0], cellXY[1], 1, 1,
- isWorkspaceLocked());
- }
+ mWorkspace.addInScreen(view, container, screenId, cellXY[0], cellXY[1], 1, 1,
+ isWorkspaceLocked());
}
/**
@@ -1553,10 +1512,9 @@ public class Launcher extends Activity
*
* @param appWidgetId The app widget id
*/
- @Thunk void completeAddAppWidget(int appWidgetId, long container, long screenId,
+ @Thunk void completeAddAppWidget(int appWidgetId, ItemInfo itemInfo,
AppWidgetHostView hostView, LauncherAppWidgetProviderInfo appWidgetInfo) {
- ItemInfo info = mPendingAddInfo;
if (appWidgetInfo == null) {
appWidgetInfo = mAppWidgetManager.getLauncherAppWidgetInfo(appWidgetId);
}
@@ -1567,24 +1525,21 @@ public class Launcher extends Activity
LauncherAppWidgetInfo launcherInfo;
launcherInfo = new LauncherAppWidgetInfo(appWidgetId, appWidgetInfo.provider);
- launcherInfo.spanX = info.spanX;
- launcherInfo.spanY = info.spanY;
- launcherInfo.minSpanX = info.minSpanX;
- launcherInfo.minSpanY = info.minSpanY;
+ launcherInfo.spanX = itemInfo.spanX;
+ launcherInfo.spanY = itemInfo.spanY;
+ launcherInfo.minSpanX = itemInfo.minSpanX;
+ launcherInfo.minSpanY = itemInfo.minSpanY;
launcherInfo.user = mAppWidgetManager.getUser(appWidgetInfo);
LauncherModel.addItemToDatabase(this, launcherInfo,
- container, screenId, info.cellX, info.cellY);
+ itemInfo.container, itemInfo.screenId, itemInfo.cellX, itemInfo.cellY);
- if (!mRestoring) {
- if (hostView == null) {
- // Perform actual inflation because we're live
- hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
- }
- hostView.setVisibility(View.VISIBLE);
- addAppWidgetToWorkspace(hostView, launcherInfo, appWidgetInfo, isWorkspaceLocked());
+ if (hostView == null) {
+ // Perform actual inflation because we're live
+ hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
}
- resetAddInfo();
+ hostView.setVisibility(View.VISIBLE);
+ addAppWidgetToWorkspace(hostView, launcherInfo, appWidgetInfo, isWorkspaceLocked());
}
private void addAppWidgetToWorkspace(
@@ -1615,8 +1570,7 @@ public class Launcher extends Activity
// Reset AllApps to its initial state only if we are not in the middle of
// processing a multi-step drop
- if (mAppsView != null && mWidgetsView != null &&
- mPendingAddInfo.container == ItemInfo.NO_ID) {
+ if (mAppsView != null && mWidgetsView != null && mPendingRequestArgs == null) {
if (!showWorkspace(false)) {
// If we are already on the workspace, then manually reset all apps
mAppsView.reset();
@@ -1828,7 +1782,7 @@ public class Launcher extends Activity
getWindow().closeAllPanels();
// Whatever we were doing is hereby canceled.
- setWaitingForResult(false);
+ setWaitingForResult(null);
}
@Override
@@ -1946,13 +1900,11 @@ public class Launcher extends Activity
closeFolder(false);
closeShortcutsContainer(false);
- if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screenId > -1 &&
- mWaitingForResult) {
- ContentValues itemValues = new ContentValues();
- mPendingAddInfo.writeToValues(itemValues);
- outState.putParcelable(RUNTIME_STATE_PENDING_ADD_ITEM, itemValues);
- outState.putParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO, mPendingAddWidgetInfo);
- outState.putInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID, mPendingAddWidgetId);
+ if (mPendingRequestArgs != null) {
+ outState.putParcelable(RUNTIME_STATE_PENDING_REQUEST_ARGS, mPendingRequestArgs);
+ }
+ if (mPendingActivityResult != null) {
+ outState.putParcelable(RUNTIME_STATE_PENDING_ACTIVITY_RESULT, mPendingActivityResult);
}
if (mLauncherCallbacks != null) {
@@ -2015,14 +1967,12 @@ public class Launcher extends Activity
@Override
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
- onStartForResult(requestCode);
super.startActivityForResult(intent, requestCode, options);
}
@Override
public void startIntentSenderForResult (IntentSender intent, int requestCode,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options) {
- onStartForResult(requestCode);
try {
super.startIntentSenderForResult(intent, requestCode,
fillInIntent, flagsMask, flagsValues, extraFlags, options);
@@ -2031,12 +1981,6 @@ public class Launcher extends Activity
}
}
- private void onStartForResult(int requestCode) {
- if (requestCode >= 0) {
- setWaitingForResult(true);
- }
- }
-
/**
* Indicates that we want global search for this activity by setting the globalSearch
* argument for {@link #startSearch} to true.
@@ -2054,13 +1998,10 @@ public class Launcher extends Activity
appSearchData.putString("source", "launcher-search");
}
- // TODO send proper bounds.
- Rect sourceBounds = null;
-
- boolean clearTextImmediately = startSearch(initialQuery, selectInitialQuery,
- appSearchData, sourceBounds);
- if (clearTextImmediately) {
- clearTypedText();
+ if (mLauncherCallbacks == null ||
+ !mLauncherCallbacks.startSearch(initialQuery, selectInitialQuery, appSearchData)) {
+ // Starting search from the callbacks failed. Start the default global search.
+ startGlobalSearch(initialQuery, selectInitialQuery, appSearchData, null);
}
// We need to show the workspace after starting the search
@@ -2068,28 +2009,9 @@ public class Launcher extends Activity
}
/**
- * Start a text search.
- *
- * @return {@code true} if the search will start immediately, so any further keypresses
- * will be handled directly by the search UI. {@code false} if {@link Launcher} should continue
- * to buffer keypresses.
- */
- public boolean startSearch(String initialQuery,
- boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds) {
- if (mLauncherCallbacks != null && mLauncherCallbacks.providesSearch()) {
- return mLauncherCallbacks.startSearch(initialQuery, selectInitialQuery, appSearchData,
- sourceBounds);
- }
-
- startGlobalSearch(initialQuery, selectInitialQuery,
- appSearchData, sourceBounds);
- return false;
- }
-
- /**
* Starts the global search activity. This code is a copied from SearchManager
*/
- private void startGlobalSearch(String initialQuery,
+ public void startGlobalSearch(String initialQuery,
boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds) {
final SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
@@ -2147,7 +2069,7 @@ public class Launcher extends Activity
}
public boolean isWorkspaceLocked() {
- return mWorkspaceLoading || mWaitingForResult;
+ return mWorkspaceLoading || mPendingRequestArgs != null;
}
public boolean isWorkspaceLoading() {
@@ -2162,9 +2084,9 @@ public class Launcher extends Activity
}
}
- private void setWaitingForResult(boolean value) {
+ private void setWaitingForResult(PendingRequestArgs args) {
boolean isLocked = isWorkspaceLocked();
- mWaitingForResult = value;
+ mPendingRequestArgs = args;
if (isLocked != isWorkspaceLocked()) {
onWorkspaceLockedChanged();
}
@@ -2176,33 +2098,23 @@ public class Launcher extends Activity
}
}
- private void resetAddInfo() {
- mPendingAddInfo.container = ItemInfo.NO_ID;
- mPendingAddInfo.screenId = -1;
- mPendingAddInfo.cellX = mPendingAddInfo.cellY = -1;
- mPendingAddInfo.spanX = mPendingAddInfo.spanY = -1;
- mPendingAddInfo.minSpanX = mPendingAddInfo.minSpanY = 1;
- }
-
- void addAppWidgetFromDropImpl(final int appWidgetId, final ItemInfo info, final
- AppWidgetHostView boundWidget, final LauncherAppWidgetProviderInfo appWidgetInfo) {
+ void addAppWidgetFromDropImpl(int appWidgetId, ItemInfo info, AppWidgetHostView boundWidget,
+ LauncherAppWidgetProviderInfo appWidgetInfo) {
if (LOGD) {
Log.d(TAG, "Adding widget from drop");
}
addAppWidgetImpl(appWidgetId, info, boundWidget, appWidgetInfo, 0);
}
- void addAppWidgetImpl(final int appWidgetId, final ItemInfo info,
- final AppWidgetHostView boundWidget, final LauncherAppWidgetProviderInfo appWidgetInfo,
+ void addAppWidgetImpl(int appWidgetId, ItemInfo info,
+ AppWidgetHostView boundWidget, LauncherAppWidgetProviderInfo appWidgetInfo,
int delay) {
if (appWidgetInfo.configure != null) {
- mPendingAddWidgetInfo = appWidgetInfo;
- mPendingAddWidgetId = appWidgetId;
+ setWaitingForResult(PendingRequestArgs.forWidgetInfo(appWidgetId, appWidgetInfo, info));
// Launch over to configure widget, if needed
mAppWidgetManager.startConfigActivity(appWidgetInfo, appWidgetId, this,
mAppWidgetHost, REQUEST_CREATE_APPWIDGET);
-
} else {
// Otherwise just add it
Runnable onComplete = new Runnable() {
@@ -2213,8 +2125,7 @@ public class Launcher extends Activity
null);
}
};
- completeAddAppWidget(appWidgetId, info.container, info.screenId, boundWidget,
- appWidgetInfo);
+ completeAddAppWidget(appWidgetId, info, boundWidget, appWidgetInfo);
mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete, delay, false);
}
}
@@ -2227,17 +2138,22 @@ public class Launcher extends Activity
public void addPendingItem(PendingAddItemInfo info, long container, long screenId,
int[] cell, int spanX, int spanY) {
+ info.container = container;
+ info.screenId = screenId;
+ if (cell != null) {
+ info.cellX = cell[0];
+ info.cellY = cell[1];
+ }
+ info.spanX = spanX;
+ info.spanY = spanY;
+
switch (info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET:
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
- int span[] = new int[2];
- span[0] = spanX;
- span[1] = spanY;
- addAppWidgetFromDrop((PendingAddWidgetInfo) info,
- container, screenId, cell, span);
+ addAppWidgetFromDrop((PendingAddWidgetInfo) info);
break;
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
- processShortcutFromDrop(info.componentName, container, screenId, cell);
+ processShortcutFromDrop(info);
break;
default:
throw new IllegalStateException("Unknown item type: " + info.itemType);
@@ -2246,51 +2162,17 @@ public class Launcher extends Activity
/**
* Process a shortcut drop.
- *
- * @param componentName The name of the component
- * @param screenId The ID of the screen where it should be added
- * @param cell The cell it should be added to, optional
*/
- private void processShortcutFromDrop(ComponentName componentName, long container, long screenId,
- int[] cell) {
- resetAddInfo();
- mPendingAddInfo.container = container;
- mPendingAddInfo.screenId = screenId;
-
- if (cell != null) {
- mPendingAddInfo.cellX = cell[0];
- mPendingAddInfo.cellY = cell[1];
- }
-
- Intent createShortcutIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
- createShortcutIntent.setComponent(componentName);
- Utilities.startActivityForResultSafely(this, createShortcutIntent, REQUEST_CREATE_SHORTCUT);
+ private void processShortcutFromDrop(PendingAddItemInfo info) {
+ Intent intent = new Intent(Intent.ACTION_CREATE_SHORTCUT).setComponent(info.componentName);
+ setWaitingForResult(PendingRequestArgs.forIntent(REQUEST_CREATE_SHORTCUT, intent, info));
+ Utilities.startActivityForResultSafely(this, intent, REQUEST_CREATE_SHORTCUT);
}
/**
* Process a widget drop.
- *
- * @param info The PendingAppWidgetInfo of the widget being added.
- * @param screenId The ID of the screen where it should be added
- * @param cell The cell it should be added to, optional
*/
- private void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId,
- int[] cell, int[] span) {
- resetAddInfo();
- mPendingAddInfo.container = info.container = container;
- mPendingAddInfo.screenId = info.screenId = screenId;
- mPendingAddInfo.minSpanX = info.minSpanX;
- mPendingAddInfo.minSpanY = info.minSpanY;
-
- if (cell != null) {
- mPendingAddInfo.cellX = cell[0];
- mPendingAddInfo.cellY = cell[1];
- }
- if (span != null) {
- mPendingAddInfo.spanX = span[0];
- mPendingAddInfo.spanY = span[1];
- }
-
+ private void addAppWidgetFromDrop(PendingAddWidgetInfo info) {
AppWidgetHostView hostView = info.boundWidget;
int appWidgetId;
if (hostView != null) {
@@ -2316,11 +2198,11 @@ public class Launcher extends Activity
if (success) {
addAppWidgetFromDropImpl(appWidgetId, info, null, info.info);
} else {
- mPendingAddWidgetInfo = info.info;
+ setWaitingForResult(PendingRequestArgs.forWidgetInfo(appWidgetId, info.info, info));
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
- mAppWidgetManager.getUser(mPendingAddWidgetInfo)
+ mAppWidgetManager.getUser(info.info)
.addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
// TODO: we need to make sure that this accounts for the options bundle.
// intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
@@ -2539,14 +2421,13 @@ public class Launcher extends Activity
LauncherAppWidgetProviderInfo appWidgetInfo =
mAppWidgetManager.findProvider(info.providerName, info.user);
if (appWidgetInfo != null) {
- mPendingAddWidgetId = info.appWidgetId;
- mPendingAddInfo.copyFrom(info);
- mPendingAddWidgetInfo = appWidgetInfo;
+ setWaitingForResult(PendingRequestArgs
+ .forWidgetInfo(info.appWidgetId, appWidgetInfo, info));
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mPendingAddWidgetId);
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, info.appWidgetId);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, appWidgetInfo.provider);
- mAppWidgetManager.getUser(mPendingAddWidgetInfo)
+ mAppWidgetManager.getUser(appWidgetInfo)
.addToIntent(intent, AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
startActivityForResult(intent, REQUEST_BIND_PENDING_APPWIDGET);
}
@@ -2575,9 +2456,7 @@ public class Launcher extends Activity
private void startRestoredWidgetReconfigActivity(
LauncherAppWidgetProviderInfo provider, LauncherAppWidgetInfo info) {
- mPendingAddWidgetInfo = provider;
- mPendingAddInfo.copyFrom(info);
- mPendingAddWidgetId = info.appWidgetId;
+ setWaitingForResult(PendingRequestArgs.forWidgetInfo(info.appWidgetId, provider, info));
mAppWidgetManager.startConfigActivity(provider,
info.appWidgetId, this, mAppWidgetHost, REQUEST_RECONFIGURE_APPWIDGET);
}
@@ -2747,6 +2626,7 @@ public class Launcher extends Activity
int pageScroll = mWorkspace.getScrollForPage(mWorkspace.getPageNearestToCenterOfScreen());
float offset = mWorkspace.mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);
+ setWaitingForResult(new PendingRequestArgs(new ItemInfo()));
Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER)
.setPackage(pickerPackage)
.putExtra(Utilities.EXTRA_WALLPAPER_OFFSET, offset);
@@ -2863,9 +2743,9 @@ public class Launcher extends Activity
&& Intent.ACTION_CALL.equals(intent.getAction())
&& checkSelfPermission(Manifest.permission.CALL_PHONE) !=
PackageManager.PERMISSION_GRANTED) {
- // TODO: Rename sPendingAddItem to a generic name.
- sPendingAddItem = preparePendingAddArgs(REQUEST_PERMISSION_CALL_PHONE, intent,
- 0, info);
+
+ setWaitingForResult(PendingRequestArgs
+ .forIntent(REQUEST_PERMISSION_CALL_PHONE, intent, info));
requestPermissions(new String[]{Manifest.permission.CALL_PHONE},
REQUEST_PERMISSION_CALL_PHONE);
} else {
@@ -3150,6 +3030,14 @@ public class Launcher extends Activity
}
}
+ public View getTopFloatingView() {
+ View topView = getOpenShortcutsContainer();
+ if (topView == null) {
+ topView = getWorkspace().getOpenFolder();
+ }
+ return topView;
+ }
+
/**
* @return The open shortcuts container, or null if there is none
*/
@@ -3199,7 +3087,7 @@ public class Launcher extends Activity
ItemInfo info = (ItemInfo) v.getTag();
longClickCellInfo = new CellLayout.CellInfo(v, info);
itemUnderLongClick = longClickCellInfo.cell;
- resetAddInfo();
+ mPendingRequestArgs = null;
}
// The hotseat touch handling does not go through Workspace, and we always allow long press
@@ -3222,7 +3110,7 @@ public class Launcher extends Activity
longClickCellInfo.cellX, longClickCellInfo.cellY));
if (!(itemUnderLongClick instanceof Folder || isAllAppsButton)) {
// User long pressed on an item
- mWorkspace.startDrag(longClickCellInfo);
+ mWorkspace.startDrag(longClickCellInfo, new DragOptions());
}
}
}
@@ -3517,10 +3405,6 @@ public class Launcher extends Activity
// TODO
}
- public boolean launcherCallbacksProvidesSearch() {
- return (mLauncherCallbacks != null && mLauncherCallbacks.providesSearch());
- }
-
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
final boolean result = super.dispatchPopulateAccessibilityEvent(event);
@@ -4074,21 +3958,10 @@ public class Launcher extends Activity
setWorkspaceLoading(false);
- // If we received the result of any pending adds while the loader was running (e.g. the
- // widget configuration forced an orientation change), process them now.
- if (sPendingAddItem != null) {
- final long screenId = completeAdd(sPendingAddItem);
-
- // TODO: this moves the user to the page where the pending item was added. Ideally,
- // the screen would be guaranteed to exist after bind, and the page would be set through
- // the workspace restore process.
- mWorkspace.post(new Runnable() {
- @Override
- public void run() {
- mWorkspace.snapToScreenId(screenId);
- }
- });
- sPendingAddItem = null;
+ if (mPendingActivityResult != null) {
+ handleActivityResult(mPendingActivityResult.requestCode,
+ mPendingActivityResult.resultCode, mPendingActivityResult.data);
+ mPendingActivityResult = null;
}
InstallShortcutReceiver.disableAndFlushInstallQueue(this);
@@ -4171,6 +4044,10 @@ public class Launcher extends Activity
return Collections.EMPTY_LIST;
}
ComponentName component = info.getTargetComponent();
+ if (component == null) {
+ return Collections.EMPTY_LIST;
+ }
+
List<String> ids = mDeepShortcutMap.get(new ComponentKey(component, info.user));
return ids == null ? Collections.EMPTY_LIST : ids;
}
@@ -4500,8 +4377,8 @@ public class Launcher extends Activity
Log.d(TAG, "BEGIN launcher3 dump state for launcher " + this);
Log.d(TAG, "mSavedState=" + mSavedState);
Log.d(TAG, "mWorkspaceLoading=" + mWorkspaceLoading);
- Log.d(TAG, "mRestoring=" + mRestoring);
- Log.d(TAG, "mWaitingForResult=" + mWaitingForResult);
+ Log.d(TAG, "mPendingRequestArgs=" + mPendingRequestArgs);
+ Log.d(TAG, "mPendingActivityResult=" + mPendingActivityResult);
mModel.dumpState();
// TODO(hyunyoungs): add mWidgetsView.dumpState(); or mWidgetsModel.dumpState();
diff --git a/src/com/android/launcher3/LauncherAppWidgetInfo.java b/src/com/android/launcher3/LauncherAppWidgetInfo.java
index f22c2a474..66d895726 100644
--- a/src/com/android/launcher3/LauncherAppWidgetInfo.java
+++ b/src/com/android/launcher3/LauncherAppWidgetInfo.java
@@ -143,8 +143,8 @@ public class LauncherAppWidgetInfo extends ItemInfo {
}
@Override
- public String toString() {
- return "AppWidget(id=" + Integer.toString(appWidgetId) + ")";
+ protected String dumpProperties() {
+ return super.dumpProperties() + " appWidgetId=" + appWidgetId;
}
public final boolean isWidgetIdAllocated() {
diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java
index 4a58e51de..6394b9052 100644
--- a/src/com/android/launcher3/LauncherCallbacks.java
+++ b/src/com/android/launcher3/LauncherCallbacks.java
@@ -79,9 +79,11 @@ public interface LauncherCallbacks {
@Deprecated
public void onWorkspaceLockedChanged();
- public boolean providesSearch();
- public boolean startSearch(String initialQuery, boolean selectInitialQuery,
- Bundle appSearchData, Rect sourceBounds);
+ /**
+ * Starts a search with {@param initialQuery}. Return false if search was not started.
+ */
+ public boolean startSearch(
+ String initialQuery, boolean selectInitialQuery, Bundle appSearchData);
public boolean hasCustomContentToLeft();
public void populateCustomContentContainer();
public View getQsbBar();
diff --git a/src/com/android/launcher3/LauncherExterns.java b/src/com/android/launcher3/LauncherExterns.java
index c7a8668de..887859cb0 100644
--- a/src/com/android/launcher3/LauncherExterns.java
+++ b/src/com/android/launcher3/LauncherExterns.java
@@ -29,4 +29,6 @@ public interface LauncherExterns {
public SharedPreferences getSharedPrefs();
public void setLauncherOverlay(Launcher.LauncherOverlay overlay);
+
+ void clearTypedText();
}
diff --git a/src/com/android/launcher3/PendingAddItemInfo.java b/src/com/android/launcher3/PendingAddItemInfo.java
index 1aaf85bbd..31820d742 100644
--- a/src/com/android/launcher3/PendingAddItemInfo.java
+++ b/src/com/android/launcher3/PendingAddItemInfo.java
@@ -29,4 +29,9 @@ public class PendingAddItemInfo extends ItemInfo {
* The component that will be created.
*/
public ComponentName componentName;
+
+ @Override
+ protected String dumpProperties() {
+ return super.dumpProperties() + " componentName=" + componentName;
+ }
}
diff --git a/src/com/android/launcher3/PinchToOverviewListener.java b/src/com/android/launcher3/PinchToOverviewListener.java
index 6ee96fc79..48a75d111 100644
--- a/src/com/android/launcher3/PinchToOverviewListener.java
+++ b/src/com/android/launcher3/PinchToOverviewListener.java
@@ -102,8 +102,8 @@ public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleG
// once the state switching animation is complete.
return false;
}
- if (mWorkspace.getOpenFolder() != null) {
- // Don't listen for the pinch gesture if a folder is open.
+ if (mLauncher.getTopFloatingView() != null) {
+ // Don't listen for the pinch gesture if a floating view is open.
return false;
}
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index 21fa8a05e..fb9374314 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -158,7 +158,7 @@ public class ShortcutInfo extends ItemInfo {
*/
Intent promisedIntent;
- ShortcutInfo() {
+ public ShortcutInfo() {
itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
}
@@ -270,14 +270,6 @@ public class ShortcutInfo extends ItemInfo {
}
}
- @Override
- public String toString() {
- return "ShortcutInfo(title=" + title + "intent=" + intent + "id=" + this.id
- + " type=" + this.itemType + " container=" + this.container + " screen=" + screenId
- + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY
- + " user=" + user + ")";
- }
-
public ComponentName getTargetComponent() {
return promisedIntent != null ? promisedIntent.getComponent() : intent.getComponent();
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 2988fb912..b0e096a2e 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -58,6 +58,8 @@ import android.util.SparseArray;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
import android.widget.Toast;
import com.android.launcher3.compat.UserHandleCompat;
@@ -108,6 +110,10 @@ public final class Utilities {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1;
}
+ public static boolean isNycOrAbove() {
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
+ }
+
public static final boolean ATLEAST_MARSHMALLOW =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
@@ -156,33 +162,14 @@ public final class Utilities {
if (isNycOrAbove()) {
// If the device was scaled, used the original dimensions to determine if rotation
// is allowed of not.
- try {
- // TODO: Use the actual field when the API is finalized.
- int originalDensity =
- DisplayMetrics.class.getField("DENSITY_DEVICE_STABLE").getInt(null);
- Resources res = context.getResources();
- int originalSmallestWidth = res.getConfiguration().smallestScreenWidthDp
- * res.getDisplayMetrics().densityDpi / originalDensity;
- return originalSmallestWidth >= 600;
- } catch (Exception e) {
- // Ignore
- }
+ Resources res = context.getResources();
+ int originalSmallestWidth = res.getConfiguration().smallestScreenWidthDp
+ * res.getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEVICE_STABLE;
+ return originalSmallestWidth >= 600;
}
return false;
}
- public static boolean isNycOrAbove() {
- // TODO(vadimt): Replace using reflection with looking at the API version once
- // Build.VERSION.SDK_INT gets bumped to 24. b/22942492.
- try {
- View.class.getDeclaredField("DRAG_FLAG_OPAQUE");
- // View.DRAG_FLAG_OPAQUE doesn't exist in M-release, so it's an indication of N+.
- return true;
- } catch (NoSuchFieldException e) {
- return false;
- }
- }
-
public static Bitmap createIconBitmap(Cursor c, int iconIndex, Context context) {
byte[] data = c.getBlob(iconIndex);
try {
@@ -699,11 +686,11 @@ public final class Utilities {
/**
* Calculates the height of a given string at a specific text size.
*/
- public static float calculateTextHeight(float textSizePx) {
+ public static int calculateTextHeight(float textSizePx) {
Paint p = new Paint();
p.setTextSize(textSizePx);
Paint.FontMetrics fm = p.getFontMetrics();
- return -fm.top + fm.bottom;
+ return (int) Math.ceil(fm.bottom - fm.top);
}
/**
@@ -776,16 +763,21 @@ public final class Utilities {
}
public static boolean isBootCompleted() {
+ return "1".equals(getSystemProperty("sys.boot_completed", "1"));
+ }
+
+ public static String getSystemProperty(String property, String defaultValue) {
try {
Class clazz = Class.forName("android.os.SystemProperties");
Method getter = clazz.getDeclaredMethod("get", String.class);
- String value = (String) getter.invoke(null, "sys.boot_completed");
- return "1".equals(value);
+ String value = (String) getter.invoke(null, property);
+ if (!TextUtils.isEmpty(value)) {
+ return value;
+ }
} catch (Exception e) {
Log.d(TAG, "Unable to read system properties");
- // Assume that boot has completed
- return true;
}
+ return defaultValue;
}
/**
@@ -916,4 +908,15 @@ public final class Utilities {
ta.recycle();
return colorAccent;
}
+
+ public static void sendCustomAccessibilityEvent(View target, int type, String text) {
+ AccessibilityManager accessibilityManager = (AccessibilityManager)
+ target.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
+ if (accessibilityManager.isEnabled()) {
+ AccessibilityEvent event = AccessibilityEvent.obtain(type);
+ target.onInitializeAccessibilityEvent(event);
+ event.getText().add(text);
+ accessibilityManager.sendAccessibilityEvent(event);
+ }
+ }
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 4c2d4bb92..c499beeb3 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -59,7 +59,7 @@ import android.widget.TextView;
import com.android.launcher3.Launcher.CustomContentCallbacks;
import com.android.launcher3.Launcher.LauncherOverlay;
import com.android.launcher3.UninstallDropTarget.DropTargetSource;
-import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.AccessibilityDragSource;
+import com.android.launcher3.accessibility.AccessibileDragListenerAdapter;
import com.android.launcher3.accessibility.OverviewAccessibilityDelegate;
import com.android.launcher3.accessibility.OverviewScreenAccessibilityDelegate;
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
@@ -69,13 +69,13 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragScroller;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.dragndrop.SpringLoadedDragController;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.graphics.DragPreviewProvider;
-import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutsContainerListener;
import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -84,6 +84,7 @@ import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LongArrayMap;
import com.android.launcher3.util.MultiStateAlphaController;
import com.android.launcher3.util.Thunk;
+import com.android.launcher3.util.VerticalFlingDetector;
import com.android.launcher3.util.WallpaperOffsetInterpolator;
import com.android.launcher3.widget.PendingAddShortcutInfo;
import com.android.launcher3.widget.PendingAddWidgetInfo;
@@ -100,7 +101,7 @@ import java.util.HashSet;
public class Workspace extends PagedView
implements DropTarget, DragSource, DragScroller, View.OnTouchListener,
DragController.DragListener, LauncherTransitionable, ViewGroup.OnHierarchyChangeListener,
- Insettable, DropTargetSource, AccessibilityDragSource, UserEventDispatcher.LaunchSourceProvider {
+ Insettable, DropTargetSource {
private static final String TAG = "Launcher.Workspace";
private static boolean ENFORCE_DRAG_EVENT_ORDER = false;
@@ -134,7 +135,6 @@ public class Workspace extends PagedView
@Thunk Runnable mRemoveEmptyScreenRunnable;
@Thunk boolean mDeferRemoveExtraEmptyScreen = false;
- @Thunk boolean mAddNewPageOnDrag = true;
/**
* CellInfo for the cell that is currently being dragged
@@ -409,7 +409,7 @@ public class Workspace extends PagedView
}
@Override
- public void onDragStart(final DragSource source, ItemInfo info, int dragAction) {
+ public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
if (ENFORCE_DRAG_EVENT_ORDER) {
enfoceDragParity("onDragStart", 0, 0);
}
@@ -426,11 +426,19 @@ public class Workspace extends PagedView
// Prevent any Un/InstallShortcutReceivers from updating the db while we are dragging
InstallShortcutReceiver.enableInstallQueue();
- if (mAddNewPageOnDrag) {
+ // Do not add a new page if it is a accessible drag which was not started by the workspace.
+ // We do not support accessibility drag from other sources and instead provide a direct
+ // action for move/add to homescreen.
+ // When a accessible drag is started by the folder, we only allow rearranging withing the
+ // folder.
+ boolean addNewPage = !(options.isAccessibleDrag && dragObject.dragSource != this);
+
+ if (addNewPage) {
mDeferRemoveExtraEmptyScreen = false;
addExtraEmptyScreenOnDrag();
- if (source != this && info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET) {
+ if (dragObject.dragInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET
+ && dragObject.dragSource != this) {
// When dragging a widget from different source, move to a page which has
// enough space to place this widget (after rearranging/resizing). We special case
// widgets as they cannot be placed inside a folder.
@@ -439,7 +447,7 @@ public class Workspace extends PagedView
int currentPage = getPageNearestToCenterOfScreen();
for (int pageIndex = currentPage; pageIndex < getPageCount(); pageIndex++) {
CellLayout page = (CellLayout) getPageAt(pageIndex);
- if (page.hasReorderSolution(info)) {
+ if (page.hasReorderSolution(dragObject.dragInfo)) {
setCurrentPage(pageIndex);
break;
}
@@ -453,10 +461,6 @@ public class Workspace extends PagedView
}
}
- public void setAddNewPageOnDrag(boolean addPage) {
- mAddNewPageOnDrag = addPage;
- }
-
public void deferRemoveExtraEmptyScreen() {
mDeferRemoveExtraEmptyScreen = true;
}
@@ -590,7 +594,31 @@ public class Workspace extends PagedView
}
// Add the first page
CellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, 0);
-
+ if (FeatureFlags.PULLDOWN_SEARCH) {
+ firstPage.setOnTouchListener(new VerticalFlingDetector(mLauncher) {
+ // detect fling when touch started from empty space
+ @Override
+ public boolean onTouch(View v, MotionEvent ev) {
+ if (workspaceInModalState()) return false;
+ if (shouldConsumeTouch(v)) return true;
+ if (super.onTouch(v, ev)) {
+ mLauncher.startSearch("", false, null, false);
+ }
+ return false;
+ }
+ });
+ firstPage.setOnInterceptTouchListener(new VerticalFlingDetector(mLauncher) {
+ // detect fling when touch started from on top of the icons
+ @Override
+ public boolean onTouch(View v, MotionEvent ev) {
+ if (shouldConsumeTouch(v)) return true;
+ if (super.onTouch(v, ev)) {
+ mLauncher.startSearch("", false, null, false);
+ }
+ return false;
+ }
+ });
+ }
// Always add a QSB on the first screen.
if (qsb == null) {
// In transposed layout, we add the QSB in the Grid. As workspace does not touch the
@@ -624,8 +652,8 @@ public class Workspace extends PagedView
ViewGroup.LayoutParams lp = qsbContainer.getLayoutParams();
if (cellHeight > 0 && lp.height != cellHeight) {
lp.height = cellHeight;
+ qsbContainer.setLayoutParams(lp);
}
- qsbContainer.setLayoutParams(lp);
}
}
@@ -682,7 +710,6 @@ public class Workspace extends PagedView
// created CellLayout.
CellLayout newScreen = (CellLayout) mLauncher.getLayoutInflater().inflate(
R.layout.workspace_screen, this, false /* attachToRoot */);
-
newScreen.setOnLongClickListener(mLongClickListener);
newScreen.setOnClickListener(mLauncher);
newScreen.setSoundEffectsEnabled(false);
@@ -1168,6 +1195,10 @@ public class Workspace extends PagedView
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
+ return shouldConsumeTouch(v);
+ }
+
+ private boolean shouldConsumeTouch(View v) {
return (workspaceInModalState() || !isFinishedSwitchingState())
|| (!workspaceInModalState() && indexOfChild(v) != mCurrentPage);
}
@@ -1722,26 +1753,6 @@ public class Workspace extends PagedView
}
}
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- @Override
- public void enableAccessibleDrag(boolean enable) {
- for (int i = 0; i < getChildCount(); i++) {
- CellLayout child = (CellLayout) getChildAt(i);
- child.enableAccessibleDrag(enable, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG);
- }
-
- if (enable) {
- // We need to allow our individual children to become click handlers in this case
- setOnClickListener(null);
- } else {
- // Reset our click listener
- setOnClickListener(mLauncher);
- }
- mLauncher.getDropTargetBar().enableAccessibleDrag(enable);
- mLauncher.getHotseat().getLayout()
- .enableAccessibleDrag(enable, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG);
- }
-
public boolean hasCustomContent() {
return (mScreenOrder.size() > 0 && mScreenOrder.get(0) == CUSTOM_CONTENT_SCREEN_ID);
}
@@ -1874,19 +1885,6 @@ public class Workspace extends PagedView
}
@Override
- protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
- if (!mLauncher.isAppsViewVisible()) {
- final Folder openFolder = getOpenFolder();
- if (openFolder != null) {
- return openFolder.requestFocus(direction, previouslyFocusedRect);
- } else {
- return super.onRequestFocusInDescendants(direction, previouslyFocusedRect);
- }
- }
- return false;
- }
-
- @Override
public int getDescendantFocusability() {
if (workspaceInModalState()) {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
@@ -1894,18 +1892,6 @@ public class Workspace extends PagedView
return super.getDescendantFocusability();
}
- @Override
- public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
- if (!mLauncher.isAppsViewVisible()) {
- final Folder openFolder = getOpenFolder();
- if (openFolder != null) {
- openFolder.addFocusables(views, direction);
- } else {
- super.addFocusables(views, direction, focusableMode);
- }
- }
- }
-
public boolean workspaceInModalState() {
return mState != State.NORMAL;
}
@@ -2280,12 +2266,7 @@ public class Workspace extends PagedView
return null;
}
- public void startDrag(CellLayout.CellInfo cellInfo) {
- startDrag(cellInfo, false);
- }
-
- @Override
- public void startDrag(CellLayout.CellInfo cellInfo, boolean accessible) {
+ public void startDrag(CellLayout.CellInfo cellInfo, DragOptions options) {
View child = cellInfo.cell;
// Make sure the drag was started by a long press as opposed to a long click.
@@ -2298,10 +2279,25 @@ public class Workspace extends PagedView
CellLayout layout = (CellLayout) child.getParent().getParent();
layout.prepareChildForDrag(child);
- beginDragShared(child, this, accessible);
+ if (options.isAccessibleDrag) {
+ mDragController.addDragListener(new AccessibileDragListenerAdapter(
+ this, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG) {
+ @Override
+ protected void enableAccessibleDrag(boolean enable) {
+ super.enableAccessibleDrag(enable);
+ setEnableForLayout(mLauncher.getHotseat().getLayout(),enable);
+
+ // We need to allow our individual children to become click handlers in this
+ // case, so temporarily unset the click handlers.
+ setOnClickListener(enable ? null : mLauncher);
+ }
+ });
+ }
+
+ beginDragShared(child, this, options);
}
- public void beginDragShared(View child, DragSource source, boolean accessible) {
+ public void beginDragShared(View child, DragSource source, DragOptions options) {
Object dragObject = child.getTag();
if (!(dragObject instanceof ItemInfo)) {
String msg = "Drag started with a view that has no tag set. This "
@@ -2309,13 +2305,13 @@ public class Workspace extends PagedView
+ "View: " + child + " tag: " + child.getTag();
throw new IllegalStateException(msg);
}
- beginDragShared(child, source, accessible, (ItemInfo) dragObject,
- new DragPreviewProvider(child));
+ beginDragShared(child, source, (ItemInfo) dragObject,
+ new DragPreviewProvider(child), options);
}
- public DragView beginDragShared(View child, DragSource source, boolean accessible,
- ItemInfo dragObject, DragPreviewProvider previewProvider) {
+ public DragView beginDragShared(View child, DragSource source, ItemInfo dragObject,
+ DragPreviewProvider previewProvider, DragOptions dragOptions) {
child.clearFocus();
child.setPressed(false);
mOutlineProvider = previewProvider;
@@ -2359,8 +2355,7 @@ public class Workspace extends PagedView
}
DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source,
- dragObject, DragController.DRAG_ACTION_MOVE, dragVisualizeOffset,
- dragRect, scale, accessible);
+ dragObject, dragVisualizeOffset, dragRect, scale, dragOptions);
dv.setIntrinsicIconScaleFactor(source.getIntrinsicIconScaleFactor());
b.recycle();
return dv;
@@ -2939,7 +2934,7 @@ public class Workspace extends PagedView
private void cleanupAddToFolder() {
if (mDragOverFolderIcon != null) {
- mDragOverFolderIcon.onDragExit(null);
+ mDragOverFolderIcon.onDragExit();
mDragOverFolderIcon = null;
}
}
@@ -3426,6 +3421,7 @@ public class Workspace extends PagedView
if (info.container == NO_ID && info instanceof AppInfo) {
// Came from all apps -- make a copy
info = ((AppInfo) info).makeShortcut();
+ d.dragInfo = info;
}
view = mLauncher.createShortcut(cellLayout, (ShortcutInfo) info);
break;
@@ -4295,6 +4291,12 @@ public class Workspace extends PagedView
target.gridY = info.cellY;
target.pageIndex = getCurrentPage();
targetParent.containerType = LauncherLogProto.WORKSPACE;
+ if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
+ target.rank = info.rank;
+ targetParent.containerType = LauncherLogProto.HOTSEAT;
+ } else if (info.container >= 0) {
+ targetParent.containerType = LauncherLogProto.FOLDER;
+ }
}
/**
diff --git a/src/com/android/launcher3/accessibility/AccessibileDragListenerAdapter.java b/src/com/android/launcher3/accessibility/AccessibileDragListenerAdapter.java
new file mode 100644
index 000000000..62a9a6d19
--- /dev/null
+++ b/src/com/android/launcher3/accessibility/AccessibileDragListenerAdapter.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.accessibility;
+
+import android.view.ViewGroup;
+
+import com.android.launcher3.CellLayout;
+import com.android.launcher3.DropTarget.DragObject;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.dragndrop.DragController.DragListener;
+import com.android.launcher3.dragndrop.DragOptions;
+
+/**
+ * Utility listener to enable/disable accessibility drag flags for a ViewGroup
+ * containing CellLayouts
+ */
+public class AccessibileDragListenerAdapter implements DragListener {
+
+ private final ViewGroup mViewGroup;
+ private final int mDragType;
+
+ /**
+ * @param parent
+ * @param dragType either {@link CellLayout#WORKSPACE_ACCESSIBILITY_DRAG} or
+ * {@link CellLayout#FOLDER_ACCESSIBILITY_DRAG}
+ */
+ public AccessibileDragListenerAdapter(ViewGroup parent, int dragType) {
+ mViewGroup = parent;
+ mDragType = dragType;
+ }
+
+ @Override
+ public void onDragStart(DragObject dragObject, DragOptions options) {
+ enableAccessibleDrag(true);
+ }
+
+ @Override
+ public void onDragEnd() {
+ enableAccessibleDrag(false);
+ Launcher.getLauncher(mViewGroup.getContext()).getDragController().removeDragListener(this);
+ }
+
+ protected void enableAccessibleDrag(boolean enable) {
+ for (int i = 0; i < mViewGroup.getChildCount(); i++) {
+ setEnableForLayout((CellLayout) mViewGroup.getChildAt(i), enable);
+ }
+ }
+
+ protected final void setEnableForLayout(CellLayout layout, boolean enable) {
+ layout.enableAccessibleDrag(enable, mDragType);
+ }
+}
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index 0562cf54b..173aad044 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -22,6 +22,8 @@ import com.android.launcher3.BubbleTextView;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeleteDropTarget;
import com.android.launcher3.DragSource;
+import com.android.launcher3.DropTarget.DragObject;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.FolderInfo;
import com.android.launcher3.InfoDropTarget;
@@ -73,7 +75,6 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
@Thunk final Launcher mLauncher;
private DragInfo mDragInfo = null;
- private AccessibilityDragSource mDragSource = null;
public LauncherAccessibilityDelegate(Launcher launcher) {
mLauncher = launcher;
@@ -372,26 +373,25 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
Folder folder = workspace.getOpenFolder();
if (folder != null) {
- if (folder.getItemsInReadingOrder().contains(item)) {
- mDragSource = folder;
- } else {
+ if (!folder.getItemsInReadingOrder().contains(item)) {
mLauncher.closeFolder();
+ folder = null;
}
}
- if (mDragSource == null) {
- mDragSource = workspace;
- }
- mDragSource.enableAccessibleDrag(true);
- mDragSource.startDrag(cellInfo, true);
- if (mLauncher.getDragController().isDragging()) {
- mLauncher.getDragController().addDragListener(this);
+ mLauncher.getDragController().addDragListener(this);
+
+ DragOptions options = new DragOptions();
+ options.isAccessibleDrag = true;
+ if (folder != null) {
+ folder.startDrag(cellInfo.cell, options);
+ } else {
+ workspace.startDrag(cellInfo, options);
}
}
-
@Override
- public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
+ public void onDragStart(DragObject dragObject, DragOptions options) {
// No-op
}
@@ -399,16 +399,6 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
public void onDragEnd() {
mLauncher.getDragController().removeDragListener(this);
mDragInfo = null;
- if (mDragSource != null) {
- mDragSource.enableAccessibleDrag(false);
- mDragSource = null;
- }
- }
-
- public static interface AccessibilityDragSource {
- void startDrag(CellLayout.CellInfo cellInfo, boolean accessible);
-
- void enableAccessibleDrag(boolean enable);
}
/**
diff --git a/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java b/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java
index dafa73fec..cfd07e658 100644
--- a/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java
+++ b/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java
@@ -96,14 +96,14 @@ public class AllAppsBackgroundDrawable extends Drawable {
public AllAppsBackgroundDrawable(Context context) {
Resources res = context.getResources();
mHand = new TransformedImageDrawable(res, R.drawable.ic_all_apps_bg_hand,
- 0.575f, 0.1f, Gravity.CENTER_HORIZONTAL);
+ 0.575f, 0.f, Gravity.CENTER_HORIZONTAL);
mIcons = new TransformedImageDrawable[4];
mIcons[0] = new TransformedImageDrawable(res, R.drawable.ic_all_apps_bg_icon_1,
0.375f, 0, Gravity.CENTER_HORIZONTAL);
mIcons[1] = new TransformedImageDrawable(res, R.drawable.ic_all_apps_bg_icon_2,
- 0.3125f, 0.25f, Gravity.CENTER_HORIZONTAL);
+ 0.3125f, 0.2f, Gravity.CENTER_HORIZONTAL);
mIcons[2] = new TransformedImageDrawable(res, R.drawable.ic_all_apps_bg_icon_3,
- 0.475f, 0.4f, Gravity.CENTER_HORIZONTAL);
+ 0.475f, 0.26f, Gravity.CENTER_HORIZONTAL);
mIcons[3] = new TransformedImageDrawable(res, R.drawable.ic_all_apps_bg_icon_4,
0.7f, 0.125f, Gravity.CENTER_HORIZONTAL);
mWidth = res.getDimensionPixelSize(R.dimen.all_apps_background_canvas_width);
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index c7bc23bd4..290accb1e 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -25,6 +25,7 @@ import android.text.Selection;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
+import android.text.TextUtils;
import android.text.method.TextKeyListener;
import android.util.AttributeSet;
import android.view.KeyEvent;
@@ -48,9 +49,11 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.graphics.TintedDrawableSpan;
import com.android.launcher3.keyboard.FocusedItemDecorator;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.ComponentKey;
import java.nio.charset.Charset;
@@ -275,6 +278,12 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
if (mAppsRecyclerView.getScrollBar().isNearThumb(point[0], point[1])) {
return false;
}
+
+ // IF a shortcuts container is open, container should not be pulled down.
+ if (mLauncher.getOpenShortcutsContainer() != null) {
+ return false;
+ }
+
// IF scroller is at the very top OR there is no scroll bar because there is probably not
// enough items to scroll, THEN it's okay for the container to be pulled down.
if (mAppsRecyclerView.getScrollBar().getThumbOffset().y <= 0) {
@@ -537,7 +546,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
if (!mLauncher.isDraggingEnabled()) return false;
// Start the drag
- mLauncher.getWorkspace().beginDragShared(v, this, false);
+ mLauncher.getWorkspace().beginDragShared(v, this, new DragOptions());
// Enter spring loaded mode
mLauncher.enterSpringLoadedDragMode();
@@ -700,4 +709,13 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
mSearchQueryBuilder.clearSpans();
Selection.setSelection(mSearchQueryBuilder, 0);
}
+
+ @Override
+ public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
+ targetParent.containerType = mAppsRecyclerView.getContainerType(v);
+ }
+
+ public boolean shouldRestoreImeState() {
+ return !TextUtils.isEmpty(mSearchInput.getText());
+ }
}
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 25ed3b8ec..0173847e0 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -27,20 +27,16 @@ import android.view.View;
import com.android.launcher3.BaseRecyclerView;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
-import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider;
import com.android.launcher3.userevent.nano.LauncherLogProto;
-import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import java.util.List;
/**
* A RecyclerView with custom fast scroll support for the all apps view.
*/
-public class AllAppsRecyclerView extends BaseRecyclerView
- implements LaunchSourceProvider {
+public class AllAppsRecyclerView extends BaseRecyclerView {
private AlphabeticalAppsList mApps;
private AllAppsFastScrollHelper mFastScrollHelper;
@@ -207,10 +203,9 @@ public class AllAppsRecyclerView extends BaseRecyclerView
updateEmptySearchBackgroundBounds();
}
- @Override
- public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
+ public int getContainerType(View v) {
if (mApps.hasFilter()) {
- targetParent.containerType = LauncherLogProto.SEARCHRESULT;
+ return LauncherLogProto.SEARCHRESULT;
} else {
if (v instanceof BubbleTextView) {
BubbleTextView icon = (BubbleTextView) v;
@@ -219,12 +214,11 @@ public class AllAppsRecyclerView extends BaseRecyclerView
List<AlphabeticalAppsList.AdapterItem> items = mApps.getAdapterItems();
AlphabeticalAppsList.AdapterItem item = items.get(position);
if (item.viewType == AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON) {
- targetParent.containerType = LauncherLogProto.PREDICTION;
- return;
+ return LauncherLogProto.PREDICTION;
}
}
}
- targetParent.containerType = LauncherLogProto.ALLAPPS;
+ return LauncherLogProto.ALLAPPS;
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
index 9a48367cd..365ab3185 100644
--- a/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
+++ b/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
@@ -127,10 +127,9 @@ public abstract class AllAppsSearchBarController
@Override
public boolean onBackKey() {
- // Only hide the search field if there is no query, or if there
- // are no filtered results
+ // Only hide the search field if there is no query
String query = Utilities.trim(mInput.getEditableText().toString());
- if (query.isEmpty() || mApps.hasNoFilteredResults()) {
+ if (query.isEmpty()) {
reset();
return true;
}
@@ -163,8 +162,7 @@ public abstract class AllAppsSearchBarController
* Focuses the search field to handle key events.
*/
public void focusSearchField() {
- mInput.requestFocus();
- mInputMethodManager.showSoftInput(mInput, InputMethodManager.SHOW_IMPLICIT);
+ mInput.showKeyboard();
}
/**
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 588823051..9fcc6a40e 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -6,6 +6,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
+import android.support.v4.content.ContextCompat;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.util.Log;
import android.view.MotionEvent;
@@ -101,7 +102,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
R.dimen.all_apps_bezel_swipe_height);
mEvaluator = new ArgbEvaluator();
- mAllAppsBackgroundColor = l.getColor(R.color.all_apps_container_color);
+ mAllAppsBackgroundColor = ContextCompat.getColor(l, R.color.all_apps_container_color);
}
@Override
diff --git a/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java b/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java
index 10740ec77..ac22dd279 100644
--- a/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java
+++ b/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithm.java
@@ -22,15 +22,12 @@ import com.android.launcher3.util.ComponentKey;
import java.util.ArrayList;
import java.util.List;
-import java.util.regex.Pattern;
/**
* The default search implementation.
*/
public class DefaultAppSearchAlgorithm {
- private static final Pattern SPLIT_PATTERN = Pattern.compile("[\\s|\\p{javaSpaceChar}]+");
-
private final List<AppInfo> mApps;
protected final Handler mResultHandler;
@@ -61,34 +58,79 @@ public class DefaultAppSearchAlgorithm {
// Do an intersection of the words in the query and each title, and filter out all the
// apps that don't match all of the words in the query.
final String queryTextLower = query.toLowerCase();
- final String[] queryWords = SPLIT_PATTERN.split(queryTextLower);
-
final ArrayList<ComponentKey> result = new ArrayList<>();
for (AppInfo info : mApps) {
- if (matches(info, queryWords)) {
+ if (matches(info, queryTextLower)) {
result.add(info.toComponentKey());
}
}
return result;
}
- protected boolean matches(AppInfo info, String[] queryWords) {
+ protected boolean matches(AppInfo info, String query) {
+ int queryLength = query.length();
+
String title = info.title.toString();
- String[] words = SPLIT_PATTERN.split(title.toLowerCase());
- for (int qi = 0; qi < queryWords.length; qi++) {
- boolean foundMatch = false;
- for (int i = 0; i < words.length; i++) {
- if (words[i].startsWith(queryWords[qi])) {
- foundMatch = true;
- break;
- }
+ int titleLength = title.length();
+
+ if (titleLength < queryLength || queryLength <= 0) {
+ return false;
+ }
+
+ int lastType;
+ int thisType = Character.UNASSIGNED;
+ int nextType = Character.getType(title.codePointAt(0));
+
+ int end = titleLength - queryLength;
+ for (int i = 0; i <= end; i++) {
+ lastType = thisType;
+ thisType = nextType;
+ nextType = i < (titleLength - 1) ?
+ Character.getType(title.codePointAt(i + 1)) : Character.UNASSIGNED;
+ if (isBreak(thisType, lastType, nextType) &&
+ title.substring(i, i + queryLength).equalsIgnoreCase(query)) {
+ return true;
}
- if (!foundMatch) {
- // If there is a word in the query that does not match any words in this
- // title, so skip it.
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if the current point should be a break point. Following cases
+ * are considered as break points:
+ * 1) Any non space character after a space character
+ * 2) Any digit after a non-digit character
+ * 3) Any capital character after a digit or small character
+ * 4) Any capital character before a small character
+ */
+ protected boolean isBreak(int thisType, int prevType, int nextType) {
+ switch (thisType) {
+ case Character.UPPERCASE_LETTER:
+ if (nextType == Character.UPPERCASE_LETTER) {
+ return true;
+ }
+ // Follow through
+ case Character.TITLECASE_LETTER:
+ // Break point if previous was not a upper case
+ return prevType != Character.UPPERCASE_LETTER;
+ case Character.LOWERCASE_LETTER:
+ // Break point if previous was not a letter.
+ return prevType > Character.OTHER_LETTER;
+ case Character.DECIMAL_DIGIT_NUMBER:
+ case Character.LETTER_NUMBER:
+ case Character.OTHER_NUMBER:
+ // Break point if previous was not a number
+ return !(prevType == Character.DECIMAL_DIGIT_NUMBER
+ || prevType == Character.LETTER_NUMBER
+ || prevType == Character.OTHER_NUMBER);
+ case Character.MATH_SYMBOL:
+ case Character.CURRENCY_SYMBOL:
+ case Character.OTHER_PUNCTUATION:
+ case Character.DASH_PUNCTUATION:
+ // Always a break point for a symbol
+ return true;
+ default:
return false;
- }
}
- return true;
}
}
diff --git a/src/com/android/launcher3/compat/UserManagerCompat.java b/src/com/android/launcher3/compat/UserManagerCompat.java
index 29ed5d9ba..a5f8dd296 100644
--- a/src/com/android/launcher3/compat/UserManagerCompat.java
+++ b/src/com/android/launcher3/compat/UserManagerCompat.java
@@ -32,8 +32,12 @@ public abstract class UserManagerCompat {
public static UserManagerCompat getInstance(Context context) {
synchronized (sInstanceLock) {
if (sInstance == null) {
- if (Utilities.isNycOrAbove()) {
+ if (Utilities.isNycMR1OrAbove()) {
+ sInstance = new UserManagerCompatVNMr1(context.getApplicationContext());
+ } else if (Utilities.isNycOrAbove()) {
sInstance = new UserManagerCompatVN(context.getApplicationContext());
+ } else if (Utilities.ATLEAST_MARSHMALLOW) {
+ sInstance = new UserManagerCompatVM(context.getApplicationContext());
} else if (Utilities.ATLEAST_LOLLIPOP) {
sInstance = new UserManagerCompatVL(context.getApplicationContext());
} else if (Utilities.ATLEAST_JB_MR1) {
@@ -58,4 +62,6 @@ public abstract class UserManagerCompat {
public abstract long getUserCreationTime(UserHandleCompat user);
public abstract boolean isQuietModeEnabled(UserHandleCompat user);
public abstract boolean isUserUnlocked(UserHandleCompat user);
+
+ public abstract boolean isDemoUser();
}
diff --git a/src/com/android/launcher3/compat/UserManagerCompatV16.java b/src/com/android/launcher3/compat/UserManagerCompatV16.java
index e678ffa3d..9bd4567a1 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatV16.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatV16.java
@@ -60,4 +60,9 @@ public class UserManagerCompatV16 extends UserManagerCompat {
public boolean isUserUnlocked(UserHandleCompat user) {
return true;
}
+
+ @Override
+ public boolean isDemoUser() {
+ return false;
+ }
}
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVL.java b/src/com/android/launcher3/compat/UserManagerCompatVL.java
index c53d702b7..2552b0c2c 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatVL.java
@@ -1,4 +1,3 @@
-
/*
* Copyright (C) 2014 The Android Open Source Project
*
@@ -94,9 +93,6 @@ public class UserManagerCompatVL extends UserManagerCompatV17 {
@Override
public long getUserCreationTime(UserHandleCompat user) {
- if (Utilities.ATLEAST_MARSHMALLOW) {
- return mUserManager.getUserCreationTime(user.getUser());
- }
SharedPreferences prefs = Utilities.getPrefs(mContext);
String key = USER_CREATION_TIME_KEY + getSerialNumberForUser(user);
if (!prefs.contains(key)) {
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVM.java b/src/com/android/launcher3/compat/UserManagerCompatVM.java
new file mode 100644
index 000000000..81d67ea43
--- /dev/null
+++ b/src/com/android/launcher3/compat/UserManagerCompatVM.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.compat;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.os.Build;
+
+@TargetApi(Build.VERSION_CODES.M)
+public class UserManagerCompatVM extends UserManagerCompatVL {
+
+ UserManagerCompatVM(Context context) {
+ super(context);
+ }
+
+ @Override
+ public long getUserCreationTime(UserHandleCompat user) {
+ return mUserManager.getUserCreationTime(user.getUser());
+ }
+}
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVN.java b/src/com/android/launcher3/compat/UserManagerCompatVN.java
index 771d141c3..4edac0522 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatVN.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatVN.java
@@ -20,10 +20,10 @@ import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
-@TargetApi(Build.VERSION_CODES.N)
-public class UserManagerCompatVN extends UserManagerCompatVL {
+import com.android.launcher3.Utilities;
- private static final String TAG = "UserManagerCompatVN";
+@TargetApi(Build.VERSION_CODES.N)
+public class UserManagerCompatVN extends UserManagerCompatVM {
UserManagerCompatVN(Context context) {
super(context);
@@ -36,12 +36,7 @@ public class UserManagerCompatVN extends UserManagerCompatVL {
@Override
public boolean isUserUnlocked(UserHandleCompat user) {
- // TODO: Remove the try-catch block when the API permission has been relaxed (b/30475753)
- try {
- return mUserManager.isUserUnlocked(user.getUser());
- } catch (RuntimeException e) {
- return !isQuietModeEnabled(user);
- }
+ return mUserManager.isUserUnlocked(user.getUser());
}
}
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVNMr1.java b/src/com/android/launcher3/compat/UserManagerCompatVNMr1.java
new file mode 100644
index 000000000..3f64bc863
--- /dev/null
+++ b/src/com/android/launcher3/compat/UserManagerCompatVNMr1.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.compat;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.os.Build;
+
+@TargetApi(Build.VERSION_CODES.N_MR1)
+public class UserManagerCompatVNMr1 extends UserManagerCompatVN {
+
+ UserManagerCompatVNMr1(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isDemoUser() {
+ return mUserManager.isDemoUser();
+ }
+}
diff --git a/src/com/android/launcher3/dragndrop/AnotherWindowDragSource.java b/src/com/android/launcher3/dragndrop/AnotherWindowDragSource.java
new file mode 100644
index 000000000..156941a29
--- /dev/null
+++ b/src/com/android/launcher3/dragndrop/AnotherWindowDragSource.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.dragndrop;
+
+import android.content.Context;
+import android.view.View;
+
+import com.android.launcher3.DragSource;
+import com.android.launcher3.DropTarget.DragObject;
+import com.android.launcher3.ItemInfo;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
+
+/**
+ * DragSource used when the drag started at another window.
+ */
+public class AnotherWindowDragSource implements DragSource {
+
+ private final Context mContext;
+
+ AnotherWindowDragSource(Context context) {
+ mContext = context;
+ }
+
+ @Override
+ public boolean supportsFlingToDelete() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAppInfoDropTarget() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsDeleteDropTarget() {
+ return false;
+ }
+
+ @Override
+ public float getIntrinsicIconScaleFactor() {
+ return 1;
+ }
+
+ @Override
+ public void onFlingToDeleteCompleted() {
+ }
+
+ @Override
+ public void onDropCompleted(View target, DragObject d,
+ boolean isFlingToDelete, boolean success) {
+ if (!success) {
+ Launcher.getLauncher(mContext).exitSpringLoadedDragModeDelayed(false, 0, null);
+ }
+
+ }
+
+ @Override
+ public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
+ // TODO: Probably log something
+ }
+}
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index 9da1cb313..a93ee9019 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -25,7 +25,6 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Handler;
import android.os.IBinder;
-import android.util.Log;
import android.view.DragEvent;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
@@ -43,7 +42,6 @@ import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
-import com.android.launcher3.Workspace;
import com.android.launcher3.accessibility.DragViewStateAnnouncer;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.ItemInfoMatcher;
@@ -51,7 +49,6 @@ import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.TouchController;
import java.util.ArrayList;
-import java.util.HashSet;
/**
* Class for initiating a drag within a view or across multiple views.
@@ -59,12 +56,6 @@ import java.util.HashSet;
public class DragController implements DragDriver.EventListener, TouchController {
private static final String TAG = "Launcher.DragController";
- /** Indicates the drag is a move. */
- public static int DRAG_ACTION_MOVE = 0;
-
- /** Indicates the drag is a copy. */
- public static int DRAG_ACTION_COPY = 1;
-
public static final int SCROLL_DELAY = 500;
public static final int RESCROLL_DELAY = PagedView.PAGE_SNAP_ANIMATION_DURATION + 150;
@@ -93,8 +84,8 @@ public class DragController implements DragDriver.EventListener, TouchController
*/
private DragDriver mDragDriver = null;
- /** Whether or not an accessible drag operation is in progress. */
- private boolean mIsAccessibleDrag;
+ /** Options controlling the drag behavior. */
+ private DragOptions mOptions;
/** X coordinate of the down event. */
private int mMotionDownX;
@@ -147,12 +138,10 @@ public class DragController implements DragDriver.EventListener, TouchController
/**
* A drag has begun
*
- * @param source An object representing where the drag originated
- * @param info The data associated with the object that is being dragged
- * @param dragAction The drag action: either {@link DragController#DRAG_ACTION_MOVE}
- * or {@link DragController#DRAG_ACTION_COPY}
+ * @param dragObject The object being dragged
+ * @param options Options used to start the drag
*/
- void onDragStart(DragSource source, ItemInfo info, int dragAction);
+ void onDragStart(DropTarget.DragObject dragObject, DragOptions options);
/**
* The drag has ended
@@ -162,8 +151,6 @@ public class DragController implements DragDriver.EventListener, TouchController
/**
* Used to create a new DragLayer from XML.
- *
- * @param context The application's context.
*/
public DragController(Launcher launcher) {
Resources r = launcher.getResources();
@@ -185,11 +172,9 @@ public class DragController implements DragDriver.EventListener, TouchController
* @param source An object representing where the drag originated
* @param dragInfo The data associated with the object that is being dragged
* @param viewImageBounds the position of the image inside the view
- * @param dragAction The drag action: either {@link #DRAG_ACTION_MOVE} or
- * {@link #DRAG_ACTION_COPY}
*/
public void startDrag(View v, Bitmap bmp, DragSource source, ItemInfo dragInfo,
- Rect viewImageBounds, int dragAction, float initialDragViewScale) {
+ Rect viewImageBounds, float initialDragViewScale, DragOptions options) {
int[] loc = mCoordinatesTemp;
mLauncher.getDragLayer().getLocationInDragLayer(v, loc);
int dragLayerX = loc[0] + viewImageBounds.left
@@ -197,12 +182,8 @@ public class DragController implements DragDriver.EventListener, TouchController
int dragLayerY = loc[1] + viewImageBounds.top
+ (int) ((initialDragViewScale * bmp.getHeight() - bmp.getHeight()) / 2);
- startDrag(bmp, dragLayerX, dragLayerY, source, dragInfo, dragAction, null,
- null, initialDragViewScale, false);
-
- if (dragAction == DRAG_ACTION_MOVE) {
- v.setVisibility(View.GONE);
- }
+ startDrag(bmp, dragLayerX, dragLayerY, source, dragInfo, null,
+ null, initialDragViewScale, options);
}
/**
@@ -214,15 +195,12 @@ public class DragController implements DragDriver.EventListener, TouchController
* @param dragLayerY The y position in the DragLayer of the left-top of the bitmap.
* @param source An object representing where the drag originated
* @param dragInfo The data associated with the object that is being dragged
- * @param dragAction The drag action: either {@link #DRAG_ACTION_MOVE} or
- * {@link #DRAG_ACTION_COPY}
* @param dragRegion Coordinates within the bitmap b for the position of item being dragged.
* Makes dragging feel more precise, e.g. you can clip out a transparent border
- * @param accessible whether this drag should occur in accessibility mode
*/
public DragView startDrag(Bitmap b, int dragLayerX, int dragLayerY,
- DragSource source, ItemInfo dragInfo, int dragAction, Point dragOffset, Rect dragRegion,
- float initialDragViewScale, boolean accessible) {
+ DragSource source, ItemInfo dragInfo, Point dragOffset, Rect dragRegion,
+ float initialDragViewScale, DragOptions options) {
if (PROFILE_DRAWING_DURING_DRAG) {
android.os.Debug.startMethodTracing("Launcher");
}
@@ -234,8 +212,10 @@ public class DragController implements DragDriver.EventListener, TouchController
}
mInputMethodManager.hideSoftInputFromWindow(mWindowToken, 0);
- for (DragListener listener : mListeners) {
- listener.onDragStart(source, dragInfo, dragAction);
+ mOptions = options;
+ if (mOptions.systemDndStartPoint != null) {
+ mMotionDownX = mOptions.systemDndStartPoint.x;
+ mMotionDownY = mOptions.systemDndStartPoint.y;
}
final int registrationX = mMotionDownX - dragLayerX;
@@ -244,7 +224,6 @@ public class DragController implements DragDriver.EventListener, TouchController
final int dragRegionLeft = dragRegion == null ? 0 : dragRegion.left;
final int dragRegionTop = dragRegion == null ? 0 : dragRegion.top;
- mIsAccessibleDrag = accessible;
mLastDropTarget = null;
mDragObject = new DropTarget.DragObject();
@@ -256,7 +235,7 @@ public class DragController implements DragDriver.EventListener, TouchController
registrationY, initialDragViewScale, scaleDps);
mDragObject.dragComplete = false;
- if (mIsAccessibleDrag) {
+ if (mOptions.isAccessibleDrag) {
// For an accessible drag, we assume the view is being dragged from the center.
mDragObject.xOffset = b.getWidth() / 2;
mDragObject.yOffset = b.getHeight() / 2;
@@ -266,11 +245,13 @@ public class DragController implements DragDriver.EventListener, TouchController
mDragObject.yOffset = mMotionDownY - (dragLayerY + dragRegionTop);
mDragObject.stateAnnouncer = DragViewStateAnnouncer.createFor(dragView);
- mDragDriver = DragDriver.create(this, dragInfo, dragView);
+ mDragDriver = DragDriver.create(mLauncher, this, mDragObject, mOptions);
}
mDragObject.dragSource = source;
mDragObject.dragInfo = dragInfo;
+ mDragObject.originalDragInfo = new ItemInfo();
+ mDragObject.originalDragInfo.copyFrom(dragInfo);
if (dragOffset != null) {
dragView.setDragVisualizeOffset(new Point(dragOffset));
@@ -282,9 +263,15 @@ public class DragController implements DragDriver.EventListener, TouchController
mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
dragView.show(mMotionDownX, mMotionDownY);
mDistanceSinceScroll = 0;
+
+ for (DragListener listener : new ArrayList<>(mListeners)) {
+ listener.onDragStart(mDragObject, mOptions);
+ }
+
mLastTouch[0] = mMotionDownX;
mLastTouch[1] = mMotionDownY;
handleMoveEvent(mMotionDownX, mMotionDownY);
+ mLauncher.getUserEventDispatcher().resetActionDurationMillis();
return dragView;
}
@@ -307,7 +294,11 @@ public class DragController implements DragDriver.EventListener, TouchController
}
public boolean isDragging() {
- return mDragDriver != null || mIsAccessibleDrag;
+ return mDragDriver != null || (mOptions != null && mOptions.isAccessibleDrag);
+ }
+
+ public boolean isExternalDrag() {
+ return (mOptions != null && mOptions.systemDndStartPoint != null);
}
/**
@@ -342,7 +333,7 @@ public class DragController implements DragDriver.EventListener, TouchController
private void endDrag() {
if (isDragging()) {
mDragDriver = null;
- mIsAccessibleDrag = false;
+ mOptions = null;
clearScrollRunnable();
boolean isDeferred = false;
if (mDragObject.dragView != null) {
@@ -421,10 +412,6 @@ public class DragController implements DragDriver.EventListener, TouchController
@Override
public void onDriverDragEnd(float x, float y, DropTarget dropTargetOverride) {
- final int[] dragLayerPos = getClampedDragLayerPos(x, y);
- final int dragLayerX = dragLayerPos[0];
- final int dragLayerY = dragLayerPos[1];
-
DropTarget dropTarget;
PointF vec = null;
@@ -453,14 +440,7 @@ public class DragController implements DragDriver.EventListener, TouchController
* Call this from a drag source view.
*/
public boolean onInterceptTouchEvent(MotionEvent ev) {
- @SuppressWarnings("all") // suppress dead code warning
- final boolean debug = false;
- if (debug) {
- Log.d(Launcher.TAG, "DragController.onInterceptTouchEvent " + ev + " Dragging="
- + (mDragDriver != null));
- }
-
- if (mIsAccessibleDrag) {
+ if (mOptions != null && mOptions.isAccessibleDrag) {
return false;
}
@@ -507,7 +487,7 @@ public class DragController implements DragDriver.EventListener, TouchController
*/
public void setMoveTarget(View view) {
mMoveTarget = view;
- }
+ }
public boolean dispatchUnhandledMove(View focused, int direction) {
return mMoveTarget != null && mMoveTarget.dispatchUnhandledMove(focused, direction);
@@ -603,7 +583,7 @@ public class DragController implements DragDriver.EventListener, TouchController
* Call this from a drag source view.
*/
public boolean onTouchEvent(MotionEvent ev) {
- if (mDragDriver == null || mIsAccessibleDrag) {
+ if (mDragDriver == null || mOptions == null || mOptions.isAccessibleDrag) {
return false;
}
@@ -734,6 +714,7 @@ public class DragController implements DragDriver.EventListener, TouchController
final View dropTargetAsView = dropTarget instanceof View ? (View) dropTarget : null;
mDragObject.dragSource.onDropCompleted(
dropTargetAsView, mDragObject, flingVel != null, accepted);
+ mLauncher.getUserEventDispatcher().logDragNDrop(mDragObject, dropTargetAsView);
}
private DropTarget findDropTarget(int x, int y, int[] dropCoordinates) {
diff --git a/src/com/android/launcher3/dragndrop/DragDriver.java b/src/com/android/launcher3/dragndrop/DragDriver.java
index 2164708ba..4db8c07d5 100644
--- a/src/com/android/launcher3/dragndrop/DragDriver.java
+++ b/src/com/android/launcher3/dragndrop/DragDriver.java
@@ -17,18 +17,19 @@
package com.android.launcher3.dragndrop;
import android.content.ClipData;
+import android.content.ClipDescription;
+import android.content.Context;
import android.content.Intent;
-import android.graphics.Canvas;
-import android.graphics.Point;
import android.view.DragEvent;
import android.view.MotionEvent;
-import android.view.View;
-import com.android.launcher3.AnotherWindowDropTarget;
import com.android.launcher3.DropTarget;
-import com.android.launcher3.ItemInfo;
+import com.android.launcher3.DropTarget.DragObject;
+import com.android.launcher3.InstallShortcutReceiver;
+import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
-import com.android.launcher3.config.FeatureFlags;
+
+import java.util.ArrayList;
/**
* Base class for driving a drag/drop operation.
@@ -50,7 +51,7 @@ public abstract class DragDriver {
/**
* Handles ending of the DragView animation.
*/
- public abstract void onDragViewAnimationEnd();
+ public void onDragViewAnimationEnd() { }
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
@@ -89,100 +90,46 @@ public abstract class DragDriver {
return true;
}
- public static DragDriver create(
- DragController dragController, ItemInfo dragInfo, DragView dragView) {
- if (FeatureFlags.LAUNCHER3_USE_SYSTEM_DRAG_DRIVER && Utilities.isNycOrAbove()) {
- return new SystemDragDriver(dragController, dragInfo.getIntent(), dragView);
+ public static DragDriver create(Context context, DragController dragController,
+ DragObject dragObject, DragOptions options) {
+ if (Utilities.isNycOrAbove() && options.systemDndStartPoint != null) {
+ return new SystemDragDriver(dragController, context, dragObject);
} else {
return new InternalDragDriver(dragController);
}
}
-
-};
+}
/**
* Class for driving a system (i.e. framework) drag/drop operation.
*/
class SystemDragDriver extends DragDriver {
- /** Intent associated with the drag operation, or null is there no associated intent. */
- private final Intent mDragIntent;
- private final DragView mDragView;
- boolean mIsFrameworkDragActive = false;
+ private final DragObject mDragObject;
+ private final Context mContext;
+
boolean mReceivedDropEvent = false;
float mLastX = 0;
float mLastY = 0;
- public SystemDragDriver(DragController dragController, Intent dragIntent, DragView dragView) {
+ public SystemDragDriver(DragController dragController, Context context, DragObject dragObject) {
super(dragController);
- mDragIntent = dragIntent;
- mDragView = dragView;
- }
-
- private static class ShadowBuilder extends View.DragShadowBuilder {
- final DragView mDragView;
-
- public ShadowBuilder(DragView dragView) {
- mDragView = dragView;
- }
-
- @Override
- public void onProvideShadowMetrics (Point size, Point touch) {
- mDragView.provideDragShadowMetrics(size, touch);
- }
-
- @Override
- public void onDrawShadow(Canvas canvas) {
- mDragView.drawDragShadow(canvas);
- }
- };
-
- @Override
- public void onDragViewAnimationEnd() {
- // Clip data for the drag operation. If there is an intent, create an intent-based ClipData,
- // which will be passed to a global DND.
- // If there is no intent, craft a fake ClipData and start a local DND operation; this
- // ClipData will be ignored.
- final ClipData dragData = mDragIntent != null ?
- ClipData.newIntent("", mDragIntent) :
- ClipData.newPlainText("", "");
-
- View.DragShadowBuilder shadowBuilder = new ShadowBuilder(mDragView);
- // TODO: DND flags are in flux, once settled, use the appropriate constant.
- final int flagGlobal = 1 << 0;
- final int flagOpaque = 1 << 9;
- final int flags = (mDragIntent != null ? flagGlobal : 0) | flagOpaque;
-
- mIsFrameworkDragActive = true;
-
- if (!mDragView.startDrag(dragData, shadowBuilder, null, flags)) {
- mIsFrameworkDragActive = false;
- mEventListener.onDriverDragCancel();
- return;
- }
-
- // Starting from this point, the driver takes over showing the drag shadow, so hiding the
- // drag view.
- mDragView.setVisibility(View.INVISIBLE);
+ mDragObject = dragObject;
+ mContext = context;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
- return !mIsFrameworkDragActive && super.onTouchEvent(ev);
+ return false;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
- return !mIsFrameworkDragActive && super.onInterceptTouchEvent(ev);
+ return false;
}
@Override
public boolean onDragEvent (DragEvent event) {
- if (!mIsFrameworkDragActive) {
- // We are interested only in drag events started by this driver.
- return false;
- }
-
final int action = event.getAction();
switch (action) {
@@ -192,8 +139,6 @@ class SystemDragDriver extends DragDriver {
return true;
case DragEvent.ACTION_DRAG_ENTERED:
- mLastX = event.getX();
- mLastY = event.getY();
return true;
case DragEvent.ACTION_DRAG_LOCATION:
@@ -205,35 +150,66 @@ class SystemDragDriver extends DragDriver {
case DragEvent.ACTION_DROP:
mLastX = event.getX();
mLastY = event.getY();
- mReceivedDropEvent = true;
- return true;
+ mReceivedDropEvent =
+ updateInfoFromClipData(event.getClipData(), event.getClipDescription());
+ return mReceivedDropEvent;
case DragEvent.ACTION_DRAG_EXITED:
- mLastX = event.getX();
- mLastY = event.getY();
mEventListener.onDriverDragExitWindow();
return true;
case DragEvent.ACTION_DRAG_ENDED:
- final boolean dragAccepted = event.getResult();
- final boolean acceptedByAnotherWindow = dragAccepted && !mReceivedDropEvent;
-
- // When the system drag ends, its drag shadow disappears. Resume showing the drag
- // view for the possible final animation.
- mDragView.setVisibility(View.VISIBLE);
-
- final DropTarget dropTargetOverride = acceptedByAnotherWindow ?
- new AnotherWindowDropTarget(mDragView.getContext()) : null;
-
- mEventListener.onDriverDragEnd(mLastX, mLastY, dropTargetOverride);
- mIsFrameworkDragActive = false;
+ if (mReceivedDropEvent) {
+ mEventListener.onDriverDragEnd(mLastX, mLastY, null);
+ } else {
+ mEventListener.onDriverDragCancel();
+ }
return true;
default:
return false;
}
}
-};
+
+ private boolean updateInfoFromClipData(ClipData data, ClipDescription desc) {
+ if (data == null) {
+ return false;
+ }
+ ArrayList<Intent> intents = new ArrayList<>();
+ int itemCount = data.getItemCount();
+ for (int i = 0; i < itemCount; i++) {
+ Intent intent = data.getItemAt(i).getIntent();
+ if (intent == null) {
+ continue;
+ }
+
+ // Give preference to shortcut intents.
+ if (!Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction())) {
+ intents.add(intent);
+ continue;
+ }
+ ShortcutInfo info = InstallShortcutReceiver.fromShortcutIntent(mContext, intent);
+ if (info != null) {
+ mDragObject.dragInfo = info;
+ return true;
+ }
+ return true;
+ }
+
+ // Try creating shortcuts just using the intent and label
+ Intent fullIntent = new Intent().putExtra(Intent.EXTRA_SHORTCUT_NAME, desc.getLabel());
+ for (Intent intent : intents) {
+ fullIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
+ ShortcutInfo info = InstallShortcutReceiver.fromShortcutIntent(mContext, fullIntent);
+ if (info != null) {
+ mDragObject.dragInfo = info;
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
/**
* Class for driving an internal (i.e. not using framework) drag/drop operation.
@@ -244,8 +220,5 @@ class InternalDragDriver extends DragDriver {
}
@Override
- public void onDragViewAnimationEnd() {}
-
- @Override
public boolean onDragEvent (DragEvent event) { return false; }
};
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index dcff89f55..016347b17 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -21,14 +21,22 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
+import android.annotation.TargetApi;
+import android.content.ClipDescription;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.DragEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -45,12 +53,14 @@ import com.android.launcher3.AppWidgetResizeFrame;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DropTargetBar;
import com.android.launcher3.InsettableFrameLayout;
+import com.android.launcher3.InstallShortcutReceiver;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetHostView;
import com.android.launcher3.PinchToOverviewListener;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutAndWidgetContainer;
+import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.allapps.AllAppsTransitionController;
@@ -62,6 +72,7 @@ import com.android.launcher3.shortcuts.DeepShortcutsContainer;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.TouchController;
+import java.net.URISyntaxException;
import java.util.ArrayList;
/**
@@ -343,16 +354,9 @@ public class DragLayer extends InsettableFrameLayout {
}
private void sendTapOutsideFolderAccessibilityEvent(boolean isEditingName) {
- AccessibilityManager accessibilityManager = (AccessibilityManager)
- getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
- if (accessibilityManager.isEnabled()) {
- int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close;
- AccessibilityEvent event = AccessibilityEvent.obtain(
- AccessibilityEvent.TYPE_VIEW_FOCUSED);
- onInitializeAccessibilityEvent(event);
- event.getText().add(getContext().getString(stringId));
- accessibilityManager.sendAccessibilityEvent(event);
- }
+ int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close;
+ Utilities.sendCustomAccessibilityEvent(
+ this, AccessibilityEvent.TYPE_VIEW_FOCUSED, getContext().getString(stringId));
}
private boolean isInAccessibleDrag() {
@@ -362,37 +366,27 @@ public class DragLayer extends InsettableFrameLayout {
@Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
// Shortcuts can appear above folder
- View topView = mLauncher.getOpenShortcutsContainer();
+ View topView = mLauncher.getTopFloatingView();
if (topView != null) {
- return handleTopViewSendAccessibilityEvent(topView, child, event);
- }
-
- topView = mLauncher.getWorkspace().getOpenFolder();
- if (topView != null) {
- return handleTopViewSendAccessibilityEvent(topView, child, event);
+ if (child == topView) {
+ return super.onRequestSendAccessibilityEvent(child, event);
+ }
+ if (isInAccessibleDrag() && child instanceof DropTargetBar) {
+ return super.onRequestSendAccessibilityEvent(child, event);
+ }
+ // Skip propagating onRequestSendAccessibilityEvent for all other children
+ // which are not topView
+ return false;
}
return super.onRequestSendAccessibilityEvent(child, event);
}
- private boolean handleTopViewSendAccessibilityEvent(
- View topView, View child, AccessibilityEvent event) {
- if (child == topView) {
- return super.onRequestSendAccessibilityEvent(child, event);
- }
- if (isInAccessibleDrag() && child instanceof DropTargetBar) {
- return super.onRequestSendAccessibilityEvent(child, event);
- }
- // Skip propagating onRequestSendAccessibilityEvent for all other children
- // which are not topView
- return false;
- }
-
@Override
public void addChildrenForAccessibility(ArrayList<View> childrenForAccessibility) {
- Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
- if (currentFolder != null) {
- // Only add the folder as a child for accessibility when it is open
- childrenForAccessibility.add(currentFolder);
+ View topView = mLauncher.getTopFloatingView();
+ if (topView != null) {
+ // Only add the top view as a child for accessibility when it is open
+ childrenForAccessibility.add(topView);
if (isInAccessibleDrag()) {
childrenForAccessibility.add(mLauncher.getDropTargetBar());
@@ -448,8 +442,46 @@ public class DragLayer extends InsettableFrameLayout {
return false;
}
+ @TargetApi(Build.VERSION_CODES.N)
+ private void handleSystemDragStart(DragEvent event) {
+ if (!FeatureFlags.LAUNCHER3_USE_SYSTEM_DRAG_DRIVER || !Utilities.isNycOrAbove()) {
+ return;
+ }
+ if (mLauncher.isWorkspaceLocked()) {
+ return;
+ }
+
+ ClipDescription description = event.getClipDescription();
+ if (!description.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
+ return;
+ }
+ ShortcutInfo info = new ShortcutInfo();
+ // Set a dummy intent until we get the final value
+ info.intent = new Intent();
+
+ // Since we are not going through the workspace for starting the drag, set drag related
+ // information on the workspace before starting the drag.
+ ExternalDragPreviewProvider previewProvider =
+ new ExternalDragPreviewProvider(mLauncher, info);
+ mLauncher.getWorkspace().prepareDragWithProvider(previewProvider);
+
+ DragOptions options = new DragOptions();
+ options.systemDndStartPoint = new Point((int) event.getX(), (int) event.getY());
+
+ int halfPadding = previewProvider.previewPadding / 2;
+ mDragController.startDrag(
+ Bitmap.createBitmap(1, 1, Config.ARGB_8888),
+ 0, 0,
+ new AnotherWindowDragSource(mLauncher), info,
+ new Point(- halfPadding, halfPadding),
+ previewProvider.getPreviewBounds(), 1f, options);
+ }
+
@Override
public boolean onDragEvent (DragEvent event) {
+ if (event.getAction() == DragEvent.ACTION_DRAG_STARTED) {
+ handleSystemDragStart(event);
+ }
return mDragController.onDragEvent(event);
}
@@ -523,7 +555,9 @@ public class DragLayer extends InsettableFrameLayout {
@Override
public boolean dispatchUnhandledMove(View focused, int direction) {
- return mDragController.dispatchUnhandledMove(focused, direction);
+ // Consume the unhandled move if a container is open, to avoid switching pages underneath.
+ boolean isContainerOpen = mLauncher.getTopFloatingView() != null;
+ return isContainerOpen || mDragController.dispatchUnhandledMove(focused, direction);
}
@Override
@@ -773,11 +807,15 @@ public class DragLayer extends InsettableFrameLayout {
// If duration < 0, this is a cue to compute the duration based on the distance
if (duration < 0) {
- duration = res.getInteger(R.integer.config_dropAnimMaxDuration);
- if (dist < maxDist) {
- duration *= mCubicEaseOutInterpolator.getInterpolation(dist / maxDist);
+ if (mDragController != null && mDragController.isExternalDrag()) {
+ duration = 1;
+ } else {
+ duration = res.getInteger(R.integer.config_dropAnimMaxDuration);
+ if (dist < maxDist) {
+ duration *= mCubicEaseOutInterpolator.getInterpolation(dist / maxDist);
+ }
+ duration = Math.max(duration, res.getInteger(R.integer.config_dropAnimMinDuration));
}
- duration = Math.max(duration, res.getInteger(R.integer.config_dropAnimMinDuration));
}
// Fall back to cubic ease out interpolator for the animation if none is specified
@@ -1037,6 +1075,26 @@ public class DragLayer extends InsettableFrameLayout {
return mBackgroundAlpha;
}
+ @Override
+ protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
+ View topView = mLauncher.getTopFloatingView();
+ if (topView != null) {
+ return topView.requestFocus(direction, previouslyFocusedRect);
+ } else {
+ return super.onRequestFocusInDescendants(direction, previouslyFocusedRect);
+ }
+ }
+
+ @Override
+ public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
+ View topView = mLauncher.getTopFloatingView();
+ if (topView != null) {
+ topView.addFocusables(views, direction);
+ } else {
+ super.addFocusables(views, direction, focusableMode);
+ }
+ }
+
public void setTouchCompleteListener(TouchCompleteListener listener) {
mTouchCompleteListener = listener;
}
diff --git a/src/com/android/launcher3/dragndrop/DragOptions.java b/src/com/android/launcher3/dragndrop/DragOptions.java
new file mode 100644
index 000000000..3d52a48c6
--- /dev/null
+++ b/src/com/android/launcher3/dragndrop/DragOptions.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.dragndrop;
+
+import android.graphics.Point;
+
+/**
+ * Set of options to control the drag and drop behavior.
+ */
+public class DragOptions {
+
+ /** Whether or not an accessible drag operation is in progress. */
+ public boolean isAccessibleDrag = false;
+
+ /** Specifies the start location for the system DnD, null when using internal DnD */
+ public Point systemDndStartPoint = null;
+}
diff --git a/src/com/android/launcher3/dragndrop/ExternalDragPreviewProvider.java b/src/com/android/launcher3/dragndrop/ExternalDragPreviewProvider.java
new file mode 100644
index 000000000..6b14be714
--- /dev/null
+++ b/src/com/android/launcher3/dragndrop/ExternalDragPreviewProvider.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.dragndrop;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+
+import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.HolographicOutlineHelper;
+import com.android.launcher3.ItemInfo;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.graphics.DragPreviewProvider;
+
+/**
+ * Extension of {@link DragPreviewProvider} which provides a dummy outline when drag starts from
+ * a different window.
+ * It just draws an empty circle to a placeholder outline.
+ */
+public class ExternalDragPreviewProvider extends DragPreviewProvider {
+
+ private final Launcher mLauncher;
+ private final ItemInfo mAddInfo;
+
+ private final int[] mOutlineSize;
+
+ public ExternalDragPreviewProvider(Launcher launcher, ItemInfo addInfo) {
+ super(null);
+ mLauncher = launcher;
+ mAddInfo = addInfo;
+
+ mOutlineSize = mLauncher.getWorkspace().estimateItemSize(mAddInfo, false);
+ }
+
+ public Rect getPreviewBounds() {
+ Rect rect = new Rect();
+ DeviceProfile dp = mLauncher.getDeviceProfile();
+ rect.left = DRAG_BITMAP_PADDING / 2;
+ rect.top = (mOutlineSize[1] - dp.cellHeightPx) / 2;
+ rect.right = rect.left + dp.iconSizePx;
+ rect.bottom = rect.top + dp.iconSizePx;
+ return rect;
+ }
+
+ @Override
+ public Bitmap createDragOutline(Canvas canvas) {
+ final Bitmap b = Bitmap.createBitmap(mOutlineSize[0], mOutlineSize[1], Bitmap.Config.ALPHA_8);
+ canvas.setBitmap(b);
+
+ Paint paint = new Paint();
+ paint.setColor(Color.WHITE);
+ paint.setStyle(Paint.Style.FILL);
+
+ // Use 0.9f times the radius for the actual circle to account for icon normalization.
+ float radius = getPreviewBounds().width() * 0.5f;
+ canvas.drawCircle(DRAG_BITMAP_PADDING / 2 + radius,
+ DRAG_BITMAP_PADDING / 2 + radius, radius * 0.9f, paint);
+
+ HolographicOutlineHelper.obtain(mLauncher).applyExpensiveOutlineWithBlur(b, canvas);
+ canvas.setBitmap(null);
+ return b;
+ }
+}
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 96da18136..b64d12c1d 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -42,7 +42,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityManager;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.EditorInfo;
@@ -51,8 +50,8 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.launcher3.Alarm;
+import com.android.launcher3.AppInfo;
import com.android.launcher3.CellLayout;
-import com.android.launcher3.CellLayout.CellInfo;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
@@ -71,12 +70,12 @@ import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.UninstallDropTarget.DropTargetSource;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace.ItemOperator;
-import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.AccessibilityDragSource;
+import com.android.launcher3.accessibility.AccessibileDragListenerAdapter;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragController.DragListener;
import com.android.launcher3.dragndrop.DragLayer;
-import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.pageindicators.PageIndicatorDots;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
@@ -92,8 +91,7 @@ import java.util.Comparator;
*/
public class Folder extends LinearLayout implements DragSource, View.OnClickListener,
View.OnLongClickListener, DropTarget, FolderListener, TextView.OnEditorActionListener,
- View.OnFocusChangeListener, DragListener, DropTargetSource, AccessibilityDragSource,
- LaunchSourceProvider {
+ View.OnFocusChangeListener, DragListener, DropTargetSource {
private static final String TAG = "Launcher.Folder";
/**
@@ -166,10 +164,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mRearrangeOnClose = false;
boolean mItemsInvalidated = false;
- private ShortcutInfo mCurrentDragInfo;
private View mCurrentDragView;
private boolean mIsExternalDrag;
- boolean mSuppressOnAdd = false;
private boolean mDragInProgress = false;
private boolean mDeleteFolderOnDropCompleted = false;
private boolean mSuppressFolderDeletion = false;
@@ -283,10 +279,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
public boolean onLongClick(View v) {
// Return if global dragging is not enabled
if (!mLauncher.isDraggingEnabled()) return true;
- return beginDrag(v, false);
+ return startDrag(v, new DragOptions());
}
- private boolean beginDrag(View v, boolean accessible) {
+ public boolean startDrag(View v, DragOptions options) {
Object tag = v.getTag();
if (tag instanceof ShortcutInfo) {
ShortcutInfo item = (ShortcutInfo) tag;
@@ -294,35 +290,55 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
return false;
}
- mLauncher.getWorkspace().beginDragShared(v, this, accessible);
-
- mCurrentDragInfo = item;
mEmptyCellRank = item.rank;
mCurrentDragView = v;
- mContent.removeItem(mCurrentDragView);
- mInfo.remove(mCurrentDragInfo, true);
- mDragInProgress = true;
- mItemAddedBackToSelfViaIcon = false;
+ mDragController.addDragListener(this);
+ if (options.isAccessibleDrag) {
+ mDragController.addDragListener(new AccessibileDragListenerAdapter(
+ mContent, CellLayout.FOLDER_ACCESSIBILITY_DRAG) {
+
+ @Override
+ protected void enableAccessibleDrag(boolean enable) {
+ super.enableAccessibleDrag(enable);
+ mFooter.setImportantForAccessibility(enable
+ ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
+ : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
+ }
+ });
+ }
+
+ mLauncher.getWorkspace().beginDragShared(v, this, options);
}
return true;
}
@Override
- public void startDrag(CellInfo cellInfo, boolean accessible) {
- beginDrag(cellInfo.cell, accessible);
+ public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
+ if (dragObject.dragSource != this) {
+ return;
+ }
+
+ mContent.removeItem(mCurrentDragView);
+ if (dragObject.dragInfo instanceof ShortcutInfo) {
+ mItemsInvalidated = true;
+
+ // We do not want to get events for the item being removed, as they will get handled
+ // when the drop completes
+ try (SuppressInfoChanges s = new SuppressInfoChanges()) {
+ mInfo.remove((ShortcutInfo) dragObject.dragInfo, true);
+ }
+ }
+ mDragInProgress = true;
+ mItemAddedBackToSelfViaIcon = false;
}
@Override
- public void enableAccessibleDrag(boolean enable) {
- mLauncher.getDropTargetBar().enableAccessibleDrag(enable);
- for (int i = 0; i < mContent.getChildCount(); i++) {
- mContent.getPageAt(i).enableAccessibleDrag(enable, CellLayout.FOLDER_ACCESSIBILITY_DRAG);
+ public void onDragEnd() {
+ if (mIsExternalDrag && mDragInProgress) {
+ completeDragExit();
}
-
- mFooter.setImportantForAccessibility(enable ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS :
- IMPORTANT_FOR_ACCESSIBILITY_AUTO);
- mLauncher.getWorkspace().setAddNewPageOnDrag(!enable);
+ mDragController.removeDragListener(this);
}
public boolean isEditingName() {
@@ -353,7 +369,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
LauncherModel.updateItemInDatabase(mLauncher, mInfo);
if (commit) {
- sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
+ Utilities.sendCustomAccessibilityEvent(
+ this, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
getContext().getString(R.string.folder_renamed, newTitle));
}
@@ -592,7 +609,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
openFolderAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
- sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
+ Utilities.sendCustomAccessibilityEvent(
+ Folder.this,
+ AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
mContent.getAccessibilityDescription());
mState = STATE_ANIMATING;
}
@@ -651,9 +670,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mContent.verifyVisibleHighResIcons(mContent.getNextPage());
}
- public void beginExternalDrag(ShortcutInfo item) {
- mCurrentDragInfo = item;
- mEmptyCellRank = mContent.allocateRankForNewItem(item);
+ public void beginExternalDrag() {
+ mEmptyCellRank = mContent.allocateRankForNewItem();
mIsExternalDrag = true;
mDragInProgress = true;
@@ -662,28 +680,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mDragController.addDragListener(this);
}
- @Override
- public void onDragStart(DragSource source, ItemInfo info, int dragAction) { }
-
- @Override
- public void onDragEnd() {
- if (mIsExternalDrag && mDragInProgress) {
- completeDragExit();
- }
- mDragController.removeDragListener(this);
- }
-
- @Thunk void sendCustomAccessibilityEvent(int type, String text) {
- AccessibilityManager accessibilityManager = (AccessibilityManager)
- getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
- if (accessibilityManager.isEnabled()) {
- AccessibilityEvent event = AccessibilityEvent.obtain(type);
- onInitializeAccessibilityEvent(event);
- event.getText().add(text);
- accessibilityManager.sendAccessibilityEvent(event);
- }
- }
-
public void animateClosed() {
if (!(getParent() instanceof DragLayer)) return;
final ObjectAnimator oa = LauncherAnimUtils.ofViewAlphaAndScale(this, 0, 0.9f, 0.9f);
@@ -695,7 +691,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
@Override
public void onAnimationStart(Animator animation) {
- sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
+ Utilities.sendCustomAccessibilityEvent(
+ Folder.this,
+ AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
getContext().getString(R.string.folder_closed));
mState = STATE_ANIMATING;
}
@@ -852,9 +850,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
private void clearDragInfo() {
- mCurrentDragInfo = null;
mCurrentDragView = null;
- mSuppressOnAdd = false;
mIsExternalDrag = false;
}
@@ -918,9 +914,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mContent.arrangeChildren(views, views.size());
mItemsInvalidated = true;
- mSuppressOnAdd = true;
- mFolderIcon.onDrop(d);
- mSuppressOnAdd = false;
+ try (SuppressInfoChanges s = new SuppressInfoChanges()) {
+ mFolderIcon.onDrop(d);
+ }
}
if (target != this) {
@@ -937,9 +933,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mDeleteFolderOnDropCompleted = false;
mDragInProgress = false;
mItemAddedBackToSelfViaIcon = false;
- mCurrentDragInfo = null;
mCurrentDragView = null;
- mSuppressOnAdd = false;
// Reordering may have occured, and we need to save the new item locations. We do this once
// at the end to prevent unnecessary database operations.
@@ -1281,7 +1275,14 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mContent.completePendingPageChanges();
View currentDragView;
- ShortcutInfo si = mCurrentDragInfo;
+ final ShortcutInfo si;
+ if (d.dragInfo instanceof AppInfo) {
+ // Came from all apps -- make a copy.
+ si = ((AppInfo) d.dragInfo).makeShortcut();
+ } else {
+ // ShortcutInfo
+ si = (ShortcutInfo) d.dragInfo;
+ }
if (mIsExternalDrag) {
currentDragView = mContent.createAndAddViewForRank(si, mEmptyCellRank);
// Actually move the item in the database if it was an external drag. Call this
@@ -1318,11 +1319,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
rearrangeChildren();
// Temporarily suppress the listener, as we did all the work already here.
- mSuppressOnAdd = true;
- mInfo.add(si, false);
- mSuppressOnAdd = false;
+ try (SuppressInfoChanges s = new SuppressInfoChanges()) {
+ mInfo.add(si, false);
+ }
+
// Clear the drag info, as it is no longer being dragged.
- mCurrentDragInfo = null;
mDragInProgress = false;
if (mContent.getPageCount() > 1) {
@@ -1345,10 +1346,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
@Override
public void onAdd(ShortcutInfo item) {
- // If the item was dropped onto this open folder, we have done the work associated
- // with adding the item to the folder, as indicated by mSuppressOnAdd being set
- if (mSuppressOnAdd) return;
- mContent.createAndAddViewForRank(item, mContent.allocateRankForNewItem(item));
+ mContent.createAndAddViewForRank(item, mContent.allocateRankForNewItem());
mItemsInvalidated = true;
LauncherModel.addOrMoveItemInDatabase(
mLauncher, item, mInfo.id, 0, item.cellX, item.cellY);
@@ -1356,9 +1354,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
public void onRemove(ShortcutInfo item) {
mItemsInvalidated = true;
- // If this item is being dragged from this open folder, we have already handled
- // the work associated with removing the item, so we don't have to do anything here.
- if (item == mCurrentDragInfo) return;
View v = getViewForInfo(item);
mContent.removeItem(v);
if (mState == STATE_ANIMATING) {
@@ -1497,4 +1492,20 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
}
};
+
+ /**
+ * Temporary resource held while we don't want to handle info changes
+ */
+ private class SuppressInfoChanges implements AutoCloseable {
+
+ SuppressInfoChanges() {
+ mInfo.removeListener(Folder.this);
+ }
+
+ @Override
+ public void close() {
+ mInfo.addListener(Folder.this);
+ updateTextViewFocus();
+ }
+ }
}
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index eebbfe8b7..69c2b0fa3 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -125,8 +125,6 @@ public class FolderIcon extends FrameLayout implements FolderListener {
Paint mBgPaint = new Paint();
private Alarm mOpenAlarm = new Alarm();
- @Thunk
- ItemInfo mDragInfo;
public FolderIcon(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -195,8 +193,6 @@ public class FolderIcon extends FrameLayout implements FolderListener {
return super.onSaveInstanceState();
}
-
-
public Folder getFolder() {
return mFolder;
}
@@ -242,22 +238,11 @@ public class FolderIcon extends FrameLayout implements FolderListener {
// Workspace#onDropExternal.
mOpenAlarm.setAlarm(ON_OPEN_DELAY);
}
- mDragInfo = dragInfo;
}
OnAlarmListener mOnOpenListener = new OnAlarmListener() {
public void onAlarm(Alarm alarm) {
- ShortcutInfo item;
- if (mDragInfo instanceof AppInfo) {
- // Came from all apps -- make a copy.
- item = ((AppInfo) mDragInfo).makeShortcut();
- item.spanX = 1;
- item.spanY = 1;
- } else {
- // ShortcutInfo
- item = (ShortcutInfo) mDragInfo;
- }
- mFolder.beginExternalDrag(item);
+ mFolder.beginExternalDrag();
mLauncher.openFolder(FolderIcon.this);
}
};
@@ -284,7 +269,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
animateFirstItem(animateDrawable, INITIAL_ITEM_ANIMATION_DURATION, false, null);
// This will animate the dragView (srcView) into the new folder
- onDrop(srcInfo, srcView, dstRect, scaleRelativeToDragLayer, 1, postAnimationRunnable, null);
+ onDrop(srcInfo, srcView, dstRect, scaleRelativeToDragLayer, 1, postAnimationRunnable);
}
public void performDestroyAnimation(final View finalView, Runnable onCompleteRunnable) {
@@ -298,18 +283,13 @@ public class FolderIcon extends FrameLayout implements FolderListener {
onCompleteRunnable);
}
- public void onDragExit(Object dragInfo) {
- onDragExit();
- }
-
public void onDragExit() {
mBackground.animateToRest();
mOpenAlarm.cancelAlarm();
}
private void onDrop(final ShortcutInfo item, DragView animateView, Rect finalRect,
- float scaleRelativeToDragLayer, int index, Runnable postAnimationRunnable,
- DragObject d) {
+ float scaleRelativeToDragLayer, int index, Runnable postAnimationRunnable) {
item.cellX = -1;
item.cellY = -1;
@@ -379,7 +359,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
item = (ShortcutInfo) d.dragInfo;
}
mFolder.notifyDrop();
- onDrop(item, d.dragView, null, 1.0f, mInfo.contents.size(), d.postAnimationRunnable, d);
+ onDrop(item, d.dragView, null, 1.0f, mInfo.contents.size(), d.postAnimationRunnable);
}
private void computePreviewDrawingParams(int drawableSize, int totalSize) {
diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java
index 3df1d2438..1171d488d 100644
--- a/src/com/android/launcher3/folder/FolderPagedView.java
+++ b/src/com/android/launcher3/folder/FolderPagedView.java
@@ -195,7 +195,7 @@ public class FolderPagedView extends PagedView {
* Create space for a new item at the end, and returns the rank for that item.
* Also sets the current page to the last page.
*/
- public int allocateRankForNewItem(ShortcutInfo info) {
+ public int allocateRankForNewItem() {
int rank = getItemCount();
ArrayList<View> views = new ArrayList<>(mFolder.getItemsInReadingOrder());
views.add(rank, null);
diff --git a/src/com/android/launcher3/graphics/DragPreviewProvider.java b/src/com/android/launcher3/graphics/DragPreviewProvider.java
index e078d9b15..bc91c15be 100644
--- a/src/com/android/launcher3/graphics/DragPreviewProvider.java
+++ b/src/com/android/launcher3/graphics/DragPreviewProvider.java
@@ -27,7 +27,6 @@ import android.widget.TextView;
import com.android.launcher3.HolographicOutlineHelper;
import com.android.launcher3.Launcher;
import com.android.launcher3.PreloadIconDrawable;
-import com.android.launcher3.R;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.folder.FolderIcon;
@@ -134,14 +133,12 @@ public class DragPreviewProvider {
* Responsibility for the bitmap is transferred to the caller.
*/
public Bitmap createDragOutline(Canvas canvas) {
- final int outlineColor = mView.getResources().getColor(R.color.outline_color);
final Bitmap b = Bitmap.createBitmap(mView.getWidth() + DRAG_BITMAP_PADDING,
- mView.getHeight() + DRAG_BITMAP_PADDING, Bitmap.Config.ARGB_8888);
-
+ mView.getHeight() + DRAG_BITMAP_PADDING, Bitmap.Config.ALPHA_8);
canvas.setBitmap(b);
drawDragView(canvas);
HolographicOutlineHelper.obtain(mView.getContext())
- .applyExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor);
+ .applyExpensiveOutlineWithBlur(b, canvas);
canvas.setBitmap(null);
return b;
}
diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java
index dc045977d..845dbc2bc 100644
--- a/src/com/android/launcher3/logging/LoggerUtils.java
+++ b/src/com/android/launcher3/logging/LoggerUtils.java
@@ -2,8 +2,12 @@ package com.android.launcher3.logging;
import android.view.View;
+import com.android.launcher3.ButtonDropTarget;
+import com.android.launcher3.DeleteDropTarget;
+import com.android.launcher3.InfoDropTarget;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherSettings;
+import com.android.launcher3.UninstallDropTarget;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
@@ -164,14 +168,35 @@ public class LoggerUtils {
return event;
}
- private static Target initTarget(View v) {
+ /**
+ * Used for drag and drop interaction.
+ */
+ public static LauncherLogProto.LauncherEvent initLauncherEvent(
+ int actionType,
+ View v,
+ ItemInfo info,
+ int parentSrcTargetType,
+ View parentDestTargetType){
+ LauncherLogProto.LauncherEvent event = new LauncherLogProto.LauncherEvent();
+
+ event.srcTarget = new LauncherLogProto.Target[2];
+ event.srcTarget[0] = initTarget(v, info);
+ event.srcTarget[1] = new LauncherLogProto.Target();
+ event.srcTarget[1].type = parentSrcTargetType;
+
+ event.destTarget = new LauncherLogProto.Target[2];
+ event.destTarget[0] = initTarget(v, info);
+ event.destTarget[1] = initDropTarget(parentDestTargetType);
+
+ event.action = new LauncherLogProto.Action();
+ event.action.type = actionType;
+ return event;
+ }
+
+ private static Target initTarget(View v, ItemInfo info) {
Target t = new LauncherLogProto.Target();
t.type = Target.ITEM;
- if (!(v.getTag() instanceof ItemInfo)) {
- return t;
- }
- ItemInfo itemInfo = (ItemInfo) v.getTag();
- switch (itemInfo.itemType) {
+ switch (info.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
t.itemType = LauncherLogProto.APP_ICON;
break;
@@ -190,4 +215,30 @@ public class LoggerUtils {
}
return t;
}
+
+ private static Target initDropTarget(View v) {
+ Target t = new LauncherLogProto.Target();
+ t.type = (v instanceof ButtonDropTarget)? Target.CONTROL : Target.CONTAINER;
+ if (t.type == Target.CONTAINER) {
+ return t;
+ }
+
+ if (v instanceof InfoDropTarget) {
+ t.controlType = LauncherLogProto.APPINFO_TARGET;
+ } else if (v instanceof UninstallDropTarget) {
+ t.controlType = LauncherLogProto.UNINSTALL_TARGET;
+ } else if (v instanceof DeleteDropTarget) {
+ t.controlType = LauncherLogProto.REMOVE_TARGET;
+ }
+ return t;
+ }
+
+ private static Target initTarget(View v) {
+ Target t = new LauncherLogProto.Target();
+ t.type = Target.ITEM;
+ if (!(v.getTag() instanceof ItemInfo)) {
+ return t;
+ }
+ return initTarget(v, (ItemInfo) v.getTag());
+ }
}
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index e4cc182cf..0356a9c7b 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -18,12 +18,15 @@ package com.android.launcher3.logging;
import android.content.ComponentName;
import android.content.Intent;
+import android.os.SystemClock;
import android.util.Log;
import android.view.View;
import android.view.ViewParent;
+import com.android.launcher3.DropTarget;
import com.android.launcher3.ItemInfo;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
@@ -37,10 +40,15 @@ import java.util.Locale;
*/
public class UserEventDispatcher {
- private static final boolean DEBUG_LOGGING = false;
private final static int MAXIMUM_VIEW_HIERARCHY_LEVEL = 5;
+ private final boolean mIsVerbose;
+
/**
+ * TODO: change the name of this interface to LogContainerProvider
+ * and the method name to fillInLogContainerData. Not changed to minimize CL diff
+ * in this branch.
+ *
* Implemented by containers to provide a launch source for a given child.
*/
public interface LaunchSourceProvider {
@@ -61,6 +69,7 @@ public class UserEventDispatcher {
*/
public static LaunchSourceProvider getLaunchProviderRecursive(View v) {
ViewParent parent = null;
+
if (v != null) {
parent = v.getParent();
} else {
@@ -88,6 +97,14 @@ public class UserEventDispatcher {
// Used for filling in predictedRank on {@link Target}s.
private List<ComponentKey> mPredictedApps;
+ public UserEventDispatcher() {
+ if (ProviderConfig.IS_DOGFOOD_BUILD) {
+ mIsVerbose = Utilities.isPropertyEnabled(TAG);
+ } else {
+ mIsVerbose = false;
+ }
+ }
+
// APP_ICON SHORTCUT WIDGET
// --------------------------------------------------------------
// packageNameHash required optional required
@@ -104,7 +121,7 @@ public class UserEventDispatcher {
// TODO: make this percolate up the view hierarchy if needed.
int idx = 0;
LaunchSourceProvider provider = getLaunchProviderRecursive(v);
- if (!(v.getTag() instanceof ItemInfo)) {
+ if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) {
return null;
}
ItemInfo itemInfo = (ItemInfo) v.getTag();
@@ -122,8 +139,8 @@ public class UserEventDispatcher {
}
// Fill in the duration of time spent navigating in Launcher and the container.
- event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis;
- event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis;
+ event.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis;
+ event.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis;
return event;
}
@@ -139,8 +156,8 @@ public class UserEventDispatcher {
LauncherEvent event = LoggerUtils.initLauncherEvent(Action.TOUCH, Target.CONTROL);
event.action.touch = action;
event.srcTarget[0].controlType = controlType;
- event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis;
- event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis;
+ event.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis;
+ event.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis;
dispatchUserEvent(event, null);
}
@@ -149,8 +166,8 @@ public class UserEventDispatcher {
event.action.touch = action;
event.action.dir = dir;
event.srcTarget[0].containerType = containerType;
- event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis;
- event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis;
+ event.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis;
+ event.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis;
dispatchUserEvent(event, null);
}
@@ -158,14 +175,14 @@ public class UserEventDispatcher {
LauncherEvent event = LoggerUtils.initLauncherEvent(
Action.TOUCH, icon, Target.CONTAINER);
LaunchSourceProvider provider = getLaunchProviderRecursive(icon);
- if (!(icon.getTag() instanceof ItemInfo)) {
+ if (icon == null && !(icon.getTag() instanceof ItemInfo)) {
return;
}
ItemInfo info = (ItemInfo) icon.getTag();
provider.fillInLaunchSourceData(icon, info, event.srcTarget[0], event.srcTarget[1]);
event.action.touch = Action.LONGPRESS;
- event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis;
- event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis;
+ event.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis;
+ event.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis;
dispatchUserEvent(event, null);
}
@@ -173,39 +190,66 @@ public class UserEventDispatcher {
mPredictedApps = predictedApps;
}
+ public void logDragNDrop(DropTarget.DragObject dragObj, View dropTargetAsView) {
+ LauncherEvent event = LoggerUtils.initLauncherEvent(Action.TOUCH,
+ dragObj.dragView,
+ dragObj.originalDragInfo,
+ Target.CONTAINER,
+ dropTargetAsView);
+ event.action.touch = Action.DRAGDROP;
+
+ dragObj.dragSource.fillInLaunchSourceData(null, dragObj.originalDragInfo,
+ event.srcTarget[0], event.srcTarget[1]);
+
+ if (dropTargetAsView instanceof LaunchSourceProvider) {
+ ((LaunchSourceProvider) dropTargetAsView).fillInLaunchSourceData(null,
+ dragObj.dragInfo, event.destTarget[0], event.destTarget[1]);
+
+ }
+
+ event.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis;
+ event.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis;
+ event.actionDurationMillis = SystemClock.uptimeMillis() - mActionDurationMillis;
+ dispatchUserEvent(event, null);
+ }
+
/**
* Currently logs following containers: workspace, allapps, widget tray.
*/
public final void resetElapsedContainerMillis() {
- mElapsedContainerMillis = System.currentTimeMillis();
+ mElapsedContainerMillis = SystemClock.uptimeMillis();
}
public final void resetElapsedSessionMillis() {
- mElapsedSessionMillis = System.currentTimeMillis();
- mElapsedContainerMillis = System.currentTimeMillis();
+ mElapsedSessionMillis = SystemClock.uptimeMillis();
+ mElapsedContainerMillis = SystemClock.uptimeMillis();
}
public final void resetActionDurationMillis() {
- mActionDurationMillis = System.currentTimeMillis();
+ mActionDurationMillis = SystemClock.uptimeMillis();
}
public void dispatchUserEvent(LauncherEvent ev, Intent intent) {
- if (DEBUG_LOGGING) {
- Log.d(TAG, String.format(Locale.US,
- "\naction:%s\n Source child:%s\tparent:%s",
- LoggerUtils.getActionStr(ev.action),
- LoggerUtils.getTargetStr(ev.srcTarget != null ? ev.srcTarget[0] : null),
- LoggerUtils.getTargetStr(ev.srcTarget.length > 1 ? ev.srcTarget[1] : null)));
- if (ev.destTarget != null && ev.destTarget.length > 0) {
- Log.d(TAG, String.format(Locale.US,
- " Destination child:%s\tparent:%s",
- LoggerUtils.getTargetStr(ev.destTarget != null ? ev.destTarget[0] : null),
- LoggerUtils.getTargetStr(ev.destTarget.length > 1 ? ev.destTarget[1] : null)));
- }
+ if (!mIsVerbose) {
+ return;
+ }
+ Log.d(TAG, String.format(Locale.US,
+ "\naction:%s\n Source child:%s\tparent:%s",
+ LoggerUtils.getActionStr(ev.action),
+ LoggerUtils.getTargetStr(ev.srcTarget != null ? ev.srcTarget[0] : null),
+ LoggerUtils.getTargetStr(ev.srcTarget != null && ev.srcTarget.length > 1 ?
+ ev.srcTarget[1] : null)));
+ if (ev.destTarget != null && ev.destTarget.length > 0) {
Log.d(TAG, String.format(Locale.US,
- " Elapsed container %d ms session %d ms",
- ev.elapsedContainerMillis,
- ev.elapsedSessionMillis));
+ " Destination child:%s\tparent:%s",
+ LoggerUtils.getTargetStr(ev.destTarget != null ? ev.destTarget[0] : null),
+ LoggerUtils.getTargetStr(ev.destTarget != null && ev.destTarget.length > 1 ?
+ ev.destTarget[1] : null)));
}
+ Log.d(TAG, String.format(Locale.US,
+ " Elapsed container %d ms session %d ms action %d ms",
+ ev.elapsedContainerMillis,
+ ev.elapsedSessionMillis,
+ ev.actionDurationMillis));
}
}
diff --git a/src/com/android/launcher3/model/PackageItemInfo.java b/src/com/android/launcher3/model/PackageItemInfo.java
index ddc9cbfd9..c86ba86fd 100644
--- a/src/com/android/launcher3/model/PackageItemInfo.java
+++ b/src/com/android/launcher3/model/PackageItemInfo.java
@@ -46,17 +46,12 @@ public class PackageItemInfo extends ItemInfo {
*/
public String titleSectionName;
- int flags = 0;
-
PackageItemInfo(String packageName) {
this.packageName = packageName;
}
@Override
- public String toString() {
- return "PackageItemInfo(title=" + title + " id=" + this.id
- + " type=" + this.itemType + " container=" + this.container
- + " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY
- + " spanX=" + spanX + " spanY=" + spanY + " user=" + user + ")";
+ protected String dumpProperties() {
+ return super.dumpProperties() + " packageName=" + packageName;
}
}
diff --git a/src/com/android/launcher3/pageindicators/CaretDrawable.java b/src/com/android/launcher3/pageindicators/CaretDrawable.java
index 1451773af..4789f69f5 100644
--- a/src/com/android/launcher3/pageindicators/CaretDrawable.java
+++ b/src/com/android/launcher3/pageindicators/CaretDrawable.java
@@ -37,6 +37,7 @@ public class CaretDrawable extends Drawable {
private Paint mShadowPaint = new Paint();
private Paint mCaretPaint = new Paint();
private Path mPath = new Path();
+ private final int mCaretSizePx;
public CaretDrawable(Context context) {
final Resources res = context.getResources();
@@ -57,6 +58,18 @@ public class CaretDrawable extends Drawable {
mShadowPaint.setStyle(Paint.Style.STROKE);
mShadowPaint.setStrokeCap(Paint.Cap.ROUND);
mShadowPaint.setStrokeJoin(Paint.Join.ROUND);
+
+ mCaretSizePx = res.getDimensionPixelSize(R.dimen.all_apps_caret_size);
+ }
+
+ @Override
+ public int getIntrinsicHeight() {
+ return mCaretSizePx;
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return mCaretSizePx;
}
@Override
diff --git a/src/com/android/launcher3/pageindicators/PageIndicator.java b/src/com/android/launcher3/pageindicators/PageIndicator.java
index b53715d98..47c2ffb38 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicator.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicator.java
@@ -18,20 +18,21 @@ package com.android.launcher3.pageindicators;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
-import android.view.View;
+import android.widget.FrameLayout;
import com.android.launcher3.dynamicui.ExtractedColors;
/**
* Base class for a page indicator.
*/
-public abstract class PageIndicator extends View {
+public abstract class PageIndicator extends FrameLayout {
private CaretDrawable mCaretDrawable;
protected int mNumPages = 1;
public PageIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
+ setWillNotDraw(false);
}
public void setScroll(int currentScroll, int totalScroll) {}
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
index 747c21bbe..fb9d2f7fe 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
@@ -226,11 +226,6 @@ public class PageIndicatorDots extends PageIndicator {
public void setActiveMarker(int activePage) {
if (mActivePage != activePage) {
mActivePage = activePage;
-
- // Simulate a scroll change
- int totalScroll = mNumPages - 1;
- int currentScroll = mIsRtl ? (totalScroll - mActivePage) : mActivePage;
- setScroll(currentScroll, totalScroll);
}
}
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java b/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
index 0d771adb7..350bc8a9b 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
@@ -15,14 +15,13 @@ import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Property;
-import android.view.View;
import android.view.ViewConfiguration;
+import android.widget.ImageView;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dynamicui.ExtractedColors;
-import com.android.launcher3.util.TransformingTouchDelegate;
/**
* A PageIndicator that briefly shows a fraction of a line when moving between pages.
@@ -60,10 +59,7 @@ public class PageIndicatorLineCaret extends PageIndicator {
private Paint mLinePaint;
private Launcher mLauncher;
private final int mLineHeight;
- private final TransformingTouchDelegate mTouchDelegate;
- private final int mTouchExtensionHeight;
- private final int mCaretSizePx;
- private final int mCaretWorkspaceOffsetPx;
+ private ImageView mAllAppsHandle;
private static final Property<PageIndicatorLineCaret, Integer> PAINT_ALPHA
= new Property<PageIndicatorLineCaret, Integer>(Integer.class, "paint_alpha") {
@@ -128,48 +124,26 @@ public class PageIndicatorLineCaret extends PageIndicator {
Resources res = context.getResources();
mLinePaint = new Paint();
mLinePaint.setAlpha(0);
- mCaretSizePx = res.getDimensionPixelSize(R.dimen.all_apps_caret_size);
- mCaretWorkspaceOffsetPx = res.getDimensionPixelSize(
- R.dimen.all_apps_caret_workspace_offset);
mLauncher = (Launcher) context;
- setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
- setOnClickListener(mLauncher);
- setOnLongClickListener(mLauncher);
- setOnFocusChangeListener(mLauncher.mFocusHandler);
- setCaretDrawable(new CaretDrawable(context));
mLineHeight = res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_line_height);
- mTouchExtensionHeight = res.getDimensionPixelSize(
- R.dimen.dynamic_grid_page_indicator_extra_touch_height);
- mTouchDelegate = new TransformingTouchDelegate(this);
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- mLauncher.getDragLayer().setTouchDelegate(mTouchDelegate);
+ setCaretDrawable(new CaretDrawable(context));
}
@Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- // Top/center align the caret in the page indicator space
- int l = (right - left) / 2 - mCaretSizePx / 2;
- getCaretDrawable().setBounds(l, mCaretWorkspaceOffsetPx, l + mCaretSizePx,
- mCaretWorkspaceOffsetPx + mCaretSizePx);
-
- // The touch area is expanded below this view by #mTouchExtensionHeight
- // which extends to the top of the hotseat.
- View parent = mLauncher.getDragLayer();
- sTempCoords[0] = sTempCoords[1] = 0;
- Utilities.getDescendantCoordRelativeToAncestor(this, parent, sTempCoords, true);
- mTouchDelegate.setBounds(sTempCoords[0], sTempCoords[1], sTempCoords[0] + this.getWidth(),
- sTempCoords[1] + getHeight() + mTouchExtensionHeight);
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mAllAppsHandle = (ImageView) findViewById(R.id.all_apps_handle);
+ mAllAppsHandle.setImageDrawable(getCaretDrawable());
+ mAllAppsHandle.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
+ mAllAppsHandle.setOnClickListener(mLauncher);
+ mAllAppsHandle.setOnLongClickListener(mLauncher);
+ mAllAppsHandle.setOnFocusChangeListener(mLauncher.mFocusHandler);
+ mLauncher.setAllAppsButton(mAllAppsHandle);
}
@Override
protected void onDraw(Canvas canvas) {
- getCaretDrawable().draw(canvas);
if (mTotalScroll == 0 || mNumPagesFloat == 0) {
return;
}
@@ -185,6 +159,11 @@ public class PageIndicatorLineCaret extends PageIndicator {
}
@Override
+ public void setContentDescription(CharSequence contentDescription) {
+ mAllAppsHandle.setContentDescription(contentDescription);
+ }
+
+ @Override
public void setScroll(int currentScroll, int totalScroll) {
if (getAlpha() == 0) {
return;
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
index 5a7044aa4..7657ed610 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
@@ -62,9 +62,9 @@ import com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.graphics.TriangleShape;
-import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
@@ -76,8 +76,7 @@ import java.util.List;
*/
@TargetApi(Build.VERSION_CODES.N)
public class DeepShortcutsContainer extends LinearLayout implements View.OnLongClickListener,
- View.OnTouchListener, DragSource, DragController.DragListener,
- UserEventDispatcher.LaunchSourceProvider {
+ View.OnTouchListener, DragSource, DragController.DragListener {
private static final String TAG = "ShortcutsContainer";
private final Point mIconShift = new Point();
@@ -255,8 +254,10 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC
@Override
public void onAnimationEnd(Animator animation) {
mOpenCloseAnimator = null;
-
- sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+ Utilities.sendCustomAccessibilityEvent(
+ DeepShortcutsContainer.this,
+ AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
+ getContext().getString(R.string.action_deep_shortcut));
}
});
@@ -516,8 +517,8 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC
mIconShift.y = mIconLastTouchPos.y - mLauncher.getDeviceProfile().iconSizePx;
DragView dv = mLauncher.getWorkspace().beginDragShared(
- sv.getBubbleText(), this, false, sv.getFinalInfo(),
- new ShortcutDragPreviewProvider(sv.getIconView(), mIconShift));
+ sv.getBubbleText(), this, sv.getFinalInfo(),
+ new ShortcutDragPreviewProvider(sv.getIconView(), mIconShift), new DragOptions());
dv.animateShift(-mIconShift.x, -mIconShift.y);
// TODO: support dragging from within folder without having to close it
@@ -561,7 +562,7 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC
}
@Override
- public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
+ public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
// Either the original icon or one of the shortcuts was dragged.
// Hide the container, but don't remove it yet because that interferes with touch events.
animateClose();
@@ -578,8 +579,7 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC
} else {
// Close animation is not running.
if (mDeferContainerRemoval) {
- mDeferContainerRemoval = false;
- mLauncher.getDragLayer().removeView(this);
+ close();
}
}
}
@@ -600,7 +600,6 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC
mOpenCloseAnimator.cancel();
}
mIsOpen = false;
- mLauncher.getDragController().removeDragListener(this);
final AnimatorSet shortcutAnims = LauncherAnimUtils.createAnimatorSet();
final int shortcutCount = getShortcutCount();
diff --git a/src/com/android/launcher3/shortcuts/ShortcutDragPreviewProvider.java b/src/com/android/launcher3/shortcuts/ShortcutDragPreviewProvider.java
index a25e475d4..2adb82e2d 100644
--- a/src/com/android/launcher3/shortcuts/ShortcutDragPreviewProvider.java
+++ b/src/com/android/launcher3/shortcuts/ShortcutDragPreviewProvider.java
@@ -22,12 +22,9 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.View;
-import android.widget.ImageView;
-import com.android.launcher3.BubbleTextView;
import com.android.launcher3.HolographicOutlineHelper;
import com.android.launcher3.Launcher;
-import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.graphics.DragPreviewProvider;
@@ -45,23 +42,22 @@ public class ShortcutDragPreviewProvider extends DragPreviewProvider {
@Override
public Bitmap createDragOutline(Canvas canvas) {
- Bitmap b = drawScaledPreview(canvas);
+ Bitmap b = drawScaledPreview(canvas, Bitmap.Config.ALPHA_8);
- final int outlineColor = mView.getResources().getColor(R.color.outline_color);
HolographicOutlineHelper.obtain(mView.getContext())
- .applyExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor);
+ .applyExpensiveOutlineWithBlur(b, canvas);
canvas.setBitmap(null);
return b;
}
@Override
public Bitmap createDragBitmap(Canvas canvas) {
- Bitmap b = drawScaledPreview(canvas);
+ Bitmap b = drawScaledPreview(canvas, Bitmap.Config.ARGB_8888);
canvas.setBitmap(null);
return b;
}
- private Bitmap drawScaledPreview(Canvas canvas) {
+ private Bitmap drawScaledPreview(Canvas canvas, Bitmap.Config config) {
Drawable d = mView.getBackground();
Rect bounds = getDrawableBounds(d);
@@ -70,7 +66,7 @@ public class ShortcutDragPreviewProvider extends DragPreviewProvider {
final Bitmap b = Bitmap.createBitmap(
size + DRAG_BITMAP_PADDING,
size + DRAG_BITMAP_PADDING,
- Bitmap.Config.ARGB_8888);
+ config);
canvas.setBitmap(b);
canvas.save(Canvas.MATRIX_SAVE_FLAG);
diff --git a/src/com/android/launcher3/testing/LauncherExtension.java b/src/com/android/launcher3/testing/LauncherExtension.java
index 0affc81f8..6797c7ba3 100644
--- a/src/com/android/launcher3/testing/LauncherExtension.java
+++ b/src/com/android/launcher3/testing/LauncherExtension.java
@@ -139,13 +139,8 @@ public class LauncherExtension extends Launcher {
}
@Override
- public boolean providesSearch() {
- return false;
- }
-
- @Override
public boolean startSearch(String initialQuery, boolean selectInitialQuery,
- Bundle appSearchData, Rect sourceBounds) {
+ Bundle appSearchData) {
return false;
}
diff --git a/src/com/android/launcher3/util/ActivityResultInfo.java b/src/com/android/launcher3/util/ActivityResultInfo.java
new file mode 100644
index 000000000..2261bee8c
--- /dev/null
+++ b/src/com/android/launcher3/util/ActivityResultInfo.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.util;
+
+import android.content.Intent;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Utility class which stores information from onActivityResult
+ */
+public class ActivityResultInfo implements Parcelable {
+
+ public final int requestCode;
+ public final int resultCode;
+ public final Intent data;
+
+ public ActivityResultInfo(int requestCode, int resultCode, Intent data) {
+ this.requestCode = requestCode;
+ this.resultCode = resultCode;
+ this.data = data;
+ }
+
+ private ActivityResultInfo(Parcel parcel) {
+ requestCode = parcel.readInt();
+ resultCode = parcel.readInt();
+ data = parcel.readInt() != 0 ? Intent.CREATOR.createFromParcel(parcel) : null;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(requestCode);
+ dest.writeInt(resultCode);
+ if (data != null) {
+ dest.writeInt(1);
+ data.writeToParcel(dest, flags);
+ } else {
+ dest.writeInt(0);
+ }
+ }
+
+ public static final Parcelable.Creator<ActivityResultInfo> CREATOR =
+ new Parcelable.Creator<ActivityResultInfo>() {
+ public ActivityResultInfo createFromParcel(Parcel source) {
+ return new ActivityResultInfo(source);
+ }
+
+ public ActivityResultInfo[] newArray(int size) {
+ return new ActivityResultInfo[size];
+ }
+ };
+}
diff --git a/src/com/android/launcher3/util/PackageManagerHelper.java b/src/com/android/launcher3/util/PackageManagerHelper.java
index 3c4c79aec..3e15d05e1 100644
--- a/src/com/android/launcher3/util/PackageManagerHelper.java
+++ b/src/com/android/launcher3/util/PackageManagerHelper.java
@@ -16,10 +16,15 @@
package com.android.launcher3.util;
+import android.app.AppOpsManager;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
+import android.os.Build;
+import android.text.TextUtils;
import com.android.launcher3.Utilities;
@@ -96,4 +101,53 @@ public class PackageManagerHelper {
}
return excludePackages.get(0);
}
+
+ /**
+ * Returns true if {@param srcPackage} has the permission required to start the activity from
+ * {@param intent}. If {@param srcPackage} is null, then the activity should not need
+ * any permissions
+ */
+ public static boolean hasPermissionForActivity(Context context, Intent intent,
+ String srcPackage) {
+ PackageManager pm = context.getPackageManager();
+ ResolveInfo target = pm.resolveActivity(intent, 0);
+ if (target == null) {
+ // Not a valid target
+ return false;
+ }
+ if (TextUtils.isEmpty(target.activityInfo.permission)) {
+ // No permission is needed
+ return true;
+ }
+ if (TextUtils.isEmpty(srcPackage)) {
+ // The activity requires some permission but there is no source.
+ return false;
+ }
+
+ // Source does not have sufficient permissions.
+ if(pm.checkPermission(target.activityInfo.permission, srcPackage) !=
+ PackageManager.PERMISSION_GRANTED) {
+ return false;
+ }
+
+ if (!Utilities.ATLEAST_MARSHMALLOW) {
+ // These checks are sufficient for below M devices.
+ return true;
+ }
+
+ // On M and above also check AppOpsManager for compatibility mode permissions.
+ if (TextUtils.isEmpty(AppOpsManager.permissionToOp(target.activityInfo.permission))) {
+ // There is no app-op for this permission, which could have been disabled.
+ return true;
+ }
+
+ // There is no direct way to check if the app-op is allowed for a particular app. Since
+ // app-op is only enabled for apps running in compatibility mode, simply block such apps.
+
+ try {
+ return pm.getApplicationInfo(srcPackage, 0).targetSdkVersion >= Build.VERSION_CODES.M;
+ } catch (NameNotFoundException e) { }
+
+ return false;
+ }
}
diff --git a/src/com/android/launcher3/util/PendingRequestArgs.java b/src/com/android/launcher3/util/PendingRequestArgs.java
new file mode 100644
index 000000000..4e402f348
--- /dev/null
+++ b/src/com/android/launcher3/util/PendingRequestArgs.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.util;
+
+import android.content.ContentValues;
+import android.content.Intent;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import com.android.launcher3.ItemInfo;
+import com.android.launcher3.LauncherAppWidgetProviderInfo;
+
+/**
+ * Utility class to store information regarding a pending request made by launcher. This information
+ * can be saved across launcher instances.
+ */
+public class PendingRequestArgs extends ItemInfo implements Parcelable {
+
+ private static final int TYPE_NONE = 0;
+ private static final int TYPE_INTENT = 1;
+ private static final int TYPE_APP_WIDGET = 2;
+
+ private final int mArg1;
+ private final int mObjectType;
+ private final Parcelable mObject;
+
+ public PendingRequestArgs(ItemInfo info) {
+ mArg1 = 0;
+ mObjectType = TYPE_NONE;
+ mObject = null;
+
+ copyFrom(info);
+ }
+
+ private PendingRequestArgs(int arg1, int objectType, Parcelable object) {
+ mArg1 = arg1;
+ mObjectType = objectType;
+ mObject = object;
+ }
+
+ public PendingRequestArgs(Parcel parcel) {
+ readFromValues(ContentValues.CREATOR.createFromParcel(parcel));
+
+ mArg1 = parcel.readInt();
+ mObjectType = parcel.readInt();
+ if (parcel.readInt() != 0) {
+ mObject = mObjectType == TYPE_INTENT
+ ? Intent.CREATOR.createFromParcel(parcel)
+ : new LauncherAppWidgetProviderInfo(parcel);
+ } else {
+ mObject = null;
+ }
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ ContentValues itemValues = new ContentValues();
+ writeToValues(itemValues);
+
+ dest.writeInt(mArg1);
+ dest.writeInt(mObjectType);
+ if (mObject != null) {
+ dest.writeInt(1);
+ mObject.writeToParcel(dest, flags);
+ } else {
+ dest.writeInt(0);
+ }
+ }
+
+ public LauncherAppWidgetProviderInfo getWidgetProvider() {
+ return mObjectType == TYPE_APP_WIDGET ? (LauncherAppWidgetProviderInfo) mObject : null;
+ }
+
+ public int getWidgetId() {
+ return mObjectType == TYPE_APP_WIDGET ? mArg1 : 0;
+ }
+
+ public Intent getPendingIntent() {
+ return mObjectType == TYPE_INTENT ? (Intent) mObject : null;
+ }
+
+ public int getRequestCode() {
+ return mObjectType == TYPE_INTENT ? mArg1 : 0;
+ }
+
+ public static PendingRequestArgs forWidgetInfo(
+ int appWidgetId, LauncherAppWidgetProviderInfo widgetInfo, ItemInfo info) {
+ PendingRequestArgs args = new PendingRequestArgs(appWidgetId, TYPE_APP_WIDGET, widgetInfo);
+ args.copyFrom(info);
+ return args;
+ }
+
+ public static PendingRequestArgs forIntent(int requestCode, Intent intent, ItemInfo info) {
+ PendingRequestArgs args = new PendingRequestArgs(requestCode, TYPE_INTENT, intent);
+ args.copyFrom(info);
+ return args;
+ }
+
+ public static final Parcelable.Creator<PendingRequestArgs> CREATOR =
+ new Parcelable.Creator<PendingRequestArgs>() {
+ public PendingRequestArgs createFromParcel(Parcel source) {
+ return new PendingRequestArgs(source);
+ }
+
+ public PendingRequestArgs[] newArray(int size) {
+ return new PendingRequestArgs[size];
+ }
+ };
+}
diff --git a/src/com/android/launcher3/util/TransformingTouchDelegate.java b/src/com/android/launcher3/util/TransformingTouchDelegate.java
index da1de5e77..3197ba946 100644
--- a/src/com/android/launcher3/util/TransformingTouchDelegate.java
+++ b/src/com/android/launcher3/util/TransformingTouchDelegate.java
@@ -33,6 +33,10 @@ public class TransformingTouchDelegate extends TouchDelegate {
private final RectF mBounds;
+ private final RectF mTouchCheckBounds;
+ private float mTouchExtension;
+ private boolean mWasTouchOutsideBounds;
+
private View mDelegateView;
private boolean mDelegateTargeted;
@@ -41,10 +45,22 @@ public class TransformingTouchDelegate extends TouchDelegate {
mDelegateView = delegateView;
mBounds = new RectF();
+ mTouchCheckBounds = new RectF();
}
public void setBounds(int left, int top, int right, int bottom) {
mBounds.set(left, top, right, bottom);
+ updateTouchBounds();
+ }
+
+ public void extendTouchBounds(float extension) {
+ mTouchExtension = extension;
+ updateTouchBounds();
+ }
+
+ private void updateTouchBounds() {
+ mTouchCheckBounds.set(mBounds);
+ mTouchCheckBounds.inset(-mTouchExtension, -mTouchExtension);
}
public void setDelegateView(View view) {
@@ -62,8 +78,9 @@ public class TransformingTouchDelegate extends TouchDelegate {
boolean sendToDelegate = false;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
- mDelegateTargeted = mBounds.contains(event.getX(), event.getY());
+ mDelegateTargeted = mTouchCheckBounds.contains(event.getX(), event.getY());
if (mDelegateTargeted) {
+ mWasTouchOutsideBounds = !mBounds.contains(event.getX(), event.getY());
sendToDelegate = true;
}
break;
@@ -78,9 +95,15 @@ public class TransformingTouchDelegate extends TouchDelegate {
}
boolean handled = false;
if (sendToDelegate) {
- event.offsetLocation(-mBounds.left, -mBounds.top);
+ float x = event.getX();
+ float y = event.getY();
+ if (mWasTouchOutsideBounds) {
+ event.setLocation(mBounds.centerX(), mBounds.centerY());
+ } else {
+ event.offsetLocation(-mBounds.left, -mBounds.top);
+ }
handled = mDelegateView.dispatchTouchEvent(event);
- event.offsetLocation(mBounds.left, mBounds.top);
+ event.setLocation(x, y);
}
return handled;
}
diff --git a/src/com/android/launcher3/util/VerticalFlingDetector.java b/src/com/android/launcher3/util/VerticalFlingDetector.java
new file mode 100644
index 000000000..7236c2d1b
--- /dev/null
+++ b/src/com/android/launcher3/util/VerticalFlingDetector.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.util;
+
+import android.content.Context;
+import android.view.MotionEvent;
+import android.view.VelocityTracker;
+import android.view.View;
+import android.view.ViewConfiguration;
+
+public class VerticalFlingDetector implements View.OnTouchListener {
+
+ private static final float CUSTOM_SLOP_MULTIPLIER = 2.2f;
+ private static final int SEC_IN_MILLIS = 1000;
+
+ private VelocityTracker mVelocityTracker;
+ private float mMinimumFlingVelocity;
+ private float mMaximumFlingVelocity;
+ private float mDownX, mDownY;
+ private boolean mShouldCheckFling;
+ private double mCustomTouchSlop;
+
+ public VerticalFlingDetector(Context context) {
+ ViewConfiguration vc = ViewConfiguration.get(context);
+ mMinimumFlingVelocity = vc.getScaledMinimumFlingVelocity();
+ mMaximumFlingVelocity = vc.getScaledMaximumFlingVelocity();
+ mCustomTouchSlop = CUSTOM_SLOP_MULTIPLIER * vc.getScaledTouchSlop();
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent ev) {
+ if (mVelocityTracker == null) {
+ mVelocityTracker = VelocityTracker.obtain();
+ }
+ mVelocityTracker.addMovement(ev);
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ mDownX = ev.getX();
+ mDownY = ev.getY();
+ mShouldCheckFling = false;
+ break;
+ case MotionEvent.ACTION_MOVE:
+ if (mShouldCheckFling) {
+ break;
+ }
+ if (Math.abs(ev.getY() - mDownY) > mCustomTouchSlop &&
+ Math.abs(ev.getY() - mDownY) > Math.abs(ev.getX() - mDownX)) {
+ mShouldCheckFling = true;
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ if (mShouldCheckFling) {
+ mVelocityTracker.computeCurrentVelocity(SEC_IN_MILLIS, mMaximumFlingVelocity);
+ // only when fling is detected in down direction
+ if (mVelocityTracker.getYVelocity() > mMinimumFlingVelocity) {
+ cleanUp();
+ return true;
+ }
+ }
+ // fall through.
+ case MotionEvent.ACTION_CANCEL:
+ cleanUp();
+ }
+ return false;
+ }
+
+ private void cleanUp() {
+ if (mVelocityTracker == null) {
+ return;
+ }
+ mVelocityTracker.recycle();
+ mVelocityTracker = null;
+ }
+}
diff --git a/src/com/android/launcher3/widget/PendingAddShortcutInfo.java b/src/com/android/launcher3/widget/PendingAddShortcutInfo.java
index a56985083..486b18ef2 100644
--- a/src/com/android/launcher3/widget/PendingAddShortcutInfo.java
+++ b/src/com/android/launcher3/widget/PendingAddShortcutInfo.java
@@ -35,10 +35,4 @@ public class PendingAddShortcutInfo extends PendingAddItemInfo {
componentName = new ComponentName(activityInfo.packageName, activityInfo.name);
itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
}
-
- @Override
- public String toString() {
- return String.format("PendingAddShortcutInfo package=%s, name=%s",
- activityInfo.packageName, activityInfo.name);
- }
}
diff --git a/src/com/android/launcher3/widget/PendingAddWidgetInfo.java b/src/com/android/launcher3/widget/PendingAddWidgetInfo.java
index de06ab664..f800ac44d 100644
--- a/src/com/android/launcher3/widget/PendingAddWidgetInfo.java
+++ b/src/com/android/launcher3/widget/PendingAddWidgetInfo.java
@@ -59,10 +59,4 @@ public class PendingAddWidgetInfo extends PendingAddItemInfo {
public boolean isCustomWidget() {
return itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
}
-
- @Override
- public String toString() {
- return String.format("PendingAddWidgetInfo package=%s, name=%s",
- componentName.getPackageName(), componentName.getShortClassName());
- }
}
diff --git a/src/com/android/launcher3/widget/PendingItemPreviewProvider.java b/src/com/android/launcher3/widget/PendingItemPreviewProvider.java
index 8739390c4..eaa0bb3d5 100644
--- a/src/com/android/launcher3/widget/PendingItemPreviewProvider.java
+++ b/src/com/android/launcher3/widget/PendingItemPreviewProvider.java
@@ -24,7 +24,6 @@ import android.view.View;
import com.android.launcher3.HolographicOutlineHelper;
import com.android.launcher3.Launcher;
import com.android.launcher3.PendingAddItemInfo;
-import com.android.launcher3.R;
import com.android.launcher3.Workspace;
import com.android.launcher3.graphics.DragPreviewProvider;
@@ -50,7 +49,7 @@ public class PendingItemPreviewProvider extends DragPreviewProvider {
int w = size[0];
int h = size[1];
- final Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ final Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ALPHA_8);
canvas.setBitmap(b);
Rect src = new Rect(0, 0, mPreviewBitmap.getWidth(), mPreviewBitmap.getHeight());
@@ -68,9 +67,8 @@ public class PendingItemPreviewProvider extends DragPreviewProvider {
// Don't clip alpha values for the drag outline if we're using the default widget preview
boolean clipAlpha = !(mAddInfo instanceof PendingAddWidgetInfo &&
(((PendingAddWidgetInfo) mAddInfo).previewImage == 0));
- final int outlineColor = mView.getResources().getColor(R.color.outline_color);
HolographicOutlineHelper.obtain(mView.getContext())
- .applyExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor, clipAlpha);
+ .applyExpensiveOutlineWithBlur(b, canvas, clipAlpha);
canvas.setBitmap(null);
return b;
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index 97877fd35..293585dd6 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -135,6 +135,8 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
mWidgetName.setText(mItem.label);
mWidgetDims.setText(getContext().getString(R.string.widget_dims_format,
mItem.spanX, mItem.spanY));
+ mWidgetDims.setContentDescription(getContext().getString(
+ R.string.widget_accessible_dims_format, mItem.spanX, mItem.spanY));
mWidgetPreviewLoader = loader;
if (item.activityInfo != null) {
diff --git a/src/com/android/launcher3/widget/WidgetHostViewLoader.java b/src/com/android/launcher3/widget/WidgetHostViewLoader.java
index 297505be2..049871f98 100644
--- a/src/com/android/launcher3/widget/WidgetHostViewLoader.java
+++ b/src/com/android/launcher3/widget/WidgetHostViewLoader.java
@@ -11,6 +11,7 @@ import android.view.View;
import com.android.launcher3.AppWidgetResizeFrame;
import com.android.launcher3.DragSource;
+import com.android.launcher3.DropTarget;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
@@ -18,6 +19,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.util.Thunk;
public class WidgetHostViewLoader implements DragController.DragListener {
@@ -47,7 +49,7 @@ public class WidgetHostViewLoader implements DragController.DragListener {
}
@Override
- public void onDragStart(DragSource source, ItemInfo info, int dragAction) { }
+ public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) { }
@Override
public void onDragEnd() {
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index 352cea479..89c44c859 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -33,6 +33,7 @@ import com.android.launcher3.CellLayout;
import com.android.launcher3.DeleteDropTarget;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget.DragObject;
+import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.IconCache;
import com.android.launcher3.ItemInfo;
@@ -45,7 +46,10 @@ import com.android.launcher3.WidgetPreviewLoader;
import com.android.launcher3.Workspace;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.model.WidgetsModel;
+import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.Thunk;
+import com.android.launcher3.util.TransformingTouchDelegate;
/**
* The widgets list view container.
@@ -61,11 +65,11 @@ public class WidgetsContainerView extends BaseContainerView
private IconCache mIconCache;
private final Rect mTmpBgPaddingRect = new Rect();
- private final Rect mTmpRect = new Rect();
/* Recycler view related member variables */
private WidgetsRecyclerView mRecyclerView;
private WidgetsListAdapter mAdapter;
+ private TransformingTouchDelegate mRecyclerViewTouchDelegate;
/* Touch handling related member variables. */
private Toast mWidgetInstructionToast;
@@ -93,29 +97,29 @@ public class WidgetsContainerView extends BaseContainerView
}
@Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ getRevealView().getBackground().getPadding(mTmpBgPaddingRect);
+ mRecyclerViewTouchDelegate.setBounds(
+ mRecyclerView.getLeft() - mTmpBgPaddingRect.left,
+ mRecyclerView.getTop() - mTmpBgPaddingRect.top,
+ mRecyclerView.getRight() + mTmpBgPaddingRect.right,
+ mRecyclerView.getBottom() + mTmpBgPaddingRect.bottom);
+ }
+
+ @Override
protected void onFinishInflate() {
super.onFinishInflate();
mRecyclerView = (WidgetsRecyclerView) getContentView().findViewById(R.id.widgets_list_view);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+ mRecyclerViewTouchDelegate = new TransformingTouchDelegate(mRecyclerView);
}
@Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- getRevealView().getBackground().getPadding(mTmpBgPaddingRect);
- if (Utilities.isRtl(getResources())) {
- getContentView().setPadding(0, mTmpBgPaddingRect.top, mTmpBgPaddingRect.right,
- mTmpBgPaddingRect.bottom);
- mTmpRect.set(mTmpBgPaddingRect.left, 0, 0, 0);
- mRecyclerView.updateBackgroundPadding(mTmpRect);
- } else {
- getContentView().setPadding(mTmpBgPaddingRect.left, mTmpBgPaddingRect.top, 0,
- mTmpBgPaddingRect.bottom);
- mTmpRect.set(0, 0, mTmpBgPaddingRect.right, 0);
- mRecyclerView.updateBackgroundPadding(mTmpRect);
- }
-
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ ((View) mRecyclerView.getParent()).setTouchDelegate(mRecyclerViewTouchDelegate);
}
//
@@ -249,7 +253,7 @@ public class WidgetsContainerView extends BaseContainerView
// Start the drag
mDragController.startDrag(image, preview, this, createItemInfo,
- bounds, DragController.DRAG_ACTION_COPY, scale);
+ bounds, scale, new DragOptions());
return true;
}
@@ -349,4 +353,9 @@ public class WidgetsContainerView extends BaseContainerView
}
return mWidgetPreviewLoader;
}
+
+ @Override
+ public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) {
+ targetParent.containerType = LauncherLogProto.WIDGETS;
+ }
} \ No newline at end of file
diff --git a/src_config/com/android/launcher3/config/FeatureFlags.java b/src_config/com/android/launcher3/config/FeatureFlags.java
index 69d8f0f5f..13acc4ae3 100644
--- a/src_config/com/android/launcher3/config/FeatureFlags.java
+++ b/src_config/com/android/launcher3/config/FeatureFlags.java
@@ -27,12 +27,14 @@ public final class FeatureFlags {
// As opposed to the new spring-loaded workspace.
public static boolean LAUNCHER3_LEGACY_WORKSPACE_DND = false;
public static boolean LAUNCHER3_LEGACY_FOLDER_ICON = false;
- public static boolean LAUNCHER3_USE_SYSTEM_DRAG_DRIVER = false;
+ public static boolean LAUNCHER3_USE_SYSTEM_DRAG_DRIVER = true;
public static boolean LAUNCHER3_DISABLE_PINCH_TO_OVERVIEW = false;
public static boolean LAUNCHER3_ALL_APPS_PULL_UP = true;
- // Feature flag to enable moving the QSB on the 0th screen of the workspace
+ // Feature flag to enable moving the QSB on the 0th screen of the workspace.
public static final boolean QSB_ON_FIRST_SCREEN = true;
// When enabled the all-apps icon is not added to the hotseat.
public static final boolean NO_ALL_APPS_ICON = true;
+ // When enabled fling down gesture on the first workspace triggers search.
+ public static final boolean PULLDOWN_SEARCH = true;
}
diff --git a/tests/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithmTest.java b/tests/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithmTest.java
new file mode 100644
index 000000000..4d0a7a9bd
--- /dev/null
+++ b/tests/src/com/android/launcher3/allapps/DefaultAppSearchAlgorithmTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.allapps;
+
+import android.content.ComponentName;
+import android.test.InstrumentationTestCase;
+
+import com.android.launcher3.AppInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Unit tests for {@link DefaultAppSearchAlgorithm}
+ */
+public class DefaultAppSearchAlgorithmTest extends InstrumentationTestCase {
+
+ private List<AppInfo> mAppsList;
+ private DefaultAppSearchAlgorithm mAlgorithm;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mAppsList = new ArrayList<>();
+ getInstrumentation().runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ mAlgorithm = new DefaultAppSearchAlgorithm(mAppsList);
+ }
+ });
+ }
+
+ public void testMatches() {
+ assertTrue(mAlgorithm.matches(getInfo("white cow"), "cow"));
+ assertTrue(mAlgorithm.matches(getInfo("whiteCow"), "cow"));
+ assertTrue(mAlgorithm.matches(getInfo("whiteCOW"), "cow"));
+ assertTrue(mAlgorithm.matches(getInfo("whitecowCOW"), "cow"));
+ assertTrue(mAlgorithm.matches(getInfo("white2cow"), "cow"));
+
+ assertFalse(mAlgorithm.matches(getInfo("whitecow"), "cow"));
+ assertFalse(mAlgorithm.matches(getInfo("whitEcow"), "cow"));
+
+ assertTrue(mAlgorithm.matches(getInfo("whitecowCow"), "cow"));
+ assertTrue(mAlgorithm.matches(getInfo("whitecow cow"), "cow"));
+ assertFalse(mAlgorithm.matches(getInfo("whitecowcow"), "cow"));
+ assertFalse(mAlgorithm.matches(getInfo("whit ecowcow"), "cow"));
+
+ assertTrue(mAlgorithm.matches(getInfo("cats&dogs"), "dog"));
+ assertTrue(mAlgorithm.matches(getInfo("cats&Dogs"), "dog"));
+ assertTrue(mAlgorithm.matches(getInfo("cats&Dogs"), "&"));
+
+ assertTrue(mAlgorithm.matches(getInfo("2+43"), "43"));
+ assertFalse(mAlgorithm.matches(getInfo("2+43"), "3"));
+
+ assertTrue(mAlgorithm.matches(getInfo("Q"), "q"));
+ assertTrue(mAlgorithm.matches(getInfo(" Q"), "q"));
+ }
+
+ private AppInfo getInfo(String title) {
+ AppInfo info = new AppInfo();
+ info.title = title;
+ info.componentName = new ComponentName("Test", title);
+ return info;
+ }
+}