From 6e0b00d15ce47892f57bd5c1b9326b90c3450024 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Sun, 27 Dec 2020 15:56:09 -0600 Subject: [PATCH 1/4] Remove Second consumer from AllAppsSearchBarController Bug: 175125073 Test: Manual Change-Id: I34abf0b999e58e034705a1c0696e8fcd88020b28 --- .../allapps/search/AllAppsSearchBarController.java | 4 +--- .../allapps/search/AppsSearchContainerLayout.java | 12 ++---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java index bc5a5f2cf1..9886745417 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java @@ -15,7 +15,6 @@ */ package com.android.launcher3.allapps.search; -import android.os.Bundle; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -37,7 +36,6 @@ import com.android.systemui.plugins.AllAppsSearchPlugin; import com.android.systemui.plugins.shared.SearchTarget; import java.util.ArrayList; -import java.util.List; import java.util.function.Consumer; /** @@ -63,7 +61,7 @@ public class AllAppsSearchBarController */ public final void initialize( SearchAlgorithm searchAlgorithm, ExtendedEditText input, - BaseDraggingActivity launcher, Callbacks cb, Consumer> secondaryCb) { + BaseDraggingActivity launcher, Callbacks cb) { mCb = cb; mLauncher = launcher; diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java index bd2f04d4ee..4f79fb8b6b 100644 --- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java +++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java @@ -24,7 +24,6 @@ import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTO import android.content.Context; import android.graphics.Rect; -import android.os.Bundle; import android.text.Selection; import android.text.SpannableStringBuilder; import android.text.method.TextKeyListener; @@ -50,15 +49,13 @@ import com.android.launcher3.anim.PropertySetter; import com.android.launcher3.config.FeatureFlags; import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; /** * Layout to contain the All-apps search UI. */ public class AppsSearchContainerLayout extends ExtendedEditText implements SearchUiManager, AllAppsSearchBarController.Callbacks, - AllAppsStore.OnUpdateListener, Insettable, Consumer> { + AllAppsStore.OnUpdateListener, Insettable { private final BaseDraggingActivity mLauncher; private final AllAppsSearchBarController mSearchBarController; @@ -141,7 +138,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText mAppsView = appsView; mSearchBarController.initialize( new DefaultAppSearchAlgorithm(mLauncher, LauncherAppState.getInstance(mLauncher)), - this, mLauncher, this, this); + this, mLauncher, this); } @Override @@ -234,9 +231,4 @@ public class AppsSearchContainerLayout extends ExtendedEditText public EditText getEditText() { return this; } - - @Override - public void accept(List bundles) { - // TODO: Render the result on mAppsView object - } } From fd58d23cdffa05d488e3fe65ca1f53b72bc40661 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Tue, 12 Jan 2021 12:59:39 -0600 Subject: [PATCH 2/4] Migrate from Plugin SearchTarget to API search Target [1/3] Setup architecture for separation between aosp and quickstep search as setup for switch to android.app.SearchTarget Bug: 177223401 Test: manual Change-Id: Iefd069a34d5e5551bf731e9171958e93377774aa --- .../res}/layout/search_result_icon.xml | 2 +- .../res}/layout/search_result_icon_row.xml | 6 +- .../res}/layout/search_result_people_item.xml | 4 +- .../res}/layout/search_result_play_item.xml | 4 +- .../layout/search_result_settings_row.xml | 4 +- .../res}/layout/search_result_slice.xml | 4 +- .../res}/layout/search_result_suggest.xml | 4 +- .../res}/layout/search_result_thumbnail.xml | 2 +- .../res}/layout/search_result_widget_live.xml | 2 +- .../layout/search_result_widget_preview.xml | 4 +- .../res}/layout/search_section_title.xml | 2 +- .../search/DeviceSearchAdapterProvider.java | 110 +++++++++++++++ .../launcher3/search/SearchAdapterItem.java | 59 +++++++++ .../launcher3}/search/SearchEventTracker.java | 3 +- .../launcher3/search}/SearchResultIcon.java | 6 +- .../search}/SearchResultIconRow.java | 6 +- .../search}/SearchResultPeopleView.java | 6 +- .../search}/SearchResultPlayItem.java | 6 +- .../search}/SearchResultSettingsSlice.java | 6 +- .../search}/SearchResultSuggestion.java | 3 +- .../launcher3/search}/SearchResultWidget.java | 6 +- .../search}/SearchResultWidgetPreview.java | 6 +- .../search}/SearchSectionHeaderView.java | 5 +- .../search}/SearchSettingsRowView.java | 6 +- .../launcher3/search/SearchTargetHandler.java | 37 ++++++ .../search}/ThumbnailSearchResultView.java | 10 +- .../uioverrides/QuickstepLauncher.java | 7 + .../android/quickstep/RecentsActivity.java | 2 + .../launcher3/BaseDraggingActivity.java | 12 +- .../allapps/AllAppsContainerView.java | 15 ++- .../launcher3/allapps/AllAppsGridAdapter.java | 125 +++--------------- .../allapps/AllAppsRecyclerView.java | 1 - .../search/AllAppsSearchBarController.java | 19 --- .../search/DefaultSearchAdapterProvider.java | 53 ++++++++ .../allapps/search/SearchAdapterProvider.java | 65 +++++++++ 35 files changed, 413 insertions(+), 199 deletions(-) rename {res => quickstep/res}/layout/search_result_icon.xml (88%) rename {res => quickstep/res}/layout/search_result_icon_row.xml (93%) rename {res => quickstep/res}/layout/search_result_people_item.xml (93%) rename {res => quickstep/res}/layout/search_result_play_item.xml (94%) rename {res => quickstep/res}/layout/search_result_settings_row.xml (93%) rename {res => quickstep/res}/layout/search_result_slice.xml (89%) rename {res => quickstep/res}/layout/search_result_suggest.xml (89%) rename {res => quickstep/res}/layout/search_result_thumbnail.xml (93%) rename {res => quickstep/res}/layout/search_result_widget_live.xml (66%) rename {res => quickstep/res}/layout/search_result_widget_preview.xml (64%) rename {res => quickstep/res}/layout/search_section_title.xml (89%) create mode 100644 quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java create mode 100644 quickstep/src/com/android/launcher3/search/SearchAdapterItem.java rename {src/com/android/launcher3/allapps => quickstep/src/com/android/launcher3}/search/SearchEventTracker.java (95%) rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/SearchResultIcon.java (97%) rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/SearchResultIconRow.java (96%) rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/SearchResultPeopleView.java (97%) rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/SearchResultPlayItem.java (97%) rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/SearchResultSettingsSlice.java (93%) rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/SearchResultSuggestion.java (95%) rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/SearchResultWidget.java (96%) rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/SearchResultWidgetPreview.java (95%) rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/SearchSectionHeaderView.java (91%) rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/SearchSettingsRowView.java (95%) create mode 100644 quickstep/src/com/android/launcher3/search/SearchTargetHandler.java rename {src/com/android/launcher3/views => quickstep/src/com/android/launcher3/search}/ThumbnailSearchResultView.java (91%) create mode 100644 src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java create mode 100644 src/com/android/launcher3/allapps/search/SearchAdapterProvider.java diff --git a/res/layout/search_result_icon.xml b/quickstep/res/layout/search_result_icon.xml similarity index 88% rename from res/layout/search_result_icon.xml rename to quickstep/res/layout/search_result_icon.xml index 3c1dd49109..e1b6dfd371 100644 --- a/res/layout/search_result_icon.xml +++ b/quickstep/res/layout/search_result_icon.xml @@ -13,7 +13,7 @@ limitations under the License. --> - diff --git a/res/layout/search_result_icon_row.xml b/quickstep/res/layout/search_result_icon_row.xml similarity index 93% rename from res/layout/search_result_icon_row.xml rename to quickstep/res/layout/search_result_icon_row.xml index 81c23e4c90..1393b87d58 100644 --- a/res/layout/search_result_icon_row.xml +++ b/quickstep/res/layout/search_result_icon_row.xml @@ -12,14 +12,14 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - \ No newline at end of file + \ No newline at end of file diff --git a/res/layout/search_result_people_item.xml b/quickstep/res/layout/search_result_people_item.xml similarity index 93% rename from res/layout/search_result_people_item.xml rename to quickstep/res/layout/search_result_people_item.xml index 7526f6f10f..964300dd20 100644 --- a/res/layout/search_result_people_item.xml +++ b/quickstep/res/layout/search_result_people_item.xml @@ -12,7 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - - \ No newline at end of file + \ No newline at end of file diff --git a/res/layout/search_result_play_item.xml b/quickstep/res/layout/search_result_play_item.xml similarity index 94% rename from res/layout/search_result_play_item.xml rename to quickstep/res/layout/search_result_play_item.xml index d70c56a1de..ecd67b104a 100644 --- a/res/layout/search_result_play_item.xml +++ b/quickstep/res/layout/search_result_play_item.xml @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - - + diff --git a/res/layout/search_result_settings_row.xml b/quickstep/res/layout/search_result_settings_row.xml similarity index 93% rename from res/layout/search_result_settings_row.xml rename to quickstep/res/layout/search_result_settings_row.xml index 22c08bf58f..33c9592d1c 100644 --- a/res/layout/search_result_settings_row.xml +++ b/quickstep/res/layout/search_result_settings_row.xml @@ -12,7 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - - \ No newline at end of file + \ No newline at end of file diff --git a/res/layout/search_result_slice.xml b/quickstep/res/layout/search_result_slice.xml similarity index 89% rename from res/layout/search_result_slice.xml rename to quickstep/res/layout/search_result_slice.xml index 24d75e9eb6..f7dcfce0ee 100644 --- a/res/layout/search_result_slice.xml +++ b/quickstep/res/layout/search_result_slice.xml @@ -12,7 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - @@ -36,5 +36,5 @@ android:layout_marginStart="@dimen/dynamic_grid_cell_padding_x" android:layout_width="0dp" /> - + diff --git a/res/layout/search_result_suggest.xml b/quickstep/res/layout/search_result_suggest.xml similarity index 89% rename from res/layout/search_result_suggest.xml rename to quickstep/res/layout/search_result_suggest.xml index 01e25d5893..eb5313c36b 100644 --- a/res/layout/search_result_suggest.xml +++ b/quickstep/res/layout/search_result_suggest.xml @@ -12,7 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - - \ No newline at end of file + \ No newline at end of file diff --git a/res/layout/search_result_thumbnail.xml b/quickstep/res/layout/search_result_thumbnail.xml similarity index 93% rename from res/layout/search_result_thumbnail.xml rename to quickstep/res/layout/search_result_thumbnail.xml index 0cc5a29f60..0f253360f0 100644 --- a/res/layout/search_result_thumbnail.xml +++ b/quickstep/res/layout/search_result_thumbnail.xml @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - \ No newline at end of file diff --git a/res/layout/search_result_widget_live.xml b/quickstep/res/layout/search_result_widget_live.xml similarity index 66% rename from res/layout/search_result_widget_live.xml rename to quickstep/res/layout/search_result_widget_live.xml index 0dd8a06c9a..ffbad55838 100644 --- a/res/layout/search_result_widget_live.xml +++ b/quickstep/res/layout/search_result_widget_live.xml @@ -1,5 +1,5 @@ - \ No newline at end of file diff --git a/res/layout/search_result_widget_preview.xml b/quickstep/res/layout/search_result_widget_preview.xml similarity index 64% rename from res/layout/search_result_widget_preview.xml rename to quickstep/res/layout/search_result_widget_preview.xml index 942b199b7f..7af24a136d 100644 --- a/res/layout/search_result_widget_preview.xml +++ b/quickstep/res/layout/search_result_widget_preview.xml @@ -1,8 +1,8 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/res/layout/search_section_title.xml b/quickstep/res/layout/search_section_title.xml similarity index 89% rename from res/layout/search_section_title.xml rename to quickstep/res/layout/search_section_title.xml index b7ba83e71b..5842e574fc 100644 --- a/res/layout/search_section_title.xml +++ b/quickstep/res/layout/search_section_title.xml @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - { public static final int MAX_SHORTCUTS_COUNT = 2; diff --git a/src/com/android/launcher3/views/SearchResultPeopleView.java b/quickstep/src/com/android/launcher3/search/SearchResultPeopleView.java similarity index 97% rename from src/com/android/launcher3/views/SearchResultPeopleView.java rename to quickstep/src/com/android/launcher3/search/SearchResultPeopleView.java index e499bd5b66..e856531ee4 100644 --- a/src/com/android/launcher3/views/SearchResultPeopleView.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultPeopleView.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.views; +package com.android.launcher3.search; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; @@ -42,8 +42,6 @@ import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.R; -import com.android.launcher3.allapps.search.AllAppsSearchBarController; -import com.android.launcher3.allapps.search.SearchEventTracker; import com.android.launcher3.icons.BitmapInfo; import com.android.launcher3.icons.LauncherIcons; import com.android.systemui.plugins.shared.SearchTarget; @@ -55,7 +53,7 @@ import java.util.ArrayList; * A view representing a single people search result in all apps */ public class SearchResultPeopleView extends LinearLayout implements - AllAppsSearchBarController.SearchTargetHandler { + SearchTargetHandler { public static final String TARGET_TYPE_PEOPLE = "people"; diff --git a/src/com/android/launcher3/views/SearchResultPlayItem.java b/quickstep/src/com/android/launcher3/search/SearchResultPlayItem.java similarity index 97% rename from src/com/android/launcher3/views/SearchResultPlayItem.java rename to quickstep/src/com/android/launcher3/search/SearchResultPlayItem.java index 86ed436f53..33c933077b 100644 --- a/src/com/android/launcher3/views/SearchResultPlayItem.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultPlayItem.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.views; +package com.android.launcher3.search; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; @@ -41,8 +41,6 @@ import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.R; -import com.android.launcher3.allapps.search.AllAppsSearchBarController; -import com.android.launcher3.allapps.search.SearchEventTracker; import com.android.launcher3.icons.BitmapRenderer; import com.android.launcher3.util.Themes; import com.android.systemui.plugins.shared.SearchTarget; @@ -56,7 +54,7 @@ import java.net.URLConnection; * A View representing a PlayStore item. */ public class SearchResultPlayItem extends LinearLayout implements - AllAppsSearchBarController.SearchTargetHandler { + SearchTargetHandler { public static final String TARGET_TYPE_PLAY = "play"; diff --git a/src/com/android/launcher3/views/SearchResultSettingsSlice.java b/quickstep/src/com/android/launcher3/search/SearchResultSettingsSlice.java similarity index 93% rename from src/com/android/launcher3/views/SearchResultSettingsSlice.java rename to quickstep/src/com/android/launcher3/search/SearchResultSettingsSlice.java index 29e6c1b8cf..826b653989 100644 --- a/src/com/android/launcher3/views/SearchResultSettingsSlice.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultSettingsSlice.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.views; +package com.android.launcher3.search; import android.content.Context; import android.net.Uri; @@ -32,8 +32,6 @@ import androidx.slice.widget.SliceView; import com.android.launcher3.Launcher; import com.android.launcher3.R; -import com.android.launcher3.allapps.search.AllAppsSearchBarController; -import com.android.launcher3.allapps.search.SearchEventTracker; import com.android.systemui.plugins.shared.SearchTarget; import com.android.systemui.plugins.shared.SearchTargetEvent; @@ -41,7 +39,7 @@ import com.android.systemui.plugins.shared.SearchTargetEvent; * A slice view wrapper with settings app icon at start */ public class SearchResultSettingsSlice extends LinearLayout implements - AllAppsSearchBarController.SearchTargetHandler, SliceView.OnSliceActionListener { + SearchTargetHandler, SliceView.OnSliceActionListener { public static final String TARGET_TYPE_SLICE = "settings_slice"; diff --git a/src/com/android/launcher3/views/SearchResultSuggestion.java b/quickstep/src/com/android/launcher3/search/SearchResultSuggestion.java similarity index 95% rename from src/com/android/launcher3/views/SearchResultSuggestion.java rename to quickstep/src/com/android/launcher3/search/SearchResultSuggestion.java index c67b1cf7f3..6a6bd1b14a 100644 --- a/src/com/android/launcher3/views/SearchResultSuggestion.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultSuggestion.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.views; +package com.android.launcher3.search; import android.content.Context; import android.content.res.TypedArray; @@ -22,6 +22,7 @@ import android.util.AttributeSet; import android.view.ViewGroup; import com.android.launcher3.R; +import com.android.launcher3.views.BaseDragLayer; /** * {@link SearchResultIconRow} with custom drawable resource diff --git a/src/com/android/launcher3/views/SearchResultWidget.java b/quickstep/src/com/android/launcher3/search/SearchResultWidget.java similarity index 96% rename from src/com/android/launcher3/views/SearchResultWidget.java rename to quickstep/src/com/android/launcher3/search/SearchResultWidget.java index f76de3d2cf..ba26d852e7 100644 --- a/src/com/android/launcher3/views/SearchResultWidget.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultWidget.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.views; +package com.android.launcher3.search; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetProviderInfo; @@ -32,8 +32,6 @@ import com.android.launcher3.AppWidgetResizeFrame; import com.android.launcher3.CheckLongPressHelper; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; -import com.android.launcher3.allapps.search.AllAppsSearchBarController; -import com.android.launcher3.allapps.search.SearchEventTracker; import com.android.launcher3.allapps.search.SearchWidgetInfoContainer; import com.android.launcher3.dragndrop.DraggableView; import com.android.launcher3.touch.ItemLongClickListener; @@ -46,7 +44,7 @@ import com.android.systemui.plugins.shared.SearchTargetEvent; * provider */ public class SearchResultWidget extends RelativeLayout implements - AllAppsSearchBarController.SearchTargetHandler, DraggableView, View.OnLongClickListener { + SearchTargetHandler, DraggableView, View.OnLongClickListener { private static final String TAG = "SearchResultWidget"; diff --git a/src/com/android/launcher3/views/SearchResultWidgetPreview.java b/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java similarity index 95% rename from src/com/android/launcher3/views/SearchResultWidgetPreview.java rename to quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java index c11c232307..0d790252de 100644 --- a/src/com/android/launcher3/views/SearchResultWidgetPreview.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.views; +package com.android.launcher3.search; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; @@ -32,8 +32,6 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherAppWidgetProviderInfo; import com.android.launcher3.R; -import com.android.launcher3.allapps.search.AllAppsSearchBarController; -import com.android.launcher3.allapps.search.SearchEventTracker; import com.android.launcher3.dragndrop.DragOptions; import com.android.launcher3.model.WidgetItem; import com.android.launcher3.touch.ItemLongClickListener; @@ -48,7 +46,7 @@ import com.android.systemui.plugins.shared.SearchTargetEvent; * displays preview of a widget upon receiving {@link AppWidgetProviderInfo} from Search provider */ public class SearchResultWidgetPreview extends LinearLayout implements - AllAppsSearchBarController.SearchTargetHandler, View.OnLongClickListener, + SearchTargetHandler, View.OnLongClickListener, View.OnClickListener { public static final String TARGET_TYPE_WIDGET_PREVIEW = "widget_preview"; diff --git a/src/com/android/launcher3/views/SearchSectionHeaderView.java b/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java similarity index 91% rename from src/com/android/launcher3/views/SearchSectionHeaderView.java rename to quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java index 326c23d1dc..a552366d1c 100644 --- a/src/com/android/launcher3/views/SearchSectionHeaderView.java +++ b/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.views; +package com.android.launcher3.search; import android.content.Context; import android.util.AttributeSet; @@ -21,14 +21,13 @@ import android.widget.TextView; import androidx.annotation.Nullable; -import com.android.launcher3.allapps.search.AllAppsSearchBarController; import com.android.systemui.plugins.shared.SearchTarget; /** * Header text view that shows a title for a given section in All apps search */ public class SearchSectionHeaderView extends TextView implements - AllAppsSearchBarController.SearchTargetHandler { + SearchTargetHandler { public static final String TARGET_TYPE_SECTION_HEADER = "section_header"; public SearchSectionHeaderView(Context context) { diff --git a/src/com/android/launcher3/views/SearchSettingsRowView.java b/quickstep/src/com/android/launcher3/search/SearchSettingsRowView.java similarity index 95% rename from src/com/android/launcher3/views/SearchSettingsRowView.java rename to quickstep/src/com/android/launcher3/search/SearchSettingsRowView.java index 160ee6514b..dc5c2f183e 100644 --- a/src/com/android/launcher3/views/SearchSettingsRowView.java +++ b/quickstep/src/com/android/launcher3/search/SearchSettingsRowView.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.views; +package com.android.launcher3.search; import static com.android.launcher3.FastBitmapDrawable.newIcon; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; @@ -37,8 +37,6 @@ import com.android.launcher3.FastBitmapDrawable; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; -import com.android.launcher3.allapps.search.AllAppsSearchBarController; -import com.android.launcher3.allapps.search.SearchEventTracker; import com.android.launcher3.model.data.PackageItemInfo; import com.android.systemui.plugins.shared.SearchTarget; import com.android.systemui.plugins.shared.SearchTargetEvent; @@ -50,7 +48,7 @@ import java.util.List; * A row of clickable TextViews with a breadcrumb for settings search. */ public class SearchSettingsRowView extends LinearLayout implements - View.OnClickListener, AllAppsSearchBarController.SearchTargetHandler { + View.OnClickListener, SearchTargetHandler { public static final String TARGET_TYPE_SETTINGS_ROW = "settings_row"; diff --git a/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java b/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java new file mode 100644 index 0000000000..347c7d46fc --- /dev/null +++ b/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java @@ -0,0 +1,37 @@ +/* + * 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 com.android.systemui.plugins.shared.SearchTarget; + +/** + * An interface for supporting dynamic search results + */ +public interface SearchTargetHandler { + + /** + * Update view using values from {@link SearchTarget} + */ + void applySearchTarget(SearchTarget searchTarget); + + /** + * Handles selection of SearchTarget + */ + default void handleSelection(int eventType) { + } + +} diff --git a/src/com/android/launcher3/views/ThumbnailSearchResultView.java b/quickstep/src/com/android/launcher3/search/ThumbnailSearchResultView.java similarity index 91% rename from src/com/android/launcher3/views/ThumbnailSearchResultView.java rename to quickstep/src/com/android/launcher3/search/ThumbnailSearchResultView.java index 573d48f799..c100d6ad32 100644 --- a/src/com/android/launcher3/views/ThumbnailSearchResultView.java +++ b/quickstep/src/com/android/launcher3/search/ThumbnailSearchResultView.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.launcher3.views; +package com.android.launcher3.search; -import static com.android.launcher3.views.SearchResultIcon.REMOTE_ACTION_SHOULD_START; -import static com.android.launcher3.views.SearchResultIcon.REMOTE_ACTION_TOKEN; +import static com.android.launcher3.search.SearchResultIcon.REMOTE_ACTION_SHOULD_START; +import static com.android.launcher3.search.SearchResultIcon.REMOTE_ACTION_TOKEN; import android.content.Context; import android.content.Intent; @@ -30,8 +30,6 @@ import androidx.core.graphics.drawable.RoundedBitmapDrawable; import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory; import com.android.launcher3.Launcher; -import com.android.launcher3.allapps.search.AllAppsSearchBarController; -import com.android.launcher3.allapps.search.SearchEventTracker; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.RemoteActionItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; @@ -44,7 +42,7 @@ import com.android.systemui.plugins.shared.SearchTargetEvent; * A view representing a high confidence app search result that includes shortcuts */ public class ThumbnailSearchResultView extends androidx.appcompat.widget.AppCompatImageView - implements AllAppsSearchBarController.SearchTargetHandler { + implements SearchTargetHandler { public static final String TARGET_TYPE_SCREENSHOT = "screenshot"; public static final String TARGET_TYPE_SCREENSHOT_LEGACY = "screenshot_legacy"; diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 8c3b57abc9..d345165e78 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -42,6 +42,7 @@ 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.search.SearchAdapterProvider; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.appprediction.PredictionRowView; import com.android.launcher3.config.FeatureFlags; @@ -51,6 +52,7 @@ import com.android.launcher3.logging.StatsLogManager.StatsLogger; import com.android.launcher3.model.BgDataModel.FixedContainerItems; import com.android.launcher3.model.data.ItemInfo; 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; @@ -263,6 +265,11 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { } } + @Override + public SearchAdapterProvider createSearchAdapterProvider() { + return new DeviceSearchAdapterProvider(this); + } + @Override public TouchController[] createTouchControllers() { Mode mode = SysUINavigationMode.getMode(this); diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index d050030e74..c37fd84516 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -45,6 +45,7 @@ import com.android.launcher3.LauncherAnimationRunner.AnimationResult; import com.android.launcher3.R; import com.android.launcher3.WrappedAnimationRunnerImpl; import com.android.launcher3.WrappedLauncherAnimationRunner; +import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.compat.AccessibilityManagerCompat; @@ -91,6 +92,7 @@ public final class RecentsActivity extends StatefulActivity { // Strong refs to runners which are cleared when the activity is destroyed private WrappedAnimationRunnerImpl mActivityLaunchAnimationRunner; + private SearchAdapterProvider mSearchAdapterProvider; /** * Init drag layer and overview panel views. diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index 52f0a4a612..33af4d7983 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -43,6 +43,8 @@ import android.widget.Toast; import androidx.annotation.Nullable; import com.android.launcher3.LauncherSettings.Favorites; +import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider; +import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.logging.InstanceId; import com.android.launcher3.logging.InstanceIdSequence; import com.android.launcher3.model.data.ItemInfo; @@ -187,7 +189,7 @@ public abstract class BaseDraggingActivity extends BaseActivity logAppLaunch(item, instanceId); } return true; - } catch (NullPointerException|ActivityNotFoundException|SecurityException e) { + } catch (NullPointerException | ActivityNotFoundException | SecurityException e) { Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Unable to launch. tag=" + item + " intent=" + intent, e); } @@ -290,4 +292,12 @@ public abstract class BaseDraggingActivity extends BaseActivity display.getSize(mwSize); return new WindowBounds(new Rect(0, 0, mwSize.x, mwSize.y), new Rect()); } + + /** + * Creates and returns {@link SearchAdapterProvider} for build variant specific search result + * views + */ + public SearchAdapterProvider createSearchAdapterProvider() { + return new DefaultSearchAdapterProvider(this); + } } diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 558c6a81a5..b016df189b 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -16,7 +16,6 @@ package com.android.launcher3.allapps; import static com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem; -import static com.android.launcher3.allapps.AllAppsGridAdapter.SearchAdapterItem; import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION; import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_CHANGE_PERMISSION; import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_ENABLED; @@ -57,7 +56,7 @@ import com.android.launcher3.Insettable; import com.android.launcher3.InsettableFrameLayout; import com.android.launcher3.R; import com.android.launcher3.Utilities; -import com.android.launcher3.allapps.search.SearchEventTracker; +import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.keyboard.FocusedItemDecorator; import com.android.launcher3.model.data.AppInfo; @@ -68,7 +67,6 @@ import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.launcher3.util.Themes; import com.android.launcher3.views.RecyclerViewFastScroller; import com.android.launcher3.views.SpringRelativeLayout; -import com.android.systemui.plugins.shared.SearchTarget; /** * The all apps view container. @@ -110,6 +108,8 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo private Rect mInsets = new Rect(); + SearchAdapterProvider mSearchAdapterProvider; + public AllAppsContainerView(Context context) { this(context, null); } @@ -124,6 +124,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo mLauncher = BaseDraggingActivity.fromContext(context); mLauncher.addOnDeviceProfileChangeListener(this); + mSearchAdapterProvider = mLauncher.createSearchAdapterProvider(); mSearchQueryBuilder = new SpannableStringBuilder(); Selection.setSelection(mSearchQueryBuilder, 0); @@ -141,6 +142,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo addSpringView(R.id.all_apps_tabs_view_pager); mMultiValueAlpha = new MultiValueAlpha(this, ALPHA_CHANNEL_COUNT); + } /** @@ -545,9 +547,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo return mLauncher.startActivitySafely(v, headerItem.getIntent(), headerItem); } AdapterItem focusedItem = getActiveRecyclerView().getApps().getFocusedChild(); - if (focusedItem instanceof SearchAdapterItem) { - SearchTarget searchTarget = ((SearchAdapterItem) focusedItem).getSearchTarget(); - SearchEventTracker.INSTANCE.get(getContext()).quickSelect(searchTarget); + if (mSearchAdapterProvider.onAdapterItemSelected(focusedItem)) { return true; } if (focusedItem.appInfo != null) { @@ -677,7 +677,8 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo AdapterHolder(boolean isWork) { mIsWork = isWork; appsList = new AlphabeticalAppsList(mLauncher, mAllAppsStore, isWork); - adapter = new AllAppsGridAdapter(mLauncher, getLayoutInflater(), appsList); + adapter = new AllAppsGridAdapter(mLauncher, getLayoutInflater(), appsList, + mSearchAdapterProvider); appsList.setAdapter(adapter); layoutManager = adapter.getLayoutManager(); } diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index 3c88288160..715c142ac9 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -41,13 +41,11 @@ import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.BubbleTextView; import com.android.launcher3.R; -import com.android.launcher3.allapps.search.AllAppsSearchBarController.SearchTargetHandler; +import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.allapps.search.SearchSectionInfo; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.util.PackageManagerHelper; -import com.android.launcher3.views.SearchResultWidget; -import com.android.systemui.plugins.shared.SearchTarget; import java.util.List; @@ -72,31 +70,11 @@ public class AllAppsGridAdapter extends // A divider that separates the apps list and the search market button public static final int VIEW_TYPE_ALL_APPS_DIVIDER = 1 << 4; - public static final int VIEW_TYPE_SEARCH_CORPUS_TITLE = 1 << 5; - - public static final int VIEW_TYPE_SEARCH_ROW_WITH_BUTTON = 1 << 7; - - public static final int VIEW_TYPE_SEARCH_ROW = 1 << 8; - - public static final int VIEW_TYPE_SEARCH_SLICE = 1 << 9; - - public static final int VIEW_TYPE_SEARCH_ICON_ROW = 1 << 10; - - public static final int VIEW_TYPE_SEARCH_PEOPLE = 1 << 11; - - public static final int VIEW_TYPE_SEARCH_THUMBNAIL = 1 << 12; - - public static final int VIEW_TYPE_SEARCH_SUGGEST = 1 << 13; - - public static final int VIEW_TYPE_SEARCH_ICON = 1 << 14; - - public static final int VIEW_TYPE_SEARCH_WIDGET_LIVE = 1 << 15; - - public static final int VIEW_TYPE_SEARCH_WIDGET_PREVIEW = 1 << 16; - // Common view type masks public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER; - public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON | VIEW_TYPE_SEARCH_ICON; + public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON; + + private final SearchAdapterProvider mSearchAdapterProvider; /** * ViewHolder for each icon. @@ -177,32 +155,8 @@ public class AllAppsGridAdapter extends return item; } - boolean isCountedForAccessibility() { - return viewType == VIEW_TYPE_ICON - || viewType == VIEW_TYPE_SEARCH_ROW_WITH_BUTTON - || viewType == VIEW_TYPE_SEARCH_SLICE - || viewType == VIEW_TYPE_SEARCH_ROW - || viewType == VIEW_TYPE_SEARCH_PEOPLE - || viewType == VIEW_TYPE_SEARCH_THUMBNAIL - || viewType == VIEW_TYPE_SEARCH_ICON_ROW - || viewType == VIEW_TYPE_SEARCH_ICON - || viewType == VIEW_TYPE_SEARCH_SUGGEST; - } - } - - /** - * Extension of AdapterItem that contains an extra payload specific to item - */ - public static class SearchAdapterItem extends AdapterItem { - private SearchTarget mSearchTarget; - - public SearchAdapterItem(SearchTarget searchTarget, int type) { - mSearchTarget = searchTarget; - viewType = type; - } - - public SearchTarget getSearchTarget() { - return mSearchTarget; + protected boolean isCountedForAccessibility() { + return viewType == VIEW_TYPE_ICON || viewType == VIEW_TYPE_SEARCH_MARKET; } } @@ -289,9 +243,8 @@ public class AllAppsGridAdapter extends int viewType = mApps.getAdapterItems().get(position).viewType; if (isIconViewType(viewType)) { return 1 * SPAN_MULTIPLIER; - } else if (viewType == VIEW_TYPE_SEARCH_THUMBNAIL - || viewType == VIEW_TYPE_SEARCH_WIDGET_PREVIEW) { - return mAppsPerRow; + } else if (mSearchAdapterProvider.isSearchView(viewType)) { + return mSearchAdapterProvider.getGridSpanSize(viewType, mAppsPerRow); } else { // Section breaks span the full width return mAppsPerRow * SPAN_MULTIPLIER; @@ -321,7 +274,7 @@ public class AllAppsGridAdapter extends private Intent mMarketSearchIntent; public AllAppsGridAdapter(BaseDraggingActivity launcher, LayoutInflater inflater, - AlphabeticalAppsList apps) { + AlphabeticalAppsList apps, SearchAdapterProvider searchAdapterProvider) { Resources res = launcher.getResources(); mLauncher = launcher; mApps = apps; @@ -334,6 +287,8 @@ public class AllAppsGridAdapter extends mOnIconClickListener = launcher.getItemOnClickListener(); setAppsPerRow(mLauncher.getDeviceProfile().inv.numAllAppsColumns); + + mSearchAdapterProvider = searchAdapterProvider; } public void setAppsPerRow(int appsPerRow) { @@ -406,40 +361,11 @@ public class AllAppsGridAdapter extends case VIEW_TYPE_ALL_APPS_DIVIDER: return new ViewHolder(mLayoutInflater.inflate( R.layout.all_apps_divider, parent, false)); - case VIEW_TYPE_SEARCH_ICON: - return new ViewHolder(mLayoutInflater.inflate( - R.layout.search_result_icon, parent, false)); - case VIEW_TYPE_SEARCH_CORPUS_TITLE: - return new ViewHolder( - mLayoutInflater.inflate(R.layout.search_section_title, parent, false)); - case VIEW_TYPE_SEARCH_ROW_WITH_BUTTON: - return new ViewHolder(mLayoutInflater.inflate( - R.layout.search_result_play_item, parent, false)); - case VIEW_TYPE_SEARCH_ROW: - return new ViewHolder(mLayoutInflater.inflate( - R.layout.search_result_settings_row, parent, false)); - case VIEW_TYPE_SEARCH_SLICE: - return new ViewHolder(mLayoutInflater.inflate( - R.layout.search_result_slice, parent, false)); - case VIEW_TYPE_SEARCH_ICON_ROW: - return new ViewHolder(mLayoutInflater.inflate( - R.layout.search_result_icon_row, parent, false)); - case VIEW_TYPE_SEARCH_PEOPLE: - return new ViewHolder(mLayoutInflater.inflate( - R.layout.search_result_people_item, parent, false)); - case VIEW_TYPE_SEARCH_THUMBNAIL: - return new ViewHolder(mLayoutInflater.inflate( - R.layout.search_result_thumbnail, parent, false)); - case VIEW_TYPE_SEARCH_SUGGEST: - return new ViewHolder(mLayoutInflater.inflate( - R.layout.search_result_suggest, parent, false)); - case VIEW_TYPE_SEARCH_WIDGET_LIVE: - return new ViewHolder(mLayoutInflater.inflate( - R.layout.search_result_widget_live, parent, false)); - case VIEW_TYPE_SEARCH_WIDGET_PREVIEW: - return new ViewHolder(mLayoutInflater.inflate( - R.layout.search_result_widget_preview, parent, false)); default: + if (mSearchAdapterProvider.isSearchView(viewType)) { + return mSearchAdapterProvider.onCreateViewHolder(mLayoutInflater, parent, + viewType); + } throw new RuntimeException("Unexpected view type"); } } @@ -472,25 +398,11 @@ public class AllAppsGridAdapter extends searchView.setVisibility(View.GONE); } break; - case VIEW_TYPE_SEARCH_CORPUS_TITLE: - case VIEW_TYPE_SEARCH_ROW_WITH_BUTTON: - case VIEW_TYPE_SEARCH_SLICE: - case VIEW_TYPE_SEARCH_ROW: - case VIEW_TYPE_SEARCH_ICON: - case VIEW_TYPE_SEARCH_ICON_ROW: - case VIEW_TYPE_SEARCH_PEOPLE: - case VIEW_TYPE_SEARCH_THUMBNAIL: - case VIEW_TYPE_SEARCH_SUGGEST: - case VIEW_TYPE_SEARCH_WIDGET_LIVE: - case VIEW_TYPE_SEARCH_WIDGET_PREVIEW: - SearchAdapterItem item = - (SearchAdapterItem) mApps.getAdapterItems().get(position); - SearchTargetHandler payloadResultView = (SearchTargetHandler) holder.itemView; - payloadResultView.applySearchTarget(item.getSearchTarget()); - break; case VIEW_TYPE_ALL_APPS_DIVIDER: // nothing to do break; + default: + mSearchAdapterProvider.onBindView(holder, position); } } @@ -501,9 +413,6 @@ public class AllAppsGridAdapter extends if (holder.itemView instanceof AllAppsSectionDecorator.SelfDecoratingView) { ((AllAppsSectionDecorator.SelfDecoratingView) holder.itemView).removeDecoration(); } - if (holder.itemView instanceof SearchResultWidget) { - ((SearchResultWidget) holder.itemView).removeListener(); - } } @Override diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 1fa43d00e2..e61b95d070 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -104,7 +104,6 @@ public class AllAppsRecyclerView extends BaseRecyclerView { pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER, 1); pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET, 1); pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ICON, approxRows * mNumAppsPerRow); - pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_CORPUS_TITLE, 1); mViewHeights.clear(); mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_ICON, grid.allAppsCellHeightPx); diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java index bc5a5f2cf1..f09f1cabd0 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java @@ -34,7 +34,6 @@ import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.PackageManagerHelper; import com.android.systemui.plugins.AllAppsSearchPlugin; -import com.android.systemui.plugins.shared.SearchTarget; import java.util.ArrayList; import java.util.List; @@ -211,23 +210,5 @@ public class AllAppsSearchBarController void clearSearchResult(); } - /** - * An interface for supporting dynamic search results - */ - public interface SearchTargetHandler { - - /** - * Update view using values from {@link SearchTarget} - */ - void applySearchTarget(SearchTarget searchTarget); - - /** - * Handles selection of SearchTarget - */ - default void handleSelection(int eventType) { - } - - } - } \ No newline at end of file diff --git a/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java b/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java new file mode 100644 index 0000000000..e3c178b937 --- /dev/null +++ b/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java @@ -0,0 +1,53 @@ +/* + * 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.allapps.search; + +import android.view.LayoutInflater; +import android.view.ViewGroup; + +import com.android.launcher3.BaseDraggingActivity; +import com.android.launcher3.allapps.AllAppsGridAdapter; + +/** + * Provides views for local search results + */ +public class DefaultSearchAdapterProvider extends SearchAdapterProvider { + + public DefaultSearchAdapterProvider(BaseDraggingActivity launcher) { + super(launcher); + } + + @Override + public void onBindView(AllAppsGridAdapter.ViewHolder holder, int position) { + + } + + @Override + public boolean isSearchView(int viewType) { + return false; + } + + @Override + public AllAppsGridAdapter.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater, + ViewGroup parent, int viewType) { + return null; + } + + @Override + public boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem focusedItem) { + return false; + } +} diff --git a/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java b/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java new file mode 100644 index 0000000000..1c7247aadb --- /dev/null +++ b/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java @@ -0,0 +1,65 @@ +/* + * 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.allapps.search; + + +import android.view.LayoutInflater; +import android.view.ViewGroup; + +import com.android.launcher3.BaseDraggingActivity; +import com.android.launcher3.allapps.AllAppsGridAdapter; + +/** + * A UI expansion wrapper providing for search results + */ +public abstract class SearchAdapterProvider { + + protected final BaseDraggingActivity mLauncher; + + public SearchAdapterProvider(BaseDraggingActivity launcher) { + mLauncher = launcher; + } + + /** + * Called from RecyclerView.Adapter#onBindViewHolder + */ + public abstract void onBindView(AllAppsGridAdapter.ViewHolder holder, int position); + + /** + * Returns whether or not viewType can be handled by searchProvider + */ + public abstract boolean isSearchView(int viewType); + + /** + * Called from RecyclerView.Adapter#onCreateViewHolder + */ + public abstract AllAppsGridAdapter.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater, + ViewGroup parent, int viewType); + + /** + * Returns how many cells a view should span + */ + public int getGridSpanSize(int viewType, int appsPerRow) { + return appsPerRow * AllAppsGridAdapter.SPAN_MULTIPLIER; + } + + /** + * handles selection event on search adapter item. Returns false if provider can not handle + * event + */ + public abstract boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem focusedItem); +} From a5f289a6059a6655ec5fb2406ec8c4f4f7caf665 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Wed, 13 Jan 2021 10:26:00 -0600 Subject: [PATCH 3/4] Increase timeout and additional logs for WorkTabTest#testWorkEduFlow Bug: 159671700 Test: WorkTabTest#testWorkEduFlow Change-Id: I5c015fbb9555be0e3e74c721873da4edd0393c8a --- tests/src/com/android/launcher3/ui/WorkTabTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/src/com/android/launcher3/ui/WorkTabTest.java b/tests/src/com/android/launcher3/ui/WorkTabTest.java index ac0d355704..aef26ae3d0 100644 --- a/tests/src/com/android/launcher3/ui/WorkTabTest.java +++ b/tests/src/com/android/launcher3/ui/WorkTabTest.java @@ -150,11 +150,15 @@ public class WorkTabTest extends AbstractLauncherUiTest { waitForLauncherCondition("Launcher did not show the next edu screen", l -> { Log.d(TestProtocol.WORK_PROFILE_REMOVED, "running test attempt" + attempt.getAndIncrement()); + if (!(l.getAppsView().getContentView() instanceof AllAppsPagedView)) { + Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work tab not setup. Skipping test"); + return false; + } return ((AllAppsPagedView) l.getAppsView().getContentView()).getCurrentPage() == WORK_PAGE && ((TextView) workEduView.findViewById( R.id.content_text)).getText().equals( l.getResources().getString(R.string.work_profile_edu_work_apps)); - }); + }, 60000); } @Test From 6478fa649a36ab81da1aa0db8aa51b2819f19879 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Fri, 4 Dec 2020 23:00:01 +0100 Subject: [PATCH 4/4] Migrate FrameTracker to use ST Jank information (2/2) Test: FrameTrackerTest Test: Systrace, perform CUJ Bug: 174755489 Change-Id: I6abecbd9b244f443c9df389938d82427f9584037 --- .../com/android/launcher3/BaseQuickstepLauncher.java | 8 -------- .../launcher3/QuickstepAppTransitionManagerImpl.java | 2 +- .../src/com/android/quickstep/AbsSwipeUpHandler.java | 10 ++++++---- .../com/android/quickstep/OverviewCommandHelper.java | 4 +++- .../android/quickstep/util/SwipePipToHomeAnimator.java | 6 ++++-- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 4204597c03..3643d6d7e3 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -316,12 +316,4 @@ public abstract class BaseQuickstepLauncher extends Launcher public void setHintUserWillBeActive() { addActivityFlags(ACTIVITY_STATE_USER_WILL_BE_ACTIVE); } - - @Override - public void onAttachedToWindow() { - super.onAttachedToWindow(); - if (Utilities.ATLEAST_R) { - InteractionJankMonitorWrapper.init(getWindow().getDecorView()); - } - } } diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java index 108006b5f0..8e6a5b628b 100644 --- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java @@ -763,7 +763,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans anim.addListener(new AnimationSuccessListener() { @Override public void onAnimationStart(Animator animation) { - InteractionJankMonitorWrapper.begin(cuj); + InteractionJankMonitorWrapper.begin(mDragLayer, cuj); super.onAnimationStart(animation); } diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 5f196feaa1..a7e4741c07 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -721,9 +721,9 @@ public abstract class AbsSwipeUpHandler, Q extends @UiThread public void onGestureStarted(boolean isLikelyToStartNewTask) { - InteractionJankMonitorWrapper.begin( + InteractionJankMonitorWrapper.begin(mRecentsView, InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH, 2000 /* ms timeout */); - InteractionJankMonitorWrapper.begin( + InteractionJankMonitorWrapper.begin(mRecentsView, InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); notifyGestureStartedAsync(); setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */); @@ -805,7 +805,8 @@ public abstract class AbsSwipeUpHandler, Q extends maybeUpdateRecentsAttachedState(false); final GestureEndTarget endTarget = mGestureState.getEndTarget(); if (endTarget != NEW_TASK) { - InteractionJankMonitorWrapper.cancel(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); + InteractionJankMonitorWrapper.cancel( + InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); } if (endTarget != HOME) { InteractionJankMonitorWrapper.cancel( @@ -1165,7 +1166,8 @@ public abstract class AbsSwipeUpHandler, Q extends TaskInfoCompat.getPipSourceRectHint(runningTaskTarget.pictureInPictureParams), TaskInfoCompat.getWindowConfigurationBounds(taskInfo), startBounds, - destinationBounds); + destinationBounds, + mRecentsView); // We would assume home and app window always in the same rotation While homeRotation // is not ROTATION_0 (which implies the rotation is turned on in launcher settings). if (homeRotation == ROTATION_0 diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index fd9c315f78..ec6e303830 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -175,7 +175,9 @@ public class OverviewCommandHelper { return; } - InteractionJankMonitorWrapper.begin(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); + InteractionJankMonitorWrapper.begin( + mActivityInterface.getCreatedActivity().getRootView(), + InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); // Otherwise, start overview. mListener = mActivityInterface.createActivityInitListener(this::onActivityReady); diff --git a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java index 8fbd645be4..378f25b7dc 100644 --- a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java +++ b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java @@ -28,6 +28,7 @@ import android.graphics.RectF; import android.util.Log; import android.view.Surface; import android.view.SurfaceControl; +import android.view.View; import androidx.annotation.NonNull; @@ -91,7 +92,8 @@ public class SwipePipToHomeAnimator extends ValueAnimator implements @NonNull Rect sourceRectHint, @NonNull Rect appBounds, @NonNull Rect startBounds, - @NonNull Rect destinationBounds) { + @NonNull Rect destinationBounds, + @NonNull View view) { mTaskId = taskId; mComponentName = componentName; mLeash = leash; @@ -110,7 +112,7 @@ public class SwipePipToHomeAnimator extends ValueAnimator implements addListener(new AnimationSuccessListener() { @Override public void onAnimationStart(Animator animation) { - InteractionJankMonitorWrapper.begin(CUJ_APP_CLOSE_TO_PIP); + InteractionJankMonitorWrapper.begin(view, CUJ_APP_CLOSE_TO_PIP); super.onAnimationStart(animation); }