Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31935226 authored by Alex Chau's avatar Alex Chau
Browse files

Change wallpaper depth value in AllApps bottomsheet

- Cap AllApps wallpaper zoom to workspaceContentScale rather than all the way to max depth (config_wallpaperMaxScale)
- Changed both workspace scale and depth interpolator to correlate with AllApps threshold

Bug: 240580498
Test: manual
Change-Id: I0342a37c72206268dcffc5697a212704a41b020f
parent 5166c5da
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -16,8 +16,7 @@
package com.android.launcher3.taskbar.allapps;

import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.systemui.animation.Interpolators.EMPHASIZED_ACCELERATE;
import static com.android.launcher3.anim.Interpolators.EMPHASIZED;

import android.animation.PropertyValuesHolder;
import android.content.Context;
@@ -60,7 +59,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarAllApp
        if (animate) {
            mOpenCloseAnimator.setValues(
                    PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED));
            mOpenCloseAnimator.setInterpolator(AGGRESSIVE_EASE);
            mOpenCloseAnimator.setInterpolator(EMPHASIZED);
            mOpenCloseAnimator.setDuration(
                    ALL_APPS.getTransitionDuration(mActivityContext, true /* isToState */)).start();
        } else {
@@ -87,7 +86,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarAllApp

    @Override
    protected Interpolator getIdleInterpolator() {
        return EMPHASIZED_ACCELERATE;
        return EMPHASIZED;
    }

    @Override
+23 −7
Original line number Diff line number Diff line
@@ -16,14 +16,17 @@
package com.android.launcher3.uioverrides.states;

import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAPPS;

import android.content.Context;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.DeviceProfileListenable;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.Themes;

/**
@@ -41,9 +44,9 @@ public class AllAppsState extends LauncherState {
    @Override
    public <DEVICE_PROFILE_CONTEXT extends Context & DeviceProfileListenable>
    int getTransitionDuration(DEVICE_PROFILE_CONTEXT context, boolean isToState) {
        return !context.getDeviceProfile().isTablet && isToState
                ? 600
                : isToState ? 500 : 300;
        return context.getDeviceProfile().isTablet
                ? 500
                :  isToState ? 600 : 300;
    }

    @Override
@@ -77,11 +80,24 @@ public class AllAppsState extends LauncherState {
    }

    @Override
    protected float getDepthUnchecked(Context context) {
    protected <DEVICE_PROFILE_CONTEXT extends Context & DeviceProfile.DeviceProfileListenable>
            float getDepthUnchecked(DEVICE_PROFILE_CONTEXT context) {
        if (context.getDeviceProfile().isTablet) {
            // The goal is to set wallpaper to zoom at workspaceContentScale when in AllApps.
            // When depth is 0, wallpaper zoom is set to maxWallpaperScale.
            // When depth is 1, wallpaper zoom is set to 1.
            // For depth to achieve zoom set to maxWallpaperScale * workspaceContentScale:
            float maxWallpaperScale = context.getResources().getFloat(
                    com.android.internal.R.dimen.config_wallpaperMaxScale);
            return Utilities.mapToRange(
                    maxWallpaperScale * context.getDeviceProfile().workspaceContentScale,
                    maxWallpaperScale, 1f, 0f, 1f, LINEAR);
        } else {
            // The scrim fades in at approximately 50% of the swipe gesture.
            // This means that the depth should be greater than 1, in order to fully zoom out.
            return 2f;
        }
    }

    @Override
    public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
+3 −2
Original line number Diff line number Diff line
@@ -195,7 +195,8 @@ public final class TaskViewUtils {

        int taskIndex = recentsView.indexOfChild(v);
        Context context = v.getContext();
        DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
        BaseActivity baseActivity = BaseActivity.fromContext(context);
        DeviceProfile dp = baseActivity.getDeviceProfile();
        boolean showAsGrid = dp.isTablet;
        boolean parallaxCenterAndAdjacentTask =
                taskIndex != recentsView.getCurrentPage() && !showAsGrid;
@@ -368,7 +369,7 @@ public final class TaskViewUtils {
        });

        if (depthController != null) {
            out.setFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(context),
            out.setFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(baseActivity),
                    TOUCH_RESPONSE_INTERPOLATOR);
        }
    }
+6 −3
Original line number Diff line number Diff line
@@ -265,7 +265,8 @@ public abstract class LauncherState implements BaseState<LauncherState> {
     *
     * 0 means completely zoomed in, without blurs. 1 is zoomed out, with blurs.
     */
    public final float getDepth(Context context) {
    public final  <DEVICE_PROFILE_CONTEXT extends Context & DeviceProfile.DeviceProfileListenable>
            float getDepth(DEVICE_PROFILE_CONTEXT context) {
        return getDepth(context,
                BaseDraggingActivity.fromContext(context).getDeviceProfile().isMultiWindowMode);
    }
@@ -275,14 +276,16 @@ public abstract class LauncherState implements BaseState<LauncherState> {
     *
     * @see #getDepth(Context).
     */
    public final float getDepth(Context context, boolean isMultiWindowMode) {
    public final <DEVICE_PROFILE_CONTEXT extends Context & DeviceProfile.DeviceProfileListenable>
            float getDepth(DEVICE_PROFILE_CONTEXT context, boolean isMultiWindowMode) {
        if (isMultiWindowMode) {
            return 0;
        }
        return getDepthUnchecked(context);
    }

    protected float getDepthUnchecked(Context context) {
    protected <DEVICE_PROFILE_CONTEXT extends Context & DeviceProfile.DeviceProfileListenable>
            float getDepthUnchecked(DEVICE_PROFILE_CONTEXT context) {
        return 0f;
    }

+14 −1
Original line number Diff line number Diff line
@@ -57,6 +57,10 @@ public class Interpolators {
    public static final Interpolator DECELERATED_EASE = new PathInterpolator(0, 0, .2f, 1f);
    public static final Interpolator ACCELERATED_EASE = new PathInterpolator(0.4f, 0, 1f, 1f);

    /**
     * The default emphasized interpolator. Used for hero / emphasized movement of content.
     */
    public static final Interpolator EMPHASIZED = createEmphasizedInterpolator();
    public static final Interpolator EMPHASIZED_ACCELERATE = new PathInterpolator(
            0.3f, 0f, 0.8f, 0.15f);
    public static final Interpolator EMPHASIZED_DECELERATE = new PathInterpolator(
@@ -87,7 +91,6 @@ public class Interpolators {
    public static final Interpolator TOUCH_RESPONSE_INTERPOLATOR_ACCEL_DEACCEL =
            v -> ACCEL_DEACCEL.getInterpolation(TOUCH_RESPONSE_INTERPOLATOR.getInterpolation(v));


    /**
     * Inversion of ZOOM_OUT, compounded with an ease-out.
     */
@@ -218,4 +221,14 @@ public class Interpolators {
    public static Interpolator reverse(Interpolator interpolator) {
        return t -> 1 - interpolator.getInterpolation(1 - t);
    }

    // Create the default emphasized interpolator
    private static PathInterpolator createEmphasizedInterpolator() {
        Path path = new Path();
        // Doing the same as fast_out_extra_slow_in
        path.moveTo(0f, 0f);
        path.cubicTo(0.05f, 0f, 0.133333f, 0.06f, 0.166666f, 0.4f);
        path.cubicTo(0.208333f, 0.82f, 0.25f, 1f, 1f, 1f);
        return new PathInterpolator(path);
    }
}
Loading