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
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 3e19811..9b26aeb 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -26,6 +26,7 @@
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.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 @@
private Animator mCurrentAnim;
+ private static final TimeInterpolator sFadeOutInterpolator = new DecelerateInterpolator();
+
final AnimatorListener[] mAfterAnimation = new AnimatorListener[] {
new AnimatorListener() { // NORMAL_VIEW
@Override
@@ -166,6 +170,7 @@
@Override
public void onAnimationEnd(Animator animation) {
mCurrentAnim = null;
+ mContainerView.requestLayout();
}
@Override
@@ -492,12 +497,12 @@
@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 @@
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 @@
}
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));
- }
}
}
diff --git a/core/java/com/android/internal/widget/ActionBarContainer.java b/core/java/com/android/internal/widget/ActionBarContainer.java
new file mode 100644
index 0000000..e520e69
--- /dev/null
+++ b/core/java/com/android/internal/widget/ActionBarContainer.java
@@ -0,0 +1,42 @@
+/*
+ * 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();
+ }
+}
diff --git a/core/java/com/android/internal/widget/ActionBarContextView.java b/core/java/com/android/internal/widget/ActionBarContextView.java
index 6d4c6bd..60c3487 100644
--- a/core/java/com/android/internal/widget/ActionBarContextView.java
+++ b/core/java/com/android/internal/widget/ActionBarContextView.java
@@ -159,15 +159,13 @@
}
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 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 @@
}
private void finishAnimation() {
- if (mCurrentAnimation != null && mCurrentAnimation.isRunning()) {
- mCurrentAnimation.end();
+ final Animator a = mCurrentAnimation;
+ if (a != null && a.isRunning()) {
+ mCurrentAnimation = null;
+ a.end();
}
}
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 931bea9..ccec32a 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -183,11 +183,6 @@
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);
diff --git a/core/res/res/layout-xlarge/screen_action_bar.xml b/core/res/res/layout-xlarge/screen_action_bar.xml
index 5aae733..751d322 100644
--- a/core/res/res/layout-xlarge/screen_action_bar.xml
+++ b/core/res/res/layout-xlarge/screen_action_bar.xml
@@ -21,9 +21,10 @@
<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 @@
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"
diff --git a/core/res/res/layout-xlarge/screen_action_bar_overlay.xml b/core/res/res/layout-xlarge/screen_action_bar_overlay.xml
index 11e0eac..89f0d89 100644
--- a/core/res/res/layout-xlarge/screen_action_bar_overlay.xml
+++ b/core/res/res/layout-xlarge/screen_action_bar_overlay.xml
@@ -24,9 +24,10 @@
<FrameLayout android:id="@android:id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
- <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"
+ style="?android:attr/actionBarStyle"
android:gravity="top">
<com.android.internal.widget.ActionBarView
android:id="@+id/action_bar"
@@ -39,7 +40,7 @@
android:layout_height="wrap_content"
android:visibility="gone"
style="?android:attr/actionModeStyle" />
- </FrameLayout>
+ </com.android.internal.widget.ActionBarContainer>
<ImageView android:src="?android:attr/windowContentOverlay"
android:scaleType="fitXY"
android:layout_width="match_parent"
diff --git a/core/res/res/layout/screen_action_bar.xml b/core/res/res/layout/screen_action_bar.xml
index e60a7e3..70af265 100644
--- a/core/res/res/layout/screen_action_bar.xml
+++ b/core/res/res/layout/screen_action_bar.xml
@@ -21,9 +21,10 @@
<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 @@
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"
diff --git a/core/res/res/layout/screen_action_bar_overlay.xml b/core/res/res/layout/screen_action_bar_overlay.xml
index 47d87a9..b486ee7 100644
--- a/core/res/res/layout/screen_action_bar_overlay.xml
+++ b/core/res/res/layout/screen_action_bar_overlay.xml
@@ -24,9 +24,10 @@
<FrameLayout android:id="@android:id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
- <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"
+ style="?android:attr/actionBarStyle"
android:gravity="top">
<com.android.internal.widget.ActionBarView
android:id="@+id/action_bar"
@@ -39,7 +40,7 @@
android:layout_height="wrap_content"
android:visibility="gone"
style="?android:attr/actionModeStyle" />
- </FrameLayout>
+ </com.android.internal.widget.ActionBarContainer>
<ImageView android:src="?android:attr/windowContentOverlay"
android:scaleType="fitXY"
android:layout_width="match_parent"