Search in sources :

Example 86 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ArrowOS.

the class AllAppsList method updatePackage.

/**
 * Add and remove icons for this package which has been updated.
 */
public List<LauncherActivityInfo> updatePackage(Context context, String packageName, UserHandle user) {
    final List<LauncherActivityInfo> matches = context.getSystemService(LauncherApps.class).getActivityList(packageName, user);
    if (matches.size() > 0) {
        // to the removed list.
        for (int i = data.size() - 1; i >= 0; i--) {
            final AppInfo applicationInfo = data.get(i);
            if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) {
                if (!findActivity(matches, applicationInfo.componentName)) {
                    Log.w(TAG, "Changing shortcut target due to app component name change.");
                    removeApp(i);
                }
            }
        }
        // Also updates existing activities with new labels/icons
        for (final LauncherActivityInfo info : matches) {
            AppInfo applicationInfo = findAppInfo(info.getComponentName(), user);
            if (applicationInfo == null) {
                add(new AppInfo(context, info, user), info);
            } else {
                Intent launchIntent = AppInfo.makeLaunchIntent(info);
                mIconCache.getTitleAndIcon(applicationInfo, info, false);
                applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title);
                applicationInfo.setProgressLevel(PackageManagerHelper.getLoadingProgress(info), PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
                applicationInfo.intent = launchIntent;
                mDataChanged = true;
            }
        }
    } else {
        // Remove all data for this package.
        for (int i = data.size() - 1; i >= 0; i--) {
            final AppInfo applicationInfo = data.get(i);
            if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) {
                mIconCache.remove(applicationInfo.componentName, user);
                removeApp(i);
            }
        }
    }
    return matches;
}
Also used : LauncherActivityInfo(android.content.pm.LauncherActivityInfo) LauncherApps(android.content.pm.LauncherApps) Intent(android.content.Intent) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 87 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ArrowOS.

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;
    if (mMotionPauseDetector.isPaused() && noFling) {
        cancelAnimations();
        StateAnimationConfig config = new StateAnimationConfig();
        config.duration = ATOMIC_DURATION_FROM_PAUSED_TO_OVERVIEW;
        Animator overviewAnim = mLauncher.getStateManager().createAtomicAnimation(mStartState, OVERVIEW, config);
        overviewAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                onAnimationToStateCompleted(OVERVIEW);
            }
        });
        overviewAnim.start();
        // Create an empty state transition so StateListeners get onStateTransitionStart().
        mLauncher.getStateManager().createAnimationToNewWorkspace(OVERVIEW, config.duration, StateAnimationConfig.SKIP_ALL_ANIMATIONS).dispatchOnStart();
        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 = SKIP_ALL_ANIMATIONS;
        updateNonOverviewAnim(targetState, config);
        nonOverviewAnim = mNonOverviewAnim.getAnimationPlayer();
        mNonOverviewAnim.dispatchOnStart();
        new WorkspaceRevealAnim(mLauncher, 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.getTarget().removeListener(mClearStateOnCancelListener);
            mNonOverviewAnim.dispatchOnCancel();
        }
        float startProgress = mNonOverviewAnim.getProgressFraction();
        float endProgress = canceled ? 0 : 1;
        nonOverviewAnim.setFloatValues(startProgress, endProgress);
        mNonOverviewAnim.dispatchOnStart();
    }
    if (targetState == QUICK_SWITCH) {
        // Navigating to quick switch, add scroll feedback since the first time is not
        // considered a scroll by the RecentsView.
        VibratorWrapper.INSTANCE.get(mLauncher).vibrate(RecentsView.SCROLL_VIBRATION_PRIMITIVE, RecentsView.SCROLL_VIBRATION_PRIMITIVE_SCALE, RecentsView.SCROLL_VIBRATION_FALLBACK);
    }
    nonOverviewAnim.setDuration(Math.max(xDuration, yDuration));
    mNonOverviewAnim.setEndAction(() -> onAnimationToStateCompleted(targetState));
    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) ValueAnimator(android.animation.ValueAnimator) WorkspaceRevealAnim(com.android.quickstep.util.WorkspaceRevealAnim)

Example 88 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ArrowOS.

the class TaskViewTouchController method reInitAnimationController.

private void reInitAnimationController(boolean goingUp) {
    if (mCurrentAnimation != null && mCurrentAnimationIsGoingUp == goingUp) {
        // No need to init
        return;
    }
    if ((goingUp && !mAllowGoingUp) || (!goingUp && !mAllowGoingDown)) {
        // Trying to re-init in an unsupported direction.
        return;
    }
    if (mCurrentAnimation != null) {
        mCurrentAnimation.setPlayFraction(0);
        mCurrentAnimation.getTarget().removeListener(this);
        mCurrentAnimation.dispatchOnCancel();
    }
    PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
    mCurrentAnimationIsGoingUp = goingUp;
    BaseDragLayer dl = mActivity.getDragLayer();
    final int secondaryLayerDimension = orientationHandler.getSecondaryDimension(dl);
    long maxDuration = 2 * secondaryLayerDimension;
    int verticalFactor = orientationHandler.getTaskDragDisplacementFactor(mIsRtl);
    int secondaryTaskDimension = orientationHandler.getSecondaryDimension(mTaskBeingDragged);
    // The interpolator controlling the most prominent visual movement. We use this to determine
    // whether we passed SUCCESS_TRANSITION_PROGRESS.
    final Interpolator currentInterpolator;
    PendingAnimation pa;
    if (goingUp) {
        currentInterpolator = Interpolators.LINEAR;
        pa = mRecentsView.createTaskDismissAnimation(mTaskBeingDragged, true, /* animateTaskView */
        true, /* removeTask */
        maxDuration, false);
        mEndDisplacement = -secondaryTaskDimension;
    } else {
        currentInterpolator = Interpolators.ZOOM_IN;
        pa = mRecentsView.createTaskLaunchAnimation(mTaskBeingDragged, maxDuration, currentInterpolator);
        // Since the thumbnail is what is filling the screen, based the end displacement on it.
        View thumbnailView = mTaskBeingDragged.getThumbnail();
        mTempCords[1] = orientationHandler.getSecondaryDimension(thumbnailView);
        dl.getDescendantCoordRelativeToSelf(thumbnailView, mTempCords);
        mEndDisplacement = secondaryLayerDimension - mTempCords[1];
    }
    mEndDisplacement *= verticalFactor;
    mCurrentAnimation = pa.createPlaybackController();
    // Setting this interpolator doesn't affect the visual motion, but is used to determine
    // whether we successfully reached the target state in onDragEnd().
    mCurrentAnimation.getTarget().setInterpolator(currentInterpolator);
    onUserControlledAnimationCreated(mCurrentAnimation);
    mCurrentAnimation.getTarget().addListener(this);
    mCurrentAnimation.dispatchOnStart();
    mProgressMultiplier = 1 / mEndDisplacement;
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) Interpolator(android.view.animation.Interpolator) TaskView(com.android.quickstep.views.TaskView) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 89 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ProtonAOSP.

the class QuickstepTransitionManager method getOpeningWindowAnimators.

/**
 * @return Animator that controls the window of the opening targets from app icons.
 */
private Animator getOpeningWindowAnimators(View v, RemoteAnimationTargetCompat[] appTargets, RemoteAnimationTargetCompat[] wallpaperTargets, RemoteAnimationTargetCompat[] nonAppTargets, Rect windowTargetBounds, boolean appTargetsAreTranslucent, int rotationChange) {
    RectF launcherIconBounds = new RectF();
    FloatingIconView floatingView = FloatingIconView.getFloatingIconView(mLauncher, v, !appTargetsAreTranslucent, launcherIconBounds, true);
    Rect crop = new Rect();
    Matrix matrix = new Matrix();
    RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets, wallpaperTargets, nonAppTargets, MODE_OPENING);
    SurfaceTransactionApplier surfaceApplier = new SurfaceTransactionApplier(floatingView);
    openingTargets.addReleaseCheck(surfaceApplier);
    RemoteAnimationTargetCompat navBarTarget = openingTargets.getNavBarRemoteAnimationTarget();
    int[] dragLayerBounds = new int[2];
    mDragLayer.getLocationOnScreen(dragLayerBounds);
    final boolean hasSplashScreen;
    if (supportsSSplashScreen()) {
        int taskId = openingTargets.getFirstAppTargetTaskId();
        Pair<Integer, Integer> defaultParams = Pair.create(STARTING_WINDOW_TYPE_NONE, 0);
        Pair<Integer, Integer> taskParams = mTaskStartParams.getOrDefault(taskId, defaultParams);
        mTaskStartParams.remove(taskId);
        hasSplashScreen = taskParams.first == STARTING_WINDOW_TYPE_SPLASH_SCREEN;
    } else {
        hasSplashScreen = false;
    }
    AnimOpenProperties prop = new AnimOpenProperties(mLauncher.getResources(), mDeviceProfile, windowTargetBounds, launcherIconBounds, v, dragLayerBounds[0], dragLayerBounds[1], hasSplashScreen, floatingView.isDifferentFromAppIcon());
    int left = prop.cropCenterXStart - prop.cropWidthStart / 2;
    int top = prop.cropCenterYStart - prop.cropHeightStart / 2;
    int right = left + prop.cropWidthStart;
    int bottom = top + prop.cropHeightStart;
    // Set the crop here so we can calculate the corner radius below.
    crop.set(left, top, right, bottom);
    RectF floatingIconBounds = new RectF();
    RectF tmpRectF = new RectF();
    Point tmpPos = new Point();
    AnimatorSet animatorSet = new AnimatorSet();
    ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
    appAnimator.setDuration(APP_LAUNCH_DURATION);
    appAnimator.setInterpolator(LINEAR);
    appAnimator.addListener(floatingView);
    appAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (v instanceof BubbleTextView) {
                ((BubbleTextView) v).setStayPressed(false);
            }
            LauncherTaskbarUIController taskbarController = mLauncher.getTaskbarUIController();
            if (taskbarController != null) {
                taskbarController.showEdu();
            }
            openingTargets.release();
        }
    });
    final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources()) ? Math.max(crop.width(), crop.height()) / 2f : 0f;
    final float finalWindowRadius = mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher);
    final float finalShadowRadius = appTargetsAreTranslucent ? 0 : mMaxShadowRadius;
    MultiValueUpdateListener listener = new MultiValueUpdateListener() {

        FloatProp mDx = new FloatProp(0, prop.dX, 0, APP_LAUNCH_DURATION, mOpeningXInterpolator);

        FloatProp mDy = new FloatProp(0, prop.dY, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mIconScaleToFitScreen = new FloatProp(prop.initialAppIconScale, prop.finalAppIconScale, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mIconAlpha = new FloatProp(prop.iconAlphaStart, 0f, APP_LAUNCH_ALPHA_START_DELAY, APP_LAUNCH_ALPHA_DURATION, LINEAR);

        FloatProp mWindowRadius = new FloatProp(initialWindowRadius, finalWindowRadius, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mShadowRadius = new FloatProp(0, finalShadowRadius, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mCropRectCenterX = new FloatProp(prop.cropCenterXStart, prop.cropCenterXEnd, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mCropRectCenterY = new FloatProp(prop.cropCenterYStart, prop.cropCenterYEnd, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mCropRectWidth = new FloatProp(prop.cropWidthStart, prop.cropWidthEnd, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mCropRectHeight = new FloatProp(prop.cropHeightStart, prop.cropHeightEnd, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mNavFadeOut = new FloatProp(1f, 0f, 0, ANIMATION_NAV_FADE_OUT_DURATION, NAV_FADE_OUT_INTERPOLATOR);

        FloatProp mNavFadeIn = new FloatProp(0f, 1f, ANIMATION_DELAY_NAV_FADE_IN, ANIMATION_NAV_FADE_IN_DURATION, NAV_FADE_IN_INTERPOLATOR);

        @Override
        public void onUpdate(float percent, boolean initOnly) {
            // Calculate the size of the scaled icon.
            float iconWidth = launcherIconBounds.width() * mIconScaleToFitScreen.value;
            float iconHeight = launcherIconBounds.height() * mIconScaleToFitScreen.value;
            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();
            if (rotationChange != 0) {
                Utilities.rotateBounds(crop, mDeviceProfile.widthPx, mDeviceProfile.heightPx, rotationChange);
            }
            // Scale the size of the icon to match the size of the window crop.
            float scaleX = iconWidth / windowCropWidth;
            float scaleY = iconHeight / windowCropHeight;
            float scale = Math.min(1f, Math.max(scaleX, scaleY));
            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.
            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 - crop.left * scale;
            float windowTransY0 = tmpRectF.top - offsetY - crop.top * scale;
            // Calculate the icon position.
            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;
            if (initOnly) {
                // For the init pass, we want full alpha since the window is not yet ready.
                floatingView.update(1f, 255, floatingIconBounds, percent, 0f, mWindowRadius.value * scale, true);
                return;
            }
            ArrayList<SurfaceParams> params = new ArrayList<>();
            for (int i = appTargets.length - 1; i >= 0; i--) {
                RemoteAnimationTargetCompat target = appTargets[i];
                SurfaceParams.Builder builder = new SurfaceParams.Builder(target.leash);
                if (target.mode == MODE_OPENING) {
                    matrix.setScale(scale, scale);
                    if (rotationChange == 1) {
                        matrix.postTranslate(windowTransY0, mDeviceProfile.widthPx - (windowTransX0 + scaledCropWidth));
                    } else if (rotationChange == 2) {
                        matrix.postTranslate(mDeviceProfile.widthPx - (windowTransX0 + scaledCropWidth), mDeviceProfile.heightPx - (windowTransY0 + scaledCropHeight));
                    } else if (rotationChange == 3) {
                        matrix.postTranslate(mDeviceProfile.heightPx - (windowTransY0 + scaledCropHeight), windowTransX0);
                    } else {
                        matrix.postTranslate(windowTransX0, windowTransY0);
                    }
                    floatingView.update(mIconAlpha.value, 255, floatingIconBounds, percent, 0f, mWindowRadius.value * scale, true);
                    builder.withMatrix(matrix).withWindowCrop(crop).withAlpha(1f - mIconAlpha.value).withCornerRadius(mWindowRadius.value).withShadowRadius(mShadowRadius.value);
                } else if (target.mode == MODE_CLOSING) {
                    if (target.localBounds != null) {
                        final Rect localBounds = target.localBounds;
                        tmpPos.set(target.localBounds.left, target.localBounds.top);
                    } else {
                        tmpPos.set(target.position.x, target.position.y);
                    }
                    final Rect crop = new Rect(target.screenSpaceBounds);
                    crop.offsetTo(0, 0);
                    if ((rotationChange % 2) == 1) {
                        int tmp = crop.right;
                        crop.right = crop.bottom;
                        crop.bottom = tmp;
                        tmp = tmpPos.x;
                        tmpPos.x = tmpPos.y;
                        tmpPos.y = tmp;
                    }
                    matrix.setTranslate(tmpPos.x, tmpPos.y);
                    builder.withMatrix(matrix).withWindowCrop(crop).withAlpha(1f);
                }
                params.add(builder.build());
            }
            if (navBarTarget != null) {
                final SurfaceParams.Builder navBuilder = new SurfaceParams.Builder(navBarTarget.leash);
                if (mNavFadeIn.value > mNavFadeIn.getStartValue()) {
                    matrix.setScale(scale, scale);
                    matrix.postTranslate(windowTransX0, windowTransY0);
                    navBuilder.withMatrix(matrix).withWindowCrop(crop).withAlpha(mNavFadeIn.value);
                } else {
                    navBuilder.withAlpha(mNavFadeOut.value);
                }
                params.add(navBuilder.build());
            }
            surfaceApplier.scheduleApply(params.toArray(new SurfaceParams[params.size()]));
        }
    };
    appAnimator.addUpdateListener(listener);
    // Since we added a start delay, call update here to init the FloatingIconView properly.
    listener.onUpdate(0, true);
    // flicker when it resets itself at the end of its animation.
    if (appTargetsAreTranslucent) {
        animatorSet.play(appAnimator);
    } else {
        animatorSet.playTogether(appAnimator, getBackgroundAnimator());
    }
    return animatorSet;
}
Also used : FloatingIconView(com.android.launcher3.views.FloatingIconView) FloatingIconView.getFloatingIconView(com.android.launcher3.views.FloatingIconView.getFloatingIconView) ArrayList(java.util.ArrayList) RemoteAnimationTargets(com.android.quickstep.RemoteAnimationTargets) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Matrix(android.graphics.Matrix) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SurfaceParams(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams) Rect(android.graphics.Rect) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) Point(android.graphics.Point) Point(android.graphics.Point) RectF(android.graphics.RectF) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) LauncherTaskbarUIController(com.android.launcher3.taskbar.LauncherTaskbarUIController)

Example 90 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ProtonAOSP.

the class QuickstepTransitionManager method getClosingWindowAnimators.

/**
 * Closing animator that animates the window into its final location on the workspace.
 */
private void getClosingWindowAnimators(AnimatorSet animation, RemoteAnimationTargetCompat[] targets, View launcherView, PointF velocityPxPerS) {
    FloatingIconView floatingIconView = null;
    FloatingWidgetView floatingWidget = null;
    RectF targetRect = new RectF();
    RemoteAnimationTargetCompat runningTaskTarget = null;
    boolean isTransluscent = false;
    for (RemoteAnimationTargetCompat target : targets) {
        if (target.mode == MODE_CLOSING) {
            runningTaskTarget = target;
            isTransluscent = runningTaskTarget.isTranslucent;
            break;
        }
    }
    // Get floating view and target rect.
    if (launcherView instanceof LauncherAppWidgetHostView) {
        Size windowSize = new Size(mDeviceProfile.availableWidthPx, mDeviceProfile.availableHeightPx);
        int fallbackBackgroundColor = FloatingWidgetView.getDefaultBackgroundColor(mLauncher, runningTaskTarget);
        floatingWidget = FloatingWidgetView.getFloatingWidgetView(mLauncher, (LauncherAppWidgetHostView) launcherView, targetRect, windowSize, mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher), isTransluscent, fallbackBackgroundColor);
    } else if (launcherView != null) {
        floatingIconView = getFloatingIconView(mLauncher, launcherView, true, /* hideOriginal */
        targetRect, false);
    } else {
        targetRect.set(getDefaultWindowTargetRect());
    }
    final RectF startRect = new RectF(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx);
    RectFSpringAnim anim = new RectFSpringAnim(startRect, targetRect, mLauncher, mDeviceProfile);
    // Hook up floating views to the closing window animators.
    final int rotationChange = getRotationChange(targets);
    Rect windowTargetBounds = getWindowTargetBounds(targets, rotationChange);
    if (floatingIconView != null) {
        anim.addAnimatorListener(floatingIconView);
        floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged);
        floatingIconView.setFastFinishRunnable(anim::end);
        FloatingIconView finalFloatingIconView = floatingIconView;
        // We want the window alpha to be 0 once this threshold is met, so that the
        // FolderIconView can be seen morphing into the icon shape.
        final float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION;
        RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect, windowTargetBounds) {

            @Override
            public void onUpdate(RectF currentRectF, float progress) {
                finalFloatingIconView.update(1f, 255, /* fgAlpha */
                currentRectF, progress, windowAlphaThreshold, getCornerRadius(progress), false);
                super.onUpdate(currentRectF, progress);
            }
        };
        anim.addOnUpdateListener(runner);
    } else if (floatingWidget != null) {
        anim.addAnimatorListener(floatingWidget);
        floatingWidget.setOnTargetChangeListener(anim::onTargetPositionChanged);
        floatingWidget.setFastFinishRunnable(anim::end);
        final float floatingWidgetAlpha = isTransluscent ? 0 : 1;
        FloatingWidgetView finalFloatingWidget = floatingWidget;
        RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect, windowTargetBounds) {

            @Override
            public void onUpdate(RectF currentRectF, float progress) {
                final float fallbackBackgroundAlpha = 1 - mapBoundToRange(progress, 0.8f, 1, 0, 1, EXAGGERATED_EASE);
                final float foregroundAlpha = mapBoundToRange(progress, 0.5f, 1, 0, 1, EXAGGERATED_EASE);
                finalFloatingWidget.update(currentRectF, floatingWidgetAlpha, foregroundAlpha, fallbackBackgroundAlpha, 1 - progress);
                super.onUpdate(currentRectF, progress);
            }
        };
        anim.addOnUpdateListener(runner);
    }
    // Use a fixed velocity to start the animation.
    animation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            anim.start(mLauncher, velocityPxPerS);
        }
    });
}
Also used : FloatingIconView(com.android.launcher3.views.FloatingIconView) FloatingIconView.getFloatingIconView(com.android.launcher3.views.FloatingIconView.getFloatingIconView) Rect(android.graphics.Rect) FloatingWidgetView(com.android.quickstep.views.FloatingWidgetView) Size(android.util.Size) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) Point(android.graphics.Point) RectF(android.graphics.RectF) RectFSpringAnim(com.android.quickstep.util.RectFSpringAnim) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView)

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