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

Commit 2f2ca08b authored by Winson Chung's avatar Winson Chung
Browse files

Fixing crash when filtering tasks too quickly.

- Using a translation-based animation duration scheme
- Fixing issue where filtering a task could slide it out of view

Change-Id: Id434b4a98aa671d84d047dad18cbe26f543cdf25
parent 5e3e5d89
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -107,5 +107,10 @@

    <!-- milliseconds before the heads up notification accepts touches. -->
    <integer name="heads_up_sensitivity_delay">700</integer>

    <!-- The min animation duration for animating views that are currently visible. -->
    <integer name="recents_filter_animate_current_views_min_duration">175</integer>
    <!-- The min animation duration for animating views that are newly visible. -->
    <integer name="recents_filter_animate_new_views_min_duration">125</integer>
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -236,6 +236,10 @@
    <!-- The size of the activity icon in the recents task view. -->
    <dimen name="recents_task_view_activity_icon_size">60dp</dimen>

    <!-- Used to calculate the translation animation duration, the expected amount of movement 
         in dps over one second of time. -->
    <dimen name="recents_animation_movement_in_dps_per_second">800dp</dimen>

    <!-- Space below the notification stack -->
    <dimen name="notification_stack_margin_bottom">0dp</dimen>

+67 −0
Original line number Diff line number Diff line
package com.android.systemui.recents;

import android.animation.TimeInterpolator;

/**
 * A pre-baked bezier-curved interpolator for quantum-paper transitions.
 */
public class BakedBezierInterpolator implements TimeInterpolator {
    public static final BakedBezierInterpolator INSTANCE = new BakedBezierInterpolator();

    /**
     * Use the INSTANCE variable instead of instantiating.
     */
    private BakedBezierInterpolator() {
        super();
    }

    /**
     * Lookup table values.
     * Generated using a Bezier curve from (0,0) to (1,1) with control points:
     * P0 (0,0)
     * P1 (0.4, 0)
     * P2 (0.2, 1.0)
     * P3 (1.0, 1.0)
     *
     * Values sampled with x at regular intervals between 0 and 1.
     *
     * These values were generated using:
     *   ./scripts/bezier_interpolator_values_gen.py 0.4 0.2
     */
    private static final float[] VALUES = new float[] {
        0.0f, 0.0002f, 0.0009f, 0.0019f, 0.0036f, 0.0059f, 0.0086f, 0.0119f, 0.0157f, 0.0209f,
        0.0257f, 0.0321f, 0.0392f, 0.0469f, 0.0566f, 0.0656f, 0.0768f, 0.0887f, 0.1033f, 0.1186f,
        0.1349f, 0.1519f, 0.1696f, 0.1928f, 0.2121f, 0.237f, 0.2627f, 0.2892f, 0.3109f, 0.3386f,
        0.3667f, 0.3952f, 0.4241f, 0.4474f, 0.4766f, 0.5f, 0.5234f, 0.5468f, 0.5701f, 0.5933f,
        0.6134f, 0.6333f, 0.6531f, 0.6698f, 0.6891f, 0.7054f, 0.7214f, 0.7346f, 0.7502f, 0.763f,
        0.7756f, 0.7879f, 0.8f, 0.8107f, 0.8212f, 0.8326f, 0.8415f, 0.8503f, 0.8588f, 0.8672f,
        0.8754f, 0.8833f, 0.8911f, 0.8977f, 0.9041f, 0.9113f, 0.9165f, 0.9232f, 0.9281f, 0.9328f,
        0.9382f, 0.9434f, 0.9476f, 0.9518f, 0.9557f, 0.9596f, 0.9632f, 0.9662f, 0.9695f, 0.9722f,
        0.9753f, 0.9777f, 0.9805f, 0.9826f, 0.9847f, 0.9866f, 0.9884f, 0.9901f, 0.9917f, 0.9931f,
        0.9944f, 0.9955f, 0.9964f, 0.9973f, 0.9981f, 0.9986f, 0.9992f, 0.9995f, 0.9998f, 1.0f, 1.0f
    };

    private static final float STEP_SIZE = 1.0f / (VALUES.length - 1);

    @Override
    public float getInterpolation(float input) {
        if (input >= 1.0f) {
            return 1.0f;
        }

        if (input <= 0f) {
            return 0f;
        }

        int position = Math.min(
                (int)(input * (VALUES.length - 1)),
                VALUES.length - 2);

        float quantized = position * STEP_SIZE;
        float difference = input - quantized;
        float weight = difference / STEP_SIZE;

        return VALUES[position] + weight * (VALUES[position + 1] - VALUES[position]);
    }

}
+2 −16
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public class Constants {
            // For debugging, this enables us to create mock recents tasks
            public static final boolean EnableSystemServicesProxy = false;
            // For debugging, this defines the number of mock recents packages to create
            public static final int SystemServicesProxyMockPackageCount = 12;
            public static final int SystemServicesProxyMockPackageCount = 3;
            // For debugging, this defines the number of mock recents tasks to create
            public static final int SystemServicesProxyMockTaskCount = 75;

@@ -82,16 +82,8 @@ public class Constants {
        }

        public static class TaskStackView {
            public static class Animation {
                public static final int TaskRemovedReshuffleDuration = 200;
                public static final int SnapScrollBackDuration = 650;
                public static final int FilteredCurrentViewsDuration = 150;
                public static final int FilteredNewViewsDuration = 200;
                public static final int UnfilteredCurrentViewsDuration = 150;
                public static final int UnfilteredNewViewsDuration = 200;
            }

            public static final int TaskStackOverscrollRange = 150;
            public static final int FilterStartDelay = 25;

            // The padding will be applied to the smallest dimension, and then applied to all sides
            public static final float StackPaddingPct = 0.15f;
@@ -106,12 +98,6 @@ public class Constants {
        }

        public static class TaskView {
            public static class Animation {
                public static final int TaskDataUpdatedFadeDuration = 250;
                public static final int TaskIconOnEnterDuration = 175;
                public static final int TaskIconOnLeavingDuration = 75;
            }

            public static final boolean AnimateFrontTaskIconOnEnterRecents = true;
            public static final boolean AnimateFrontTaskIconOnLeavingRecents = true;

+12 −1
Original line number Diff line number Diff line
@@ -17,11 +17,11 @@
package com.android.systemui.recents;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import com.android.systemui.R;


/** A static Recents configuration for the current context
@@ -34,6 +34,11 @@ public class RecentsConfiguration {
    public Rect systemInsets = new Rect();
    public Rect displayRect = new Rect();

    public float animationDpsMovementPerSecond;

    public int filteringCurrentViewsMinAnimDuration;
    public int filteringNewViewsMinAnimDuration;

    /** Private constructor */
    private RecentsConfiguration() {}

@@ -58,6 +63,12 @@ public class RecentsConfiguration {
        mDisplayMetrics = dm;

        displayRect.set(0, 0, dm.widthPixels, dm.heightPixels);
        animationDpsMovementPerSecond =
                res.getDimensionPixelSize(R.dimen.recents_animation_movement_in_dps_per_second);
        filteringCurrentViewsMinAnimDuration =
                res.getInteger(R.integer.recents_filter_animate_current_views_min_duration);
        filteringNewViewsMinAnimDuration =
                res.getInteger(R.integer.recents_filter_animate_new_views_min_duration);
    }

    public void updateSystemInsets(Rect insets) {
Loading