From 6e0b00d15ce47892f57bd5c1b9326b90c3450024 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Sun, 27 Dec 2020 15:56:09 -0600 Subject: [PATCH 01/21] 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 5c953ed47d5233c07eda76daee137225a436798d Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 5 Jan 2021 12:52:34 -0800 Subject: [PATCH 02/21] Disabling fling gesture for assistant over deferred region Fixing missing trigger when using fling gesture Bug: 130186141 Bug: 175839420 Test: Verified fling does not work over keyboard dismiss button Change-Id: Id15320122cf9183c591416962634561a1ddc6fa0 --- .../quickstep/OverviewComponentObserver.java | 5 --- .../RecentsAnimationDeviceState.java | 10 ++++- .../quickstep/TouchInteractionService.java | 11 ++---- .../AssistantInputConsumer.java | 38 +++++++++---------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java index 49feef0862..7bf7712fd0 100644 --- a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java +++ b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java @@ -23,7 +23,6 @@ import static android.content.Intent.ACTION_PACKAGE_REMOVED; import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY; import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter; import static com.android.systemui.shared.system.PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED; -import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED; import android.content.BroadcastReceiver; import android.content.ComponentName; @@ -119,10 +118,6 @@ public final class OverviewComponentObserver { updateOverviewTargets(); } - public boolean assistantGestureIsConstrained() { - return (mDeviceState.getSystemUiStateFlags() & SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED) != 0; - } - /** * Update overview intent and {@link BaseActivityInterface} based off the current launcher home * component. diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java index d8064a2153..fb195f8a6f 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java @@ -24,6 +24,7 @@ import static com.android.quickstep.SysUINavigationMode.Mode.THREE_BUTTONS; import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE; +import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_GLOBAL_ACTIONS_SHOWING; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED; @@ -374,7 +375,7 @@ public class RecentsAnimationDeviceState implements * @return the system ui state flags. */ // TODO(141886704): See if we can remove this - public @SystemUiStateFlags int getSystemUiStateFlags() { + public int getSystemUiStateFlags() { return mSystemUiStateFlags; } @@ -406,6 +407,13 @@ public class RecentsAnimationDeviceState implements return (mSystemUiStateFlags & SYSUI_STATE_SCREEN_PINNING) != 0; } + /** + * @return whether assistant gesture is constraint + */ + public boolean isAssistantGestureIsConstrained() { + return (mSystemUiStateFlags & SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED) != 0; + } + /** * @return whether the bubble stack is expanded */ diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 1e0a00aec8..e59035cf5a 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -466,7 +466,8 @@ public class TouchInteractionService extends Service implements PluginListener mGestureDetector; public AssistantInputConsumer( Context context, GestureState gestureState, InputConsumer delegate, InputMonitorCompat inputMonitor, - boolean isAssistGestureConstrained) { + RecentsAnimationDeviceState deviceState, + MotionEvent startEvent) { super(delegate, inputMonitor); final Resources res = context.getResources(); mContext = context; - mIsAssistGestureConstrained = isAssistGestureConstrained; mDragDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold); mFlingDistThreshold = res.getDimension(R.dimen.gestures_assistant_fling_threshold); mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold); @@ -104,7 +106,11 @@ public class AssistantInputConsumer extends DelegateInputConsumer { mSquaredSlop = slop * slop; mActivityInterface = gestureState.getActivityInterface(); - mGestureDetector = new GestureDetector(context, new AssistantGestureListener()); + boolean flingDisabled = deviceState.isAssistantGestureIsConstrained() + || deviceState.isInDeferredGestureRegion(startEvent); + mGestureDetector = flingDisabled + ? ev -> { } + : new GestureDetector(context, new AssistantGestureListener())::onTouchEvent; } @Override @@ -201,7 +207,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer { break; } - mGestureDetector.onTouchEvent(ev); + mGestureDetector.accept(ev); if (mState != STATE_ACTIVE) { mDelegate.onMotionEvent(ev); @@ -214,12 +220,6 @@ public class AssistantInputConsumer extends DelegateInputConsumer { if (mDistance >= mDragDistThreshold && mTimeFraction >= 1) { SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion(0); startAssistantInternal(); - - Bundle args = new Bundle(); - args.putInt(OPA_BUNDLE_TRIGGER, OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE); - args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE); - SystemUiProxy.INSTANCE.get(mContext).startAssistant(args); - mLaunchedAssistant = true; } else { SystemUiProxy.INSTANCE.get(mContext).onAssistantProgress(mLastProgress); } @@ -233,6 +233,12 @@ public class AssistantInputConsumer extends DelegateInputConsumer { 13, // HapticFeedbackConstants.GESTURE_END HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } + + Bundle args = new Bundle(); + args.putInt(OPA_BUNDLE_TRIGGER, OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE); + args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE); + SystemUiProxy.INSTANCE.get(mContext).startAssistant(args); + mLaunchedAssistant = true; } /** @@ -250,8 +256,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer { private class AssistantGestureListener extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - if (!mIsAssistGestureConstrained - && isValidAssistantGestureAngle(velocityX, -velocityY) + if (isValidAssistantGestureAngle(velocityX, -velocityY) && mDistance >= mFlingDistThreshold && !mLaunchedAssistant && mState != STATE_DELEGATE_ACTIVE) { @@ -259,11 +264,6 @@ public class AssistantInputConsumer extends DelegateInputConsumer { SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion( (float) Math.sqrt(velocityX * velocityX + velocityY * velocityY)); startAssistantInternal(); - - Bundle args = new Bundle(); - args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE); - SystemUiProxy.INSTANCE.get(mContext).startAssistant(args); - mLaunchedAssistant = true; } return true; } From 12d8222124ea9f24e8dd7daa7336ae04b4074ce3 Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 7 Jan 2021 14:50:52 -0800 Subject: [PATCH 03/21] Starting CUJ_APP_CLOSE_TO_HOME metric earlier Now starting it at the very start of the gesture. Test: Manual Bug: 174892351 Change-Id: I9c36b4e4ae51302fc1c6b99b825358fb647cd310 --- .../android/quickstep/AbsSwipeUpHandler.java | 21 ++++++++----------- .../quickstep/RecentsAnimationController.java | 1 + 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index f82bc2d698..5f196feaa1 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -723,6 +723,8 @@ public abstract class AbsSwipeUpHandler, Q extends public void onGestureStarted(boolean isLikelyToStartNewTask) { InteractionJankMonitorWrapper.begin( InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH, 2000 /* ms timeout */); + InteractionJankMonitorWrapper.begin( + InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); notifyGestureStartedAsync(); setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */); mStateCallback.setStateOnUiThread(STATE_GESTURE_STARTED); @@ -802,6 +804,13 @@ public abstract class AbsSwipeUpHandler, Q extends // Fast-finish the attaching animation if it's still running. maybeUpdateRecentsAttachedState(false); final GestureEndTarget endTarget = mGestureState.getEndTarget(); + if (endTarget != NEW_TASK) { + InteractionJankMonitorWrapper.cancel(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); + } + if (endTarget != HOME) { + InteractionJankMonitorWrapper.cancel( + InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); + } switch (endTarget) { case HOME: mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT); @@ -820,9 +829,6 @@ public abstract class AbsSwipeUpHandler, Q extends break; } ActiveGestureLog.INSTANCE.addLog("onSettledOnEndTarget " + endTarget); - if (endTarget != NEW_TASK) { - InteractionJankMonitorWrapper.cancel(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); - } } /** @return Whether this was the task we were waiting to appear, and thus handled it. */ @@ -1219,11 +1225,9 @@ public abstract class AbsSwipeUpHandler, Q extends anim.addOnUpdateListener((r, p) -> { updateSysUiFlags(Math.max(p, mCurrentShift.value)); }); - final int cuj = InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME; anim.addAnimatorListener(new AnimationSuccessListener() { @Override public void onAnimationStart(Animator animation) { - InteractionJankMonitorWrapper.begin(cuj); if (mActivity != null) { removeLiveTileOverlay(); } @@ -1237,13 +1241,6 @@ public abstract class AbsSwipeUpHandler, Q extends // Make sure recents is in its final state maybeUpdateRecentsAttachedState(false); mActivityInterface.onSwipeUpToHomeComplete(mDeviceState); - InteractionJankMonitorWrapper.end(cuj); - } - - @Override - public void onAnimationCancel(Animator animation) { - super.onAnimationCancel(animation); - InteractionJankMonitorWrapper.cancel(cuj); } }); if (mRecentsAnimationTargets != null) { diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationController.java b/quickstep/src/com/android/quickstep/RecentsAnimationController.java index bc5e18dab1..646c5a0592 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationController.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationController.java @@ -136,6 +136,7 @@ public class RecentsAnimationController { UI_HELPER_EXECUTOR.execute(() -> { mController.finish(toRecents, sendUserLeaveHint); InteractionJankMonitorWrapper.end(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); + InteractionJankMonitorWrapper.end(InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); if (callback != null) { MAIN_EXECUTOR.execute(callback); } From f19c57970680e9424b9c3c30eac1f856f20c8c4c Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Tue, 22 Dec 2020 15:20:14 -0800 Subject: [PATCH 04/21] Disable default IME in all apps if DISABLE_INITIAL_IME_IN_ALLAPPS is on Bug: 173447266 Test: manual Change-Id: Ib5c03b20cc7f09fdc2d066dd20fb7ccbb1e154f5 --- .../launcher3/allapps/AllAppsTransitionController.java | 10 +++++++--- src/com/android/launcher3/config/FeatureFlags.java | 3 +++ .../touch/AbstractStateChangeTouchController.java | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index f9ab196792..c03619e198 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -142,7 +142,8 @@ public class AllAppsTransitionController implements StateHandler, float shiftCurrent = progress * mShiftRange; mAppsView.setTranslationY(shiftCurrent); - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { + if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() + && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get()) { mInsetController.setProgress(progress); } } @@ -233,7 +234,9 @@ public class AllAppsTransitionController implements StateHandler, public void setupViews(AllAppsContainerView appsView, ScrimView scrimView) { mAppsView = appsView; mScrimView = scrimView; - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) { + if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() + && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get() + && BuildCompat.isAtLeastR()) { mInsetController = new AllAppsInsetTransitionController(mShiftRange, mAppsView); mLauncher.getSystemUiController().updateUiState(UI_STATE_ALLAPPS, View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN @@ -261,7 +264,8 @@ public class AllAppsTransitionController implements StateHandler, if (Float.compare(mProgress, 1f) == 0) { mAppsView.reset(false /* animate */); } - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) { + if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() + && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get() && BuildCompat.isAtLeastR()) { mInsetController.onAnimationEnd(mProgress); if (Float.compare(mProgress, 0f) == 0) { mLauncher.getLiveSearchManager().start(); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 883eab0159..bd5b30eba1 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -98,6 +98,9 @@ public final class FeatureFlags { public static final BooleanFlag ENABLE_DEVICE_SEARCH = getDebugFlag( "ENABLE_DEVICE_SEARCH", false, "Allows on device search in all apps"); + public static final BooleanFlag DISABLE_INITIAL_IME_IN_ALLAPPS = getDebugFlag( + "DISABLE_INITIAL_IME_IN_ALLAPPS", false, "Disable default IME state in all apps"); + public static final BooleanFlag FOLDER_NAME_SUGGEST = new DeviceFlag( "FOLDER_NAME_SUGGEST", true, "Suggests folder names instead of blank text."); diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index 23baaf08cc..10cd04cfcf 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -261,7 +261,9 @@ public abstract class AbstractStateChangeTouchController mCanBlockFling = mFromState == NORMAL; mFlingBlockCheck.unblockFling(); // Must be called after all the animation controllers have been paused - if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR() + if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() + && !FeatureFlags.DISABLE_INITIAL_IME_IN_ALLAPPS.get() + && BuildCompat.isAtLeastR() && (mToState == ALL_APPS || mToState == NORMAL)) { mLauncher.getAllAppsController().getInsetController().onDragStart( mFromState == NORMAL ? 1f : 0f); From e0484de39a46f15006f0eec4ece5be5b78b4fa0f Mon Sep 17 00:00:00 2001 From: Bernardo Rufino Date: Mon, 11 Jan 2021 18:39:26 +0000 Subject: [PATCH 05/21] Add BROADCAST_CLOSE_SYSTEM_DIALOGS to recents package It uses AM.closeSystemDialogs() and should have the permission. I had created the protection level in ag/13090697 but forgot to actually request the permission. Bug: 177228919 Bug: 159105552 Test: atest CloseSystemDialogsTest Test: atest android.server.wm.WindowMetricsActivityTests#testMetricsMatchesLayoutOnActivityOnCreate Change-Id: I661dac17f2160ed36adb1a193e739c200169a37d --- quickstep/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml index 4e7c3fa75b..8dab9150c4 100644 --- a/quickstep/AndroidManifest.xml +++ b/quickstep/AndroidManifest.xml @@ -27,6 +27,7 @@ android:permissionGroup="android.permission-group.SYSTEM_TOOLS" android:protectionLevel="signatureOrSystem" /> + From f725e955cb58771847ec1e073686af8f17eb8218 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Mon, 11 Jan 2021 15:01:58 -0500 Subject: [PATCH 06/21] Refactor app open code. Move all the logic that calculate the app open float properties to a separate class. This is in preparation for the new app launch properties. Change-Id: I1a008b2ea1379cbf667c5ad3ad58ece04bd88185 --- quickstep/res/values/dimens.xml | 1 - .../QuickstepAppTransitionManagerImpl.java | 142 ++++++++++-------- 2 files changed, 82 insertions(+), 61 deletions(-) diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 727fbd3ea1..551f7b0eb1 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -45,7 +45,6 @@ 50dp - 50dp 115dp 16sp diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java index cc3b7b6a64..108006b5f0 100644 --- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java @@ -33,7 +33,6 @@ import static com.android.launcher3.config.FeatureFlags.KEYGUARD_ANIMATION; import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY; import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS; import static com.android.launcher3.statehandlers.DepthController.DEPTH; -import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION; import static com.android.quickstep.TaskUtils.taskIsATargetWithMode; import static com.android.systemui.shared.system.QuickStepContract.getWindowCornerRadius; import static com.android.systemui.shared.system.QuickStepContract.supportsRoundedCornersOnWindows; @@ -149,7 +148,6 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans private final boolean mIsRtl; private final float mContentTransY; - private final float mWorkspaceTransY; private final float mClosingWindowTransY; private final float mMaxShadowRadius; @@ -183,7 +181,6 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans Resources res = mLauncher.getResources(); mContentTransY = res.getDimensionPixelSize(R.dimen.content_trans_y); - mWorkspaceTransY = res.getDimensionPixelSize(R.dimen.workspace_trans_y); mClosingWindowTransY = res.getDimensionPixelSize(R.dimen.closing_window_trans_y); mMaxShadowRadius = res.getDimensionPixelSize(R.dimen.max_shadow_radius); @@ -457,39 +454,11 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans new SurfaceTransactionApplier(floatingView); openingTargets.addReleaseCheck(surfaceApplier); - // Scale the app icon to take up the entire screen. This simplifies the math when - // animating the app window position / scale. - float smallestSize = Math.min(windowTargetBounds.height(), windowTargetBounds.width()); - float maxScaleX = smallestSize / bounds.width(); - float maxScaleY = smallestSize / bounds.height(); - float scale = Math.max(maxScaleX, maxScaleY); - float startScale = 1f; - if (v instanceof BubbleTextView && !(v.getParent() instanceof DeepShortcutView)) { - Drawable dr = ((BubbleTextView) v).getIcon(); - if (dr instanceof FastBitmapDrawable) { - startScale = ((FastBitmapDrawable) dr).getAnimatedScale(); - } - } - final float initialStartScale = startScale; - int[] dragLayerBounds = new int[2]; mDragLayer.getLocationOnScreen(dragLayerBounds); - // Animate the app icon to the center of the window bounds in screen coordinates. - float centerX = windowTargetBounds.centerX() - dragLayerBounds[0]; - float centerY = windowTargetBounds.centerY() - dragLayerBounds[1]; - - float dX = centerX - bounds.centerX(); - float dY = centerY - bounds.centerY(); - - boolean useUpwardAnimation = bounds.top > centerY - || Math.abs(dY) < mLauncher.getDeviceProfile().cellHeightPx; - final long xDuration = useUpwardAnimation ? APP_LAUNCH_CURVED_DURATION - : APP_LAUNCH_DOWN_DURATION; - final long yDuration = useUpwardAnimation ? APP_LAUNCH_DURATION - : APP_LAUNCH_DOWN_CURVED_DURATION; - final long alphaDuration = useUpwardAnimation ? APP_LAUNCH_ALPHA_DURATION - : APP_LAUNCH_ALPHA_DOWN_DURATION; + AnimOpenProperties prop = new AnimOpenProperties(mLauncher.getResources(), mDeviceProfile, + windowTargetBounds, bounds, v, dragLayerBounds); RectF targetBounds = new RectF(windowTargetBounds); RectF iconBounds = new RectF(); @@ -511,39 +480,28 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans } }); - float shapeRevealDuration = APP_LAUNCH_DURATION * SHAPE_PROGRESS_DURATION; - - final float startCrop; - final float endCrop; - if (mDeviceProfile.isVerticalBarLayout()) { - startCrop = windowTargetBounds.height(); - endCrop = windowTargetBounds.width(); - } else { - startCrop = windowTargetBounds.width(); - endCrop = windowTargetBounds.height(); - } - final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources()) - ? startCrop / 2f : 0f; - final float windowRadius = mDeviceProfile.isMultiWindowMode + ? prop.startCrop / 2f : 0f; + final float finalWindowRadius = mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher.getResources()); + appAnimator.addUpdateListener(new MultiValueUpdateListener() { - FloatProp mDx = new FloatProp(0, dX, 0, xDuration, AGGRESSIVE_EASE); - FloatProp mDy = new FloatProp(0, dY, 0, yDuration, AGGRESSIVE_EASE); - FloatProp mScale = new FloatProp(initialStartScale, scale, 0, APP_LAUNCH_DURATION, + FloatProp mDx = new FloatProp(0, prop.dX, 0, prop.xDuration, AGGRESSIVE_EASE); + FloatProp mDy = new FloatProp(0, prop.dY, 0, prop.yDuration, AGGRESSIVE_EASE); + FloatProp mScale = new FloatProp(prop.initialAppIconScale, + prop.finalAppIconScale, 0, APP_LAUNCH_DURATION, EXAGGERATED_EASE); + FloatProp mIconAlpha = new FloatProp(prop.iconAlphaStart, 0f, + APP_LAUNCH_ALPHA_START_DELAY, prop.alphaDuration, LINEAR); + FloatProp mCroppedSize = new FloatProp(prop.startCrop, prop.endCrop, 0, CROP_DURATION, EXAGGERATED_EASE); - FloatProp mIconAlpha = new FloatProp(1f, 0f, APP_LAUNCH_ALPHA_START_DELAY, - alphaDuration, LINEAR); - FloatProp mCroppedSize = new FloatProp(startCrop, endCrop, 0, CROP_DURATION, - EXAGGERATED_EASE); - FloatProp mWindowRadius = new FloatProp(initialWindowRadius, windowRadius, 0, + FloatProp mWindowRadius = new FloatProp(initialWindowRadius, finalWindowRadius, 0, RADIUS_DURATION, EXAGGERATED_EASE); FloatProp mShadowRadius = new FloatProp(0, mMaxShadowRadius, 0, APP_LAUNCH_DURATION, EXAGGERATED_EASE); @Override public void onUpdate(float percent) { - // Calculate the size. + // Calculate the size of the scaled icon. float width = bounds.width() * mScale.value; float height = bounds.height() * mScale.value; @@ -559,7 +517,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans } crop.set(0, 0, cropWidth, cropHeight); - // Scale the size to match the crop. + // Scale the size of the icon to match the size of the window crop. float scaleX = width / cropWidth; float scaleY = height / cropHeight; float scale = Math.min(1f, Math.max(scaleX, scaleY)); @@ -569,7 +527,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans float offsetX = (scaledCropWidth - width) / 2; float offsetY = (scaledCropHeight - height) / 2; - // Calculate the window position. + // Calculate the window position to match the icon position. temp.set(bounds); temp.offset(dragLayerBounds[0], dragLayerBounds[1]); temp.offset(mDx.value, mDy.value); @@ -586,8 +544,6 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans iconBounds.right += offsetX; iconBounds.bottom += offsetY; - float croppedHeight = (windowTargetBounds.height() - crop.height()) * scale; - float croppedWidth = (windowTargetBounds.width() - crop.width()) * scale; SurfaceParams[] params = new SurfaceParams[appTargets.length]; for (int i = appTargets.length - 1; i >= 0; i--) { RemoteAnimationTargetCompat target = appTargets[i]; @@ -970,4 +926,70 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans result.setAnimation(anim, mLauncher); } } + + /** + * Class that holds all the variables for the app open animation. + */ + static class AnimOpenProperties { + + public final float startCrop; + public final float endCrop; + + public final float dX; + public final float dY; + + public final long xDuration; + public final long yDuration; + public final long alphaDuration; + + public final float initialAppIconScale; + public final float finalAppIconScale; + + public final float iconAlphaStart; + + AnimOpenProperties(Resources r, DeviceProfile dp, Rect windowTargetBounds, + RectF launcherIconBounds, View view, int[] dragLayerBounds) { + // Scale the app icon to take up the entire screen. This simplifies the math when + // animating the app window position / scale. + float smallestSize = Math.min(windowTargetBounds.height(), windowTargetBounds.width()); + float maxScaleX = smallestSize / launcherIconBounds.width(); + float maxScaleY = smallestSize / launcherIconBounds.height(); + float iconStartScale = 1f; + if (view instanceof BubbleTextView && !(view.getParent() instanceof DeepShortcutView)) { + Drawable dr = ((BubbleTextView) view).getIcon(); + if (dr instanceof FastBitmapDrawable) { + iconStartScale = ((FastBitmapDrawable) dr).getAnimatedScale(); + } + } + + initialAppIconScale = iconStartScale; + finalAppIconScale = Math.max(maxScaleX, maxScaleY); + + // Animate the app icon to the center of the window bounds in screen coordinates. + float centerX = windowTargetBounds.centerX() - dragLayerBounds[0]; + float centerY = windowTargetBounds.centerY() - dragLayerBounds[1]; + + dX = centerX - launcherIconBounds.centerX(); + dY = centerY - launcherIconBounds.centerY(); + + boolean useUpwardAnimation = launcherIconBounds.top > centerY + || Math.abs(dY) < dp.cellHeightPx; + xDuration = useUpwardAnimation ? APP_LAUNCH_CURVED_DURATION + : APP_LAUNCH_DOWN_DURATION; + yDuration = useUpwardAnimation ? APP_LAUNCH_DURATION + : APP_LAUNCH_DOWN_CURVED_DURATION; + alphaDuration = useUpwardAnimation ? APP_LAUNCH_ALPHA_DURATION + : APP_LAUNCH_ALPHA_DOWN_DURATION; + + if (dp.isVerticalBarLayout()) { + startCrop = windowTargetBounds.height(); + endCrop = windowTargetBounds.width(); + } else { + startCrop = windowTargetBounds.width(); + endCrop = windowTargetBounds.height(); + } + + iconAlphaStart = 1f; + } + } } From 6a5f431a7b27fb81ec8cd15a3f81cd8c9649d249 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Tue, 12 Jan 2021 19:30:02 +0000 Subject: [PATCH 07/21] Revert "Revert "Add UI updates for incremental app installs."" This reverts commit 229497d1820f49450687bbc558041df97d0bf779. Reason for revert: Patching bugs Fixes: 176901235, 176992421, 176884453 Test: manual Change-Id: I57e13a15e72284564a10761966732ee31d15fd08 --- .../PackageInstallStateChangedTaskTest.java | 2 +- src/com/android/launcher3/BubbleTextView.java | 50 ++++++---- src/com/android/launcher3/Launcher.java | 5 +- src/com/android/launcher3/LauncherModel.java | 10 ++ src/com/android/launcher3/Utilities.java | 7 +- src/com/android/launcher3/Workspace.java | 2 +- .../launcher3/allapps/AllAppsStore.java | 12 ++- .../launcher3/folder/PreviewItemManager.java | 6 +- .../graphics/PreloadIconDrawable.java | 4 +- .../model/AddWorkspaceItemsTask.java | 5 +- .../android/launcher3/model/AllAppsList.java | 33 ++++--- .../android/launcher3/model/BgDataModel.java | 7 +- .../android/launcher3/model/LoaderCursor.java | 23 +++-- .../android/launcher3/model/LoaderTask.java | 24 ++++- ...PackageIncrementalDownloadUpdatedTask.java | 79 +++++++++++++++ .../model/PackageInstallStateChangedTask.java | 21 ++-- .../android/launcher3/model/data/AppInfo.java | 40 +++++++- .../model/data/ItemInfoWithIcon.java | 97 +++++++++++++++++++ .../launcher3/model/data/PromiseAppInfo.java | 54 ----------- .../model/data/WorkspaceItemInfo.java | 25 +---- .../launcher3/pm/PackageInstallInfo.java | 4 +- .../SecondaryDisplayLauncher.java | 14 +-- .../launcher3/touch/ItemClickHandler.java | 19 ++-- .../launcher3/util/PackageManagerHelper.java | 20 +++- 24 files changed, 400 insertions(+), 163 deletions(-) create mode 100644 src/com/android/launcher3/model/PackageIncrementalDownloadUpdatedTask.java delete mode 100644 src/com/android/launcher3/model/data/PromiseAppInfo.java diff --git a/robolectric_tests/src/com/android/launcher3/model/PackageInstallStateChangedTaskTest.java b/robolectric_tests/src/com/android/launcher3/model/PackageInstallStateChangedTaskTest.java index e43df21ae9..412ace03ff 100644 --- a/robolectric_tests/src/com/android/launcher3/model/PackageInstallStateChangedTaskTest.java +++ b/robolectric_tests/src/com/android/launcher3/model/PackageInstallStateChangedTaskTest.java @@ -67,7 +67,7 @@ public class PackageInstallStateChangedTaskTest { for (ItemInfo info : mModelHelper.getBgDataModel().itemsIdMap) { if (info instanceof WorkspaceItemInfo) { assertEquals(updates.contains(info.id) ? progress: 0, - ((WorkspaceItemInfo) info).getInstallProgress()); + ((WorkspaceItemInfo) info).getProgressLevel()); } else { assertEquals(updates.contains(info.id) ? progress: -1, ((LauncherAppWidgetInfo) info).installProgress); diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 3eb52adf1a..f44f88b098 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -50,6 +50,7 @@ import android.view.View; import android.view.ViewDebug; import android.widget.TextView; +import androidx.annotation.Nullable; import androidx.core.graphics.ColorUtils; import com.android.launcher3.Launcher.OnResumeCallback; @@ -71,7 +72,6 @@ import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.PackageItemInfo; -import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.RemoteActionItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.util.SafeCloseable; @@ -287,10 +287,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, public void applyFromWorkspaceItem(WorkspaceItemInfo info, boolean promiseStateChanged) { applyIconAndLabel(info); setTag(info); - if (promiseStateChanged || (info.hasPromiseIconUi())) { - applyPromiseState(promiseStateChanged); - } - + applyLoadingState(promiseStateChanged); applyDotState(info, false /* animate */); } @@ -303,9 +300,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, // Verify high res immediately verifyHighRes(); - if (info instanceof PromiseAppInfo) { - PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info; - applyProgressLevel(promiseAppInfo.level); + if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) { + applyProgressLevel(info.getProgressLevel()); } applyDotState(info, false /* animate */); } @@ -335,6 +331,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, mDotParams.color = IconPalette.getMutedColor(info.bitmap.color, 0.54f); setIcon(iconDrawable); + applyLabel(info); + } + + private void applyLabel(ItemInfoWithIcon info) { setText(info.title); if (info.contentDescription != null) { setContentDescription(info.isDisabled() @@ -595,21 +595,35 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, mLongPressHelper.cancelLongPress(); } - public void applyPromiseState(boolean promiseStateChanged) { + /** Applies the loading progress value to the progress bar. + * + * If this app is installing, the progress bar will be updated with the installation progress. + * If this app is installed and downloading incrementally, the progress bar will be updated + * with the total download progress. + */ + public void applyLoadingState(boolean promiseStateChanged) { if (getTag() instanceof WorkspaceItemInfo) { WorkspaceItemInfo info = (WorkspaceItemInfo) getTag(); - final boolean isPromise = info.hasPromiseIconUi(); - final int progressLevel = isPromise ? - ((info.hasStatusFlag(WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE) ? - info.getInstallProgress() : 0)) : 100; - - PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel); - if (preloadDrawable != null && promiseStateChanged) { - preloadDrawable.maybePerformFinishedAnimation(); + int progressLevel = info.getProgressLevel(); + if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_INCREMENTAL_DOWNLOAD_ACTIVE) + != 0) { + updateProgressBarUi(progressLevel, progressLevel == 100); + } else if (info.hasPromiseIconUi() || (info.runtimeStatusFlags + & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) { + updateProgressBarUi(progressLevel, promiseStateChanged); } } } + private void updateProgressBarUi(int progressLevel, boolean maybePerformFinishedAnimation) { + PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel); + if (preloadDrawable != null && maybePerformFinishedAnimation) { + preloadDrawable.maybePerformFinishedAnimation(); + } + } + + /** Applies the given progress level to the this icon's progress bar. */ + @Nullable public PreloadIconDrawable applyProgressLevel(int progressLevel) { if (getTag() instanceof ItemInfoWithIcon) { ItemInfoWithIcon info = (ItemInfoWithIcon) getTag(); @@ -629,9 +643,11 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, if (mIcon instanceof PreloadIconDrawable) { preloadDrawable = (PreloadIconDrawable) mIcon; preloadDrawable.setLevel(progressLevel); + preloadDrawable.setIsDisabled(!info.isAppStartable()); } else { preloadDrawable = newPendingIcon(getContext(), info); preloadDrawable.setLevel(progressLevel); + preloadDrawable.setIsDisabled(!info.isAppStartable()); setIcon(preloadDrawable); } return preloadDrawable; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index a96fabd66e..5b55c4b435 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -137,7 +137,6 @@ import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; -import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.notification.NotificationListener; import com.android.launcher3.pm.PinRequestHelper; @@ -2516,8 +2515,8 @@ public class Launcher extends StatefulActivity implements Launche } @Override - public void bindPromiseAppProgressUpdated(PromiseAppInfo app) { - mAppsView.getAppsStore().updatePromiseAppProgress(app); + public void bindIncrementalDownloadProgressUpdated(AppInfo app) { + mAppsView.getAppsStore().updateProgressBar(app); } @Override diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 8458152146..e89b9b060a 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -48,6 +48,7 @@ import com.android.launcher3.model.LoaderResults; import com.android.launcher3.model.LoaderTask; import com.android.launcher3.model.ModelDelegate; import com.android.launcher3.model.ModelWriter; +import com.android.launcher3.model.PackageIncrementalDownloadUpdatedTask; import com.android.launcher3.model.PackageInstallStateChangedTask; import com.android.launcher3.model.PackageUpdatedTask; import com.android.launcher3.model.ShortcutsChangedTask; @@ -195,6 +196,15 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi PackageUpdatedTask.OP_UNSUSPEND, user, packageNames)); } + @Override + public void onPackageLoadingProgressChanged( + String packageName, UserHandle user, float progress) { + if (Utilities.ATLEAST_S) { + enqueueModelUpdateTask(new PackageIncrementalDownloadUpdatedTask( + packageName, user, progress)); + } + } + @Override public void onShortcutsChanged(String packageName, List shortcuts, UserHandle user) { diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 5c2f35b981..df5d23428d 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -107,12 +107,13 @@ public final class Utilities { public static final String[] EMPTY_STRING_ARRAY = new String[0]; public static final Person[] EMPTY_PERSON_ARRAY = new Person[0]; - public static final boolean ATLEAST_R = BuildCompat.isAtLeastR(); + public static final boolean ATLEAST_P = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P; public static final boolean ATLEAST_Q = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; - public static final boolean ATLEAST_P = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.P; + public static final boolean ATLEAST_R = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R; + + public static final boolean ATLEAST_S = BuildCompat.isAtLeastS(); /** * Set on a motion event dispatched from the nav bar. See {@link MotionEvent#setEdgeFlags(int)}. diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 777ea3c7d5..65eba20672 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -3154,7 +3154,7 @@ public class Workspace extends PagedView ItemOperator op = (info, v) -> { if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView && updates.contains(info)) { - ((BubbleTextView) v).applyPromiseState(false /* promiseStateChanged */); + ((BubbleTextView) v).applyLoadingState(false /* promiseStateChanged */); } else if (v instanceof PendingAppWidgetHostView && info instanceof LauncherAppWidgetInfo && updates.contains(info)) { diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java index 3ae0a18137..00bdb70c4a 100644 --- a/src/com/android/launcher3/allapps/AllAppsStore.java +++ b/src/com/android/launcher3/allapps/AllAppsStore.java @@ -24,7 +24,6 @@ import android.view.ViewGroup; import com.android.launcher3.BubbleTextView; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.PackageUserKey; @@ -145,10 +144,17 @@ public class AllAppsStore { }); } - public void updatePromiseAppProgress(PromiseAppInfo app) { + /** + * Sets the AppInfo's associated icon's progress bar. + * + * If this app is installed and supports incremental downloads, the progress bar will be updated + * the app's total download progress. Otherwise, the progress bar will be updated to the app's + * installation progress. + */ + public void updateProgressBar(AppInfo app) { updateAllIcons((child) -> { if (child.getTag() == app) { - child.applyProgressLevel(app.level); + child.applyProgressLevel(app.getProgressLevel()); } }); } diff --git a/src/com/android/launcher3/folder/PreviewItemManager.java b/src/com/android/launcher3/folder/PreviewItemManager.java index 7f8a15c927..9ae7faf988 100644 --- a/src/com/android/launcher3/folder/PreviewItemManager.java +++ b/src/com/android/launcher3/folder/PreviewItemManager.java @@ -39,6 +39,7 @@ import androidx.annotation.NonNull; import com.android.launcher3.Utilities; import com.android.launcher3.graphics.PreloadIconDrawable; +import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.views.ActivityContext; @@ -394,9 +395,10 @@ public class PreviewItemManager { } private void setDrawable(PreviewItemDrawingParams p, WorkspaceItemInfo item) { - if (item.hasPromiseIconUi()) { + if (item.hasPromiseIconUi() || (item.runtimeStatusFlags + & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) { PreloadIconDrawable drawable = newPendingIcon(mContext, item); - drawable.setLevel(item.getInstallProgress()); + drawable.setLevel(item.getProgressLevel()); p.drawable = drawable; } else { p.drawable = newIcon(mContext, item); diff --git a/src/com/android/launcher3/graphics/PreloadIconDrawable.java b/src/com/android/launcher3/graphics/PreloadIconDrawable.java index e85b056376..9971990267 100644 --- a/src/com/android/launcher3/graphics/PreloadIconDrawable.java +++ b/src/com/android/launcher3/graphics/PreloadIconDrawable.java @@ -117,6 +117,8 @@ public class PreloadIconDrawable extends FastBitmapDrawable { mIndicatorColor = IconPalette.getPreloadProgressColor(context, mIconColor); setInternalProgress(0); + + setIsDisabled(!info.isAppStartable()); } @Override @@ -266,14 +268,12 @@ public class PreloadIconDrawable extends FastBitmapDrawable { mIconScale = SMALL_SCALE; mScaledTrackPath.reset(); mTrackAlpha = MAX_PAINT_ALPHA; - setIsDisabled(true); } if (progress < 1 && progress > 0) { mPathMeasure.getSegment(0, progress * mTrackLength, mScaledProgressPath, true); mIconScale = SMALL_SCALE; mTrackAlpha = MAX_PAINT_ALPHA; - setIsDisabled(true); } else if (progress >= 1) { setIsDisabled(mItem.isDisabled()); mScaledTrackPath.set(mScaledProgressPath); diff --git a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java index c236fa6dec..56dbbd33da 100644 --- a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java +++ b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java @@ -34,6 +34,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pm.InstallSessionHelper; +import com.android.launcher3.pm.PackageInstallInfo; import com.android.launcher3.util.GridOccupancy; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.PackageManagerHelper; @@ -132,7 +133,9 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask { continue; } } else { - workspaceInfo.setInstallProgress((int) sessionInfo.getProgress()); + workspaceInfo.setProgressLevel( + (int) (sessionInfo.getProgress() * 100), + PackageInstallInfo.STATUS_INSTALLING); } if (hasActivity) { diff --git a/src/com/android/launcher3/model/AllAppsList.java b/src/com/android/launcher3/model/AllAppsList.java index 2695e66591..8d5cf7422f 100644 --- a/src/com/android/launcher3/model/AllAppsList.java +++ b/src/com/android/launcher3/model/AllAppsList.java @@ -21,11 +21,11 @@ import static com.android.launcher3.model.data.AppInfo.EMPTY_ARRAY; import android.content.ComponentName; import android.content.Context; +import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; import android.os.LocaleList; -import android.os.Process; import android.os.UserHandle; import android.util.Log; @@ -37,7 +37,6 @@ import com.android.launcher3.compat.AlphabeticIndexCompat; import com.android.launcher3.icons.IconCache; import com.android.launcher3.model.BgDataModel.Callbacks; import com.android.launcher3.model.data.AppInfo; -import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.pm.PackageInstallInfo; import com.android.launcher3.util.FlagOp; import com.android.launcher3.util.ItemInfoMatcher; @@ -150,7 +149,7 @@ public class AllAppsList { .getApplicationInfo(installInfo.packageName, installInfo.user, 0); // only if not yet installed if (applicationInfo == null) { - PromiseAppInfo info = new PromiseAppInfo(installInfo); + AppInfo info = new AppInfo(installInfo); mIconCache.getTitleAndIcon(info, info.usingLowResIcon()); info.sectionName = mIndex.computeSectionName(info.title); @@ -159,24 +158,26 @@ public class AllAppsList { } } - public PromiseAppInfo updatePromiseInstallInfo(PackageInstallInfo installInfo) { - UserHandle user = Process.myUserHandle(); - for (int i=0; i < data.size(); i++) { + /** Updates the given PackageInstallInfo's associated AppInfo's installation info. */ + public List updatePromiseInstallInfo(PackageInstallInfo installInfo) { + List updatedAppInfos = new ArrayList<>(); + UserHandle user = installInfo.user; + for (int i = data.size() - 1; i >= 0; i--) { final AppInfo appInfo = data.get(i); final ComponentName tgtComp = appInfo.getTargetComponent(); if (tgtComp != null && tgtComp.getPackageName().equals(installInfo.packageName) - && appInfo.user.equals(user) - && appInfo instanceof PromiseAppInfo) { - final PromiseAppInfo promiseAppInfo = (PromiseAppInfo) appInfo; - if (installInfo.state == PackageInstallInfo.STATUS_INSTALLING) { - promiseAppInfo.level = installInfo.progress; - return promiseAppInfo; + && appInfo.user.equals(user)) { + if (installInfo.state == PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING + || installInfo.state == PackageInstallInfo.STATUS_INSTALLING) { + appInfo.setProgressLevel(installInfo); + + updatedAppInfos.add(appInfo); } else if (installInfo.state == PackageInstallInfo.STATUS_FAILED) { removeApp(i); } } } - return null; + return updatedAppInfos; } private void removeApp(int index) { @@ -268,8 +269,14 @@ public class AllAppsList { if (applicationInfo == null) { add(new AppInfo(context, info, user), info); } else { + Intent launchIntent = AppInfo.makeLaunchIntent(info); + mIconCache.getTitleAndIcon(applicationInfo, info, true /* useLowResIcon */); applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title); + applicationInfo.setProgressLevel( + PackageManagerHelper.getLoadingProgress(info), + PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING); + applicationInfo.intent = launchIntent; mDataChanged = true; } diff --git a/src/com/android/launcher3/model/BgDataModel.java b/src/com/android/launcher3/model/BgDataModel.java index c217a475a1..2d860a41d3 100644 --- a/src/com/android/launcher3/model/BgDataModel.java +++ b/src/com/android/launcher3/model/BgDataModel.java @@ -39,7 +39,6 @@ import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; -import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pm.UserCache; import com.android.launcher3.shortcuts.ShortcutKey; @@ -459,7 +458,11 @@ public class BgDataModel { void preAddApps(); void bindAppsAdded(IntArray newScreens, ArrayList addNotAnimated, ArrayList addAnimated); - void bindPromiseAppProgressUpdated(PromiseAppInfo app); + + /** + * Binds updated incremental download progress + */ + void bindIncrementalDownloadProgressUpdated(AppInfo app); void bindWorkspaceItemsChanged(List updated); void bindWidgetsRestored(ArrayList widgets); void bindRestoreItemsChange(HashSet updates); diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java index 532834eeb8..19d9af98dc 100644 --- a/src/com/android/launcher3/model/LoaderCursor.java +++ b/src/com/android/launcher3/model/LoaderCursor.java @@ -35,11 +35,13 @@ import android.text.TextUtils; import android.util.Log; import android.util.LongSparseArray; +import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; +import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.Utilities; import com.android.launcher3.Workspace; import com.android.launcher3.config.FeatureFlags; @@ -92,6 +94,9 @@ public class LoaderCursor extends CursorWrapper { private final int restoredIndex; private final int intentIndex; + @Nullable + private LauncherActivityInfo mActivityInfo; + // Properties loaded per iteration public long serialNumber; public UserHandle user; @@ -132,6 +137,8 @@ public class LoaderCursor extends CursorWrapper { public boolean moveToNext() { boolean result = super.moveToNext(); if (result) { + mActivityInfo = null; + // Load common properties. itemType = getInt(itemTypeIndex); container = getInt(containerIndex); @@ -245,6 +252,10 @@ public class LoaderCursor extends CursorWrapper { return info; } + public LauncherActivityInfo getLauncherActivityInfo() { + return mActivityInfo; + } + /** * Make an WorkspaceItemInfo object for a shortcut that is an application. */ @@ -264,25 +275,25 @@ public class LoaderCursor extends CursorWrapper { Intent newIntent = new Intent(Intent.ACTION_MAIN, null); newIntent.addCategory(Intent.CATEGORY_LAUNCHER); newIntent.setComponent(componentName); - LauncherActivityInfo lai = mContext.getSystemService(LauncherApps.class) + mActivityInfo = mContext.getSystemService(LauncherApps.class) .resolveActivity(newIntent, user); - if ((lai == null) && !allowMissingTarget) { + if ((mActivityInfo == null) && !allowMissingTarget) { Log.d(TAG, "Missing activity found in getShortcutInfo: " + componentName); return null; } final WorkspaceItemInfo info = new WorkspaceItemInfo(); - info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; + info.itemType = Favorites.ITEM_TYPE_APPLICATION; info.user = user; info.intent = newIntent; - mIconCache.getTitleAndIcon(info, lai, useLowResIcon); + mIconCache.getTitleAndIcon(info, mActivityInfo, useLowResIcon); if (mIconCache.isDefaultIcon(info.bitmap, user)) { loadIcon(info); } - if (lai != null) { - AppInfo.updateRuntimeFlagsForActivityTarget(info, lai); + if (mActivityInfo != null) { + AppInfo.updateRuntimeFlagsForActivityTarget(info, mActivityInfo); } // from the db diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java index 8e085ce52d..f74c8b5c1c 100644 --- a/src/com/android/launcher3/model/LoaderTask.java +++ b/src/com/android/launcher3/model/LoaderTask.java @@ -69,6 +69,7 @@ import com.android.launcher3.logging.FileLog; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.model.data.PackageItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; @@ -591,11 +592,24 @@ public class LoaderTask implements Runnable { if (c.restoreFlag != 0 && !TextUtils.isEmpty(targetPkg)) { tempPackageKey.update(targetPkg, c.user); SessionInfo si = installingPkgs.get(tempPackageKey); - if (si == null) { - info.status &= ~WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE; - } else { - info.setInstallProgress((int) (si.getProgress() * 100)); - } + LauncherActivityInfo activityInfo = + c.getLauncherActivityInfo(); + if (si == null) { + info.runtimeStatusFlags &= + ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE; + } else if (activityInfo == null) { + int installProgress = (int) (si.getProgress() * 100); + + info.setProgressLevel( + installProgress, + PackageInstallInfo.STATUS_INSTALLING); + } else { + info.setProgressLevel( + PackageManagerHelper + .getLoadingProgress(activityInfo), + PackageInstallInfo + .STATUS_INSTALLED_DOWNLOADING); + } } c.checkAndAddItem(info, mBgDataModel); diff --git a/src/com/android/launcher3/model/PackageIncrementalDownloadUpdatedTask.java b/src/com/android/launcher3/model/PackageIncrementalDownloadUpdatedTask.java new file mode 100644 index 0000000000..e3e87693b1 --- /dev/null +++ b/src/com/android/launcher3/model/PackageIncrementalDownloadUpdatedTask.java @@ -0,0 +1,79 @@ +/* + * 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.model; + +import android.content.ComponentName; +import android.os.UserHandle; + +import com.android.launcher3.LauncherAppState; +import com.android.launcher3.model.data.AppInfo; +import com.android.launcher3.model.data.ItemInfoWithIcon; +import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.pm.PackageInstallInfo; + +import java.util.ArrayList; +import java.util.List; + +/** + * Handles updates due to incremental download progress updates. + */ +public class PackageIncrementalDownloadUpdatedTask extends BaseModelUpdateTask { + + private final UserHandle mUser; + private final int mProgress; + private final String mPackageName; + + public PackageIncrementalDownloadUpdatedTask( + String packageName, UserHandle user, float progress) { + mUser = user; + mProgress = 1 - progress > 0.001 ? (int) (100 * progress) : 100; + mPackageName = packageName; + } + + @Override + public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList appsList) { + PackageInstallInfo downloadInfo = new PackageInstallInfo( + mPackageName, + PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING, + mProgress, + mUser); + + synchronized (appsList) { + List updatedAppInfos = appsList.updatePromiseInstallInfo(downloadInfo); + if (!updatedAppInfos.isEmpty()) { + for (AppInfo appInfo : updatedAppInfos) { + appInfo.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE; + scheduleCallbackTask( + c -> c.bindIncrementalDownloadProgressUpdated(appInfo)); + } + } + bindApplicationsIfNeeded(); + } + + final ArrayList updatedWorkspaceItems = new ArrayList<>(); + synchronized (dataModel) { + dataModel.forAllWorkspaceItemInfos(mUser, si -> { + ComponentName cn = si.getTargetComponent(); + if ((cn != null) && cn.getPackageName().equals(mPackageName)) { + si.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE; + si.setProgressLevel(downloadInfo); + updatedWorkspaceItems.add(si); + } + }); + } + bindUpdatedWorkspaceItems(updatedWorkspaceItems); + } +} diff --git a/src/com/android/launcher3/model/PackageInstallStateChangedTask.java b/src/com/android/launcher3/model/PackageInstallStateChangedTask.java index 8369c48e5c..8215edd90b 100644 --- a/src/com/android/launcher3/model/PackageInstallStateChangedTask.java +++ b/src/com/android/launcher3/model/PackageInstallStateChangedTask.java @@ -20,14 +20,15 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import com.android.launcher3.LauncherAppState; +import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.LauncherAppWidgetInfo; -import com.android.launcher3.model.data.PromiseAppInfo; -import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pm.PackageInstallInfo; import com.android.launcher3.util.InstantAppResolver; import java.util.HashSet; +import java.util.List; /** * Handles changes due to a sessions updates for a currently installing app. @@ -59,9 +60,11 @@ public class PackageInstallStateChangedTask extends BaseModelUpdateTask { } synchronized (apps) { - PromiseAppInfo updated = apps.updatePromiseInstallInfo(mInstallInfo); - if (updated != null) { - scheduleCallbackTask(c -> c.bindPromiseAppProgressUpdated(updated)); + List updatedAppInfos = apps.updatePromiseInstallInfo(mInstallInfo); + if (!updatedAppInfos.isEmpty()) { + for (AppInfo appInfo : updatedAppInfos) { + scheduleCallbackTask(c -> c.bindIncrementalDownloadProgressUpdated(appInfo)); + } } bindApplicationsIfNeeded(); } @@ -71,11 +74,13 @@ public class PackageInstallStateChangedTask extends BaseModelUpdateTask { dataModel.forAllWorkspaceItemInfos(mInstallInfo.user, si -> { ComponentName cn = si.getTargetComponent(); if (si.hasPromiseIconUi() && (cn != null) - && mInstallInfo.packageName.equals(cn.getPackageName())) { - si.setInstallProgress(mInstallInfo.progress); + && cn.getPackageName().equals(mInstallInfo.packageName)) { + int installProgress = mInstallInfo.progress; + + si.setProgressLevel(installProgress, PackageInstallInfo.STATUS_INSTALLING); if (mInstallInfo.state == PackageInstallInfo.STATUS_FAILED) { // Mark this info as broken. - si.status &= ~WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE; + si.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE; } updates.add(si); } diff --git a/src/com/android/launcher3/model/data/AppInfo.java b/src/com/android/launcher3/model/data/AppInfo.java index aee1f2a65b..39247c221f 100644 --- a/src/com/android/launcher3/model/data/AppInfo.java +++ b/src/com/android/launcher3/model/data/AppInfo.java @@ -28,10 +28,13 @@ import android.os.Process; import android.os.UserHandle; import android.os.UserManager; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.launcher3.LauncherSettings; import com.android.launcher3.Utilities; +import com.android.launcher3.pm.PackageInstallInfo; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.PackageManagerHelper; @@ -104,13 +107,37 @@ public class AppInfo extends ItemInfoWithIcon { this.intent = intent; } + public AppInfo(@NonNull PackageInstallInfo installInfo) { + componentName = installInfo.componentName; + intent = new Intent(Intent.ACTION_MAIN) + .addCategory(Intent.CATEGORY_LAUNCHER) + .setComponent(componentName) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); + user = installInfo.user; + } + @Override protected String dumpProperties() { return super.dumpProperties() + " componentName=" + componentName; } public WorkspaceItemInfo makeWorkspaceItem() { - return new WorkspaceItemInfo(this); + WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo(this); + + if ((runtimeStatusFlags & FLAG_INSTALL_SESSION_ACTIVE) != 0) { + // We need to update the component name when the apk is installed + workspaceItemInfo.status |= WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON; + // Since the user is manually placing it on homescreen, it should not be auto-removed + // later + workspaceItemInfo.status |= WorkspaceItemInfo.FLAG_RESTORE_STARTED; + workspaceItemInfo.status |= FLAG_INSTALL_SESSION_ACTIVE; + } + if ((runtimeStatusFlags & FLAG_INCREMENTAL_DOWNLOAD_ACTIVE) != 0) { + workspaceItemInfo.runtimeStatusFlags |= FLAG_INCREMENTAL_DOWNLOAD_ACTIVE; + } + + return workspaceItemInfo; } public ComponentKey toComponentKey() { @@ -129,6 +156,12 @@ public class AppInfo extends ItemInfoWithIcon { | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); } + @Nullable + @Override + public ComponentName getTargetComponent() { + return componentName; + } + public static void updateRuntimeFlagsForActivityTarget( ItemInfoWithIcon info, LauncherActivityInfo lai) { ApplicationInfo appInfo = lai.getApplicationInfo(); @@ -143,6 +176,11 @@ public class AppInfo extends ItemInfoWithIcon { // The icon for a non-primary user is badged, hence it's not exactly an adaptive icon. info.runtimeStatusFlags |= FLAG_ADAPTIVE_ICON; } + + // Sets the progress level, installation and incremental download flags. + info.setProgressLevel( + PackageManagerHelper.getLoadingProgress(lai), + PackageInstallInfo.STATUS_INSTALLED); } @Override diff --git a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java index d95f94f79f..b8a71d33e0 100644 --- a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java +++ b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java @@ -16,7 +16,15 @@ package com.android.launcher3.model.data; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; + +import androidx.annotation.Nullable; + import com.android.launcher3.icons.BitmapInfo; +import com.android.launcher3.pm.PackageInstallInfo; +import com.android.launcher3.util.PackageManagerHelper; /** * Represents an ItemInfo which also holds an icon. @@ -87,12 +95,35 @@ public abstract class ItemInfoWithIcon extends ItemInfo { */ public static final int FLAG_ICON_BADGED = 1 << 9; + /** + * The icon is being installed. If {@link WorkspaceItemInfo#FLAG_RESTORED_ICON} or + * {@link WorkspaceItemInfo#FLAG_AUTOINSTALL_ICON} is set, then the icon is either being + * installed or is in a broken state. + */ + public static final int FLAG_INSTALL_SESSION_ACTIVE = 1 << 10; + + /** + * This icon is still being downloaded. + */ + public static final int FLAG_INCREMENTAL_DOWNLOAD_ACTIVE = 1 << 11; + + public static final int FLAG_SHOW_DOWNLOAD_PROGRESS_MASK = FLAG_INSTALL_SESSION_ACTIVE + | FLAG_INCREMENTAL_DOWNLOAD_ACTIVE; + /** * Status associated with the system state of the underlying item. This is calculated every * time a new info is created and not persisted on the disk. */ public int runtimeStatusFlags = 0; + /** + * The download progress of the package that this shortcut represents. For legacy apps, this + * will always be the installation progress. For apps that support incremental downloads, this + * will only match be the installation progress until the app is installed, then this will the + * total download progress. + */ + private int mProgressLevel = 100; + protected ItemInfoWithIcon() { } protected ItemInfoWithIcon(ItemInfoWithIcon info) { @@ -113,6 +144,72 @@ public abstract class ItemInfoWithIcon extends ItemInfo { return bitmap.isLowRes(); } + /** + * Returns whether the app this shortcut represents is able to be started. For legacy apps, + * this returns whether it is fully installed. For apps that support incremental downloads, + * this returns whether the app is either fully downloaded or has installed and is downloading + * incrementally. + */ + public boolean isAppStartable() { + return ((runtimeStatusFlags & FLAG_INSTALL_SESSION_ACTIVE) == 0) + && (((runtimeStatusFlags & FLAG_INCREMENTAL_DOWNLOAD_ACTIVE) != 0) + || mProgressLevel == 100); + } + + /** + * Returns the download progress for the app this shortcut represents. If this app is not yet + * installed or does not support incremental downloads, this will return the installation + * progress. + */ + public int getProgressLevel() { + if ((runtimeStatusFlags & FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) { + return mProgressLevel; + } + return 100; + } + + /** + * Sets the download progress for the app this shortcut represents. If this app is not yet + * installed or does not support incremental downloads, this will set + * {@code FLAG_INSTALL_SESSION_ACTIVE}. If this app is downloading incrementally, this will + * set {@code FLAG_INCREMENTAL_DOWNLOAD_ACTIVE}. Otherwise, this will remove both flags. + */ + public void setProgressLevel(PackageInstallInfo installInfo) { + setProgressLevel(installInfo.progress, installInfo.state); + } + + /** + * Sets the download progress for the app this shortcut represents. + */ + public void setProgressLevel(int progress, int status) { + if (status == PackageInstallInfo.STATUS_INSTALLING) { + mProgressLevel = progress; + runtimeStatusFlags = progress < 100 + ? runtimeStatusFlags | FLAG_INSTALL_SESSION_ACTIVE + : runtimeStatusFlags & ~FLAG_INSTALL_SESSION_ACTIVE; + } else if (status == PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING) { + mProgressLevel = progress; + runtimeStatusFlags = runtimeStatusFlags & ~FLAG_INSTALL_SESSION_ACTIVE; + runtimeStatusFlags = progress < 100 + ? runtimeStatusFlags | FLAG_INCREMENTAL_DOWNLOAD_ACTIVE + : runtimeStatusFlags & ~FLAG_INCREMENTAL_DOWNLOAD_ACTIVE; + } else { + mProgressLevel = status == PackageInstallInfo.STATUS_INSTALLED ? 100 : 0; + runtimeStatusFlags = runtimeStatusFlags & ~FLAG_INSTALL_SESSION_ACTIVE; + runtimeStatusFlags = runtimeStatusFlags & ~FLAG_INCREMENTAL_DOWNLOAD_ACTIVE; + } + } + + /** Creates an intent to that launches the app store at this app's page. */ + @Nullable + public Intent getMarketIntent(Context context) { + ComponentName componentName = getTargetComponent(); + + return componentName != null + ? new PackageManagerHelper(context).getMarketIntent(componentName.getPackageName()) + : null; + } + /** * @return a copy of this */ diff --git a/src/com/android/launcher3/model/data/PromiseAppInfo.java b/src/com/android/launcher3/model/data/PromiseAppInfo.java deleted file mode 100644 index b6231ede19..0000000000 --- a/src/com/android/launcher3/model/data/PromiseAppInfo.java +++ /dev/null @@ -1,54 +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.model.data; - -import android.content.Context; -import android.content.Intent; - -import androidx.annotation.NonNull; - -import com.android.launcher3.pm.PackageInstallInfo; -import com.android.launcher3.util.PackageManagerHelper; - -public class PromiseAppInfo extends AppInfo { - - public int level = 0; - - public PromiseAppInfo(@NonNull PackageInstallInfo installInfo) { - componentName = installInfo.componentName; - intent = new Intent(Intent.ACTION_MAIN) - .addCategory(Intent.CATEGORY_LAUNCHER) - .setComponent(componentName) - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); - } - - @Override - public WorkspaceItemInfo makeWorkspaceItem() { - WorkspaceItemInfo shortcut = new WorkspaceItemInfo(this); - shortcut.setInstallProgress(level); - // We need to update the component name when the apk is installed - shortcut.status |= WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON; - // Since the user is manually placing it on homescreen, it should not be auto-removed later - shortcut.status |= WorkspaceItemInfo.FLAG_RESTORE_STARTED; - return shortcut; - } - - public Intent getMarketIntent(Context context) { - return new PackageManagerHelper(context).getMarketIntent(componentName.getPackageName()); - } -} diff --git a/src/com/android/launcher3/model/data/WorkspaceItemInfo.java b/src/com/android/launcher3/model/data/WorkspaceItemInfo.java index 1e1d093b13..690e904a02 100644 --- a/src/com/android/launcher3/model/data/WorkspaceItemInfo.java +++ b/src/com/android/launcher3/model/data/WorkspaceItemInfo.java @@ -57,21 +57,15 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon { */ public static final int FLAG_AUTOINSTALL_ICON = 1 << 1; - /** - * The icon is being installed. If {@link #FLAG_RESTORED_ICON} or {@link #FLAG_AUTOINSTALL_ICON} - * is set, then the icon is either being installed or is in a broken state. - */ - public static final int FLAG_INSTALL_SESSION_ACTIVE = 1 << 2; - /** * Indicates that the widget restore has started. */ - public static final int FLAG_RESTORE_STARTED = 1 << 3; + public static final int FLAG_RESTORE_STARTED = 1 << 2; /** * Web UI supported. */ - public static final int FLAG_SUPPORTS_WEB_UI = 1 << 4; + public static final int FLAG_SUPPORTS_WEB_UI = 1 << 3; /** * The intent used to start the application. @@ -98,11 +92,6 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon { */ @NonNull private String[] personKeys = Utilities.EMPTY_STRING_ARRAY; - /** - * The installation progress [0-100] of the package that this shortcut represents. - */ - private int mInstallProgress; - public WorkspaceItemInfo() { itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; @@ -114,7 +103,6 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon { intent = new Intent(info.intent); iconResource = info.iconResource; status = info.status; - mInstallProgress = info.mInstallProgress; personKeys = info.personKeys.clone(); } @@ -168,15 +156,6 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon { return isPromise() && !hasStatusFlag(FLAG_SUPPORTS_WEB_UI); } - public int getInstallProgress() { - return mInstallProgress; - } - - public void setInstallProgress(int progress) { - mInstallProgress = progress; - status |= FLAG_INSTALL_SESSION_ACTIVE; - } - public void updateFromDeepShortcutInfo(ShortcutInfo shortcutInfo, Context context) { // {@link ShortcutInfo#getActivity} can change during an update. Recreate the intent intent = ShortcutKey.makeIntent(shortcutInfo); diff --git a/src/com/android/launcher3/pm/PackageInstallInfo.java b/src/com/android/launcher3/pm/PackageInstallInfo.java index 7997d16756..fad904f968 100644 --- a/src/com/android/launcher3/pm/PackageInstallInfo.java +++ b/src/com/android/launcher3/pm/PackageInstallInfo.java @@ -25,7 +25,8 @@ public final class PackageInstallInfo { public static final int STATUS_INSTALLED = 0; public static final int STATUS_INSTALLING = 1; - public static final int STATUS_FAILED = 2; + public static final int STATUS_INSTALLED_DOWNLOADING = 2; + public static final int STATUS_FAILED = 3; public final ComponentName componentName; public final String packageName; @@ -56,5 +57,4 @@ public final class PackageInstallInfo { public static PackageInstallInfo fromState(int state, String packageName, UserHandle user) { return new PackageInstallInfo(packageName, state, 0 /* progress */, user); } - } diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java index b496608ac5..026634529f 100644 --- a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java +++ b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java @@ -35,8 +35,8 @@ import com.android.launcher3.allapps.AllAppsContainerView; import com.android.launcher3.model.BgDataModel; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.LauncherAppWidgetInfo; -import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.popup.PopupDataProvider; @@ -215,8 +215,8 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity ArrayList addAnimated) { } @Override - public void bindPromiseAppProgressUpdated(PromiseAppInfo app) { - mAppsView.getAppsStore().updatePromiseAppProgress(app); + public void bindIncrementalDownloadProgressUpdated(AppInfo app) { + mAppsView.getAppsStore().updateProgressBar(app); } @Override @@ -315,9 +315,11 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity if (tag instanceof ItemInfo) { ItemInfo item = (ItemInfo) tag; Intent intent; - if (item instanceof PromiseAppInfo) { - PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item; - intent = promiseAppInfo.getMarketIntent(this); + if (item instanceof ItemInfoWithIcon + && (((ItemInfoWithIcon) item).runtimeStatusFlags + & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) { + ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item; + intent = appInfo.getMarketIntent(this); } else { intent = item.getIntent(); } diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java index 9b9cb0a61b..41587357f5 100644 --- a/src/com/android/launcher3/touch/ItemClickHandler.java +++ b/src/com/android/launcher3/touch/ItemClickHandler.java @@ -49,8 +49,8 @@ import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.LauncherAppWidgetInfo; -import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.RemoteActionItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pm.InstallSessionHelper; @@ -231,8 +231,12 @@ public class ItemClickHandler { ? shortcut.getIntent().getComponent().getPackageName() : shortcut.getIntent().getPackage(); if (!TextUtils.isEmpty(packageName)) { - onClickPendingAppItem(v, launcher, packageName, - shortcut.hasStatusFlag(WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE)); + onClickPendingAppItem( + v, + launcher, + packageName, + (shortcut.runtimeStatusFlags + & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0); return; } } @@ -266,9 +270,12 @@ public class ItemClickHandler { TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity"); Intent intent; - if (item instanceof PromiseAppInfo) { - PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item; - intent = promiseAppInfo.getMarketIntent(launcher); + if (item instanceof ItemInfoWithIcon + && (((ItemInfoWithIcon) item).runtimeStatusFlags + & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) { + ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item; + intent = new PackageManagerHelper(launcher) + .getMarketIntent(appInfo.getTargetComponent().getPackageName()); } else { intent = item.getIntent(); } diff --git a/src/com/android/launcher3/util/PackageManagerHelper.java b/src/com/android/launcher3/util/PackageManagerHelper.java index 523545af43..7b264275d4 100644 --- a/src/com/android/launcher3/util/PackageManagerHelper.java +++ b/src/com/android/launcher3/util/PackageManagerHelper.java @@ -45,10 +45,11 @@ import android.widget.Toast; import com.android.launcher3.PendingAddItemInfo; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.LauncherAppWidgetInfo; -import com.android.launcher3.model.data.PromiseAppInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import java.net.URISyntaxException; @@ -200,9 +201,12 @@ public class PackageManagerHelper { * Starts the details activity for {@code info} */ public void startDetailsActivityForInfo(ItemInfo info, Rect sourceBounds, Bundle opts) { - if (info instanceof PromiseAppInfo) { - PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info; - mContext.startActivity(promiseAppInfo.getMarketIntent(mContext)); + if (info instanceof ItemInfoWithIcon + && (((ItemInfoWithIcon) info).runtimeStatusFlags + & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) { + ItemInfoWithIcon appInfo = (ItemInfoWithIcon) info; + mContext.startActivity(new PackageManagerHelper(mContext) + .getMarketIntent(appInfo.getTargetComponent().getPackageName())); return; } ComponentName componentName = null; @@ -319,4 +323,12 @@ public class PackageManagerHelper { } return false; } + + /** Returns the incremental download progress for the given shortcut's app. */ + public static int getLoadingProgress(LauncherActivityInfo info) { + if (Utilities.ATLEAST_S) { + return (int) (100 * info.getLoadingProgress()); + } + return 100; + } } From b803f7e2cb8dbaab2c1453693c61155c03fd90c8 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Tue, 12 Jan 2021 11:40:27 -0800 Subject: [PATCH 08/21] Add UI updates for incremental app installs. 1. Changed Preload Icon UI to be grayscale while the app is not startable. 2. Added progress bar for when app is installed but still ownloading. 3. Updated Preload Icon progress and click handling to use new incremental api. Progress bar color updates will follow in a separate CL. Demo: https://drive.google.com/file/d/1H1EvtTorLeJwC1eiq10tm-TT81YZ6osk/view?usp=sharing Fixes: 176901235,176992421,176884453 Test: manual Change-Id: Ie0575dc56c33c5d6ecd6c5cbf00666b96d6dcb16 --- src/com/android/launcher3/model/AllAppsList.java | 9 +++++++-- src/com/android/launcher3/model/PackageUpdatedTask.java | 2 ++ src/com/android/launcher3/model/data/AppInfo.java | 3 +-- .../android/launcher3/model/data/ItemInfoWithIcon.java | 6 ++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/model/AllAppsList.java b/src/com/android/launcher3/model/AllAppsList.java index 8d5cf7422f..c57c3e495a 100644 --- a/src/com/android/launcher3/model/AllAppsList.java +++ b/src/com/android/launcher3/model/AllAppsList.java @@ -26,6 +26,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; import android.os.LocaleList; +import android.os.Process; import android.os.UserHandle; import android.util.Log; @@ -161,14 +162,18 @@ public class AllAppsList { /** Updates the given PackageInstallInfo's associated AppInfo's installation info. */ public List updatePromiseInstallInfo(PackageInstallInfo installInfo) { List updatedAppInfos = new ArrayList<>(); - UserHandle user = installInfo.user; + UserHandle user = Process.myUserHandle(); for (int i = data.size() - 1; i >= 0; i--) { final AppInfo appInfo = data.get(i); final ComponentName tgtComp = appInfo.getTargetComponent(); if (tgtComp != null && tgtComp.getPackageName().equals(installInfo.packageName) && appInfo.user.equals(user)) { if (installInfo.state == PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING - || installInfo.state == PackageInstallInfo.STATUS_INSTALLING) { + || installInfo.state == PackageInstallInfo.STATUS_INSTALLING) { + if (appInfo.isAppStartable() + && installInfo.state == PackageInstallInfo.STATUS_INSTALLING) { + continue; + } appInfo.setProgressLevel(installInfo); updatedAppInfos.add(appInfo); diff --git a/src/com/android/launcher3/model/PackageUpdatedTask.java b/src/com/android/launcher3/model/PackageUpdatedTask.java index 896bfb666e..3275d59488 100644 --- a/src/com/android/launcher3/model/PackageUpdatedTask.java +++ b/src/com/android/launcher3/model/PackageUpdatedTask.java @@ -38,6 +38,7 @@ import com.android.launcher3.logging.FileLog; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.pm.PackageInstallInfo; import com.android.launcher3.pm.UserCache; import com.android.launcher3.shortcuts.ShortcutRequest; import com.android.launcher3.util.FlagOp; @@ -246,6 +247,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { if (isNewApkAvailable && si.itemType == Favorites.ITEM_TYPE_APPLICATION) { + si.setProgressLevel(100, PackageInstallInfo.STATUS_INSTALLED); iconCache.getTitleAndIcon(si, si.usingLowResIcon()); infoUpdated = true; } diff --git a/src/com/android/launcher3/model/data/AppInfo.java b/src/com/android/launcher3/model/data/AppInfo.java index 39247c221f..dde0cf4674 100644 --- a/src/com/android/launcher3/model/data/AppInfo.java +++ b/src/com/android/launcher3/model/data/AppInfo.java @@ -94,8 +94,6 @@ public class AppInfo extends ItemInfoWithIcon { componentName = info.componentName; title = Utilities.trim(info.title); intent = new Intent(info.intent); - user = info.user; - runtimeStatusFlags = info.runtimeStatusFlags; } @VisibleForTesting @@ -114,6 +112,7 @@ public class AppInfo extends ItemInfoWithIcon { .setComponent(componentName) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); + setProgressLevel(installInfo); user = installInfo.user; } diff --git a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java index b8a71d33e0..d95e7080de 100644 --- a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java +++ b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java @@ -129,7 +129,9 @@ public abstract class ItemInfoWithIcon extends ItemInfo { protected ItemInfoWithIcon(ItemInfoWithIcon info) { super(info); bitmap = info.bitmap; + mProgressLevel = info.mProgressLevel; runtimeStatusFlags = info.runtimeStatusFlags; + user = info.user; } @Override @@ -195,8 +197,8 @@ public abstract class ItemInfoWithIcon extends ItemInfo { : runtimeStatusFlags & ~FLAG_INCREMENTAL_DOWNLOAD_ACTIVE; } else { mProgressLevel = status == PackageInstallInfo.STATUS_INSTALLED ? 100 : 0; - runtimeStatusFlags = runtimeStatusFlags & ~FLAG_INSTALL_SESSION_ACTIVE; - runtimeStatusFlags = runtimeStatusFlags & ~FLAG_INCREMENTAL_DOWNLOAD_ACTIVE; + runtimeStatusFlags &= ~FLAG_INSTALL_SESSION_ACTIVE; + runtimeStatusFlags &= ~FLAG_INCREMENTAL_DOWNLOAD_ACTIVE; } } From fd58d23cdffa05d488e3fe65ca1f53b72bc40661 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Tue, 12 Jan 2021 12:59:39 -0600 Subject: [PATCH 09/21] 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 10/21] 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 11/21] 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); } From a60d1f9be7eb041a3988c7906815043ba065b465 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Tue, 12 Jan 2021 20:39:46 -0600 Subject: [PATCH 12/21] Migrate from Plugin SearchTarget to API search Target [2/3] - Adds support for android.app.search.SearchTarget in plugin while maintaining plugin SearchTarget support - Introduces SEARCH_TARGET_LEGACY temporary to switch between plugin and sdk variants. - Maps resultType and layoutType pairs to the appropriate view Bug: 177223401 Test: Manual Change-Id: If8d4bb7c21c47a12447dcb0c56eed8781bd21e54 --- .../search/DeviceSearchAdapterProvider.java | 34 ++++++++++++--- .../launcher3/search/SearchAdapterItem.java | 15 ++++++- .../launcher3/search/SearchEventTracker.java | 17 ++++---- .../launcher3/search/SearchResultIcon.java | 25 +++++++---- .../launcher3/search/SearchResultIconRow.java | 13 +++--- .../search/SearchResultPeopleView.java | 16 +++---- .../search/SearchResultPlayItem.java | 14 +++--- .../search/SearchResultSettingsSlice.java | 14 +++--- .../launcher3/search/SearchResultWidget.java | 14 +++--- .../search/SearchResultWidgetPreview.java | 14 +++--- .../search/SearchSectionHeaderView.java | 4 +- .../search/SearchSettingsRowView.java | 12 +++--- .../launcher3/search/SearchTargetHandler.java | 15 +++++-- .../search/ThumbnailSearchResultView.java | 12 +++--- .../uioverrides/QuickstepLauncher.java | 5 ++- .../launcher3/BaseDraggingActivity.java | 3 +- .../allapps/AllAppsContainerView.java | 6 ++- .../launcher3/config/FeatureFlags.java | 4 ++ .../systemui/plugins/AllAppsSearchPlugin.java | 43 +++++++++++++++---- ...vent.java => SearchTargetEventLegacy.java} | 23 ++++++---- ...rchTarget.java => SearchTargetLegacy.java} | 17 +++++--- 21 files changed, 209 insertions(+), 111 deletions(-) rename src_plugins/com/android/systemui/plugins/shared/{SearchTargetEvent.java => SearchTargetEventLegacy.java} (76%) rename src_plugins/com/android/systemui/plugins/shared/{SearchTarget.java => SearchTargetLegacy.java} (89%) diff --git a/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java b/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java index da325c7705..9ce196ef84 100644 --- a/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java +++ b/quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java @@ -18,15 +18,18 @@ package com.android.launcher3.search; import static com.android.launcher3.allapps.AllAppsGridAdapter.VIEW_TYPE_ICON; +import android.app.search.SearchTarget; import android.util.SparseIntArray; import android.view.LayoutInflater; import android.view.ViewGroup; 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.systemui.plugins.shared.SearchTarget; +import com.android.launcher3.config.FeatureFlags; +import com.android.systemui.plugins.shared.SearchTargetLegacy; /** * Provides views for on-device search results @@ -45,11 +48,13 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider { public static final int VIEW_TYPE_SEARCH_WIDGET_LIVE = 1 << 15; public static final int VIEW_TYPE_SEARCH_WIDGET_PREVIEW = 1 << 16; + private final AllAppsContainerView mAppsView; private final SparseIntArray mViewTypeToLayoutMap = new SparseIntArray(); - public DeviceSearchAdapterProvider(Launcher launcher) { + public DeviceSearchAdapterProvider(Launcher launcher, AllAppsContainerView appsView) { super(launcher); + mAppsView = appsView; mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ICON, R.layout.search_result_icon); mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_CORPUS_TITLE, R.layout.search_section_title); @@ -68,12 +73,16 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider { @Override public void onBindView(AllAppsGridAdapter.ViewHolder holder, int position) { - SearchAdapterItem item = (SearchAdapterItem) Launcher.getLauncher(mLauncher) - .getAppsView().getApps().getAdapterItems().get(position); + SearchAdapterItem item = (SearchAdapterItem) mAppsView.getApps().getAdapterItems().get( + position); SearchTargetHandler payloadResultView = (SearchTargetHandler) holder.itemView; - payloadResultView.applySearchTarget(item.getSearchTarget()); + if (FeatureFlags.SEARCH_TARGET_LEGACY.get()) { + payloadResultView.applySearchTarget(item.getSearchTargetLegacy()); + } else { + payloadResultView.applySearchTarget(item.getSearchTarget()); + } } @Override @@ -101,10 +110,23 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider { @Override public boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem focusedItem) { if (focusedItem instanceof SearchTargetHandler) { - SearchTarget searchTarget = ((SearchAdapterItem) focusedItem).getSearchTarget(); + SearchTargetLegacy searchTarget = ((SearchAdapterItem) focusedItem) + .getSearchTargetLegacy(); SearchEventTracker.INSTANCE.get(mLauncher).quickSelect(searchTarget); return true; } return false; } + + /** + * Determines what view type should be used to present search target. + * Returns -1 if viewType is not found + */ + public int getViewTypeForSearchTarget(SearchTarget t) { + //TODO: Replace with values from :SearchUi + if (t.getResultType() == 1 && t.getLayoutType().equals("icon")) { + return VIEW_TYPE_SEARCH_ICON; + } + return -1; + } } diff --git a/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java b/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java index b79e073da8..258d97750b 100644 --- a/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java +++ b/quickstep/src/com/android/launcher3/search/SearchAdapterItem.java @@ -27,13 +27,16 @@ import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE 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 com.android.systemui.plugins.shared.SearchTarget; +import com.android.systemui.plugins.shared.SearchTargetLegacy; /** * Extension of AdapterItem that contains an extra payload specific to item */ public class SearchAdapterItem extends AllAppsGridAdapter.AdapterItem { + private SearchTargetLegacy mSearchTargetLegacy; private SearchTarget mSearchTarget; @@ -43,11 +46,21 @@ public class SearchAdapterItem extends AllAppsGridAdapter.AdapterItem { | VIEW_TYPE_SEARCH_WIDGET_PREVIEW | VIEW_TYPE_SEARCH_WIDGET_LIVE | VIEW_TYPE_SEARCH_SUGGEST; + public SearchAdapterItem(SearchTargetLegacy searchTargetLegacy, int type) { + mSearchTargetLegacy = searchTargetLegacy; + viewType = type; + } + + public SearchAdapterItem(SearchTarget searchTarget, int type) { mSearchTarget = searchTarget; viewType = type; } + public SearchTargetLegacy getSearchTargetLegacy() { + return mSearchTargetLegacy; + } + public SearchTarget getSearchTarget() { return mSearchTarget; } diff --git a/quickstep/src/com/android/launcher3/search/SearchEventTracker.java b/quickstep/src/com/android/launcher3/search/SearchEventTracker.java index efb7b19bea..90fe661df4 100644 --- a/quickstep/src/com/android/launcher3/search/SearchEventTracker.java +++ b/quickstep/src/com/android/launcher3/search/SearchEventTracker.java @@ -23,8 +23,8 @@ import androidx.annotation.Nullable; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.systemui.plugins.AllAppsSearchPlugin; -import com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; import java.util.WeakHashMap; @@ -34,7 +34,7 @@ import java.util.WeakHashMap; public class SearchEventTracker { @Nullable private AllAppsSearchPlugin mPlugin; - private final WeakHashMap + private final WeakHashMap mCallbacks = new WeakHashMap<>(); public static final MainThreadInitializedObject INSTANCE = @@ -60,26 +60,27 @@ public class SearchEventTracker { /** * Sends SearchTargetEvent to search provider */ - public void notifySearchTargetEvent(SearchTargetEvent searchTargetEvent) { + public void notifySearchTargetEvent(SearchTargetEventLegacy searchTargetEvent) { if (mPlugin != null) { - UI_HELPER_EXECUTOR.post(() -> mPlugin.notifySearchTargetEvent(searchTargetEvent)); + UI_HELPER_EXECUTOR.post(() -> mPlugin.notifySearchTargetEventLegacy(searchTargetEvent)); } } /** * Registers a {@link SearchTargetHandler} to handle quick launch for specified SearchTarget. */ - public void registerWeakHandler(SearchTarget searchTarget, SearchTargetHandler targetHandler) { + public void registerWeakHandler(SearchTargetLegacy searchTarget, + SearchTargetHandler targetHandler) { mCallbacks.put(searchTarget, targetHandler); } /** * Handles quick select for SearchTarget */ - public void quickSelect(SearchTarget searchTarget) { + public void quickSelect(SearchTargetLegacy searchTarget) { SearchTargetHandler searchTargetHandler = mCallbacks.get(searchTarget); if (searchTargetHandler != null) { - searchTargetHandler.handleSelection(SearchTargetEvent.QUICK_SELECT); + searchTargetHandler.handleSelection(SearchTargetEventLegacy.QUICK_SELECT); } } diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIcon.java b/quickstep/src/com/android/launcher3/search/SearchResultIcon.java index 1aa89eecc5..e4d737c44f 100644 --- a/quickstep/src/com/android/launcher3/search/SearchResultIcon.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultIcon.java @@ -20,6 +20,7 @@ import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.app.RemoteAction; +import android.app.search.SearchTarget; import android.content.ComponentName; import android.content.Context; import android.content.pm.ShortcutInfo; @@ -42,8 +43,8 @@ import com.android.launcher3.model.data.RemoteActionItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.touch.ItemLongClickListener; import com.android.launcher3.util.ComponentKey; -import com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; import java.util.function.Consumer; @@ -69,7 +70,7 @@ public class SearchResultIcon extends BubbleTextView implements private final Launcher mLauncher; - private SearchTarget mSearchTarget; + private SearchTargetLegacy mSearchTarget; private Consumer mOnItemInfoChanged; public SearchResultIcon(Context context) { @@ -100,13 +101,13 @@ public class SearchResultIcon extends BubbleTextView implements * Applies search target with a ItemInfoWithIcon consumer to be called after itemInfo is * constructed */ - public void applySearchTarget(SearchTarget searchTarget, Consumer cb) { + public void applySearchTarget(SearchTargetLegacy searchTarget, Consumer cb) { mOnItemInfoChanged = cb; applySearchTarget(searchTarget); } @Override - public void applySearchTarget(SearchTarget searchTarget) { + public void applySearchTarget(SearchTargetLegacy searchTarget) { mSearchTarget = searchTarget; SearchEventTracker.getInstance(getContext()).registerWeakHandler(mSearchTarget, this); setVisibility(VISIBLE); @@ -127,9 +128,16 @@ public class SearchResultIcon extends BubbleTextView implements } } + @Override + public void applySearchTarget(SearchTarget searchTarget) { + prepareUsingApp(new ComponentName(searchTarget.getPackageName(), + searchTarget.getExtras().getString("class")), searchTarget.getUserHandle()); + } + private void prepareUsingApp(ComponentName componentName, UserHandle userHandle) { AllAppsStore appsStore = mLauncher.getAppsView().getAppsStore(); AppInfo appInfo = appsStore.getApp(new ComponentKey(componentName, userHandle)); + if (appInfo == null) { setVisibility(GONE); return; @@ -181,7 +189,8 @@ public class SearchResultIcon extends BubbleTextView implements } private void reportEvent(int eventType) { - SearchTargetEvent.Builder b = new SearchTargetEvent.Builder(mSearchTarget, eventType); + SearchTargetEventLegacy.Builder b = new SearchTargetEventLegacy.Builder(mSearchTarget, + eventType); if (mSearchTarget.getItemType().equals(TARGET_TYPE_SHORTCUT)) { b.setShortcutPosition(0); } @@ -191,7 +200,7 @@ public class SearchResultIcon extends BubbleTextView implements @Override public void onClick(View view) { - handleSelection(SearchTargetEvent.SELECT); + handleSelection(SearchTargetEventLegacy.SELECT); } @Override @@ -199,7 +208,7 @@ public class SearchResultIcon extends BubbleTextView implements if (!supportsLongPress(mSearchTarget.getItemType())) { return false; } - reportEvent(SearchTargetEvent.LONG_PRESS); + reportEvent(SearchTargetEventLegacy.LONG_PRESS); return ItemLongClickListener.INSTANCE_ALL_APPS.onLongClick(view); } diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java b/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java index b3dfbe28af..8c491d27d1 100644 --- a/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultIconRow.java @@ -39,8 +39,8 @@ import com.android.launcher3.R; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.PackageItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; -import com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; import java.util.ArrayList; import java.util.List; @@ -63,7 +63,7 @@ public class SearchResultIconRow extends LinearLayout implements private TextView mDescriptionView; private BubbleTextView[] mShortcutViews = new BubbleTextView[2]; - private SearchTarget mSearchTarget; + private SearchTargetLegacy mSearchTarget; private PackageItemInfo mProviderInfo; @@ -100,8 +100,9 @@ public class SearchResultIconRow extends LinearLayout implements lp.width = iconSize; bubbleTextView.setOnClickListener(view -> { WorkspaceItemInfo itemInfo = (WorkspaceItemInfo) bubbleTextView.getTag(); - SearchTargetEvent event = new SearchTargetEvent.Builder(mSearchTarget, - SearchTargetEvent.CHILD_SELECT).setShortcutPosition(itemInfo.rank).build(); + SearchTargetEventLegacy event = new SearchTargetEventLegacy.Builder(mSearchTarget, + SearchTargetEventLegacy.CHILD_SELECT).setShortcutPosition( + itemInfo.rank).build(); SearchEventTracker.getInstance(getContext()).notifySearchTargetEvent(event); mLauncher.getItemOnClickListener().onClick(view); }); @@ -111,7 +112,7 @@ public class SearchResultIconRow extends LinearLayout implements } @Override - public void applySearchTarget(SearchTarget searchTarget) { + public void applySearchTarget(SearchTargetLegacy searchTarget) { mSearchTarget = searchTarget; mResultIcon.applySearchTarget(searchTarget, this); String itemType = searchTarget.getItemType(); diff --git a/quickstep/src/com/android/launcher3/search/SearchResultPeopleView.java b/quickstep/src/com/android/launcher3/search/SearchResultPeopleView.java index e856531ee4..8caa51c07f 100644 --- a/quickstep/src/com/android/launcher3/search/SearchResultPeopleView.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultPeopleView.java @@ -44,8 +44,8 @@ import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.icons.BitmapInfo; import com.android.launcher3.icons.LauncherIcons; -import com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; import java.util.ArrayList; @@ -66,7 +66,7 @@ public class SearchResultPeopleView extends LinearLayout implements private Intent mIntent; - private SearchTarget mSearchTarget; + private SearchTargetLegacy mSearchTarget; public SearchResultPeopleView(Context context) { this(context, null, 0); @@ -99,11 +99,11 @@ public class SearchResultPeopleView extends LinearLayout implements button.getLayoutParams().width = mButtonSize; button.getLayoutParams().height = mButtonSize; } - setOnClickListener(v -> handleSelection(SearchTargetEvent.SELECT)); + setOnClickListener(v -> handleSelection(SearchTargetEventLegacy.SELECT)); } @Override - public void applySearchTarget(SearchTarget searchTarget) { + public void applySearchTarget(SearchTargetLegacy searchTarget) { mSearchTarget = searchTarget; Bundle payload = searchTarget.getExtras(); mTitleView.setText(payload.getString("title")); @@ -186,8 +186,8 @@ public class SearchResultPeopleView extends LinearLayout implements Bundle bundle = new Bundle(); bundle.putBundle("provider", provider); SearchEventTracker.INSTANCE.get(getContext()).notifySearchTargetEvent( - new SearchTargetEvent.Builder(mSearchTarget, - SearchTargetEvent.CHILD_SELECT).setExtras(bundle).build()); + new SearchTargetEventLegacy.Builder(mSearchTarget, + SearchTargetEventLegacy.CHILD_SELECT).setExtras(bundle).build()); }); } @@ -197,7 +197,7 @@ public class SearchResultPeopleView extends LinearLayout implements Launcher launcher = Launcher.getLauncher(getContext()); launcher.startActivitySafely(this, mIntent, null); SearchEventTracker.INSTANCE.get(getContext()).notifySearchTargetEvent( - new SearchTargetEvent.Builder(mSearchTarget, eventType).build()); + new SearchTargetEventLegacy.Builder(mSearchTarget, eventType).build()); } } } diff --git a/quickstep/src/com/android/launcher3/search/SearchResultPlayItem.java b/quickstep/src/com/android/launcher3/search/SearchResultPlayItem.java index 33c933077b..3bb821f958 100644 --- a/quickstep/src/com/android/launcher3/search/SearchResultPlayItem.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultPlayItem.java @@ -43,8 +43,8 @@ import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.icons.BitmapRenderer; import com.android.launcher3.util.Themes; -import com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; import java.io.IOException; import java.net.URL; @@ -69,7 +69,7 @@ public class SearchResultPlayItem extends LinearLayout implements private String mPackageName; private boolean mIsInstantGame; - private SearchTarget mSearchTarget; + private SearchTargetLegacy mSearchTarget; public SearchResultPlayItem(Context context) { @@ -101,7 +101,7 @@ public class SearchResultPlayItem extends LinearLayout implements ViewGroup.LayoutParams iconParams = mIconView.getLayoutParams(); iconParams.height = mDeviceProfile.allAppsIconSizePx; iconParams.width = mDeviceProfile.allAppsIconSizePx; - setOnClickListener(view -> handleSelection(SearchTargetEvent.SELECT)); + setOnClickListener(view -> handleSelection(SearchTargetEventLegacy.SELECT)); } @@ -127,7 +127,7 @@ public class SearchResultPlayItem extends LinearLayout implements @Override - public void applySearchTarget(SearchTarget searchTarget) { + public void applySearchTarget(SearchTargetLegacy searchTarget) { mSearchTarget = searchTarget; Bundle bundle = searchTarget.getExtras(); SearchEventTracker.INSTANCE.get(getContext()).registerWeakHandler(searchTarget, this); @@ -193,11 +193,11 @@ public class SearchResultPlayItem extends LinearLayout implements intent.putExtra("callerId", getContext().getPackageName()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); - logSearchEvent(SearchTargetEvent.CHILD_SELECT); + logSearchEvent(SearchTargetEventLegacy.CHILD_SELECT); } private void logSearchEvent(int eventType) { SearchEventTracker.INSTANCE.get(getContext()).notifySearchTargetEvent( - new SearchTargetEvent.Builder(mSearchTarget, eventType).build()); + new SearchTargetEventLegacy.Builder(mSearchTarget, eventType).build()); } } diff --git a/quickstep/src/com/android/launcher3/search/SearchResultSettingsSlice.java b/quickstep/src/com/android/launcher3/search/SearchResultSettingsSlice.java index 826b653989..80ad305af8 100644 --- a/quickstep/src/com/android/launcher3/search/SearchResultSettingsSlice.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultSettingsSlice.java @@ -32,8 +32,8 @@ import androidx.slice.widget.SliceView; import com.android.launcher3.Launcher; import com.android.launcher3.R; -import com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; /** * A slice view wrapper with settings app icon at start @@ -50,7 +50,7 @@ public class SearchResultSettingsSlice extends LinearLayout implements private SliceView mSliceView; private View mIcon; private LiveData mSliceLiveData; - private SearchTarget mSearchTarget; + private SearchTargetLegacy mSearchTarget; private final Launcher mLauncher; public SearchResultSettingsSlice(Context context) { @@ -77,7 +77,7 @@ public class SearchResultSettingsSlice extends LinearLayout implements } @Override - public void applySearchTarget(SearchTarget searchTarget) { + public void applySearchTarget(SearchTargetLegacy searchTarget) { reset(); mSearchTarget = searchTarget; try { @@ -103,8 +103,8 @@ public class SearchResultSettingsSlice extends LinearLayout implements @Override public void handleSelection(int eventType) { SearchEventTracker.INSTANCE.get(mLauncher).notifySearchTargetEvent( - new SearchTargetEvent.Builder(mSearchTarget, - SearchTargetEvent.CHILD_SELECT).build()); + new SearchTargetEventLegacy.Builder(mSearchTarget, + SearchTargetEventLegacy.CHILD_SELECT).build()); } private void reset() { @@ -116,7 +116,7 @@ public class SearchResultSettingsSlice extends LinearLayout implements @Override public void onSliceAction(@NonNull EventInfo eventInfo, @NonNull SliceItem sliceItem) { - handleSelection(SearchTargetEvent.CHILD_SELECT); + handleSelection(SearchTargetEventLegacy.CHILD_SELECT); } private Uri getSliceUri() { diff --git a/quickstep/src/com/android/launcher3/search/SearchResultWidget.java b/quickstep/src/com/android/launcher3/search/SearchResultWidget.java index ba26d852e7..4fe92296d5 100644 --- a/quickstep/src/com/android/launcher3/search/SearchResultWidget.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultWidget.java @@ -36,8 +36,8 @@ import com.android.launcher3.allapps.search.SearchWidgetInfoContainer; import com.android.launcher3.dragndrop.DraggableView; import com.android.launcher3.touch.ItemLongClickListener; import com.android.launcher3.widget.PendingAddWidgetInfo; -import com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; /** * displays live version of a widget upon receiving {@link AppWidgetProviderInfo} from Search @@ -58,7 +58,7 @@ public class SearchResultWidget extends RelativeLayout implements private final AppWidgetHostView mHostView; private final float mScaleToFit; - private SearchTarget mSearchTarget; + private SearchTargetLegacy mSearchTarget; private AppWidgetProviderInfo mProviderInfo; private SearchWidgetInfoContainer mInfoContainer; @@ -82,7 +82,7 @@ public class SearchResultWidget extends RelativeLayout implements // detect tap event on widget container for search target event reporting mClickDetector = new GestureDetector(context, - new ClickListener(() -> handleSelection(SearchTargetEvent.CHILD_SELECT))); + new ClickListener(() -> handleSelection(SearchTargetEventLegacy.CHILD_SELECT))); mLongPressHelper = new CheckLongPressHelper(this); mLongPressHelper.setLongPressTimeoutFactor(1); @@ -96,7 +96,7 @@ public class SearchResultWidget extends RelativeLayout implements } @Override - public void applySearchTarget(SearchTarget searchTarget) { + public void applySearchTarget(SearchTargetLegacy searchTarget) { if (searchTarget.getExtras() == null || searchTarget.getExtras().getParcelable("provider") == null) { setVisibility(GONE); @@ -141,7 +141,7 @@ public class SearchResultWidget extends RelativeLayout implements @Override public void handleSelection(int eventType) { SearchEventTracker.INSTANCE.get(getContext()).notifySearchTargetEvent( - new SearchTargetEvent.Builder(mSearchTarget, eventType).build()); + new SearchTargetEventLegacy.Builder(mSearchTarget, eventType).build()); } @Override @@ -182,7 +182,7 @@ public class SearchResultWidget extends RelativeLayout implements @Override public boolean onLongClick(View view) { ItemLongClickListener.INSTANCE_ALL_APPS.onLongClick(view); - handleSelection(SearchTargetEvent.LONG_PRESS); + handleSelection(SearchTargetEventLegacy.LONG_PRESS); return false; } diff --git a/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java b/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java index 0d790252de..5effbe594e 100644 --- a/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java @@ -39,8 +39,8 @@ 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 com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; /** * displays preview of a widget upon receiving {@link AppWidgetProviderInfo} from Search provider @@ -55,7 +55,7 @@ public class SearchResultWidgetPreview extends LinearLayout implements private WidgetCell mWidgetCell; private Toast mWidgetToast; - private SearchTarget mSearchTarget; + private SearchTargetLegacy mSearchTarget; public SearchResultWidgetPreview(Context context) { @@ -83,7 +83,7 @@ public class SearchResultWidgetPreview extends LinearLayout implements } @Override - public void applySearchTarget(SearchTarget searchTarget) { + public void applySearchTarget(SearchTargetLegacy searchTarget) { if (searchTarget.getExtras() == null || searchTarget.getExtras().getParcelable("provider") == null) { setVisibility(GONE); @@ -121,19 +121,19 @@ public class SearchResultWidgetPreview extends LinearLayout implements new PendingItemDragHelper(mWidgetCell).startDrag( imageView.getBitmapBounds(), imageView.getBitmap().getWidth(), imageView.getWidth(), new Point(loc[0], loc[1]), mLauncher.getAppsView(), new DragOptions()); - handleSelection(SearchTargetEvent.LONG_PRESS); + handleSelection(SearchTargetEventLegacy.LONG_PRESS); return true; } @Override public void onClick(View view) { mWidgetToast = BaseWidgetSheet.showWidgetToast(getContext(), mWidgetToast); - handleSelection(SearchTargetEvent.SELECT); + handleSelection(SearchTargetEventLegacy.SELECT); } @Override public void handleSelection(int eventType) { SearchEventTracker.INSTANCE.get(getContext()).notifySearchTargetEvent( - new SearchTargetEvent.Builder(mSearchTarget, eventType).build()); + new SearchTargetEventLegacy.Builder(mSearchTarget, eventType).build()); } } diff --git a/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java b/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java index a552366d1c..eb40938ecf 100644 --- a/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java +++ b/quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java @@ -21,7 +21,7 @@ import android.widget.TextView; import androidx.annotation.Nullable; -import com.android.systemui.plugins.shared.SearchTarget; +import com.android.systemui.plugins.shared.SearchTargetLegacy; /** * Header text view that shows a title for a given section in All apps search @@ -44,7 +44,7 @@ public class SearchSectionHeaderView extends TextView implements } @Override - public void applySearchTarget(SearchTarget searchTarget) { + public void applySearchTarget(SearchTargetLegacy searchTarget) { String title = searchTarget.getExtras().getString("title"); if (title == null || !title.isEmpty()) { setText(title); diff --git a/quickstep/src/com/android/launcher3/search/SearchSettingsRowView.java b/quickstep/src/com/android/launcher3/search/SearchSettingsRowView.java index dc5c2f183e..8306e3b555 100644 --- a/quickstep/src/com/android/launcher3/search/SearchSettingsRowView.java +++ b/quickstep/src/com/android/launcher3/search/SearchSettingsRowView.java @@ -38,8 +38,8 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.model.data.PackageItemInfo; -import com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; import java.util.ArrayList; import java.util.List; @@ -56,7 +56,7 @@ public class SearchSettingsRowView extends LinearLayout implements private TextView mTitleView; private TextView mBreadcrumbsView; private Intent mIntent; - private SearchTarget mSearchTarget; + private SearchTargetLegacy mSearchTarget; public SearchSettingsRowView(@NonNull Context context) { @@ -84,7 +84,7 @@ public class SearchSettingsRowView extends LinearLayout implements } @Override - public void applySearchTarget(SearchTarget searchTarget) { + public void applySearchTarget(SearchTargetLegacy searchTarget) { mSearchTarget = searchTarget; Bundle bundle = searchTarget.getExtras(); mIntent = bundle.getParcelable("intent"); @@ -108,7 +108,7 @@ public class SearchSettingsRowView extends LinearLayout implements @Override public void onClick(View view) { - handleSelection(SearchTargetEvent.SELECT); + handleSelection(SearchTargetEventLegacy.SELECT); } @Override @@ -120,7 +120,7 @@ public class SearchSettingsRowView extends LinearLayout implements launcher.startActivityForResult(mIntent, 0); SearchEventTracker.INSTANCE.get(getContext()).notifySearchTargetEvent( - new SearchTargetEvent.Builder(mSearchTarget, eventType).build()); + new SearchTargetEventLegacy.Builder(mSearchTarget, eventType).build()); } /** diff --git a/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java b/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java index 347c7d46fc..9ff057f0bf 100644 --- a/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java +++ b/quickstep/src/com/android/launcher3/search/SearchTargetHandler.java @@ -16,7 +16,9 @@ package com.android.launcher3.search; -import com.android.systemui.plugins.shared.SearchTarget; +import android.app.search.SearchTarget; + +import com.android.systemui.plugins.shared.SearchTargetLegacy; /** * An interface for supporting dynamic search results @@ -24,9 +26,16 @@ import com.android.systemui.plugins.shared.SearchTarget; public interface SearchTargetHandler { /** - * Update view using values from {@link SearchTarget} + * Update view using values from {@link SearchTargetLegacy} */ - void applySearchTarget(SearchTarget searchTarget); + void applySearchTarget(SearchTargetLegacy searchTarget); + + /** + * Update view using values from {@link SearchTargetLegacy} + */ + default void applySearchTarget(SearchTarget searchTarget){ + + } /** * Handles selection of SearchTarget diff --git a/quickstep/src/com/android/launcher3/search/ThumbnailSearchResultView.java b/quickstep/src/com/android/launcher3/search/ThumbnailSearchResultView.java index c100d6ad32..44f70575b6 100644 --- a/quickstep/src/com/android/launcher3/search/ThumbnailSearchResultView.java +++ b/quickstep/src/com/android/launcher3/search/ThumbnailSearchResultView.java @@ -35,8 +35,8 @@ import com.android.launcher3.model.data.RemoteActionItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.touch.ItemClickHandler; import com.android.launcher3.util.Themes; -import com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; /** * A view representing a high confidence app search result that includes shortcuts @@ -47,7 +47,7 @@ public class ThumbnailSearchResultView extends androidx.appcompat.widget.AppComp public static final String TARGET_TYPE_SCREENSHOT = "screenshot"; public static final String TARGET_TYPE_SCREENSHOT_LEGACY = "screenshot_legacy"; - private SearchTarget mSearchTarget; + private SearchTargetLegacy mSearchTarget; public ThumbnailSearchResultView(Context context) { super(context); @@ -72,11 +72,11 @@ public class ThumbnailSearchResultView extends androidx.appcompat.widget.AppComp ItemClickHandler.onClickAppShortcut(this, (WorkspaceItemInfo) itemInfo, launcher); } SearchEventTracker.INSTANCE.get(getContext()).notifySearchTargetEvent( - new SearchTargetEvent.Builder(mSearchTarget, eventType).build()); + new SearchTargetEventLegacy.Builder(mSearchTarget, eventType).build()); } @Override - public void applySearchTarget(SearchTarget target) { + public void applySearchTarget(SearchTargetLegacy target) { mSearchTarget = target; Bitmap bitmap; if (target.getRemoteAction() != null) { @@ -108,7 +108,7 @@ public class ThumbnailSearchResultView extends androidx.appcompat.widget.AppComp RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(null, bitmap); drawable.setCornerRadius(Themes.getDialogCornerRadius(getContext())); setImageDrawable(drawable); - setOnClickListener(v -> handleSelection(SearchTargetEvent.SELECT)); + setOnClickListener(v -> handleSelection(SearchTargetEventLegacy.SELECT)); SearchEventTracker.INSTANCE.get(getContext()).registerWeakHandler(target, this); } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index d345165e78..3be1ced810 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.AllAppsContainerView; import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.appprediction.PredictionRowView; @@ -266,8 +267,8 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { } @Override - public SearchAdapterProvider createSearchAdapterProvider() { - return new DeviceSearchAdapterProvider(this); + public SearchAdapterProvider createSearchAdapterProvider(AllAppsContainerView appsView) { + return new DeviceSearchAdapterProvider(this, appsView); } @Override diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index 33af4d7983..5bfde15a04 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -43,6 +43,7 @@ import android.widget.Toast; import androidx.annotation.Nullable; import com.android.launcher3.LauncherSettings.Favorites; +import com.android.launcher3.allapps.AllAppsContainerView; import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider; import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.logging.InstanceId; @@ -297,7 +298,7 @@ public abstract class BaseDraggingActivity extends BaseActivity * Creates and returns {@link SearchAdapterProvider} for build variant specific search result * views */ - public SearchAdapterProvider createSearchAdapterProvider() { + public SearchAdapterProvider createSearchAdapterProvider(AllAppsContainerView allapps) { return new DefaultSearchAdapterProvider(this); } } diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index b016df189b..4d51d70e7b 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -124,7 +124,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo mLauncher = BaseDraggingActivity.fromContext(context); mLauncher.addOnDeviceProfileChangeListener(this); - mSearchAdapterProvider = mLauncher.createSearchAdapterProvider(); + mSearchAdapterProvider = mLauncher.createSearchAdapterProvider(this); mSearchQueryBuilder = new SpannableStringBuilder(); Selection.setSelection(mSearchQueryBuilder, 0); @@ -569,6 +569,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo return null; } + public SearchAdapterProvider getSearchAdapterProvider() { + return mSearchAdapterProvider; + } + public RecyclerViewFastScroller getScrollBar() { AllAppsRecyclerView rv = getActiveRecyclerView(); return rv == null ? null : rv.getScrollbar(); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 24df653ca0..2455706d7d 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -98,6 +98,10 @@ public final class FeatureFlags { public static final BooleanFlag ENABLE_DEVICE_SEARCH = getDebugFlag( "ENABLE_DEVICE_SEARCH", false, "Allows on device search in all apps"); + public static final BooleanFlag SEARCH_TARGET_LEGACY = getDebugFlag( + "SEARCH_TARGET_LEGACY", true, + "Use SearchTarget provided by plugin lib (only during migration)"); + public static final BooleanFlag DISABLE_INITIAL_IME_IN_ALLAPPS = getDebugFlag( "DISABLE_INITIAL_IME_IN_ALLAPPS", false, "Disable default IME state in all apps"); diff --git a/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java b/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java index 5cc238da23..0b48c07d01 100644 --- a/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java +++ b/src_plugins/com/android/systemui/plugins/AllAppsSearchPlugin.java @@ -19,11 +19,12 @@ package com.android.systemui.plugins; import android.app.Activity; import android.os.Bundle; import android.os.CancellationSignal; +import android.os.Parcelable; import android.view.View; import com.android.systemui.plugins.annotations.ProvidesInterface; -import com.android.systemui.plugins.shared.SearchTarget; -import com.android.systemui.plugins.shared.SearchTargetEvent; +import com.android.systemui.plugins.shared.SearchTargetEventLegacy; +import com.android.systemui.plugins.shared.SearchTargetLegacy; import java.util.List; import java.util.function.Consumer; @@ -34,20 +35,25 @@ import java.util.function.Consumer; @ProvidesInterface(action = AllAppsSearchPlugin.ACTION, version = AllAppsSearchPlugin.VERSION) public interface AllAppsSearchPlugin extends Plugin { String ACTION = "com.android.systemui.action.PLUGIN_ALL_APPS_SEARCH_ACTIONS"; - int VERSION = 8; + int VERSION = 9; - void setup(Activity activity, View view); + /** + * init plugin + */ + void setup(Activity activity, View view, boolean useLegacy); /** * Send launcher state related signals. */ void onStateTransitionStart(int fromState, int toState); + void onStateTransitionComplete(int state); /** * Send launcher window focus and visibility changed signals. */ void onWindowFocusChanged(boolean hasFocus); + void onWindowVisibilityChanged(int visibility); /** @@ -59,22 +65,41 @@ public interface AllAppsSearchPlugin extends Plugin { /** * Main function that triggers search. * - * @param input string that has been typed by a user - * @param inputArgs extra info that may be relevant for the input query - * @param results contains the result that will be rendered in all apps search surface + * @param input string that has been typed by a user + * @param inputArgs extra info that may be relevant for the input query + * @param results contains the result that will be rendered in all apps search + * surface * @param cancellationSignal {@link CancellationSignal} can be used to share status of current */ - void query(String input, Bundle inputArgs, Consumer> results, + void queryLegacy(String input, Bundle inputArgs, Consumer> results, + CancellationSignal cancellationSignal); + + /** + * Main function that triggers search. + * + * @param input string that has been typed by a user + * @param inputArgs extra info that may be relevant for the input query + * @param results contains the result that will be rendered in all apps search + * surface + * @param cancellationSignal {@link CancellationSignal} can be used to share status of current + */ + void query(String input, Bundle inputArgs, Consumer> results, CancellationSignal cancellationSignal); /** * Send over search target interaction events to Plugin */ - void notifySearchTargetEvent(SearchTargetEvent event); + void notifySearchTargetEventLegacy(SearchTargetEventLegacy event); + + /** + * Send over search target interaction events to Plugin + */ + void notifySearchTargetEvent(Parcelable event); /** * Launcher activity lifecycle callbacks */ void onResume(int state); + void onStop(int state); } \ No newline at end of file diff --git a/src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java b/src_plugins/com/android/systemui/plugins/shared/SearchTargetEventLegacy.java similarity index 76% rename from src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java rename to src_plugins/com/android/systemui/plugins/shared/SearchTargetEventLegacy.java index 290fe54a27..7fbd6ac814 100644 --- a/src_plugins/com/android/systemui/plugins/shared/SearchTargetEvent.java +++ b/src_plugins/com/android/systemui/plugins/shared/SearchTargetEventLegacy.java @@ -19,8 +19,11 @@ import android.os.Bundle; /** * Event used for the feedback loop to the plugin. (and future aiai) + * + * @deprecated Use SearchTargetEvent */ -public class SearchTargetEvent { +@Deprecated +public class SearchTargetEventLegacy { public static final int POSITION_NONE = -1; public static final int SELECT = 0; @@ -28,12 +31,13 @@ public class SearchTargetEvent { public static final int LONG_PRESS = 2; public static final int CHILD_SELECT = 3; - private final SearchTarget mSearchTarget; + private final SearchTargetLegacy mSearchTarget; private final int mEventType; private final int mShortcutPosition; private final Bundle mExtras; - public SearchTargetEvent(SearchTarget searchTarget, int eventType, int shortcutPosition, + public SearchTargetEventLegacy(SearchTargetLegacy searchTarget, int eventType, + int shortcutPosition, Bundle extras) { mSearchTarget = searchTarget; mEventType = eventType; @@ -42,7 +46,7 @@ public class SearchTargetEvent { } - public SearchTarget getSearchTarget() { + public SearchTargetLegacy getSearchTarget() { return mSearchTarget; } @@ -59,15 +63,15 @@ public class SearchTargetEvent { } /** - * A builder for {@link SearchTarget} + * A builder for {@link SearchTargetLegacy} */ public static final class Builder { - private final SearchTarget mSearchTarget; + private final SearchTargetLegacy mSearchTarget; private final int mEventType; private int mShortcutPosition = POSITION_NONE; private Bundle mExtras; - public Builder(SearchTarget searchTarget, int eventType) { + public Builder(SearchTargetLegacy searchTarget, int eventType) { mSearchTarget = searchTarget; mEventType = eventType; } @@ -82,8 +86,9 @@ public class SearchTargetEvent { return this; } - public SearchTargetEvent build() { - return new SearchTargetEvent(mSearchTarget, mEventType, mShortcutPosition, mExtras); + public SearchTargetEventLegacy build() { + return new SearchTargetEventLegacy(mSearchTarget, mEventType, mShortcutPosition, + mExtras); } } diff --git a/src_plugins/com/android/systemui/plugins/shared/SearchTarget.java b/src_plugins/com/android/systemui/plugins/shared/SearchTargetLegacy.java similarity index 89% rename from src_plugins/com/android/systemui/plugins/shared/SearchTarget.java rename to src_plugins/com/android/systemui/plugins/shared/SearchTargetLegacy.java index 2c7972e908..2a6ba8829f 100644 --- a/src_plugins/com/android/systemui/plugins/shared/SearchTarget.java +++ b/src_plugins/com/android/systemui/plugins/shared/SearchTargetLegacy.java @@ -25,8 +25,11 @@ import java.util.List; /** * Used to return all apps search targets. + * + * @deprecated Use SearchTarget */ -public class SearchTarget implements Comparable { +@Deprecated +public class SearchTargetLegacy implements Comparable { private final String mItemId; private final String mItemType; @@ -39,7 +42,7 @@ public class SearchTarget implements Comparable { private final RemoteAction mRemoteAction; private final Bundle mExtras; - private SearchTarget(String itemId, String itemType, float score, + private SearchTargetLegacy(String itemId, String itemType, float score, ComponentName componentName, UserHandle userHandle, List shortcutInfos, RemoteAction remoteAction, Bundle extras) { mItemId = itemId; @@ -85,12 +88,12 @@ public class SearchTarget implements Comparable { } @Override - public int compareTo(SearchTarget o) { + public int compareTo(SearchTargetLegacy o) { return Float.compare(o.mScore, mScore); } /** - * A builder for {@link SearchTarget} + * A builder for {@link SearchTargetLegacy} */ public static final class Builder { @@ -158,13 +161,13 @@ public class SearchTarget implements Comparable { } /** - * Builds a {@link SearchTarget} + * Builds a {@link SearchTargetLegacy} */ - public SearchTarget build() { + public SearchTargetLegacy build() { if (mItemId == null) { throw new IllegalStateException("Item ID is required for building SearchTarget"); } - return new SearchTarget(mItemId, mItemType, mScore, mComponentName, mUserHandle, + return new SearchTargetLegacy(mItemId, mItemType, mScore, mComponentName, mUserHandle, mShortcutInfos, mRemoteAction, mExtras); } From c37058976dfa8e89026df5a58bde27e08c021f6b Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 13 Jan 2021 11:34:16 -0800 Subject: [PATCH 13/21] Generating Hdumps for more leaks Test: presubmits Bug: 177065099 Change-Id: I386229cf92a925d2953952ed0fab6c44dcdc61f0 --- tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index d3fc89e6be..37dd4d27c0 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -150,7 +150,7 @@ public abstract class AbstractLauncherUiTest { return "Activity leak detector has found leaked activities, " + dumpHprofData() + "."; } - private static String dumpHprofData() { + public static String dumpHprofData() { try { final String fileName = getInstrumentation().getTargetContext().getFilesDir().getPath() + "/ActivityLeakHeapDump.hprof"; From d7f7f52ddac0e288f3632f29ede63748c04d7ce5 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 13 Jan 2021 13:55:33 -0800 Subject: [PATCH 14/21] Waiting until the launcher change is propagater before test Bug: 143488140 Test: Presubmit Change-Id: Ie3f35a1e58b784d078a305814bd682beaae1f4cb --- .../quickstep/FallbackRecentsTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java index b9e0f628ab..475953bd9b 100644 --- a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java +++ b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java @@ -23,6 +23,7 @@ import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS; import static com.android.launcher3.tapl.TestHelpers.getHomeIntentInPackage; import static com.android.launcher3.tapl.TestHelpers.getLauncherInMyProcess; import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_ACTIVITY_TIMEOUT; +import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_BROADCAST_TIMEOUT_SECS; import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_UI_TIMEOUT; import static com.android.launcher3.ui.AbstractLauncherUiTest.resolveSystemApp; import static com.android.launcher3.ui.AbstractLauncherUiTest.startAppFast; @@ -66,6 +67,8 @@ import org.junit.rules.TestRule; import org.junit.runner.RunWith; import org.junit.runners.model.Statement; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.function.Function; @@ -112,11 +115,16 @@ public class FallbackRecentsTest { @Override public void evaluate() throws Throwable { TestCommandReceiver.callCommand(TestCommandReceiver.ENABLE_TEST_LAUNCHER); + OverviewUpdateHandler updateHandler = + MAIN_EXECUTOR.submit(OverviewUpdateHandler::new).get(); UiDevice.getInstance(getInstrumentation()).executeShellCommand( getLauncherCommand(mOtherLauncherActivity)); + updateHandler.mChangeCounter + .await(DEFAULT_BROADCAST_TIMEOUT_SECS, TimeUnit.SECONDS); try { base.evaluate(); } finally { + MAIN_EXECUTOR.submit(updateHandler::destroy).get(); TestCommandReceiver.callCommand(TestCommandReceiver.DISABLE_TEST_LAUNCHER); UiDevice.getInstance(getInstrumentation()).executeShellCommand( getLauncherCommand(getLauncherInMyProcess())); @@ -241,4 +249,30 @@ public class FallbackRecentsTest { private int getTaskCount(RecentsActivity recents) { return recents.getOverviewPanel().getTaskViewCount(); } + + private class OverviewUpdateHandler { + + final RecentsAnimationDeviceState mRads; + final OverviewComponentObserver mObserver; + final CountDownLatch mChangeCounter; + + OverviewUpdateHandler() { + Context ctx = getInstrumentation().getTargetContext(); + mRads = new RecentsAnimationDeviceState(ctx); + mObserver = new OverviewComponentObserver(ctx, mRads); + mChangeCounter = new CountDownLatch(1); + if (mObserver.getHomeIntent().getComponent() + .getPackageName().equals(mOtherLauncherActivity.packageName)) { + // Home already same + mChangeCounter.countDown(); + } else { + mObserver.setOverviewChangeListener(b -> mChangeCounter.countDown()); + } + } + + void destroy() { + mObserver.onDestroy(); + mRads.destroy(); + } + } } From 9d44e81062ee6707fbd2ba1ffa42b22d0cd14755 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 13 Jan 2021 15:37:59 -0800 Subject: [PATCH 15/21] Temporarily disable jank tracing Bug: 174755489 Test: Temporarily fix NPE Change-Id: Ifeae83a307f396c25d0d072abe19e8cf8493c427 --- .../src/com/android/quickstep/AbsSwipeUpHandler.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index a7e4741c07..3d5b1c6b83 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -721,10 +721,11 @@ public abstract class AbsSwipeUpHandler, Q extends @UiThread public void onGestureStarted(boolean isLikelyToStartNewTask) { - InteractionJankMonitorWrapper.begin(mRecentsView, - InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH, 2000 /* ms timeout */); - InteractionJankMonitorWrapper.begin(mRecentsView, - InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); + // Temporarily disable this until we have a view that we can use + // InteractionJankMonitorWrapper.begin(mRecentsView, + // InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH, 2000 /* ms timeout */); + // InteractionJankMonitorWrapper.begin(mRecentsView, + // InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); notifyGestureStartedAsync(); setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */); mStateCallback.setStateOnUiThread(STATE_GESTURE_STARTED); From 42203bec0a51da8263d3845b1d3bac3864bbd1d8 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Wed, 13 Jan 2021 15:48:25 -0800 Subject: [PATCH 16/21] Include searchui library to Launcher3CommonLib Change-Id: Ib66e028d3cf36a113aaca7511c53944e663ecd2d --- Android.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Android.mk b/Android.mk index 503f9aecb3..ed420393dc 100644 --- a/Android.mk +++ b/Android.mk @@ -33,7 +33,8 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \ LOCAL_STATIC_JAVA_LIBRARIES := \ LauncherPluginLib \ - launcher_log_protos_lite + launcher_log_protos_lite \ + search_ui LOCAL_SRC_FILES := \ $(call all-java-files-under, src_build_config) \ From e138389214cda4d6cfa7af0620f20ca1b5373ca8 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Tue, 12 Jan 2021 16:22:18 +0000 Subject: [PATCH 17/21] Flag FLAG_MULTIPLE_ORIENTATION_SUPPORTED_BY_DENSITY false when allow_rotation is set Bug: 177312556 Change-Id: I22e28b60be68b9cf7bb064d801854d0093920c9e --- .../src/com/android/quickstep/util/RecentsOrientedState.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java index dd3e31fa2a..a89aaf4b3c 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java @@ -49,6 +49,7 @@ import androidx.annotation.NonNull; import com.android.launcher3.DeviceProfile; import com.android.launcher3.InvariantDeviceProfile; +import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.touch.PagedOrientationHandler; @@ -156,7 +157,8 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre Resources res = context.getResources(); int originalSmallestWidth = res.getConfiguration().smallestScreenWidthDp * res.getDisplayMetrics().densityDpi / DENSITY_DEVICE_STABLE; - if (originalSmallestWidth < 600) { + if (originalSmallestWidth < 600 && !mContext.getResources().getBoolean( + R.bool.allow_rotation)) { mFlags |= FLAG_MULTIPLE_ORIENTATION_SUPPORTED_BY_DENSITY; } mFlags |= FLAG_SWIPE_UP_NOT_RUNNING; From b198d46f9ca68736e04345db645c238305cc5430 Mon Sep 17 00:00:00 2001 From: Becky Qiu Date: Wed, 13 Jan 2021 12:09:47 -0800 Subject: [PATCH 18/21] [Overview Sharing] Create the share function for sharing image in overview. Bug: 169772466, 169799864 Test: local Change-Id: Iaac49fa396e68f7392b59f6f9b8854cc1abe270b --- .../android/quickstep/ImageActionsApi.java | 11 +++++++ .../quickstep/util/ImageActionUtils.java | 32 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/quickstep/src/com/android/quickstep/ImageActionsApi.java b/quickstep/src/com/android/quickstep/ImageActionsApi.java index ba8ba3328b..b04905ca60 100644 --- a/quickstep/src/com/android/quickstep/ImageActionsApi.java +++ b/quickstep/src/com/android/quickstep/ImageActionsApi.java @@ -22,11 +22,14 @@ import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.quickstep.util.ImageActionUtils.persistBitmapAndStartActivity; +import android.app.prediction.AppTarget; import android.content.Context; import android.content.Intent; +import android.content.pm.ShortcutInfo; import android.graphics.Bitmap; import android.graphics.Insets; import android.graphics.Rect; +import android.graphics.RectF; import android.util.Log; import androidx.annotation.Nullable; @@ -96,4 +99,12 @@ public class ImageActionsApi { ImageActionUtils.saveScreenshot(mSystemUiProxy, screenshot, screenshotBounds, visibleInsets, task); } + + /** + * Share the image when user taps on overview share targets. + */ + @UiThread + public void shareImage(RectF rectF, ShortcutInfo shortcutInfo, AppTarget appTarget) { + ImageActionUtils.shareImage(mContext, mBitmapSupplier, rectF, shortcutInfo, appTarget, TAG); + } } diff --git a/quickstep/src/com/android/quickstep/util/ImageActionUtils.java b/quickstep/src/com/android/quickstep/util/ImageActionUtils.java index e998e9a7ef..d022085877 100644 --- a/quickstep/src/com/android/quickstep/util/ImageActionUtils.java +++ b/quickstep/src/com/android/quickstep/util/ImageActionUtils.java @@ -22,15 +22,19 @@ import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION; import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; +import android.app.prediction.AppTarget; import android.content.ClipData; import android.content.ClipDescription; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ShortcutInfo; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Insets; import android.graphics.Picture; import android.graphics.Rect; +import android.graphics.RectF; import android.net.Uri; import android.util.Log; @@ -70,6 +74,34 @@ public class ImageActionUtils { screenshotBounds, visibleInsets, task); } + /** + * Launch the activity to share image for overview sharing. This is to share cropped bitmap + * with specific share targets (with shortcutInfo and appTarget) rendered in overview. + */ + @UiThread + public static void shareImage(Context context, Supplier bitmapSupplier, RectF rectF, + ShortcutInfo shortcutInfo, AppTarget appTarget, String tag) { + if (bitmapSupplier.get() == null) { + return; + } + Rect crop = new Rect(); + rectF.round(crop); + Intent intent = new Intent(); + Uri uri = getImageUri(bitmapSupplier.get(), crop, context, tag); + ClipData clipdata = new ClipData(new ClipDescription("content", + new String[]{"image/png"}), + new ClipData.Item(uri)); + intent.setAction(Intent.ACTION_SEND) + .setComponent(new ComponentName(appTarget.getPackageName(), appTarget.getClassName())) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + .addFlags(FLAG_GRANT_READ_URI_PERMISSION) + .setType("image/png") + .putExtra(Intent.EXTRA_STREAM, uri) + .putExtra(Intent.EXTRA_SHORTCUT_ID, shortcutInfo.getId()) + .setClipData(clipdata); + context.startActivity(intent); + } + /** * Launch the activity to share image. */ From 5b97b40eb1be1489bef93acc965f1f019afc4cc6 Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 14 Jan 2021 13:42:35 -0800 Subject: [PATCH 19/21] Skipping QS metrics if activity is not created Test: presubmit Bug: 177472265 Change-Id: Ic92adbe589736d16ab8687ea761c32919d8c186b --- .../src/com/android/quickstep/OverviewCommandHelper.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index ec6e303830..985389ea7d 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -175,9 +175,12 @@ public class OverviewCommandHelper { return; } - InteractionJankMonitorWrapper.begin( - mActivityInterface.getCreatedActivity().getRootView(), - InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); + final T activity = mActivityInterface.getCreatedActivity(); + if (activity != null) { + InteractionJankMonitorWrapper.begin( + activity.getRootView(), + InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); + } // Otherwise, start overview. mListener = mActivityInterface.createActivityInitListener(this::onActivityReady); From 7e40d6b25a4ccafcb4e09a054c9390c0e9e143b9 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Mon, 11 Jan 2021 18:59:22 -0500 Subject: [PATCH 20/21] Added new app launch crop / positioning. New app launch crops the app window from the center, which is meant to align with the centered icon in the new preview window, and then it "reveals" the rest of the app window from center to out. Code is behind same prop as the shell starting surface. To enable: - adb shell set prop persist.debug.shell_starting_surface true - reboot Bug: 177264697 Change-Id: I78f2eab216d4bb40dedae245f47a89fe677dd6e9 --- .../QuickstepAppTransitionManagerImpl.java | 150 +++++++++++------- 1 file changed, 97 insertions(+), 53 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java index 108006b5f0..cb439d5dea 100644 --- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java @@ -56,6 +56,7 @@ import android.graphics.drawable.Drawable; import android.os.CancellationSignal; import android.os.Handler; import android.os.Looper; +import android.os.SystemProperties; import android.util.Pair; import android.view.View; @@ -99,6 +100,9 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans private static final String TAG = "QuickstepTransition"; + private static final boolean ENABLE_SHELL_STARTING_SURFACE = + SystemProperties.getBoolean("persist.debug.shell_starting_surface", false); + /** Duration of status bar animations. */ public static final int STATUS_BAR_TRANSITION_DURATION = 120; @@ -442,9 +446,9 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans RemoteAnimationTargetCompat[] appTargets, RemoteAnimationTargetCompat[] wallpaperTargets, Rect windowTargetBounds, boolean toggleVisibility) { - RectF bounds = new RectF(); + RectF launcherIconBounds = new RectF(); FloatingIconView floatingView = FloatingIconView.getFloatingIconView(mLauncher, v, - toggleVisibility, bounds, true /* isOpening */); + toggleVisibility, launcherIconBounds, true /* isOpening */); Rect crop = new Rect(); Matrix matrix = new Matrix(); @@ -458,11 +462,17 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans mDragLayer.getLocationOnScreen(dragLayerBounds); AnimOpenProperties prop = new AnimOpenProperties(mLauncher.getResources(), mDeviceProfile, - windowTargetBounds, bounds, v, dragLayerBounds); + windowTargetBounds, launcherIconBounds, v, dragLayerBounds[0], dragLayerBounds[1]); + int left = (int) (prop.cropCenterXStart - prop.cropWidthStart / 2); + int top = (int) (prop.cropCenterYStart - prop.cropHeightStart / 2); + int right = (int) (left + prop.cropWidthStart); + int bottom = (int) (top + prop.cropHeightStart); + // Set the crop here so we can calculate the corner radius below. + crop.set(left, top, right, bottom); RectF targetBounds = new RectF(windowTargetBounds); - RectF iconBounds = new RectF(); - RectF temp = new RectF(); + RectF floatingIconBounds = new RectF(); + RectF tmpRectF = new RectF(); Point tmpPos = new Point(); AnimatorSet animatorSet = new AnimatorSet(); @@ -481,68 +491,79 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans }); final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources()) - ? prop.startCrop / 2f : 0f; + ? Math.max(crop.width(), crop.height()) / 2f + : 0f; final float finalWindowRadius = mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher.getResources()); appAnimator.addUpdateListener(new MultiValueUpdateListener() { FloatProp mDx = new FloatProp(0, prop.dX, 0, prop.xDuration, AGGRESSIVE_EASE); FloatProp mDy = new FloatProp(0, prop.dY, 0, prop.yDuration, AGGRESSIVE_EASE); - FloatProp mScale = new FloatProp(prop.initialAppIconScale, + + FloatProp mIconScaleToFitScreen = new FloatProp(prop.initialAppIconScale, prop.finalAppIconScale, 0, APP_LAUNCH_DURATION, EXAGGERATED_EASE); FloatProp mIconAlpha = new FloatProp(prop.iconAlphaStart, 0f, APP_LAUNCH_ALPHA_START_DELAY, prop.alphaDuration, LINEAR); - FloatProp mCroppedSize = new FloatProp(prop.startCrop, prop.endCrop, 0, CROP_DURATION, - EXAGGERATED_EASE); + FloatProp mWindowRadius = new FloatProp(initialWindowRadius, finalWindowRadius, 0, RADIUS_DURATION, EXAGGERATED_EASE); FloatProp mShadowRadius = new FloatProp(0, mMaxShadowRadius, 0, APP_LAUNCH_DURATION, EXAGGERATED_EASE); + FloatProp mCropRectCenterX = new FloatProp(prop.cropCenterXStart, prop.cropCenterXEnd, + 0, CROP_DURATION, EXAGGERATED_EASE); + FloatProp mCropRectCenterY = new FloatProp(prop.cropCenterYStart, prop.cropCenterYEnd, + 0, CROP_DURATION, EXAGGERATED_EASE); + FloatProp mCropRectWidth = new FloatProp(prop.cropWidthStart, prop.cropWidthEnd, 0, + CROP_DURATION, EXAGGERATED_EASE); + FloatProp mCropRectHeight = new FloatProp(prop.cropHeightStart, prop.cropHeightEnd, 0, + CROP_DURATION, EXAGGERATED_EASE); + @Override public void onUpdate(float percent) { // Calculate the size of the scaled icon. - float width = bounds.width() * mScale.value; - float height = bounds.height() * mScale.value; + float iconWidth = launcherIconBounds.width() * mIconScaleToFitScreen.value; + float iconHeight = launcherIconBounds.height() * mIconScaleToFitScreen.value; - // Animate the crop so that it starts off as a square. - final int cropWidth; - final int cropHeight; - if (mDeviceProfile.isVerticalBarLayout()) { - cropWidth = (int) mCroppedSize.value; - cropHeight = windowTargetBounds.height(); - } else { - cropWidth = windowTargetBounds.width(); - cropHeight = (int) mCroppedSize.value; - } - crop.set(0, 0, cropWidth, cropHeight); + int left = (int) (mCropRectCenterX.value - mCropRectWidth.value / 2); + int top = (int) (mCropRectCenterY.value - mCropRectHeight.value / 2); + int right = (int) (left + mCropRectWidth.value); + int bottom = (int) (top + mCropRectHeight.value); + crop.set(left, top, right, bottom); + + final int windowCropWidth = crop.width(); + final int windowCropHeight = crop.height(); // Scale the size of the icon to match the size of the window crop. - float scaleX = width / cropWidth; - float scaleY = height / cropHeight; + float scaleX = iconWidth / windowCropWidth; + float scaleY = iconHeight / windowCropHeight; float scale = Math.min(1f, Math.max(scaleX, scaleY)); - float scaledCropWidth = cropWidth * scale; - float scaledCropHeight = cropHeight * scale; - float offsetX = (scaledCropWidth - width) / 2; - float offsetY = (scaledCropHeight - height) / 2; + float scaledCropWidth = windowCropWidth * scale; + float scaledCropHeight = windowCropHeight * scale; + float offsetX = (scaledCropWidth - iconWidth) / 2; + float offsetY = (scaledCropHeight - iconHeight) / 2; // Calculate the window position to match the icon position. - temp.set(bounds); - temp.offset(dragLayerBounds[0], dragLayerBounds[1]); - temp.offset(mDx.value, mDy.value); - Utilities.scaleRectFAboutCenter(temp, mScale.value); - float windowTransX0 = temp.left - offsetX; - float windowTransY0 = temp.top - offsetY; + tmpRectF.set(launcherIconBounds); + tmpRectF.offset(dragLayerBounds[0], dragLayerBounds[1]); + tmpRectF.offset(mDx.value, mDy.value); + Utilities.scaleRectFAboutCenter(tmpRectF, mIconScaleToFitScreen.value); + float windowTransX0 = tmpRectF.left - offsetX; + float windowTransY0 = tmpRectF.top - offsetY; + if (ENABLE_SHELL_STARTING_SURFACE) { + windowTransX0 -= crop.left * scale; + windowTransY0 -= crop.top * scale; + } // Calculate the icon position. - iconBounds.set(bounds); - iconBounds.offset(mDx.value, mDy.value); - Utilities.scaleRectFAboutCenter(iconBounds, mScale.value); - iconBounds.left -= offsetX; - iconBounds.top -= offsetY; - iconBounds.right += offsetX; - iconBounds.bottom += offsetY; + floatingIconBounds.set(launcherIconBounds); + floatingIconBounds.offset(mDx.value, mDy.value); + Utilities.scaleRectFAboutCenter(floatingIconBounds, mIconScaleToFitScreen.value); + floatingIconBounds.left -= offsetX; + floatingIconBounds.top -= offsetY; + floatingIconBounds.right += offsetX; + floatingIconBounds.bottom += offsetY; SurfaceParams[] params = new SurfaceParams[appTargets.length]; for (int i = appTargets.length - 1; i >= 0; i--) { @@ -553,7 +574,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans matrix.setScale(scale, scale); matrix.postTranslate(windowTransX0, windowTransY0); - floatingView.update(iconBounds, mIconAlpha.value, percent, 0f, + floatingView.update(floatingIconBounds, mIconAlpha.value, percent, 0f, mWindowRadius.value * scale, true /* isOpening */); builder.withMatrix(matrix) .withWindowCrop(crop) @@ -932,8 +953,15 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans */ static class AnimOpenProperties { - public final float startCrop; - public final float endCrop; + public final int cropCenterXStart; + public final int cropCenterYStart; + public final int cropWidthStart; + public final int cropHeightStart; + + public final int cropCenterXEnd; + public final int cropCenterYEnd; + public final int cropWidthEnd; + public final int cropHeightEnd; public final float dX; public final float dY; @@ -948,7 +976,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans public final float iconAlphaStart; AnimOpenProperties(Resources r, DeviceProfile dp, Rect windowTargetBounds, - RectF launcherIconBounds, View view, int[] dragLayerBounds) { + RectF launcherIconBounds, View view, int dragLayerLeft, int dragLayerTop) { // Scale the app icon to take up the entire screen. This simplifies the math when // animating the app window position / scale. float smallestSize = Math.min(windowTargetBounds.height(), windowTargetBounds.width()); @@ -966,8 +994,8 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans finalAppIconScale = Math.max(maxScaleX, maxScaleY); // Animate the app icon to the center of the window bounds in screen coordinates. - float centerX = windowTargetBounds.centerX() - dragLayerBounds[0]; - float centerY = windowTargetBounds.centerY() - dragLayerBounds[1]; + float centerX = windowTargetBounds.centerX() - dragLayerLeft; + float centerY = windowTargetBounds.centerY() - dragLayerTop; dX = centerX - launcherIconBounds.centerX(); dY = centerY - launcherIconBounds.centerY(); @@ -981,15 +1009,31 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans alphaDuration = useUpwardAnimation ? APP_LAUNCH_ALPHA_DURATION : APP_LAUNCH_ALPHA_DOWN_DURATION; - if (dp.isVerticalBarLayout()) { - startCrop = windowTargetBounds.height(); - endCrop = windowTargetBounds.width(); + if (ENABLE_SHELL_STARTING_SURFACE) { + iconAlphaStart = 0; + + // TOOD: Share value from shell when available. + final float windowIconSize = Utilities.pxFromSp(108, r.getDisplayMetrics()); + + cropCenterXStart = windowTargetBounds.centerX(); + cropCenterYStart = windowTargetBounds.centerY(); + + cropWidthStart = (int) windowIconSize; + cropHeightStart = (int) windowIconSize; } else { - startCrop = windowTargetBounds.width(); - endCrop = windowTargetBounds.height(); + iconAlphaStart = 1; + + cropWidthStart = cropHeightStart = + Math.min(windowTargetBounds.width(), windowTargetBounds.height()); + cropCenterXStart = cropCenterYStart = + Math.min(windowTargetBounds.centerX(), windowTargetBounds.centerY()); } - iconAlphaStart = 1f; + cropWidthEnd = windowTargetBounds.width(); + cropHeightEnd = windowTargetBounds.height(); + + cropCenterXEnd = windowTargetBounds.centerX(); + cropCenterYEnd = windowTargetBounds.centerY(); } } } From e733e79946058b749476f22284043757d3508111 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 14 Jan 2021 14:16:09 -0800 Subject: [PATCH 21/21] Fixing preview rendering in device search mode When the flag is disabled, search box may not show in preview Bug: 177500166 Test: Presubmit Change-Id: I064ba6ca22e71030056a4ceafea27e6ef0517d01 --- res/layout/launcher_preview_layout.xml | 19 ++----------------- .../graphics/LauncherPreviewRenderer.java | 11 ----------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/res/layout/launcher_preview_layout.xml b/res/layout/launcher_preview_layout.xml index 4a20c705b6..16916800f3 100644 --- a/res/layout/launcher_preview_layout.xml +++ b/res/layout/launcher_preview_layout.xml @@ -29,23 +29,8 @@ launcher:containerType="workspace" launcher:pageIndicator="@+id/page_indicator"/> - - - - - - - + layout="@layout/hotseat" /> \ No newline at end of file diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java index efc1201bba..3a9986ee42 100644 --- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java @@ -64,7 +64,6 @@ import com.android.launcher3.LauncherSettings; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.R; import com.android.launcher3.WorkspaceLayoutManager; -import com.android.launcher3.allapps.SearchUiManager; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.icons.BaseIconFactory; @@ -512,16 +511,6 @@ public class LauncherPreviewRenderer extends ContextThemeWrapper mWorkspace.addViewToCellLayout(qsb, 0, R.id.search_container_workspace, lp, true); } - // Setup search view - SearchUiManager searchUiManager = mRootView.findViewById(R.id.search_container_all_apps); - mRootView.findViewById(R.id.apps_view).setTranslationY( - mDp.heightPx - searchUiManager.getScrollRangeDelta(mInsets)); - ViewGroup searchView = (ViewGroup) searchUiManager; - searchView.setEnabled(false); - for (int i = 0; i < searchView.getChildCount(); i++) { - searchView.getChildAt(i).setEnabled(false); - } - measureView(mRootView, mDp.widthPx, mDp.heightPx); dispatchVisibilityAggregated(mRootView, true); measureView(mRootView, mDp.widthPx, mDp.heightPx);