diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java index f041f07817682..db20549ee5ae7 100644 --- a/core/java/com/android/internal/app/ActionBarImpl.java +++ b/core/java/com/android/internal/app/ActionBarImpl.java @@ -110,6 +110,7 @@ public class ActionBarImpl extends ActionBar { private int mCurWindowVisibility = View.VISIBLE; + private boolean mContentAnimations = true; private boolean mHiddenByApp; private boolean mHiddenBySystem; private boolean mShowingForMode; @@ -122,7 +123,7 @@ public class ActionBarImpl extends ActionBar { final AnimatorListener mHideListener = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - if (mContentView != null) { + if (mContentAnimations && mContentView != null) { mContentView.setTranslationY(0); mTopVisibilityView.setTranslationY(0); } @@ -151,23 +152,24 @@ public class ActionBarImpl extends ActionBar { mActivity = activity; Window window = activity.getWindow(); View decor = window.getDecorView(); - init(decor); - if (!mActivity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) { + boolean overlayMode = mActivity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY); + init(decor, overlayMode); + if (!overlayMode) { mContentView = decor.findViewById(android.R.id.content); } } public ActionBarImpl(Dialog dialog) { mDialog = dialog; - init(dialog.getWindow().getDecorView()); + init(dialog.getWindow().getDecorView(), false); } - private void init(View decor) { + private void init(View decor, boolean overlayMode) { mContext = decor.getContext(); mOverlayLayout = (ActionBarOverlayLayout) decor.findViewById( com.android.internal.R.id.action_bar_overlay_layout); if (mOverlayLayout != null) { - mOverlayLayout.setActionBar(this); + mOverlayLayout.setActionBar(this, overlayMode); } mActionView = (ActionBarView) decor.findViewById(com.android.internal.R.id.action_bar); mContextView = (ActionBarContextView) decor.findViewById( @@ -586,6 +588,10 @@ public class ActionBarImpl extends ActionBar { return mContainerView.getHeight(); } + public void enableContentAnimations(boolean enabled) { + mContentAnimations = enabled; + } + @Override public void show() { if (mHiddenByApp) { @@ -684,7 +690,7 @@ public class ActionBarImpl extends ActionBar { AnimatorSet anim = new AnimatorSet(); AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mTopVisibilityView, "translationY", 0)); - if (mContentView != null) { + if (mContentAnimations && mContentView != null) { b.with(ObjectAnimator.ofFloat(mContentView, "translationY", startingY, 0)); } @@ -709,7 +715,7 @@ public class ActionBarImpl extends ActionBar { } else { mTopVisibilityView.setAlpha(1); mTopVisibilityView.setTranslationY(0); - if (mContentView != null) { + if (mContentAnimations && mContentView != null) { mContentView.setTranslationY(0); } if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { @@ -742,7 +748,7 @@ public class ActionBarImpl extends ActionBar { } AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mTopVisibilityView, "translationY", endingY)); - if (mContentView != null) { + if (mContentAnimations && mContentView != null) { b.with(ObjectAnimator.ofFloat(mContentView, "translationY", 0, endingY)); } diff --git a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java index 18a696e31489e..482eba71e959a 100644 --- a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java +++ b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java @@ -40,6 +40,7 @@ public class ActionBarOverlayLayout extends FrameLayout { private ActionBarContainer mContainerView; private ActionBarView mActionView; private View mActionBarBottom; + private boolean mOverlayMode; private int mLastSystemUiVisibility; private final Rect mLocalInsets = new Rect(); @@ -63,8 +64,13 @@ public class ActionBarOverlayLayout extends FrameLayout { ta.recycle(); } - public void setActionBar(ActionBarImpl impl) { + public void setOverlayMode(boolean mode) { + mOverlayMode = mode; + } + + public void setActionBar(ActionBarImpl impl, boolean overlayMode) { mActionBar = impl; + mOverlayMode = overlayMode; if (getWindowToken() != null) { // This is being initialized after being added to a window; // make sure to update all state now. @@ -105,8 +111,13 @@ public class ActionBarOverlayLayout extends FrameLayout { mLastSystemUiVisibility = visible; final boolean barVisible = (visible&SYSTEM_UI_FLAG_FULLSCREEN) == 0; final boolean wasVisible = mActionBar != null ? mActionBar.isSystemShowing() : true; + final boolean stable = (visible&SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0; if (mActionBar != null) { - if (barVisible) mActionBar.showForSystem(); + // We want the bar to be visible if it is not being hidden, + // or the app has not turned on a stable UI mode (meaning they + // are performing explicit layout around the action bar). + mActionBar.enableContentAnimations(!stable); + if (barVisible || !stable) mActionBar.showForSystem(); else mActionBar.hideForSystem(); } if ((diff&SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { @@ -161,35 +172,42 @@ public class ActionBarOverlayLayout extends FrameLayout { changed |= applyInsets(mActionBarBottom, insets, true, false, true, true); } + int topSpace = 0; + if (stable || mActionBarTop.getVisibility() == VISIBLE) { + // This is the space needed on top of the window for the action bar. + topSpace = mActionBarHeight; + } + if (mActionBar != null && mActionBar.hasNonEmbeddedTabs()) { + View tabs = mContainerView.getTabContainer(); + if (tabs != null && (stable || tabs.getVisibility() == VISIBLE)) { + // If tabs are not embedded, increase space on top to account for them. + topSpace += mActionBarHeight; + } + } + + int bottomSpace = 0; + if (mActionView.isSplitActionBar()) { + if ((mActionBarBottom != null + && (stable || mActionBarBottom.getVisibility() == VISIBLE))) { + // If action bar is split, adjust bottom insets for it. + bottomSpace = mActionBarHeight; + } + } + // If the window has not requested system UI layout flags, we need to // make sure its content is not being covered by system UI... though it // will still be covered by the action bar since they have requested it to // overlay. boolean res = computeFitSystemWindows(insets, mLocalInsets); + if (!mOverlayMode && !stable) { + mLocalInsets.top += topSpace; + mLocalInsets.bottom += bottomSpace; + } else { + insets.top += topSpace; + insets.bottom += bottomSpace; + } changed |= applyInsets(mContent, mLocalInsets, true, true, true, true); - - if (stable || mActionBarTop.getVisibility() == VISIBLE) { - // The action bar creates additional insets for its content to use. - insets.top += mActionBarHeight; - } - - if (mActionBar != null && mActionBar.hasNonEmbeddedTabs()) { - View tabs = mContainerView.getTabContainer(); - if (stable || (tabs != null && tabs.getVisibility() == VISIBLE)) { - // If tabs are not embedded, adjust insets to account for them. - insets.top += mActionBarHeight; - } - } - - if (mActionView.isSplitActionBar()) { - if (stable || (mActionBarBottom != null - && mActionBarBottom.getVisibility() == VISIBLE)) { - // If action bar is split, adjust bottom insets for it. - insets.bottom += mActionBarHeight; - } - } - if (changed) { requestLayout(); } diff --git a/core/res/res/layout/screen_action_bar.xml b/core/res/res/layout/screen_action_bar.xml index f0b2313eee214..95519c6d48c66 100644 --- a/core/res/res/layout/screen_action_bar.xml +++ b/core/res/res/layout/screen_action_bar.xml @@ -18,38 +18,47 @@ This is an optimized layout for a screen with the Action Bar enabled. --> - - - - - + android:layout_width="match_parent" + android:layout_height="match_parent" /> + + + + + + + - + diff --git a/core/res/res/layout/screen_action_bar_overlay.xml b/core/res/res/layout/screen_action_bar_overlay.xml deleted file mode 100644 index c8181d18ff3c6..0000000000000 --- a/core/res/res/layout/screen_action_bar_overlay.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index e1d9b73845104..5ad305cbd2a2e 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -33,6 +33,7 @@ import com.android.internal.view.menu.MenuPresenter; import com.android.internal.view.menu.MenuView; import com.android.internal.widget.ActionBarContainer; import com.android.internal.widget.ActionBarContextView; +import com.android.internal.widget.ActionBarOverlayLayout; import com.android.internal.widget.ActionBarView; import android.app.KeyguardManager; @@ -2788,11 +2789,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { com.android.internal.R.attr.dialogTitleDecorLayout, res, true); layoutResource = res.resourceId; } else if ((features & (1 << FEATURE_ACTION_BAR)) != 0) { - if ((features & (1 << FEATURE_ACTION_BAR_OVERLAY)) != 0) { - layoutResource = com.android.internal.R.layout.screen_action_bar_overlay; - } else { - layoutResource = com.android.internal.R.layout.screen_action_bar; - } + layoutResource = com.android.internal.R.layout.screen_action_bar; } else { layoutResource = com.android.internal.R.layout.screen_title; } diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java index 30a968ffd33d9..66337870feb16 100644 --- a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java +++ b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java @@ -272,7 +272,7 @@ public class FrameworkPerfActivity extends Activity args.bgOp = mCurOpIndex; } else { args.fgOp = mCurOpIndex; - args.bgOp = mFgTestIndex; + args.bgOp = mBgTestIndex; } } Bundle bundle = new Bundle(); @@ -424,6 +424,8 @@ public class FrameworkPerfActivity extends Activity updateWakeLock(); stopService(new Intent(this, SchedulerService.class)); synchronized (mResults) { + Log.i("PerfRes", "\tTEST\tFgOps\tFgMsPerOp\tFgTime\tFgName\tBgOps\tBgMsPerOp\t" + + "BgTime\tBgName"); for (int i=0; i