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

Commit 169bc15b authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge changes Ie3943d2b,I158f560f

* changes:
  New task switch animation
  New activity open/close animation
parents 44026b7f 60a39fe8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -156,6 +156,8 @@ public class AnimationUtils {
                anim = new RotateAnimation(c, attrs);
            }  else if (name.equals("translate")) {
                anim = new TranslateAnimation(c, attrs);
            } else if (name.equals("cliprect")) {
                anim = new ClipRectAnimation(c, attrs);
            } else {
                throw new RuntimeException("Unknown animation name: " + parser.getName());
            }
+105 −6
Original line number Diff line number Diff line
@@ -16,7 +16,11 @@

package android.view.animation;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.DisplayMetrics;

/**
 * An animation that controls the clip of an object. See the
@@ -26,8 +30,84 @@ import android.graphics.Rect;
 * @hide
 */
public class ClipRectAnimation extends Animation {
    protected Rect mFromRect = new Rect();
    protected Rect mToRect = new Rect();
    protected final Rect mFromRect = new Rect();
    protected final Rect mToRect = new Rect();

    private int mFromLeftType = ABSOLUTE;
    private int mFromTopType = ABSOLUTE;
    private int mFromRightType = ABSOLUTE;
    private int mFromBottomType = ABSOLUTE;

    private int mToLeftType = ABSOLUTE;
    private int mToTopType = ABSOLUTE;
    private int mToRightType = ABSOLUTE;
    private int mToBottomType = ABSOLUTE;

    private float mFromLeftValue;
    private float mFromTopValue;
    private float mFromRightValue;
    private float mFromBottomValue;

    private float mToLeftValue;
    private float mToTopValue;
    private float mToRightValue;
    private float mToBottomValue;

    /**
     * Constructor used when a ClipRectAnimation is loaded from a resource.
     *
     * @param context Application context to use
     * @param attrs Attribute set from which to read values
     */
    public ClipRectAnimation(Context context, AttributeSet attrs) {
        super(context, attrs);

        TypedArray a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.ClipRectAnimation);

        Description d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_fromLeft));
        mFromLeftType = d.type;
        mFromLeftValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_fromTop));
        mFromTopType = d.type;
        mFromTopValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_fromRight));
        mFromRightType = d.type;
        mFromRightValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_fromBottom));
        mFromBottomType = d.type;
        mFromBottomValue = d.value;


        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_toLeft));
        mToLeftType = d.type;
        mToLeftValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_toTop));
        mToTopType = d.type;
        mToTopValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_toRight));
        mToRightType = d.type;
        mToRightValue = d.value;

        d = Description.parseValue(a.peekValue(
                com.android.internal.R.styleable.ClipRectAnimation_toBottom));
        mToBottomType = d.type;
        mToBottomValue = d.value;

        a.recycle();
    }

    /**
     * Constructor to use when building a ClipRectAnimation from code
@@ -39,8 +119,15 @@ public class ClipRectAnimation extends Animation {
        if (fromClip == null || toClip == null) {
            throw new RuntimeException("Expected non-null animation clip rects");
        }
        mFromRect.set(fromClip);
        mToRect.set(toClip);
        mFromLeftValue = fromClip.left;
        mFromTopValue = fromClip.top;
        mFromRightValue= fromClip.right;
        mFromBottomValue = fromClip.bottom;

        mToLeftValue = toClip.left;
        mToTopValue = toClip.top;
        mToRightValue= toClip.right;
        mToBottomValue = toClip.bottom;
    }

    /**
@@ -48,8 +135,7 @@ public class ClipRectAnimation extends Animation {
     */
    public ClipRectAnimation(int fromL, int fromT, int fromR, int fromB,
            int toL, int toT, int toR, int toB) {
        mFromRect.set(fromL, fromT, fromR, fromB);
        mToRect.set(toL, toT, toR, toB);
        this(new Rect(fromL, fromT, fromR, fromB), new Rect(toL, toT, toR, toB));
    }

    @Override
@@ -65,4 +151,17 @@ public class ClipRectAnimation extends Animation {
    public boolean willChangeTransformationMatrix() {
        return false;
    }

    @Override
    public void initialize(int width, int height, int parentWidth, int parentHeight) {
        super.initialize(width, height, parentWidth, parentHeight);
        mFromRect.set((int) resolveSize(mFromLeftType, mFromLeftValue, width, parentWidth),
                (int) resolveSize(mFromTopType, mFromTopValue, height, parentHeight),
                (int) resolveSize(mFromRightType, mFromRightValue, width, parentWidth),
                (int) resolveSize(mFromBottomType, mFromBottomValue, height, parentHeight));
        mToRect.set((int) resolveSize(mToLeftType, mToLeftValue, width, parentWidth),
                (int) resolveSize(mToTopType, mToTopValue, height, parentHeight),
                (int) resolveSize(mToRightType, mToRightValue, width, parentWidth),
                (int) resolveSize(mToBottomType, mToBottomValue, height, parentHeight));
    }
}
+13 −5
Original line number Diff line number Diff line
@@ -17,9 +17,17 @@
*/
-->

<set xmlns:android="http://schemas.android.com/apk/res/android" android:zAdjustment="normal">
    <alpha android:fromAlpha="0.7" android:toAlpha="1.0"
            android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
            android:interpolator="@interpolator/linear_out_slow_in"
            android:duration="250"/>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromYDelta="-2%"
        android:toYDelta="0"
        android:interpolator="@interpolator/fast_out_slow_in"
        android:duration="425"/>
    <alpha
        android:fromAlpha="0.9"
        android:toAlpha="1.0"
        android:interpolator="@interpolator/activity_close_dim"
        android:startOffset="0"
        android:duration="425"/>
</set>
 No newline at end of file
+23 −11
Original line number Diff line number Diff line
@@ -18,15 +18,27 @@
-->

<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:shareInterpolator="false" android:zAdjustment="top">
    <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
            android:interpolator="@interpolator/linear"
            android:fillEnabled="true"
            android:fillBefore="false" android:fillAfter="true"
            android:startOffset="100"
            android:duration="150"/>
    <translate android:fromYDelta="0%" android:toYDelta="8%"
            android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
            android:interpolator="@interpolator/accelerate_quart"
            android:duration="250"/>
    android:shareInterpolator="false"
    android:zAdjustment="top">
    <translate
        android:fromYDelta="0"
        android:toYDelta="4.1%"
        android:interpolator="@interpolator/fast_out_slow_in"
        android:duration="425"/>
    <cliprect
        android:fromLeft="0%"
        android:fromTop="0%"
        android:fromRight="100%"
        android:fromBottom="100%"
        android:toLeft="0%"
        android:toTop="95.9%"
        android:toRight="100%"
        android:toBottom="100%"
        android:interpolator="@interpolator/exaggerated_ease"
        android:duration="425"/>
    <alpha
        android:fromAlpha="1.0"
        android:toAlpha="1.0"
        android:interpolator="@interpolator/fast_out_linear_in"
        android:duration="425"/>
</set>
 No newline at end of file
+18 −13
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
/*
** Copyright 2009, The Android Open Source Project
**
@@ -18,15 +17,21 @@
-->

<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:shareInterpolator="false"
        android:zAdjustment="top">
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
            android:interpolator="@interpolator/decelerate_quart"
            android:fillEnabled="true"
            android:fillBefore="false" android:fillAfter="true"
            android:duration="200"/>
    <translate android:fromYDelta="8%" android:toYDelta="0"
            android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
            android:interpolator="@interpolator/decelerate_quint"
            android:duration="350"/>
    android:shareInterpolator="false">
    <translate
        android:fromYDelta="4.1%"
        android:toYDelta="0"
        android:interpolator="@interpolator/fast_out_slow_in"
        android:duration="425"/>
    <cliprect
        android:fromLeft="0%"
        android:fromTop="95.9%"
        android:fromRight="100%"
        android:fromBottom="100%"
        android:toLeft="0%"
        android:toTop="0%"
        android:toRight="100%"
        android:toBottom="100%"
        android:interpolator="@interpolator/exaggerated_ease"
        android:duration="425"/>
</set>
 No newline at end of file
Loading