Loading api/current.xml +81 −102 Original line number Diff line number Diff line Loading @@ -2088,6 +2088,28 @@ visibility="public" > </field> <field name="actionButtonStyle" type="int" transient="false" volatile="false" value="16843545" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="actionDropDownStyle" type="int" transient="false" volatile="false" value="16843544" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="activityCloseEnterAnimation" type="int" transient="false" Loading Loading @@ -3683,6 +3705,17 @@ visibility="public" > </field> <field name="dropDownSpinnerStyle" type="int" transient="false" volatile="false" value="16843543" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="dropDownVerticalOffset" type="int" transient="false" Loading Loading @@ -8556,6 +8589,17 @@ visibility="public" > </field> <field name="showAsAction" type="int" transient="false" volatile="false" value="16843546" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="showDefault" type="int" transient="false" Loading Loading @@ -16531,6 +16575,17 @@ visibility="public" > </field> <field name="Widget_ActionButton" type="int" transient="false" volatile="false" value="16973971" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="Widget_AutoCompleteTextView" type="int" transient="false" Loading Loading @@ -19480,19 +19535,6 @@ <parameter name="mask" type="int"> </parameter> </method> <method name="setDividerDrawable" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="d" type="android.graphics.drawable.Drawable"> </parameter> </method> <method name="setDropdownNavigationMode" return="void" abstract="true" Loading Loading @@ -19534,17 +19576,6 @@ <parameter name="title" type="java.lang.CharSequence"> </parameter> </method> <method name="updateActionMenu" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <field name="DISPLAY_HIDE_HOME" type="int" transient="false" Loading Loading @@ -19619,19 +19650,6 @@ deprecated="not deprecated" visibility="public" > <method name="onActionItemClicked" return="boolean" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="item" type="android.view.MenuItem"> </parameter> </method> <method name="onContextItemClicked" return="boolean" abstract="true" Loading @@ -19647,19 +19665,6 @@ <parameter name="item" type="android.view.MenuItem"> </parameter> </method> <method name="onCreateActionMenu" return="boolean" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="menu" type="android.view.Menu"> </parameter> </method> <method name="onCreateContextMode" return="boolean" abstract="true" Loading Loading @@ -19705,19 +19710,6 @@ <parameter name="menu" type="android.view.Menu"> </parameter> </method> <method name="onUpdateActionMenu" return="boolean" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="menu" type="android.view.Menu"> </parameter> </method> </interface> <class name="ActionBar.SimpleCallback" extends="java.lang.Object" Loading @@ -19737,19 +19729,6 @@ visibility="public" > </constructor> <method name="onActionItemClicked" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="item" type="android.view.MenuItem"> </parameter> </method> <method name="onContextItemClicked" return="boolean" abstract="false" Loading @@ -19765,19 +19744,6 @@ <parameter name="item" type="android.view.MenuItem"> </parameter> </method> <method name="onCreateActionMenu" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="menu" type="android.view.Menu"> </parameter> </method> <method name="onCreateContextMode" return="boolean" abstract="false" Loading Loading @@ -19823,19 +19789,6 @@ <parameter name="menu" type="android.view.Menu"> </parameter> </method> <method name="onUpdateActionMenu" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="menu" type="android.view.Menu"> </parameter> </method> </class> <class name="Activity" extends="android.view.ContextThemeWrapper" Loading Loading @@ -36198,6 +36151,19 @@ visibility="public" > </method> <method name="onCancelled" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="data" type="D"> </parameter> </method> </class> <class name="BroadcastReceiver" extends="java.lang.Object" Loading Loading @@ -41751,6 +41717,19 @@ visibility="public" > </method> <method name="onCancelled" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="cursor" type="android.database.Cursor"> </parameter> </method> <method name="setProjection" return="void" abstract="false" core/java/android/app/ActionBar.java +0 −63 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.graphics.drawable.Drawable; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.SpinnerAdapter; /** Loading Loading @@ -153,13 +152,6 @@ public abstract class ActionBar { */ public abstract void setBackgroundDrawable(Drawable d); /** * Set a drawable to use as a divider between sections of the ActionBar. * * @param d Divider drawable */ public abstract void setDividerDrawable(Drawable d); /** * @return The current custom navigation view. */ Loading Loading @@ -206,53 +198,10 @@ public abstract class ActionBar { */ public abstract int getDisplayOptions(); /** * Request an update of the items in the action menu. * This will result in a call to Callback.onUpdateActionMenu(Menu) * and the ActionBar will update based on any changes made there. */ public abstract void updateActionMenu(); /** * Callback interface for ActionBar events. */ public interface Callback { /** * Initialize the always-visible contents of the action bar. * You should place your menu items into <var>menu</var>. * * <p>This is only called once, the first time the action bar is displayed. * * @param menu The action menu in which to place your items. * @return You must return true for actions to be displayed; * if you return false they will not be shown. * * @see #onActionItemClicked(MenuItem) */ public boolean onCreateActionMenu(Menu menu); /** * Update the action bar. This is called in response to {@link #updateActionMenu()} * calls, which may be application-initiated or the result of changing fragment state. * * @return true if the action bar should update based on altered menu contents, * false if no changes are necessary. */ public boolean onUpdateActionMenu(Menu menu); /** * This hook is called whenever an action item in your action bar is clicked. * The default implementation simply returns false to have the normal * processing happen (sending a message to its handler). You can use this * method for any items for which you would like to do processing without * those other facilities. * * @param item The action bar item that was selected. * @return boolean Return false to allow normal menu processing to proceed, * true to consume it here. */ public boolean onActionItemClicked(MenuItem item); /** * This method is called whenever a navigation item in your action bar * is selected. Loading @@ -276,18 +225,6 @@ public abstract class ActionBar { * Extend this if you only need a subset of Callback functionality. */ public static class SimpleCallback implements Callback { public boolean onCreateActionMenu(Menu menu) { return false; } public boolean onUpdateActionMenu(Menu menu) { return false; } public boolean onActionItemClicked(MenuItem item) { return false; } public boolean onCreateContextMode(int modeId, Menu menu) { return false; } Loading core/java/android/app/Activity.java +4 −0 Original line number Diff line number Diff line Loading @@ -936,6 +936,10 @@ public class Activity extends ContextThemeWrapper mTitleReady = true; onTitleChanged(getTitle(), getTitleColor()); } if (mWindow != null && mWindow.hasFeature(Window.FEATURE_ACTION_BAR)) { // Invalidate the action bar menu so that it can initialize properly. mWindow.invalidatePanelMenu(Window.FEATURE_ACTION_BAR); } mCalled = true; } Loading core/java/android/view/ActionBarView.java +39 −216 Original line number Diff line number Diff line Loading @@ -16,7 +16,10 @@ package android.view; import java.util.ArrayList; import com.android.internal.R; import com.android.internal.view.menu.ActionMenu; import com.android.internal.view.menu.ActionMenuItem; import com.android.internal.view.menu.MenuBuilder; import android.app.ActionBar; import android.app.Activity; Loading @@ -37,10 +40,6 @@ import android.widget.Spinner; import android.widget.SpinnerAdapter; import android.widget.TextView; import com.android.internal.R; import com.android.internal.view.menu.ActionMenu; import com.android.internal.view.menu.ActionMenuItem; /** * @hide */ Loading Loading @@ -75,7 +74,6 @@ public class ActionBarView extends ViewGroup { private CharSequence mSubtitle; private Drawable mIcon; private Drawable mLogo; private Drawable mDivider; private ImageView mIconView; private ImageView mLogoView; Loading @@ -86,26 +84,15 @@ public class ActionBarView extends ViewGroup { private boolean mShowMenu; private MenuBuilder mOptionsMenu; private View mMenuView; private ActionMenuItem mLogoNavItem; private ActionMenu mActionMenu; private ActionMenu mOptionsMenu; private SparseArray<ActionMenu> mContextMenus; private Callback mCallback; private final ArrayList<ActionView> mActions = new ArrayList<ActionView>(); private final OnClickListener mActionClickHandler = new OnClickListener() { public void onClick(View v) { ActionView av = (ActionView) v; ActionMenuItem item = (ActionMenuItem) av.menuItem; if (mCallback == null || !mCallback.onActionItemClicked(item)) { item.invoke(); } } }; private final AdapterView.OnItemSelectedListener mNavItemSelectedListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View view, int position, long id) { Loading Loading @@ -151,7 +138,6 @@ public class ActionBarView extends ViewGroup { if (mIcon == null) { mIcon = info.loadIcon(pm); } mDivider = a.getDrawable(R.styleable.ActionBar_divider); Drawable background = a.getDrawable(R.styleable.ActionBar_background); if (background != null) { Loading @@ -178,8 +164,10 @@ public class ActionBarView extends ViewGroup { mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle); mHomeClickListener = new OnClickListener() { public void onClick(View v) { if (mCallback != null) { mCallback.onActionItemClicked(mLogoNavItem); Context context = getContext(); if (context instanceof Activity) { Activity activity = (Activity) context; activity.onOptionsItemSelected(mLogoNavItem); } } }; Loading @@ -188,31 +176,22 @@ public class ActionBarView extends ViewGroup { mContextMenus = new SparseArray<ActionMenu>(); } private boolean initOptionsMenu() { final Context context = getContext(); if (!(context instanceof Activity)) { return false; } final Activity activity = (Activity) context; ActionMenu optionsMenu = new ActionMenu(context); if (activity.onCreateOptionsMenu(optionsMenu)) { mOptionsMenu = optionsMenu; return true; } return false; } public void setCallback(Callback callback) { final Context context = getContext(); mCallback = callback; } ActionMenu actionMenu = new ActionMenu(context); if (callback.onCreateActionMenu(actionMenu)) { mActionMenu = actionMenu; performUpdateActionMenu(); public void setMenu(Menu menu) { MenuBuilder builder = (MenuBuilder) menu; mOptionsMenu = builder; if (mMenuView != null) { removeView(mMenuView); } final View menuView = builder.getMenuView(MenuBuilder.TYPE_ACTION_BUTTON, null); final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); menuView.setLayoutParams(layoutParams); addView(menuView); mMenuView = menuView; } public void setCustomNavigationView(View view) { Loading @@ -222,10 +201,6 @@ public class ActionBarView extends ViewGroup { } } public void setDividerDrawable(Drawable d) { mDivider = d; } public CharSequence getTitle() { return mTitle; } Loading Loading @@ -301,9 +276,13 @@ public class ActionBarView extends ViewGroup { mSpinner = new Spinner(mContext, null, com.android.internal.R.attr.dropDownSpinnerStyle); mSpinner.setOnItemSelectedListener(mNavItemSelectedListener); mSpinner.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); addView(mSpinner); break; case ActionBar.NAVIGATION_MODE_CUSTOM: mCustomNavView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); addView(mCustomNavView); break; } Loading @@ -328,18 +307,6 @@ public class ActionBarView extends ViewGroup { return mDisplayOptions; } private ActionView findActionViewForItem(MenuItem item) { final ArrayList<ActionView> actions = mActions; final int actionCount = actions.size(); for (int i = 0; i < actionCount; i++) { ActionView av = actions.get(i); if (av.menuItem.equals(item)) { return av; } } return null; } public void setContextMode(int mode) { Callback callback = mCallback; if (callback == null) { Loading Loading @@ -368,92 +335,6 @@ public class ActionBarView extends ViewGroup { // TODO Turn off context mode; go back to normal. } public void updateActionMenu() { final ActionMenu menu = mActionMenu; if (menu == null || mCallback == null || !mCallback.onUpdateActionMenu(menu)) { return; } performUpdateActionMenu(); } private void performUpdateActionMenu() { final ActionMenu menu = mActionMenu; if (menu == null) { return; } final Context context = getContext(); int childCount = getChildCount(); int childIndex = 0; while (childIndex < childCount) { View v = getChildAt(childIndex); if (v instanceof ActionView) { detachViewFromParent(childIndex); childCount--; } else { childIndex++; } } ArrayList<ActionView> detachedViews = new ArrayList<ActionView>(mActions); final int itemCount = menu.size(); for (int i = 0; i < itemCount; i++) { final MenuItem item = menu.getItem(i); boolean newView = false; ActionView actionView = findActionViewForItem(item); if (actionView == null) { actionView = new ActionView(context); newView = true; } actionView.actionId = item.getItemId(); actionView.menuItem = item; actionView.actionLabel = item.getTitle(); actionView.setAdjustViewBounds(true); actionView.setImageDrawable(item.getIcon()); actionView.setFocusable(true); actionView.setOnClickListener(mActionClickHandler); LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, LayoutParams.ITEM_TYPE_ACTION); actionView.setLayoutParams(layoutParams); if (newView) { addView(actionView); mActions.add(actionView); } else { attachViewToParent(actionView, -1, layoutParams); detachedViews.remove(actionView); actionView.invalidate(); } } final int detachedCount = detachedViews.size(); for (int i = 0; i < detachedCount; i++) { removeDetachedView(detachedViews.get(i), false); } requestLayout(); } public void addAction(int id, Drawable icon, CharSequence label, OnActionListener listener) { ActionView actionView = new ActionView(getContext()); actionView.actionId = id; actionView.actionLabel = label; actionView.actionListener = listener; actionView.setAdjustViewBounds(true); actionView.setImageDrawable(icon); actionView.setOnClickListener(mActionClickHandler); actionView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, LayoutParams.ITEM_TYPE_ACTION)); addView(actionView); mActions.add(actionView); requestLayout(); } @Override protected void onFinishInflate() { super.onFinishInflate(); Loading @@ -463,7 +344,7 @@ public class ActionBarView extends ViewGroup { mLogoView = new ImageView(getContext()); mLogoView.setAdjustViewBounds(true); mLogoView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, LayoutParams.ITEM_TYPE_ICON)); LayoutParams.MATCH_PARENT)); mLogoView.setImageDrawable(mLogo); mLogoView.setClickable(true); mLogoView.setFocusable(true); Loading @@ -473,7 +354,7 @@ public class ActionBarView extends ViewGroup { mIconView = new ImageView(getContext()); mIconView.setAdjustViewBounds(true); mIconView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, LayoutParams.ITEM_TYPE_ICON)); LayoutParams.MATCH_PARENT)); mIconView.setImageDrawable(mIcon); mIconView.setClickable(true); mIconView.setFocusable(true); Loading Loading @@ -508,8 +389,8 @@ public class ActionBarView extends ViewGroup { private void initTitle() { LayoutInflater inflater = LayoutInflater.from(getContext()); mTitleView = (TextView) inflater.inflate(R.layout.action_bar_title_item, null); mTitleView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, LayoutParams.ITEM_TYPE_TITLE)); mTitleView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); if (mTitle != null) { mTitleView.setText(mTitle); } Loading Loading @@ -543,11 +424,8 @@ public class ActionBarView extends ViewGroup { availableWidth = measureChildView(mIconView, availableWidth, childSpecHeight, mSpacing); } final ArrayList<ActionView> actions = mActions; final int actionCount = actions.size(); for (int i = 0; i < actionCount; i++) { ActionView action = actions.get(i); availableWidth = measureChildView(action, availableWidth, if (mMenuView != null) { availableWidth = measureChildView(mMenuView, availableWidth, childSpecHeight, mActionSpacing); } Loading Loading @@ -619,10 +497,9 @@ public class ActionBarView extends ViewGroup { x = r - l - getPaddingRight(); final int count = mActions.size(); for (int i = count - 1; i >= 0; i--) { ActionView action = mActions.get(i); x -= (positionChildInverse(action, x, y, contentHeight) + mActionSpacing); if (mMenuView != null) { x -= positionChildInverse(mMenuView, x, y, contentHeight) + mActionSpacing; } } Loading @@ -645,58 +522,4 @@ public class ActionBarView extends ViewGroup { return childWidth; } @Override public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { return new ViewGroup.LayoutParams(getContext(), attrs); } @Override protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { return p != null && p instanceof LayoutParams; } private static class LayoutParams extends ViewGroup.LayoutParams { static final int ITEM_TYPE_UNKNOWN = -1; static final int ITEM_TYPE_ICON = 0; static final int ITEM_TYPE_TITLE = 1; static final int ITEM_TYPE_CUSTOM_NAV = 2; static final int ITEM_TYPE_ACTION = 3; static final int ITEM_TYPE_MORE = 4; int type = ITEM_TYPE_UNKNOWN; public LayoutParams(Context c, AttributeSet attrs) { super(c, attrs); } public LayoutParams(int width, int height) { super(width, height); } public LayoutParams(int width, int height, int type) { this(width, height); this.type = type; } public LayoutParams(ViewGroup.LayoutParams source) { super(source); } } public interface OnActionListener { void onAction(int id); } private static class ActionView extends ImageView { int actionId; CharSequence actionLabel; OnActionListener actionListener; MenuItem menuItem; public ActionView(Context context) { super(context); } } } core/java/android/view/MenuInflater.java +15 −2 Original line number Diff line number Diff line Loading @@ -241,6 +241,14 @@ public class MenuInflater { private boolean itemVisible; private boolean itemEnabled; /** * Sync to attrs.xml enum: * - 0: never * - 1: ifRoom * - 2: always */ private int itemShowAsAction; private String itemListenerMethodName; private static final int defaultGroupId = NO_ID; Loading Loading @@ -314,6 +322,7 @@ public class MenuInflater { itemChecked = a.getBoolean(com.android.internal.R.styleable.MenuItem_checked, defaultItemChecked); itemVisible = a.getBoolean(com.android.internal.R.styleable.MenuItem_visible, groupVisible); itemEnabled = a.getBoolean(com.android.internal.R.styleable.MenuItem_enabled, groupEnabled); itemShowAsAction = a.getInt(com.android.internal.R.styleable.MenuItem_showAsAction, 0); itemListenerMethodName = a.getString(com.android.internal.R.styleable.MenuItem_onClick); a.recycle(); Loading Loading @@ -344,8 +353,12 @@ public class MenuInflater { new InflatedOnMenuItemClickListener(mContext, itemListenerMethodName)); } if (itemCheckable >= 2 && item instanceof MenuItemImpl) { ((MenuItemImpl) item).setExclusiveCheckable(true); if (item instanceof MenuItemImpl) { MenuItemImpl impl = (MenuItemImpl) item; if (itemCheckable >= 2) { impl.setExclusiveCheckable(true); } impl.setShowAsAction(itemShowAsAction); } } Loading Loading
api/current.xml +81 −102 Original line number Diff line number Diff line Loading @@ -2088,6 +2088,28 @@ visibility="public" > </field> <field name="actionButtonStyle" type="int" transient="false" volatile="false" value="16843545" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="actionDropDownStyle" type="int" transient="false" volatile="false" value="16843544" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="activityCloseEnterAnimation" type="int" transient="false" Loading Loading @@ -3683,6 +3705,17 @@ visibility="public" > </field> <field name="dropDownSpinnerStyle" type="int" transient="false" volatile="false" value="16843543" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="dropDownVerticalOffset" type="int" transient="false" Loading Loading @@ -8556,6 +8589,17 @@ visibility="public" > </field> <field name="showAsAction" type="int" transient="false" volatile="false" value="16843546" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="showDefault" type="int" transient="false" Loading Loading @@ -16531,6 +16575,17 @@ visibility="public" > </field> <field name="Widget_ActionButton" type="int" transient="false" volatile="false" value="16973971" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="Widget_AutoCompleteTextView" type="int" transient="false" Loading Loading @@ -19480,19 +19535,6 @@ <parameter name="mask" type="int"> </parameter> </method> <method name="setDividerDrawable" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="d" type="android.graphics.drawable.Drawable"> </parameter> </method> <method name="setDropdownNavigationMode" return="void" abstract="true" Loading Loading @@ -19534,17 +19576,6 @@ <parameter name="title" type="java.lang.CharSequence"> </parameter> </method> <method name="updateActionMenu" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <field name="DISPLAY_HIDE_HOME" type="int" transient="false" Loading Loading @@ -19619,19 +19650,6 @@ deprecated="not deprecated" visibility="public" > <method name="onActionItemClicked" return="boolean" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="item" type="android.view.MenuItem"> </parameter> </method> <method name="onContextItemClicked" return="boolean" abstract="true" Loading @@ -19647,19 +19665,6 @@ <parameter name="item" type="android.view.MenuItem"> </parameter> </method> <method name="onCreateActionMenu" return="boolean" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="menu" type="android.view.Menu"> </parameter> </method> <method name="onCreateContextMode" return="boolean" abstract="true" Loading Loading @@ -19705,19 +19710,6 @@ <parameter name="menu" type="android.view.Menu"> </parameter> </method> <method name="onUpdateActionMenu" return="boolean" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="menu" type="android.view.Menu"> </parameter> </method> </interface> <class name="ActionBar.SimpleCallback" extends="java.lang.Object" Loading @@ -19737,19 +19729,6 @@ visibility="public" > </constructor> <method name="onActionItemClicked" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="item" type="android.view.MenuItem"> </parameter> </method> <method name="onContextItemClicked" return="boolean" abstract="false" Loading @@ -19765,19 +19744,6 @@ <parameter name="item" type="android.view.MenuItem"> </parameter> </method> <method name="onCreateActionMenu" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="menu" type="android.view.Menu"> </parameter> </method> <method name="onCreateContextMode" return="boolean" abstract="false" Loading Loading @@ -19823,19 +19789,6 @@ <parameter name="menu" type="android.view.Menu"> </parameter> </method> <method name="onUpdateActionMenu" return="boolean" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="menu" type="android.view.Menu"> </parameter> </method> </class> <class name="Activity" extends="android.view.ContextThemeWrapper" Loading Loading @@ -36198,6 +36151,19 @@ visibility="public" > </method> <method name="onCancelled" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="data" type="D"> </parameter> </method> </class> <class name="BroadcastReceiver" extends="java.lang.Object" Loading Loading @@ -41751,6 +41717,19 @@ visibility="public" > </method> <method name="onCancelled" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="cursor" type="android.database.Cursor"> </parameter> </method> <method name="setProjection" return="void" abstract="false"
core/java/android/app/ActionBar.java +0 −63 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.graphics.drawable.Drawable; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.SpinnerAdapter; /** Loading Loading @@ -153,13 +152,6 @@ public abstract class ActionBar { */ public abstract void setBackgroundDrawable(Drawable d); /** * Set a drawable to use as a divider between sections of the ActionBar. * * @param d Divider drawable */ public abstract void setDividerDrawable(Drawable d); /** * @return The current custom navigation view. */ Loading Loading @@ -206,53 +198,10 @@ public abstract class ActionBar { */ public abstract int getDisplayOptions(); /** * Request an update of the items in the action menu. * This will result in a call to Callback.onUpdateActionMenu(Menu) * and the ActionBar will update based on any changes made there. */ public abstract void updateActionMenu(); /** * Callback interface for ActionBar events. */ public interface Callback { /** * Initialize the always-visible contents of the action bar. * You should place your menu items into <var>menu</var>. * * <p>This is only called once, the first time the action bar is displayed. * * @param menu The action menu in which to place your items. * @return You must return true for actions to be displayed; * if you return false they will not be shown. * * @see #onActionItemClicked(MenuItem) */ public boolean onCreateActionMenu(Menu menu); /** * Update the action bar. This is called in response to {@link #updateActionMenu()} * calls, which may be application-initiated or the result of changing fragment state. * * @return true if the action bar should update based on altered menu contents, * false if no changes are necessary. */ public boolean onUpdateActionMenu(Menu menu); /** * This hook is called whenever an action item in your action bar is clicked. * The default implementation simply returns false to have the normal * processing happen (sending a message to its handler). You can use this * method for any items for which you would like to do processing without * those other facilities. * * @param item The action bar item that was selected. * @return boolean Return false to allow normal menu processing to proceed, * true to consume it here. */ public boolean onActionItemClicked(MenuItem item); /** * This method is called whenever a navigation item in your action bar * is selected. Loading @@ -276,18 +225,6 @@ public abstract class ActionBar { * Extend this if you only need a subset of Callback functionality. */ public static class SimpleCallback implements Callback { public boolean onCreateActionMenu(Menu menu) { return false; } public boolean onUpdateActionMenu(Menu menu) { return false; } public boolean onActionItemClicked(MenuItem item) { return false; } public boolean onCreateContextMode(int modeId, Menu menu) { return false; } Loading
core/java/android/app/Activity.java +4 −0 Original line number Diff line number Diff line Loading @@ -936,6 +936,10 @@ public class Activity extends ContextThemeWrapper mTitleReady = true; onTitleChanged(getTitle(), getTitleColor()); } if (mWindow != null && mWindow.hasFeature(Window.FEATURE_ACTION_BAR)) { // Invalidate the action bar menu so that it can initialize properly. mWindow.invalidatePanelMenu(Window.FEATURE_ACTION_BAR); } mCalled = true; } Loading
core/java/android/view/ActionBarView.java +39 −216 Original line number Diff line number Diff line Loading @@ -16,7 +16,10 @@ package android.view; import java.util.ArrayList; import com.android.internal.R; import com.android.internal.view.menu.ActionMenu; import com.android.internal.view.menu.ActionMenuItem; import com.android.internal.view.menu.MenuBuilder; import android.app.ActionBar; import android.app.Activity; Loading @@ -37,10 +40,6 @@ import android.widget.Spinner; import android.widget.SpinnerAdapter; import android.widget.TextView; import com.android.internal.R; import com.android.internal.view.menu.ActionMenu; import com.android.internal.view.menu.ActionMenuItem; /** * @hide */ Loading Loading @@ -75,7 +74,6 @@ public class ActionBarView extends ViewGroup { private CharSequence mSubtitle; private Drawable mIcon; private Drawable mLogo; private Drawable mDivider; private ImageView mIconView; private ImageView mLogoView; Loading @@ -86,26 +84,15 @@ public class ActionBarView extends ViewGroup { private boolean mShowMenu; private MenuBuilder mOptionsMenu; private View mMenuView; private ActionMenuItem mLogoNavItem; private ActionMenu mActionMenu; private ActionMenu mOptionsMenu; private SparseArray<ActionMenu> mContextMenus; private Callback mCallback; private final ArrayList<ActionView> mActions = new ArrayList<ActionView>(); private final OnClickListener mActionClickHandler = new OnClickListener() { public void onClick(View v) { ActionView av = (ActionView) v; ActionMenuItem item = (ActionMenuItem) av.menuItem; if (mCallback == null || !mCallback.onActionItemClicked(item)) { item.invoke(); } } }; private final AdapterView.OnItemSelectedListener mNavItemSelectedListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View view, int position, long id) { Loading Loading @@ -151,7 +138,6 @@ public class ActionBarView extends ViewGroup { if (mIcon == null) { mIcon = info.loadIcon(pm); } mDivider = a.getDrawable(R.styleable.ActionBar_divider); Drawable background = a.getDrawable(R.styleable.ActionBar_background); if (background != null) { Loading @@ -178,8 +164,10 @@ public class ActionBarView extends ViewGroup { mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle); mHomeClickListener = new OnClickListener() { public void onClick(View v) { if (mCallback != null) { mCallback.onActionItemClicked(mLogoNavItem); Context context = getContext(); if (context instanceof Activity) { Activity activity = (Activity) context; activity.onOptionsItemSelected(mLogoNavItem); } } }; Loading @@ -188,31 +176,22 @@ public class ActionBarView extends ViewGroup { mContextMenus = new SparseArray<ActionMenu>(); } private boolean initOptionsMenu() { final Context context = getContext(); if (!(context instanceof Activity)) { return false; } final Activity activity = (Activity) context; ActionMenu optionsMenu = new ActionMenu(context); if (activity.onCreateOptionsMenu(optionsMenu)) { mOptionsMenu = optionsMenu; return true; } return false; } public void setCallback(Callback callback) { final Context context = getContext(); mCallback = callback; } ActionMenu actionMenu = new ActionMenu(context); if (callback.onCreateActionMenu(actionMenu)) { mActionMenu = actionMenu; performUpdateActionMenu(); public void setMenu(Menu menu) { MenuBuilder builder = (MenuBuilder) menu; mOptionsMenu = builder; if (mMenuView != null) { removeView(mMenuView); } final View menuView = builder.getMenuView(MenuBuilder.TYPE_ACTION_BUTTON, null); final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); menuView.setLayoutParams(layoutParams); addView(menuView); mMenuView = menuView; } public void setCustomNavigationView(View view) { Loading @@ -222,10 +201,6 @@ public class ActionBarView extends ViewGroup { } } public void setDividerDrawable(Drawable d) { mDivider = d; } public CharSequence getTitle() { return mTitle; } Loading Loading @@ -301,9 +276,13 @@ public class ActionBarView extends ViewGroup { mSpinner = new Spinner(mContext, null, com.android.internal.R.attr.dropDownSpinnerStyle); mSpinner.setOnItemSelectedListener(mNavItemSelectedListener); mSpinner.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); addView(mSpinner); break; case ActionBar.NAVIGATION_MODE_CUSTOM: mCustomNavView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); addView(mCustomNavView); break; } Loading @@ -328,18 +307,6 @@ public class ActionBarView extends ViewGroup { return mDisplayOptions; } private ActionView findActionViewForItem(MenuItem item) { final ArrayList<ActionView> actions = mActions; final int actionCount = actions.size(); for (int i = 0; i < actionCount; i++) { ActionView av = actions.get(i); if (av.menuItem.equals(item)) { return av; } } return null; } public void setContextMode(int mode) { Callback callback = mCallback; if (callback == null) { Loading Loading @@ -368,92 +335,6 @@ public class ActionBarView extends ViewGroup { // TODO Turn off context mode; go back to normal. } public void updateActionMenu() { final ActionMenu menu = mActionMenu; if (menu == null || mCallback == null || !mCallback.onUpdateActionMenu(menu)) { return; } performUpdateActionMenu(); } private void performUpdateActionMenu() { final ActionMenu menu = mActionMenu; if (menu == null) { return; } final Context context = getContext(); int childCount = getChildCount(); int childIndex = 0; while (childIndex < childCount) { View v = getChildAt(childIndex); if (v instanceof ActionView) { detachViewFromParent(childIndex); childCount--; } else { childIndex++; } } ArrayList<ActionView> detachedViews = new ArrayList<ActionView>(mActions); final int itemCount = menu.size(); for (int i = 0; i < itemCount; i++) { final MenuItem item = menu.getItem(i); boolean newView = false; ActionView actionView = findActionViewForItem(item); if (actionView == null) { actionView = new ActionView(context); newView = true; } actionView.actionId = item.getItemId(); actionView.menuItem = item; actionView.actionLabel = item.getTitle(); actionView.setAdjustViewBounds(true); actionView.setImageDrawable(item.getIcon()); actionView.setFocusable(true); actionView.setOnClickListener(mActionClickHandler); LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, LayoutParams.ITEM_TYPE_ACTION); actionView.setLayoutParams(layoutParams); if (newView) { addView(actionView); mActions.add(actionView); } else { attachViewToParent(actionView, -1, layoutParams); detachedViews.remove(actionView); actionView.invalidate(); } } final int detachedCount = detachedViews.size(); for (int i = 0; i < detachedCount; i++) { removeDetachedView(detachedViews.get(i), false); } requestLayout(); } public void addAction(int id, Drawable icon, CharSequence label, OnActionListener listener) { ActionView actionView = new ActionView(getContext()); actionView.actionId = id; actionView.actionLabel = label; actionView.actionListener = listener; actionView.setAdjustViewBounds(true); actionView.setImageDrawable(icon); actionView.setOnClickListener(mActionClickHandler); actionView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, LayoutParams.ITEM_TYPE_ACTION)); addView(actionView); mActions.add(actionView); requestLayout(); } @Override protected void onFinishInflate() { super.onFinishInflate(); Loading @@ -463,7 +344,7 @@ public class ActionBarView extends ViewGroup { mLogoView = new ImageView(getContext()); mLogoView.setAdjustViewBounds(true); mLogoView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, LayoutParams.ITEM_TYPE_ICON)); LayoutParams.MATCH_PARENT)); mLogoView.setImageDrawable(mLogo); mLogoView.setClickable(true); mLogoView.setFocusable(true); Loading @@ -473,7 +354,7 @@ public class ActionBarView extends ViewGroup { mIconView = new ImageView(getContext()); mIconView.setAdjustViewBounds(true); mIconView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, LayoutParams.ITEM_TYPE_ICON)); LayoutParams.MATCH_PARENT)); mIconView.setImageDrawable(mIcon); mIconView.setClickable(true); mIconView.setFocusable(true); Loading Loading @@ -508,8 +389,8 @@ public class ActionBarView extends ViewGroup { private void initTitle() { LayoutInflater inflater = LayoutInflater.from(getContext()); mTitleView = (TextView) inflater.inflate(R.layout.action_bar_title_item, null); mTitleView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, LayoutParams.ITEM_TYPE_TITLE)); mTitleView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); if (mTitle != null) { mTitleView.setText(mTitle); } Loading Loading @@ -543,11 +424,8 @@ public class ActionBarView extends ViewGroup { availableWidth = measureChildView(mIconView, availableWidth, childSpecHeight, mSpacing); } final ArrayList<ActionView> actions = mActions; final int actionCount = actions.size(); for (int i = 0; i < actionCount; i++) { ActionView action = actions.get(i); availableWidth = measureChildView(action, availableWidth, if (mMenuView != null) { availableWidth = measureChildView(mMenuView, availableWidth, childSpecHeight, mActionSpacing); } Loading Loading @@ -619,10 +497,9 @@ public class ActionBarView extends ViewGroup { x = r - l - getPaddingRight(); final int count = mActions.size(); for (int i = count - 1; i >= 0; i--) { ActionView action = mActions.get(i); x -= (positionChildInverse(action, x, y, contentHeight) + mActionSpacing); if (mMenuView != null) { x -= positionChildInverse(mMenuView, x, y, contentHeight) + mActionSpacing; } } Loading @@ -645,58 +522,4 @@ public class ActionBarView extends ViewGroup { return childWidth; } @Override public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { return new ViewGroup.LayoutParams(getContext(), attrs); } @Override protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { return p != null && p instanceof LayoutParams; } private static class LayoutParams extends ViewGroup.LayoutParams { static final int ITEM_TYPE_UNKNOWN = -1; static final int ITEM_TYPE_ICON = 0; static final int ITEM_TYPE_TITLE = 1; static final int ITEM_TYPE_CUSTOM_NAV = 2; static final int ITEM_TYPE_ACTION = 3; static final int ITEM_TYPE_MORE = 4; int type = ITEM_TYPE_UNKNOWN; public LayoutParams(Context c, AttributeSet attrs) { super(c, attrs); } public LayoutParams(int width, int height) { super(width, height); } public LayoutParams(int width, int height, int type) { this(width, height); this.type = type; } public LayoutParams(ViewGroup.LayoutParams source) { super(source); } } public interface OnActionListener { void onAction(int id); } private static class ActionView extends ImageView { int actionId; CharSequence actionLabel; OnActionListener actionListener; MenuItem menuItem; public ActionView(Context context) { super(context); } } }
core/java/android/view/MenuInflater.java +15 −2 Original line number Diff line number Diff line Loading @@ -241,6 +241,14 @@ public class MenuInflater { private boolean itemVisible; private boolean itemEnabled; /** * Sync to attrs.xml enum: * - 0: never * - 1: ifRoom * - 2: always */ private int itemShowAsAction; private String itemListenerMethodName; private static final int defaultGroupId = NO_ID; Loading Loading @@ -314,6 +322,7 @@ public class MenuInflater { itemChecked = a.getBoolean(com.android.internal.R.styleable.MenuItem_checked, defaultItemChecked); itemVisible = a.getBoolean(com.android.internal.R.styleable.MenuItem_visible, groupVisible); itemEnabled = a.getBoolean(com.android.internal.R.styleable.MenuItem_enabled, groupEnabled); itemShowAsAction = a.getInt(com.android.internal.R.styleable.MenuItem_showAsAction, 0); itemListenerMethodName = a.getString(com.android.internal.R.styleable.MenuItem_onClick); a.recycle(); Loading Loading @@ -344,8 +353,12 @@ public class MenuInflater { new InflatedOnMenuItemClickListener(mContext, itemListenerMethodName)); } if (itemCheckable >= 2 && item instanceof MenuItemImpl) { ((MenuItemImpl) item).setExclusiveCheckable(true); if (item instanceof MenuItemImpl) { MenuItemImpl impl = (MenuItemImpl) item; if (itemCheckable >= 2) { impl.setExclusiveCheckable(true); } impl.setShowAsAction(itemShowAsAction); } } Loading