From 25ac8b804f6840417049c821b766da6c55340e36 Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Mon, 25 Apr 2022 18:49:33 +0100 Subject: [PATCH 1/6] Increase empty space limits Bug: 227344807 Test: manual Change-Id: Id5d484d57da60f3cf90db9bf0571919d93288de3 --- res/xml/paddings_6x5.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/xml/paddings_6x5.xml b/res/xml/paddings_6x5.xml index a958ec7b55..a72f55412c 100644 --- a/res/xml/paddings_6x5.xml +++ b/res/xml/paddings_6x5.xml @@ -32,7 +32,7 @@ + launcher:maxEmptySpace="170dp"> @@ -47,7 +47,7 @@ + launcher:maxEmptySpace="410dp"> From a9b2c4bb5a0bff6ce85d7fb432d859aed725bf93 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Mon, 25 Apr 2022 22:18:03 +0000 Subject: [PATCH 2/6] Revert "Remove old logs associated to b/200572078" This reverts commit c4240fd4295bfa1f073003b92ac701771a0c3e7c. Reason for revert: Returning logs for flaking test Bug: 227650070 Change-Id: I7db31533cfb72d9e329f38dc001f3a8e52b9fb7f --- src/com/android/launcher3/Launcher.java | 8 ++++++++ src/com/android/launcher3/LauncherModel.java | 6 ++++++ .../android/launcher3/model/BaseLoaderResults.java | 13 +++++++++++++ src/com/android/launcher3/model/ModelUtils.java | 5 +++++ src/com/android/launcher3/testing/TestProtocol.java | 1 + 5 files changed, 33 insertions(+) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index e2bce00fcc..8fb2f53ec6 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2173,6 +2173,10 @@ public class Launcher extends StatefulActivity implements Launche IntSet result = new IntSet(); if (visibleIds.isEmpty()) { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.NULL_INT_SET, "getPagesToBindSynchronously (1): " + + result); + } return result; } for (int id : orderedScreenIds.toArray()) { @@ -2193,6 +2197,10 @@ public class Launcher extends StatefulActivity implements Launche // pages being hidden in single panel. result.add(pairId); } + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.NULL_INT_SET, "getPagesToBindSynchronously (2): " + + result); + } return result; } diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 2d7fcb12fa..8646849c2c 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -357,6 +357,12 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi public void addCallbacks(Callbacks callbacks) { Preconditions.assertUIThread(); synchronized (mCallbacksList) { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.NULL_INT_SET, "addCallbacks pointer: " + + callbacks + + ", name: " + + callbacks.getClass().getName(), new Exception()); + } mCallbacksList.add(callbacks); } } diff --git a/src/com/android/launcher3/model/BaseLoaderResults.java b/src/com/android/launcher3/model/BaseLoaderResults.java index db417a7e5e..5b278ab4cf 100644 --- a/src/com/android/launcher3/model/BaseLoaderResults.java +++ b/src/com/android/launcher3/model/BaseLoaderResults.java @@ -32,6 +32,7 @@ import com.android.launcher3.model.BgDataModel.FixedContainerItems; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; +import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.LooperExecutor; @@ -173,8 +174,20 @@ public abstract class BaseLoaderResults { ArrayList currentAppWidgets = new ArrayList<>(); ArrayList otherAppWidgets = new ArrayList<>(); + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.NULL_INT_SET, "bind (1) currentScreenIds: " + + currentScreenIds + + ", pointer: " + + mCallbacks + + ", name: " + + mCallbacks.getClass().getName()); + } filterCurrentWorkspaceItems(currentScreenIds, mWorkspaceItems, currentWorkspaceItems, otherWorkspaceItems); + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.NULL_INT_SET, "bind (2) currentScreenIds: " + + currentScreenIds); + } filterCurrentWorkspaceItems(currentScreenIds, mAppWidgets, currentAppWidgets, otherAppWidgets); final InvariantDeviceProfile idp = mApp.getInvariantDeviceProfile(); diff --git a/src/com/android/launcher3/model/ModelUtils.java b/src/com/android/launcher3/model/ModelUtils.java index 58aa9e591f..ef5eef1e43 100644 --- a/src/com/android/launcher3/model/ModelUtils.java +++ b/src/com/android/launcher3/model/ModelUtils.java @@ -31,6 +31,7 @@ import com.android.launcher3.icons.BitmapInfo; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; @@ -66,6 +67,10 @@ public class ModelUtils { (lhs, rhs) -> Integer.compare(lhs.container, rhs.container)); for (T info : allWorkspaceItems) { if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.NULL_INT_SET, "filterCurrentWorkspaceItems: " + + currentScreenIds); + } if (currentScreenIds.contains(info.screenId)) { currentScreenItems.add(info); itemsOnScreen.add(info.id); diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 11a585fffb..fc18ada958 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -127,6 +127,7 @@ public final class TestProtocol { public static final String PERMANENT_DIAG_TAG = "TaplTarget"; public static final String TASK_VIEW_ID_CRASH = "b/195430732"; public static final String NO_DROP_TARGET = "b/195031154"; + public static final String NULL_INT_SET = "b/200572078"; public static final String MISSING_PROMISE_ICON = "b/202985412"; public static final String LAUNCHER_NOT_INITIALIZED = "b/215233405"; } From 2f5a1b67561aac75f8a40660eb63c69f488c9bc4 Mon Sep 17 00:00:00 2001 From: My Name Date: Fri, 1 Apr 2022 11:11:57 +0000 Subject: [PATCH 3/6] Adding support to parse deep-shortcuts. Actual problem space is to prebundle YouTube Shorts shortcut to the JioPhone Next device. The parsers don't support parsing the deep shortcut. In this CL we have added support for parsing deep-shortcuts. Test: Tested manually on device. Bug: 227290255 Change-Id: I7ea240a29639b88254fa679733541ff98ddfaa48 --- .../launcher3/DefaultLayoutParser.java | 37 ++++++++++++++++++- .../launcher3/shortcuts/ShortcutKey.java | 12 ++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/DefaultLayoutParser.java b/src/com/android/launcher3/DefaultLayoutParser.java index af85594779..d8fba8bd91 100644 --- a/src/com/android/launcher3/DefaultLayoutParser.java +++ b/src/com/android/launcher3/DefaultLayoutParser.java @@ -7,15 +7,19 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; +import android.content.pm.LauncherApps; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.os.Bundle; +import android.os.Process; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import com.android.launcher3.LauncherSettings.Favorites; +import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.shortcuts.ShortcutKey; import com.android.launcher3.util.Thunk; import org.xmlpull.v1.XmlPullParser; @@ -23,6 +27,7 @@ import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.net.URISyntaxException; +import java.util.Collections; import java.util.List; /** @@ -43,6 +48,8 @@ public class DefaultLayoutParser extends AutoInstallsLayout { private static final String ATTR_CONTAINER = "container"; private static final String ATTR_SCREEN = "screen"; private static final String ATTR_FOLDER_ITEMS = "folderItems"; + private static final String ATTR_SHORTCUT_ID = "shortcutId"; + private static final String ATTR_PACKAGE_NAME = "packageName"; // TODO: Remove support for this broadcast, instead use widget options to send bind time options private static final String ACTION_APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE = @@ -178,7 +185,6 @@ public class DefaultLayoutParser extends AutoInstallsLayout { } } - /** * Shortcut parser which allows any uri and not just web urls. */ @@ -188,6 +194,35 @@ public class DefaultLayoutParser extends AutoInstallsLayout { super(iconRes); } + @Override + public int parseAndAdd(XmlPullParser parser) { + final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); + final String shortcutId = getAttributeValue(parser, ATTR_SHORTCUT_ID); + if (!TextUtils.isEmpty(packageName) && !TextUtils.isEmpty(shortcutId)) { + return parseAndAddDeepShortcut(shortcutId, packageName); + } + return super.parseAndAdd(parser); + } + + /** + * This method parses and adds a deep shortcut. + * @return item id if the shortcut is successfully added else -1 + */ + public int parseAndAddDeepShortcut(String shortcutId, String packageName) { + try { + LauncherApps launcherApps = mContext.getSystemService(LauncherApps.class); + launcherApps.pinShortcuts(packageName, Collections.singletonList(shortcutId), + Process.myUserHandle()); + Intent intent = ShortcutKey.makeIntent(shortcutId, packageName); + mValues.put(Favorites.RESTORED, WorkspaceItemInfo.FLAG_RESTORED_ICON); + return addShortcut(null, intent, Favorites.ITEM_TYPE_DEEP_SHORTCUT); + } catch (Exception e) { + Log.e(TAG, "Unable to pin the shortcut for shortcut id = " + shortcutId + + " and package name = " + packageName); + } + return -1; + } + @Override protected Intent parseIntent(XmlPullParser parser) { String uri = null; diff --git a/src/com/android/launcher3/shortcuts/ShortcutKey.java b/src/com/android/launcher3/shortcuts/ShortcutKey.java index 0c6d675afd..9af68c0388 100644 --- a/src/com/android/launcher3/shortcuts/ShortcutKey.java +++ b/src/com/android/launcher3/shortcuts/ShortcutKey.java @@ -57,11 +57,17 @@ public class ShortcutKey extends ComponentKey { } public static Intent makeIntent(ShortcutInfo si) { + return makeIntent(si.getId(), si.getPackage()).setComponent(si.getActivity()); + } + + /** + * Creates an intent for shortcut id and package name. + */ + public static Intent makeIntent(String shortcutId, String packageName) { return new Intent(Intent.ACTION_MAIN) .addCategory(INTENT_CATEGORY) - .setComponent(si.getActivity()) - .setPackage(si.getPackage()) + .setPackage(packageName) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) - .putExtra(EXTRA_SHORTCUT_ID, si.getId()); + .putExtra(EXTRA_SHORTCUT_ID, shortcutId); } } From 015d44aee3192710459e5f941067a9053adc788e Mon Sep 17 00:00:00 2001 From: Andras Kloczl Date: Wed, 27 Apr 2022 12:24:43 +0100 Subject: [PATCH 4/6] Cleanup tapl test workaround There was a bug in the framework (b/219711163) so we needed a workaround to make the tapl test pass. Test: Run TAPL tests Bug: 219919285 Change-Id: I3eb4ca8c5b1d24f38330ad41b58c31c81eb01501 --- tests/tapl/com/android/launcher3/tapl/Workspace.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index fee449011d..ae0f6a6e12 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -389,8 +389,7 @@ public final class Workspace extends Home { // Since the destination can be on another page, we need to drag to the edge first // until we reach the target page while (targetDest.x > displayX || targetDest.x < 0) { - // TODO: b/219919285 - int edgeX = targetDest.x > 0 ? displayX - 1 : 1; + int edgeX = targetDest.x > 0 ? displayX : 0; Point screenEdge = new Point(edgeX, targetDest.y); Point finalDragStart = dragStart; executeAndWaitForPageScroll(launcher, From 5cc7ff09904cbc027144895b3583042b69291d1d Mon Sep 17 00:00:00 2001 From: Anushree Ganjam Date: Wed, 27 Apr 2022 23:49:40 +0000 Subject: [PATCH 5/6] Revert "Refactors Search results into separate RV for Toast." This reverts commit 6729f0b95001bbebe32721e471b5dd9173977410. Reason for revert: This change caused b/230648542. Please see https://b.corp.google.com/issues/230648542#comment5 for the video after reverting this change. Bug: 206905515 Bug: 230648542 Change-Id: I85f063c56cad137c05b810204244bba7e8f94ee7 --- quickstep/res/layout/taskbar_all_apps.xml | 4 - .../allapps/TaskbarAllAppsContainerView.java | 5 +- res/layout/all_apps.xml | 4 - res/layout/search_results_rv_layout.xml | 24 --- res/layout/secondary_launcher.xml | 4 - ...ecyclerView.java => BaseRecyclerView.java} | 10 +- src/com/android/launcher3/Launcher.java | 2 +- .../allapps/ActivityAllAppsContainerView.java | 29 ++-- .../allapps/AllAppsRecyclerView.java | 32 ++-- .../allapps/AllAppsTransitionController.java | 9 +- .../allapps/AlphabeticalAppsList.java | 53 +++--- .../allapps/BaseAllAppsContainerView.java | 152 ++++++------------ .../launcher3/allapps/FloatingHeaderView.java | 29 ++-- .../launcher3/allapps/SearchRecyclerView.java | 53 ------ .../launcher3/allapps/WorkEduCard.java | 2 +- .../search/AppsSearchContainerLayout.java | 14 +- .../testing/TestInformationHandler.java | 2 +- .../views/RecyclerViewFastScroller.java | 6 +- .../widget/picker/WidgetsRecyclerView.java | 4 +- .../launcher3/ui/AbstractLauncherUiTest.java | 2 +- .../android/launcher3/ui/WorkProfileTest.java | 6 +- 21 files changed, 146 insertions(+), 300 deletions(-) delete mode 100644 res/layout/search_results_rv_layout.xml rename src/com/android/launcher3/{FastScrollRecyclerView.java => BaseRecyclerView.java} (95%) delete mode 100644 src/com/android/launcher3/allapps/SearchRecyclerView.java diff --git a/quickstep/res/layout/taskbar_all_apps.xml b/quickstep/res/layout/taskbar_all_apps.xml index 34d4b231b1..d402469833 100644 --- a/quickstep/res/layout/taskbar_all_apps.xml +++ b/quickstep/res/layout/taskbar_all_apps.xml @@ -33,10 +33,6 @@ layout="@layout/all_apps_bottom_sheet_background" android:visibility="gone" /> - - diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java index 51fa4d9f3a..0ea2aa0647 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java @@ -44,10 +44,9 @@ public class TaskbarAllAppsContainerView extends } @Override - protected BaseAllAppsAdapter createAdapter( - AlphabeticalAppsList appsList, + protected BaseAllAppsAdapter getAdapter(AlphabeticalAppsList mAppsList, BaseAdapterProvider[] adapterProviders) { - return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList, + return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList, adapterProviders); } } diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml index d0d82d48bd..2ac7e63a15 100644 --- a/res/layout/all_apps.xml +++ b/res/layout/all_apps.xml @@ -29,10 +29,6 @@ layout="@layout/all_apps_bottom_sheet_background" android:visibility="gone" /> - - diff --git a/res/layout/search_results_rv_layout.xml b/res/layout/search_results_rv_layout.xml deleted file mode 100644 index 567cb5f4fc..0000000000 --- a/res/layout/search_results_rv_layout.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml index 635db141dd..0fe05ee721 100644 --- a/res/layout/secondary_launcher.xml +++ b/res/layout/secondary_launcher.xml @@ -59,10 +59,6 @@ layout="@layout/all_apps_bottom_sheet_background" android:visibility="gone" /> - - diff --git a/src/com/android/launcher3/FastScrollRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java similarity index 95% rename from src/com/android/launcher3/FastScrollRecyclerView.java rename to src/com/android/launcher3/BaseRecyclerView.java index a60d143c6e..9369bdc2fd 100644 --- a/src/com/android/launcher3/FastScrollRecyclerView.java +++ b/src/com/android/launcher3/BaseRecyclerView.java @@ -37,19 +37,19 @@ import com.android.launcher3.views.RecyclerViewFastScroller; *
  • Enable fast scroller. * */ -public abstract class FastScrollRecyclerView extends RecyclerView { +public abstract class BaseRecyclerView extends RecyclerView { protected RecyclerViewFastScroller mScrollbar; - public FastScrollRecyclerView(Context context) { + public BaseRecyclerView(Context context) { this(context, null); } - public FastScrollRecyclerView(Context context, AttributeSet attrs) { + public BaseRecyclerView(Context context, AttributeSet attrs) { this(context, attrs, 0); } - public FastScrollRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) { + public BaseRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @@ -206,4 +206,4 @@ public abstract class FastScrollRecyclerView extends RecyclerView { } scrollToPosition(0); } -} +} \ No newline at end of file diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 463280b958..4b42ecbae0 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2750,7 +2750,7 @@ public class Launcher extends StatefulActivity packageName); if (supportsAllAppsState && isInState(LauncherState.ALL_APPS)) { - return getFirstMatch(Collections.singletonList(mAppsView.getActiveAppsRecyclerView()), + return getFirstMatch(Collections.singletonList(mAppsView.getActiveRecyclerView()), preferredItem, packageAndUserAndApp); } else { List containers = new ArrayList<>(mWorkspace.getPanelCount() + 1); diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 16a2823c4e..e279f59aaf 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -80,7 +80,7 @@ public class ActivityAllAppsContainerView mActivityContext.startActivitySafely(v, marketSearchIntent, null); for (int i = 0; i < mAH.size(); i++) { - mAH.get(i).mAdapter.setLastSearchQuery(query, marketSearchClickListener); + mAH.get(i).adapter.setLastSearchQuery(query, marketSearchClickListener); } mIsSearching = true; rebindAdapters(); @@ -142,7 +142,7 @@ public class ActivityAllAppsContainerView mHeaderThreshold) { bgVisible = false; @@ -251,7 +242,7 @@ public class ActivityAllAppsContainerView createAdapter(AlphabeticalAppsList appsList, + protected BaseAllAppsAdapter getAdapter(AlphabeticalAppsList mAppsList, BaseAdapterProvider[] adapterProviders) { - return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList, + return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList, adapterProviders); } } diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 18c6788397..7dbe711716 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -37,8 +37,8 @@ import android.view.View; import androidx.recyclerview.widget.RecyclerView; +import com.android.launcher3.BaseRecyclerView; import com.android.launcher3.DeviceProfile; -import com.android.launcher3.FastScrollRecyclerView; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.Utilities; @@ -53,13 +53,13 @@ import java.util.List; /** * A RecyclerView with custom fast scroll support for the all apps view. */ -public class AllAppsRecyclerView extends FastScrollRecyclerView { - protected static final String TAG = "AllAppsRecyclerView"; +public class AllAppsRecyclerView extends BaseRecyclerView { + private static final String TAG = "AllAppsContainerView"; private static final boolean DEBUG = false; private static final boolean DEBUG_LATENCY = Utilities.isPropertyEnabled(SEARCH_LOGGING); - protected AlphabeticalAppsList mApps; - protected final int mNumAppsPerRow; + private AlphabeticalAppsList mApps; + private final int mNumAppsPerRow; // The specific view heights that we use to calculate scroll private final SparseIntArray mViewHeights = new SparseIntArray(); @@ -74,8 +74,8 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { }; // The empty-search result background - protected AllAppsBackgroundDrawable mEmptySearchBackground; - protected int mEmptySearchBackgroundTopOffset; + private AllAppsBackgroundDrawable mEmptySearchBackground; + private int mEmptySearchBackgroundTopOffset; private ArrayList mAutoSizedOverlays = new ArrayList<>(); @@ -112,7 +112,7 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { return mApps; } - protected void updatePoolSize() { + private void updatePoolSize() { DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile(); RecyclerView.RecycledViewPool pool = getRecycledViewPool(); int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx); @@ -137,8 +137,8 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { Log.d(TAG, "onDraw at = " + System.currentTimeMillis()); } if (DEBUG_LATENCY) { - Log.d(SEARCH_LOGGING, getClass().getSimpleName() + " onDraw; time stamp = " - + System.currentTimeMillis()); + Log.d(SEARCH_LOGGING, + "-- Recycle view onDraw, time stamp = " + System.currentTimeMillis()); } super.onDraw(c); } @@ -223,7 +223,8 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { && mEmptySearchBackground != null && mEmptySearchBackground.getAlpha() > 0) { mEmptySearchBackground.setHotspot(e.getX(), e.getY()); } - hideKeyboardAsync(ActivityContext.lookupContext(getContext()), getApplicationWindowToken()); + hideKeyboardAsync(ActivityContext.lookupContext(getContext()), + getApplicationWindowToken()); return result; } @@ -358,6 +359,13 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { } } + @Override + public boolean supportsFastScrolling() { + // Only allow fast scrolling when the user is not searching, since the results are not + // grouped in a meaningful order + return !mApps.hasFilter(); + } + @Override public int getCurrentScrollY() { // Return early if there are no items or we haven't been measured @@ -368,7 +376,7 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { // Calculate the y and offset for the item View child = getChildAt(0); - int position = getChildAdapterPosition(child); + int position = getChildPosition(child); if (position == NO_POSITION) { return -1; } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 723bc65978..637a4189b8 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -84,8 +84,7 @@ public class AllAppsTransitionController @Override public Float get(AllAppsTransitionController controller) { if (controller.mIsTablet) { - return controller.mAppsView.getAppsRecyclerViewContainer() - .getTranslationY(); + return controller.mAppsView.getRecyclerViewContainer().getTranslationY(); } else { return controller.getAppsViewPullbackTranslationY().get( controller.mAppsView); @@ -95,7 +94,7 @@ public class AllAppsTransitionController @Override public void setValue(AllAppsTransitionController controller, float translation) { if (controller.mIsTablet) { - controller.mAppsView.getAppsRecyclerViewContainer().setTranslationY( + controller.mAppsView.getRecyclerViewContainer().setTranslationY( translation); } else { controller.getAppsViewPullbackTranslationY().set(controller.mAppsView, @@ -110,7 +109,7 @@ public class AllAppsTransitionController @Override public Float get(AllAppsTransitionController controller) { if (controller.mIsTablet) { - return controller.mAppsView.getAppsRecyclerViewContainer().getAlpha(); + return controller.mAppsView.getRecyclerViewContainer().getAlpha(); } else { return controller.getAppsViewPullbackAlpha().getValue(); } @@ -119,7 +118,7 @@ public class AllAppsTransitionController @Override public void setValue(AllAppsTransitionController controller, float alpha) { if (controller.mIsTablet) { - controller.mAppsView.getAppsRecyclerViewContainer().setAlpha(alpha); + controller.mAppsView.getRecyclerViewContainer().setAlpha(alpha); } else { controller.getAppsViewPullbackAlpha().setValue(alpha); } diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java index 42374b894f..7687fea85d 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -18,8 +18,6 @@ package com.android.launcher3.allapps; import android.content.Context; -import androidx.annotation.Nullable; - import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.data.AppInfo; @@ -73,7 +71,6 @@ public class AlphabeticalAppsList implement // The set of apps from the system private final List mApps = new ArrayList<>(); - @Nullable private final AllAppsStore mAllAppsStore; // The number of results in current adapter @@ -91,16 +88,14 @@ public class AlphabeticalAppsList implement private int mNumAppRowsInAdapter; private ItemInfoMatcher mItemFilter; - public AlphabeticalAppsList(Context context, @Nullable AllAppsStore appsStore, + public AlphabeticalAppsList(Context context, AllAppsStore appsStore, WorkAdapterProvider adapterProvider) { mAllAppsStore = appsStore; mActivityContext = ActivityContext.lookupContext(context); mAppNameComparator = new AppInfoComparator(context); mWorkAdapterProvider = adapterProvider; mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns; - if (mAllAppsStore != null) { - mAllAppsStore.addUpdateListener(this); - } + mAllAppsStore.addUpdateListener(this); } public void updateItemFilter(ItemInfoMatcher itemFilter) { @@ -173,9 +168,9 @@ public class AlphabeticalAppsList implement } /** - * Returns whether there are search results which will hide the A-Z list. + * Returns whether there are is a filter set. */ - public boolean hasSearchResults() { + public boolean hasFilter() { return !mSearchResults.isEmpty(); } @@ -183,7 +178,7 @@ public class AlphabeticalAppsList implement * Returns whether there are no filtered results. */ public boolean hasNoFilteredResults() { - return hasSearchResults() && mAccessibilityResultsCount == 0; + return hasFilter() && mAccessibilityResultsCount == 0; } /** @@ -201,13 +196,13 @@ public class AlphabeticalAppsList implement return true; } - /** Appends results to search. */ - public void appendSearchResults(ArrayList results) { - if (hasSearchResults() && results != null && results.size() > 0) { + public boolean appendSearchResults(ArrayList results) { + if (hasFilter() && results != null && results.size() > 0) { updateSearchAdapterItems(results, mSearchResults.size()); - mSearchResults.addAll(results); refreshRecyclerView(); + return true; } + return false; } void updateSearchAdapterItems(ArrayList list, int offset) { @@ -227,14 +222,11 @@ public class AlphabeticalAppsList implement */ @Override public void onAppsUpdated() { - if (mAllAppsStore == null) { - return; - } // Sort the list of apps mApps.clear(); for (AppInfo app : mAllAppsStore.getApps()) { - if (mItemFilter == null || mItemFilter.matches(app, null) || hasSearchResults()) { + if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) { mApps.add(app); } } @@ -304,18 +296,7 @@ public class AlphabeticalAppsList implement // Recreate the filtered and sectioned apps (for convenience for the grid layout) from the // ordered set of sections - if (hasSearchResults()) { - if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { - // Append the search market item - if (hasNoFilteredResults()) { - mSearchResults.add(AdapterItem.asEmptySearch(position++)); - } else { - mSearchResults.add(AdapterItem.asAllAppsDivider(position++)); - } - mSearchResults.add(AdapterItem.asMarketSearch(position++)); - } - updateSearchAdapterItems(mSearchResults, 0); - } else { + if (!hasFilter()) { mAccessibilityResultsCount = mApps.size(); if (mWorkAdapterProvider != null) { position += mWorkAdapterProvider.addWorkItems(mAdapterItems); @@ -342,6 +323,18 @@ public class AlphabeticalAppsList implement mAdapterItems.add(appItem); } + } else { + updateSearchAdapterItems(mSearchResults, 0); + if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { + // Append the search market item + if (hasNoFilteredResults()) { + mAdapterItems.add(AdapterItem.asEmptySearch(position++)); + } else { + mAdapterItems.add(AdapterItem.asAllAppsDivider(position++)); + } + mAdapterItems.add(AdapterItem.asMarketSearch(position++)); + + } } if (mNumAppsPerRowAllApps != 0) { // Update the number of rows in the adapter after we do all the merging (otherwise, we diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java index 6a4498917e..f913aa9093 100644 --- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java @@ -80,7 +80,7 @@ public abstract class BaseAllAppsContainerView