diff options
Diffstat (limited to 'policy')
3 files changed, 271 insertions, 181 deletions
diff --git a/policy/src/com/android/internal/policy/impl/BarController.java b/policy/src/com/android/internal/policy/impl/BarController.java index fc49a569..49e1072 100644 --- a/policy/src/com/android/internal/policy/impl/BarController.java +++ b/policy/src/com/android/internal/policy/impl/BarController.java @@ -108,13 +108,20 @@ public class BarController { if (mWin != null) { if (win != null && (win.getAttrs().privateFlags & WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR) == 0) { - if ((PolicyControl.getWindowFlags(win, null) & mTranslucentWmFlag) != 0) { + int fl = PolicyControl.getWindowFlags(win, null); + if ((fl & mTranslucentWmFlag) != 0) { vis |= mTranslucentFlag; } else { vis &= ~mTranslucentFlag; } + if ((fl & WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) { + vis |= View.SYSTEM_UI_TRANSPARENT; + } else { + vis &= ~View.SYSTEM_UI_TRANSPARENT; + } } else { vis = (vis & ~mTranslucentFlag) | (oldVis & mTranslucentFlag); + vis = (vis & View.SYSTEM_UI_TRANSPARENT) | (oldVis & View.SYSTEM_UI_TRANSPARENT); } } return vis; @@ -230,7 +237,8 @@ public class BarController { vis |= mTransientFlag; // ignore clear requests until transition completes vis &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; // never show transient bars in low profile } - if ((vis & mTranslucentFlag) != 0 || (oldVis & mTranslucentFlag) != 0) { + if ((vis & mTranslucentFlag) != 0 || (oldVis & mTranslucentFlag) != 0 || + ((vis | oldVis) & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0) { mLastTranslucent = SystemClock.uptimeMillis(); } return vis; diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index 6341a0c..2fea785 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -36,11 +36,10 @@ 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 com.android.internal.widget.DecorContentParent; import com.android.internal.widget.SwipeDismissLayout; -import android.animation.Animator; -import android.animation.ObjectAnimator; -import android.app.ActivityOptions; +import android.app.ActivityManager; import android.app.KeyguardManager; import android.content.Context; import android.content.pm.ActivityInfo; @@ -49,6 +48,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -56,22 +56,15 @@ import android.media.AudioManager; import android.net.Uri; import android.os.Bundle; import android.os.Handler; -import android.os.Looper; import android.os.Parcel; import android.os.Parcelable; import android.os.RemoteException; import android.os.ServiceManager; -import android.transition.ChangeBounds; -import android.transition.Explode; -import android.transition.Fade; -import android.transition.MoveImage; import android.transition.Scene; import android.transition.Transition; import android.transition.TransitionInflater; import android.transition.TransitionManager; -import android.transition.TransitionSet; import android.util.AndroidRuntimeException; -import android.util.ArrayMap; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.Log; @@ -98,7 +91,6 @@ import android.view.ViewManager; import android.view.ViewParent; import android.view.ViewRootImpl; import android.view.ViewStub; -import android.view.ViewTreeObserver; import android.view.Window; import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; @@ -113,8 +105,6 @@ import android.widget.TextView; import java.lang.ref.WeakReference; import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; /** * Android-specific Window. @@ -158,7 +148,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private TextView mTitleView; - private ActionBarView mActionBar; + private DecorContentParent mDecorContentParent; private ActionMenuPresenterCallback mActionMenuPresenterCallback; private PanelMenuPresenterCallback mPanelMenuPresenterCallback; @@ -213,6 +203,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { private int mFrameResource = 0; private int mTextColor = 0; + private int mStatusBarColor = 0; + private int mNavigationBarColor = 0; + private boolean mForcedStatusBarColor = false; + private boolean mForcedNavigationBarColor = false; private CharSequence mTitle = null; @@ -448,8 +442,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { public void setTitle(CharSequence title) { if (mTitleView != null) { mTitleView.setText(title); - } else if (mActionBar != null) { - mActionBar.setWindowTitle(title); + } else if (mDecorContentParent != null) { + mDecorContentParent.setWindowTitle(title); } mTitle = title; } @@ -496,10 +490,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { final boolean isActionBarMenu = (st.featureId == FEATURE_OPTIONS_PANEL || st.featureId == FEATURE_ACTION_BAR); - if (isActionBarMenu && mActionBar != null) { + if (isActionBarMenu && mDecorContentParent != null) { // Enforce ordering guarantees around events so that the action bar never // dispatches menu-related events before the panel is prepared. - mActionBar.setMenuPrepared(); + mDecorContentParent.setMenuPrepared(); } if (st.createdPanelView == null) { @@ -511,11 +505,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } } - if (isActionBarMenu && mActionBar != null) { + if (isActionBarMenu && mDecorContentParent != null) { if (mActionMenuPresenterCallback == null) { mActionMenuPresenterCallback = new ActionMenuPresenterCallback(); } - mActionBar.setMenu(st.menu, mActionMenuPresenterCallback); + mDecorContentParent.setMenu(st.menu, mActionMenuPresenterCallback); } // Call callback, and return if it doesn't want to display menu. @@ -527,9 +521,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // Ditch the menu created above st.setMenu(null); - if (isActionBarMenu && mActionBar != null) { + if (isActionBarMenu && mDecorContentParent != null) { // Don't show it in the action bar either - mActionBar.setMenu(null, mActionMenuPresenterCallback); + mDecorContentParent.setMenu(null, mActionMenuPresenterCallback); } return false; @@ -552,10 +546,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } if (!cb.onPreparePanel(st.featureId, st.createdPanelView, st.menu)) { - if (isActionBarMenu && mActionBar != null) { + if (isActionBarMenu && mDecorContentParent != null) { // The app didn't want to show the menu for now but it still exists. // Clear it out of the action bar. - mActionBar.setMenu(null, mActionMenuPresenterCallback); + mDecorContentParent.setMenu(null, mActionMenuPresenterCallback); } st.menu.startDispatchingItemsChanged(); return false; @@ -580,7 +574,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { @Override public void onConfigurationChanged(Configuration newConfig) { // Action bars handle their own menu state - if (mActionBar == null) { + if (mDecorContentParent == null) { PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false); if ((st != null) && (st.menu != null)) { if (st.isOpen) { @@ -632,12 +626,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { @Override public final void openPanel(int featureId, KeyEvent event) { - if (featureId == FEATURE_OPTIONS_PANEL && mActionBar != null && - mActionBar.isOverflowReserved() && + if (featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null && + mDecorContentParent.canShowOverflowMenu() && !ViewConfiguration.get(getContext()).hasPermanentMenuKey()) { - if (mActionBar.getVisibility() == View.VISIBLE) { - mActionBar.showOverflowMenu(); - } + mDecorContentParent.showOverflowMenu(); } else { openPanel(getPanelState(featureId, true), event); } @@ -766,10 +758,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { @Override public final void closePanel(int featureId) { - if (featureId == FEATURE_OPTIONS_PANEL && mActionBar != null && - mActionBar.isOverflowReserved() && + if (featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null && + mDecorContentParent.canShowOverflowMenu() && !ViewConfiguration.get(getContext()).hasPermanentMenuKey()) { - mActionBar.hideOverflowMenu(); + mDecorContentParent.hideOverflowMenu(); } else if (featureId == FEATURE_CONTEXT_MENU) { closeContextMenu(); } else { @@ -791,7 +783,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { public final void closePanel(PanelFeatureState st, boolean doCallback) { // System.out.println("Close panel: isOpen=" + st.isOpen); if (doCallback && st.featureId == FEATURE_OPTIONS_PANEL && - mActionBar != null && mActionBar.isOverflowMenuShowing()) { + mDecorContentParent != null && mDecorContentParent.isOverflowMenuShowing()) { checkCloseActionMenu(st.menu); return; } @@ -837,7 +829,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } mClosingActionMenu = true; - mActionBar.dismissPopupMenus(); + mDecorContentParent.dismissPopups(); Callback cb = getCallback(); if (cb != null && !isDestroyed()) { cb.onPanelClosed(FEATURE_ACTION_BAR, menu); @@ -883,7 +875,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // Prepare the options panel if we have an action bar if ((featureId == FEATURE_ACTION_BAR || featureId == FEATURE_OPTIONS_PANEL) - && mActionBar != null) { + && mDecorContentParent != null) { st = getPanelState(Window.FEATURE_OPTIONS_PANEL, false); if (st != null) { st.isPrepared = false; @@ -930,17 +922,15 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { boolean playSoundEffect = false; final PanelFeatureState st = getPanelState(featureId, true); - if (featureId == FEATURE_OPTIONS_PANEL && mActionBar != null && - mActionBar.isOverflowReserved() && + if (featureId == FEATURE_OPTIONS_PANEL && mDecorContentParent != null && + mDecorContentParent.canShowOverflowMenu() && !ViewConfiguration.get(getContext()).hasPermanentMenuKey()) { - if (mActionBar.getVisibility() == View.VISIBLE) { - if (!mActionBar.isOverflowMenuShowing()) { - if (!isDestroyed() && preparePanel(st, event)) { - playSoundEffect = mActionBar.showOverflowMenu(); - } - } else { - playSoundEffect = mActionBar.hideOverflowMenu(); + if (!mDecorContentParent.isOverflowMenuShowing()) { + if (!isDestroyed() && preparePanel(st, event)) { + playSoundEffect = mDecorContentParent.showOverflowMenu(); } + } else { + playSoundEffect = mDecorContentParent.hideOverflowMenu(); } } else { if (st.isOpen || st.isHandled) { @@ -1053,7 +1043,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { st.isHandled = true; // Only close down the menu if we don't have an action bar keeping it open. - if ((flags & Menu.FLAG_PERFORM_NO_CLOSE) == 0 && mActionBar == null) { + if ((flags & Menu.FLAG_PERFORM_NO_CLOSE) == 0 && mDecorContentParent == null) { closePanel(st, true); } } @@ -1075,7 +1065,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { boolean res = st.menu.performIdentifierAction(id, flags); // Only close down the menu if we don't have an action bar keeping it open. - if (mActionBar == null) { + if (mDecorContentParent == null) { closePanel(st, true); } @@ -1110,12 +1100,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } private void reopenMenu(boolean toggleMenuMode) { - if (mActionBar != null && mActionBar.isOverflowReserved() && + if (mDecorContentParent != null && mDecorContentParent.canShowOverflowMenu() && (!ViewConfiguration.get(getContext()).hasPermanentMenuKey() || - mActionBar.isOverflowMenuShowPending())) { + mDecorContentParent.isOverflowMenuShowPending())) { final Callback cb = getCallback(); - if (!mActionBar.isOverflowMenuShowing() || !toggleMenuMode) { - if (cb != null && !isDestroyed() && mActionBar.getVisibility() == View.VISIBLE) { + if (!mDecorContentParent.isOverflowMenuShowing() || !toggleMenuMode) { + if (cb != null && !isDestroyed()) { // If we have a menu invalidation pending, do it now. if (mInvalidatePanelMenuPosted && (mInvalidatePanelMenuFeatures & (1 << FEATURE_OPTIONS_PANEL)) != 0) { @@ -1130,11 +1120,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (st.menu != null && !st.refreshMenuContent && cb.onPreparePanel(FEATURE_OPTIONS_PANEL, st.createdPanelView, st.menu)) { cb.onMenuOpened(FEATURE_ACTION_BAR, st.menu); - mActionBar.showOverflowMenu(); + mDecorContentParent.showOverflowMenu(); } } } else { - mActionBar.hideOverflowMenu(); + mDecorContentParent.hideOverflowMenu(); if (cb != null && !isDestroyed()) { final PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, true); cb.onPanelClosed(FEATURE_ACTION_BAR, st.menu); @@ -1171,7 +1161,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // If we have an action bar, initialize the menu with a context themed for it. if ((st.featureId == FEATURE_OPTIONS_PANEL || st.featureId == FEATURE_ACTION_BAR) && - mActionBar != null) { + mDecorContentParent != null) { TypedValue outValue = new TypedValue(); Resources.Theme currentTheme = context.getTheme(); currentTheme.resolveAttribute(com.android.internal.R.attr.actionBarWidgetTheme, @@ -1516,8 +1506,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { mIconRes = resId; mResourcesSetFlags |= FLAG_RESOURCE_SET_ICON; mResourcesSetFlags &= ~FLAG_RESOURCE_SET_ICON_FALLBACK; - if (mActionBar != null) { - mActionBar.setIcon(resId); + if (mDecorContentParent != null) { + mDecorContentParent.setIcon(resId); } } @@ -1527,13 +1517,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { return; } mIconRes = resId; - if (mActionBar != null && (!mActionBar.hasIcon() || + if (mDecorContentParent != null && (!mDecorContentParent.hasIcon() || (mResourcesSetFlags & FLAG_RESOURCE_SET_ICON_FALLBACK) != 0)) { if (resId != 0) { - mActionBar.setIcon(resId); + mDecorContentParent.setIcon(resId); mResourcesSetFlags &= ~FLAG_RESOURCE_SET_ICON_FALLBACK; } else { - mActionBar.setIcon(getContext().getPackageManager().getDefaultActivityIcon()); + mDecorContentParent.setIcon( + getContext().getPackageManager().getDefaultActivityIcon()); mResourcesSetFlags |= FLAG_RESOURCE_SET_ICON_FALLBACK; } } @@ -1543,8 +1534,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { public void setLogo(int resId) { mLogoRes = resId; mResourcesSetFlags |= FLAG_RESOURCE_SET_LOGO; - if (mActionBar != null) { - mActionBar.setLogo(resId); + if (mDecorContentParent != null) { + mDecorContentParent.setLogo(resId); } } @@ -1554,8 +1545,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { return; } mLogoRes = resId; - if (mActionBar != null && !mActionBar.hasLogo()) { - mActionBar.setLogo(resId); + if (mDecorContentParent != null && !mDecorContentParent.hasLogo()) { + mDecorContentParent.setLogo(resId); } } @@ -1812,9 +1803,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { outState.putSparseParcelableArray(PANELS_TAG, panelStates); } - if (mActionBar != null) { + if (mDecorContentParent != null) { SparseArray<Parcelable> actionBarStates = new SparseArray<Parcelable>(); - mActionBar.saveHierarchyState(actionBarStates); + mDecorContentParent.saveToolbarHierarchyState(actionBarStates); outState.putSparseParcelableArray(ACTION_BAR_TAG, actionBarStates); } @@ -1853,11 +1844,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { restorePanelState(panelStates); } - if (mActionBar != null) { + if (mDecorContentParent != null) { SparseArray<Parcelable> actionBarStates = savedInstanceState.getSparseParcelableArray(ACTION_BAR_TAG); if (actionBarStates != null) { - mActionBar.restoreHierarchyState(actionBarStates); + mDecorContentParent.restoreToolbarHierarchyState(actionBarStates); } else { Log.w(TAG, "Missing saved instance states for action bar views! " + "State will not be restored."); @@ -1987,7 +1978,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } } - private final class DecorView extends FrameLayout implements RootViewSurfaceTaker { + private final class DecorView extends FrameLayout implements RootViewSurfaceTaker, + View.OnSystemUiVisibilityChangeListener { /* package */int mDefaultOpacity = PixelFormat.OPAQUE; /** The feature ID of the panel, or -1 if this is the application's DecorView */ @@ -2017,6 +2009,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // View added at runtime to draw under the navigation bar area private View mNavigationGuard; + private View mStatusColorView; + private View mNavigationColorView; + + private int mLastTopInset = 0; + private int mLastBottomInset = 0; + private int mLastSystemUiVisibility = 0; + + public DecorView(Context context, int featureId) { super(context); mFeatureId = featureId; @@ -2122,12 +2122,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } public boolean superDispatchKeyEvent(KeyEvent event) { - if (super.dispatchKeyEvent(event)) { - return true; - } - - // Not handled by the view hierarchy, does the action bar want it - // to cancel out of something special? + // Give priority to closing action modes if applicable. if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { final int action = event.getAction(); // Back cancels action modes first. @@ -2137,17 +2132,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } return true; } - - // Next collapse any expanded action views. - if (mActionBar != null && mActionBar.hasExpandedActionView()) { - if (action == KeyEvent.ACTION_UP) { - mActionBar.collapseActionView(); - } - return true; - } } - return false; + return super.dispatchKeyEvent(event); } public boolean superDispatchKeyShortcutEvent(KeyEvent event) { @@ -2582,8 +2569,15 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } @Override + public void onSystemUiVisibilityChange(int visible) { + mLastSystemUiVisibility = visible; + updateColorViews(null /* insets */); + } + + @Override protected boolean fitSystemWindows(Rect insets) { mFrameOffsets.set(insets); + updateColorViews(insets); updateStatusGuard(insets); updateNavigationGuard(insets); if (getForeground() != null) { @@ -2597,6 +2591,52 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { return false; } + private void updateColorViews(Rect insets) { + if (mIsFloating || !ActivityManager.isHighEndGfx()) { + // No colors on floating windows or low end devices :( + return; + } + if (insets != null) { + mLastTopInset = insets.top; + mLastBottomInset = insets.bottom; + } + mStatusColorView = updateColorViewInt(mStatusColorView, + SYSTEM_UI_FLAG_FULLSCREEN, FLAG_TRANSLUCENT_STATUS, + mStatusBarColor, mLastTopInset, Gravity.TOP); + mNavigationColorView = updateColorViewInt(mNavigationColorView, + SYSTEM_UI_FLAG_HIDE_NAVIGATION, FLAG_TRANSLUCENT_NAVIGATION, + mNavigationBarColor, mLastBottomInset, Gravity.BOTTOM); + } + + private View updateColorViewInt(View view, int systemUiHideFlag, int translucentFlag, + int color, int height, int verticalGravity) { + boolean show = height > 0 && (mLastSystemUiVisibility & systemUiHideFlag) == 0 + && (getAttributes().flags & translucentFlag) == 0 + && (color & Color.BLACK) != 0 + && (getAttributes().flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0; + + if (view == null) { + if (show) { + view = new View(mContext); + view.setBackgroundColor(color); + addView(view, new LayoutParams(LayoutParams.MATCH_PARENT, height, + Gravity.START | verticalGravity)); + } + } else { + int vis = show ? VISIBLE : INVISIBLE; + view.setVisibility(vis); + if (show) { + LayoutParams lp = (LayoutParams) view.getLayoutParams(); + if (lp.height != height) { + lp.height = height; + view.setLayoutParams(lp); + } + view.setBackgroundColor(color); + } + } + return view; + } + private void updateStatusGuard(Rect insets) { boolean showStatusGuard = false; // Show the status guard when the non-overlay contextual action bar is showing @@ -2616,9 +2656,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { mStatusGuard = new View(mContext); mStatusGuard.setBackgroundColor(mContext.getResources() .getColor(R.color.input_method_navigation_guard)); - addView(mStatusGuard, new LayoutParams( - LayoutParams.MATCH_PARENT, mlp.topMargin, - Gravity.START | Gravity.TOP)); + addView(mStatusGuard, indexOfChild(mStatusColorView), + new LayoutParams(LayoutParams.MATCH_PARENT, mlp.topMargin, + Gravity.START | Gravity.TOP)); } else { LayoutParams lp = (LayoutParams) mStatusGuard.getLayoutParams(); if (lp.height != mlp.topMargin) { @@ -2663,7 +2703,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { mNavigationGuard = new View(mContext); mNavigationGuard.setBackgroundColor(mContext.getResources() .getColor(R.color.input_method_navigation_guard)); - addView(mNavigationGuard, new LayoutParams( + addView(mNavigationGuard, indexOfChild(mNavigationColorView), new LayoutParams( LayoutParams.MATCH_PARENT, insets.bottom, Gravity.START | Gravity.BOTTOM)); } else { @@ -2789,8 +2829,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { cb.onDetachedFromWindow(); } - if (mActionBar != null) { - mActionBar.dismissPopupMenus(); + if (mDecorContentParent != null) { + mDecorContentParent.dismissPopups(); } if (mActionModePopup != null) { @@ -3009,6 +3049,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { final int targetSdk = context.getApplicationInfo().targetSdkVersion; final boolean targetPreHoneycomb = targetSdk < android.os.Build.VERSION_CODES.HONEYCOMB; final boolean targetPreIcs = targetSdk < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH; + final boolean targetPreL = targetSdk < android.os.Build.VERSION_CODES.L; final boolean targetHcNeedsOptions = context.getResources().getBoolean( com.android.internal.R.bool.target_honeycomb_needs_options_menu); final boolean noActionBar = !hasFeature(FEATURE_ACTION_BAR) || hasFeature(FEATURE_NO_TITLE); @@ -3018,7 +3059,25 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } else { clearFlags(WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY); } - + + // Non-floating windows on high end devices must put up decor beneath the system bars and + // therefore must know about visibility changes of those. + if (!mIsFloating && ActivityManager.isHighEndGfx()) { + if (!targetPreL && a.getBoolean( + com.android.internal.R.styleable.Window_windowDrawsSystemBarBackgrounds, + false)) { + setFlags(FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, + FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS & ~getForcedWindowFlags()); + } + decor.setOnSystemUiVisibilityChangeListener(decor); + } + if (!mForcedStatusBarColor) { + mStatusBarColor = a.getColor(R.styleable.Window_statusBarColor, 0xFF000000); + } + if (!mForcedNavigationBarColor) { + mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000); + } + if (mAlwaysReadCloseOnTouchAttr || getContext().getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) { if (a.getBoolean( @@ -3207,96 +3266,68 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // Set up decor part of UI to ignore fitsSystemWindows if appropriate. mDecor.makeOptionalFitsSystemWindows(); - mTitleView = (TextView)findViewById(com.android.internal.R.id.title); - if (mTitleView != null) { - mTitleView.setLayoutDirection(mDecor.getLayoutDirection()); - if ((getLocalFeatures() & (1 << FEATURE_NO_TITLE)) != 0) { - View titleContainer = findViewById(com.android.internal.R.id.title_container); - if (titleContainer != null) { - titleContainer.setVisibility(View.GONE); - } else { - mTitleView.setVisibility(View.GONE); - } - if (mContentParent instanceof FrameLayout) { - ((FrameLayout)mContentParent).setForeground(null); - } - } else { - mTitleView.setText(mTitle); + final DecorContentParent decorContentParent = (DecorContentParent) mDecor.findViewById( + com.android.internal.R.id.decor_content_parent); + + if (decorContentParent != null) { + mDecorContentParent = decorContentParent; + mDecorContentParent.setWindowCallback(getCallback()); + if (mDecorContentParent.getTitle() == null) { + mDecorContentParent.setWindowTitle(mTitle); } - } else { - mActionBar = (ActionBarView) findViewById(com.android.internal.R.id.action_bar); - if (mActionBar != null) { - mActionBar.setWindowCallback(getCallback()); - if (mActionBar.getTitle() == null) { - mActionBar.setWindowTitle(mTitle); - } - final int localFeatures = getLocalFeatures(); - if ((localFeatures & (1 << FEATURE_PROGRESS)) != 0) { - mActionBar.initProgress(); - } - if ((localFeatures & (1 << FEATURE_INDETERMINATE_PROGRESS)) != 0) { - mActionBar.initIndeterminateProgress(); - } - final ActionBarOverlayLayout abol = (ActionBarOverlayLayout) findViewById( - com.android.internal.R.id.action_bar_overlay_layout); - if (abol != null) { - abol.setOverlayMode( - (localFeatures & (1 << FEATURE_ACTION_BAR_OVERLAY)) != 0); + final int localFeatures = getLocalFeatures(); + for (int i = 0; i < FEATURE_MAX; i++) { + if ((localFeatures & (1 << i)) != 0) { + mDecorContentParent.initFeature(i); } + } - boolean splitActionBar = false; - final boolean splitWhenNarrow = - (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0; - if (splitWhenNarrow) { - splitActionBar = getContext().getResources().getBoolean( - com.android.internal.R.bool.split_action_bar_is_narrow); - } else { - splitActionBar = getWindowStyle().getBoolean( - com.android.internal.R.styleable.Window_windowSplitActionBar, false); - } - final ActionBarContainer splitView = (ActionBarContainer) findViewById( - com.android.internal.R.id.split_action_bar); - if (splitView != null) { - mActionBar.setSplitView(splitView); - mActionBar.setSplitActionBar(splitActionBar); - mActionBar.setSplitWhenNarrow(splitWhenNarrow); - - final ActionBarContextView cab = (ActionBarContextView) findViewById( - com.android.internal.R.id.action_context_bar); - cab.setSplitView(splitView); - cab.setSplitActionBar(splitActionBar); - cab.setSplitWhenNarrow(splitWhenNarrow); - } else if (splitActionBar) { - Log.e(TAG, "Requested split action bar with " + - "incompatible window decor! Ignoring request."); - } + mDecorContentParent.setUiOptions(mUiOptions); - if ((mResourcesSetFlags & FLAG_RESOURCE_SET_ICON) != 0 || - (mIconRes != 0 && !mActionBar.hasIcon())) { - mActionBar.setIcon(mIconRes); - } else if ((mResourcesSetFlags & FLAG_RESOURCE_SET_ICON) == 0 && - mIconRes == 0 && !mActionBar.hasIcon()) { - mActionBar.setIcon( - getContext().getPackageManager().getDefaultActivityIcon()); - mResourcesSetFlags |= FLAG_RESOURCE_SET_ICON_FALLBACK; - } - if ((mResourcesSetFlags & FLAG_RESOURCE_SET_LOGO) != 0 || - (mLogoRes != 0 && !mActionBar.hasLogo())) { - mActionBar.setLogo(mLogoRes); - } + 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); + } - // Post the panel invalidate for later; avoid application onCreateOptionsMenu - // being called in the middle of onCreate or similar. - mDecor.post(new Runnable() { - public void run() { - // Invalidate if the panel menu hasn't been created before this. - PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false); - if (!isDestroyed() && (st == null || st.menu == null)) { - invalidatePanelMenu(FEATURE_ACTION_BAR); - } + // Post the panel invalidate for later; avoid application onCreateOptionsMenu + // being called in the middle of onCreate or similar. + mDecor.post(new Runnable() { + public void run() { + // Invalidate if the panel menu hasn't been created before this. + PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false); + if (!isDestroyed() && (st == null || st.menu == null)) { + invalidatePanelMenu(FEATURE_ACTION_BAR); + } + } + }); + } else { + mTitleView = (TextView)findViewById(com.android.internal.R.id.title); + if (mTitleView != null) { + mTitleView.setLayoutDirection(mDecor.getLayoutDirection()); + if ((getLocalFeatures() & (1 << FEATURE_NO_TITLE)) != 0) { + View titleContainer = findViewById( + com.android.internal.R.id.title_container); + if (titleContainer != null) { + titleContainer.setVisibility(View.GONE); + } else { + mTitleView.setVisibility(View.GONE); + } + if (mContentParent instanceof FrameLayout) { + ((FrameLayout)mContentParent).setForeground(null); } - }); + } else { + mTitleView.setText(mTitle); + } } } @@ -3522,6 +3553,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { return (mLeftIconView = (ImageView)findViewById(com.android.internal.R.id.left_icon)); } + @Override + protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) { + super.dispatchWindowAttributesChanged(attrs); + if (mDecor != null) { + mDecor.updateColorViews(null /* insets */); + } + } + private ProgressBar getCircularProgressBar(boolean shouldInstallDecor) { if (mCircularProgressBar != null) { return mCircularProgressBar; @@ -4166,4 +4205,32 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { void sendCloseSystemWindows(String reason) { PhoneWindowManager.sendCloseSystemWindows(getContext(), reason); } + + @Override + public int getStatusBarColor() { + return mStatusBarColor; + } + + @Override + public void setStatusBarColor(int color) { + mStatusBarColor = color; + mForcedStatusBarColor = true; + if (mDecor != null) { + mDecor.updateColorViews(null); + } + } + + @Override + public int getNavigationBarColor() { + return mNavigationBarColor; + } + + @Override + public void setNavigationBarColor(int color) { + mNavigationBarColor = color; + mForcedNavigationBarColor = true; + if (mDecor != null) { + mDecor.updateColorViews(null); + } + } } diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 43c7391..466c8ed 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -170,7 +170,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.STATUS_BAR_TRANSLUCENT - | View.NAVIGATION_BAR_TRANSLUCENT; + | View.NAVIGATION_BAR_TRANSLUCENT + | View.SYSTEM_UI_TRANSPARENT; /** * Keyguard stuff @@ -1316,6 +1317,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { // The status bar is the only window allowed to exhibit keyguard behavior. attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; } + + if (ActivityManager.isHighEndGfx() + && (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) { + attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; + } } void readLidState() { @@ -2682,7 +2690,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { // drive nav being hidden only by whether it is requested. final int sysui = mLastSystemUiFlags; boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; - boolean navTranslucent = (sysui & View.NAVIGATION_BAR_TRANSLUCENT) != 0; + boolean navTranslucent = (sysui + & (View.NAVIGATION_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0; boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; boolean navAllowedHidden = immersive || immersiveSticky; @@ -2808,7 +2817,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0; - boolean statusBarTranslucent = (sysui & View.STATUS_BAR_TRANSLUCENT) != 0; + boolean statusBarTranslucent = (sysui + & (View.STATUS_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; statusBarTranslucent &= areTranslucentBarsAllowed(); // If the status bar is hidden, we don't want to cause @@ -3004,12 +3014,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (isAppWindow && !inheritTranslucentDecor && !topAtRest) { if ((sysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 && (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0 - && (fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == 0) { + && (fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == 0 + && (fl & WindowManager.LayoutParams. + FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { // Ensure policy decor includes status bar dcf.top = mStableTop; } if ((fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == 0 - && (sysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) { + && (sysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0 + && (fl & WindowManager.LayoutParams. + FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { // Ensure policy decor includes navigation bar dcf.bottom = mStableBottom; dcf.right = mStableRight; @@ -5206,7 +5220,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } if (!areTranslucentBarsAllowed()) { - vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT); + vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT + | View.SYSTEM_UI_TRANSPARENT); } // update status bar |