diff options
author | Chet Haase <chet@google.com> | 2013-06-03 07:30:21 -0700 |
---|---|---|
committer | Chet Haase <chet@google.com> | 2013-06-03 16:37:05 -0700 |
commit | 867a86613d4152a93423300f83597300e6ebeebe (patch) | |
tree | 9087a8ca942f453fb2da7555cd04c5aa2083213d /tests/TransitionTests | |
parent | d18607980d86f03ffd838321ac3d511fa820b3e0 (diff) | |
download | frameworks_base-867a86613d4152a93423300f83597300e6ebeebe.zip frameworks_base-867a86613d4152a93423300f83597300e6ebeebe.tar.gz frameworks_base-867a86613d4152a93423300f83597300e6ebeebe.tar.bz2 |
Various fixes/cleanup in Scenes and Transitions
setDuration() wasn't handled correctly for TransitionGroup; it should
propagate the value to its children.
Also, videos with no ids were not being handled correctly. The transition code was
using the default id on those views (-1) to store start/end data about the view,
causing multiple non-id views to clobber values in the hashmaps. The correct approach
should be to ignore default id values - only store information about the view
instances, not about the unset ids.
Also, added a new test InterruptTest to be used to fix the current behavior of
not handling situations where new transitions start while old ones are still taking place.
Change-Id: I4e880bdbb33cc26d487bceb0d56e463e72f7621f
Diffstat (limited to 'tests/TransitionTests')
9 files changed, 182 insertions, 2 deletions
diff --git a/tests/TransitionTests/AndroidManifest.xml b/tests/TransitionTests/AndroidManifest.xml index 8cd36bf..be6b145 100644 --- a/tests/TransitionTests/AndroidManifest.xml +++ b/tests/TransitionTests/AndroidManifest.xml @@ -205,6 +205,13 @@ <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> + <activity android:label="InterruptionTest" + android:name="InterruptionTest"> + <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/layout/interruption.xml b/tests/TransitionTests/res/layout/interruption.xml new file mode 100644 index 0000000..9fdb27a --- /dev/null +++ b/tests/TransitionTests/res/layout/interruption.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:id="@+id/container" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <RadioGroup android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + <RadioButton android:id="@+id/scene1RB" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/state1" + android:onClick="onRadioButtonClicked"/> + <RadioButton android:id="@+id/scene2RB" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/state2" + android:onClick="onRadioButtonClicked"/> + <RadioButton android:id="@+id/scene3RB" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/state3" + android:onClick="onRadioButtonClicked"/> + <RadioButton android:id="@+id/scene4RB" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/state4" + android:onClick="onRadioButtonClicked"/> + </RadioGroup> + + <LinearLayout + android:orientation="vertical" + android:id="@+id/sceneRoot" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <include layout="@layout/interruption_inner_1"/> + + </LinearLayout> + + +</LinearLayout>
\ No newline at end of file diff --git a/tests/TransitionTests/res/layout/interruption_inner_1.xml b/tests/TransitionTests/res/layout/interruption_inner_1.xml new file mode 100644 index 0000000..990a7fd --- /dev/null +++ b/tests/TransitionTests/res/layout/interruption_inner_1.xml @@ -0,0 +1,13 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:id="@+id/buttonContainer"> + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/button" + android:layout_alignParentTop="true" + android:layout_alignParentLeft="true" + android:text="@string/state1"/> + +</RelativeLayout>
\ No newline at end of file diff --git a/tests/TransitionTests/res/layout/interruption_inner_2.xml b/tests/TransitionTests/res/layout/interruption_inner_2.xml new file mode 100644 index 0000000..d18b557 --- /dev/null +++ b/tests/TransitionTests/res/layout/interruption_inner_2.xml @@ -0,0 +1,13 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:id="@+id/buttonContainer"> + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:id="@+id/button" + android:layout_alignParentRight="true" + android:text="@string/state2"/> + +</RelativeLayout>
\ No newline at end of file diff --git a/tests/TransitionTests/res/layout/interruption_inner_3.xml b/tests/TransitionTests/res/layout/interruption_inner_3.xml new file mode 100644 index 0000000..70bd02c --- /dev/null +++ b/tests/TransitionTests/res/layout/interruption_inner_3.xml @@ -0,0 +1,13 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:id="@+id/buttonContainer"> + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/button" + android:layout_alignParentBottom="true" + android:layout_alignParentLeft="true" + android:text="@string/state3"/> + +</RelativeLayout>
\ No newline at end of file diff --git a/tests/TransitionTests/res/layout/interruption_inner_4.xml b/tests/TransitionTests/res/layout/interruption_inner_4.xml new file mode 100644 index 0000000..85265fc --- /dev/null +++ b/tests/TransitionTests/res/layout/interruption_inner_4.xml @@ -0,0 +1,13 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:id="@+id/buttonContainer"> + <Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/button" + android:layout_alignParentBottom="true" + android:layout_alignParentRight="true" + android:text="@string/state4"/> + +</RelativeLayout>
\ No newline at end of file diff --git a/tests/TransitionTests/res/values/strings.xml b/tests/TransitionTests/res/values/strings.xml index e251d5c..3be243b 100644 --- a/tests/TransitionTests/res/values/strings.xml +++ b/tests/TransitionTests/res/values/strings.xml @@ -39,4 +39,8 @@ <string name="shortText2">Not much text here</string> <string name="longText1">This is the beginning of the Spring of my discontent. In the event of a real emergency, you would be notified by email. Fear not, for death comes swiftly.</string> <string name="longText2">When do we get to eat? I like all things, especially following strong leaders, and mangy cats. Break glass in emergency. The purpose of a framework is to provide the facilities and functionality of a powerful toolkit with the simplicity of a refrigerator.</string> + <string name="state1">State 1</string> + <string name="state2">State 2</string> + <string name="state3">State 3</string> + <string name="state4">State 4</string> </resources> diff --git a/tests/TransitionTests/src/com/android/transitiontests/ChangingText.java b/tests/TransitionTests/src/com/android/transitiontests/ChangingText.java index 3bb7100..05bed5f 100644 --- a/tests/TransitionTests/src/com/android/transitiontests/ChangingText.java +++ b/tests/TransitionTests/src/com/android/transitiontests/ChangingText.java @@ -29,10 +29,8 @@ import android.view.transition.TransitionManager; public class ChangingText extends Activity { - Button mRemovingButton, mInvisibleButton, mGoneButton; Scene mScene1, mScene2; ViewGroup mSceneRoot; - Fade fader; TransitionGroup mChanger; @Override diff --git a/tests/TransitionTests/src/com/android/transitiontests/InterruptionTest.java b/tests/TransitionTests/src/com/android/transitiontests/InterruptionTest.java new file mode 100644 index 0000000..47cf002 --- /dev/null +++ b/tests/TransitionTests/src/com/android/transitiontests/InterruptionTest.java @@ -0,0 +1,74 @@ +/* + * 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.AutoTransition; +import android.view.transition.Move; +import android.view.transition.Scene; +import android.view.transition.TextChange; +import android.view.transition.Transition; +import android.view.transition.TransitionGroup; +import android.view.transition.TransitionManager; +import android.widget.RadioButton; + +public class InterruptionTest extends Activity { + + RadioButton mScene1RB, mScene2RB, mScene3RB, mScene4RB; + private Scene mScene1; + private Scene mScene2; + private Scene mScene3; + private Scene mScene4; + Transition mAutoTransition = new AutoTransition(); + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.interruption); + + View container = (View) findViewById(R.id.container); + ViewGroup sceneRoot = (ViewGroup) findViewById(R.id.sceneRoot); + + mScene1 = new Scene(sceneRoot, R.layout.interruption_inner_1, this); + mScene2 = new Scene(sceneRoot, R.layout.interruption_inner_2, this); + mScene3 = new Scene(sceneRoot, R.layout.interruption_inner_3, this); + mScene4 = new Scene(sceneRoot, R.layout.interruption_inner_4, this); + + mScene1RB = (RadioButton) findViewById(R.id.scene1RB); + mScene2RB = (RadioButton) findViewById(R.id.scene2RB); + mScene3RB = (RadioButton) findViewById(R.id.scene3RB); + mScene4RB = (RadioButton) findViewById(R.id.scene4RB); + + sceneRoot.setCurrentScene(mScene1); + + mAutoTransition.setDuration(1500); + } + + public void onRadioButtonClicked(View clickedButton) { + if (clickedButton == mScene1RB) { + TransitionManager.go(mScene1, mAutoTransition); + } else if (clickedButton == mScene2RB) { + TransitionManager.go(mScene2, mAutoTransition); + } else if (clickedButton == mScene3RB) { + TransitionManager.go(mScene3, mAutoTransition); + } else { + TransitionManager.go(mScene4, mAutoTransition); + } + } +} |