Search in sources :

Example 36 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Trebuchet by LineageOS.

the class RecentsView method createTaskLaunchAnimation.

public PendingAnimation createTaskLaunchAnimation(TaskView tv, long duration, Interpolator interpolator) {
    if (FeatureFlags.IS_STUDIO_BUILD && mPendingAnimation != null) {
        throw new IllegalStateException("Another pending animation is still running");
    }
    int count = getTaskViewCount();
    if (count == 0) {
        return new PendingAnimation(duration);
    }
    int targetSysUiFlags = tv.getThumbnail().getSysUiStatusNavFlags();
    final boolean[] passedOverviewThreshold = new boolean[] { false };
    ValueAnimator progressAnim = ValueAnimator.ofFloat(0, 1);
    progressAnim.addUpdateListener(animator -> {
        // Once we pass a certain threshold, update the sysui flags to match the target
        // tasks' flags
        mActivity.getSystemUiController().updateUiState(UI_STATE_OVERVIEW, animator.getAnimatedFraction() > UPDATE_SYSUI_FLAGS_THRESHOLD ? targetSysUiFlags : 0);
        onTaskLaunchAnimationUpdate(animator.getAnimatedFraction(), tv);
        // Passing the threshold from taskview to fullscreen app will vibrate
        final boolean passed = animator.getAnimatedFraction() >= SUCCESS_TRANSITION_PROGRESS;
        if (passed != passedOverviewThreshold[0]) {
            passedOverviewThreshold[0] = passed;
            performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
        }
    });
    AnimatorSet anim = createAdjacentPageAnimForTaskLaunch(tv);
    DepthController depthController = getDepthController();
    if (depthController != null) {
        ObjectAnimator depthAnimator = ObjectAnimator.ofFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(mActivity));
        anim.play(depthAnimator);
    }
    anim.play(progressAnim);
    anim.setInterpolator(interpolator);
    mPendingAnimation = new PendingAnimation(duration);
    mPendingAnimation.add(anim);
    mPendingAnimation.addEndListener((endState) -> {
        if (endState.isSuccess) {
            Consumer<Boolean> onLaunchResult = (result) -> {
                onTaskLaunchAnimationEnd(result);
                if (!result) {
                    tv.notifyTaskLaunchFailed(TAG);
                }
            };
            tv.launchTask(false, onLaunchResult, getHandler());
            Task task = tv.getTask();
            if (task != null) {
                mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(endState.logAction, Direction.DOWN, indexOfChild(tv), TaskUtils.getLaunchComponentKeyForTask(task.key));
                mActivity.getStatsLogManager().logger().withItemInfo(tv.getItemInfo()).log(LAUNCHER_TASK_LAUNCH_SWIPE_DOWN);
            }
        } else {
            onTaskLaunchAnimationEnd(false);
        }
        mPendingAnimation = null;
    });
    return mPendingAnimation;
}
Also used : BACKGROUND_APP(com.android.launcher3.LauncherState.BACKGROUND_APP) HIDDEN_NO_TASKS(com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_TASKS) Overrides(com.android.launcher3.util.ResourceBasedOverride.Overrides) AccessibilityManagerCompat(com.android.launcher3.compat.AccessibilityManagerCompat) BaseActivityInterface(com.android.quickstep.BaseActivityInterface) Drawable(android.graphics.drawable.Drawable) LayoutTransition(android.animation.LayoutTransition) Handler(android.os.Handler) TAP(com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.TAP) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener) Canvas(android.graphics.Canvas) LayoutUtils(com.android.quickstep.util.LayoutUtils) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) TargetApi(android.annotation.TargetApi) CLEAR_ALL_BUTTON(com.android.launcher3.userevent.nano.LauncherLogProto.ControlType.CLEAR_ALL_BUTTON) TaskVisualsChangeListener(com.android.quickstep.RecentsModel.TaskVisualsChangeListener) RecentsAnimationTargets(com.android.quickstep.RecentsAnimationTargets) HIDDEN_NO_RECENTS(com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_RECENTS) Interpolator(android.view.animation.Interpolator) HIDDEN_NON_ZERO_ROTATION(com.android.quickstep.views.OverviewActionsView.HIDDEN_NON_ZERO_ROTATION) DeviceProfile(com.android.launcher3.DeviceProfile) HapticFeedbackConstants(android.view.HapticFeedbackConstants) LAUNCHER_TASK_LAUNCH_SWIPE_DOWN(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_SWIPE_DOWN) Nullable(androidx.annotation.Nullable) Layout(android.text.Layout) TextPaint(android.text.TextPaint) CurveProperties(com.android.launcher3.touch.PagedOrientationHandler.CurveProperties) LauncherLogProto(com.android.launcher3.userevent.nano.LauncherLogProto) TaskKey(com.android.systemui.shared.recents.model.Task.TaskKey) Insettable(com.android.launcher3.Insettable) EndState(com.android.launcher3.anim.PendingAnimation.EndState) Utilities.squaredTouchSlop(com.android.launcher3.Utilities.squaredTouchSlop) SystemUiProxy(com.android.quickstep.SystemUiProxy) ArrayList(java.util.ArrayList) TransformParams(com.android.quickstep.util.TransformParams) TaskUtils.checkCurrentOrManagedUserId(com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId) SplitScreenBounds(com.android.quickstep.util.SplitScreenBounds) UserHandle(android.os.UserHandle) Utilities.mapToRange(com.android.launcher3.Utilities.mapToRange) DEPTH(com.android.launcher3.statehandlers.DepthController.DEPTH) MeasureSpec.makeMeasureSpec(android.view.View.MeasureSpec.makeMeasureSpec) SpringProperty(com.android.launcher3.anim.SpringProperty) ViewPool(com.android.launcher3.util.ViewPool) ViewDebug(android.view.ViewDebug) FeatureFlags(com.android.launcher3.config.FeatureFlags) DynamicResource(com.android.launcher3.util.DynamicResource) OVERVIEW_MODAL_TASK(com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK) Direction(com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) SparseBooleanArray(android.util.SparseBooleanArray) R(com.android.launcher3.R) Configuration(android.content.res.Configuration) ComponentKey(com.android.launcher3.util.ComponentKey) IPinnedStackAnimationListener(com.android.systemui.shared.recents.IPinnedStackAnimationListener) ACCEL(com.android.launcher3.anim.Interpolators.ACCEL) UI_STATE_OVERVIEW(com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW) ValueAnimator(android.animation.ValueAnimator) Rect(android.graphics.Rect) PackageManagerWrapper(com.android.systemui.shared.system.PackageManagerWrapper) PointF(android.graphics.PointF) Task(com.android.systemui.shared.recents.model.Task) FloatProperty(android.util.FloatProperty) AttributeSet(android.util.AttributeSet) ActivityManagerWrapper(com.android.systemui.shared.system.ActivityManagerWrapper) View(android.view.View) LauncherEventUtil(com.android.systemui.shared.system.LauncherEventUtil) RectF(android.graphics.RectF) Utilities(com.android.launcher3.Utilities) TransitionListener(android.animation.LayoutTransition.TransitionListener) UI_HELPER_EXECUTOR(com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR) DepthController(com.android.launcher3.statehandlers.DepthController) ObjectAnimator(android.animation.ObjectAnimator) EDGE_NAV_BAR(com.android.launcher3.Utilities.EDGE_NAV_BAR) TaskUtils(com.android.quickstep.TaskUtils) TaskStackChangeListener(com.android.systemui.shared.system.TaskStackChangeListener) ROTATION_0(android.view.Surface.ROTATION_0) ViewGroup(android.view.ViewGroup) MultiValueAlpha(com.android.launcher3.util.MultiValueAlpha) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData) ListView(android.widget.ListView) Themes(com.android.launcher3.util.Themes) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) SUCCESS_TRANSITION_PROGRESS(com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController.SUCCESS_TRANSITION_PROGRESS) Typeface(android.graphics.Typeface) Context(android.content.Context) StaticLayout(android.text.StaticLayout) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) TaskThumbnailCache(com.android.quickstep.TaskThumbnailCache) CHANGE_FLAG_ICON_PARAMS(com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS) KeyEvent(android.view.KeyEvent) HIDDEN_GESTURE_RUNNING(com.android.quickstep.views.OverviewActionsView.HIDDEN_GESTURE_RUNNING) RunningTaskInfo(android.app.ActivityManager.RunningTaskInfo) EXACTLY(android.view.View.MeasureSpec.EXACTLY) STATE_HANDLER_INVISIBILITY_FLAGS(com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS) Touch(com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch) LAUNCHER_TASK_DISMISS_SWIPE_UP(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_DISMISS_SWIPE_UP) FAST_OUT_SLOW_IN(com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) Utilities.squaredHypot(com.android.launcher3.Utilities.squaredHypot) ENABLE_QUICKSTEP_LIVE_TILE(com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE) MotionEvent(android.view.MotionEvent) BaseActivity(com.android.launcher3.BaseActivity) AnimatorSet(android.animation.AnimatorSet) Build(android.os.Build) TaskOverlayFactory(com.android.quickstep.TaskOverlayFactory) OverScroller(com.android.launcher3.util.OverScroller) LayoutInflater(android.view.LayoutInflater) RecentsAnimationController(com.android.quickstep.RecentsAnimationController) StatefulActivity(com.android.launcher3.statemanager.StatefulActivity) Point(android.graphics.Point) ACCEL_2(com.android.launcher3.anim.Interpolators.ACCEL_2) RecentsOrientedState(com.android.quickstep.util.RecentsOrientedState) ResourceProvider(com.android.systemui.plugins.ResourceProvider) VIEW_ALPHA(com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA) LauncherState(com.android.launcher3.LauncherState) Consumer(java.util.function.Consumer) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) PropertyListBuilder(com.android.launcher3.anim.PropertyListBuilder) RecentsModel(com.android.quickstep.RecentsModel) PagedView(com.android.launcher3.PagedView) ACCEL_0_75(com.android.launcher3.anim.Interpolators.ACCEL_0_75) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) PendingAnimation(com.android.launcher3.anim.PendingAnimation) ViewUtils(com.android.quickstep.ViewUtils) PendingAnimation(com.android.launcher3.anim.PendingAnimation) Task(com.android.systemui.shared.recents.model.Task) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) DepthController(com.android.launcher3.statehandlers.DepthController) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 37 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Trebuchet by LineageOS.

the class Launcher method onNewIntent.

@Override
protected void onNewIntent(Intent intent) {
    if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
        Log.d(TestProtocol.PERMANENT_DIAG_TAG, "Launcher.onNewIntent: " + intent);
    }
    Object traceToken = TraceHelper.INSTANCE.beginSection(ON_NEW_INTENT_EVT);
    super.onNewIntent(intent);
    boolean alreadyOnHome = hasWindowFocus() && ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    // Check this condition before handling isActionMain, as this will get reset.
    boolean shouldMoveToDefaultScreen = alreadyOnHome && isInState(NORMAL) && AbstractFloatingView.getTopOpenView(this) == null;
    boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction());
    boolean internalStateHandled = ACTIVITY_TRACKER.handleNewIntent(this, intent);
    if (isActionMain) {
        if (!internalStateHandled) {
            // In all these cases, only animate if we're already on home
            closeOpenViews(isStarted());
            if (!isInState(NORMAL)) {
                // Only change state, if not already the same. This prevents cancelling any
                // animations running as part of resume
                mStateManager.goToState(NORMAL, mStateManager.shouldAnimateStateChange(), this::handlePendingActivityRequest);
            }
            // Reset the apps view
            if (!alreadyOnHome) {
                mAppsView.reset(isStarted());
            }
            if (shouldMoveToDefaultScreen && !mWorkspace.isHandlingTouch()) {
                mWorkspace.post(mWorkspace::moveToDefaultScreen);
            }
        }
        // Handle HOME_INTENT
        UserEventDispatcher ued = getUserEventDispatcher();
        Target target = newContainerTarget(mStateManager.getState().containerType);
        target.pageIndex = mWorkspace.getCurrentPage();
        ued.logActionCommand(Action.Command.HOME_INTENT, target, newContainerTarget(ContainerType.WORKSPACE));
        hideKeyboard();
        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onHomeIntent(internalStateHandled);
        }
        mOverlayManager.hideOverlay(isStarted() && !isForceInvisible());
        handleGestureContract(intent);
    } else if (Intent.ACTION_ALL_APPS.equals(intent.getAction())) {
        getStateManager().goToState(ALL_APPS, alreadyOnHome);
    }
    TraceHelper.INSTANCE.endSection(traceToken);
}
Also used : UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) LoggerUtils.newContainerTarget(com.android.launcher3.logging.LoggerUtils.newContainerTarget) DragObject(com.android.launcher3.DropTarget.DragObject)

Example 38 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Trebuchet by LineageOS.

the class NoButtonQuickSwitchTouchController method onDragEnd.

@Override
public void onDragEnd(PointF velocity) {
    boolean horizontalFling = mSwipeDetector.isFling(velocity.x);
    boolean verticalFling = mSwipeDetector.isFling(velocity.y);
    boolean noFling = !horizontalFling && !verticalFling;
    int logAction = noFling ? Touch.SWIPE : Touch.FLING;
    if (mMotionPauseDetector.isPaused() && noFling) {
        cancelAnimations();
        Animator overviewAnim = mLauncher.createAtomicAnimationFactory().createStateElementAnimation(INDEX_PAUSE_TO_OVERVIEW_ANIM);
        overviewAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                onAnimationToStateCompleted(OVERVIEW, logAction);
            }
        });
        overviewAnim.start();
        return;
    }
    final LauncherState targetState;
    if (horizontalFling && verticalFling) {
        if (velocity.x < 0) {
            // Flinging left and up or down both go back home.
            targetState = NORMAL;
        } else {
            if (velocity.y > 0) {
                // Flinging right and down goes to quick switch.
                targetState = QUICK_SWITCH;
            } else {
                // Flinging up and right could go either home or to quick switch.
                // Determine the target based on the higher velocity.
                targetState = Math.abs(velocity.x) > Math.abs(velocity.y) ? QUICK_SWITCH : NORMAL;
            }
        }
    } else if (horizontalFling) {
        targetState = velocity.x > 0 ? QUICK_SWITCH : NORMAL;
    } else if (verticalFling) {
        targetState = velocity.y > 0 ? QUICK_SWITCH : NORMAL;
    } else {
        // If user isn't flinging, just snap to the closest state.
        boolean passedHorizontalThreshold = mXOverviewAnim.getInterpolatedProgress() > 0.5f;
        boolean passedVerticalThreshold = mYOverviewAnim.value > 1f;
        targetState = passedHorizontalThreshold && !passedVerticalThreshold ? QUICK_SWITCH : NORMAL;
    }
    // Animate the various components to the target state.
    float xProgress = mXOverviewAnim.getProgressFraction();
    float startXProgress = Utilities.boundToRange(xProgress + velocity.x * getSingleFrameMs(mLauncher) / mXRange, 0f, 1f);
    final float endXProgress = targetState == NORMAL ? 0 : 1;
    long xDuration = BaseSwipeDetector.calculateDuration(velocity.x, Math.abs(endXProgress - startXProgress));
    ValueAnimator xOverviewAnim = mXOverviewAnim.getAnimationPlayer();
    xOverviewAnim.setFloatValues(startXProgress, endXProgress);
    xOverviewAnim.setDuration(xDuration).setInterpolator(scrollInterpolatorForVelocity(velocity.x));
    mXOverviewAnim.dispatchOnStart();
    boolean flingUpToNormal = verticalFling && velocity.y < 0 && targetState == NORMAL;
    float yProgress = mYOverviewAnim.value;
    float startYProgress = Utilities.boundToRange(yProgress - velocity.y * getSingleFrameMs(mLauncher) / mYRange, 0f, mMaxYProgress);
    final float endYProgress;
    if (flingUpToNormal) {
        endYProgress = 1;
    } else if (targetState == NORMAL) {
        // Keep overview at its current scale/translationY as it slides off the screen.
        endYProgress = startYProgress;
    } else {
        endYProgress = 0;
    }
    float yDistanceToCover = Math.abs(endYProgress - startYProgress) * mYRange;
    long yDuration = (long) (yDistanceToCover / Math.max(1f, Math.abs(velocity.y)));
    ValueAnimator yOverviewAnim = mYOverviewAnim.animateToValue(startYProgress, endYProgress);
    yOverviewAnim.setDuration(yDuration);
    mYOverviewAnim.updateValue(startYProgress);
    ValueAnimator nonOverviewAnim = mNonOverviewAnim.getAnimationPlayer();
    if (flingUpToNormal && !mIsHomeScreenVisible) {
        // We are flinging to home while workspace is invisible, run the same staggered
        // animation as from an app.
        StateAnimationConfig config = new StateAnimationConfig();
        // Update mNonOverviewAnim to do nothing so it doesn't interfere.
        config.animFlags = 0;
        updateNonOverviewAnim(targetState, config);
        nonOverviewAnim = mNonOverviewAnim.getAnimationPlayer();
        new StaggeredWorkspaceAnim(mLauncher, velocity.y, false).start();
    } else {
        boolean canceled = targetState == NORMAL;
        if (canceled) {
            // Let the state manager know that the animation didn't go to the target state,
            // but don't clean up yet (we already clean up when the animation completes).
            mNonOverviewAnim.dispatchOnCancelWithoutCancelRunnable();
        }
        float startProgress = mNonOverviewAnim.getProgressFraction();
        float endProgress = canceled ? 0 : 1;
        nonOverviewAnim.setFloatValues(startProgress, endProgress);
        mNonOverviewAnim.dispatchOnStart();
    }
    nonOverviewAnim.setDuration(Math.max(xDuration, yDuration));
    mNonOverviewAnim.setEndAction(() -> onAnimationToStateCompleted(targetState, logAction));
    cancelAnimations();
    xOverviewAnim.start();
    yOverviewAnim.start();
    nonOverviewAnim.start();
}
Also used : LauncherState(com.android.launcher3.LauncherState) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) StaggeredWorkspaceAnim(com.android.quickstep.util.StaggeredWorkspaceAnim) ValueAnimator(android.animation.ValueAnimator)

Example 39 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Trebuchet by LineageOS.

the class HotseatPredictionController method encodeHotseatLayoutIntoPredictionRank.

/**
 * Fill in predicted_rank field based on app prediction.
 * Only applicable when {@link ItemInfo#itemType} is PREDICTED_HOTSEAT
 */
public static void encodeHotseatLayoutIntoPredictionRank(@NonNull ItemInfo itemInfo, @NonNull LauncherLogProto.Target target) {
    QuickstepLauncher launcher = QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity();
    if (launcher == null || launcher.getHotseatPredictionController() == null || itemInfo.getTargetComponent() == null) {
        return;
    }
    HotseatPredictionController controller = launcher.getHotseatPredictionController();
    final ComponentKey k = new ComponentKey(itemInfo.getTargetComponent(), itemInfo.user);
    final List<ComponentKeyMapper> predictedApps = controller.mComponentKeyMappers;
    OptionalInt rank = IntStream.range(0, predictedApps.size()).filter((i) -> k.equals(predictedApps.get(i).getComponentKey())).findFirst();
    target.predictedRank = 10000 + (controller.mPredictedSpotsCount * 100) + (rank.isPresent() ? rank.getAsInt() + 1 : 0);
}
Also used : ComponentKeyMapper(com.android.launcher3.appprediction.ComponentKeyMapper) NonNull(androidx.annotation.NonNull) Animator(android.animation.Animator) LauncherSettings(com.android.launcher3.LauncherSettings) DynamicItemCache(com.android.launcher3.appprediction.DynamicItemCache) IconCache(com.android.launcher3.icons.IconCache) AppTarget(android.app.prediction.AppTarget) Process(android.os.Process) ShortcutKey(com.android.launcher3.shortcuts.ShortcutKey) LAUNCHER_HOTSEAT_RANKED(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_RANKED) HotseatEduController.getSettingsIntent(com.android.launcher3.hybridhotseat.HotseatEduController.getSettingsIntent) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener) SCALE_PROPERTY(com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY) Log(android.util.Log) Utilities(com.android.launcher3.Utilities) AppPredictor(android.app.prediction.AppPredictor) QuickstepLauncher(com.android.launcher3.uioverrides.QuickstepLauncher) Launcher(com.android.launcher3.Launcher) ObjectAnimator(android.animation.ObjectAnimator) AppPredictionManager(android.app.prediction.AppPredictionManager) AllAppsStore(com.android.launcher3.allapps.AllAppsStore) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) ViewGroup(android.view.ViewGroup) DragOptions(com.android.launcher3.dragndrop.DragOptions) HapticFeedbackConstants(android.view.HapticFeedbackConstants) List(java.util.List) Nullable(androidx.annotation.Nullable) AppPredictionContext(android.app.prediction.AppPredictionContext) NORMAL(com.android.launcher3.LauncherState.NORMAL) LauncherLogProto(com.android.launcher3.userevent.nano.LauncherLogProto) IntStream(java.util.stream.IntStream) AppInfo(com.android.launcher3.model.data.AppInfo) ContainerInfo(com.android.launcher3.logger.LauncherAtom.ContainerInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) Snackbar(com.android.launcher3.views.Snackbar) OptionalInt(java.util.OptionalInt) ArrayList(java.util.ArrayList) ItemLongClickListener(com.android.launcher3.touch.ItemLongClickListener) PredictedHotseatContainer(com.android.launcher3.logger.LauncherAtom.PredictedHotseatContainer) AppTargetEvent(android.app.prediction.AppTargetEvent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimatorSet(android.animation.AnimatorSet) DragSource(com.android.launcher3.DragSource) WeakReference(java.lang.ref.WeakReference) SystemShortcut(com.android.launcher3.popup.SystemShortcut) CHANGE_FLAG_GRID(com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_GRID) IntArray(com.android.launcher3.util.IntArray) InstanceId(com.android.launcher3.logging.InstanceId) ArrowTipView(com.android.launcher3.views.ArrowTipView) ComponentName(android.content.ComponentName) DropTarget(com.android.launcher3.DropTarget) LauncherAppState(com.android.launcher3.LauncherAppState) DragController(com.android.launcher3.dragndrop.DragController) OnboardingPrefs(com.android.launcher3.util.OnboardingPrefs) Hotseat(com.android.launcher3.Hotseat) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) R(com.android.launcher3.R) ComponentKey(com.android.launcher3.util.ComponentKey) Collections(java.util.Collections) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) ComponentKey(com.android.launcher3.util.ComponentKey) QuickstepLauncher(com.android.launcher3.uioverrides.QuickstepLauncher) OptionalInt(java.util.OptionalInt) ComponentKeyMapper(com.android.launcher3.appprediction.ComponentKeyMapper)

Example 40 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Trebuchet by LineageOS.

the class PredictionUiStateManager method fillInPredictedRank.

/**
 * Fill in predicted_rank field based on app prediction.
 * Only applicable when {@link ItemInfo#itemType} is one of the followings:
 * {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION},
 * {@link LauncherSettings.Favorites#ITEM_TYPE_SHORTCUT},
 * {@link LauncherSettings.Favorites#ITEM_TYPE_DEEP_SHORTCUT}
 */
public static void fillInPredictedRank(@NonNull ItemInfo itemInfo, @NonNull LauncherLogProto.Target target) {
    final PredictionUiStateManager manager = PredictionUiStateManager.INSTANCE.getNoCreate();
    if (manager == null || itemInfo.getTargetComponent() == null || itemInfo.user == null || (itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT && itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT)) {
        return;
    }
    if (itemInfo.container != LauncherSettings.Favorites.CONTAINER_PREDICTION) {
        HotseatPredictionController.encodeHotseatLayoutIntoPredictionRank(itemInfo, target);
        return;
    }
    final ComponentKey k = new ComponentKey(itemInfo.getTargetComponent(), itemInfo.user);
    final List<ComponentKeyMapper> predictedApps = manager.getCurrentState().apps;
    IntStream.range(0, predictedApps.size()).filter((i) -> k.equals(predictedApps.get(i).getComponentKey())).findFirst().ifPresent((rank) -> target.predictedRank = 0 - rank);
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey)

Aggregations

View (android.view.View)85 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)59 Point (android.graphics.Point)42 Rect (android.graphics.Rect)41 AppWidgetHostView (android.appwidget.AppWidgetHostView)40 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)38 ItemInfo (com.android.launcher3.model.data.ItemInfo)37 Animator (android.animation.Animator)35 ValueAnimator (android.animation.ValueAnimator)35 Target (com.android.launcher3.userevent.nano.LauncherLogProto.Target)35 BubbleTextView (com.android.launcher3.BubbleTextView)34 DropTarget (com.android.launcher3.DropTarget)32 DragView (com.android.launcher3.dragndrop.DragView)30 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)30 AnimatorSet (android.animation.AnimatorSet)29 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)29 ComponentName (android.content.ComponentName)28 ObjectAnimator (android.animation.ObjectAnimator)27 DraggableView (com.android.launcher3.dragndrop.DraggableView)26 AppInfo (com.android.launcher3.model.data.AppInfo)26