Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45f1e08c authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 3259354 - Handle ActionBar backgrounds better for interacting

with action modes.

Tweak ActionBar/mode transition animation to look better with a
variety of action bar styles.

Fix bug 3273773 - ActionBar disappearing while displaying
popupwindow. Some SurfaceFlinger optimizations require a relayout to
recalculate the bounds of overlaid views.

Fix bug 3266010 - Cancel animations properly when switching between
modes.

Change-Id: Ic431176b11115a2211bd0a46d09c8998aefe58d6
parent 2711e494
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Dialog;
@@ -41,6 +42,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.SpinnerAdapter;
@@ -91,6 +93,8 @@ public class ActionBarImpl extends ActionBar {

    private Animator mCurrentAnim;

    private static final TimeInterpolator sFadeOutInterpolator = new DecelerateInterpolator();

    final AnimatorListener[] mAfterAnimation = new AnimatorListener[] {
            new AnimatorListener() { // NORMAL_VIEW
                @Override
@@ -166,6 +170,7 @@ public class ActionBarImpl extends ActionBar {
        @Override
        public void onAnimationEnd(Animator animation) {
            mCurrentAnim = null;
            mContainerView.requestLayout();
        }

        @Override
@@ -492,12 +497,12 @@ public class ActionBarImpl extends ActionBar {

    @Override
    public void show() {
        if (mCurrentAnim != null) {
            mCurrentAnim.end();
        }
        if (mContainerView.getVisibility() == View.VISIBLE) {
            return;
        }
        if (mCurrentAnim != null) {
            mCurrentAnim.end();
        }
        mContainerView.setVisibility(View.VISIBLE);
        mContainerView.setAlpha(0);
        mContainerView.setTranslationY(-mContainerView.getHeight());
@@ -545,10 +550,6 @@ public class ActionBarImpl extends ActionBar {
        final View targetChild = mContainerView.getChildAt(viewIndex);
        targetChild.setVisibility(View.VISIBLE);
        AnimatorSet.Builder b = set.play(ObjectAnimator.ofFloat(targetChild, "alpha", 1));
        if (viewIndex == NORMAL_VIEW) {
            targetChild.setScaleY(0);
            b.with(ObjectAnimator.ofFloat(targetChild, "scaleY", 1));
        }

        final int count = mContainerView.getChildCount();
        for (int i = 0; i < count; i++) {
@@ -558,11 +559,9 @@ public class ActionBarImpl extends ActionBar {
            }

            if (child.getVisibility() != View.GONE) {
                ObjectAnimator a = ObjectAnimator.ofFloat(child, "alpha", 0);
                Animator a = ObjectAnimator.ofFloat(child, "alpha", 0);
                a.setInterpolator(sFadeOutInterpolator);
                b.with(a);
                if (viewIndex == CONTEXT_VIEW) {
                    b.with(ObjectAnimator.ofFloat(child, "scaleY", 0));
                }
            }
        }

+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 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.internal.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.FrameLayout;

/**
 * This class acts as a container for the action bar view and action mode context views.
 * It applies special styles as needed to help handle animated transitions between them.
 * @hide
 */
public class ActionBarContainer extends FrameLayout {
    public ActionBarContainer(Context context) {
        this(context, null);
    }

    public ActionBarContainer(Context context, AttributeSet attrs) {
        super(context, attrs);

        TypedArray a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.ActionBar);
        setBackgroundDrawable(a.getDrawable(com.android.internal.R.styleable.ActionBar_background));
        a.recycle();
    }
}
+11 −7
Original line number Diff line number Diff line
@@ -159,15 +159,13 @@ public class ActionBarContextView extends ViewGroup implements AnimatorListener
    }

    public void initForMode(final ActionMode mode) {
        if (mCurrentAnimation != null && mCurrentAnimation.isRunning()) {
            mCurrentAnimation.end();
            killMode();
        }
        finishAnimation();

        if (mClose == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            mClose = inflater.inflate(R.layout.action_mode_close_item, this, false);
            addView(mClose);
        } else {
        } else if (mClose.getParent() == null) {
            addView(mClose);
        }

@@ -188,6 +186,10 @@ public class ActionBarContextView extends ViewGroup implements AnimatorListener
    }

    public void closeMode() {
        if (mAnimationMode == ANIMATE_OUT) {
            // Called again during close; just finish what we were doing.
            return;
        }
        if (mClose == null) {
            killMode();
            return;
@@ -200,8 +202,10 @@ public class ActionBarContextView extends ViewGroup implements AnimatorListener
    }

    private void finishAnimation() {
        if (mCurrentAnimation != null && mCurrentAnimation.isRunning()) {
            mCurrentAnimation.end();
        final Animator a = mCurrentAnimation;
        if (a != null && a.isRunning()) {
            mCurrentAnimation = null;
            a.end();
        }
    }

+0 −5
Original line number Diff line number Diff line
@@ -183,11 +183,6 @@ public class ActionBarView extends ViewGroup {
        mHomeAsUpView = mHomeLayout.findViewById(com.android.internal.R.id.up);
        mIconView = (ImageView) mHomeLayout.findViewById(com.android.internal.R.id.home);
        
        Drawable background = a.getDrawable(R.styleable.ActionBar_background);
        if (background != null) {
            setBackgroundDrawable(background);
        }
        
        mTitleStyleRes = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
        mSubtitleStyleRes = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
        mProgressStyle = a.getResourceId(R.styleable.ActionBar_progressBarStyle, 0);
+4 −3
Original line number Diff line number Diff line
@@ -21,9 +21,10 @@ This is an optimized layout for a screen with the Action Bar enabled.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:fitsSystemWindows="true">
    <FrameLayout android:id="@+id/action_bar_container"
    <com.android.internal.widget.ActionBarContainer android:id="@+id/action_bar_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        android:layout_height="wrap_content"
        style="?android:attr/actionBarStyle">
        <com.android.internal.widget.ActionBarView
            android:id="@+id/action_bar"
            android:layout_width="match_parent"
@@ -35,7 +36,7 @@ This is an optimized layout for a screen with the Action Bar enabled.
            android:layout_height="wrap_content"
            android:visibility="gone"
            style="?android:attr/actionModeStyle" />
    </FrameLayout>
    </com.android.internal.widget.ActionBarContainer>
    <FrameLayout android:id="@android:id/content"
        android:layout_width="match_parent"
        android:layout_height="0dip"
Loading