diff options
author | Chet Haase <chet@google.com> | 2012-05-18 14:17:57 -0700 |
---|---|---|
committer | Chet Haase <chet@google.com> | 2013-04-18 13:33:13 -0700 |
commit | faebd8f0795b7d275fb4e503533c8c0c4a9acc21 (patch) | |
tree | 464de8bb5dcd9ae99402ebb630d329dc8ce953cc /tests/TransitionTests/src/com/android/transitiontests/ScenesTestv21.java | |
parent | b3caa9200a61cde1178a2c83419de56579d3c5a5 (diff) | |
download | frameworks_base-faebd8f0795b7d275fb4e503533c8c0c4a9acc21.zip frameworks_base-faebd8f0795b7d275fb4e503533c8c0c4a9acc21.tar.gz frameworks_base-faebd8f0795b7d275fb4e503533c8c0c4a9acc21.tar.bz2 |
First draft of Scenes & Transitions feature
This checkin has preliminary API (in flux, definitely changes still
to be made) and implementation for a new "Scenes & Transitions" feature.
The current implementation allows you to define different Scenes
(via layout resource IDs or callbacks) and Transitions to be used when
changing to those scenes. By default, scene changes will use AutoTransition,
which generally does the right thing.
There are no overview docs or tutorials yet. The best way to learn how things
work is to see the code for the various tests in
frameworks/base/tests/TransitionTests.
Expect the API to change. Expect the implementation to change (mostly to add
more functionality). Expect bugs, but tell me if things do not work
as expected.
Change-Id: Ib025a9f565678b225afa4759325cf6d496cc7215
Diffstat (limited to 'tests/TransitionTests/src/com/android/transitiontests/ScenesTestv21.java')
-rw-r--r-- | tests/TransitionTests/src/com/android/transitiontests/ScenesTestv21.java | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/TransitionTests/src/com/android/transitiontests/ScenesTestv21.java b/tests/TransitionTests/src/com/android/transitiontests/ScenesTestv21.java new file mode 100644 index 0000000..2dae463 --- /dev/null +++ b/tests/TransitionTests/src/com/android/transitiontests/ScenesTestv21.java @@ -0,0 +1,75 @@ +/* + * 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.Fade; +import android.view.transition.Move; +import android.view.transition.Recolor; +import android.view.transition.Scene; +import android.view.transition.TransitionGroup; +import android.view.transition.TransitionManager; +import com.android.transitiontest.R; + + +public class ScenesTestv21 extends Activity { + ViewGroup mSceneRoot; + static Scene mCurrentScene; + TransitionManager mTransitionManager = null; + Scene mResultsScreen, mSearchScreen; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.search_screen); + + View container = (View) findViewById(R.id.container); + mSceneRoot = (ViewGroup) container.getParent(); + + mSearchScreen = new Scene(mSceneRoot, R.layout.search_screen, this); + mResultsScreen = new Scene(mSceneRoot, R.layout.results_screen, this); + + TransitionGroup transitionToResults = new TransitionGroup(); + Fade fade = new Fade(); + fade.setTargetIds(R.id.resultsText, R.id.resultsList); + fade.setStartDelay(300); + transitionToResults.addTransitions(fade); + transitionToResults.addTransitions(new Move().setTargetIds(R.id.searchContainer)); + transitionToResults.addTransitions(new Recolor().setTargetIds(R.id.container)); + + TransitionGroup transitionToSearch = new TransitionGroup(); + transitionToSearch.addTransitions(new Fade().setTargetIds(R.id.resultsText, R.id.resultsList)); + transitionToSearch.addTransitions(new Move().setTargetIds(R.id.searchContainer)); + transitionToSearch.addTransitions(new Recolor().setTargetIds(R.id.container)); + mTransitionManager = new TransitionManager(); + mTransitionManager.setTransition(mSearchScreen, transitionToSearch); + mTransitionManager.setTransition(mResultsScreen, transitionToResults); + } + + public void sendMessage(View view) { + if (mCurrentScene == mResultsScreen) { + mTransitionManager.transitionTo(mSearchScreen); + mCurrentScene = mSearchScreen; + } else { + mTransitionManager.transitionTo(mResultsScreen); + mCurrentScene = mResultsScreen; + } + } +} |