Merge "Fixes NPE with LAUNCHER_ALLAPPS_EXIT log event." into sc-dev
diff --git a/quickstep/res/drawable/chip_scrim_gradient.xml b/quickstep/res/drawable/chip_scrim_gradient.xml
deleted file mode 100644
index 5a2dfb7..0000000
--- a/quickstep/res/drawable/chip_scrim_gradient.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:angle="90"
- android:endColor="@android:color/transparent"
- android:startColor="@color/chip_scrim_start_color"
- android:type="linear" />
-</shape>
\ No newline at end of file
diff --git a/quickstep/res/layout/fallback_search_input.xml b/quickstep/res/layout/fallback_search_input.xml
deleted file mode 100644
index 0fb2924..0000000
--- a/quickstep/res/layout/fallback_search_input.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2020 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<com.android.launcher3.search.FallbackSearchInputView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center_vertical"
- android:layout_marginLeft="48dp"
- android:layout_marginRight="48dp"
- android:background="@android:color/transparent"
- android:focusableInTouchMode="true"
- android:gravity="start|center_vertical"
- android:inputType="textNoSuggestions"
- android:imeOptions="actionSearch|flagNoExtractUi"
- android:maxLines="1"
- android:privateImeOptions="bc_search"
- android:scrollHorizontally="true"
- android:singleLine="true"
- android:textColor="?android:attr/textColorSecondary"
- android:textColorHint="?android:attr/textColorTertiary"
- android:textSize="16sp" />
\ No newline at end of file
diff --git a/quickstep/res/layout/search_edu_view.xml b/quickstep/res/layout/search_edu_view.xml
deleted file mode 100644
index d89f5c7..0000000
--- a/quickstep/res/layout/search_edu_view.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2008 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.search.DeviceSearchEdu
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center_horizontal"
- android:orientation="vertical">
-
-
- <FrameLayout
- android:layout_height="wrap_content"
- android:id="@+id/search_box_wrapper"
- android:layout_width="match_parent">
-
- <include
- layout="@layout/fallback_search_input"
- android:id="@+id/mock_search_box" />
- </FrameLayout>
-
- <LinearLayout
- android:layout_height="wrap_content"
- android:id="@+id/edu_wrapper"
- android:padding="24dp"
- android:layout_marginTop="40dp"
- android:orientation="vertical"
- android:layout_width="match_parent">
-
- <TextView
- style="@style/TextHeadline"
- android:layout_width="match_parent"
- android:gravity="center"
- android:textSize="24sp"
- android:textColor="?android:attr/textColorPrimary"
- android:layout_height="wrap_content"
- android:text="@string/search_edu_primary" />
-
- <TextView
- style="@style/TextHeadline"
- android:layout_width="match_parent"
- android:gravity="center"
- android:textSize="18sp"
- android:layout_marginTop="30dp"
- android:textColor="?android:attr/textColorPrimary"
- android:layout_height="wrap_content"
- android:text="@string/search_edu_secondary" />
-
- <Button
- android:id="@+id/dismiss_edu"
- android:layout_width="wrap_content"
- android:layout_marginTop="@dimen/dynamic_grid_edge_margin"
- android:background="?android:attr/selectableItemBackground"
- android:layout_height="wrap_content"
- android:textColor="?android:attr/textColorPrimary"
- android:gravity="center"
- android:layout_gravity="center"
- android:text="@string/search_edu_dismiss" />
-
- </LinearLayout>
-
-</com.android.launcher3.search.DeviceSearchEdu>
\ No newline at end of file
diff --git a/quickstep/res/layout/search_result_icon.xml b/quickstep/res/layout/search_result_icon.xml
deleted file mode 100644
index e1b6dfd..0000000
--- a/quickstep/res/layout/search_result_icon.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2008 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.search.SearchResultIcon xmlns:launcher="http://schemas.android.com/apk/res-auto"
- style="@style/BaseIcon.AllApps"
- launcher:iconDisplay="all_apps"
- launcher:centerVertically="true" />
-
diff --git a/quickstep/res/layout/search_result_icon_row.xml b/quickstep/res/layout/search_result_icon_row.xml
deleted file mode 100644
index 084920a..0000000
--- a/quickstep/res/layout/search_result_icon_row.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2020 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<com.android.launcher3.search.SearchResultIconRow xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res-auto"
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="@dimen/dynamic_grid_edge_margin">
-
- <com.android.launcher3.search.SearchResultIcon
- android:id="@+id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- launcher:iconDisplay="hero_app" />
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:padding="@dimen/dynamic_grid_edge_margin"
- android:orientation="vertical"
- android:layout_gravity="center_vertical">
-
- <TextView
- android:id="@id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="start|center_vertical"
- android:maxLines="1"
- android:textAlignment="viewStart"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="@dimen/search_hero_title_size" />
-
- <TextView
- android:layout_width="wrap_content"
- android:id="@+id/subtitle"
- android:maxLines="1"
- android:textColor="?android:attr/textColorTertiary"
- android:textSize="@dimen/search_hero_subtitle_size"
- android:layout_height="wrap_content" />
- </LinearLayout>
-
- <com.android.launcher3.search.SearchResultIcon
- android:id="@+id/shortcut_0"
- style="@style/BaseIcon"
- android:layout_width="@dimen/deep_shortcut_icon_size"
- android:layout_height="match_parent"
- android:layout_marginStart="4dp"
- android:gravity="center"
- launcher:iconDisplay="shortcut_popup"
- android:textSize="@dimen/search_hero_inline_button_size"
- launcher:iconSizeOverride="@dimen/deep_shortcut_icon_size"
- launcher:layoutHorizontal="false" />
-
- <com.android.launcher3.search.SearchResultIcon
- android:id="@+id/shortcut_1"
- style="@style/BaseIcon"
- android:layout_width="@dimen/deep_shortcut_icon_size"
- android:layout_height="match_parent"
- android:layout_marginStart="4dp"
- android:gravity="center"
- launcher:iconDisplay="shortcut_popup"
- android:textSize="@dimen/search_hero_inline_button_size"
- launcher:iconSizeOverride="@dimen/deep_shortcut_icon_size"
- launcher:layoutHorizontal="false" />
-
- <com.android.launcher3.search.SearchResultIcon
- android:id="@+id/shortcut_2"
- style="@style/BaseIcon"
- android:layout_width="@dimen/deep_shortcut_icon_size"
- android:layout_height="match_parent"
- android:layout_marginStart="4dp"
- android:gravity="center"
- launcher:iconDisplay="shortcut_popup"
- android:textSize="@dimen/search_hero_inline_button_size"
- launcher:iconSizeOverride="@dimen/deep_shortcut_icon_size"
- launcher:layoutHorizontal="false" />
-</com.android.launcher3.search.SearchResultIconRow>
\ No newline at end of file
diff --git a/quickstep/res/layout/search_result_slice.xml b/quickstep/res/layout/search_result_slice.xml
deleted file mode 100644
index 4f884ff..0000000
--- a/quickstep/res/layout/search_result_slice.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2020 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<com.android.launcher3.search.SearchResultIconSlice xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res-auto"
- android:padding="@dimen/dynamic_grid_edge_margin"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <FrameLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
-
- <com.android.launcher3.search.SearchResultIcon
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/icon"
- launcher:iconDisplay="hero_app" />
- </FrameLayout>
-
- <androidx.slice.widget.SliceView
- android:id="@+id/slice"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_marginStart="@dimen/dynamic_grid_cell_padding_x"
- android:layout_width="0dp" />
-
-</com.android.launcher3.search.SearchResultIconSlice>
-
diff --git a/quickstep/res/layout/search_result_small_icon_row.xml b/quickstep/res/layout/search_result_small_icon_row.xml
deleted file mode 100644
index 41856fe..0000000
--- a/quickstep/res/layout/search_result_small_icon_row.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2021 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<com.android.launcher3.search.SearchResultSmallIconRow
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res-auto"
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="@dimen/dynamic_grid_edge_margin">
-
- <com.android.launcher3.search.SearchResultIcon
- android:id="@+id/icon"
- style="@style/BaseIcon"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:drawablePadding="@dimen/dynamic_grid_icon_drawable_padding"
- android:drawableTint="?android:attr/textColorPrimary"
- android:padding="@dimen/dynamic_grid_edge_margin"
- launcher:iconDisplay="hero_app"
- launcher:iconSizeOverride="48dp"
- launcher:matchTextInsetWithQuery="true"
- launcher:layoutHorizontal="true" />
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:orientation="horizontal"
- android:padding="@dimen/dynamic_grid_edge_margin" >
-
- <TextView
- android:id="@id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="start|center_vertical"
- android:maxLines="1"
- android:paddingEnd="4dp"
- android:textAlignment="viewStart"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="@dimen/search_hero_title_size" />
- <TextView
- android:id="@+id/delimeter"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="start|center_vertical"
- android:maxLines="1"
- android:text="\u2022"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="@dimen/search_hero_subtitle_size" />
- <TextView
- android:id="@+id/subtitle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:maxLines="1"
- android:paddingStart="4dp"
- android:textColor="?android:attr/textColorTertiary"
- android:textSize="@dimen/search_hero_subtitle_size" />
- </LinearLayout>
-</com.android.launcher3.search.SearchResultSmallIconRow>
\ No newline at end of file
diff --git a/quickstep/res/layout/search_result_thumbnail.xml b/quickstep/res/layout/search_result_thumbnail.xml
deleted file mode 100644
index 5062b76..0000000
--- a/quickstep/res/layout/search_result_thumbnail.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<com.android.launcher3.search.SearchResultThumbnailView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="125dp"
- android:layout_height="125dp"/>
\ No newline at end of file
diff --git a/quickstep/res/layout/search_result_widget_live.xml b/quickstep/res/layout/search_result_widget_live.xml
deleted file mode 100644
index f2ac6cd..0000000
--- a/quickstep/res/layout/search_result_widget_live.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<com.android.launcher3.search.SearchResultWidget
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingVertical="@dimen/widget_section_vertical_padding"
- android:layout_marginBottom="@dimen/widget_section_vertical_padding"
- android:gravity="center"
- >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:orientation="horizontal"
- android:layout_height="wrap_content">
-
- <com.android.launcher3.BubbleTextView
- android:id="@+id/widget_provider"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/widget_section_height"
- android:drawablePadding="@dimen/widget_section_horizontal_padding"
- android:focusable="true"
- android:gravity="start|center_vertical"
- android:paddingHorizontal="@dimen/widget_section_horizontal_padding"
- android:paddingVertical="@dimen/widget_section_horizontal_padding"
- android:singleLine="true"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="16sp"
- android:textAlignment="viewStart"
- launcher:iconDisplay="widget_section"
- launcher:layoutHorizontal="true"
- launcher:iconSizeOverride="@dimen/widget_section_icon_size" />
-
- <TextView
- android:id="@+id/widget_label"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/widget_section_height"
- android:textSize="16sp" />
-
- </LinearLayout>
-
-</com.android.launcher3.search.SearchResultWidget>
\ No newline at end of file
diff --git a/quickstep/res/layout/search_result_widget_preview.xml b/quickstep/res/layout/search_result_widget_preview.xml
deleted file mode 100644
index 7af24a1..0000000
--- a/quickstep/res/layout/search_result_widget_preview.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<com.android.launcher3.search.SearchResultWidgetPreview xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:padding="@dimen/dynamic_grid_cell_padding_x"
- android:layout_height="wrap_content">
- <include layout="@layout/widget_cell" android:id="@+id/widget_cell"/>
-<!-- <include layout="@layout/widget_cell_content" />-->
-</com.android.launcher3.search.SearchResultWidgetPreview>
\ No newline at end of file
diff --git a/quickstep/res/layout/search_section_title.xml b/quickstep/res/layout/search_section_title.xml
deleted file mode 100644
index 5842e57..0000000
--- a/quickstep/res/layout/search_section_title.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<com.android.launcher3.search.SearchSectionHeaderView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/section_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="@style/TextHeadline"
- android:paddingStart="4dp"
- android:paddingBottom="2dp"
- android:paddingTop="12dp"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="18sp" />
\ No newline at end of file
diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml
index f9bb2f2..c90706b 100644
--- a/quickstep/res/layout/task.xml
+++ b/quickstep/res/layout/task.xml
@@ -17,6 +17,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:clipChildren="false"
android:defaultFocusHighlightEnabled="false"
android:elevation="4dp"
android:focusable="true">
diff --git a/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java b/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
index 5cb55ec..eca27b5 100644
--- a/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
+++ b/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
@@ -43,8 +43,18 @@
@RunWith(RobolectricTestRunner.class)
public class OrientationTouchTransformerTest {
- private static final int SIZE_WIDTH = 1080;
- private static final int SIZE_HEIGHT = 2280;
+ static class ScreenSize {
+ int mHeight;
+ int mWidth;
+
+ ScreenSize(int height, int width) {
+ mHeight = height;
+ mWidth = width;
+ }
+ }
+
+ private static final ScreenSize NORMAL_SCREEN_SIZE = new ScreenSize(2280, 1080);
+ private static final ScreenSize LARGE_SCREEN_SIZE = new ScreenSize(3280, 1080);
private static final float DENSITY_DISPLAY_METRICS = 3.0f;
private OrientationTouchTransformer mTouchTransformer;
@@ -63,14 +73,16 @@
DisplayMetrics mockDisplayMetrics = new DisplayMetrics();
mockDisplayMetrics.density = DENSITY_DISPLAY_METRICS;
when(mResources.getDisplayMetrics()).thenReturn(mockDisplayMetrics);
- mInfo = createDisplayInfo(Surface.ROTATION_0);
+ mInfo = createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_0);
mTouchTransformer = new OrientationTouchTransformer(mResources, NO_BUTTON, () -> 0);
}
@Test
public void disabledMultipleRegions_shouldOverrideFirstRegion() {
- float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
- float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
+ float portraitRegionY =
+ generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1;
+ float landscapeRegionY =
+ generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
mTouchTransformer.createOrAddTouchRegion(mInfo);
tapAndAssertTrue(100, portraitRegionY,
@@ -83,7 +95,8 @@
event -> mTouchTransformer.touchInAssistantRegion(event));
// Override region
- mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
+ mTouchTransformer
+ .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
tapAndAssertFalse(100, portraitRegionY,
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
tapAndAssertTrue(100, landscapeRegionY,
@@ -107,10 +120,13 @@
@Test
public void enableMultipleRegions_shouldOverrideFirstRegion() {
- float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
- float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
+ float portraitRegionY =
+ generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1;
+ float landscapeRegionY =
+ generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
- mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
+ mTouchTransformer
+ .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
tapAndAssertFalse(100, portraitRegionY,
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
tapAndAssertTrue(100, landscapeRegionY,
@@ -136,11 +152,14 @@
@Test
public void enableMultipleRegions_assistantTriggersInMostRecent() {
- float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
- float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
+ float portraitRegionY =
+ generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1;
+ float landscapeRegionY =
+ generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
mTouchTransformer.enableMultipleRegions(true, mInfo);
- mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
+ mTouchTransformer
+ .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
mTouchTransformer.createOrAddTouchRegion(mInfo);
tapAndAssertTrue(0, portraitRegionY,
event -> mTouchTransformer.touchInAssistantRegion(event));
@@ -150,12 +169,15 @@
@Test
public void enableMultipleRegions_assistantTriggersInCurrentOrientationAfterDisable() {
- float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
- float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
+ float portraitRegionY =
+ generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1;
+ float landscapeRegionY =
+ generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
mTouchTransformer.enableMultipleRegions(true, mInfo);
mTouchTransformer.createOrAddTouchRegion(mInfo);
- mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
+ mTouchTransformer
+ .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
mTouchTransformer.enableMultipleRegions(false, mInfo);
tapAndAssertTrue(0, portraitRegionY,
event -> mTouchTransformer.touchInAssistantRegion(event));
@@ -164,6 +186,26 @@
}
@Test
+ public void assistantTriggersInCurrentScreenAfterScreenSizeChange() {
+ float smallerScreenPortraitRegionY =
+ generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1;
+ float largerScreenPortraitRegionY =
+ generateTouchRegionHeight(LARGE_SCREEN_SIZE, Surface.ROTATION_0) + 1;
+
+ mTouchTransformer.enableMultipleRegions(false,
+ createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_0));
+ tapAndAssertTrue(0, smallerScreenPortraitRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+
+ mTouchTransformer
+ .enableMultipleRegions(false, createDisplayInfo(LARGE_SCREEN_SIZE, Surface.ROTATION_0));
+ tapAndAssertTrue(0, largerScreenPortraitRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ tapAndAssertFalse(0, smallerScreenPortraitRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ }
+
+ @Test
public void applyTransform_taskNotFrozen_notInRegion() {
mTouchTransformer.createOrAddTouchRegion(mInfo);
tapAndAssertFalse(100, 100,
@@ -182,7 +224,7 @@
public void applyTransform_taskFrozen_noRotate_inRegion() {
mTouchTransformer.createOrAddTouchRegion(mInfo);
mTouchTransformer.enableMultipleRegions(true, mInfo);
- float y = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
+ float y = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1;
tapAndAssertTrue(100, y,
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
}
@@ -190,15 +232,16 @@
@Test
public void applyTransform_taskNotFrozen_noRotate_inDefaultRegion() {
mTouchTransformer.createOrAddTouchRegion(mInfo);
- float y = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
+ float y = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1;
tapAndAssertTrue(100, y,
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
}
@Test
public void applyTransform_taskNotFrozen_90Rotate_inRegion() {
- mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
- float y = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
+ mTouchTransformer
+ .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
+ float y = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
tapAndAssertTrue(100, y,
event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
}
@@ -210,9 +253,10 @@
public void applyTransform_taskNotFrozen_90Rotate_inTwoRegions() {
mTouchTransformer.createOrAddTouchRegion(mInfo);
mTouchTransformer.enableMultipleRegions(true, mInfo);
- mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
+ mTouchTransformer
+ .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90));
// Landscape point
- float y1 = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
+ float y1 = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1;
MotionEvent inRegion1_down = generateMotionEvent(MotionEvent.ACTION_DOWN, 10, y1);
MotionEvent inRegion1_up = generateMotionEvent(MotionEvent.ACTION_UP, 10, y1);
// Portrait point in landscape orientation axis
@@ -231,18 +275,18 @@
assertTrue(mTouchTransformer.touchInValidSwipeRegions(inRegion2.getX(), inRegion2.getY()));
}
- private DisplayController.Info createDisplayInfo(int rotation) {
- Point p = new Point(SIZE_WIDTH, SIZE_HEIGHT);
+ private DisplayController.Info createDisplayInfo(ScreenSize screenSize, int rotation) {
+ Point p = new Point(screenSize.mWidth, screenSize.mHeight);
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
- p = new Point(SIZE_HEIGHT, SIZE_WIDTH);
+ p = new Point(screenSize.mHeight, screenSize.mWidth);
}
return new DisplayController.Info(0, rotation, 0, p, p, p, null);
}
- private float generateTouchRegionHeight(int rotation) {
- float height = SIZE_HEIGHT;
+ private float generateTouchRegionHeight(ScreenSize screenSize, int rotation) {
+ float height = screenSize.mHeight;
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
- height = SIZE_WIDTH;
+ height = screenSize.mWidth;
}
return height - ResourceUtils.DEFAULT_NAVBAR_VALUE * DENSITY_DISPLAY_METRICS;
}
diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java
index c968de9..3a1a2f7 100644
--- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java
+++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java
@@ -29,7 +29,6 @@
*/
public class HotseatEduActivity extends Activity {
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -49,7 +48,7 @@
@Override
public boolean init(BaseActivity activity, boolean alreadyOnHome) {
QuickstepLauncher launcher = (QuickstepLauncher) activity;
- if (launcher != null && launcher.getHotseatPredictionController() != null) {
+ if (launcher != null) {
launcher.getHotseatPredictionController().showEdu();
}
return false;
diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatFileLog.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatFileLog.java
deleted file mode 100644
index 20e1edc..0000000
--- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatFileLog.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.hybridhotseat;
-
-import android.content.Context;
-import android.os.Handler;
-import android.util.Log;
-
-import com.android.launcher3.logging.FileLog;
-import com.android.launcher3.util.Executors;
-import com.android.launcher3.util.MainThreadInitializedObject;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-/**
- * Helper class to allow hot seat file logging
- */
-public class HotseatFileLog {
-
- public static final int LOG_DAYS = 10;
- private static final String FILE_NAME_PREFIX = "hotseat-log-";
- private static final DateFormat DATE_FORMAT =
- DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
- public static final MainThreadInitializedObject<HotseatFileLog> INSTANCE =
- new MainThreadInitializedObject<>(HotseatFileLog::new);
-
-
- private final Handler mHandler = new Handler(
- Executors.createAndStartNewLooper("hotseat-logger"));
- private final File mLogsDir;
- private PrintWriter mCurrentWriter;
- private String mFileName;
-
- private HotseatFileLog(Context context) {
- mLogsDir = context.getFilesDir();
- }
-
- /**
- * Prints log values to disk
- */
- public void log(String tag, String msg) {
- String out = String.format("%s %s %s", DATE_FORMAT.format(new Date()), tag, msg);
-
- mHandler.post(() -> {
- synchronized (this) {
- PrintWriter writer = getWriter();
- if (writer != null) {
- writer.println(out);
- }
- }
- });
- }
-
- private PrintWriter getWriter() {
- Calendar cal = Calendar.getInstance();
- String fName = FILE_NAME_PREFIX + (cal.get(Calendar.DAY_OF_YEAR) % 10);
- if (fName.equals(mFileName)) return mCurrentWriter;
-
- boolean append = false;
- File logFile = new File(mLogsDir, fName);
- if (logFile.exists()) {
- Calendar modifiedTime = Calendar.getInstance();
- modifiedTime.setTimeInMillis(logFile.lastModified());
-
- // If the file was modified more that 36 hours ago, purge the file.
- // We use instead of 24 to account for day-365 followed by day-1
- modifiedTime.add(Calendar.HOUR, 36);
- append = cal.before(modifiedTime);
- }
-
-
- if (mCurrentWriter != null) {
- mCurrentWriter.close();
- }
- try {
- mCurrentWriter = new PrintWriter(new FileWriter(logFile, append));
- mFileName = fName;
- } catch (Exception ex) {
- Log.e("HotseatLogs", "Error writing logs to file", ex);
- closeWriter();
- }
- return mCurrentWriter;
- }
-
-
- private synchronized void closeWriter() {
- mFileName = null;
- if (mCurrentWriter != null) {
- mCurrentWriter.close();
- }
- mCurrentWriter = null;
- }
-
-
- /**
- * Returns a list of all log files
- */
- public synchronized File[] getLogFiles() {
- File[] files = new File[LOG_DAYS + FileLog.LOG_DAYS];
- //include file log files here
- System.arraycopy(FileLog.getLogFiles(), 0, files, 0, FileLog.LOG_DAYS);
-
- closeWriter();
- for (int i = 0; i < LOG_DAYS; i++) {
- files[FileLog.LOG_DAYS + i] = new File(mLogsDir, FILE_NAME_PREFIX + i);
- }
- return files;
- }
-}
diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
index 88cfacb..0156e8f 100644
--- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
+++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
@@ -26,7 +26,6 @@
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.ComponentName;
-import android.os.Process;
import android.view.HapticFeedbackConstants;
import android.view.View;
import android.view.ViewGroup;
@@ -40,7 +39,6 @@
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragController;
@@ -76,11 +74,13 @@
private static final int FLAG_UPDATE_PAUSED = 1 << 0;
private static final int FLAG_DRAG_IN_PROGRESS = 1 << 1;
private static final int FLAG_FILL_IN_PROGRESS = 1 << 2;
+ private static final int FLAG_REMOVING_PREDICTED_ICON = 1 << 3;
private int mHotSeatItemsCount;
private QuickstepLauncher mLauncher;
private final Hotseat mHotseat;
+ private final Runnable mUpdateFillIfNotLoading = this::updateFillIfNotLoading;
private List<ItemInfo> mPredictedItems = Collections.emptyList();
@@ -134,7 +134,8 @@
private void onHotseatHierarchyChanged() {
if (mPauseFlags == 0 && !mLauncher.isWorkspaceLoading()) {
// Post update after a single frame to avoid layout within layout
- MAIN_EXECUTOR.getHandler().post(this::updateFillIfNotLoading);
+ MAIN_EXECUTOR.getHandler().removeCallbacks(mUpdateFillIfNotLoading);
+ MAIN_EXECUTOR.getHandler().post(mUpdateFillIfNotLoading);
}
}
@@ -376,7 +377,7 @@
continue;
}
if (dragObject.dragSource == this && icon.equals(dragObject.originalView)) {
- mHotseat.removeView(icon);
+ removeIconWithoutNotify(icon);
continue;
}
int rank = ((WorkspaceItemInfo) icon.getTag()).rank;
@@ -388,7 +389,7 @@
@Override
public void onAnimationSuccess(Animator animator) {
if (icon.getParent() != null) {
- mHotseat.removeView(icon);
+ removeIconWithoutNotify(icon);
}
}
});
@@ -397,6 +398,17 @@
mIconRemoveAnimators.start();
}
+ /**
+ * Removes icon while suppressing any extra tasks performed on view-hierarchy changes.
+ * This avoids recursive/redundant updates as the control updates the UI anyway after
+ * it's animation.
+ */
+ private void removeIconWithoutNotify(PredictedAppIcon icon) {
+ mPauseFlags |= FLAG_REMOVING_PREDICTED_ICON;
+ mHotseat.removeView(icon);
+ mPauseFlags &= ~FLAG_REMOVING_PREDICTED_ICON;
+ }
+
@Override
public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
removePredictedApps(mOutlineDrawings, dragObject);
@@ -446,16 +458,6 @@
* Logs rank info based on current list of predicted items
*/
public void logLaunchedAppRankingInfo(@NonNull ItemInfo itemInfo, InstanceId instanceId) {
- if (Utilities.IS_DEBUG_DEVICE) {
- final String pkg = itemInfo.getTargetComponent() != null
- ? itemInfo.getTargetComponent().getPackageName() : "unknown";
- HotseatFileLog.INSTANCE.get(mLauncher).log("UserEvent",
- "appLaunch: packageName:" + pkg + ",isWorkApp:" + (itemInfo.user != null
- && !Process.myUserHandle().equals(itemInfo.user))
- + ",launchLocation:" + itemInfo.container);
- }
-
-
ComponentName targetCN = itemInfo.getTargetComponent();
if (targetCN == null) {
return;
diff --git a/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java b/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java
deleted file mode 100644
index d415c36..0000000
--- a/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.search;
-
-import static com.android.launcher3.allapps.AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER;
-import static com.android.launcher3.allapps.AllAppsGridAdapter.VIEW_TYPE_ICON;
-
-import android.app.search.SearchTarget;
-import android.util.Log;
-import android.util.SparseIntArray;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.android.app.search.LayoutType;
-import com.android.launcher3.Launcher;
-import com.android.launcher3.R;
-import com.android.launcher3.allapps.AllAppsContainerView;
-import com.android.launcher3.allapps.AllAppsGridAdapter;
-import com.android.launcher3.allapps.search.SearchAdapterProvider;
-import com.android.launcher3.config.FeatureFlags;
-
-/**
- * Provides views for on-device search results
- */
-public class DeviceSearchAdapterProvider extends SearchAdapterProvider {
-
- public static final int VIEW_TYPE_SEARCH_CORPUS_TITLE = 1 << 5;
- public static final int VIEW_TYPE_SEARCH_SLICE = 1 << 7;
- public static final int VIEW_TYPE_SEARCH_ICON = (1 << 8) | VIEW_TYPE_ICON;
- public static final int VIEW_TYPE_SEARCH_ICON_ROW = (1 << 9);
- public static final int VIEW_TYPE_SEARCH_SMALL_ICON_ROW = (1 << 10);
- public static final int VIEW_TYPE_SEARCH_THUMBNAIL = 1 << 12;
- public static final int VIEW_TYPE_SEARCH_WIDGET_LIVE = 1 << 15;
- public static final int VIEW_TYPE_SEARCH_WIDGET_PREVIEW = 1 << 16;
-
- private static final String TAG = "SearchServiceAdapter";
-
- private final AllAppsContainerView mAppsView;
- private final SparseIntArray mViewTypeToLayoutMap = new SparseIntArray();
-
- public DeviceSearchAdapterProvider(Launcher launcher, AllAppsContainerView appsView) {
- super(launcher);
- mAppsView = appsView;
-
- mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_CORPUS_TITLE, R.layout.search_section_title);
- mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ICON, R.layout.search_result_icon);
- mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ICON_ROW, R.layout.search_result_icon_row);
- mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_SMALL_ICON_ROW, R.layout.search_result_small_icon_row);
- mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_SLICE, R.layout.search_result_slice);
- mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_THUMBNAIL, R.layout.search_result_thumbnail);
- mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_WIDGET_LIVE, R.layout.search_result_widget_live);
- mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_WIDGET_PREVIEW,
- R.layout.search_result_widget_preview);
- mViewTypeToLayoutMap.put(VIEW_TYPE_ALL_APPS_DIVIDER, R.layout.all_apps_divider);
- }
-
- @Override
- public void onBindView(AllAppsGridAdapter.ViewHolder holder, int position) {
- SearchAdapterItem item = (SearchAdapterItem) mAppsView.getApps().getAdapterItems().get(
- position);
- SearchTargetHandler
- payloadResultView =
- (SearchTargetHandler) holder.itemView;
- payloadResultView.apply(item.getSearchTarget(), item.getInlineItems());
- }
-
- @Override
- public boolean isSearchView(int viewType) {
- return mViewTypeToLayoutMap.get(viewType, -1) != -1;
- }
-
- @Override
- public AllAppsGridAdapter.ViewHolder onCreateViewHolder(LayoutInflater inflater,
- ViewGroup parent, int viewType) {
- return new AllAppsGridAdapter.ViewHolder(inflater.inflate(
- mViewTypeToLayoutMap.get(viewType), parent, false));
- }
-
- @Override
- public int getGridSpanSize(int viewType, int appsPerRow) {
- if (viewType == VIEW_TYPE_SEARCH_THUMBNAIL
- || viewType == VIEW_TYPE_SEARCH_WIDGET_PREVIEW) {
- return appsPerRow;
- }
- return super.getGridSpanSize(viewType, appsPerRow);
- }
-
-
- @Override
- public boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem adapterItem, View view) {
- if (view instanceof SearchTargetHandler) {
- return ((SearchTargetHandler) view).quickSelect();
- }
- return false;
- }
-
- /**
- * Determines what view type should be used to present search target.
- * Returns -1 if viewType is not found or if required field is not present
- * to render the viewType.
- */
- public int getViewTypeForSearchTarget(SearchTarget t) {
- switch (t.getLayoutType()) {
- case LayoutType.TEXT_HEADER:
- return VIEW_TYPE_SEARCH_CORPUS_TITLE;
- case LayoutType.ICON_SINGLE_VERTICAL_TEXT:
- return VIEW_TYPE_SEARCH_ICON;
- case LayoutType.ICON_SLICE:
- if (t.getSliceUri() != null) {
- return VIEW_TYPE_SEARCH_SLICE;
- }
- Log.w(TAG, "LayoutType.ICON_SLICE target doesn't contain sliceUri.");
- break;
- case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT:
- case LayoutType.ICON_SINGLE_HORIZONTAL_TEXT:
- case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT_BUTTON:
- case LayoutType.ICON_HORIZONTAL_TEXT:
- return VIEW_TYPE_SEARCH_ICON_ROW;
- case LayoutType.SMALL_ICON_HORIZONTAL_TEXT:
- return VIEW_TYPE_SEARCH_SMALL_ICON_ROW;
- case LayoutType.THUMBNAIL:
- if (t.getSearchAction() != null) {
- return VIEW_TYPE_SEARCH_THUMBNAIL;
- }
- Log.w(TAG, "LayoutType.THUMBNAIL target doesn't contain searchAction.");
- break;
- case LayoutType.WIDGET_PREVIEW:
- return VIEW_TYPE_SEARCH_WIDGET_PREVIEW;
- case LayoutType.WIDGET_LIVE:
- return VIEW_TYPE_SEARCH_WIDGET_LIVE;
- case LayoutType.DIVIDER:
- return VIEW_TYPE_ALL_APPS_DIVIDER;
- }
-
- return -1;
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/DeviceSearchEdu.java b/quickstep/src/com/android/launcher3/search/DeviceSearchEdu.java
deleted file mode 100644
index 016ec1b..0000000
--- a/quickstep/src/com/android/launcher3/search/DeviceSearchEdu.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-import static com.android.launcher3.util.OnboardingPrefs.SEARCH_EDU_SEEN;
-
-import android.animation.PropertyValuesHolder;
-import android.content.Context;
-import android.graphics.Rect;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.util.AttributeSet;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-import android.widget.TextView;
-
-import androidx.core.graphics.ColorUtils;
-
-import com.android.launcher3.AbstractFloatingView;
-import com.android.launcher3.Insettable;
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherState;
-import com.android.launcher3.R;
-import com.android.launcher3.anim.Interpolators;
-import com.android.launcher3.statemanager.StateManager;
-import com.android.launcher3.util.Themes;
-import com.android.launcher3.views.AbstractSlideInView;
-
-/**
- * Feature education for on-device Search. Shown the first time user opens AllApps Search
- */
-public class DeviceSearchEdu extends AbstractSlideInView implements
- StateManager.StateListener<LauncherState>, TextWatcher, Insettable,
- TextView.OnEditorActionListener {
-
- private static final long ANIMATION_DURATION = 350;
- private static final int ANIMATION_CONTENT_TRANSLATION = 200;
-
- private EditText mEduInput;
-
- private View mInputWrapper;
- private EditText mSearchInput;
-
- private boolean mSwitchFocusOnDismiss;
-
-
- public DeviceSearchEdu(Context context) {
- this(context, null, 0);
- }
-
- public DeviceSearchEdu(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public DeviceSearchEdu(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
-
- private void dismiss() {
- handleClose(true);
- mLauncher.getOnboardingPrefs().markChecked(SEARCH_EDU_SEEN);
- }
-
- @Override
- protected void handleClose(boolean animate) {
- handleClose(animate, ANIMATION_DURATION);
- mLauncher.getAllAppsController().getInsetController().show();
- mLauncher.getStateManager().removeStateListener(this);
- }
-
- @Override
- protected boolean isOfType(int type) {
- return false;
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mSearchInput = mLauncher.getAppsView().getSearchUiManager().getEditText();
- mInputWrapper = findViewById(R.id.search_box_wrapper);
- mContent = findViewById(R.id.edu_wrapper);
-
- mEduInput = findViewById(R.id.mock_search_box);
- mEduInput.setHint(R.string.all_apps_on_device_search_bar_hint);
- mEduInput.addTextChangedListener(this);
- if (mSearchInput != null) {
- mEduInput.getLayoutParams().height = mSearchInput.getHeight();
- mEduInput.setOnEditorActionListener(this);
- } else {
- mEduInput.setVisibility(INVISIBLE);
- }
-
- findViewById(R.id.dismiss_edu).setOnClickListener((view) -> {
- mSwitchFocusOnDismiss = true;
- dismiss();
- });
- }
-
- private void showInternal() {
- mLauncher.getStateManager().addStateListener(this);
- AbstractFloatingView.closeAllOpenViews(mLauncher);
- attachToContainer();
- if (mSearchInput != null) {
- Rect r = mLauncher.getViewBounds(mSearchInput);
- mEduInput.requestFocus();
- InputMethodManager imm = mLauncher.getSystemService(InputMethodManager.class);
- imm.showSoftInput(mEduInput, InputMethodManager.SHOW_IMPLICIT);
- ((LayoutParams) mInputWrapper.getLayoutParams()).setMargins(0, r.top, 0, 0);
- }
- animateOpen();
- }
-
- @Override
- protected int getScrimColor(Context context) {
- return ColorUtils.setAlphaComponent(Themes.getAttrColor(context, R.attr.allAppsScrimColor),
- 230);
- }
-
- protected void setTranslationShift(float translationShift) {
- mTranslationShift = translationShift;
- mContent.setAlpha(getBoxedProgress(1 - mTranslationShift, .25f, 1));
- mContent.setTranslationY(ANIMATION_CONTENT_TRANSLATION * translationShift);
- if (mColorScrim != null) {
- mColorScrim.setAlpha(getBoxedProgress(1 - mTranslationShift, 0, .75f));
- }
- }
-
- /**
- * Given input [0-1], returns progress within bounds [min,max] allowing for staged animations
- */
- private float getBoxedProgress(float input, float min, float max) {
- if (input < min) return 0;
- if (input > max) return 1;
- return (input - min) / (max - min);
- }
-
- private void animateOpen() {
- if (mIsOpen || mOpenCloseAnimator.isRunning()) {
- return;
- }
- mIsOpen = true;
- mOpenCloseAnimator.setValues(
- PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED));
- mOpenCloseAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
- mOpenCloseAnimator.setDuration(ANIMATION_DURATION);
- mOpenCloseAnimator.start();
- }
-
- /**
- * Show On-device search education view.
- */
- public static void show(Launcher launcher) {
- LayoutInflater layoutInflater = LayoutInflater.from(launcher);
- ((DeviceSearchEdu) layoutInflater.inflate(
- R.layout.search_edu_view, launcher.getDragLayer(),
- false)).showInternal();
- }
-
- @Override
- public void onStateTransitionStart(LauncherState toState) {
- dismiss();
- }
-
- @Override
- protected void onCloseComplete() {
- super.onCloseComplete();
- if (mSearchInput != null && mSwitchFocusOnDismiss) {
- mSearchInput.requestFocus();
- mSearchInput.setSelection(mSearchInput.getText().length());
- }
- }
-
- @Override
- public void afterTextChanged(Editable editable) {
- //Does nothing
- }
-
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- //Does nothing
- }
-
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- if (mSearchInput != null) {
- mSearchInput.setText(charSequence.toString());
- mSwitchFocusOnDismiss = true;
- dismiss();
- }
- }
-
- @Override
- public void setInsets(Rect insets) {
-
- }
-
- @Override
- public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
- mSearchInput.onEditorAction(i);
- dismiss();
- return true;
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/FallbackSearchInputView.java b/quickstep/src/com/android/launcher3/search/FallbackSearchInputView.java
deleted file mode 100644
index 7b10622..0000000
--- a/quickstep/src/com/android/launcher3/search/FallbackSearchInputView.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-import static com.android.launcher3.LauncherState.ALL_APPS;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-
-import com.android.launcher3.ExtendedEditText;
-import com.android.launcher3.Launcher;
-import com.android.launcher3.allapps.AllAppsContainerView;
-import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem;
-import com.android.launcher3.allapps.AllAppsStore;
-import com.android.launcher3.allapps.AlphabeticalAppsList;
-import com.android.launcher3.allapps.FloatingHeaderView;
-import com.android.launcher3.allapps.search.AllAppsSearchBarController;
-import com.android.launcher3.allapps.search.SearchAlgorithm;
-
-import java.util.ArrayList;
-
-/**
- * A search view shown in all apps for on device search
- */
-public class FallbackSearchInputView extends ExtendedEditText
- implements AllAppsSearchBarController.Callbacks, AllAppsStore.OnUpdateListener {
-
- private final AllAppsSearchBarController mSearchBarController;
-
- private AlphabeticalAppsList mApps;
- private Runnable mOnResultsChanged;
- private AllAppsContainerView mAppsView;
-
- public FallbackSearchInputView(Context context) {
- this(context, null);
- }
-
- public FallbackSearchInputView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public FallbackSearchInputView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mSearchBarController = new AllAppsSearchBarController();
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- Launcher.getLauncher(getContext()).getAppsView().getAppsStore().addUpdateListener(this);
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- Launcher.getLauncher(getContext()).getAppsView().getAppsStore().removeUpdateListener(this);
- }
-
- /**
- * Initializes SearchInput
- */
- public void initialize(AllAppsContainerView appsView, SearchAlgorithm algo, Runnable changed) {
- mOnResultsChanged = changed;
- mApps = appsView.getApps();
- mAppsView = appsView;
- mSearchBarController.initialize(algo, this, Launcher.getLauncher(getContext()), this);
- }
-
- @Override
- public void onSearchResult(String query, ArrayList<AdapterItem> items) {
- if (mApps != null && getParent() != null) {
- mApps.setSearchResults(items);
- notifyResultChanged();
- collapseAppsViewHeader(true);
- mAppsView.setLastSearchQuery(query);
- }
- }
-
- @Override
- public void onAppendSearchResult(String query, ArrayList<AdapterItem> items) {
- if (mApps != null && getParent() != null) {
- mApps.appendSearchResults(items);
- notifyResultChanged();
- }
- }
-
- @Override
- public void clearSearchResult() {
- if (getParent() != null && mApps != null) {
- mApps.setSearchResults(null);
- notifyResultChanged();
- collapseAppsViewHeader(false);
- mAppsView.onClearSearchResult();
- }
- }
-
- @Override
- public void onAppsUpdated() {
- mSearchBarController.refreshSearchResult();
- }
-
- private void collapseAppsViewHeader(boolean collapse) {
- FloatingHeaderView header = mAppsView.getFloatingHeaderView();
- if (header != null) {
- header.setCollapsed(collapse);
- }
- }
-
- private void notifyResultChanged() {
- if (mOnResultsChanged != null) {
- mOnResultsChanged.run();
- }
- mAppsView.onSearchResultsChanged();
- }
-
- @Override
- protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
- // TODO: Consider animating the state transition here
- if (focused) {
- // Getting focus will open the keyboard. Go to the all-apps state, so that the input
- // box is at the top and there is enough space below to show search results.
- Launcher.getLauncher(getContext()).getStateManager().goToState(ALL_APPS, false);
- }
- super.onFocusChanged(focused, direction, previouslyFocusedRect);
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java b/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java
deleted file mode 100644
index 8983c4f..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.search;
-
-import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_ICON;
-import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_ICON_ROW;
-import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_SMALL_ICON_ROW;
-import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_SLICE;
-import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_THUMBNAIL;
-import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_WIDGET_LIVE;
-import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_WIDGET_PREVIEW;
-
-import android.app.search.SearchTarget;
-
-import com.android.launcher3.allapps.AllAppsGridAdapter;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Extension of AdapterItem that contains an extra payload specific to item
- */
-public class SearchAdapterItem extends AllAppsGridAdapter.AdapterItem {
- private SearchTarget mSearchTarget;
- private List<SearchTarget> mInlineItems = new ArrayList<>();
-
-
- private static final int AVAILABLE_FOR_ACCESSIBILITY = VIEW_TYPE_SEARCH_SLICE
- | VIEW_TYPE_SEARCH_THUMBNAIL
- | VIEW_TYPE_SEARCH_ICON_ROW
- | VIEW_TYPE_SEARCH_ICON
- | VIEW_TYPE_SEARCH_SMALL_ICON_ROW
- | VIEW_TYPE_SEARCH_WIDGET_PREVIEW
- | VIEW_TYPE_SEARCH_WIDGET_LIVE;
-
- public SearchAdapterItem(SearchTarget searchTarget, int type) {
- mSearchTarget = searchTarget;
- viewType = type;
- }
-
- public SearchTarget getSearchTarget() {
- return mSearchTarget;
- }
-
- public List<SearchTarget> getInlineItems() {
- return mInlineItems;
- }
- @Override
- protected boolean isCountedForAccessibility() {
- return (AVAILABLE_FOR_ACCESSIBILITY & viewType) == viewType;
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIcon.java b/quickstep/src/com/android/launcher3/search/SearchResultIcon.java
deleted file mode 100644
index 4c44479..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchResultIcon.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-import static com.android.launcher3.LauncherSettings.Favorites.EXTENDED_CONTAINERS;
-import static com.android.launcher3.model.data.SearchActionItemInfo.FLAG_BADGE_WITH_PACKAGE;
-import static com.android.launcher3.model.data.SearchActionItemInfo.FLAG_PRIMARY_ICON_FROM_TITLE;
-import static com.android.launcher3.search.SearchTargetUtil.BUNDLE_EXTRA_PRIMARY_ICON_FROM_TITLE;
-import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
-import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
-
-import android.app.search.SearchAction;
-import android.app.search.SearchTarget;
-import android.app.search.SearchTargetEvent;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.pm.ShortcutInfo;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Paint;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffXfermode;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.graphics.drawable.Icon;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.android.app.search.ResultType;
-import com.android.launcher3.BubbleTextView;
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.allapps.AllAppsStore;
-import com.android.launcher3.icons.BitmapInfo;
-import com.android.launcher3.icons.BitmapRenderer;
-import com.android.launcher3.icons.LauncherIcons;
-import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer;
-import com.android.launcher3.logger.LauncherAtomExtensions.ExtendedContainers;
-import com.android.launcher3.model.data.AppInfo;
-import com.android.launcher3.model.data.ItemInfoWithIcon;
-import com.android.launcher3.model.data.PackageItemInfo;
-import com.android.launcher3.model.data.SearchActionItemInfo;
-import com.android.launcher3.model.data.WorkspaceItemInfo;
-import com.android.launcher3.touch.ItemClickHandler;
-import com.android.launcher3.touch.ItemLongClickListener;
-import com.android.launcher3.util.ComponentKey;
-import com.android.launcher3.util.Themes;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.List;
-import java.util.function.Consumer;
-
-/**
- * A {@link BubbleTextView} representing a single cell result in AllApps
- */
-public class SearchResultIcon extends BubbleTextView implements
- SearchTargetHandler, View.OnClickListener,
- View.OnLongClickListener {
-
- //Play store thumbnail process workaround
- private final Rect mTempRect = new Rect();
- private final Paint mIconPaint = new Paint();
- private static final int BITMAP_CROP_MASK_COLOR = 0xff424242;
-
- private final Launcher mLauncher;
- private final SearchSessionTracker mSearchSessionTracker;
- private String mTargetId;
- private Consumer<ItemInfoWithIcon> mOnItemInfoChanged;
-
-
- public SearchResultIcon(Context context) {
- this(context, null, 0);
- }
-
- public SearchResultIcon(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SearchResultIcon(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mLauncher = Launcher.getLauncher(getContext());
- mSearchSessionTracker = SearchSessionTracker.getInstance(getContext());
- }
-
- private boolean mLongPressSupported;
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- setLongPressTimeoutFactor(1f);
- setOnFocusChangeListener(mLauncher.getFocusHandler());
- setOnClickListener(this);
- setOnLongClickListener(this);
- setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- mLauncher.getDeviceProfile().allAppsCellHeightPx));
- }
-
- /**
- * Applies {@link SearchTarget} to view. registers a consumer after a corresponding {@link
- * ItemInfoWithIcon} is created
- */
- public void apply(SearchTarget searchTarget, List<SearchTarget> inlineItems,
- Consumer<ItemInfoWithIcon> cb) {
- mOnItemInfoChanged = cb;
- apply(searchTarget, inlineItems);
- }
-
- @Override
- public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
- mTargetId = parentTarget.getId();
- if (parentTarget.getShortcutInfo() != null) {
- prepareUsingShortcutInfo(parentTarget.getShortcutInfo());
- mLongPressSupported = true;
- } else if (parentTarget.getSearchAction() != null) {
- prepareUsingSearchAction(parentTarget);
- mLongPressSupported = false;
- } else {
- String className = parentTarget.getExtras().getString(SearchTargetUtil.EXTRA_CLASS);
- prepareUsingApp(new ComponentName(parentTarget.getPackageName(), className),
- parentTarget.getUserHandle());
- mLongPressSupported = true;
- }
- }
-
- private void prepareUsingSearchAction(SearchTarget searchTarget) {
- SearchAction searchAction = searchTarget.getSearchAction();
- Bundle extras = searchAction.getExtras();
-
- SearchActionItemInfo itemInfo = new SearchActionItemInfo(searchAction.getIcon(),
- searchTarget.getPackageName(), searchTarget.getUserHandle(),
- searchAction.getTitle()) {
- @Override
- protected ExtendedContainers getExtendedContainer() {
- return ExtendedContainers.newBuilder()
- .setDeviceSearchResultContainer(buildDeviceSearchResultContainer()).build();
- }
- };
- itemInfo.setIntent(searchAction.getIntent());
- itemInfo.setPendingIntent(searchAction.getPendingIntent());
-
- //TODO: remove this after flags are introduced in SearchAction. Settings results require
- // startActivityForResult
- boolean isSettingsResult = searchTarget.getResultType() == ResultType.SETTING;
- if ((extras != null && extras.getBoolean(
- SearchTargetUtil.BUNDLE_EXTRA_SHOULD_START_FOR_RESULT))
- || isSettingsResult) {
- itemInfo.setFlags(SearchActionItemInfo.FLAG_SHOULD_START_FOR_RESULT);
- } else if (extras != null && extras.getBoolean(
- SearchTargetUtil.BUNDLE_EXTRA_SHOULD_START)) {
- itemInfo.setFlags(SearchActionItemInfo.FLAG_SHOULD_START);
- }
- if (extras != null && extras.getBoolean(
- SearchTargetUtil.BUNDLE_EXTRA_BADGE_WITH_PACKAGE)) {
- itemInfo.setFlags(FLAG_BADGE_WITH_PACKAGE);
- }
- if (extras != null && extras.getBoolean(BUNDLE_EXTRA_PRIMARY_ICON_FROM_TITLE)) {
- itemInfo.setFlags(FLAG_PRIMARY_ICON_FROM_TITLE);
- }
-
- notifyItemInfoChanged(itemInfo);
- LauncherAppState appState = LauncherAppState.getInstance(mLauncher);
- MODEL_EXECUTOR.post(() -> {
- try (LauncherIcons li = LauncherIcons.obtain(getContext())) {
- Icon icon = searchTarget.getSearchAction().getIcon();
- BitmapInfo pkgBitmap = getPackageBitmap(appState, searchTarget);
- if (itemInfo.hasFlags(FLAG_PRIMARY_ICON_FROM_TITLE)) {
- // create a bitmap with first char if FLAG_PRIMARY_ICON_FROM_TITLE is set
- itemInfo.bitmap = li.createIconBitmap(String.valueOf(itemInfo.title.charAt(0)),
- pkgBitmap.color);
- } else if (icon == null) {
- // Use default icon from package name
- itemInfo.bitmap = pkgBitmap;
- } else {
- boolean isPlayResult = searchTarget.getResultType() == ResultType.PLAY;
- if (isPlayResult) {
- Bitmap b = getPlayResultBitmap(searchAction.getIcon());
- itemInfo.bitmap = b == null
- ? BitmapInfo.LOW_RES_INFO : BitmapInfo.fromBitmap(b);
- } else {
- itemInfo.bitmap = li.createBadgedIconBitmap(icon.loadDrawable(getContext()),
- itemInfo.user, false);
- }
- }
-
- // badge with package name
- if (itemInfo.hasFlags(FLAG_BADGE_WITH_PACKAGE) && itemInfo.bitmap != pkgBitmap) {
- itemInfo.bitmap = li.badgeBitmap(itemInfo.bitmap.icon, pkgBitmap);
- }
- }
- MAIN_EXECUTOR.post(() -> applyFromSearchActionItemInfo(itemInfo));
- });
- }
-
- private static BitmapInfo getPackageBitmap(LauncherAppState appState, SearchTarget target) {
- PackageItemInfo pkgInfo = new PackageItemInfo(target.getPackageName());
- pkgInfo.user = target.getUserHandle();
- appState.getIconCache().getTitleAndIconForApp(pkgInfo, false);
- return pkgInfo.bitmap;
- }
-
- private Bitmap getPlayResultBitmap(Icon icon) {
- try {
- int iconSize = getIconSize();
- URL url = new URL(icon.getUri().toString());
- URLConnection con = url.openConnection();
- con.addRequestProperty("Cache-Control", "max-age: 0");
- con.setUseCaches(true);
- Bitmap bitmap = BitmapFactory.decodeStream(con.getInputStream());
- return getRoundedBitmap(Bitmap.createScaledBitmap(bitmap, iconSize, iconSize, false));
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- private Bitmap getRoundedBitmap(Bitmap bitmap) {
- final int iconSize = bitmap.getWidth();
- final float radius = Themes.getDialogCornerRadius(getContext());
-
- return BitmapRenderer.createHardwareBitmap(iconSize, iconSize, (canvas) -> {
- mTempRect.set(0, 0, iconSize, iconSize);
- final RectF rectF = new RectF(mTempRect);
-
- mIconPaint.setAntiAlias(true);
- mIconPaint.reset();
- canvas.drawARGB(0, 0, 0, 0);
- mIconPaint.setColor(BITMAP_CROP_MASK_COLOR);
- canvas.drawRoundRect(rectF, radius, radius, mIconPaint);
-
- mIconPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
- canvas.drawBitmap(bitmap, mTempRect, mTempRect, mIconPaint);
- });
- }
-
- private void prepareUsingApp(ComponentName componentName, UserHandle userHandle) {
- AllAppsStore appsStore = mLauncher.getAppsView().getAppsStore();
- AppInfo appInfo = new AppInfo(
- appsStore.getApp(new ComponentKey(componentName, userHandle))) {
- @Override
- protected ExtendedContainers getExtendedContainer() {
- return ExtendedContainers.newBuilder()
- .setDeviceSearchResultContainer(buildDeviceSearchResultContainer()).build();
- }
- };
- appInfo.container = EXTENDED_CONTAINERS;
- if (appInfo == null) {
- setVisibility(GONE);
- return;
- }
- applyFromApplicationInfo(appInfo);
- notifyItemInfoChanged(appInfo);
- }
-
- private void prepareUsingShortcutInfo(ShortcutInfo shortcutInfo) {
- WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo(shortcutInfo, getContext()) {
- @Override
- protected ExtendedContainers getExtendedContainer() {
- return ExtendedContainers.newBuilder()
- .setDeviceSearchResultContainer(buildDeviceSearchResultContainer()).build();
- }
- };
- workspaceItemInfo.container = EXTENDED_CONTAINERS;
- notifyItemInfoChanged(workspaceItemInfo);
- LauncherAppState launcherAppState = LauncherAppState.getInstance(getContext());
- MODEL_EXECUTOR.execute(() -> {
- launcherAppState.getIconCache().getShortcutIcon(workspaceItemInfo, shortcutInfo);
- MAIN_EXECUTOR.post(() -> applyFromWorkspaceItem(workspaceItemInfo));
- });
- }
-
- @Override
- public boolean quickSelect() {
- this.performClick();
- notifyEvent(mLauncher, mTargetId, SearchTargetEvent.ACTION_LAUNCH_KEYBOARD_FOCUS);
- return true;
- }
-
- @Override
- public void onClick(View view) {
- ItemClickHandler.INSTANCE.onClick(view);
- notifyEvent(mLauncher, mTargetId, SearchTargetEvent.ACTION_LAUNCH_TOUCH);
- }
-
- @Override
- public boolean onLongClick(View view) {
- if (!mLongPressSupported) {
- return false;
- }
- notifyEvent(mLauncher, mTargetId, SearchTargetEvent.ACTION_LONGPRESS);
- return ItemLongClickListener.INSTANCE_ALL_APPS.onLongClick(this);
- }
-
-
- private void notifyItemInfoChanged(ItemInfoWithIcon itemInfoWithIcon) {
- if (mOnItemInfoChanged != null) {
- mOnItemInfoChanged.accept(itemInfoWithIcon);
- mOnItemInfoChanged = null;
- }
- }
-
- private DeviceSearchResultContainer buildDeviceSearchResultContainer() {
- return mSearchSessionTracker.getQueryLength()
- .map(queryLength -> DeviceSearchResultContainer.newBuilder()
- .setQueryLength(queryLength))
- .orElse(DeviceSearchResultContainer.newBuilder()).build();
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java b/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java
deleted file mode 100644
index 12a1a1c..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
-import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
-
-import android.app.search.SearchTarget;
-import android.content.Context;
-import android.content.pm.ShortcutInfo;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.annotation.Nullable;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.R;
-import com.android.launcher3.model.data.ItemInfoWithIcon;
-import com.android.launcher3.model.data.PackageItemInfo;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A full width representation of {@link SearchResultIcon} with a secondary label and inline
- * SearchTargets
- */
-public class SearchResultIconRow extends LinearLayout implements SearchTargetHandler {
-
- public static final int MAX_INLINE_ITEMS = 3;
-
- protected final Launcher mLauncher;
- protected final SearchResultIcon[] mInlineIcons = new SearchResultIcon[MAX_INLINE_ITEMS];
- private SearchResultIcon mResultIcon;
-
- private final LauncherAppState mLauncherAppState;
- private TextView mTitleView;
- private TextView mSubTitleView;
-
- private PackageItemInfo mProviderInfo;
-
- public SearchResultIconRow(Context context) {
- this(context, null, 0);
- }
-
- public SearchResultIconRow(Context context,
- @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SearchResultIconRow(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mLauncher = Launcher.getLauncher(getContext());
- mLauncherAppState = LauncherAppState.getInstance(getContext());
- }
-
- protected int getIconSize() {
- return mLauncher.getDeviceProfile().allAppsIconSizePx;
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- int iconSize = getIconSize();
-
- mResultIcon = findViewById(R.id.icon);
-
- mTitleView = findViewById(R.id.title);
- mSubTitleView = findViewById(R.id.subtitle);
- mSubTitleView.setVisibility(GONE);
-
- mResultIcon.getLayoutParams().height = iconSize;
- mResultIcon.getLayoutParams().width = iconSize;
- mResultIcon.setTextVisibility(false);
-
- mInlineIcons[0] = findViewById(R.id.shortcut_0);
- mInlineIcons[1] = findViewById(R.id.shortcut_1);
- mInlineIcons[2] = findViewById(R.id.shortcut_2);
- for (SearchResultIcon inlineIcon : mInlineIcons) {
- inlineIcon.getLayoutParams().width = getIconSize();
- }
- setOnClickListener(mResultIcon);
- setOnLongClickListener(mResultIcon);
- }
-
- @Override
- public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
- mResultIcon.apply(parentTarget, children, this::onItemInfoCreated);
-
- showSubtitleIfNeeded(null);
-
- if (parentTarget.getShortcutInfo() != null) {
- updateWithShortcutInfo(parentTarget.getShortcutInfo());
- } else if (parentTarget.getSearchAction() != null) {
- showSubtitleIfNeeded(parentTarget.getSearchAction().getSubtitle());
- }
- showInlineItems(children);
- }
-
- @Override
- public boolean quickSelect() {
- this.performClick();
- return true;
- }
-
- private void updateWithShortcutInfo(ShortcutInfo shortcutInfo) {
- PackageItemInfo packageItemInfo = new PackageItemInfo(shortcutInfo.getPackage());
- if (packageItemInfo.equals(mProviderInfo)) return;
- MODEL_EXECUTOR.post(() -> {
- mLauncherAppState.getIconCache().getTitleAndIconForApp(packageItemInfo, true);
- MAIN_EXECUTOR.post(() -> {
- showSubtitleIfNeeded(packageItemInfo.title);
- mProviderInfo = packageItemInfo;
- });
- });
- }
-
- protected void showSubtitleIfNeeded(CharSequence subTitle) {
- if (!TextUtils.isEmpty(subTitle)) {
- mSubTitleView.setText(subTitle);
- mSubTitleView.setVisibility(VISIBLE);
- } else {
- mSubTitleView.setVisibility(GONE);
- }
- }
-
- protected void showInlineItems(List<SearchTarget> children) {
- for (int i = 0; i < MAX_INLINE_ITEMS; i++) {
- if (i < children.size()) {
- mInlineIcons[i].apply(children.get(i), new ArrayList<>());
- mInlineIcons[i].setVisibility(VISIBLE);
- } else {
- mInlineIcons[i].setVisibility(GONE);
- }
- }
- }
-
- protected void onItemInfoCreated(ItemInfoWithIcon info) {
- setTag(info);
- mTitleView.setText(info.title);
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java b/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java
deleted file mode 100644
index 4bf3432..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-import android.app.search.SearchTarget;
-import android.app.search.SearchTargetEvent;
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.LinearLayout;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.slice.SliceItem;
-import androidx.slice.widget.EventInfo;
-import androidx.slice.widget.SliceView;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.R;
-import com.android.launcher3.model.data.PackageItemInfo;
-import com.android.launcher3.util.SafeCloseable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A slice view wrapper with settings app icon at start
- */
-public class SearchResultIconSlice extends LinearLayout implements SearchTargetHandler,
- SliceView.OnSliceActionListener {
-
- private final Launcher mLauncher;
-
- private SliceView mSliceView;
- private SearchResultIcon mIcon;
- private SafeCloseable mSliceSession;
- private String mTargetId;
-
- public SearchResultIconSlice(Context context) {
- this(context, null, 0);
- }
-
- public SearchResultIconSlice(Context context,
- @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SearchResultIconSlice(Context context, @Nullable AttributeSet attrs,
- int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mLauncher = Launcher.getLauncher(getContext());
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mSliceView = findViewById(R.id.slice);
- mIcon = findViewById(R.id.icon);
- mIcon.setTextVisibility(false);
- int iconSize = mLauncher.getDeviceProfile().iconSizePx;
- mIcon.getLayoutParams().height = iconSize;
- mIcon.getLayoutParams().width = iconSize;
- }
-
- @Override
- public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
- mTargetId = parentTarget.getId();
- reset();
- updateIcon(parentTarget, children);
- mSliceSession = mLauncher.getLiveSearchManager()
- .addObserver(parentTarget.getSliceUri(), mSliceView);
- }
-
- private void updateIcon(SearchTarget parentTarget, List<SearchTarget> children) {
- if (children.size() == 1) {
- mIcon.apply(children.get(0), new ArrayList<>());
- } else {
- PackageItemInfo pkgItem = new PackageItemInfo(parentTarget.getPackageName());
- pkgItem.user = parentTarget.getUserHandle();
- if (!pkgItem.equals(mIcon.getTag())) {
- // The icon will load and apply high res icon automatically
- mIcon.applyFromItemInfoWithIcon(pkgItem);
- }
- }
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- mSliceView.setOnSliceActionListener(this);
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- reset();
- }
-
- private void reset() {
- mSliceView.setOnSliceActionListener(null);
- if (mSliceSession != null) {
- mSliceSession.close();
- }
- }
-
- @Override
- public void onSliceAction(@NonNull EventInfo eventInfo, @NonNull SliceItem sliceItem) {
- notifyEvent(mLauncher, mTargetId, SearchTargetEvent.ACTION_TAP);
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultSmallIconRow.java b/quickstep/src/com/android/launcher3/search/SearchResultSmallIconRow.java
deleted file mode 100644
index ca8aa81..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchResultSmallIconRow.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
-import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
-
-import android.app.search.SearchTarget;
-import android.content.Context;
-import android.content.pm.ShortcutInfo;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.annotation.Nullable;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.R;
-import com.android.launcher3.model.data.ItemInfoWithIcon;
-import com.android.launcher3.model.data.PackageItemInfo;
-
-import java.util.List;
-
-/**
- * A full width representation of {@link SearchResultIcon} with a secondary label and inline
- * SearchTargets
- */
-public class SearchResultSmallIconRow extends LinearLayout implements SearchTargetHandler {
-
- protected final Launcher mLauncher;
- private final LauncherAppState mLauncherAppState;
- protected SearchResultIcon mResultIcon;
-
- private TextView mTitleView;
- private TextView mDelimeterView;
- private TextView mSubTitleView;
-
- private PackageItemInfo mProviderInfo;
-
- public SearchResultSmallIconRow(Context context) {
- this(context, null, 0);
- }
-
- public SearchResultSmallIconRow(Context context,
- @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SearchResultSmallIconRow(Context context,
- @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mLauncher = Launcher.getLauncher(getContext());
- mLauncherAppState = LauncherAppState.getInstance(getContext());
- }
-
- protected int getIconSize() {
- return mLauncher.getDeviceProfile().allAppsIconSizePx;
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- int iconSize = getIconSize();
-
- mResultIcon = findViewById(R.id.icon);
-
- mTitleView = findViewById(R.id.title);
- mDelimeterView = findViewById(R.id.delimeter);
- mDelimeterView.setVisibility(GONE);
- mSubTitleView = findViewById(R.id.subtitle);
- mSubTitleView.setVisibility(GONE);
-
- mResultIcon.getLayoutParams().height = iconSize;
- mResultIcon.getLayoutParams().width = iconSize;
- mResultIcon.setTextVisibility(false);
-
- setOnClickListener(mResultIcon);
- setOnLongClickListener(mResultIcon);
- }
-
- @Override
- public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
- mResultIcon.apply(parentTarget, children, this::onItemInfoCreated);
-
- showSubtitleIfNeeded(null);
-
- if (parentTarget.getShortcutInfo() != null) {
- updateWithShortcutInfo(parentTarget.getShortcutInfo());
- } else if (parentTarget.getSearchAction() != null) {
- showSubtitleIfNeeded(parentTarget.getSearchAction().getSubtitle());
- }
- }
-
- @Override
- public boolean quickSelect() {
- this.performClick();
- return true;
- }
-
- private void updateWithShortcutInfo(ShortcutInfo shortcutInfo) {
- PackageItemInfo packageItemInfo = new PackageItemInfo(shortcutInfo.getPackage());
- if (packageItemInfo.equals(mProviderInfo)) return;
- MODEL_EXECUTOR.post(() -> {
- mLauncherAppState.getIconCache().getTitleAndIconForApp(packageItemInfo, true);
- MAIN_EXECUTOR.post(() -> {
- showSubtitleIfNeeded(packageItemInfo.title);
- mProviderInfo = packageItemInfo;
- });
- });
- }
-
- protected void showSubtitleIfNeeded(CharSequence subTitle) {
- if (!TextUtils.isEmpty(subTitle)) {
- mSubTitleView.setText(subTitle);
- mSubTitleView.setVisibility(VISIBLE);
- mDelimeterView.setVisibility(VISIBLE);
-
- } else {
- mSubTitleView.setVisibility(GONE);
- }
- }
-
- protected void onItemInfoCreated(ItemInfoWithIcon info) {
- setTag(info);
- mTitleView.setText(info.title);
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultThumbnailView.java b/quickstep/src/com/android/launcher3/search/SearchResultThumbnailView.java
deleted file mode 100644
index 8803c98..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchResultThumbnailView.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-
-import android.app.search.SearchTarget;
-import android.app.search.SearchTargetEvent;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.util.AttributeSet;
-import android.view.View;
-
-import androidx.core.graphics.drawable.RoundedBitmapDrawable;
-import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.model.data.SearchActionItemInfo;
-import com.android.launcher3.touch.ItemClickHandler;
-import com.android.launcher3.util.Themes;
-
-import java.util.List;
-
-/**
- * A view representing a high confidence app search result that includes shortcuts
- */
-public class SearchResultThumbnailView extends androidx.appcompat.widget.AppCompatImageView
- implements SearchTargetHandler, View.OnClickListener {
-
- private SearchTarget mSearchTarget;
-
- public SearchResultThumbnailView(Context context) {
- super(context);
- }
-
- public SearchResultThumbnailView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public SearchResultThumbnailView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- setOnFocusChangeListener(Launcher.getLauncher(getContext()).getFocusHandler());
- setOnClickListener(this);
- }
-
- @Override
- public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
- mSearchTarget = parentTarget;
- Bitmap bitmap;
-
- SearchActionItemInfo itemInfo = new SearchActionItemInfo(
- parentTarget.getSearchAction().getIcon(),
- parentTarget.getPackageName(),
- parentTarget.getUserHandle(),
- parentTarget.getSearchAction().getTitle());
- itemInfo.setIntent(parentTarget.getSearchAction().getIntent());
- itemInfo.setPendingIntent(parentTarget.getSearchAction().getPendingIntent());
-
- bitmap = ((BitmapDrawable) itemInfo.getIcon()
- .loadDrawable(getContext())).getBitmap();
- // crop
- if (bitmap.getWidth() < bitmap.getHeight()) {
- bitmap = Bitmap.createBitmap(bitmap, 0,
- bitmap.getHeight() / 2 - bitmap.getWidth() / 2,
- bitmap.getWidth(), bitmap.getWidth());
- } else {
- bitmap = Bitmap.createBitmap(bitmap, bitmap.getWidth() / 2 - bitmap.getHeight() / 2,
- 0,
- bitmap.getHeight(), bitmap.getHeight());
- }
- setTag(itemInfo);
-
- RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(null, bitmap);
- drawable.setCornerRadius(Themes.getDialogCornerRadius(getContext()));
- setImageDrawable(drawable);
- }
-
- @Override
- public void onClick(View view) {
- ItemClickHandler.onClickSearchAction(Launcher.getLauncher(getContext()),
- (SearchActionItemInfo) view.getTag());
- notifyEvent(getContext(), mSearchTarget.getId(), SearchTargetEvent.ACTION_LAUNCH_TOUCH);
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultWidget.java b/quickstep/src/com/android/launcher3/search/SearchResultWidget.java
deleted file mode 100644
index e22f6ab..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchResultWidget.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
-import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
-
-import android.app.search.SearchTarget;
-import android.app.search.SearchTargetEvent;
-import android.appwidget.AppWidgetHostView;
-import android.appwidget.AppWidgetProviderInfo;
-import android.content.Context;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.view.GestureDetector;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.android.launcher3.AppWidgetResizeFrame;
-import com.android.launcher3.BubbleTextView;
-import com.android.launcher3.CheckLongPressHelper;
-import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.LauncherAppWidgetProviderInfo;
-import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
-import com.android.launcher3.allapps.search.SearchWidgetInfoContainer;
-import com.android.launcher3.dragndrop.DraggableView;
-import com.android.launcher3.icons.cache.HandlerRunnable;
-import com.android.launcher3.model.data.PackageItemInfo;
-import com.android.launcher3.touch.ItemLongClickListener;
-import com.android.launcher3.widget.PendingAddWidgetInfo;
-
-import java.util.List;
-
-/**
- * displays live version of a widget upon receiving {@link AppWidgetProviderInfo} from Search
- * provider
- */
-public class SearchResultWidget extends LinearLayout implements SearchTargetHandler, DraggableView,
- View.OnLongClickListener {
-
-
- private final Rect mWidgetOffset = new Rect();
-
- private final Launcher mLauncher;
- private final CheckLongPressHelper mLongPressHelper;
- private final GestureDetector mClickDetector;
- private final AppWidgetHostView mHostView;
- private final float mScaleToFit;
-
- private SearchWidgetInfoContainer mInfoContainer;
- private HandlerRunnable mLabelRequest;
- private BubbleTextView mWidgetProvider;
- private TextView mWidgetLabel;
-
- public SearchResultWidget(@NonNull Context context) {
- this(context, null, 0);
- }
-
- public SearchResultWidget(@NonNull Context context,
- @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SearchResultWidget(@NonNull Context context, @Nullable AttributeSet attrs,
- int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mLauncher = Launcher.getLauncher(context);
- mHostView = new AppWidgetHostView(context);
- DeviceProfile grid = mLauncher.getDeviceProfile();
- mScaleToFit = Math.min(grid.appWidgetScale.x, grid.appWidgetScale.y);
-
- // detect tap event on widget container for search target event reporting
- mClickDetector = new GestureDetector(context,
- new ClickListener(
- () -> reportEvent(SearchTargetEvent.ACTION_LAUNCH_TOUCH)));
- mLongPressHelper = new CheckLongPressHelper(this);
- mLongPressHelper.setLongPressTimeoutFactor(1);
- setOnLongClickListener(this);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mWidgetProvider = findViewById(R.id.widget_provider);
- mWidgetLabel = findViewById(R.id.widget_label);
- addView(mHostView);
- }
-
- @Override
- public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
- AppWidgetProviderInfo providerInfo = parentTarget.getAppWidgetProviderInfo();
- removeListener();
-
- showWidgetInfo(providerInfo);
- mInfoContainer = mLauncher.getLiveSearchManager().getPlaceHolderWidget(providerInfo);
- if (mInfoContainer == null) {
- setVisibility(GONE);
- return;
- }
- setVisibility(VISIBLE);
- mInfoContainer.attachWidget(mHostView);
- PendingAddWidgetInfo info = (PendingAddWidgetInfo) mHostView.getTag();
- int[] size = mLauncher.getWorkspace().estimateItemSize(info);
- mHostView.getLayoutParams().width = size[0];
- mHostView.getLayoutParams().height = size[1];
- AppWidgetResizeFrame.updateWidgetSizeRanges(mHostView, mLauncher, info.spanX,
- info.spanY);
- mHostView.requestLayout();
- setTag(info);
- }
-
- private void showWidgetInfo(AppWidgetProviderInfo providerInfo) {
- PackageItemInfo pinfo = new PackageItemInfo(providerInfo.provider.getPackageName());
- pinfo.user = providerInfo.getProfile();
- mWidgetProvider.applyFromItemInfoWithIcon(pinfo);
-
- mLabelRequest = new HandlerRunnable<>(
- MODEL_EXECUTOR.getHandler(),
- () -> LauncherAppState.getInstance(mLauncher).getIconCache()
- .getTitleNoCache(LauncherAppWidgetProviderInfo
- .fromProviderInfo(mLauncher, providerInfo)),
- MAIN_EXECUTOR,
- mWidgetLabel::setText);
- Utilities.postAsyncCallback(MODEL_EXECUTOR.getHandler(), mLabelRequest);
- }
-
- /**
- * Stops hostView from getting updates on a widget provider
- */
- public void removeListener() {
- if (mInfoContainer != null) {
- mInfoContainer.detachWidget(mHostView);
- mInfoContainer = null;
- }
- if (mLabelRequest != null) {
- mLabelRequest.cancel();
- mLabelRequest = null;
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- removeListener();
- }
-
- private void reportEvent(int eventType) {
- SearchSessionTracker.INSTANCE.get(getContext()).notifyEvent(
- new SearchTargetEvent.Builder("search target id", eventType).build());
- }
-
- @Override
- public boolean onInterceptTouchEvent(MotionEvent ev) {
- mLongPressHelper.onTouchEvent(ev);
- mClickDetector.onTouchEvent(ev);
- return mLongPressHelper.hasPerformedLongPress();
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- mLongPressHelper.onTouchEvent(ev);
- return true;
- }
-
- @Override
- public void cancelLongPress() {
- super.cancelLongPress();
- mLongPressHelper.cancelLongPress();
- }
-
- @Override
- public int getViewType() {
- return DraggableView.DRAGGABLE_WIDGET;
- }
-
- @Override
- public void getSourceVisualDragBounds(Rect bounds) {
- mHostView.getHitRect(mWidgetOffset);
- int width = (int) (mHostView.getMeasuredWidth() * mScaleToFit);
- int height = (int) (mHostView.getMeasuredHeight() * mScaleToFit);
- bounds.set(mWidgetOffset.left,
- mWidgetOffset.top,
- width + mWidgetOffset.left,
- height + mWidgetOffset.top);
- }
-
- @Override
- public boolean onLongClick(View view) {
- ItemLongClickListener.INSTANCE_ALL_APPS.onLongClick(view);
- return false;
- }
-
-
- static class ClickListener extends GestureDetector.SimpleOnGestureListener {
- private final Runnable mCb;
-
- ClickListener(Runnable cb) {
- mCb = cb;
- }
-
- @Override
- public boolean onSingleTapConfirmed(MotionEvent e) {
- mCb.run();
- return super.onSingleTapConfirmed(e);
- }
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java b/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java
deleted file mode 100644
index 5bf1908..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
-import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
-
-import android.app.search.SearchTarget;
-import android.app.search.SearchTargetEvent;
-import android.appwidget.AppWidgetProviderInfo;
-import android.content.Context;
-import android.graphics.Point;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.LinearLayout;
-import android.widget.Toast;
-
-import androidx.annotation.Nullable;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.LauncherAppWidgetProviderInfo;
-import com.android.launcher3.R;
-import com.android.launcher3.dragndrop.DragOptions;
-import com.android.launcher3.model.WidgetItem;
-import com.android.launcher3.touch.ItemLongClickListener;
-import com.android.launcher3.widget.BaseWidgetSheet;
-import com.android.launcher3.widget.PendingItemDragHelper;
-import com.android.launcher3.widget.WidgetCell;
-import com.android.launcher3.widget.WidgetImageView;
-
-import java.util.List;
-
-/**
- * displays preview of a widget upon receiving {@link AppWidgetProviderInfo} from Search provider
- */
-public class SearchResultWidgetPreview extends LinearLayout implements SearchTargetHandler,
- View.OnClickListener, View.OnLongClickListener {
-
- private final Launcher mLauncher;
- private final LauncherAppState mAppState;
- private WidgetCell mWidgetCell;
- private Toast mWidgetToast;
-
- private String mTargetId;
- public SearchResultWidgetPreview(Context context) {
- this(context, null, 0);
- }
-
- public SearchResultWidgetPreview(Context context,
- @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SearchResultWidgetPreview(Context context, @Nullable AttributeSet attrs,
- int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mLauncher = Launcher.getLauncher(context);
- mAppState = LauncherAppState.getInstance(context);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mWidgetCell = findViewById(R.id.widget_cell);
- mWidgetCell.setOnLongClickListener(this);
- mWidgetCell.setOnClickListener(this);
- }
-
- @Override
- public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
- mTargetId = parentTarget.getId();
- AppWidgetProviderInfo providerInfo = parentTarget.getAppWidgetProviderInfo();
- LauncherAppWidgetProviderInfo pInfo = LauncherAppWidgetProviderInfo.fromProviderInfo(
- getContext(), providerInfo);
- MODEL_EXECUTOR.post(() -> {
- WidgetItem widgetItem = new WidgetItem(pInfo, mLauncher.getDeviceProfile().inv,
- mAppState.getIconCache());
- MAIN_EXECUTOR.post(() -> {
- mWidgetCell.applyFromCellItem(widgetItem, mAppState.getWidgetCache());
- mWidgetCell.ensurePreview();
- });
- });
- }
-
- @Override
- public boolean onLongClick(View view) {
- view.cancelLongPress();
- if (!ItemLongClickListener.canStartDrag(mLauncher)) return false;
- if (mWidgetCell.getTag() == null) return false;
-
- WidgetImageView imageView = mWidgetCell.getWidgetView();
- if (imageView.getBitmap() == null) {
- return false;
- }
-
- int[] loc = new int[2];
- mLauncher.getDragLayer().getLocationInDragLayer(imageView, loc);
-
- new PendingItemDragHelper(mWidgetCell).startDrag(
- imageView.getBitmapBounds(), imageView.getBitmap().getWidth(), imageView.getWidth(),
- new Point(loc[0], loc[1]), mLauncher.getAppsView(), new DragOptions());
- reportEvent(SearchTargetEvent.ACTION_LONGPRESS);
- return true;
- }
-
- @Override
- public void onClick(View view) {
- mWidgetToast = BaseWidgetSheet.showWidgetToast(getContext(), mWidgetToast);
- reportEvent(SearchTargetEvent.ACTION_LAUNCH_TOUCH);
- }
-
- private void reportEvent(int eventType) {
- SearchSessionTracker.INSTANCE.get(getContext()).notifyEvent(
- new SearchTargetEvent.Builder(mTargetId, eventType).build());
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java b/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java
deleted file mode 100644
index 9276841..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-import android.app.search.SearchTarget;
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-import androidx.annotation.Nullable;
-
-import java.util.List;
-
-/**
- * Header text view that shows a title for a given section in All apps search
- */
-public class SearchSectionHeaderView extends TextView implements SearchTargetHandler {
-
- public SearchSectionHeaderView(Context context) {
- super(context);
- }
-
- public SearchSectionHeaderView(Context context,
- @Nullable AttributeSet attrs) {
- super(context, attrs);
- }
-
- public SearchSectionHeaderView(Context context, @Nullable AttributeSet attrs, int styleAttr) {
- super(context, attrs, styleAttr);
- }
-
- @Override
- public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
- setText(parentTarget.getSearchAction().getTitle());
- setVisibility(VISIBLE);
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchServicePipeline.java b/quickstep/src/com/android/launcher3/search/SearchServicePipeline.java
deleted file mode 100644
index fac6ba7..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchServicePipeline.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3.search;
-
-import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
-
-import android.app.search.Query;
-import android.app.search.SearchContext;
-import android.app.search.SearchSession;
-import android.app.search.SearchTarget;
-import android.app.search.SearchUiManager;
-import android.content.Context;
-import android.os.CancellationSignal;
-import android.text.TextUtils;
-import android.util.Log;
-
-import androidx.annotation.WorkerThread;
-
-import com.android.app.search.ResultType;
-import com.android.launcher3.allapps.AllAppsGridAdapter;
-import com.android.launcher3.allapps.AllAppsSectionDecorator;
-import com.android.launcher3.allapps.search.SearchPipeline;
-import com.android.launcher3.allapps.search.SearchSectionInfo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.function.Consumer;
-
-/**
- * Search pipeline utilizing {@link android.app.search.SearchUiManager}
- */
-public class SearchServicePipeline implements SearchPipeline {
- private static final int SUPPORTED_RESULT_TYPES =
- ResultType.APPLICATION | ResultType.SHORTCUT | ResultType.PLAY | ResultType.PEOPLE
- | ResultType.SETTING;
-
- private static final boolean DEBUG = true;
- private static final int REQUEST_TIMEOUT = 200;
- private static final String TAG = "SearchServicePipeline";
-
- private final Context mContext;
- private final SearchSession mSession;
- private final DeviceSearchAdapterProvider mAdapterProvider;
-
- private boolean mCanceled = false;
-
-
- public SearchServicePipeline(Context context, DeviceSearchAdapterProvider adapterProvider) {
- mContext = context;
- mAdapterProvider = adapterProvider;
- SearchUiManager manager = context.getSystemService(SearchUiManager.class);
- mSession = manager.createSearchSession(
- new SearchContext(SUPPORTED_RESULT_TYPES, REQUEST_TIMEOUT, null));
- SearchSessionTracker.getInstance(context).setSearchSession(mSession);
- }
-
- @WorkerThread
- @Override
- public void query(String input, Consumer<ArrayList<AllAppsGridAdapter.AdapterItem>> callback,
- CancellationSignal cancellationSignal) {
- mCanceled = false;
- Query query = new Query(input, System.currentTimeMillis(), null);
- mSession.query(query, UI_HELPER_EXECUTOR, targets -> {
- if (!mCanceled) {
- if (DEBUG) {
- printSearchTargets(input, targets);
- }
- SearchSessionTracker.getInstance(mContext).setQuery(query);
- callback.accept(this.onResult(targets));
- }
- Log.w(TAG, "Ignoring results due to cancel signal");
- });
- }
-
- /**
- * Given A list of search Targets, pairs a group of search targets to a AdapterItem that can
- * be inflated in AllAppsRecyclerView
- */
- private ArrayList<AllAppsGridAdapter.AdapterItem> onResult(List<SearchTarget> searchTargets) {
- HashMap<String, SearchAdapterItem> adapterMap = new LinkedHashMap<>();
- List<SearchTarget> unmappedChildren = new ArrayList<>();
- SearchSectionInfo section = new SearchSectionInfo();
- section.setDecorationHandler(
- new AllAppsSectionDecorator.SectionDecorationHandler(mContext, true));
- for (SearchTarget target : searchTargets) {
- if (!TextUtils.isEmpty(target.getParentId())) {
- if (!addChildToParent(target, adapterMap)) {
- unmappedChildren.add(target);
- }
- continue;
- }
- int viewType = mAdapterProvider.getViewTypeForSearchTarget(target);
- if (viewType != -1) {
- SearchAdapterItem adapterItem = new SearchAdapterItem(target, viewType);
- adapterItem.searchSectionInfo = section;
- adapterMap.put(target.getId(), adapterItem);
- }
- }
- for (SearchTarget s : unmappedChildren) {
- if (!addChildToParent(s, adapterMap)) {
- Log.w(TAG,
- "Unable to pair child " + s.getId() + " to parent " + s.getParentId());
- }
- }
- return new ArrayList<>(adapterMap.values());
- }
-
- private void printSearchTargets(String query, List<SearchTarget> results) {
- Log.d(TAG, " query=" + query + " size=" + results.size());
- for (SearchTarget s : results) {
- Log.d(TAG, "layoutType=" + s.getLayoutType() + " resultType=" + s.getResultType());
- }
- }
-
- /**
- * Adds a child SearchTarget to a collection of searchTarget children with a shared parentId.
- * Returns false if no parent searchTarget with id=$parentId does not exists.
- */
- private boolean addChildToParent(SearchTarget target, HashMap<String, SearchAdapterItem> map) {
- if (!map.containsKey(target.getParentId())) return false;
- map.get(target.getParentId()).getInlineItems().add(target);
- return true;
- }
-
- /**
- * Unregister callbacks and destroy search session
- */
- public void destroy() {
- mSession.destroy();
- }
-
- /**
- * Cancels current ongoing search request.
- */
- public void cancel() {
- mCanceled = true;
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchSessionTracker.java b/quickstep/src/com/android/launcher3/search/SearchSessionTracker.java
deleted file mode 100644
index 97a72bb..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchSessionTracker.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2017 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.search;
-
-import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
-
-import android.app.search.Query;
-import android.app.search.SearchSession;
-import android.app.search.SearchTargetEvent;
-import android.content.Context;
-import android.util.Log;
-
-import androidx.annotation.Nullable;
-import androidx.annotation.WorkerThread;
-
-import com.android.launcher3.util.MainThreadInitializedObject;
-
-import java.util.Optional;
-
-/**
- * A singleton class to track and report search events back to SearchSession
- */
-public class SearchSessionTracker {
-
- private static final String TAG = "SearchSessionTracker";
-
- @Nullable
- private SearchSession mSession;
- private Query mQuery;
-
- public static final MainThreadInitializedObject<SearchSessionTracker> INSTANCE =
- new MainThreadInitializedObject<>(SearchSessionTracker::new);
-
- private SearchSessionTracker(Context context) {
- }
-
- /**
- * Returns instance of SearchSessionTracker
- */
- public static SearchSessionTracker getInstance(Context context) {
- return SearchSessionTracker.INSTANCE.get(context);
- }
-
- @WorkerThread
- public void setSearchSession(SearchSession session) {
- mSession = session;
- }
-
- @WorkerThread
- public void setQuery(Query query) {
- mQuery = query;
- }
-
- public Optional<Integer> getQueryLength() {
- return Optional.ofNullable(mQuery).map(Query::getInput).map(String::length);
- }
-
- /**
- * Send the user event handling back to the {@link SearchSession} object.
- */
- public void notifyEvent(SearchTargetEvent event) {
- if (mSession == null) {
- Log.d(TAG, "Dropping event " + event.getTargetId());
- }
- Log.d(TAG, "notifyEvent:" + mQuery.getInput() + ":" + event.getTargetId());
- UI_HELPER_EXECUTOR.post(() -> mSession.notifyEvent(mQuery, event));
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java b/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java
deleted file mode 100644
index acf6f8a..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.search;
-
-import android.app.search.SearchTarget;
-import android.app.search.SearchTargetEvent;
-import android.content.Context;
-
-import java.util.List;
-
-/**
- * An interface for supporting dynamic search results
- */
-public interface SearchTargetHandler {
-
- /**
- * Update view using values from {@link SearchTarget}
- */
- default void apply(SearchTarget parentTarget, List<SearchTarget> children) { }
-
- /**
- * Handle IME quick select event. returns whether event was handled.
- */
- default boolean quickSelect() {
- return false;
- }
-
- default void notifyEvent(Context context, String id, int eventType) {
- SearchTargetEvent.Builder builder = new SearchTargetEvent.Builder(id, eventType);
- SearchSessionTracker.getInstance(context).notifyEvent(builder.build());
- }
-}
diff --git a/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java b/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java
deleted file mode 100644
index ede3b9d..0000000
--- a/quickstep/src/com/android/launcher3/search/SearchTargetUtil.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.search;
-
-import static com.android.app.search.LayoutType.DIVIDER;
-import static com.android.app.search.LayoutType.ICON_HORIZONTAL_TEXT;
-import static com.android.app.search.LayoutType.SMALL_ICON_HORIZONTAL_TEXT;
-import static com.android.app.search.LayoutType.THUMBNAIL;
-import static com.android.app.search.ResultType.ACTION;
-import static com.android.app.search.ResultType.SCREENSHOT;
-import static com.android.app.search.ResultType.SUGGEST;
-
-import android.app.PendingIntent;
-import android.app.search.SearchAction;
-import android.app.search.SearchTarget;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ShortcutInfo;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.drawable.Icon;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Process;
-import android.os.UserHandle;
-
-import com.android.app.search.ResultType;
-
-public class SearchTargetUtil {
-
- public static final String BUNDLE_EXTRA_SHOULD_START = "should_start";
- public static final String BUNDLE_EXTRA_SHOULD_START_FOR_RESULT = "should_start_for_result";
- public static final String BUNDLE_EXTRA_BADGE_WITH_PACKAGE = "badge_with_package";
- public static final String BUNDLE_EXTRA_PRIMARY_ICON_FROM_TITLE = "primary_icon_from_title";
-
- public static final String EXTRA_CLASS = "class";
-
- private static final String TITLE = " title: weather ";
- private static final String SUBTITLE = " subtitle: 68 degrees ";
- private static final String PACKAGE2 = "com.google.android.gm";
- private static final UserHandle USERHANDLE = Process.myUserHandle();
-
-
- /**
- * Generate SearchTargetUtil for ICON_HORIZONTAL_TEXT layout type.
- *
- * targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
- * mContext, "red", Color.RED));
- * targets.add(SearchTargetUtil.generateIconDoubleHorizontalText_SearchAction(
- * mContext, "yellow", Color.YELLOW));
- */
- public static SearchTarget generateIcoHorizontalText_usingSearchAction(
- Context context, String id, int color) {
- SearchTarget.Builder builder =
- new SearchTarget.Builder(ACTION, ICON_HORIZONTAL_TEXT, id)
- .setPackageName(PACKAGE2) /* required */
- .setUserHandle(USERHANDLE); /* required */
-
- Intent intent = new Intent("com.google.android.googlequicksearchbox.GENERIC_QUERY");
- intent.putExtra("query", "weather");
- intent.putExtra("full_screen", false);
- PendingIntent pendingIntent =
- PendingIntent.getActivity(
- context, 1, intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
-
- Bitmap bitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
- canvas.drawColor(color);
- Icon icon = Icon.createWithAdaptiveBitmap(bitmap);
-
- Bundle b = new Bundle();
- b.putBoolean(BUNDLE_EXTRA_SHOULD_START_FOR_RESULT, true);
- b.putBoolean(BUNDLE_EXTRA_BADGE_WITH_PACKAGE, true);
- b.putBoolean(BUNDLE_EXTRA_PRIMARY_ICON_FROM_TITLE, true);
-
- builder.setSearchAction(new SearchAction.Builder(id, id + TITLE)
- .setSubtitle(id + SUBTITLE)
- .setPendingIntent(pendingIntent)
- .setIcon(icon)
- .setExtras(b)
- .build());
- return builder.build();
- }
-
- /**
- * Inside SearchServicePipeline, add following samples to test the search target.
- *
- * targets.add(SearchTargetUtil.generateThumbnail_SearchAction("blue", Color.BLUE));
- * targets.add(SearchTargetUtil.generateThumbnail_SearchAction("red", Color.RED));
- * targets.add(SearchTargetUtil.generateThumbnail_SearchAction("green", Color.GREEN));
- */
- public static SearchTarget generateThumbnail_usingSearchAction(String id, int color) {
- SearchTarget.Builder builder =
- new SearchTarget.Builder(SCREENSHOT, THUMBNAIL, id)
- .setPackageName(PACKAGE2) /* required */
- .setUserHandle(USERHANDLE); /* required */
-
-
- Intent intent = new Intent(Intent.ACTION_VIEW)
- .setData(Uri.parse("uri blah blah"))
- .setType("image/*")
- .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- Bitmap bitmap = Bitmap.createBitmap(1000, 500, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
- canvas.drawColor(color);
- Icon icon = Icon.createWithBitmap(bitmap);
-
- builder.setSearchAction(new SearchAction.Builder(id, TITLE)
- .setSubtitle(SUBTITLE)
- .setIcon(icon)
- .setIntent(intent)
- .build());
- return builder.build();
-
- }
-
- /**
- * Generate SearchTargetUtil for SMALL_ICON_HORIZONTAL_TEXT layout type.
- *
- * targets.add(SearchTargetUtil.generateIconHorizontalText_SearchAction(
- * mContext, "red", Color.RED));
- * targets.add(SearchTargetUtil.generateIconHorizontalText_SearchAction(
- * mContext, "yellow", Color.YELLOW));
- */
- public static SearchTarget generateSmallIconHorizontalText_usingSearchAction(
- Context context, String id, int color) {
- String title = "Ask the assistant";
- String fallbackQuery = "sourdough bread";
- SearchTarget.Builder builder =
- new SearchTarget.Builder(SUGGEST, SMALL_ICON_HORIZONTAL_TEXT, id)
- .setPackageName(PACKAGE2) /* required */
- .setUserHandle(USERHANDLE); /* required */
-
- Intent intent3 = new Intent("com.google.android.googlequicksearchbox.GENERIC_QUERY");
- intent3.putExtra("query", fallbackQuery);
- intent3.putExtra("full_screen", false);
- PendingIntent pendingIntent3 =
- PendingIntent.getActivity(
- context, 1, intent3,
- PendingIntent.FLAG_UPDATE_CURRENT);
-
- Bitmap bitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
- canvas.drawColor(color);
- Icon icon = Icon.createWithAdaptiveBitmap(bitmap);
-
- Bundle extra = new Bundle();
- extra.putBoolean(BUNDLE_EXTRA_SHOULD_START_FOR_RESULT, true);
-
- SearchAction searchAction = new SearchAction.Builder(id, title)
- .setSubtitle(fallbackQuery)
- .setPendingIntent(pendingIntent3)
- .setIcon(icon)
- .setExtras(extra)
- .build();
- return builder.setSearchAction(searchAction).build();
- }
-
- public static SearchTarget generateDivider() {
- SearchTarget.Builder builder =
- new SearchTarget.Builder(SUGGEST, DIVIDER, "divider")
- .setPackageName("") /* required but not used*/
- .setUserHandle(USERHANDLE); /* required */
- return builder.build();
- }
-
-
- /**
- * Generate SearchTargetUtil for ICON_DOUBLE_HORIZONTAL_TEXT layout type.
- */
- public static SearchTarget generateIconDoubleHorizontalText_ShortcutInfo(Context context) {
- String id = "23456";
- SearchTarget.Builder builder =
- new SearchTarget.Builder(ResultType.SHORTCUT, SMALL_ICON_HORIZONTAL_TEXT, id)
- .setPackageName("com.google.android.gm") /* required */
- .setUserHandle(UserHandle.CURRENT); /* required */
-
- builder.setShortcutInfo(new ShortcutInfo.Builder(context, id).build());
- return builder.build();
- }
-}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java b/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java
index 22c4a7e..2d50125 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java
@@ -160,7 +160,7 @@
public boolean performAccessibilityAction(int action, ItemInfo info) {
QuickstepLauncher launcher = Launcher.cast(Launcher.getLauncher(getContext()));
if (action == PIN_PREDICTION) {
- if (launcher == null || launcher.getHotseatPredictionController() == null) {
+ if (launcher == null) {
return false;
}
HotseatPredictionController controller = launcher.getHotseatPredictionController();
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index 9a1e707..2e018f3 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -45,11 +45,8 @@
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Workspace;
-import com.android.launcher3.allapps.AllAppsContainerView;
-import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.appprediction.PredictionRowView;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.StatsLogManager.StatsLogger;
@@ -57,7 +54,6 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.SystemShortcut;
-import com.android.launcher3.search.DeviceSearchAdapterProvider;
import com.android.launcher3.statemanager.StateManager.AtomicAnimationFactory;
import com.android.launcher3.uioverrides.states.QuickstepAtomicAnimationFactory;
import com.android.launcher3.uioverrides.touchcontrollers.NavBarToHomeTouchController;
@@ -104,9 +100,7 @@
@Override
protected void setupViews() {
super.setupViews();
- if (FeatureFlags.ENABLE_HYBRID_HOTSEAT.get()) {
- mHotseatPredictionController = new HotseatPredictionController(this);
- }
+ mHotseatPredictionController = new HotseatPredictionController(this);
}
@Override
@@ -141,9 +135,7 @@
}
logger.log(LAUNCHER_APP_LAUNCH_TAP);
- if (mHotseatPredictionController != null) {
- mHotseatPredictionController.logLaunchedAppRankingInfo(info, instanceId);
- }
+ mHotseatPredictionController.logLaunchedAppRankingInfo(info, instanceId);
}
/**
@@ -166,10 +158,8 @@
@Override
public boolean startActivitySafely(View v, Intent intent, ItemInfo item) {
- if (mHotseatPredictionController != null) {
- // Only pause is taskbar controller is not present
- mHotseatPredictionController.setPauseUIUpdate(getTaskbarController() == null);
- }
+ // Only pause is taskbar controller is not present
+ mHotseatPredictionController.setPauseUIUpdate(getTaskbarController() == null);
return super.startActivitySafely(v, intent, item);
}
@@ -181,7 +171,7 @@
onStateOrResumeChanging((getActivityFlags() & ACTIVITY_STATE_TRANSITION_ACTIVE) == 0);
}
- if (mHotseatPredictionController != null && ((changeBits & ACTIVITY_STATE_STARTED) != 0
+ if (((changeBits & ACTIVITY_STATE_STARTED) != 0
|| (changeBits & getActivityFlags() & ACTIVITY_STATE_DEFERRED_RESUMED) != 0)) {
mHotseatPredictionController.setPauseUIUpdate(false);
}
@@ -195,12 +185,8 @@
@Override
public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
- if (mHotseatPredictionController != null) {
- return Stream.concat(super.getSupportedShortcuts(),
- Stream.of(mHotseatPredictionController));
- } else {
- return super.getSupportedShortcuts();
- }
+ return Stream.concat(
+ super.getSupportedShortcuts(), Stream.of(mHotseatPredictionController));
}
/**
@@ -227,8 +213,7 @@
mAllAppsPredictions = item;
getAppsView().getFloatingHeaderView().findFixedRowByType(PredictionRowView.class)
.setPredictedApps(item.items);
- } else if (item.containerId == Favorites.CONTAINER_HOTSEAT_PREDICTION
- && mHotseatPredictionController != null) {
+ } else if (item.containerId == Favorites.CONTAINER_HOTSEAT_PREDICTION) {
mHotseatPredictionController.setPredictedItems(item);
}
}
@@ -246,10 +231,7 @@
public void onDestroy() {
super.onDestroy();
getAppsView().getSearchUiManager().destroy();
- if (mHotseatPredictionController != null) {
- mHotseatPredictionController.destroy();
- mHotseatPredictionController = null;
- }
+ mHotseatPredictionController.destroy();
}
@Override
@@ -293,11 +275,6 @@
}
@Override
- public SearchAdapterProvider createSearchAdapterProvider(AllAppsContainerView appsView) {
- return new DeviceSearchAdapterProvider(this, appsView);
- }
-
- @Override
public TouchController[] createTouchControllers() {
Mode mode = SysUINavigationMode.getMode(this);
diff --git a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
index b258a10..6a32dc4 100644
--- a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
+++ b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
@@ -30,7 +30,6 @@
import android.graphics.Point;
import android.graphics.RectF;
import android.util.Log;
-import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.Surface;
@@ -40,6 +39,9 @@
import com.android.launcher3.util.DisplayController.Info;
import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
/**
* Maintains state for supporting nav bars and tracking their gestures in multiple orientations.
@@ -51,6 +53,37 @@
*/
class OrientationTouchTransformer {
+ class CurrentDisplay {
+ public Point size;
+ public int rotation;
+
+ CurrentDisplay() {
+ this.size = new Point(0, 0);
+ this.rotation = 0;
+ }
+
+ CurrentDisplay(Point size, int rotation) {
+ this.size = size;
+ this.rotation = rotation;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ CurrentDisplay display = (CurrentDisplay) o;
+ if (rotation != display.rotation) return false;
+
+ return Objects.equals(size, display.size);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(size, rotation);
+ }
+ };
+
private static final String TAG = "OrientationTouchTransformer";
private static final boolean DEBUG = false;
private static final int MAX_ORIENTATIONS = 4;
@@ -60,11 +93,12 @@
private final Matrix mTmpMatrix = new Matrix();
private final float[] mTmpPoint = new float[2];
- private SparseArray<OrientationRectF> mSwipeTouchRegions = new SparseArray<>(MAX_ORIENTATIONS);
+ private Map<CurrentDisplay, OrientationRectF> mSwipeTouchRegions =
+ new HashMap<CurrentDisplay, OrientationRectF>();
private final RectF mAssistantLeftRegion = new RectF();
private final RectF mAssistantRightRegion = new RectF();
private final RectF mOneHandedModeRegion = new RectF();
- private int mCurrentDisplayRotation;
+ private CurrentDisplay mCurrentDisplay = new CurrentDisplay();
private int mNavBarGesturalHeight;
private int mNavBarLargerGesturalHeight;
private boolean mEnableMultipleRegions;
@@ -147,21 +181,22 @@
* @see #enableMultipleRegions(boolean, Info)
*/
void createOrAddTouchRegion(Info info) {
- mCurrentDisplayRotation = info.rotation;
+ mCurrentDisplay = new CurrentDisplay(info.realSize, info.rotation);
+
if (mQuickStepStartingRotation > QUICKSTEP_ROTATION_UNINITIALIZED
- && mCurrentDisplayRotation == mQuickStepStartingRotation) {
+ && mCurrentDisplay.rotation == mQuickStepStartingRotation) {
// User already was swiping and the current screen is same rotation as the starting one
// Remove active nav bars in other rotations except for the one we started out in
resetSwipeRegions(info);
return;
}
- OrientationRectF region = mSwipeTouchRegions.get(mCurrentDisplayRotation);
+ OrientationRectF region = mSwipeTouchRegions.get(mCurrentDisplay);
if (region != null) {
return;
}
if (mEnableMultipleRegions) {
- mSwipeTouchRegions.put(mCurrentDisplayRotation, createRegionForDisplay(info));
+ mSwipeTouchRegions.put(mCurrentDisplay, createRegionForDisplay(info));
} else {
resetSwipeRegions(info);
}
@@ -208,31 +243,31 @@
*/
private void resetSwipeRegions(Info region) {
if (DEBUG) {
- Log.d(TAG, "clearing all regions except rotation: " + mCurrentDisplayRotation);
+ Log.d(TAG, "clearing all regions except rotation: " + mCurrentDisplay.rotation);
}
- mCurrentDisplayRotation = region.rotation;
- OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplayRotation);
+ mCurrentDisplay = new CurrentDisplay(region.realSize, region.rotation);
+ OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplay);
if (regionToKeep == null) {
regionToKeep = createRegionForDisplay(region);
}
mSwipeTouchRegions.clear();
- mSwipeTouchRegions.put(mCurrentDisplayRotation, regionToKeep);
+ mSwipeTouchRegions.put(mCurrentDisplay, regionToKeep);
updateAssistantRegions(regionToKeep);
}
private void resetSwipeRegions() {
- OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplayRotation);
+ OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplay);
mSwipeTouchRegions.clear();
if (regionToKeep != null) {
- mSwipeTouchRegions.put(mCurrentDisplayRotation, regionToKeep);
+ mSwipeTouchRegions.put(mCurrentDisplay, regionToKeep);
updateAssistantRegions(regionToKeep);
}
}
private OrientationRectF createRegionForDisplay(Info display) {
if (DEBUG) {
- Log.d(TAG, "creating rotation region for: " + mCurrentDisplayRotation);
+ Log.d(TAG, "creating rotation region for: " + mCurrentDisplay.rotation);
}
Point size = display.realSize;
@@ -341,7 +376,9 @@
}
for (int i = 0; i < MAX_ORIENTATIONS; i++) {
- OrientationRectF rect = mSwipeTouchRegions.get(i);
+ CurrentDisplay display = new CurrentDisplay(mCurrentDisplay.size, i);
+ OrientationRectF rect = mSwipeTouchRegions.get(display);
+
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.NO_SWIPE_TO_HOME, "transform:DOWN, rect=" + rect);
}
@@ -355,7 +392,7 @@
mLastRectTouched = rect;
mActiveTouchRotation = rect.mRotation;
if (mEnableMultipleRegions
- && mCurrentDisplayRotation == mActiveTouchRotation) {
+ && mCurrentDisplay.rotation == mActiveTouchRotation) {
// TODO(b/154580671) might make this block unnecessary
// Start a touch session for the default nav region for the display
mQuickStepStartingRotation = mLastRectTouched.mRotation;
@@ -378,8 +415,8 @@
pw.println(" lastTouchedRegion=" + mLastRectTouched);
pw.println(" multipleRegionsEnabled=" + mEnableMultipleRegions);
StringBuilder regions = new StringBuilder(" currentTouchableRotations=");
- for(int i = 0; i < mSwipeTouchRegions.size(); i++) {
- OrientationRectF rectF = mSwipeTouchRegions.get(mSwipeTouchRegions.keyAt(i));
+ for (CurrentDisplay key: mSwipeTouchRegions.keySet()) {
+ OrientationRectF rectF = mSwipeTouchRegions.get(key);
regions.append(rectF).append(" ");
}
pw.println(regions.toString());
@@ -417,12 +454,12 @@
boolean applyTransform(MotionEvent event, boolean forceTransform) {
mTmpMatrix.reset();
- postDisplayRotation(deltaRotation(mCurrentDisplayRotation, mRotation),
+ postDisplayRotation(deltaRotation(mCurrentDisplay.rotation, mRotation),
mHeight, mWidth, mTmpMatrix);
if (forceTransform) {
if (DEBUG) {
Log.d(TAG, "Transforming rotation due to forceTransform, "
- + "mCurrentRotation: " + mCurrentDisplayRotation
+ + "mCurrentRotation: " + mCurrentDisplay.rotation
+ "mRotation: " + mRotation);
}
event.transform(mTmpMatrix);
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index 85b21e0..64d05e1 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -481,6 +481,17 @@
}
@Override
+ public void exitSplitScreenOnHide(boolean exitSplitScreenOnHide) {
+ if (mSystemUiProxy != null) {
+ try {
+ mSystemUiProxy.exitSplitScreenOnHide(exitSplitScreenOnHide);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed call exitSplitScreen");
+ }
+ }
+ }
+
+ @Override
public void startTask(int taskId, int stage, int position, Bundle options) {
if (mSystemUiProxy != null) {
try {
diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
index 8cde5f2..8151d41 100644
--- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
+++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
@@ -15,8 +15,6 @@
*/
package com.android.quickstep.util;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_SYSTEM_VELOCITY_PROVIDER;
-
import android.content.Context;
import android.content.res.Resources;
import android.view.MotionEvent;
@@ -51,7 +49,7 @@
private final Alarm mForcePauseTimeout;
private final boolean mMakePauseHarderToTrigger;
private final Context mContext;
- private final VelocityProvider mVelocityProvider;
+ private final SystemVelocityProvider mVelocityProvider;
private Float mPreviousVelocity = null;
@@ -88,8 +86,7 @@
mForcePauseTimeout = new Alarm();
mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */));
mMakePauseHarderToTrigger = makePauseHarderToTrigger;
- mVelocityProvider = ENABLE_SYSTEM_VELOCITY_PROVIDER.get()
- ? new SystemVelocityProvider(axis) : new LinearVelocityProvider(axis);
+ mVelocityProvider = new SystemVelocityProvider(axis);
}
/**
@@ -124,8 +121,8 @@
mForcePauseTimeout.setAlarm(mMakePauseHarderToTrigger
? HARDER_TRIGGER_TIMEOUT
: FORCE_PAUSE_TIMEOUT);
- Float newVelocity = mVelocityProvider.addMotionEvent(ev, pointerIndex);
- if (newVelocity != null && mPreviousVelocity != null) {
+ float newVelocity = mVelocityProvider.addMotionEvent(ev, pointerIndex);
+ if (mPreviousVelocity != null) {
checkMotionPaused(newVelocity, mPreviousVelocity, ev.getEventTime());
}
mPreviousVelocity = newVelocity;
@@ -210,58 +207,7 @@
default void onMotionPauseChanged(boolean isPaused) { }
}
- /**
- * Interface to abstract out velocity calculations
- */
- protected interface VelocityProvider {
-
- /**
- * Adds a new motion events, and returns the velocity at this point, or null if
- * the velocity is not available
- */
- Float addMotionEvent(MotionEvent ev, int pointer);
-
- /**
- * Clears all stored motion event records
- */
- void clear();
- }
-
- private static class LinearVelocityProvider implements VelocityProvider {
-
- private Long mPreviousTime = null;
- private Float mPreviousPosition = null;
-
- private final int mAxis;
-
- LinearVelocityProvider(int axis) {
- mAxis = axis;
- }
-
- @Override
- public Float addMotionEvent(MotionEvent ev, int pointer) {
- long time = ev.getEventTime();
- float position = ev.getAxisValue(mAxis, pointer);
- Float velocity = null;
-
- if (mPreviousTime != null && mPreviousPosition != null) {
- long changeInTime = Math.max(1, time - mPreviousTime);
- float changeInPosition = position - mPreviousPosition;
- velocity = changeInPosition / changeInTime;
- }
- mPreviousTime = time;
- mPreviousPosition = position;
- return velocity;
- }
-
- @Override
- public void clear() {
- mPreviousTime = null;
- mPreviousPosition = null;
- }
- }
-
- private static class SystemVelocityProvider implements VelocityProvider {
+ private static class SystemVelocityProvider {
private final VelocityTracker mVelocityTracker;
private final int mAxis;
@@ -271,8 +217,11 @@
mAxis = axis;
}
- @Override
- public Float addMotionEvent(MotionEvent ev, int pointer) {
+ /**
+ * Adds a new motion events, and returns the velocity at this point, or null if
+ * the velocity is not available
+ */
+ public float addMotionEvent(MotionEvent ev, int pointer) {
mVelocityTracker.addMovement(ev);
mVelocityTracker.computeCurrentVelocity(1); // px / ms
return mAxis == MotionEvent.AXIS_X
@@ -280,7 +229,9 @@
: mVelocityTracker.getYVelocity(pointer);
}
- @Override
+ /**
+ * Clears all stored motion event records
+ */
public void clear() {
mVelocityTracker.clear();
}
diff --git a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
index cb81d36..1544f00 100644
--- a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
+++ b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
@@ -27,10 +27,8 @@
import com.android.launcher3.LauncherState;
import com.android.launcher3.Workspace;
-import com.android.launcher3.allapps.AllAppsInsetTransitionController;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
-import com.android.launcher3.search.DeviceSearchEdu;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.uioverrides.QuickstepLauncher;
@@ -43,7 +41,6 @@
*/
public class QuickstepOnboardingPrefs extends OnboardingPrefs<QuickstepLauncher> {
-
public QuickstepOnboardingPrefs(QuickstepLauncher launcher, SharedPreferences sharedPrefs) {
super(launcher, sharedPrefs);
@@ -66,8 +63,7 @@
});
}
- if (FeatureFlags.ENABLE_HYBRID_HOTSEAT.get() && !hasReachedMaxCount(
- HOTSEAT_DISCOVERY_TIP_COUNT)) {
+ if (!hasReachedMaxCount(HOTSEAT_DISCOVERY_TIP_COUNT)) {
stateManager.addStateListener(new StateListener<LauncherState>() {
boolean mFromAllApps = false;
@@ -134,22 +130,5 @@
}
});
}
-
- if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && !getBoolean(SEARCH_EDU_SEEN)) {
- stateManager.addStateListener(new StateListener<LauncherState>() {
- @Override
- public void onStateTransitionStart(LauncherState toState) {
- if (toState == ALL_APPS) {
- AllAppsInsetTransitionController insetTransitionController =
- mLauncher.getAllAppsController().getInsetController();
- insetTransitionController.setSearchEduRunnable(() -> {
- DeviceSearchEdu.show(launcher);
- insetTransitionController.setSearchEduRunnable(null);
- });
- stateManager.removeStateListener(this);
- }
- }
- });
- }
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 6709c2e..0654ab1 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -52,8 +52,6 @@
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.GradientDrawable;
-import android.graphics.drawable.InsetDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.AttributeSet;
@@ -436,9 +434,6 @@
mContextualChip.setScaleX(comp(modalness));
mContextualChip.setScaleY(comp(modalness));
}
- if (mContextualChipWrapper != null) {
- mContextualChipWrapper.setAlpha(comp(modalness));
- }
mDigitalWellBeingToast.updateBannerOffset(modalness);
}
@@ -775,30 +770,16 @@
layoutParams.gravity = BOTTOM | CENTER_HORIZONTAL;
int expectedChipHeight = getExpectedViewHeight(view);
float chipOffset = getResources().getDimension(R.dimen.chip_hint_vertical_offset);
- layoutParams.bottomMargin = (int)
- (((MarginLayoutParams) mSnapshotView.getLayoutParams()).bottomMargin
- - expectedChipHeight + chipOffset);
+ layoutParams.bottomMargin = -expectedChipHeight - (int) chipOffset;
mContextualChip = ((FrameLayout) mContextualChipWrapper).getChildAt(0);
mContextualChip.setScaleX(0f);
mContextualChip.setScaleY(0f);
- GradientDrawable scrimDrawable = (GradientDrawable) getResources().getDrawable(
- R.drawable.chip_scrim_gradient, mActivity.getTheme());
- float cornerRadius = getTaskCornerRadius();
- scrimDrawable.setCornerRadii(
- new float[]{0, 0, 0, 0, cornerRadius, cornerRadius, cornerRadius,
- cornerRadius});
- InsetDrawable scrimDrawableInset = new InsetDrawable(scrimDrawable, 0, 0, 0,
- (int) (expectedChipHeight - chipOffset));
- mContextualChipWrapper.setBackground(scrimDrawableInset);
- mContextualChipWrapper.setPadding(0, 0, 0, 0);
- mContextualChipWrapper.setAlpha(0f);
addView(view, getChildCount(), layoutParams);
if (mContextualChip != null) {
mContextualChip.animate().scaleX(1f).scaleY(1f).setDuration(50);
}
if (mContextualChipWrapper != null) {
mChipTouchDelegate = new TransformingTouchDelegate(mContextualChipWrapper);
- mContextualChipWrapper.animate().alpha(1f).setDuration(50);
}
}
}
@@ -1098,10 +1079,7 @@
public void setFullscreenProgress(float progress) {
progress = Utilities.boundToRange(progress, 0, 1);
mFullscreenProgress = progress;
- boolean isFullscreen = mFullscreenProgress > 0;
mIconView.setVisibility(progress < 1 ? VISIBLE : INVISIBLE);
- setClipChildren(!isFullscreen);
- setClipToPadding(!isFullscreen);
updateTaskScaling();
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 5fd9e01..aa3ef9b 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -18,7 +18,6 @@
import static com.android.launcher3.Utilities.getDevicePrefs;
import static com.android.launcher3.Utilities.getPointString;
-import static com.android.launcher3.config.FeatureFlags.APPLY_CONFIG_AT_RUNTIME;
import static com.android.launcher3.config.FeatureFlags.ENABLE_FOUR_COLUMNS;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
@@ -174,8 +173,7 @@
.putString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, getPointString(numColumns, numRows))
.apply();
- mConfigMonitor = new ConfigMonitor(context,
- APPLY_CONFIG_AT_RUNTIME.get() ? this::onConfigChanged : this::killProcess);
+ mConfigMonitor = new ConfigMonitor(context, this::onConfigChanged);
mOverlayMonitor = new OverlayMonitor(context);
}
@@ -317,11 +315,6 @@
mChangeListeners.remove(listener);
}
- private void killProcess(Context context) {
- Log.e("ConfigMonitor", "restarting launcher");
- android.os.Process.killProcess(android.os.Process.myPid());
- }
-
public void verifyConfigChangedInBackground(final Context context) {
String savedIconMaskPath = getDevicePrefs(context).getString(KEY_ICON_PATH_REF, "");
// Good place to check if grid size changed in themepicker when launcher was dead.
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 2b373a8..556aff6 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -72,9 +72,6 @@
"PROMISE_APPS_NEW_INSTALLS", true,
"Adds a promise icon to the home screen for new install sessions.");
- public static final BooleanFlag APPLY_CONFIG_AT_RUNTIME = getDebugFlag(
- "APPLY_CONFIG_AT_RUNTIME", true, "Apply display changes dynamically");
-
public static final BooleanFlag QUICKSTEP_SPRINGS = getDebugFlag(
"QUICKSTEP_SPRINGS", true, "Enable springs for quickstep animations");
@@ -130,9 +127,6 @@
"ASSISTANT_GIVES_LAUNCHER_FOCUS", false,
"Allow Launcher to handle nav bar gestures while Assistant is running over it");
- public static final BooleanFlag ENABLE_HYBRID_HOTSEAT = getDebugFlag(
- "ENABLE_HYBRID_HOTSEAT", true, "Fill gaps in hotseat with predicted apps");
-
public static final BooleanFlag HOTSEAT_MIGRATE_TO_FOLDER = getDebugFlag(
"HOTSEAT_MIGRATE_TO_FOLDER", false, "Should move hotseat items into a folder");
@@ -172,10 +166,6 @@
"Replace Smartspace with the enhanced version. "
+ "Ignored if ENABLE_SMARTSPACE_UNIVERSAL is enabled.");
- public static final BooleanFlag ENABLE_SYSTEM_VELOCITY_PROVIDER = getDebugFlag(
- "ENABLE_SYSTEM_VELOCITY_PROVIDER", true,
- "Use system VelocityTracker's algorithm for motion pause detection.");
-
public static final BooleanFlag ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS =
getDebugFlag(
"ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS", false,
diff --git a/src/com/android/launcher3/logging/FileLog.java b/src/com/android/launcher3/logging/FileLog.java
index 6bc1ecb..cdd0bda 100644
--- a/src/com/android/launcher3/logging/FileLog.java
+++ b/src/com/android/launcher3/logging/FileLog.java
@@ -10,7 +10,6 @@
import androidx.annotation.VisibleForTesting;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.IOUtils;
import java.io.BufferedReader;
@@ -43,7 +42,7 @@
private static Handler sHandler = null;
private static File sLogsDirectory = null;
- public static final int LOG_DAYS = FeatureFlags.ENABLE_HYBRID_HOTSEAT.get() ? 10 : 4;
+ public static final int LOG_DAYS = 4;
public static void setDir(File logsDir) {
if (ENABLED) {