Search in sources :

Example 21 with TransitionManager

use of android.transition.TransitionManager in project android_frameworks_base by DirtyUnicorns.

the class PhoneWindow method installDecor.

private void installDecor() {
    mForceDecorInstall = false;
    if (mDecor == null) {
        mDecor = generateDecor(-1);
        mDecor.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        mDecor.setIsRootNamespace(true);
        if (!mInvalidatePanelMenuPosted && mInvalidatePanelMenuFeatures != 0) {
            mDecor.postOnAnimation(mInvalidatePanelMenuRunnable);
        }
    } else {
        mDecor.setWindow(this);
    }
    if (mContentParent == null) {
        mContentParent = generateLayout(mDecor);
        // Set up decor part of UI to ignore fitsSystemWindows if appropriate.
        mDecor.makeOptionalFitsSystemWindows();
        final DecorContentParent decorContentParent = (DecorContentParent) mDecor.findViewById(R.id.decor_content_parent);
        if (decorContentParent != null) {
            mDecorContentParent = decorContentParent;
            mDecorContentParent.setWindowCallback(getCallback());
            if (mDecorContentParent.getTitle() == null) {
                mDecorContentParent.setWindowTitle(mTitle);
            }
            final int localFeatures = getLocalFeatures();
            for (int i = 0; i < FEATURE_MAX; i++) {
                if ((localFeatures & (1 << i)) != 0) {
                    mDecorContentParent.initFeature(i);
                }
            }
            mDecorContentParent.setUiOptions(mUiOptions);
            if ((mResourcesSetFlags & FLAG_RESOURCE_SET_ICON) != 0 || (mIconRes != 0 && !mDecorContentParent.hasIcon())) {
                mDecorContentParent.setIcon(mIconRes);
            } else if ((mResourcesSetFlags & FLAG_RESOURCE_SET_ICON) == 0 && mIconRes == 0 && !mDecorContentParent.hasIcon()) {
                mDecorContentParent.setIcon(getContext().getPackageManager().getDefaultActivityIcon());
                mResourcesSetFlags |= FLAG_RESOURCE_SET_ICON_FALLBACK;
            }
            if ((mResourcesSetFlags & FLAG_RESOURCE_SET_LOGO) != 0 || (mLogoRes != 0 && !mDecorContentParent.hasLogo())) {
                mDecorContentParent.setLogo(mLogoRes);
            }
            // Invalidate if the panel menu hasn't been created before this.
            // Panel menu invalidation is deferred avoiding application onCreateOptionsMenu
            // being called in the middle of onCreate or similar.
            // A pending invalidation will typically be resolved before the posted message
            // would run normally in order to satisfy instance state restoration.
            PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false);
            if (!isDestroyed() && (st == null || st.menu == null) && !mIsStartingWindow) {
                invalidatePanelMenu(FEATURE_ACTION_BAR);
            }
        } else {
            mTitleView = (TextView) findViewById(R.id.title);
            if (mTitleView != null) {
                if ((getLocalFeatures() & (1 << FEATURE_NO_TITLE)) != 0) {
                    final View titleContainer = findViewById(R.id.title_container);
                    if (titleContainer != null) {
                        titleContainer.setVisibility(View.GONE);
                    } else {
                        mTitleView.setVisibility(View.GONE);
                    }
                    mContentParent.setForeground(null);
                } else {
                    mTitleView.setText(mTitle);
                }
            }
        }
        if (mDecor.getBackground() == null && mBackgroundFallbackResource != 0) {
            mDecor.setBackgroundFallback(mBackgroundFallbackResource);
        }
        // already set a custom one.
        if (hasFeature(FEATURE_ACTIVITY_TRANSITIONS)) {
            if (mTransitionManager == null) {
                final int transitionRes = getWindowStyle().getResourceId(R.styleable.Window_windowContentTransitionManager, 0);
                if (transitionRes != 0) {
                    final TransitionInflater inflater = TransitionInflater.from(getContext());
                    mTransitionManager = inflater.inflateTransitionManager(transitionRes, mContentParent);
                } else {
                    mTransitionManager = new TransitionManager();
                }
            }
            mEnterTransition = getTransition(mEnterTransition, null, R.styleable.Window_windowEnterTransition);
            mReturnTransition = getTransition(mReturnTransition, USE_DEFAULT_TRANSITION, R.styleable.Window_windowReturnTransition);
            mExitTransition = getTransition(mExitTransition, null, R.styleable.Window_windowExitTransition);
            mReenterTransition = getTransition(mReenterTransition, USE_DEFAULT_TRANSITION, R.styleable.Window_windowReenterTransition);
            mSharedElementEnterTransition = getTransition(mSharedElementEnterTransition, null, R.styleable.Window_windowSharedElementEnterTransition);
            mSharedElementReturnTransition = getTransition(mSharedElementReturnTransition, USE_DEFAULT_TRANSITION, R.styleable.Window_windowSharedElementReturnTransition);
            mSharedElementExitTransition = getTransition(mSharedElementExitTransition, null, R.styleable.Window_windowSharedElementExitTransition);
            mSharedElementReenterTransition = getTransition(mSharedElementReenterTransition, USE_DEFAULT_TRANSITION, R.styleable.Window_windowSharedElementReenterTransition);
            if (mAllowEnterTransitionOverlap == null) {
                mAllowEnterTransitionOverlap = getWindowStyle().getBoolean(R.styleable.Window_windowAllowEnterTransitionOverlap, true);
            }
            if (mAllowReturnTransitionOverlap == null) {
                mAllowReturnTransitionOverlap = getWindowStyle().getBoolean(R.styleable.Window_windowAllowReturnTransitionOverlap, true);
            }
            if (mBackgroundFadeDurationMillis < 0) {
                mBackgroundFadeDurationMillis = getWindowStyle().getInteger(R.styleable.Window_windowTransitionBackgroundFadeDuration, DEFAULT_BACKGROUND_FADE_DURATION_MS);
            }
            if (mSharedElementsUseOverlay == null) {
                mSharedElementsUseOverlay = getWindowStyle().getBoolean(R.styleable.Window_windowSharedElementsUseOverlay, true);
            }
        }
    }
}
Also used : TransitionManager(android.transition.TransitionManager) DecorContentParent(com.android.internal.widget.DecorContentParent) TransitionInflater(android.transition.TransitionInflater) MenuView(com.android.internal.view.menu.MenuView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 22 with TransitionManager

use of android.transition.TransitionManager in project platform_frameworks_base by android.

the class ScenesTestAutoTargets method onCreate.

@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 = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
    mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
    TransitionSet transition = new TransitionSet();
    transition.addTransition(new Fade()).addTransition(new ChangeBounds()).addTransition(new Recolor());
    mTransitionManager = new TransitionManager();
    mTransitionManager.setTransition(mSearchScreen, transition);
    mTransitionManager.setTransition(mResultsScreen, transition);
}
Also used : TransitionManager(android.transition.TransitionManager) TransitionSet(android.transition.TransitionSet) ChangeBounds(android.transition.ChangeBounds) View(android.view.View) Fade(android.transition.Fade) Recolor(android.transition.Recolor)

Example 23 with TransitionManager

use of android.transition.TransitionManager in project platform_frameworks_base by android.

the class ScenesTestv21 method onCreate.

@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 = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
    mResultsScreen = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
    TransitionSet transitionToResults = new TransitionSet();
    Fade fade = new Fade();
    fade.addTarget(R.id.resultsText).addTarget(R.id.resultsList);
    fade.setStartDelay(300);
    transitionToResults.addTransition(fade);
    transitionToResults.addTransition(new ChangeBounds().addTarget(R.id.searchContainer));
    transitionToResults.addTransition(new Recolor().addTarget(R.id.container));
    TransitionSet transitionToSearch = new TransitionSet();
    transitionToSearch.addTransition(new Fade().addTarget(R.id.resultsText).addTarget(R.id.resultsList));
    transitionToSearch.addTransition(new ChangeBounds().addTarget(R.id.searchContainer));
    transitionToSearch.addTransition(new Recolor().addTarget(R.id.container));
    mTransitionManager = new TransitionManager();
    mTransitionManager.setTransition(mSearchScreen, transitionToSearch);
    mTransitionManager.setTransition(mResultsScreen, transitionToResults);
}
Also used : TransitionManager(android.transition.TransitionManager) TransitionSet(android.transition.TransitionSet) ChangeBounds(android.transition.ChangeBounds) View(android.view.View) Fade(android.transition.Fade) Recolor(android.transition.Recolor)

Example 24 with TransitionManager

use of android.transition.TransitionManager in project platform_frameworks_base by android.

the class Demo1 method sendMessage.

public void sendMessage(View view) {
    if (mFirstTime) {
        mFirstTime = false;
        TransitionSet transition = new TransitionSet();
        transition.addTransition(new Fade().addTarget(R.id.resultsText).addTarget(R.id.resultsList)).addTransition(new ChangeBounds().addTarget(R.id.searchContainer));
        mTransitionManager = new TransitionManager();
        mTransitionManager.setTransition(mSearchScreen, transition);
        mTransitionManager.setTransition(mResultsScreen, transition);
    }
    if (mCurrentScene == mResultsScreen) {
        mTransitionManager.transitionTo(mSearchScreen);
        mCurrentScene = mSearchScreen;
    } else {
        mTransitionManager.transitionTo(mResultsScreen);
        mCurrentScene = mResultsScreen;
    }
}
Also used : TransitionManager(android.transition.TransitionManager) TransitionSet(android.transition.TransitionSet) ChangeBounds(android.transition.ChangeBounds) Fade(android.transition.Fade)

Example 25 with TransitionManager

use of android.transition.TransitionManager in project android_frameworks_base by DirtyUnicorns.

the class LoginActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    View container = (View) findViewById(R.id.container);
    mSceneRoot = (ViewGroup) container.getParent();
    mLoginScene = Scene.getSceneForLayout(mSceneRoot, R.layout.activity_login, this);
    mPasswordScene = Scene.getSceneForLayout(mSceneRoot, R.layout.login_password, this);
    mIncorrectPasswordScene = Scene.getSceneForLayout(mSceneRoot, R.layout.incorrect_password, this);
    mUsernameTakenScene = Scene.getSceneForLayout(mSceneRoot, R.layout.username_taken, this);
    mSuccessScene = Scene.getSceneForLayout(mSceneRoot, R.layout.success, this);
    mNewUserScene = Scene.getSceneForLayout(mSceneRoot, R.layout.new_user, this);
    mTransitionManager = new TransitionManager();
    // Custom transitions in/out of NewUser screen - slide in the 2nd password UI
    TransitionSet slider = new TransitionSet();
    slider.addTransition(new Slide().addTarget(R.id.retype).addTarget(R.id.retypeEdit));
    slider.addTransition(new Recolor().addTarget(R.id.password).addTarget(R.id.passwordEdit));
    slider.addTransition(new Fade());
    mTransitionManager.setTransition(mLoginScene, mNewUserScene, slider);
    mTransitionManager.setTransition(mPasswordScene, mNewUserScene, slider);
    mTransitionManager.setTransition(mNewUserScene, mLoginScene, slider);
    mTransitionManager.setTransition(mNewUserScene, mPasswordScene, slider);
    // Custom transitions with recoloring password field
    Transition colorizer = new Recolor().addTarget(R.id.password).addTarget(R.id.passwordEdit);
    mTransitionManager.setTransition(mLoginScene, mPasswordScene, colorizer);
    mTransitionManager.setTransition(mPasswordScene, mLoginScene, colorizer);
    mCurrentScene = mLoginScene;
}
Also used : TransitionManager(android.transition.TransitionManager) TransitionSet(android.transition.TransitionSet) Slide(android.transition.Slide) Transition(android.transition.Transition) TextView(android.widget.TextView) View(android.view.View) Fade(android.transition.Fade) Recolor(android.transition.Recolor)

Aggregations

TransitionManager (android.transition.TransitionManager)37 TransitionSet (android.transition.TransitionSet)32 View (android.view.View)29 ChangeBounds (android.transition.ChangeBounds)28 Fade (android.transition.Fade)28 Recolor (android.transition.Recolor)24 TextView (android.widget.TextView)9 TransitionInflater (android.transition.TransitionInflater)5 ImageView (android.widget.ImageView)5 MenuView (com.android.internal.view.menu.MenuView)5 DecorContentParent (com.android.internal.widget.DecorContentParent)5 Crossfade (android.transition.Crossfade)4 Slide (android.transition.Slide)4 Transition (android.transition.Transition)4