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

Commit bf5dbf1c authored by Winson Chung's avatar Winson Chung Committed by Jorim Jaggi
Browse files

Enabling recents stack clipping

The taskviews now avoid overdraw by clipping invisible
parts. Also adapted some timings of the animation.

Bug: 17455301
Change-Id: Ifbf7bab363e530cb2ad842baed50fc16dcfcc4c4
parent a8433c65
Loading
Loading
Loading
Loading
+24 −19
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusable="true">
    <FrameLayout
        android:id="@+id/task_view_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <com.android.systemui.recents.views.TaskViewThumbnail
            android:id="@+id/task_view_thumbnail"
            android:layout_width="match_parent"
@@ -30,7 +34,7 @@
            android:layout_gravity="bottom|right"
            android:layout_marginRight="15dp"
            android:layout_marginBottom="15dp"
        android:translationZ="3dp"
            android:translationZ="2dp"
            android:contentDescription="@string/recents_lock_to_app_button_label"
            android:background="@drawable/recents_lock_to_task_button_bg">
            <ImageView
@@ -39,6 +43,7 @@
                android:layout_gravity="center"
                android:src="@drawable/recents_lock_to_app_pin" />
        </FrameLayout>
    </FrameLayout>
</com.android.systemui.recents.views.TaskView>

+6 −3
Original line number Diff line number Diff line
@@ -154,9 +154,12 @@
     duration of the transition in to recents from home. -->
    <integer name="recents_animate_task_enter_from_home_delay">150</integer>
    <!-- The min animation duration for animating the task in when transitioning from home. -->
    <integer name="recents_animate_task_enter_from_home_duration">275</integer>
    <!-- The animation stagger to apply to each task animation when transitioning from home. -->
    <integer name="recents_animate_task_enter_from_home_stagger_delay">10</integer>
    <integer name="recents_animate_task_enter_from_home_duration">200</integer>
    <!-- The total animation stagger delay when entering from home. -->
    <integer name="recents_animate_task_enter_from_home_stagger_delay">110</integer>
    <!-- The total animation duration added to the last card when entering from home.
    This value is partialy also added to the previous tasks -->
    <integer name="recents_animate_task_enter_from_home_stagger_duration">72</integer>
    <!-- The short duration when animating in/out the lock to app button. -->
    <integer name="recents_animate_lock_to_app_button_short_duration">150</integer>
    <!-- The long duration when animating in/out the lock to app button. -->
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ public class Constants {
            // Enables the filtering of tasks according to their grouping
            public static final boolean EnableTaskFiltering = false;
            // Enables clipping of tasks against each other
            public static final boolean EnableTaskStackClipping = false;
            public static final boolean EnableTaskStackClipping = true;
            // Enables tapping on the TaskBar to launch the task
            public static final boolean EnableTaskBarTouchEvents = true;
            // Enables app-info pane on long-pressing the icon
+3 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public class RecentsConfiguration {
    public int taskViewEnterFromHomeDelay;
    public int taskViewEnterFromHomeDuration;
    public int taskViewEnterFromHomeStaggerDelay;
    public int taskViewEnterFromHomeStaggerDuration;
    public int taskViewExitToHomeDuration;
    public int taskViewRemoveAnimDuration;
    public int taskViewRemoveAnimTranslationXPx;
@@ -219,6 +220,8 @@ public class RecentsConfiguration {
                res.getInteger(R.integer.recents_animate_task_enter_from_home_duration);
        taskViewEnterFromHomeStaggerDelay =
                res.getInteger(R.integer.recents_animate_task_enter_from_home_stagger_delay);
        taskViewEnterFromHomeStaggerDuration =
                res.getInteger(R.integer.recents_animate_task_enter_from_home_stagger_duration);
        taskViewExitToHomeDuration =
                res.getInteger(R.integer.recents_animate_task_exit_to_home_duration);
        taskViewRemoveAnimDuration =
+77 −0
Original line number Diff line number Diff line
@@ -18,11 +18,14 @@ package com.android.systemui.recents.misc;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.view.View;
import com.android.systemui.recents.RecentsConfiguration;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

/* Common code */
public class Utilities {
@@ -68,6 +71,80 @@ public class Utilities {
        }
    }

    /** Maps a coorindate in a descendant view into the parent. */
    public static float mapCoordInDescendentToSelf(View descendant, View root,
            float[] coord, boolean includeRootScroll) {
        ArrayList<View> ancestorChain = new ArrayList<View>();

        float[] pt = {coord[0], coord[1]};

        View v = descendant;
        while(v != root && v != null) {
            ancestorChain.add(v);
            v = (View) v.getParent();
        }
        ancestorChain.add(root);

        float scale = 1.0f;
        int count = ancestorChain.size();
        for (int i = 0; i < count; i++) {
            View v0 = ancestorChain.get(i);
            // For TextViews, scroll has a meaning which relates to the text position
            // which is very strange... ignore the scroll.
            if (v0 != descendant || includeRootScroll) {
                pt[0] -= v0.getScrollX();
                pt[1] -= v0.getScrollY();
            }

            v0.getMatrix().mapPoints(pt);
            pt[0] += v0.getLeft();
            pt[1] += v0.getTop();
            scale *= v0.getScaleX();
        }

        coord[0] = pt[0];
        coord[1] = pt[1];
        return scale;
    }

    /** Maps a coordinate in the root to a descendent. */
    public static float mapCoordInSelfToDescendent(View descendant, View root,
            float[] coord, Matrix tmpInverseMatrix) {
        ArrayList<View> ancestorChain = new ArrayList<View>();

        float[] pt = {coord[0], coord[1]};

        View v = descendant;
        while(v != root) {
            ancestorChain.add(v);
            v = (View) v.getParent();
        }
        ancestorChain.add(root);

        float scale = 1.0f;
        int count = ancestorChain.size();
        tmpInverseMatrix.set(Matrix.IDENTITY_MATRIX);
        for (int i = count - 1; i >= 0; i--) {
            View ancestor = ancestorChain.get(i);
            View next = i > 0 ? ancestorChain.get(i-1) : null;

            pt[0] += ancestor.getScrollX();
            pt[1] += ancestor.getScrollY();

            if (next != null) {
                pt[0] -= next.getLeft();
                pt[1] -= next.getTop();
                next.getMatrix().invert(tmpInverseMatrix);
                tmpInverseMatrix.mapPoints(pt);
                scale *= next.getScaleX();
            }
        }

        coord[0] = pt[0];
        coord[1] = pt[1];
        return scale;
    }

    /** Calculates the constrast between two colors, using the algorithm provided by the WCAG v2. */
    public static float computeContrastBetweenColors(int bg, int fg) {
        float bgR = Color.red(bg) / 255f;
Loading