blob: dda3be6f1105bd13e7c96aa65efa970ebb0c4a65 [file] [log] [blame]
Adam Powell89e06452010-06-23 20:24:52 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.app;
18
Adam Powellf8ac6b72011-05-23 18:14:09 -070019import com.android.internal.R;
Adam Powell2c9c9fe2010-07-16 10:17:57 -070020import com.android.internal.view.menu.MenuBuilder;
Adam Powell2c9c9fe2010-07-16 10:17:57 -070021import com.android.internal.view.menu.MenuPopupHelper;
22import com.android.internal.view.menu.SubMenuBuilder;
Adam Powell01feaee2011-02-10 15:05:05 -080023import com.android.internal.widget.ActionBarContainer;
Adam Powell89e06452010-06-23 20:24:52 -070024import com.android.internal.widget.ActionBarContextView;
25import com.android.internal.widget.ActionBarView;
Adam Powellf8ac6b72011-05-23 18:14:09 -070026import com.android.internal.widget.ScrollingTabContainerView;
Adam Powell89e06452010-06-23 20:24:52 -070027
Adam Powelld8b3f2e2010-12-02 13:37:03 -080028import android.animation.Animator;
Adam Powelld8b3f2e2010-12-02 13:37:03 -080029import android.animation.Animator.AnimatorListener;
Adam Powell07e1f982011-03-24 11:11:15 -070030import android.animation.AnimatorListenerAdapter;
Adam Powelld8b3f2e2010-12-02 13:37:03 -080031import android.animation.AnimatorSet;
Adam Powelle6ec7322010-12-07 15:29:26 -080032import android.animation.ObjectAnimator;
Adam Powell89e06452010-06-23 20:24:52 -070033import android.app.ActionBar;
Adam Powell661c9082010-07-02 10:09:44 -070034import android.app.Activity;
Adam Powelldec9dfd2010-08-09 15:27:54 -070035import android.app.Dialog;
Adam Powell661c9082010-07-02 10:09:44 -070036import android.app.FragmentTransaction;
Adam Powelldec9dfd2010-08-09 15:27:54 -070037import android.content.Context;
Adam Powellf8ac6b72011-05-23 18:14:09 -070038import android.content.res.Configuration;
39import android.content.res.TypedArray;
Adam Powell89e06452010-06-23 20:24:52 -070040import android.graphics.drawable.Drawable;
Adam Powell0e94b512010-06-29 17:58:20 -070041import android.os.Handler;
Adam Powell6e346362010-07-23 10:18:23 -070042import android.view.ActionMode;
Adam Powell32555f32010-11-17 13:49:22 -080043import android.view.LayoutInflater;
Adam Powell89e06452010-06-23 20:24:52 -070044import android.view.Menu;
Adam Powell9168f0b2010-08-02 15:46:24 -070045import android.view.MenuInflater;
Adam Powell89e06452010-06-23 20:24:52 -070046import android.view.MenuItem;
47import android.view.View;
Adam Powelle6ec7322010-12-07 15:29:26 -080048import android.view.Window;
Adam Powell89e06452010-06-23 20:24:52 -070049import android.widget.SpinnerAdapter;
Adam Powell89e06452010-06-23 20:24:52 -070050
Adam Powell29ed7572010-07-14 16:24:56 -070051import java.lang.ref.WeakReference;
Adam Powell661c9082010-07-02 10:09:44 -070052import java.util.ArrayList;
53
Adam Powell89e06452010-06-23 20:24:52 -070054/**
55 * ActionBarImpl is the ActionBar implementation used
56 * by devices of all screen sizes. If it detects a compatible decor,
57 * it will split contextual modes across both the ActionBarView at
58 * the top of the screen and a horizontal LinearLayout at the bottom
59 * which is normally hidden.
60 */
61public class ActionBarImpl extends ActionBar {
Adam Powelld8145042011-03-24 14:18:27 -070062 private static final String TAG = "ActionBarImpl";
Adam Powell661c9082010-07-02 10:09:44 -070063
Adam Powelldec9dfd2010-08-09 15:27:54 -070064 private Context mContext;
Adam Powell661c9082010-07-02 10:09:44 -070065 private Activity mActivity;
Adam Powelldec9dfd2010-08-09 15:27:54 -070066 private Dialog mDialog;
Adam Powell661c9082010-07-02 10:09:44 -070067
Adam Powell01feaee2011-02-10 15:05:05 -080068 private ActionBarContainer mContainerView;
Adam Powell89e06452010-06-23 20:24:52 -070069 private ActionBarView mActionView;
Adam Powell640a66e2011-04-29 10:18:53 -070070 private ActionBarContextView mContextView;
71 private ActionBarContainer mSplitView;
Adam Powelle6ec7322010-12-07 15:29:26 -080072 private View mContentView;
Adam Powellf8ac6b72011-05-23 18:14:09 -070073 private ScrollingTabContainerView mTabScrollView;
Adam Powell661c9082010-07-02 10:09:44 -070074
75 private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>();
76
Adam Powell661c9082010-07-02 10:09:44 -070077 private TabImpl mSelectedTab;
Adam Powell0c24a552010-11-03 16:44:11 -070078 private int mSavedTabPosition = INVALID_POSITION;
Adam Powell89e06452010-06-23 20:24:52 -070079
Adam Powell5d279772010-07-27 16:34:07 -070080 private ActionMode mActionMode;
Adam Powell89e06452010-06-23 20:24:52 -070081
Adam Powell8515ee82010-11-30 14:09:55 -080082 private boolean mLastMenuVisibility;
83 private ArrayList<OnMenuVisibilityListener> mMenuVisibilityListeners =
84 new ArrayList<OnMenuVisibilityListener>();
85
Adam Powell89e06452010-06-23 20:24:52 -070086 private static final int CONTEXT_DISPLAY_NORMAL = 0;
87 private static final int CONTEXT_DISPLAY_SPLIT = 1;
88
Adam Powell0c24a552010-11-03 16:44:11 -070089 private static final int INVALID_POSITION = -1;
90
Adam Powell89e06452010-06-23 20:24:52 -070091 private int mContextDisplayMode;
Adam Powellf8ac6b72011-05-23 18:14:09 -070092 private boolean mHasEmbeddedTabs;
93 private int mContentHeight;
Adam Powell0e94b512010-06-29 17:58:20 -070094
95 final Handler mHandler = new Handler();
Adam Powellf8ac6b72011-05-23 18:14:09 -070096 Runnable mTabSelector;
Adam Powelld8b3f2e2010-12-02 13:37:03 -080097
Adam Powell07e1f982011-03-24 11:11:15 -070098 private Animator mCurrentShowAnim;
99 private Animator mCurrentModeAnim;
Adam Powell50efbed2011-02-08 16:20:15 -0800100 private boolean mShowHideAnimationEnabled;
Adam Powell07e1f982011-03-24 11:11:15 -0700101 boolean mWasHiddenBeforeMode;
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800102
Adam Powell07e1f982011-03-24 11:11:15 -0700103 final AnimatorListener mHideListener = new AnimatorListenerAdapter() {
Adam Powelle6ec7322010-12-07 15:29:26 -0800104 @Override
105 public void onAnimationEnd(Animator animation) {
106 if (mContentView != null) {
107 mContentView.setTranslationY(0);
108 }
109 mContainerView.setVisibility(View.GONE);
Adam Powell01feaee2011-02-10 15:05:05 -0800110 mContainerView.setTransitioning(false);
Adam Powell07e1f982011-03-24 11:11:15 -0700111 mCurrentShowAnim = null;
Adam Powelle6ec7322010-12-07 15:29:26 -0800112 }
113 };
114
Adam Powell07e1f982011-03-24 11:11:15 -0700115 final AnimatorListener mShowListener = new AnimatorListenerAdapter() {
Adam Powelle6ec7322010-12-07 15:29:26 -0800116 @Override
117 public void onAnimationEnd(Animator animation) {
Adam Powell07e1f982011-03-24 11:11:15 -0700118 mCurrentShowAnim = null;
Adam Powell45f1e082010-12-10 14:20:13 -0800119 mContainerView.requestLayout();
Adam Powelle6ec7322010-12-07 15:29:26 -0800120 }
Adam Powelle6ec7322010-12-07 15:29:26 -0800121 };
122
Adam Powell661c9082010-07-02 10:09:44 -0700123 public ActionBarImpl(Activity activity) {
Adam Powell661c9082010-07-02 10:09:44 -0700124 mActivity = activity;
Adam Powelle6ec7322010-12-07 15:29:26 -0800125 Window window = activity.getWindow();
126 View decor = window.getDecorView();
127 init(decor);
128 if (!mActivity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
129 mContentView = decor.findViewById(android.R.id.content);
130 }
Adam Powelldec9dfd2010-08-09 15:27:54 -0700131 }
132
133 public ActionBarImpl(Dialog dialog) {
134 mDialog = dialog;
135 init(dialog.getWindow().getDecorView());
136 }
137
138 private void init(View decor) {
139 mContext = decor.getContext();
Adam Powell89e06452010-06-23 20:24:52 -0700140 mActionView = (ActionBarView) decor.findViewById(com.android.internal.R.id.action_bar);
Adam Powell640a66e2011-04-29 10:18:53 -0700141 mContextView = (ActionBarContextView) decor.findViewById(
Adam Powell89e06452010-06-23 20:24:52 -0700142 com.android.internal.R.id.action_context_bar);
Adam Powell01feaee2011-02-10 15:05:05 -0800143 mContainerView = (ActionBarContainer) decor.findViewById(
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800144 com.android.internal.R.id.action_bar_container);
Adam Powell640a66e2011-04-29 10:18:53 -0700145 mSplitView = (ActionBarContainer) decor.findViewById(
146 com.android.internal.R.id.split_action_bar);
Steve Block08f194b2010-08-24 18:20:48 +0100147
Adam Powell640a66e2011-04-29 10:18:53 -0700148 if (mActionView == null || mContextView == null || mContainerView == null) {
Adam Powell89e06452010-06-23 20:24:52 -0700149 throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
150 "with a compatible window decor layout");
151 }
Adam Powell0e94b512010-06-29 17:58:20 -0700152
Adam Powellf8ac6b72011-05-23 18:14:09 -0700153 mHasEmbeddedTabs = mContext.getResources().getBoolean(
154 com.android.internal.R.bool.action_bar_embed_tabs);
Adam Powell640a66e2011-04-29 10:18:53 -0700155 mActionView.setContextView(mContextView);
Adam Powell9b4bee02011-04-27 19:24:47 -0700156 mContextDisplayMode = mActionView.isSplitActionBar() ?
157 CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL;
Adam Powelldae78242011-04-25 15:23:41 -0700158
Adam Powellf8ac6b72011-05-23 18:14:09 -0700159 TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar);
160 mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
161 a.recycle();
162 }
163
164 public void onConfigurationChanged(Configuration newConfig) {
165 mHasEmbeddedTabs = mContext.getResources().getBoolean(
166 com.android.internal.R.bool.action_bar_embed_tabs);
167
168 // Switch tab layout configuration if needed
169 if (!mHasEmbeddedTabs) {
170 mActionView.setEmbeddedTabView(null);
171 mContainerView.setTabContainer(mTabScrollView);
172 } else {
173 mContainerView.setTabContainer(null);
174 if (mTabScrollView != null) {
175 mTabScrollView.setVisibility(View.VISIBLE);
176 }
177 mActionView.setEmbeddedTabView(mTabScrollView);
178 }
Adam Powelld21aa122011-05-27 13:09:52 -0700179 mActionView.setCollapsable(!mHasEmbeddedTabs &&
180 getNavigationMode() == NAVIGATION_MODE_TABS);
Adam Powellf8ac6b72011-05-23 18:14:09 -0700181
182 TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar);
183 mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
184 a.recycle();
185
186 if (mTabScrollView != null) {
187 mTabScrollView.getLayoutParams().height = mContentHeight;
188 mTabScrollView.requestLayout();
189 }
190 }
191
192 private void ensureTabsExist() {
193 if (mTabScrollView != null) {
194 return;
195 }
196
197 ScrollingTabContainerView tabScroller = mActionView.createTabContainer();
198
199 if (mHasEmbeddedTabs) {
200 tabScroller.setVisibility(View.VISIBLE);
201 mActionView.setEmbeddedTabView(tabScroller);
202 } else {
Adam Powelldae78242011-04-25 15:23:41 -0700203 tabScroller.setVisibility(getNavigationMode() == NAVIGATION_MODE_TABS ?
204 View.VISIBLE : View.GONE);
Adam Powelldae78242011-04-25 15:23:41 -0700205 mContainerView.setTabContainer(tabScroller);
Adam Powelldae78242011-04-25 15:23:41 -0700206 }
Adam Powellf8ac6b72011-05-23 18:14:09 -0700207 mTabScrollView = tabScroller;
Adam Powell89e06452010-06-23 20:24:52 -0700208 }
209
Adam Powell50efbed2011-02-08 16:20:15 -0800210 /**
211 * Enables or disables animation between show/hide states.
212 * If animation is disabled using this method, animations in progress
213 * will be finished.
214 *
215 * @param enabled true to animate, false to not animate.
216 */
217 public void setShowHideAnimationEnabled(boolean enabled) {
218 mShowHideAnimationEnabled = enabled;
Adam Powell07e1f982011-03-24 11:11:15 -0700219 if (!enabled && mCurrentShowAnim != null) {
220 mCurrentShowAnim.end();
Adam Powell50efbed2011-02-08 16:20:15 -0800221 }
222 }
223
Adam Powell8515ee82010-11-30 14:09:55 -0800224 public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
225 mMenuVisibilityListeners.add(listener);
226 }
227
228 public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
229 mMenuVisibilityListeners.remove(listener);
230 }
231
232 public void dispatchMenuVisibilityChanged(boolean isVisible) {
233 if (isVisible == mLastMenuVisibility) {
234 return;
235 }
236 mLastMenuVisibility = isVisible;
237
238 final int count = mMenuVisibilityListeners.size();
239 for (int i = 0; i < count; i++) {
240 mMenuVisibilityListeners.get(i).onMenuVisibilityChanged(isVisible);
241 }
242 }
243
Adam Powella66c7b02010-07-28 15:28:25 -0700244 @Override
Adam Powell3f476b32011-01-03 19:25:36 -0800245 public void setCustomView(int resId) {
246 setCustomView(LayoutInflater.from(mContext).inflate(resId, mActionView, false));
247 }
248
249 @Override
250 public void setDisplayUseLogoEnabled(boolean useLogo) {
251 setDisplayOptions(useLogo ? DISPLAY_USE_LOGO : 0, DISPLAY_USE_LOGO);
252 }
253
254 @Override
255 public void setDisplayShowHomeEnabled(boolean showHome) {
256 setDisplayOptions(showHome ? DISPLAY_SHOW_HOME : 0, DISPLAY_SHOW_HOME);
257 }
258
259 @Override
260 public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
261 setDisplayOptions(showHomeAsUp ? DISPLAY_HOME_AS_UP : 0, DISPLAY_HOME_AS_UP);
262 }
263
264 @Override
265 public void setDisplayShowTitleEnabled(boolean showTitle) {
266 setDisplayOptions(showTitle ? DISPLAY_SHOW_TITLE : 0, DISPLAY_SHOW_TITLE);
267 }
268
269 @Override
270 public void setDisplayShowCustomEnabled(boolean showCustom) {
271 setDisplayOptions(showCustom ? DISPLAY_SHOW_CUSTOM : 0, DISPLAY_SHOW_CUSTOM);
272 }
273
274 @Override
Adam Powelldae78242011-04-25 15:23:41 -0700275 public void setDisplayDisableHomeEnabled(boolean disableHome) {
276 setDisplayOptions(disableHome ? DISPLAY_DISABLE_HOME : 0, DISPLAY_DISABLE_HOME);
277 }
278
279 @Override
Adam Powella66c7b02010-07-28 15:28:25 -0700280 public void setTitle(int resId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700281 setTitle(mContext.getString(resId));
Adam Powella66c7b02010-07-28 15:28:25 -0700282 }
283
284 @Override
285 public void setSubtitle(int resId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700286 setSubtitle(mContext.getString(resId));
Adam Powella66c7b02010-07-28 15:28:25 -0700287 }
288
Adam Powell17809772010-07-21 13:25:11 -0700289 public void setSelectedNavigationItem(int position) {
290 switch (mActionView.getNavigationMode()) {
291 case NAVIGATION_MODE_TABS:
292 selectTab(mTabs.get(position));
293 break;
Adam Powell9ab97872010-10-26 21:47:29 -0700294 case NAVIGATION_MODE_LIST:
Adam Powell17809772010-07-21 13:25:11 -0700295 mActionView.setDropdownSelectedPosition(position);
296 break;
297 default:
298 throw new IllegalStateException(
Adam Powell9ab97872010-10-26 21:47:29 -0700299 "setSelectedNavigationIndex not valid for current navigation mode");
Adam Powell17809772010-07-21 13:25:11 -0700300 }
301 }
302
Adam Powell9ab97872010-10-26 21:47:29 -0700303 public void removeAllTabs() {
304 cleanupTabs();
Adam Powell17809772010-07-21 13:25:11 -0700305 }
306
Adam Powell661c9082010-07-02 10:09:44 -0700307 private void cleanupTabs() {
308 if (mSelectedTab != null) {
309 selectTab(null);
310 }
Adam Powell2b6230e2010-09-07 17:55:25 -0700311 mTabs.clear();
Adam Powelld21aa122011-05-27 13:09:52 -0700312 if (mTabScrollView != null) {
313 mTabScrollView.removeAllTabs();
314 }
Adam Powell0c24a552010-11-03 16:44:11 -0700315 mSavedTabPosition = INVALID_POSITION;
Adam Powell661c9082010-07-02 10:09:44 -0700316 }
317
Adam Powell0e94b512010-06-29 17:58:20 -0700318 public void setTitle(CharSequence title) {
319 mActionView.setTitle(title);
320 }
321
322 public void setSubtitle(CharSequence subtitle) {
323 mActionView.setSubtitle(subtitle);
324 }
325
Adam Powell89e06452010-06-23 20:24:52 -0700326 public void setDisplayOptions(int options) {
327 mActionView.setDisplayOptions(options);
328 }
Adam Powell0e94b512010-06-29 17:58:20 -0700329
Adam Powell89e06452010-06-23 20:24:52 -0700330 public void setDisplayOptions(int options, int mask) {
331 final int current = mActionView.getDisplayOptions();
332 mActionView.setDisplayOptions((options & mask) | (current & ~mask));
333 }
334
335 public void setBackgroundDrawable(Drawable d) {
Adam Powelle8c1e5c2010-12-13 10:49:32 -0800336 mContainerView.setBackgroundDrawable(d);
Adam Powell89e06452010-06-23 20:24:52 -0700337 }
338
Adam Powellef704442010-11-16 14:48:22 -0800339 public View getCustomView() {
Adam Powell89e06452010-06-23 20:24:52 -0700340 return mActionView.getCustomNavigationView();
341 }
342
343 public CharSequence getTitle() {
344 return mActionView.getTitle();
345 }
346
347 public CharSequence getSubtitle() {
348 return mActionView.getSubtitle();
349 }
350
351 public int getNavigationMode() {
352 return mActionView.getNavigationMode();
353 }
354
355 public int getDisplayOptions() {
356 return mActionView.getDisplayOptions();
357 }
358
Adam Powell5d279772010-07-27 16:34:07 -0700359 public ActionMode startActionMode(ActionMode.Callback callback) {
360 if (mActionMode != null) {
361 mActionMode.finish();
Adam Powell6e346362010-07-23 10:18:23 -0700362 }
Adam Powell3461b322010-07-14 11:34:43 -0700363
Adam Powell640a66e2011-04-29 10:18:53 -0700364 mContextView.killMode();
Adam Powell5ee36c42011-06-02 12:59:43 -0700365 ActionModeImpl mode = new ActionModeImpl(callback);
366 if (mode.dispatchOnCreate()) {
Adam Powell07e1f982011-03-24 11:11:15 -0700367 mWasHiddenBeforeMode = !isShowing();
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700368 mode.invalidate();
Adam Powell640a66e2011-04-29 10:18:53 -0700369 mContextView.initForMode(mode);
370 animateToMode(true);
371 if (mSplitView != null) {
Adam Powell89e06452010-06-23 20:24:52 -0700372 // TODO animate this
Adam Powell640a66e2011-04-29 10:18:53 -0700373 mSplitView.setVisibility(View.VISIBLE);
Adam Powell89e06452010-06-23 20:24:52 -0700374 }
Adam Powell5d279772010-07-27 16:34:07 -0700375 mActionMode = mode;
Adam Powellac695c62010-07-20 18:19:27 -0700376 return mode;
Adam Powell89e06452010-06-23 20:24:52 -0700377 }
Adam Powellac695c62010-07-20 18:19:27 -0700378 return null;
Adam Powell89e06452010-06-23 20:24:52 -0700379 }
380
Adam Powell661c9082010-07-02 10:09:44 -0700381 private void configureTab(Tab tab, int position) {
382 final TabImpl tabi = (TabImpl) tab;
Adam Powell2b6230e2010-09-07 17:55:25 -0700383 final ActionBar.TabListener callback = tabi.getCallback();
384
385 if (callback == null) {
386 throw new IllegalStateException("Action Bar Tab must have a Callback");
387 }
Adam Powell661c9082010-07-02 10:09:44 -0700388
389 tabi.setPosition(position);
390 mTabs.add(position, tabi);
391
Adam Powell81b89442010-11-02 17:58:56 -0700392 final int count = mTabs.size();
393 for (int i = position + 1; i < count; i++) {
394 mTabs.get(i).setPosition(i);
Adam Powell661c9082010-07-02 10:09:44 -0700395 }
Adam Powell661c9082010-07-02 10:09:44 -0700396 }
397
398 @Override
399 public void addTab(Tab tab) {
Adam Powell81b89442010-11-02 17:58:56 -0700400 addTab(tab, mTabs.isEmpty());
Adam Powell661c9082010-07-02 10:09:44 -0700401 }
402
403 @Override
Adam Powell2b6230e2010-09-07 17:55:25 -0700404 public void addTab(Tab tab, int position) {
Adam Powell81b89442010-11-02 17:58:56 -0700405 addTab(tab, position, mTabs.isEmpty());
406 }
407
408 @Override
409 public void addTab(Tab tab, boolean setSelected) {
Adam Powellf8ac6b72011-05-23 18:14:09 -0700410 ensureTabsExist();
411 mTabScrollView.addTab(tab, setSelected);
Adam Powell81b89442010-11-02 17:58:56 -0700412 configureTab(tab, mTabs.size());
413 if (setSelected) {
414 selectTab(tab);
415 }
416 }
417
418 @Override
419 public void addTab(Tab tab, int position, boolean setSelected) {
Adam Powellf8ac6b72011-05-23 18:14:09 -0700420 ensureTabsExist();
421 mTabScrollView.addTab(tab, position, setSelected);
Adam Powell661c9082010-07-02 10:09:44 -0700422 configureTab(tab, position);
Adam Powell81b89442010-11-02 17:58:56 -0700423 if (setSelected) {
424 selectTab(tab);
425 }
Adam Powell661c9082010-07-02 10:09:44 -0700426 }
427
428 @Override
429 public Tab newTab() {
430 return new TabImpl();
431 }
432
433 @Override
434 public void removeTab(Tab tab) {
435 removeTabAt(tab.getPosition());
436 }
437
438 @Override
439 public void removeTabAt(int position) {
Adam Powellf8ac6b72011-05-23 18:14:09 -0700440 if (mTabScrollView == null) {
441 // No tabs around to remove
442 return;
443 }
444
Adam Powell0c24a552010-11-03 16:44:11 -0700445 int selectedTabPosition = mSelectedTab != null
446 ? mSelectedTab.getPosition() : mSavedTabPosition;
Adam Powellf8ac6b72011-05-23 18:14:09 -0700447 mTabScrollView.removeTabAt(position);
Adam Powell0d8ec1d2011-05-03 14:49:13 -0700448 TabImpl removedTab = mTabs.remove(position);
449 if (removedTab != null) {
450 removedTab.setPosition(-1);
451 }
Adam Powell661c9082010-07-02 10:09:44 -0700452
453 final int newTabCount = mTabs.size();
454 for (int i = position; i < newTabCount; i++) {
455 mTabs.get(i).setPosition(i);
456 }
457
Adam Powell0c24a552010-11-03 16:44:11 -0700458 if (selectedTabPosition == position) {
459 selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1)));
460 }
Adam Powell661c9082010-07-02 10:09:44 -0700461 }
462
463 @Override
Adam Powell661c9082010-07-02 10:09:44 -0700464 public void selectTab(Tab tab) {
Adam Powell0c24a552010-11-03 16:44:11 -0700465 if (getNavigationMode() != NAVIGATION_MODE_TABS) {
466 mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION;
467 return;
468 }
469
Dianne Hackborn48e7b452011-01-17 12:28:35 -0800470 final FragmentTransaction trans = mActivity.getFragmentManager().beginTransaction()
Adam Powell0c24a552010-11-03 16:44:11 -0700471 .disallowAddToBackStack();
Adam Powell7f9b9052010-10-19 16:56:07 -0700472
473 if (mSelectedTab == tab) {
474 if (mSelectedTab != null) {
475 mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans);
Adam Powellf8ac6b72011-05-23 18:14:09 -0700476 mTabScrollView.animateToTab(tab.getPosition());
Adam Powell7f9b9052010-10-19 16:56:07 -0700477 }
478 } else {
Adam Powellf8ac6b72011-05-23 18:14:09 -0700479 mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION);
Adam Powell7f9b9052010-10-19 16:56:07 -0700480 if (mSelectedTab != null) {
481 mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans);
482 }
483 mSelectedTab = (TabImpl) tab;
484 if (mSelectedTab != null) {
485 mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans);
486 }
Adam Powell2b6230e2010-09-07 17:55:25 -0700487 }
488
489 if (!trans.isEmpty()) {
490 trans.commit();
491 }
492 }
493
494 @Override
495 public Tab getSelectedTab() {
496 return mSelectedTab;
Adam Powell661c9082010-07-02 10:09:44 -0700497 }
498
Adam Powell6b336f82010-08-10 20:13:01 -0700499 @Override
500 public int getHeight() {
501 return mActionView.getHeight();
502 }
503
504 @Override
505 public void show() {
Adam Powell07e1f982011-03-24 11:11:15 -0700506 show(true);
507 }
508
509 void show(boolean markHiddenBeforeMode) {
510 if (mCurrentShowAnim != null) {
511 mCurrentShowAnim.end();
Adam Powell45f1e082010-12-10 14:20:13 -0800512 }
Adam Powelld76cee22011-01-31 15:05:05 -0800513 if (mContainerView.getVisibility() == View.VISIBLE) {
Adam Powell07e1f982011-03-24 11:11:15 -0700514 if (markHiddenBeforeMode) mWasHiddenBeforeMode = false;
Adam Powelld76cee22011-01-31 15:05:05 -0800515 return;
516 }
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800517 mContainerView.setVisibility(View.VISIBLE);
Adam Powell50efbed2011-02-08 16:20:15 -0800518
519 if (mShowHideAnimationEnabled) {
520 mContainerView.setAlpha(0);
521 AnimatorSet anim = new AnimatorSet();
522 AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 1));
523 if (mContentView != null) {
524 b.with(ObjectAnimator.ofFloat(mContentView, "translationY",
525 -mContainerView.getHeight(), 0));
526 mContainerView.setTranslationY(-mContainerView.getHeight());
527 b.with(ObjectAnimator.ofFloat(mContainerView, "translationY", 0));
528 }
Adam Powell640a66e2011-04-29 10:18:53 -0700529 if (mSplitView != null) {
530 mSplitView.setAlpha(0);
531 b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 1));
532 }
Adam Powell50efbed2011-02-08 16:20:15 -0800533 anim.addListener(mShowListener);
Adam Powell07e1f982011-03-24 11:11:15 -0700534 mCurrentShowAnim = anim;
Adam Powell50efbed2011-02-08 16:20:15 -0800535 anim.start();
536 } else {
Adam Powelld8145042011-03-24 14:18:27 -0700537 mContainerView.setAlpha(1);
538 mContainerView.setTranslationY(0);
Adam Powell50efbed2011-02-08 16:20:15 -0800539 mShowListener.onAnimationEnd(null);
Adam Powelle6ec7322010-12-07 15:29:26 -0800540 }
Adam Powell6b336f82010-08-10 20:13:01 -0700541 }
542
543 @Override
544 public void hide() {
Adam Powell07e1f982011-03-24 11:11:15 -0700545 if (mCurrentShowAnim != null) {
546 mCurrentShowAnim.end();
Adam Powelle6ec7322010-12-07 15:29:26 -0800547 }
548 if (mContainerView.getVisibility() == View.GONE) {
549 return;
550 }
Adam Powell50efbed2011-02-08 16:20:15 -0800551
552 if (mShowHideAnimationEnabled) {
553 mContainerView.setAlpha(1);
Adam Powell01feaee2011-02-10 15:05:05 -0800554 mContainerView.setTransitioning(true);
Adam Powell50efbed2011-02-08 16:20:15 -0800555 AnimatorSet anim = new AnimatorSet();
556 AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mContainerView, "alpha", 0));
557 if (mContentView != null) {
558 b.with(ObjectAnimator.ofFloat(mContentView, "translationY",
559 0, -mContainerView.getHeight()));
560 b.with(ObjectAnimator.ofFloat(mContainerView, "translationY",
561 -mContainerView.getHeight()));
562 }
Adam Powell640a66e2011-04-29 10:18:53 -0700563 if (mSplitView != null) {
564 mSplitView.setAlpha(1);
565 b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 0));
566 }
Adam Powell50efbed2011-02-08 16:20:15 -0800567 anim.addListener(mHideListener);
Adam Powell07e1f982011-03-24 11:11:15 -0700568 mCurrentShowAnim = anim;
Adam Powell50efbed2011-02-08 16:20:15 -0800569 anim.start();
570 } else {
571 mHideListener.onAnimationEnd(null);
Adam Powelle6ec7322010-12-07 15:29:26 -0800572 }
Adam Powell6b336f82010-08-10 20:13:01 -0700573 }
574
575 public boolean isShowing() {
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800576 return mContainerView.getVisibility() == View.VISIBLE;
577 }
578
Adam Powell640a66e2011-04-29 10:18:53 -0700579 void animateToMode(boolean toActionMode) {
Adam Powell07e1f982011-03-24 11:11:15 -0700580 show(false);
581 if (mCurrentModeAnim != null) {
582 mCurrentModeAnim.end();
583 }
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800584
Adam Powell640a66e2011-04-29 10:18:53 -0700585 mActionView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE);
586 mContextView.animateToVisibility(toActionMode ? View.VISIBLE : View.GONE);
Adam Powell6b336f82010-08-10 20:13:01 -0700587 }
588
Adam Powell89e06452010-06-23 20:24:52 -0700589 /**
590 * @hide
591 */
Adam Powell5d279772010-07-27 16:34:07 -0700592 public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
Adam Powell6e346362010-07-23 10:18:23 -0700593 private ActionMode.Callback mCallback;
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700594 private MenuBuilder mMenu;
Adam Powell29ed7572010-07-14 16:24:56 -0700595 private WeakReference<View> mCustomView;
Adam Powell89e06452010-06-23 20:24:52 -0700596
Adam Powell5d279772010-07-27 16:34:07 -0700597 public ActionModeImpl(ActionMode.Callback callback) {
Adam Powell89e06452010-06-23 20:24:52 -0700598 mCallback = callback;
Adam Powell4d9861e2010-08-17 11:14:40 -0700599 mMenu = new MenuBuilder(mActionView.getContext())
600 .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700601 mMenu.setCallback(this);
Adam Powell89e06452010-06-23 20:24:52 -0700602 }
Adam Powell9168f0b2010-08-02 15:46:24 -0700603
604 @Override
605 public MenuInflater getMenuInflater() {
Adam Powell4d9861e2010-08-17 11:14:40 -0700606 return new MenuInflater(mContext);
Adam Powell9168f0b2010-08-02 15:46:24 -0700607 }
608
Adam Powell89e06452010-06-23 20:24:52 -0700609 @Override
610 public Menu getMenu() {
611 return mMenu;
612 }
613
614 @Override
615 public void finish() {
Adam Powell5d279772010-07-27 16:34:07 -0700616 if (mActionMode != this) {
617 // Not the active action mode - no-op
Adam Powell93b6bc32010-07-22 11:36:35 -0700618 return;
619 }
620
Adam Powell6e346362010-07-23 10:18:23 -0700621 mCallback.onDestroyActionMode(this);
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800622 mCallback = null;
Adam Powell640a66e2011-04-29 10:18:53 -0700623 animateToMode(false);
Adam Powell0e94b512010-06-29 17:58:20 -0700624
625 // Clear out the context mode views after the animation finishes
Adam Powell640a66e2011-04-29 10:18:53 -0700626 mContextView.closeMode();
Adam Powell5d279772010-07-27 16:34:07 -0700627 mActionMode = null;
Adam Powell07e1f982011-03-24 11:11:15 -0700628
629 if (mWasHiddenBeforeMode) {
630 hide();
631 }
Adam Powell89e06452010-06-23 20:24:52 -0700632 }
633
634 @Override
635 public void invalidate() {
Adam Powell5ee36c42011-06-02 12:59:43 -0700636 mMenu.stopDispatchingItemsChanged();
637 try {
638 mCallback.onPrepareActionMode(this, mMenu);
639 } finally {
640 mMenu.startDispatchingItemsChanged();
641 }
642 }
643
644 public boolean dispatchOnCreate() {
645 mMenu.stopDispatchingItemsChanged();
646 try {
647 return mCallback.onCreateActionMode(this, mMenu);
648 } finally {
649 mMenu.startDispatchingItemsChanged();
Adam Powell89e06452010-06-23 20:24:52 -0700650 }
651 }
652
653 @Override
654 public void setCustomView(View view) {
Adam Powell640a66e2011-04-29 10:18:53 -0700655 mContextView.setCustomView(view);
Adam Powell29ed7572010-07-14 16:24:56 -0700656 mCustomView = new WeakReference<View>(view);
Adam Powell89e06452010-06-23 20:24:52 -0700657 }
658
659 @Override
660 public void setSubtitle(CharSequence subtitle) {
Adam Powell640a66e2011-04-29 10:18:53 -0700661 mContextView.setSubtitle(subtitle);
Adam Powell89e06452010-06-23 20:24:52 -0700662 }
663
664 @Override
665 public void setTitle(CharSequence title) {
Adam Powell640a66e2011-04-29 10:18:53 -0700666 mContextView.setTitle(title);
Adam Powell89e06452010-06-23 20:24:52 -0700667 }
Adam Powell29ed7572010-07-14 16:24:56 -0700668
669 @Override
Adam Powellc9ae2a22010-07-28 14:44:21 -0700670 public void setTitle(int resId) {
Adam Powell48e8ac32011-01-14 12:10:24 -0800671 setTitle(mContext.getResources().getString(resId));
Adam Powellc9ae2a22010-07-28 14:44:21 -0700672 }
673
674 @Override
675 public void setSubtitle(int resId) {
Adam Powell48e8ac32011-01-14 12:10:24 -0800676 setSubtitle(mContext.getResources().getString(resId));
Adam Powellc9ae2a22010-07-28 14:44:21 -0700677 }
678
679 @Override
Adam Powell29ed7572010-07-14 16:24:56 -0700680 public CharSequence getTitle() {
Adam Powell640a66e2011-04-29 10:18:53 -0700681 return mContextView.getTitle();
Adam Powell29ed7572010-07-14 16:24:56 -0700682 }
683
684 @Override
685 public CharSequence getSubtitle() {
Adam Powell640a66e2011-04-29 10:18:53 -0700686 return mContextView.getSubtitle();
Adam Powell29ed7572010-07-14 16:24:56 -0700687 }
Adam Powell89e06452010-06-23 20:24:52 -0700688
Adam Powell29ed7572010-07-14 16:24:56 -0700689 @Override
690 public View getCustomView() {
691 return mCustomView != null ? mCustomView.get() : null;
692 }
693
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700694 public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800695 if (mCallback != null) {
696 return mCallback.onActionItemClicked(this, item);
697 } else {
698 return false;
699 }
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700700 }
701
702 public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
703 }
704
705 public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800706 if (mCallback == null) {
707 return false;
708 }
709
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700710 if (!subMenu.hasVisibleItems()) {
711 return true;
Adam Powell89e06452010-06-23 20:24:52 -0700712 }
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700713
Adam Powelldec9dfd2010-08-09 15:27:54 -0700714 new MenuPopupHelper(mContext, subMenu).show();
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700715 return true;
716 }
717
718 public void onCloseSubMenu(SubMenuBuilder menu) {
719 }
720
721 public void onMenuModeChange(MenuBuilder menu) {
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800722 if (mCallback == null) {
723 return;
724 }
Adam Powellf6148c52010-08-11 21:10:16 -0700725 invalidate();
Adam Powell640a66e2011-04-29 10:18:53 -0700726 mContextView.showOverflowMenu();
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700727 }
Adam Powell661c9082010-07-02 10:09:44 -0700728 }
729
730 /**
731 * @hide
732 */
733 public class TabImpl extends ActionBar.Tab {
Adam Powell2b6230e2010-09-07 17:55:25 -0700734 private ActionBar.TabListener mCallback;
735 private Object mTag;
Adam Powell661c9082010-07-02 10:09:44 -0700736 private Drawable mIcon;
737 private CharSequence mText;
Adam Powell0d8ec1d2011-05-03 14:49:13 -0700738 private int mPosition = -1;
Adam Powell2b6230e2010-09-07 17:55:25 -0700739 private View mCustomView;
Adam Powell661c9082010-07-02 10:09:44 -0700740
741 @Override
Adam Powell2b6230e2010-09-07 17:55:25 -0700742 public Object getTag() {
743 return mTag;
744 }
745
746 @Override
Adam Powell9ab97872010-10-26 21:47:29 -0700747 public Tab setTag(Object tag) {
Adam Powell2b6230e2010-09-07 17:55:25 -0700748 mTag = tag;
Adam Powell9ab97872010-10-26 21:47:29 -0700749 return this;
Adam Powell2b6230e2010-09-07 17:55:25 -0700750 }
751
752 public ActionBar.TabListener getCallback() {
753 return mCallback;
754 }
755
756 @Override
Adam Powell9ab97872010-10-26 21:47:29 -0700757 public Tab setTabListener(ActionBar.TabListener callback) {
Adam Powell2b6230e2010-09-07 17:55:25 -0700758 mCallback = callback;
Adam Powell9ab97872010-10-26 21:47:29 -0700759 return this;
Adam Powell2b6230e2010-09-07 17:55:25 -0700760 }
761
762 @Override
763 public View getCustomView() {
764 return mCustomView;
765 }
766
767 @Override
Adam Powell9ab97872010-10-26 21:47:29 -0700768 public Tab setCustomView(View view) {
Adam Powell2b6230e2010-09-07 17:55:25 -0700769 mCustomView = view;
Adam Powellf8ac6b72011-05-23 18:14:09 -0700770 if (mPosition >= 0) {
771 mTabScrollView.updateTab(mPosition);
772 }
Adam Powell9ab97872010-10-26 21:47:29 -0700773 return this;
Adam Powell661c9082010-07-02 10:09:44 -0700774 }
775
776 @Override
Adam Powell32555f32010-11-17 13:49:22 -0800777 public Tab setCustomView(int layoutResId) {
778 return setCustomView(LayoutInflater.from(mContext).inflate(layoutResId, null));
779 }
780
781 @Override
Adam Powell661c9082010-07-02 10:09:44 -0700782 public Drawable getIcon() {
783 return mIcon;
784 }
785
786 @Override
787 public int getPosition() {
788 return mPosition;
789 }
790
791 public void setPosition(int position) {
792 mPosition = position;
793 }
794
795 @Override
796 public CharSequence getText() {
797 return mText;
798 }
799
800 @Override
Adam Powell9ab97872010-10-26 21:47:29 -0700801 public Tab setIcon(Drawable icon) {
Adam Powell661c9082010-07-02 10:09:44 -0700802 mIcon = icon;
Adam Powellf8ac6b72011-05-23 18:14:09 -0700803 if (mPosition >= 0) {
804 mTabScrollView.updateTab(mPosition);
805 }
Adam Powell9ab97872010-10-26 21:47:29 -0700806 return this;
Adam Powell661c9082010-07-02 10:09:44 -0700807 }
808
809 @Override
Adam Powell32555f32010-11-17 13:49:22 -0800810 public Tab setIcon(int resId) {
811 return setIcon(mContext.getResources().getDrawable(resId));
812 }
813
814 @Override
Adam Powell9ab97872010-10-26 21:47:29 -0700815 public Tab setText(CharSequence text) {
Adam Powell661c9082010-07-02 10:09:44 -0700816 mText = text;
Adam Powellf8ac6b72011-05-23 18:14:09 -0700817 if (mPosition >= 0) {
818 mTabScrollView.updateTab(mPosition);
819 }
Adam Powell9ab97872010-10-26 21:47:29 -0700820 return this;
Adam Powell661c9082010-07-02 10:09:44 -0700821 }
822
823 @Override
Adam Powell32555f32010-11-17 13:49:22 -0800824 public Tab setText(int resId) {
825 return setText(mContext.getResources().getText(resId));
826 }
827
828 @Override
Adam Powell661c9082010-07-02 10:09:44 -0700829 public void select() {
830 selectTab(this);
Adam Powell89e06452010-06-23 20:24:52 -0700831 }
832 }
Adam Powell9ab97872010-10-26 21:47:29 -0700833
834 @Override
835 public void setCustomView(View view) {
836 mActionView.setCustomNavigationView(view);
837 }
838
839 @Override
840 public void setCustomView(View view, LayoutParams layoutParams) {
841 view.setLayoutParams(layoutParams);
842 mActionView.setCustomNavigationView(view);
843 }
844
845 @Override
Adam Powell8515ee82010-11-30 14:09:55 -0800846 public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) {
Adam Powell9ab97872010-10-26 21:47:29 -0700847 mActionView.setDropdownAdapter(adapter);
848 mActionView.setCallback(callback);
849 }
850
851 @Override
852 public int getSelectedNavigationIndex() {
853 switch (mActionView.getNavigationMode()) {
854 case NAVIGATION_MODE_TABS:
Adam Powell04587962010-11-11 22:15:07 -0800855 return mSelectedTab != null ? mSelectedTab.getPosition() : -1;
Adam Powell9ab97872010-10-26 21:47:29 -0700856 case NAVIGATION_MODE_LIST:
857 return mActionView.getDropdownSelectedPosition();
858 default:
859 return -1;
860 }
861 }
862
863 @Override
864 public int getNavigationItemCount() {
865 switch (mActionView.getNavigationMode()) {
866 case NAVIGATION_MODE_TABS:
867 return mTabs.size();
868 case NAVIGATION_MODE_LIST:
869 SpinnerAdapter adapter = mActionView.getDropdownAdapter();
870 return adapter != null ? adapter.getCount() : 0;
871 default:
872 return 0;
873 }
874 }
875
876 @Override
Adam Powell0c24a552010-11-03 16:44:11 -0700877 public int getTabCount() {
878 return mTabs.size();
879 }
880
881 @Override
Adam Powell9ab97872010-10-26 21:47:29 -0700882 public void setNavigationMode(int mode) {
Adam Powell0c24a552010-11-03 16:44:11 -0700883 final int oldMode = mActionView.getNavigationMode();
884 switch (oldMode) {
885 case NAVIGATION_MODE_TABS:
886 mSavedTabPosition = getSelectedNavigationIndex();
887 selectTab(null);
Adam Powelldae78242011-04-25 15:23:41 -0700888 if (!mActionView.hasEmbeddedTabs()) {
Adam Powellf8ac6b72011-05-23 18:14:09 -0700889 mTabScrollView.setVisibility(View.GONE);
Adam Powelldae78242011-04-25 15:23:41 -0700890 }
Adam Powell0c24a552010-11-03 16:44:11 -0700891 break;
892 }
Adam Powell9ab97872010-10-26 21:47:29 -0700893 mActionView.setNavigationMode(mode);
Adam Powell0c24a552010-11-03 16:44:11 -0700894 switch (mode) {
895 case NAVIGATION_MODE_TABS:
Adam Powellf8ac6b72011-05-23 18:14:09 -0700896 ensureTabsExist();
Adam Powelldae78242011-04-25 15:23:41 -0700897 if (!mActionView.hasEmbeddedTabs()) {
Adam Powellf8ac6b72011-05-23 18:14:09 -0700898 mTabScrollView.setVisibility(View.VISIBLE);
Adam Powelldae78242011-04-25 15:23:41 -0700899 }
Adam Powell0c24a552010-11-03 16:44:11 -0700900 if (mSavedTabPosition != INVALID_POSITION) {
901 setSelectedNavigationItem(mSavedTabPosition);
902 mSavedTabPosition = INVALID_POSITION;
903 }
904 break;
905 }
Adam Powelld21aa122011-05-27 13:09:52 -0700906 mActionView.setCollapsable(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs);
Adam Powell9ab97872010-10-26 21:47:29 -0700907 }
908
909 @Override
910 public Tab getTabAt(int index) {
911 return mTabs.get(index);
912 }
Adam Powell0c24a552010-11-03 16:44:11 -0700913
Adam Powell0c24a552010-11-03 16:44:11 -0700914
Adam Powell1969b872011-03-22 11:52:48 -0700915 @Override
916 public void setIcon(int resId) {
Adam Powell45c515b2011-04-21 18:50:20 -0700917 mActionView.setIcon(resId);
Adam Powell1969b872011-03-22 11:52:48 -0700918 }
Adam Powell0c24a552010-11-03 16:44:11 -0700919
Adam Powell1969b872011-03-22 11:52:48 -0700920 @Override
921 public void setIcon(Drawable icon) {
922 mActionView.setIcon(icon);
923 }
924
925 @Override
926 public void setLogo(int resId) {
Adam Powell45c515b2011-04-21 18:50:20 -0700927 mActionView.setLogo(resId);
Adam Powell1969b872011-03-22 11:52:48 -0700928 }
929
930 @Override
931 public void setLogo(Drawable logo) {
932 mActionView.setLogo(logo);
Adam Powell0c24a552010-11-03 16:44:11 -0700933 }
Adam Powell89e06452010-06-23 20:24:52 -0700934}