summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/com/android/internal/app/WindowDecorActionBar.java2
-rw-r--r--core/java/com/android/internal/widget/ActionBarOverlayLayout.java188
-rw-r--r--core/java/com/android/internal/widget/DecorContentParent.java53
-rw-r--r--core/res/res/layout-xlarge/screen_action_bar.xml51
-rw-r--r--core/res/res/layout/screen_action_bar.xml2
-rw-r--r--core/res/res/values/attrs.xml5
-rw-r--r--core/res/res/values/symbols.xml2
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java265
8 files changed, 352 insertions, 216 deletions
diff --git a/core/java/com/android/internal/app/WindowDecorActionBar.java b/core/java/com/android/internal/app/WindowDecorActionBar.java
index 79a8f44..a238ae3 100644
--- a/core/java/com/android/internal/app/WindowDecorActionBar.java
+++ b/core/java/com/android/internal/app/WindowDecorActionBar.java
@@ -183,7 +183,7 @@ public class WindowDecorActionBar extends ActionBar implements
private void init(View decor) {
mOverlayLayout = (ActionBarOverlayLayout) decor.findViewById(
- com.android.internal.R.id.action_bar_overlay_layout);
+ com.android.internal.R.id.decor_content_parent);
if (mOverlayLayout != null) {
mOverlayLayout.setActionBarVisibilityCallback(this);
}
diff --git a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java
index 19d58bf..7ab4bed 100644
--- a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java
+++ b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java
@@ -19,26 +19,34 @@ package com.android.internal.widget;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
+import android.content.pm.ActivityInfo;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
+import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.IntProperty;
+import android.util.Log;
import android.util.Property;
+import android.util.SparseArray;
+import android.view.KeyEvent;
+import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
+import android.view.Window;
import android.view.WindowInsets;
import android.widget.OverScroller;
+import com.android.internal.view.menu.MenuPresenter;
/**
* Special layout for the containing of an overlay action bar (and its
* content) to correctly handle fitting system windows when the content
* has request that its layout ignore them.
*/
-public class ActionBarOverlayLayout extends ViewGroup {
+public class ActionBarOverlayLayout extends ViewGroup implements DecorContentParent {
private static final String TAG = "ActionBarOverlayLayout";
private int mActionBarHeight;
@@ -47,7 +55,7 @@ public class ActionBarOverlayLayout extends ViewGroup {
// The main UI elements that we handle the layout of.
private View mContent;
- private View mActionBarBottom;
+ private ActionBarContainer mActionBarBottom;
private ActionBarContainer mActionBarTop;
// Some interior UI elements.
@@ -556,7 +564,8 @@ public class ActionBarOverlayLayout extends ViewGroup {
mActionBarTop = (ActionBarContainer) findViewById(
com.android.internal.R.id.action_bar_container);
mActionBarView = (ActionBarView) findViewById(com.android.internal.R.id.action_bar);
- mActionBarBottom = findViewById(com.android.internal.R.id.split_action_bar);
+ mActionBarBottom = (ActionBarContainer) findViewById(
+ com.android.internal.R.id.split_action_bar);
}
}
@@ -629,6 +638,179 @@ public class ActionBarOverlayLayout extends ViewGroup {
return finalY > mActionBarTop.getHeight();
}
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ if (super.dispatchKeyEvent(event)) {
+ return true;
+ }
+
+ if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
+ final int action = event.getAction();
+
+ // Collapse any expanded action views.
+ if (mActionBarView != null && mActionBarView.hasExpandedActionView()) {
+ if (action == KeyEvent.ACTION_UP) {
+ mActionBarView.collapseActionView();
+ }
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public void setWindowCallback(Window.Callback cb) {
+ pullChildren();
+ mActionBarView.setWindowCallback(cb);
+ }
+
+ @Override
+ public void setWindowTitle(CharSequence title) {
+ pullChildren();
+ mActionBarView.setWindowTitle(title);
+ }
+
+ @Override
+ public CharSequence getTitle() {
+ pullChildren();
+ return mActionBarView.getTitle();
+ }
+
+ @Override
+ public void initFeature(int windowFeature) {
+ pullChildren();
+ switch (windowFeature) {
+ case Window.FEATURE_PROGRESS:
+ mActionBarView.initProgress();
+ break;
+ case Window.FEATURE_INDETERMINATE_PROGRESS:
+ mActionBarView.initIndeterminateProgress();
+ break;
+ case Window.FEATURE_ACTION_BAR_OVERLAY:
+ setOverlayMode(true);
+ break;
+ }
+ }
+
+ @Override
+ public void setUiOptions(int uiOptions) {
+ boolean splitActionBar = false;
+ final boolean splitWhenNarrow =
+ (uiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0;
+ if (splitWhenNarrow) {
+ splitActionBar = getContext().getResources().getBoolean(
+ com.android.internal.R.bool.split_action_bar_is_narrow);
+ }
+ if (splitActionBar) {
+ pullChildren();
+ if (mActionBarBottom != null) {
+ mActionBarView.setSplitView(mActionBarBottom);
+ mActionBarView.setSplitActionBar(splitActionBar);
+ mActionBarView.setSplitWhenNarrow(splitWhenNarrow);
+
+ final ActionBarContextView cab = (ActionBarContextView) findViewById(
+ com.android.internal.R.id.action_context_bar);
+ cab.setSplitView(mActionBarBottom);
+ cab.setSplitActionBar(splitActionBar);
+ cab.setSplitWhenNarrow(splitWhenNarrow);
+ } else if (splitActionBar) {
+ Log.e(TAG, "Requested split action bar with " +
+ "incompatible window decor! Ignoring request.");
+ }
+ }
+ }
+
+ @Override
+ public boolean hasIcon() {
+ pullChildren();
+ return mActionBarView.hasIcon();
+ }
+
+ @Override
+ public boolean hasLogo() {
+ pullChildren();
+ return mActionBarView.hasLogo();
+ }
+
+ @Override
+ public void setIcon(int resId) {
+ pullChildren();
+ mActionBarView.setIcon(resId);
+ }
+
+ @Override
+ public void setIcon(Drawable d) {
+ pullChildren();
+ mActionBarView.setIcon(d);
+ }
+
+ @Override
+ public void setLogo(int resId) {
+ pullChildren();
+ mActionBarView.setLogo(resId);
+ }
+
+ @Override
+ public boolean canShowOverflowMenu() {
+ pullChildren();
+ return mActionBarView.isOverflowReserved() && mActionBarView.getVisibility() == VISIBLE;
+ }
+
+ @Override
+ public boolean isOverflowMenuShowing() {
+ pullChildren();
+ return mActionBarView.isOverflowMenuShowing();
+ }
+
+ @Override
+ public boolean isOverflowMenuShowPending() {
+ pullChildren();
+ return mActionBarView.isOverflowMenuShowPending();
+ }
+
+ @Override
+ public boolean showOverflowMenu() {
+ pullChildren();
+ return mActionBarView.showOverflowMenu();
+ }
+
+ @Override
+ public boolean hideOverflowMenu() {
+ pullChildren();
+ return mActionBarView.hideOverflowMenu();
+ }
+
+ @Override
+ public void setMenuPrepared() {
+ pullChildren();
+ mActionBarView.setMenuPrepared();
+ }
+
+ @Override
+ public void setMenu(Menu menu, MenuPresenter.Callback cb) {
+ pullChildren();
+ mActionBarView.setMenu(menu, cb);
+ }
+
+ @Override
+ public void saveToolbarHierarchyState(SparseArray<Parcelable> toolbarStates) {
+ pullChildren();
+ mActionBarView.saveHierarchyState(toolbarStates);
+ }
+
+ @Override
+ public void restoreToolbarHierarchyState(SparseArray<Parcelable> toolbarStates) {
+ pullChildren();
+ mActionBarView.restoreHierarchyState(toolbarStates);
+ }
+
+ @Override
+ public void dismissPopups() {
+ pullChildren();
+ mActionBarView.dismissPopupMenus();
+ }
+
public static class LayoutParams extends MarginLayoutParams {
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
diff --git a/core/java/com/android/internal/widget/DecorContentParent.java b/core/java/com/android/internal/widget/DecorContentParent.java
new file mode 100644
index 0000000..4fa370a
--- /dev/null
+++ b/core/java/com/android/internal/widget/DecorContentParent.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2014 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.graphics.drawable.Drawable;
+import android.os.Parcelable;
+import android.util.SparseArray;
+import android.view.Menu;
+import android.view.Window;
+import com.android.internal.view.menu.MenuPresenter;
+
+/**
+ * Implemented by the top-level decor layout for a window. DecorContentParent offers
+ * entry points for a number of title/window decor features.
+ */
+public interface DecorContentParent {
+ void setWindowCallback(Window.Callback cb);
+ void setWindowTitle(CharSequence title);
+ CharSequence getTitle();
+ void initFeature(int windowFeature);
+ void setUiOptions(int uiOptions);
+ boolean hasIcon();
+ boolean hasLogo();
+ void setIcon(int resId);
+ void setIcon(Drawable d);
+ void setLogo(int resId);
+ boolean canShowOverflowMenu();
+ boolean isOverflowMenuShowing();
+ boolean isOverflowMenuShowPending();
+ boolean showOverflowMenu();
+ boolean hideOverflowMenu();
+ void setMenuPrepared();
+ void setMenu(Menu menu, MenuPresenter.Callback cb);
+ void saveToolbarHierarchyState(SparseArray<Parcelable> toolbarStates);
+ void restoreToolbarHierarchyState(SparseArray<Parcelable> toolbarStates);
+ void dismissPopups();
+
+}
diff --git a/core/res/res/layout-xlarge/screen_action_bar.xml b/core/res/res/layout-xlarge/screen_action_bar.xml
deleted file mode 100644
index 02c99fe..0000000
--- a/core/res/res/layout-xlarge/screen_action_bar.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?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" />
- <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:viewName="android:action_bar"
- 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>
-</com.android.internal.widget.ActionBarOverlayLayout>
diff --git a/core/res/res/layout/screen_action_bar.xml b/core/res/res/layout/screen_action_bar.xml
index eb237b3..8bf8416 100644
--- a/core/res/res/layout/screen_action_bar.xml
+++ b/core/res/res/layout/screen_action_bar.xml
@@ -20,7 +20,7 @@ This is an optimized layout for a screen with the Action Bar enabled.
<com.android.internal.widget.ActionBarOverlayLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/action_bar_overlay_layout"
+ android:id="@+id/decor_content_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:splitMotionEvents="false"
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 1d35c84..fc50fcd 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -355,10 +355,6 @@
when there is not reserved space for their UI (such as an Action Bar). -->
<attr name="windowActionModeOverlay" format="boolean" />
- <!-- Flag indicating that the action bar should be split to provide more
- room for elements. -->
- <attr name="windowSplitActionBar" format="boolean" />
-
<!-- Defines the default soft input state that this window would
like when it is displayed. Corresponds
to {@link android.view.WindowManager.LayoutParams#softInputMode}. -->
@@ -1704,7 +1700,6 @@
<attr name="windowActionBar" />
<attr name="windowActionModeOverlay" />
<attr name="windowActionBarOverlay" />
- <attr name="windowSplitActionBar" />
<attr name="windowEnableSplitTouch" />
<attr name="windowCloseOnTouchOutside" />
<attr name="windowTranslucentStatus" />
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 2f0ac49..2d60b86 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -31,7 +31,6 @@
<java-symbol type="id" name="account_type" />
<java-symbol type="id" name="action_bar" />
<java-symbol type="id" name="action_bar_container" />
- <java-symbol type="id" name="action_bar_overlay_layout" />
<java-symbol type="id" name="action_bar_title" />
<java-symbol type="id" name="action_bar_subtitle" />
<java-symbol type="id" name="action_context_bar" />
@@ -61,6 +60,7 @@
<java-symbol type="id" name="day" />
<java-symbol type="id" name="day_names" />
<java-symbol type="id" name="decrement" />
+ <java-symbol type="id" name="decor_content_parent" />
<java-symbol type="id" name="default_activity_button" />
<java-symbol type="id" name="deny_button" />
<java-symbol type="id" name="description" />
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 1b96f1f..b6276f1 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -36,6 +36,7 @@ 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.app.ActivityManager;
@@ -147,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;
@@ -439,8 +440,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;
}
@@ -487,10 +488,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) {
@@ -502,11 +503,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.
@@ -518,9 +519,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;
@@ -543,10 +544,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;
@@ -571,7 +572,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) {
@@ -623,12 +624,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);
}
@@ -757,10 +756,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 {
@@ -782,7 +781,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;
}
@@ -828,7 +827,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);
@@ -874,7 +873,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;
@@ -921,17 +920,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) {
@@ -1044,7 +1041,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);
}
}
@@ -1066,7 +1063,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);
}
@@ -1101,12 +1098,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) {
@@ -1121,11 +1118,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);
@@ -1162,7 +1159,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,
@@ -1507,8 +1504,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);
}
}
@@ -1518,13 +1515,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;
}
}
@@ -1534,8 +1532,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);
}
}
@@ -1545,8 +1543,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);
}
}
@@ -1803,9 +1801,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);
}
@@ -1844,11 +1842,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.");
@@ -2122,12 +2120,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 +2130,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) {
@@ -2842,8 +2827,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
cb.onDetachedFromWindow();
}
- if (mActionBar != null) {
- mActionBar.dismissPopupMenus();
+ if (mDecorContentParent != null) {
+ mDecorContentParent.dismissPopups();
}
if (mActionModePopup != null) {
@@ -3275,96 +3260,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);
+ }
}
}