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

Commit c2a091a0 authored by Tenghui Zhu's avatar Tenghui Zhu Committed by Android (Google) Code Review
Browse files

Merge "Add test for private API forceAnimationOnUI" into nyc-dev

parents 2c7238e8 9ac5a333
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -23,6 +23,4 @@ LOCAL_PACKAGE_NAME := VectorDrawableTest

LOCAL_MODULE_TAGS := tests

LOCAL_SDK_VERSION := current

include $(BUILD_PACKAGE)
+0 −2
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.test.dynamic" >

    <uses-sdk android:minSdkVersion="21" />

    <application
        android:hardwareAccelerated="true"
        android:label="vector"
+35 −18
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.View;
import android.widget.Button;
import android.widget.GridLayout;
import android.widget.ScrollView;
import android.widget.TextView;

public class AnimatedVectorDrawableTest extends Activity implements View.OnClickListener {
    private static final String LOGCAT = "AnimatedVectorDrawableTest";
@@ -45,21 +46,36 @@ public class AnimatedVectorDrawableTest extends Activity implements View.OnClick
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        final int[] layerTypes = {View.LAYER_TYPE_SOFTWARE, View.LAYER_TYPE_HARDWARE};
        final boolean[] forceOnUi = {false, true};
        super.onCreate(savedInstanceState);

        ScrollView scrollView = new ScrollView(this);
        GridLayout container = new GridLayout(this);
        scrollView.addView(container);
        container.setColumnCount(2);
        container.setColumnCount(layerTypes.length * forceOnUi.length);

        for (int j = 0; j < layerTypes.length; j++) {
            for (int k = 0; k < forceOnUi.length; k++) {
                TextView textView = new TextView(this);
                String category = "Layer:"
                        + (layerTypes[j] == View.LAYER_TYPE_SOFTWARE ? "SW" : "HW")
                        + (forceOnUi[k] == true ? ",forceUI" : "");
                textView.setText(category);
                container.addView(textView);
            }
        }
        for (int i = 0; i < icon.length; i++) {
            for (int j = 0; j < layerTypes.length; j++) {
                for (int k = 0; k < forceOnUi.length; k++) {
                    Button button = new Button(this);
                button.setWidth(400);
                button.setHeight(400);
                    button.setWidth(300);
                    button.setHeight(300);
                    button.setLayerType(layerTypes[j], null);
                    button.setBackgroundResource(icon[i]);
                    AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground();
                    if (forceOnUi[k] == true) {
                        d.forceAnimationOnUI();
                    }
                    d.registerAnimationCallback(new Animatable2.AnimationCallback() {
                        @Override
                        public void onAnimationStart(Drawable drawable) {
@@ -76,6 +92,7 @@ public class AnimatedVectorDrawableTest extends Activity implements View.OnClick
                    button.setOnClickListener(this);
                }
            }
        }

        setContentView(scrollView);
    }