private int mCurWindowVisibility = View.VISIBLE;
+ private boolean mContentAnimations = true;
private boolean mHiddenByApp;
private boolean mHiddenBySystem;
private boolean mShowingForMode;
final AnimatorListener mHideListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- if (mContentView != null) {
+ if (mContentAnimations && mContentView != null) {
mContentView.setTranslationY(0);
mTopVisibilityView.setTranslationY(0);
}
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(
return mContainerView.getHeight();
}
+ public void enableContentAnimations(boolean enabled) {
+ mContentAnimations = enabled;
+ }
+
@Override
public void show() {
if (mHiddenByApp) {
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));
}
} else {
mTopVisibilityView.setAlpha(1);
mTopVisibilityView.setTranslationY(0);
- if (mContentView != null) {
+ if (mContentAnimations && mContentView != null) {
mContentView.setTranslationY(0);
}
if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
}
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));
}
private ActionBarContainer mContainerView;
private ActionBarView mActionView;
private View mActionBarBottom;
+ private boolean mOverlayMode;
private int mLastSystemUiVisibility;
private final Rect mLocalInsets = new Rect();
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.
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) {
changed |= applyInsets(mActionBarBottom, insets, true, false, true, true);
}
- // 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);
- changed |= applyInsets(mContent, mLocalInsets, true, true, true, true);
-
-
+ int topSpace = 0;
if (stable || mActionBarTop.getVisibility() == VISIBLE) {
- // The action bar creates additional insets for its content to use.
- insets.top += mActionBarHeight;
+ // 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 (stable || (tabs != null && tabs.getVisibility() == VISIBLE)) {
- // If tabs are not embedded, adjust insets to account for them.
- insets.top += mActionBarHeight;
+ 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 (stable || (mActionBarBottom != null
- && mActionBarBottom.getVisibility() == VISIBLE)) {
+ if ((mActionBarBottom != null
+ && (stable || mActionBarBottom.getVisibility() == VISIBLE))) {
// If action bar is split, adjust bottom insets for it.
- insets.bottom += mActionBarHeight;
+ 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 (changed) {
requestLayout();
}
This is an optimized layout for a screen with the Action Bar enabled.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.internal.widget.ActionBarOverlayLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/action_bar_overlay_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical"
- android:fitsSystemWindows="true"
android:splitMotionEvents="false">
- <com.android.internal.widget.ActionBarContainer android:id="@+id/action_bar_container"
+ <FrameLayout android:id="@android:id/content"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- style="?android:attr/actionBarStyle">
- <com.android.internal.widget.ActionBarView
- android:id="@+id/action_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- style="?android:attr/actionBarStyle" />
- <com.android.internal.widget.ActionBarContextView
- android:id="@+id/action_context_bar"
+ android:layout_height="match_parent" />
+ <LinearLayout android:id="@+id/top_action_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top">
+ <com.android.internal.widget.ActionBarContainer android:id="@+id/action_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:visibility="gone"
- style="?android:attr/actionModeStyle" />
- </com.android.internal.widget.ActionBarContainer>
- <FrameLayout android:id="@android:id/content"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1"
- android:foregroundGravity="fill_horizontal|top"
- android:foreground="?android:attr/windowContentOverlay" />
+ android:layout_alignParentTop="true"
+ style="?android:attr/actionBarStyle"
+ android:gravity="top">
+ <com.android.internal.widget.ActionBarView
+ android:id="@+id/action_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="?android:attr/actionBarStyle" />
+ <com.android.internal.widget.ActionBarContextView
+ android:id="@+id/action_context_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ style="?android:attr/actionModeStyle" />
+ </com.android.internal.widget.ActionBarContainer>
+ <ImageView android:src="?android:attr/windowContentOverlay"
+ android:scaleType="fitXY"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+ </LinearLayout>
<com.android.internal.widget.ActionBarContainer android:id="@+id/split_action_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
style="?android:attr/actionBarSplitStyle"
android:visibility="gone"
android:gravity="center"/>
-</LinearLayout>
+</com.android.internal.widget.ActionBarOverlayLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<!--
-This is an optimized layout for a screen with
-the Action Bar enabled overlaying application content.
--->
-
-<com.android.internal.widget.ActionBarOverlayLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/action_bar_overlay_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:splitMotionEvents="false">
- <FrameLayout android:id="@android:id/content"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- <LinearLayout android:id="@+id/top_action_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top">
- <com.android.internal.widget.ActionBarContainer android:id="@+id/action_bar_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- style="?android:attr/actionBarStyle"
- android:gravity="top">
- <com.android.internal.widget.ActionBarView
- android:id="@+id/action_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- style="?android:attr/actionBarStyle" />
- <com.android.internal.widget.ActionBarContextView
- android:id="@+id/action_context_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone"
- style="?android:attr/actionModeStyle" />
- </com.android.internal.widget.ActionBarContainer>
- <ImageView android:src="?android:attr/windowContentOverlay"
- android:scaleType="fitXY"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
- </LinearLayout>
- <com.android.internal.widget.ActionBarContainer android:id="@+id/split_action_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- style="?android:attr/actionBarSplitStyle"
- android:visibility="gone"
- android:gravity="center"/>
-</com.android.internal.widget.ActionBarOverlayLayout>
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;
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;
}
args.bgOp = mCurOpIndex;
} else {
args.fgOp = mCurOpIndex;
- args.bgOp = mFgTestIndex;
+ args.bgOp = mBgTestIndex;
}
}
Bundle bundle = new Bundle();
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<mResults.size(); i++) {
RunResult result = mResults.get(i);
float fgMsPerOp = result.getFgMsPerOp();
threadFinished(false);
}
}, Process.THREAD_PRIORITY_BACKGROUND);
- mForegroundThread = new RunnerThread("background", new Runnable() {
+ mForegroundThread = new RunnerThread("foreground", new Runnable() {
@Override public void run() {
boolean running;
int ops = 0;