Snap for 7135433 from 9012515fef to sc-release
Change-Id: Ide101772df983c43926aedd6138850a286640852
This commit is contained in:
commit
e7859cd3b0
51 files changed
+558
-3158
No files matched your search
@@ -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>
|
||||
@@ -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" />
|
||||
@@ -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>
|
||||
@@ -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" />
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
@@ -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"/>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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" />
|
||||
@@ -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">
|
||||
|
||||
+71
-27
@@ -43,8 +43,18 @@ import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@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 @@ public class OrientationTouchTransformerTest {
|
||||
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 @@ public class OrientationTouchTransformerTest {
|
||||
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 @@ public class OrientationTouchTransformerTest {
|
||||
|
||||
@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 @@ public class OrientationTouchTransformerTest {
|
||||
|
||||
@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 @@ public class OrientationTouchTransformerTest {
|
||||
|
||||
@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));
|
||||
@@ -163,6 +185,26 @@ public class OrientationTouchTransformerTest {
|
||||
event -> mTouchTransformer.touchInAssistantRegion(event));
|
||||
}
|
||||
|
||||
@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);
|
||||
@@ -182,7 +224,7 @@ public class OrientationTouchTransformerTest {
|
||||
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 @@ public class OrientationTouchTransformerTest {
|
||||
@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 class OrientationTouchTransformerTest {
|
||||
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 @@ public class OrientationTouchTransformerTest {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.android.launcher3.util.ActivityTracker;
|
||||
*/
|
||||
public class HotseatEduActivity extends Activity {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -49,7 +48,7 @@ public class HotseatEduActivity extends Activity {
|
||||
@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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
+17
-15
@@ -26,7 +26,6 @@ import android.animation.Animator;
|
||||
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.Hotseat;
|
||||
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 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
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 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
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 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
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 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
@Override
|
||||
public void onAnimationSuccess(Animator animator) {
|
||||
if (icon.getParent() != null) {
|
||||
mHotseat.removeView(icon);
|
||||
removeIconWithoutNotify(icon);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -397,6 +398,17 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
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 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
* 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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public class TaskbarHotseatController {
|
||||
|
||||
protected void init() {
|
||||
mLauncher.getDragController().addDragListener(mDragListener);
|
||||
onHotseatUpdated();
|
||||
}
|
||||
|
||||
protected void cleanup() {
|
||||
|
||||
@@ -50,6 +50,8 @@ public class TaskbarRecentsController {
|
||||
// The current background requests to load the task icons
|
||||
private CancellableTask[] mIconLoadRequests = new CancellableTask[mNumRecentIcons];
|
||||
|
||||
private boolean mIsAlive;
|
||||
|
||||
public TaskbarRecentsController(BaseQuickstepLauncher launcher,
|
||||
TaskbarController.TaskbarRecentsControllerCallbacks taskbarCallbacks) {
|
||||
mLauncher = launcher;
|
||||
@@ -58,11 +60,13 @@ public class TaskbarRecentsController {
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
mIsAlive = true;
|
||||
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackChangeListener);
|
||||
reloadRecentTasksIfNeeded();
|
||||
}
|
||||
|
||||
protected void cleanup() {
|
||||
mIsAlive = false;
|
||||
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(
|
||||
mTaskStackChangeListener);
|
||||
cancelAllPendingIconLoadTasks();
|
||||
@@ -84,7 +88,9 @@ public class TaskbarRecentsController {
|
||||
}
|
||||
|
||||
private void onRecentTasksChanged(ArrayList<Task> tasks) {
|
||||
mTaskbarCallbacks.updateRecentItems(tasks);
|
||||
if (mIsAlive) {
|
||||
mTaskbarCallbacks.updateRecentItems(tasks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -160,7 +160,7 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements
|
||||
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();
|
||||
|
||||
@@ -45,11 +45,8 @@ import com.android.launcher3.Launcher;
|
||||
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.BgDataModel.FixedContainerItems;
|
||||
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 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
@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 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
}
|
||||
logger.log(LAUNCHER_APP_LAUNCH_TAP);
|
||||
|
||||
if (mHotseatPredictionController != null) {
|
||||
mHotseatPredictionController.logLaunchedAppRankingInfo(info, instanceId);
|
||||
}
|
||||
mHotseatPredictionController.logLaunchedAppRankingInfo(info, instanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,10 +158,8 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
|
||||
@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 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
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 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
|
||||
@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 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
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 class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
getAppsView().getSearchUiManager().destroy();
|
||||
if (mHotseatPredictionController != null) {
|
||||
mHotseatPredictionController.destroy();
|
||||
mHotseatPredictionController = null;
|
||||
}
|
||||
mHotseatPredictionController.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -292,11 +274,6 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchAdapterProvider createSearchAdapterProvider(AllAppsContainerView appsView) {
|
||||
return new DeviceSearchAdapterProvider(this, appsView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TouchController[] createTouchControllers() {
|
||||
Mode mode = SysUINavigationMode.getMode(this);
|
||||
|
||||
+5
-2
@@ -32,6 +32,7 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.touch.BaseSwipeDetector;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.touch.SingleAxisSwipeDetector;
|
||||
@@ -150,9 +151,11 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
|
||||
mTaskBeingDragged = view;
|
||||
int upDirection = mRecentsView.getPagedOrientationHandler()
|
||||
.getUpDirection(mIsRtl);
|
||||
if (!SysUINavigationMode.getMode(mActivity).hasGestures) {
|
||||
if (!SysUINavigationMode.getMode(mActivity).hasGestures || (
|
||||
mActivity.getDeviceProfile().isTablet
|
||||
&& FeatureFlags.ENABLE_OVERVIEW_GRID.get())) {
|
||||
// Don't allow swipe down to open if we don't support swipe up
|
||||
// to enter overview.
|
||||
// to enter overview, or when grid layout is enabled.
|
||||
directionsToDetectScroll = upDirection;
|
||||
mAllowGoingUp = true;
|
||||
mAllowGoingDown = false;
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.graphics.Matrix;
|
||||
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.testing.TestProtocol;
|
||||
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 @@ import java.io.PrintWriter;
|
||||
*/
|
||||
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 @@ class OrientationTouchTransformer {
|
||||
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 @@ class OrientationTouchTransformer {
|
||||
* @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 @@ class OrientationTouchTransformer {
|
||||
*/
|
||||
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 @@ class OrientationTouchTransformer {
|
||||
}
|
||||
|
||||
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 @@ class OrientationTouchTransformer {
|
||||
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 @@ class OrientationTouchTransformer {
|
||||
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 @@ class OrientationTouchTransformer {
|
||||
|
||||
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);
|
||||
|
||||
@@ -480,6 +480,17 @@ public class SystemUiProxy implements ISystemUiProxy {
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
@@ -49,6 +49,7 @@ import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.statehandlers.DepthController;
|
||||
import com.android.launcher3.statemanager.StateManager;
|
||||
@@ -174,11 +175,13 @@ public final class TaskViewUtils {
|
||||
|
||||
final RecentsView recentsView = v.getRecentsView();
|
||||
int taskIndex = recentsView.indexOfChild(v);
|
||||
boolean parallaxCenterAndAdjacentTask = taskIndex != recentsView.getCurrentPage();
|
||||
int startScroll = recentsView.getScrollOffset(taskIndex);
|
||||
|
||||
Context context = v.getContext();
|
||||
DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
|
||||
boolean parallaxCenterAndAdjacentTask =
|
||||
taskIndex != recentsView.getCurrentPage() && !(dp.isTablet
|
||||
&& FeatureFlags.ENABLE_OVERVIEW_GRID.get());
|
||||
int startScroll = recentsView.getScrollOffset(taskIndex);
|
||||
|
||||
TaskViewSimulator topMostSimulator = null;
|
||||
|
||||
if (tsv == null && targets.apps.length > 0) {
|
||||
|
||||
@@ -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 @@ public class MotionPauseDetector {
|
||||
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 @@ public class MotionPauseDetector {
|
||||
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 @@ public class MotionPauseDetector {
|
||||
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 @@ public class MotionPauseDetector {
|
||||
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 @@ public class MotionPauseDetector {
|
||||
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 @@ public class MotionPauseDetector {
|
||||
: mVelocityTracker.getYVelocity(pointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Clears all stored motion event records
|
||||
*/
|
||||
public void clear() {
|
||||
mVelocityTracker.clear();
|
||||
}
|
||||
|
||||
@@ -27,10 +27,8 @@ import android.content.SharedPreferences;
|
||||
|
||||
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 @@ import com.android.quickstep.views.AllAppsEduView;
|
||||
*/
|
||||
public class QuickstepOnboardingPrefs extends OnboardingPrefs<QuickstepLauncher> {
|
||||
|
||||
|
||||
public QuickstepOnboardingPrefs(QuickstepLauncher launcher, SharedPreferences sharedPrefs) {
|
||||
super(launcher, sharedPrefs);
|
||||
|
||||
@@ -66,8 +63,7 @@ public class QuickstepOnboardingPrefs extends OnboardingPrefs<QuickstepLauncher>
|
||||
});
|
||||
}
|
||||
|
||||
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 @@ public class QuickstepOnboardingPrefs extends OnboardingPrefs<QuickstepLauncher>
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,8 +276,9 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
|
||||
int start = mOrientationState.getOrientationHandler()
|
||||
.getPrimaryValue(mTaskRect.left, mTaskRect.top);
|
||||
mScrollState.screenCenter = start + mScrollState.scroll + mScrollState.halfPageSize;
|
||||
mScrollState.updateInterpolation(start);
|
||||
mCurveScale = TaskView.getCurveScaleForInterpolation(mScrollState.linearInterpolation);
|
||||
mScrollState.updateInterpolation(mDp, start);
|
||||
mCurveScale = TaskView.getCurveScaleForInterpolation(mDp,
|
||||
mScrollState.linearInterpolation);
|
||||
}
|
||||
|
||||
float progress = Utilities.boundToRange(fullScreenProgress.value, 0, 1);
|
||||
|
||||
@@ -898,9 +898,14 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
||||
public void setFullscreenProgress(float fullscreenProgress) {
|
||||
mFullscreenProgress = fullscreenProgress;
|
||||
int taskCount = getTaskViewCount();
|
||||
float accumulatedTranslationX = 0;
|
||||
for (int i = 0; i < taskCount; i++) {
|
||||
getTaskViewAt(i).setFullscreenProgress(mFullscreenProgress);
|
||||
TaskView taskView = getTaskViewAt(i);
|
||||
taskView.setFullscreenProgress(mFullscreenProgress);
|
||||
taskView.setAccumulatedTranslationX(accumulatedTranslationX);
|
||||
accumulatedTranslationX += taskView.getFullscreenTranslationX();
|
||||
}
|
||||
|
||||
// Fade out the actions view quickly (0.1 range)
|
||||
mActionsView.getFullscreenAlpha().setValue(
|
||||
mapToRange(fullscreenProgress, 0, 0.1f, 1f, 0f, LINEAR));
|
||||
@@ -934,6 +939,11 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
||||
setPadding(mTempRect.left - mInsets.left, mTempRect.top - mInsets.top,
|
||||
dp.widthPx - mInsets.right - mTempRect.right,
|
||||
dp.heightPx - mInsets.bottom - mTempRect.bottom);
|
||||
// Force TaskView to update size from thumbnail
|
||||
final int taskCount = getTaskViewCount();
|
||||
for (int i = 0; i < taskCount; i++) {
|
||||
getTaskViewAt(i).updateTaskSize();
|
||||
}
|
||||
}
|
||||
|
||||
public void getTaskSize(Rect outRect) {
|
||||
@@ -942,6 +952,11 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
||||
mLastComputedTaskSize.set(outRect);
|
||||
}
|
||||
|
||||
/** Gets the last computed task size */
|
||||
public Rect getLastComputedTaskSize() {
|
||||
return mLastComputedTaskSize;
|
||||
}
|
||||
|
||||
/** Gets the task size for modal state. */
|
||||
public void getModalTaskSize(Rect outRect) {
|
||||
mSizeStrategy.calculateModalTaskSize(mActivity, mActivity.getDeviceProfile(), outRect);
|
||||
@@ -987,7 +1002,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
||||
final int pageCount = getPageCount();
|
||||
for (int i = 0; i < pageCount; i++) {
|
||||
View page = getPageAt(i);
|
||||
mScrollState.updateInterpolation(
|
||||
mScrollState.updateInterpolation(mActivity.getDeviceProfile(),
|
||||
mOrientationHandler.getChildStartWithTranslation(page));
|
||||
((PageCallbacks) page).onPageScroll(mScrollState);
|
||||
}
|
||||
@@ -1422,13 +1437,13 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
||||
/**
|
||||
* Updates linearInterpolation for the provided child position
|
||||
*/
|
||||
public void updateInterpolation(float childStart) {
|
||||
public void updateInterpolation(DeviceProfile deviceProfile, float childStart) {
|
||||
float pageCenter = childStart + halfPageSize;
|
||||
float distanceFromScreenCenter = screenCenter - pageCenter;
|
||||
// How far the page has to move from the center to be offscreen, taking into account
|
||||
// the EDGE_SCALE_DOWN_FACTOR that will be applied at that position.
|
||||
float distanceToReachEdge = halfScreenSize
|
||||
+ halfPageSize * (1 - TaskView.EDGE_SCALE_DOWN_FACTOR);
|
||||
+ halfPageSize * (1 - TaskView.getEdgeScaleDownFactor(deviceProfile));
|
||||
linearInterpolation = Math.min(1,
|
||||
Math.abs(distanceFromScreenCenter) / distanceToReachEdge);
|
||||
}
|
||||
@@ -1444,12 +1459,13 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
||||
}
|
||||
}
|
||||
|
||||
private void addDismissedTaskAnimations(View taskView, long duration, PendingAnimation anim) {
|
||||
private void addDismissedTaskAnimations(TaskView taskView, long duration,
|
||||
PendingAnimation anim) {
|
||||
// Use setFloat instead of setViewAlpha as we want to keep the view visible even when it's
|
||||
// alpha is set to 0 so that it can be recycled in the view pool properly
|
||||
anim.setFloat(taskView, VIEW_ALPHA, 0, ACCEL_2);
|
||||
FloatProperty<View> secondaryViewTranslate =
|
||||
mOrientationHandler.getSecondaryViewTranslate();
|
||||
FloatProperty<TaskView> secondaryViewTranslate =
|
||||
taskView.getDismissTaskTranslationProperty();
|
||||
int secondaryTaskDimension = mOrientationHandler.getSecondaryDimension(taskView);
|
||||
int verticalFactor = mOrientationHandler.getSecondaryTranslationDirectionFactor();
|
||||
|
||||
@@ -1515,7 +1531,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
||||
int scrollDiff = newScroll[i] - oldScroll[i] + offset;
|
||||
if (scrollDiff != 0) {
|
||||
FloatProperty translationProperty = child instanceof TaskView
|
||||
? ((TaskView) child).getPrimaryFillDismissGapTranslationProperty()
|
||||
? ((TaskView) child).getFillDismissGapTranslationProperty()
|
||||
: mOrientationHandler.getPrimaryViewTranslate();
|
||||
|
||||
ResourceProvider rp = DynamicResource.provider(mActivity);
|
||||
@@ -1971,7 +1987,8 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
||||
// Find the task's scale based on its offscreen progress, then see how far it still needs to
|
||||
// move to be completely offscreen.
|
||||
Utilities.scaleRectFAboutCenter(taskPosition,
|
||||
TaskView.getCurveScaleForInterpolation(centerToOffscreenProgress));
|
||||
TaskView.getCurveScaleForInterpolation(mActivity.getDeviceProfile(),
|
||||
centerToOffscreenProgress));
|
||||
distanceToOffscreen = desiredLeft - taskPosition.left;
|
||||
// Finally, we need to account for RecentsView scale, because it moves tasks based on its
|
||||
// pivot. To do this, we move the task position to where it would be offscreen at scale = 1
|
||||
@@ -1990,7 +2007,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
||||
mTaskViewsSecondaryTranslation = translation;
|
||||
for (int i = 0; i < getTaskViewCount(); i++) {
|
||||
TaskView task = getTaskViewAt(i);
|
||||
mOrientationHandler.getSecondaryViewTranslate().set(task, translation / getScaleY());
|
||||
task.getTaskResistanceTranslationProperty().set(task, translation / getScaleY());
|
||||
}
|
||||
mLiveTileTaskViewSimulator.recentsViewSecondaryTranslation.value = translation;
|
||||
}
|
||||
@@ -2358,6 +2375,52 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
|
||||
return super.computeMinScroll();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean getPageScrolls(int[] outPageScrolls, boolean layoutChildren,
|
||||
ComputePageScrollsLogic scrollLogic) {
|
||||
boolean pageScrollChanged = super.getPageScrolls(outPageScrolls, layoutChildren,
|
||||
scrollLogic);
|
||||
|
||||
final int taskCount = getTaskViewCount();
|
||||
final int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
if (childCount < mTaskViewStartIndex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final TaskView taskView = getTaskViewAt(
|
||||
Utilities.boundToRange(i, mTaskViewStartIndex, taskCount - 1));
|
||||
float scrollDiff =
|
||||
taskView.getFullscreenTranslationX() + taskView.getAccumulatedTranslationX();
|
||||
if (scrollDiff != 0) {
|
||||
outPageScrolls[i] += scrollDiff;
|
||||
pageScrollChanged = true;
|
||||
}
|
||||
}
|
||||
return pageScrollChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getChildOffset(int index) {
|
||||
if (index < mTaskViewStartIndex) {
|
||||
return super.getChildOffset(index);
|
||||
}
|
||||
|
||||
final TaskView taskView = getTaskViewAt(
|
||||
Utilities.boundToRange(index, mTaskViewStartIndex, getTaskViewCount() - 1));
|
||||
return super.getChildOffset(index) + (int) taskView.getFullscreenTranslationX()
|
||||
+ (int) taskView.getAccumulatedTranslationX();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getChildVisibleSize(int index) {
|
||||
final TaskView taskView = getTaskViewAtByAbsoluteIndex(index);
|
||||
if (taskView == null) {
|
||||
return super.getChildVisibleSize(index);
|
||||
}
|
||||
return super.getChildVisibleSize(index) - (int) taskView.getFullscreenTranslationX();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int computeMaxScroll() {
|
||||
if (getTaskViewCount() > 0) {
|
||||
|
||||
@@ -51,6 +51,7 @@ import com.android.launcher3.BaseActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
@@ -110,6 +111,9 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
private boolean mOverlayEnabled;
|
||||
private OverviewScreenshotActions mOverviewScreenshotActionsPlugin;
|
||||
|
||||
// TODO(b/179466077): Remove when proper API is ready.
|
||||
private Float mThumbnailRatio = null;
|
||||
|
||||
public TaskThumbnailView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -450,6 +454,31 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
return mThumbnailData.isRealSnapshot;
|
||||
}
|
||||
|
||||
// TODO(b/179466077): Remove when proper API is ready.
|
||||
public float getThumbnailRatio() {
|
||||
// API is ready.
|
||||
if (mThumbnailRatio != null) {
|
||||
return mThumbnailRatio;
|
||||
}
|
||||
|
||||
if (mThumbnailData == null || mThumbnailData.thumbnail == null) {
|
||||
final float[] thumbnailRatios =
|
||||
new float[]{0.8882452f, 1.2834098f, 0.5558415f, 2.15625f};
|
||||
// Use key's hash code to return a deterministic thumbnail ratio.
|
||||
mThumbnailRatio = thumbnailRatios[mTask.key.hashCode() % thumbnailRatios.length];
|
||||
return mThumbnailRatio;
|
||||
}
|
||||
|
||||
float surfaceWidth = mThumbnailData.thumbnail.getWidth() / mThumbnailData.scale;
|
||||
float surfaceHeight = mThumbnailData.thumbnail.getHeight() / mThumbnailData.scale;
|
||||
float availableWidth = surfaceWidth
|
||||
- (mThumbnailData.insets.left + mThumbnailData.insets.right);
|
||||
float availableHeight = surfaceHeight
|
||||
- (mThumbnailData.insets.top + mThumbnailData.insets.bottom);
|
||||
mThumbnailRatio = availableWidth / availableHeight;
|
||||
return mThumbnailRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility class to position the thumbnail in the TaskView
|
||||
*/
|
||||
@@ -480,9 +509,11 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
float scale = thumbnailData.scale;
|
||||
final float thumbnailScale;
|
||||
|
||||
// Landscape vs portrait change
|
||||
// Landscape vs portrait change.
|
||||
// Note: Disable rotation in grid layout.
|
||||
boolean windowingModeSupportsRotation = !dp.isMultiWindowMode
|
||||
&& thumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN;
|
||||
&& thumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN
|
||||
&& !(dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get());
|
||||
isOrientationDifferent = isOrientationChange(deltaRotate)
|
||||
&& windowingModeSupportsRotation;
|
||||
if (canvasWidth == 0 || canvasHeight == 0 || scale == 0) {
|
||||
|
||||
@@ -30,6 +30,8 @@ import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static com.android.launcher3.QuickstepAppTransitionManagerImpl.RECENTS_LAUNCH_DURATION;
|
||||
import static com.android.launcher3.Utilities.comp;
|
||||
import static com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor;
|
||||
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
|
||||
import static com.android.launcher3.anim.Interpolators.EXAGGERATED_EASE;
|
||||
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR;
|
||||
@@ -50,8 +52,6 @@ import android.graphics.Outline;
|
||||
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;
|
||||
@@ -61,6 +61,7 @@ import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.TouchDelegate;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.FrameLayout;
|
||||
@@ -72,6 +73,7 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
@@ -120,10 +122,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
*/
|
||||
public static final float MAX_PAGE_SCRIM_ALPHA = 0.4f;
|
||||
|
||||
/**
|
||||
* How much to scale down pages near the edge of the screen.
|
||||
*/
|
||||
public static final float EDGE_SCALE_DOWN_FACTOR = 0.03f;
|
||||
private static final float EDGE_SCALE_DOWN_FACTOR_CAROUSEL = 0.03f;
|
||||
private static final float EDGE_SCALE_DOWN_FACTOR_GRID = 0.00f;
|
||||
|
||||
public static final long SCALE_ICON_DURATION = 120;
|
||||
private static final long DIM_ANIM_DURATION = 700;
|
||||
@@ -152,29 +152,29 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
}
|
||||
};
|
||||
|
||||
private static final FloatProperty<TaskView> FILL_DISMISS_GAP_TRANSLATION_X =
|
||||
new FloatProperty<TaskView>("fillDismissGapTranslationX") {
|
||||
private static final FloatProperty<TaskView> DISMISS_TRANSLATION_X =
|
||||
new FloatProperty<TaskView>("dismissTranslationX") {
|
||||
@Override
|
||||
public void setValue(TaskView taskView, float v) {
|
||||
taskView.setFillDismissGapTranslationX(v);
|
||||
taskView.setDismissTranslationX(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(TaskView taskView) {
|
||||
return taskView.mFillDismissGapTranslationX;
|
||||
return taskView.mDismissTranslationX;
|
||||
}
|
||||
};
|
||||
|
||||
private static final FloatProperty<TaskView> FILL_DISMISS_GAP_TRANSLATION_Y =
|
||||
new FloatProperty<TaskView>("fillDismissGapTranslationY") {
|
||||
private static final FloatProperty<TaskView> DISMISS_TRANSLATION_Y =
|
||||
new FloatProperty<TaskView>("dismissTranslationY") {
|
||||
@Override
|
||||
public void setValue(TaskView taskView, float v) {
|
||||
taskView.setFillDismissGapTranslationY(v);
|
||||
taskView.setDismissTranslationY(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(TaskView taskView) {
|
||||
return taskView.mFillDismissGapTranslationY;
|
||||
return taskView.mDismissTranslationY;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -204,6 +204,32 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
}
|
||||
};
|
||||
|
||||
private static final FloatProperty<TaskView> TASK_RESISTANCE_TRANSLATION_X =
|
||||
new FloatProperty<TaskView>("taskResistanceTranslationX") {
|
||||
@Override
|
||||
public void setValue(TaskView taskView, float v) {
|
||||
taskView.setTaskResistanceTranslationX(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(TaskView taskView) {
|
||||
return taskView.mTaskResistanceTranslationX;
|
||||
}
|
||||
};
|
||||
|
||||
private static final FloatProperty<TaskView> TASK_RESISTANCE_TRANSLATION_Y =
|
||||
new FloatProperty<TaskView>("taskResistanceTranslationY") {
|
||||
@Override
|
||||
public void setValue(TaskView taskView, float v) {
|
||||
taskView.setTaskResistanceTranslationY(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(TaskView taskView) {
|
||||
return taskView.mTaskResistanceTranslationY;
|
||||
}
|
||||
};
|
||||
|
||||
private final OnAttachStateChangeListener mTaskMenuStateListener =
|
||||
new OnAttachStateChangeListener() {
|
||||
@Override
|
||||
@@ -228,15 +254,22 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
private final DigitalWellBeingToast mDigitalWellBeingToast;
|
||||
private float mCurveScale;
|
||||
private float mFullscreenProgress;
|
||||
private float mScaleAtFullscreen = 1;
|
||||
private float mFullscreenScale = 1;
|
||||
private final FullscreenDrawParams mCurrentFullscreenParams;
|
||||
private final StatefulActivity mActivity;
|
||||
|
||||
// Various causes of changing primary translation, which we aggregate to setTranslationX/Y().
|
||||
// TODO: We should do this for secondary translation properties as well.
|
||||
private float mFillDismissGapTranslationX;
|
||||
private float mFillDismissGapTranslationY;
|
||||
private float mDismissTranslationX;
|
||||
private float mDismissTranslationY;
|
||||
private float mTaskOffsetTranslationX;
|
||||
private float mTaskOffsetTranslationY;
|
||||
private float mTaskResistanceTranslationX;
|
||||
private float mTaskResistanceTranslationY;
|
||||
// The following translation variables should only be used in the same orientation as Launcher.
|
||||
private float mFullscreenTranslationX;
|
||||
private float mAccumulatedTranslationX;
|
||||
private float mBoxTranslationY;
|
||||
|
||||
private ObjectAnimator mIconAndDimAnimator;
|
||||
private float mIconScaleAnimStartProgress = 0;
|
||||
@@ -401,9 +434,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
mContextualChip.setScaleX(comp(modalness));
|
||||
mContextualChip.setScaleY(comp(modalness));
|
||||
}
|
||||
if (mContextualChipWrapper != null) {
|
||||
mContextualChipWrapper.setAlpha(comp(modalness));
|
||||
}
|
||||
mDigitalWellBeingToast.updateBannerOffset(modalness);
|
||||
}
|
||||
|
||||
@@ -425,6 +455,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
cancelPendingLoadTasks();
|
||||
mTask = task;
|
||||
mSnapshotView.bind(task);
|
||||
updateTaskSize();
|
||||
setOrientationState(orientedState);
|
||||
}
|
||||
|
||||
@@ -668,10 +699,12 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
|
||||
protected void resetViewTransforms() {
|
||||
setCurveScale(1);
|
||||
mFillDismissGapTranslationX = mTaskOffsetTranslationX = 0f;
|
||||
mFillDismissGapTranslationY = mTaskOffsetTranslationY = 0f;
|
||||
setTranslationX(0f);
|
||||
setTranslationY(0f);
|
||||
// fullscreenTranslation and accumulatedTranslation should not be reset, as
|
||||
// resetViewTransforms is called during Quickswitch scrolling.
|
||||
mDismissTranslationX = mTaskOffsetTranslationX = mTaskResistanceTranslationX = 0f;
|
||||
mDismissTranslationY = mTaskOffsetTranslationY = mTaskResistanceTranslationY = 0f;
|
||||
applyTranslationX();
|
||||
applyTranslationY();
|
||||
setTranslationZ(0);
|
||||
setAlpha(mStableAlpha);
|
||||
setIconScaleAndDim(1);
|
||||
@@ -684,6 +717,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
|
||||
@Override
|
||||
public void onRecycle() {
|
||||
mFullscreenTranslationX = mAccumulatedTranslationX = mBoxTranslationY = 0f;
|
||||
resetViewTransforms();
|
||||
// Clear any references to the thumbnail (it will be re-read either from the cache or the
|
||||
// system on next bind)
|
||||
@@ -702,7 +736,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
float curveInterpolation =
|
||||
CURVE_INTERPOLATOR.getInterpolation(scrollState.linearInterpolation);
|
||||
float curveScaleForCurveInterpolation = getCurveScaleForCurveInterpolation(
|
||||
curveInterpolation);
|
||||
mActivity.getDeviceProfile(), curveInterpolation);
|
||||
mSnapshotView.setDimAlpha(curveInterpolation * MAX_PAGE_SCRIM_ALPHA);
|
||||
setCurveScale(curveScaleForCurveInterpolation);
|
||||
|
||||
@@ -736,30 +770,16 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -787,40 +807,70 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
setPivotX((right - left) * 0.5f);
|
||||
setPivotY(mSnapshotView.getTop() + mSnapshotView.getHeight() * 0.5f);
|
||||
if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
|
||||
setPivotX(getLayoutDirection() == LAYOUT_DIRECTION_RTL ? (right - left) : 0);
|
||||
setPivotY(0);
|
||||
} else {
|
||||
setPivotX((right - left) * 0.5f);
|
||||
setPivotY(mSnapshotView.getTop() + mSnapshotView.getHeight() * 0.5f);
|
||||
}
|
||||
if (Utilities.ATLEAST_Q) {
|
||||
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).set(0, 0, getWidth(), getHeight());
|
||||
setSystemGestureExclusionRects(SYSTEM_GESTURE_EXCLUSION_RECT);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getCurveScaleForInterpolation(float linearInterpolation) {
|
||||
/**
|
||||
* How much to scale down pages near the edge of the screen according to linearInterpolation.
|
||||
*/
|
||||
public static float getCurveScaleForInterpolation(DeviceProfile deviceProfile,
|
||||
float linearInterpolation) {
|
||||
float curveInterpolation = CURVE_INTERPOLATOR.getInterpolation(linearInterpolation);
|
||||
return getCurveScaleForCurveInterpolation(curveInterpolation);
|
||||
return getCurveScaleForCurveInterpolation(deviceProfile, curveInterpolation);
|
||||
}
|
||||
|
||||
private static float getCurveScaleForCurveInterpolation(float curveInterpolation) {
|
||||
return 1 - curveInterpolation * EDGE_SCALE_DOWN_FACTOR;
|
||||
private static float getCurveScaleForCurveInterpolation(DeviceProfile deviceProfile,
|
||||
float curveInterpolation) {
|
||||
return 1 - curveInterpolation * getEdgeScaleDownFactor(deviceProfile);
|
||||
}
|
||||
|
||||
/**
|
||||
* How much to scale down pages near the edge of the screen.
|
||||
*/
|
||||
public static float getEdgeScaleDownFactor(DeviceProfile deviceProfile) {
|
||||
if (deviceProfile.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
|
||||
return EDGE_SCALE_DOWN_FACTOR_GRID;
|
||||
} else {
|
||||
return EDGE_SCALE_DOWN_FACTOR_CAROUSEL;
|
||||
}
|
||||
}
|
||||
|
||||
private void setCurveScale(float curveScale) {
|
||||
mCurveScale = curveScale;
|
||||
setScaleX(mCurveScale);
|
||||
setScaleY(mCurveScale);
|
||||
applyScale();
|
||||
}
|
||||
|
||||
private void setFullscreenScale(float fullscreenScale) {
|
||||
mFullscreenScale = fullscreenScale;
|
||||
applyScale();
|
||||
}
|
||||
|
||||
private void applyScale() {
|
||||
setScaleX(mCurveScale * mFullscreenScale);
|
||||
setScaleY(mCurveScale * mFullscreenScale);
|
||||
}
|
||||
|
||||
public float getCurveScale() {
|
||||
return mCurveScale;
|
||||
}
|
||||
|
||||
private void setFillDismissGapTranslationX(float x) {
|
||||
mFillDismissGapTranslationX = x;
|
||||
private void setDismissTranslationX(float x) {
|
||||
mDismissTranslationX = x;
|
||||
applyTranslationX();
|
||||
}
|
||||
|
||||
private void setFillDismissGapTranslationY(float y) {
|
||||
mFillDismissGapTranslationY = y;
|
||||
private void setDismissTranslationY(float y) {
|
||||
mDismissTranslationY = y;
|
||||
applyTranslationY();
|
||||
}
|
||||
|
||||
@@ -834,17 +884,59 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
applyTranslationY();
|
||||
}
|
||||
|
||||
private void setTaskResistanceTranslationX(float x) {
|
||||
mTaskResistanceTranslationX = x;
|
||||
applyTranslationX();
|
||||
}
|
||||
|
||||
private void setTaskResistanceTranslationY(float y) {
|
||||
mTaskResistanceTranslationY = y;
|
||||
applyTranslationY();
|
||||
}
|
||||
|
||||
private void setFullscreenTranslationX(float fullscreenTranslationX) {
|
||||
mFullscreenTranslationX = fullscreenTranslationX;
|
||||
applyTranslationX();
|
||||
}
|
||||
|
||||
public float getFullscreenTranslationX() {
|
||||
return mFullscreenTranslationX;
|
||||
}
|
||||
|
||||
public void setAccumulatedTranslationX(float accumulatedTranslationX) {
|
||||
mAccumulatedTranslationX = accumulatedTranslationX;
|
||||
applyTranslationX();
|
||||
}
|
||||
|
||||
public float getAccumulatedTranslationX() {
|
||||
return mAccumulatedTranslationX;
|
||||
}
|
||||
|
||||
private void setBoxTranslationY(float boxTranslationY) {
|
||||
mBoxTranslationY = boxTranslationY;
|
||||
applyTranslationY();
|
||||
}
|
||||
|
||||
private void applyTranslationX() {
|
||||
setTranslationX(mFillDismissGapTranslationX + mTaskOffsetTranslationX);
|
||||
setTranslationX(
|
||||
mDismissTranslationX + mTaskOffsetTranslationX + mTaskResistanceTranslationX
|
||||
+ mFullscreenTranslationX + mAccumulatedTranslationX);
|
||||
}
|
||||
|
||||
private void applyTranslationY() {
|
||||
setTranslationY(mFillDismissGapTranslationY + mTaskOffsetTranslationY);
|
||||
setTranslationY(
|
||||
mDismissTranslationY + mTaskOffsetTranslationY + mTaskResistanceTranslationY
|
||||
+ mBoxTranslationY);
|
||||
}
|
||||
|
||||
public FloatProperty<TaskView> getPrimaryFillDismissGapTranslationProperty() {
|
||||
public FloatProperty<TaskView> getFillDismissGapTranslationProperty() {
|
||||
return getPagedOrientationHandler().getPrimaryValue(
|
||||
FILL_DISMISS_GAP_TRANSLATION_X, FILL_DISMISS_GAP_TRANSLATION_Y);
|
||||
DISMISS_TRANSLATION_X, DISMISS_TRANSLATION_Y);
|
||||
}
|
||||
|
||||
public FloatProperty<TaskView> getDismissTaskTranslationProperty() {
|
||||
return getPagedOrientationHandler().getSecondaryValue(
|
||||
DISMISS_TRANSLATION_X, DISMISS_TRANSLATION_Y);
|
||||
}
|
||||
|
||||
public FloatProperty<TaskView> getPrimaryTaskOffsetTranslationProperty() {
|
||||
@@ -852,6 +944,11 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
TASK_OFFSET_TRANSLATION_X, TASK_OFFSET_TRANSLATION_Y);
|
||||
}
|
||||
|
||||
public FloatProperty<TaskView> getTaskResistanceTranslationProperty() {
|
||||
return getPagedOrientationHandler().getSecondaryValue(
|
||||
TASK_RESISTANCE_TRANSLATION_X, TASK_RESISTANCE_TRANSLATION_Y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
// TODO: Clip-out the icon region from the thumbnail, since they are overlapping.
|
||||
@@ -982,10 +1079,9 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
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();
|
||||
|
||||
TaskThumbnailView thumbnail = getThumbnail();
|
||||
updateCurrentFullscreenParams(thumbnail.getPreviewPositionHelper());
|
||||
@@ -1012,6 +1108,83 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
|
||||
previewPositionHelper);
|
||||
}
|
||||
|
||||
void updateTaskSize() {
|
||||
ViewGroup.LayoutParams params = getLayoutParams();
|
||||
if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
|
||||
final int thumbnailPadding = (int) getResources().getDimension(
|
||||
R.dimen.task_thumbnail_top_margin);
|
||||
|
||||
Rect lastComputedTaskSize = getRecentsView().getLastComputedTaskSize();
|
||||
int taskWidth = lastComputedTaskSize.width();
|
||||
int taskHeight = lastComputedTaskSize.height();
|
||||
int boxLength = Math.max(taskWidth, taskHeight);
|
||||
float thumbnailRatio = mSnapshotView.getThumbnailRatio();
|
||||
|
||||
int expectedWidth;
|
||||
int expectedHeight;
|
||||
if (thumbnailRatio > 1) {
|
||||
expectedWidth = boxLength;
|
||||
expectedHeight = (int) (boxLength / thumbnailRatio) + thumbnailPadding;
|
||||
} else {
|
||||
expectedWidth = (int) (boxLength * thumbnailRatio);
|
||||
expectedHeight = boxLength + thumbnailPadding;
|
||||
}
|
||||
|
||||
float heightDiff = (expectedHeight - thumbnailPadding - taskHeight) / 2.0f;
|
||||
setBoxTranslationY(heightDiff);
|
||||
|
||||
if (expectedWidth > taskWidth) {
|
||||
// In full screen, expectedWidth should not be larger than taskWidth.
|
||||
mScaleAtFullscreen = taskWidth / (float) expectedWidth;
|
||||
} else if (expectedHeight - thumbnailPadding > taskHeight) {
|
||||
// In full screen, expectedHeight should not be larger than taskHeight.
|
||||
mScaleAtFullscreen = taskHeight / (float) (expectedHeight - thumbnailPadding);
|
||||
} else {
|
||||
mScaleAtFullscreen = 1f;
|
||||
}
|
||||
|
||||
if (params.width != expectedWidth || params.height != expectedHeight) {
|
||||
params.width = expectedWidth;
|
||||
params.height = expectedHeight;
|
||||
setLayoutParams(params);
|
||||
}
|
||||
} else {
|
||||
setBoxTranslationY(0);
|
||||
if (params.width != ViewGroup.LayoutParams.MATCH_PARENT) {
|
||||
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
updateTaskScaling();
|
||||
}
|
||||
|
||||
private void updateTaskScaling() {
|
||||
if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) {
|
||||
ViewGroup.LayoutParams params = getLayoutParams();
|
||||
if (params.width == ViewGroup.LayoutParams.MATCH_PARENT
|
||||
|| params.height == ViewGroup.LayoutParams.MATCH_PARENT) {
|
||||
// Snapshot is not loaded yet, skip.
|
||||
return;
|
||||
}
|
||||
|
||||
float progress = EXAGGERATED_EASE.getInterpolation(mFullscreenProgress);
|
||||
setFullscreenScale(Utilities.mapRange(progress, 1f, mScaleAtFullscreen));
|
||||
|
||||
float widthDiff = params.width * (1 - mFullscreenScale);
|
||||
setFullscreenTranslationX(getFullscreenTrans(
|
||||
getLayoutDirection() == LAYOUT_DIRECTION_RTL ? -widthDiff : widthDiff));
|
||||
} else {
|
||||
setFullscreenScale(1);
|
||||
setFullscreenTranslationX(0);
|
||||
}
|
||||
}
|
||||
|
||||
private float getFullscreenTrans(float endTranslation) {
|
||||
float progress = ACCEL_DEACCEL.getInterpolation(mFullscreenProgress);
|
||||
return Utilities.mapRange(progress, 0, endTranslation);
|
||||
}
|
||||
|
||||
public boolean isRunningTask() {
|
||||
if (getRecentsView() == null) {
|
||||
return false;
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.launcher3;
|
||||
|
||||
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 @@ public class InvariantDeviceProfile {
|
||||
.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 @@ public class InvariantDeviceProfile {
|
||||
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.
|
||||
|
||||
@@ -745,6 +745,11 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
return mOrientationHandler.getChildStart(pageAtIndex);
|
||||
}
|
||||
|
||||
protected int getChildVisibleSize(int index) {
|
||||
View layout = getPageAt(index);
|
||||
return mOrientationHandler.getMeasuredSize(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
|
||||
int page = indexToPage(indexOfChild(child));
|
||||
@@ -1457,8 +1462,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
}
|
||||
|
||||
private int getDisplacementFromScreenCenter(int childIndex, int screenCenter) {
|
||||
View layout = getPageAt(childIndex);
|
||||
int childSize = mOrientationHandler.getMeasuredSize(layout);
|
||||
int childSize = getChildVisibleSize(childIndex);
|
||||
int halfChildSize = (childSize / 2);
|
||||
int childCenter = getChildOffset(childIndex) + halfChildSize;
|
||||
return childCenter - screenCenter;
|
||||
|
||||
@@ -157,7 +157,10 @@ public class LiveSearchManager implements StateListener<LauncherState> {
|
||||
if (finalState.equals(ALL_APPS)) {
|
||||
mLogInstanceId = new InstanceIdSequence().newInstanceId();
|
||||
logger.withInstanceId(mLogInstanceId).log(LAUNCHER_ALLAPPS_ENTRY);
|
||||
} else if (mPrevLauncherState.equals(ALL_APPS)) {
|
||||
} else if (mPrevLauncherState.equals(ALL_APPS)
|
||||
// Check if mLogInstanceId is not null; to avoid NPE when LAUNCHER_ALLAPPS_EXIT is
|
||||
// triggered multiple times
|
||||
&& mLogInstanceId != null) {
|
||||
logger.withInstanceId(mLogInstanceId).log(LAUNCHER_ALLAPPS_EXIT);
|
||||
mLogInstanceId = null;
|
||||
}
|
||||
|
||||
@@ -72,9 +72,6 @@ public final class FeatureFlags {
|
||||
"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 @@ public final class FeatureFlags {
|
||||
"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 @@ public final class FeatureFlags {
|
||||
"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,
|
||||
@@ -214,6 +204,10 @@ public final class FeatureFlags {
|
||||
public static final BooleanFlag ENABLE_TASKBAR = new DeviceFlag(
|
||||
"ENABLE_TASKBAR", false, "Allows a system Taskbar to be shown on larger devices.");
|
||||
|
||||
public static final BooleanFlag ENABLE_OVERVIEW_GRID = new DeviceFlag(
|
||||
"ENABLE_OVERVIEW_GRID", false, "Uses grid overview layout. "
|
||||
+ "Only applicable on large screen devices.");
|
||||
|
||||
public static void initialize(Context context) {
|
||||
synchronized (sDebugFlags) {
|
||||
for (DebugFlag flag : sDebugFlags) {
|
||||
|
||||
@@ -10,7 +10,6 @@ import android.util.Pair;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.util.IOUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -43,7 +42,7 @@ public final class FileLog {
|
||||
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) {
|
||||
|
||||
Reference in new issue
Block a user