1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18package com.android.internal.transition;
19
20import android.transition.ChangeBounds;
21import android.transition.Fade;
22import android.transition.ChangeText;
23import android.transition.Transition;
24import android.transition.TransitionManager;
25import android.transition.TransitionSet;
26import android.view.ViewGroup;
27
28public class ActionBarTransition {
29
30    private static boolean TRANSITIONS_ENABLED = false;
31
32    private static final int TRANSITION_DURATION = 120; // ms
33
34    private static final Transition sTransition;
35
36    static {
37        if (TRANSITIONS_ENABLED) {
38            final ChangeText tc = new ChangeText();
39            tc.setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_OUT_IN);
40            final TransitionSet inner = new TransitionSet();
41            inner.addTransition(tc).addTransition(new ChangeBounds());
42            final TransitionSet tg = new TransitionSet();
43            tg.addTransition(new Fade(Fade.OUT)).addTransition(inner).
44                    addTransition(new Fade(Fade.IN));
45            tg.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
46            tg.setDuration(TRANSITION_DURATION);
47            sTransition = tg;
48        } else {
49            sTransition = null;
50        }
51    }
52
53    public static void beginDelayedTransition(ViewGroup sceneRoot) {
54        if (TRANSITIONS_ENABLED) {
55            TransitionManager.beginDelayedTransition(sceneRoot, sTransition);
56        }
57    }
58}
59