summaryrefslogtreecommitdiffstats
path: root/tests/TransitionTests
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2013-07-12 12:54:38 -0700
committerChet Haase <chet@google.com>2013-07-12 13:40:38 -0700
commitc81a8493884c7f432d6bd5b98aca3fbdc93b355b (patch)
tree7980d444f02c96c4ca1333efb7fdac400a5f523f /tests/TransitionTests
parentf33468e68a6e78c6a2c88d90de4fbce55cad7eac (diff)
downloadframeworks_base-c81a8493884c7f432d6bd5b98aca3fbdc93b355b.zip
frameworks_base-c81a8493884c7f432d6bd5b98aca3fbdc93b355b.tar.gz
frameworks_base-c81a8493884c7f432d6bd5b98aca3fbdc93b355b.tar.bz2
Fix minor transition bugs and add capabilities
Some view changes require more flexible transitions than the defaults provided by Crossfade and TextChange - this change supplies some of that flexibility. Also, starting a new transition on a hierarchy undergoing a transition caused the first to get canceled, then the start values to be retrieved. The new transition should actually get the start values from the intermediate state of the views, so we now cancel the previous transition only after the start values have been captured. Issue #9756349 Transitions: Crossfade does not handle interruption/reverse correctly Issue #9295863 Transitions: Add behavior API/flags to various transitions Issue #9275859 Transitions: Improve mechanism for transition interruption Change-Id: I5a8c5a12466ddcab9e84e4880930563fa1216f3b
Diffstat (limited to 'tests/TransitionTests')
-rw-r--r--tests/TransitionTests/AndroidManifest.xml7
-rw-r--r--tests/TransitionTests/res/drawable-nodpi/self_portrait_square_400.jpgbin0 -> 34679 bytes
-rw-r--r--tests/TransitionTests/res/layout/crossfade_multiple.xml84
-rw-r--r--tests/TransitionTests/res/values/strings.xml8
-rw-r--r--tests/TransitionTests/src/com/android/transitiontests/CrossfadeMultiple.java139
5 files changed, 238 insertions, 0 deletions
diff --git a/tests/TransitionTests/AndroidManifest.xml b/tests/TransitionTests/AndroidManifest.xml
index 9a399d0..35e7b69 100644
--- a/tests/TransitionTests/AndroidManifest.xml
+++ b/tests/TransitionTests/AndroidManifest.xml
@@ -240,6 +240,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:label="CrossfadeMultiple"
+ android:name=".CrossfadeMultiple">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
</application>
diff --git a/tests/TransitionTests/res/drawable-nodpi/self_portrait_square_400.jpg b/tests/TransitionTests/res/drawable-nodpi/self_portrait_square_400.jpg
new file mode 100644
index 0000000..3923fd1
--- /dev/null
+++ b/tests/TransitionTests/res/drawable-nodpi/self_portrait_square_400.jpg
Binary files differ
diff --git a/tests/TransitionTests/res/layout/crossfade_multiple.xml b/tests/TransitionTests/res/layout/crossfade_multiple.xml
new file mode 100644
index 0000000..ca32ecb
--- /dev/null
+++ b/tests/TransitionTests/res/layout/crossfade_multiple.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <RadioGroup android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <RadioButton android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="changeTransitionType"
+ android:id="@+id/reveal"
+ android:text="@string/reveal"/>
+ <RadioButton android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="changeTransitionType"
+ android:id="@+id/crossfade"
+ android:text="@string/crossfade"/>
+ <RadioButton android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="changeTransitionType"
+ android:id="@+id/inout"
+ android:text="@string/inout"/>
+ <RadioButton android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="changeTransitionType"
+ android:id="@+id/textfade1"
+ android:text="@string/textfade1"/>
+ <RadioButton android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="changeTransitionType"
+ android:id="@+id/textfade2"
+ android:text="@string/textfade2"/>
+ </RadioGroup>
+ <LinearLayout android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="sendMessage"
+ android:text="@string/state1"
+ android:id="@+id/button1"/>
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="sendMessage"
+ android:text="@string/state2"
+ android:id="@+id/button2"/>
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="sendMessage"
+ android:text="@string/state3"
+ android:id="@+id/button3"/>
+ </LinearLayout>
+
+ <LinearLayout android:orientation="vertical"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <Button
+ android:layout_width="100dip"
+ android:layout_height="100dip"
+ android:textSize="40dip"
+ android:text="@string/a"
+ android:id="@+id/button"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="40dip"
+ android:text="@string/state1"
+ android:id="@+id/textview"/>
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/self_portrait_square_100"
+ android:onClick="sendMessage"
+ android:id="@+id/imageview"/>
+ </LinearLayout>
+
+</LinearLayout> \ No newline at end of file
diff --git a/tests/TransitionTests/res/values/strings.xml b/tests/TransitionTests/res/values/strings.xml
index 9b80a26..9cf7a94 100644
--- a/tests/TransitionTests/res/values/strings.xml
+++ b/tests/TransitionTests/res/values/strings.xml
@@ -49,4 +49,12 @@
<string name="button3">Button 3</string>
<string name="button4">Button 4</string>
<string name="button5">Button 5</string>
+ <string name="a">A</string>
+ <string name="b">B</string>
+ <string name="c">C</string>
+ <string name="reveal">Reveal</string>
+ <string name="crossfade">Crossfade</string>
+ <string name="inout">In/Out</string>
+ <string name="textfade1">T1</string>
+ <string name="textfade2">T2</string>
</resources>
diff --git a/tests/TransitionTests/src/com/android/transitiontests/CrossfadeMultiple.java b/tests/TransitionTests/src/com/android/transitiontests/CrossfadeMultiple.java
new file mode 100644
index 0000000..b82dbd8
--- /dev/null
+++ b/tests/TransitionTests/src/com/android/transitiontests/CrossfadeMultiple.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.transitiontests;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.transition.Crossfade;
+import android.view.transition.Move;
+import android.view.transition.TextChange;
+import android.view.transition.Transition;
+import android.view.transition.TransitionGroup;
+import android.view.transition.TransitionManager;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import static android.widget.LinearLayout.LayoutParams;
+
+public class CrossfadeMultiple extends Activity {
+ ViewGroup mSceneRoot;
+ static int mCurrentScene;
+ TransitionManager mTransitionManager;
+ Transition mTransition;
+ ImageView mImageView;
+ TextView mTextView;
+ Button mButton;
+ Crossfade mCrossfade;
+ TransitionGroup mCrossfadeGroup;
+ TransitionGroup mTextChangeGroup1, mTextChangeGroup2;
+ TransitionGroup mInOutGroup;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.crossfade_multiple);
+
+ ViewGroup container = (ViewGroup) findViewById(R.id.container);
+ mSceneRoot = container;
+
+ mButton = (Button) findViewById(R.id.button);
+ mImageView = (ImageView) findViewById(R.id.imageview);
+ mTextView = (TextView) findViewById(R.id.textview);
+
+ mCrossfade = new Crossfade();
+ mCrossfade.setTargetIds(R.id.button, R.id.textview, R.id.imageview);
+
+ mCrossfadeGroup = new TransitionGroup();
+ mCrossfadeGroup.setDuration(300);
+ mCrossfadeGroup.addTransitions(mCrossfade, new Move());
+ mTransition = mCrossfadeGroup;
+
+ mInOutGroup = new TransitionGroup();
+ Crossfade inOut = new Crossfade();
+ inOut.setDuration(300);
+ inOut.setFadeBehavior(Crossfade.FADE_BEHAVIOR_OUT_IN);
+ Move move = new Move();
+ move.setStartDelay(150);
+ move.setDuration(0);
+ mInOutGroup.addTransitions(inOut, move);
+
+ mTextChangeGroup1 = new TransitionGroup();
+ TextChange textChangeInOut = new TextChange();
+ textChangeInOut.setChangeBehavior(TextChange.CHANGE_BEHAVIOR_OUT_IN);
+ mTextChangeGroup1.addTransitions(textChangeInOut, new Move());
+
+ mTextChangeGroup2 = new TransitionGroup();
+ mTextChangeGroup2.setOrdering(TransitionGroup.SEQUENTIALLY);
+ TextChange textChangeOut = new TextChange();
+ textChangeOut.setChangeBehavior(TextChange.CHANGE_BEHAVIOR_OUT);
+ TextChange textChangeIn = new TextChange();
+ textChangeIn.setChangeBehavior(TextChange.CHANGE_BEHAVIOR_IN);
+ mTextChangeGroup2.addTransitions(textChangeOut, new Move(), textChangeIn);
+ }
+
+ public void sendMessage(View view) {
+ TransitionManager.beginDelayedTransition(mSceneRoot, mTransition);
+ int id = view.getId();
+ LayoutParams params = null;
+ switch (id) {
+ case R.id.button1:
+ params = new LayoutParams(200, 200);
+ mButton.setText("A");
+ mTextView.setText("1111111");
+ mImageView.setImageResource(R.drawable.self_portrait_square_100);
+ break;
+ case R.id.button2:
+ params = new LayoutParams(400, 200);
+ mButton.setText("B");
+ mTextView.setText("2222222");
+ mImageView.setImageResource(R.drawable.self_portrait_square_200);
+ break;
+ case R.id.button3:
+ params = new LayoutParams(200, 400);
+ mButton.setText("C");
+ mTextView.setText("3333333");
+ mImageView.setImageResource(R.drawable.self_portrait_square_400);
+ break;
+ }
+ mButton.setLayoutParams(params);
+ }
+
+ public void changeTransitionType(View view) {
+ int id = view.getId();
+ switch (id) {
+ case R.id.reveal:
+ mCrossfade.setFadeBehavior(Crossfade.FADE_BEHAVIOR_REVEAL);
+ mTransition = mCrossfadeGroup;
+ break;
+ case R.id.crossfade:
+ mCrossfade.setFadeBehavior(Crossfade.FADE_BEHAVIOR_CROSSFADE);
+ mTransition = mCrossfadeGroup;
+ break;
+ case R.id.inout:
+ mTransition = mInOutGroup;
+ break;
+ case R.id.textfade1:
+ mTransition = mTextChangeGroup1;
+ break;
+ case R.id.textfade2:
+ mTransition = mTextChangeGroup2;
+ break;
+ }
+ }
+}