diff options
author | Adam Powell <adamp@google.com> | 2010-06-10 18:58:59 -0700 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2010-06-17 11:35:43 -0700 |
commit | 96675b1df3969f2d313b68f60ed9fa36805db8ce (patch) | |
tree | 0bf8088a354d1e4f392a6adccda1911c0a0d890e /policy | |
parent | e6ac8b9aade9443ab8456c8f7a47cdfba3b70266 (diff) | |
download | frameworks_base-96675b1df3969f2d313b68f60ed9fa36805db8ce.zip frameworks_base-96675b1df3969f2d313b68f60ed9fa36805db8ce.tar.gz frameworks_base-96675b1df3969f2d313b68f60ed9fa36805db8ce.tar.bz2 |
Merging ActionBar menu with options menu.
Options menu items may now specify if they would like to appear in the
action bar. Menu items defined in xml may set the showAsAction
attribute to one of "never"(default), "ifRoom", or "always". Action
buttons are populated as follows:
* All showAsAction="always" items become action buttons, even if it
would crowd the navigation area of the action bar.
* If there is space remaining, showAsAction="ifRoom" items are added
until no more will fit comfortably.
Action button click events are now handled by the
onOptionsItemSelected method used by the standard options menu.
The construction of options menus now happens earlier in order to
provide data to the action bar. Activities with an action bar can now
expect to have onCreateOptionsMenu called when activity start-up is
complete.
Activity#invalidateOptionsMenu can be used to force a refresh of menu
items where the previous API would use ActionBar#updateActionMenu.
Change-Id: If52ddf1cf9f6926206bcdeadf42072ea2c24fab9
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindow.java | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index 1c78a01..eea855d 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -44,7 +44,6 @@ import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.net.Uri; import android.os.Bundle; -import android.os.Message; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; @@ -63,7 +62,6 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; -import android.view.Surface; import android.view.SurfaceHolder; import android.view.View; import android.view.ViewGroup; @@ -81,12 +79,6 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; -import com.android.internal.view.menu.ContextMenuBuilder; -import com.android.internal.view.menu.MenuBuilder; -import com.android.internal.view.menu.MenuDialogHelper; -import com.android.internal.view.menu.MenuView; -import com.android.internal.view.menu.SubMenuBuilder; - /** * Android-specific Window. * <p> @@ -307,7 +299,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // Already prepared (isPrepared will be reset to false later) if (st.isPrepared) return true; - + if ((mPreparedPanel != null) && (mPreparedPanel != st)) { // Another Panel is prepared and possibly open, so close it closePanel(mPreparedPanel, false); @@ -334,7 +326,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { return false; } + st.refreshMenuContent = false; + + if (mActionBar != null) { + mActionBar.setMenu(st.menu); + } } // Callback and return if the callback does not want to show the menu @@ -383,11 +380,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { clearMenuViews(st); } } - } private static void clearMenuViews(PanelFeatureState st) { - // This can be called on config changes, so we should make sure // the views will be reconstructed based on the new orientation, etc. @@ -562,6 +557,16 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } st.refreshMenuContent = true; st.refreshDecorView = true; + + // Prepare the options panel if we have an action bar + if ((featureId == FEATURE_ACTION_BAR || featureId == FEATURE_OPTIONS_PANEL) + && mActionBar != null) { + st = getPanelState(Window.FEATURE_OPTIONS_PANEL, false); + if (st != null) { + st.isPrepared = false; + preparePanel(st, null); + } + } } /** @@ -2295,10 +2300,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } } else { mActionBar = (ActionBarView) findViewById(com.android.internal.R.id.action_bar); - if (mActionBar != null) { - if (mActionBar.getTitle() == null) { - mActionBar.setTitle(mTitle); - } + if (mActionBar != null && mActionBar.getTitle() == null) { + mActionBar.setTitle(mTitle); } } } |