blob: dd2ad6c764ddeab5b1fe71ada86f21f26d4addc8 [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 Powell2c9c9fe2010-07-16 10:17:57 -070019import com.android.internal.view.menu.MenuBuilder;
Adam Powell2c9c9fe2010-07-16 10:17:57 -070020import com.android.internal.view.menu.MenuPopupHelper;
21import com.android.internal.view.menu.SubMenuBuilder;
Adam Powell89e06452010-06-23 20:24:52 -070022import com.android.internal.widget.ActionBarContextView;
23import com.android.internal.widget.ActionBarView;
24
25import android.app.ActionBar;
Adam Powell661c9082010-07-02 10:09:44 -070026import android.app.Activity;
Adam Powelldec9dfd2010-08-09 15:27:54 -070027import android.app.Dialog;
Adam Powell661c9082010-07-02 10:09:44 -070028import android.app.Fragment;
29import android.app.FragmentTransaction;
Adam Powelldec9dfd2010-08-09 15:27:54 -070030import android.content.Context;
Adam Powell89e06452010-06-23 20:24:52 -070031import android.graphics.drawable.Drawable;
Adam Powell0e94b512010-06-29 17:58:20 -070032import android.os.Handler;
Adam Powell6e346362010-07-23 10:18:23 -070033import android.view.ActionMode;
Adam Powell89e06452010-06-23 20:24:52 -070034import android.view.Menu;
Adam Powell9168f0b2010-08-02 15:46:24 -070035import android.view.MenuInflater;
Adam Powell89e06452010-06-23 20:24:52 -070036import android.view.MenuItem;
37import android.view.View;
38import android.widget.LinearLayout;
39import android.widget.SpinnerAdapter;
40import android.widget.ViewAnimator;
41
Adam Powell29ed7572010-07-14 16:24:56 -070042import java.lang.ref.WeakReference;
Adam Powell661c9082010-07-02 10:09:44 -070043import java.util.ArrayList;
44
Adam Powell89e06452010-06-23 20:24:52 -070045/**
46 * ActionBarImpl is the ActionBar implementation used
47 * by devices of all screen sizes. If it detects a compatible decor,
48 * it will split contextual modes across both the ActionBarView at
49 * the top of the screen and a horizontal LinearLayout at the bottom
50 * which is normally hidden.
51 */
52public class ActionBarImpl extends ActionBar {
53 private static final int NORMAL_VIEW = 0;
54 private static final int CONTEXT_VIEW = 1;
55
Adam Powell661c9082010-07-02 10:09:44 -070056 private static final int TAB_SWITCH_SHOW_HIDE = 0;
57 private static final int TAB_SWITCH_ADD_REMOVE = 1;
58
Adam Powelldec9dfd2010-08-09 15:27:54 -070059 private Context mContext;
Adam Powell661c9082010-07-02 10:09:44 -070060 private Activity mActivity;
Adam Powelldec9dfd2010-08-09 15:27:54 -070061 private Dialog mDialog;
Adam Powell661c9082010-07-02 10:09:44 -070062
Adam Powell89e06452010-06-23 20:24:52 -070063 private ViewAnimator mAnimatorView;
64 private ActionBarView mActionView;
65 private ActionBarContextView mUpperContextView;
66 private LinearLayout mLowerContextView;
Adam Powell661c9082010-07-02 10:09:44 -070067
68 private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>();
69
70 private int mTabContainerViewId = android.R.id.content;
71 private TabImpl mSelectedTab;
72 private int mTabSwitchMode = TAB_SWITCH_ADD_REMOVE;
Adam Powell89e06452010-06-23 20:24:52 -070073
Adam Powell5d279772010-07-27 16:34:07 -070074 private ActionMode mActionMode;
Adam Powell89e06452010-06-23 20:24:52 -070075
76 private static final int CONTEXT_DISPLAY_NORMAL = 0;
77 private static final int CONTEXT_DISPLAY_SPLIT = 1;
78
79 private int mContextDisplayMode;
Adam Powell0e94b512010-06-29 17:58:20 -070080
Adam Powell3461b322010-07-14 11:34:43 -070081 private boolean mClosingContext;
82
Adam Powell0e94b512010-06-29 17:58:20 -070083 final Handler mHandler = new Handler();
84 final Runnable mCloseContext = new Runnable() {
85 public void run() {
86 mUpperContextView.closeMode();
87 if (mLowerContextView != null) {
88 mLowerContextView.removeAllViews();
89 }
Adam Powell3461b322010-07-14 11:34:43 -070090 mClosingContext = false;
Adam Powell0e94b512010-06-29 17:58:20 -070091 }
92 };
93
Adam Powell661c9082010-07-02 10:09:44 -070094 public ActionBarImpl(Activity activity) {
Adam Powell661c9082010-07-02 10:09:44 -070095 mActivity = activity;
Adam Powelldec9dfd2010-08-09 15:27:54 -070096 init(activity.getWindow().getDecorView());
97 }
98
99 public ActionBarImpl(Dialog dialog) {
100 mDialog = dialog;
101 init(dialog.getWindow().getDecorView());
102 }
103
104 private void init(View decor) {
105 mContext = decor.getContext();
Adam Powell89e06452010-06-23 20:24:52 -0700106 mActionView = (ActionBarView) decor.findViewById(com.android.internal.R.id.action_bar);
107 mUpperContextView = (ActionBarContextView) decor.findViewById(
108 com.android.internal.R.id.action_context_bar);
109 mLowerContextView = (LinearLayout) decor.findViewById(
110 com.android.internal.R.id.lower_action_context_bar);
111 mAnimatorView = (ViewAnimator) decor.findViewById(
112 com.android.internal.R.id.action_bar_animator);
113
114 if (mActionView == null || mUpperContextView == null || mAnimatorView == null) {
115 throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
116 "with a compatible window decor layout");
117 }
Adam Powell0e94b512010-06-29 17:58:20 -0700118
Adam Powell89e06452010-06-23 20:24:52 -0700119 mContextDisplayMode = mLowerContextView == null ?
120 CONTEXT_DISPLAY_NORMAL : CONTEXT_DISPLAY_SPLIT;
121 }
122
Adam Powella66c7b02010-07-28 15:28:25 -0700123 @Override
124 public void setStandardNavigationMode(int titleResId, int subtitleResId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700125 setStandardNavigationMode(mContext.getString(titleResId),
126 mContext.getString(subtitleResId));
Adam Powella66c7b02010-07-28 15:28:25 -0700127 }
128
129 @Override
130 public void setStandardNavigationMode(int titleResId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700131 setStandardNavigationMode(mContext.getString(titleResId));
Adam Powella66c7b02010-07-28 15:28:25 -0700132 }
133
134 @Override
135 public void setTitle(int resId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700136 setTitle(mContext.getString(resId));
Adam Powella66c7b02010-07-28 15:28:25 -0700137 }
138
139 @Override
140 public void setSubtitle(int resId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700141 setSubtitle(mContext.getString(resId));
Adam Powella66c7b02010-07-28 15:28:25 -0700142 }
143
Adam Powell89e06452010-06-23 20:24:52 -0700144 public void setCustomNavigationMode(View view) {
Adam Powell661c9082010-07-02 10:09:44 -0700145 cleanupTabs();
Adam Powell89e06452010-06-23 20:24:52 -0700146 mActionView.setCustomNavigationView(view);
147 mActionView.setCallback(null);
148 }
Adam Powell0e94b512010-06-29 17:58:20 -0700149
Adam Powell89e06452010-06-23 20:24:52 -0700150 public void setDropdownNavigationMode(SpinnerAdapter adapter, NavigationCallback callback) {
Adam Powell17809772010-07-21 13:25:11 -0700151 setDropdownNavigationMode(adapter, callback, -1);
152 }
153
154 public void setDropdownNavigationMode(SpinnerAdapter adapter, NavigationCallback callback,
155 int defaultSelectedPosition) {
Adam Powell661c9082010-07-02 10:09:44 -0700156 cleanupTabs();
Adam Powell89e06452010-06-23 20:24:52 -0700157 mActionView.setNavigationMode(NAVIGATION_MODE_DROPDOWN_LIST);
158 mActionView.setDropdownAdapter(adapter);
Adam Powell17809772010-07-21 13:25:11 -0700159 if (defaultSelectedPosition >= 0) {
160 mActionView.setDropdownSelectedPosition(defaultSelectedPosition);
161 }
162 mActionView.setCallback(callback);
Adam Powell89e06452010-06-23 20:24:52 -0700163 }
Adam Powell0e94b512010-06-29 17:58:20 -0700164
165 public void setStandardNavigationMode() {
Adam Powell661c9082010-07-02 10:09:44 -0700166 cleanupTabs();
Adam Powell0e94b512010-06-29 17:58:20 -0700167 mActionView.setNavigationMode(NAVIGATION_MODE_STANDARD);
168 mActionView.setCallback(null);
169 }
170
Adam Powell89e06452010-06-23 20:24:52 -0700171 public void setStandardNavigationMode(CharSequence title) {
Adam Powell661c9082010-07-02 10:09:44 -0700172 cleanupTabs();
Adam Powell89e06452010-06-23 20:24:52 -0700173 setStandardNavigationMode(title, null);
174 }
Adam Powell0e94b512010-06-29 17:58:20 -0700175
Adam Powell89e06452010-06-23 20:24:52 -0700176 public void setStandardNavigationMode(CharSequence title, CharSequence subtitle) {
Adam Powell661c9082010-07-02 10:09:44 -0700177 cleanupTabs();
Adam Powell89e06452010-06-23 20:24:52 -0700178 mActionView.setNavigationMode(NAVIGATION_MODE_STANDARD);
179 mActionView.setTitle(title);
180 mActionView.setSubtitle(subtitle);
181 mActionView.setCallback(null);
182 }
183
Adam Powell17809772010-07-21 13:25:11 -0700184 public void setSelectedNavigationItem(int position) {
185 switch (mActionView.getNavigationMode()) {
186 case NAVIGATION_MODE_TABS:
187 selectTab(mTabs.get(position));
188 break;
189 case NAVIGATION_MODE_DROPDOWN_LIST:
190 mActionView.setDropdownSelectedPosition(position);
191 break;
192 default:
193 throw new IllegalStateException(
194 "setSelectedNavigationItem not valid for current navigation mode");
195 }
196 }
197
198 public int getSelectedNavigationItem() {
199 switch (mActionView.getNavigationMode()) {
200 case NAVIGATION_MODE_TABS:
201 return mSelectedTab.getPosition();
202 case NAVIGATION_MODE_DROPDOWN_LIST:
203 return mActionView.getDropdownSelectedPosition();
204 default:
205 return -1;
206 }
207 }
208
Adam Powell661c9082010-07-02 10:09:44 -0700209 private void cleanupTabs() {
210 if (mSelectedTab != null) {
211 selectTab(null);
212 }
213 if (!mTabs.isEmpty()) {
214 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
215 final FragmentTransaction trans = mActivity.openFragmentTransaction();
216 final int tabCount = mTabs.size();
217 for (int i = 0; i < tabCount; i++) {
218 trans.remove(mTabs.get(i).getFragment());
219 }
220 trans.commit();
221 }
222 mTabs.clear();
223 }
224 }
225
Adam Powell0e94b512010-06-29 17:58:20 -0700226 public void setTitle(CharSequence title) {
227 mActionView.setTitle(title);
228 }
229
230 public void setSubtitle(CharSequence subtitle) {
231 mActionView.setSubtitle(subtitle);
232 }
233
Adam Powell89e06452010-06-23 20:24:52 -0700234 public void setDisplayOptions(int options) {
235 mActionView.setDisplayOptions(options);
236 }
Adam Powell0e94b512010-06-29 17:58:20 -0700237
Adam Powell89e06452010-06-23 20:24:52 -0700238 public void setDisplayOptions(int options, int mask) {
239 final int current = mActionView.getDisplayOptions();
240 mActionView.setDisplayOptions((options & mask) | (current & ~mask));
241 }
242
243 public void setBackgroundDrawable(Drawable d) {
244 mActionView.setBackgroundDrawable(d);
245 }
246
247 public View getCustomNavigationView() {
248 return mActionView.getCustomNavigationView();
249 }
250
251 public CharSequence getTitle() {
252 return mActionView.getTitle();
253 }
254
255 public CharSequence getSubtitle() {
256 return mActionView.getSubtitle();
257 }
258
259 public int getNavigationMode() {
260 return mActionView.getNavigationMode();
261 }
262
263 public int getDisplayOptions() {
264 return mActionView.getDisplayOptions();
265 }
266
Adam Powell5d279772010-07-27 16:34:07 -0700267 public ActionMode startActionMode(ActionMode.Callback callback) {
268 if (mActionMode != null) {
269 mActionMode.finish();
Adam Powell6e346362010-07-23 10:18:23 -0700270 }
Adam Powell3461b322010-07-14 11:34:43 -0700271
272 // Don't wait for the close context mode animation to finish.
273 if (mClosingContext) {
274 mAnimatorView.clearAnimation();
275 mHandler.removeCallbacks(mCloseContext);
276 mCloseContext.run();
277 }
278
Adam Powell5d279772010-07-27 16:34:07 -0700279 ActionMode mode = new ActionModeImpl(callback);
Adam Powell6e346362010-07-23 10:18:23 -0700280 if (callback.onCreateActionMode(mode, mode.getMenu())) {
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700281 mode.invalidate();
282 mUpperContextView.initForMode(mode);
Adam Powell89e06452010-06-23 20:24:52 -0700283 mAnimatorView.setDisplayedChild(CONTEXT_VIEW);
284 if (mLowerContextView != null) {
285 // TODO animate this
286 mLowerContextView.setVisibility(View.VISIBLE);
287 }
Adam Powell5d279772010-07-27 16:34:07 -0700288 mActionMode = mode;
Adam Powellac695c62010-07-20 18:19:27 -0700289 return mode;
Adam Powell89e06452010-06-23 20:24:52 -0700290 }
Adam Powellac695c62010-07-20 18:19:27 -0700291 return null;
Adam Powell89e06452010-06-23 20:24:52 -0700292 }
293
Adam Powell661c9082010-07-02 10:09:44 -0700294 private void configureTab(Tab tab, int position) {
295 final TabImpl tabi = (TabImpl) tab;
296 final boolean isFirstTab = mTabs.isEmpty();
297 final FragmentTransaction trans = mActivity.openFragmentTransaction();
298 final Fragment frag = tabi.getFragment();
299
300 tabi.setPosition(position);
301 mTabs.add(position, tabi);
302
303 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
304 if (!frag.isAdded()) {
305 trans.add(mTabContainerViewId, frag);
306 }
307 }
308
309 if (isFirstTab) {
310 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
311 trans.show(frag);
312 } else if (mTabSwitchMode == TAB_SWITCH_ADD_REMOVE) {
313 trans.add(mTabContainerViewId, frag);
314 }
315 mSelectedTab = tabi;
316 } else {
317 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
318 trans.hide(frag);
319 }
320 }
321 trans.commit();
322 }
323
324 @Override
325 public void addTab(Tab tab) {
326 mActionView.addTab(tab);
327 configureTab(tab, mTabs.size());
328 }
329
330 @Override
331 public void insertTab(Tab tab, int position) {
332 mActionView.insertTab(tab, position);
333 configureTab(tab, position);
334 }
335
336 @Override
337 public Tab newTab() {
338 return new TabImpl();
339 }
340
341 @Override
342 public void removeTab(Tab tab) {
343 removeTabAt(tab.getPosition());
344 }
345
346 @Override
347 public void removeTabAt(int position) {
348 mActionView.removeTabAt(position);
349 mTabs.remove(position);
350
351 final int newTabCount = mTabs.size();
352 for (int i = position; i < newTabCount; i++) {
353 mTabs.get(i).setPosition(i);
354 }
355
356 selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1)));
357 }
358
359 @Override
360 public void setTabNavigationMode() {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700361 if (mActivity == null) {
362 throw new IllegalStateException(
363 "Tab navigation mode cannot be used outside of an Activity");
364 }
Adam Powell661c9082010-07-02 10:09:44 -0700365 mActionView.setNavigationMode(NAVIGATION_MODE_TABS);
366 }
367
368 @Override
369 public void setTabNavigationMode(int containerViewId) {
370 mTabContainerViewId = containerViewId;
371 setTabNavigationMode();
372 }
373
374 @Override
375 public void selectTab(Tab tab) {
376 if (mSelectedTab == tab) {
377 return;
378 }
379
380 mActionView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION);
381 final FragmentTransaction trans = mActivity.openFragmentTransaction();
382 if (mSelectedTab != null) {
383 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
384 trans.hide(mSelectedTab.getFragment());
385 } else if (mTabSwitchMode == TAB_SWITCH_ADD_REMOVE) {
386 trans.remove(mSelectedTab.getFragment());
387 }
388 }
389 if (tab != null) {
390 if (mTabSwitchMode == TAB_SWITCH_SHOW_HIDE) {
391 trans.show(tab.getFragment());
392 } else if (mTabSwitchMode == TAB_SWITCH_ADD_REMOVE) {
393 trans.add(mTabContainerViewId, tab.getFragment());
394 }
395 }
396 mSelectedTab = (TabImpl) tab;
397 trans.commit();
398 }
399
Adam Powell6b336f82010-08-10 20:13:01 -0700400 @Override
401 public int getHeight() {
402 return mActionView.getHeight();
403 }
404
405 @Override
406 public void show() {
407 // TODO animate!
408 mAnimatorView.setVisibility(View.VISIBLE);
409 }
410
411 @Override
412 public void hide() {
413 // TODO animate!
414 mAnimatorView.setVisibility(View.GONE);
415 }
416
417 public boolean isShowing() {
418 return mAnimatorView.getVisibility() == View.VISIBLE;
419 }
420
Adam Powell89e06452010-06-23 20:24:52 -0700421 /**
422 * @hide
423 */
Adam Powell5d279772010-07-27 16:34:07 -0700424 public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
Adam Powell6e346362010-07-23 10:18:23 -0700425 private ActionMode.Callback mCallback;
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700426 private MenuBuilder mMenu;
Adam Powell29ed7572010-07-14 16:24:56 -0700427 private WeakReference<View> mCustomView;
Adam Powell89e06452010-06-23 20:24:52 -0700428
Adam Powell5d279772010-07-27 16:34:07 -0700429 public ActionModeImpl(ActionMode.Callback callback) {
Adam Powell89e06452010-06-23 20:24:52 -0700430 mCallback = callback;
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700431 mMenu = new MenuBuilder(mActionView.getContext());
432 mMenu.setCallback(this);
Adam Powell89e06452010-06-23 20:24:52 -0700433 }
Adam Powell9168f0b2010-08-02 15:46:24 -0700434
435 @Override
436 public MenuInflater getMenuInflater() {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700437 return new MenuInflater(mContext);
Adam Powell9168f0b2010-08-02 15:46:24 -0700438 }
439
Adam Powell89e06452010-06-23 20:24:52 -0700440 @Override
441 public Menu getMenu() {
442 return mMenu;
443 }
444
445 @Override
446 public void finish() {
Adam Powell5d279772010-07-27 16:34:07 -0700447 if (mActionMode != this) {
448 // Not the active action mode - no-op
Adam Powell93b6bc32010-07-22 11:36:35 -0700449 return;
450 }
451
Adam Powell6e346362010-07-23 10:18:23 -0700452 mCallback.onDestroyActionMode(this);
Adam Powell89e06452010-06-23 20:24:52 -0700453 mAnimatorView.setDisplayedChild(NORMAL_VIEW);
Adam Powell0e94b512010-06-29 17:58:20 -0700454
455 // Clear out the context mode views after the animation finishes
Adam Powell3461b322010-07-14 11:34:43 -0700456 mClosingContext = true;
Adam Powell0e94b512010-06-29 17:58:20 -0700457 mHandler.postDelayed(mCloseContext, mAnimatorView.getOutAnimation().getDuration());
458
Adam Powell89e06452010-06-23 20:24:52 -0700459 if (mLowerContextView != null && mLowerContextView.getVisibility() != View.GONE) {
460 // TODO Animate this
461 mLowerContextView.setVisibility(View.GONE);
462 }
Adam Powell5d279772010-07-27 16:34:07 -0700463 mActionMode = null;
Adam Powell89e06452010-06-23 20:24:52 -0700464 }
465
466 @Override
467 public void invalidate() {
Adam Powell6e346362010-07-23 10:18:23 -0700468 if (mCallback.onPrepareActionMode(this, mMenu)) {
Adam Powell89e06452010-06-23 20:24:52 -0700469 // Refresh content in both context views
470 }
471 }
472
473 @Override
474 public void setCustomView(View view) {
475 mUpperContextView.setCustomView(view);
Adam Powell29ed7572010-07-14 16:24:56 -0700476 mCustomView = new WeakReference<View>(view);
Adam Powell89e06452010-06-23 20:24:52 -0700477 }
478
479 @Override
480 public void setSubtitle(CharSequence subtitle) {
481 mUpperContextView.setSubtitle(subtitle);
482 }
483
484 @Override
485 public void setTitle(CharSequence title) {
486 mUpperContextView.setTitle(title);
487 }
Adam Powell29ed7572010-07-14 16:24:56 -0700488
489 @Override
Adam Powellc9ae2a22010-07-28 14:44:21 -0700490 public void setTitle(int resId) {
491 setTitle(mActivity.getString(resId));
492 }
493
494 @Override
495 public void setSubtitle(int resId) {
496 setSubtitle(mActivity.getString(resId));
497 }
498
499 @Override
Adam Powell29ed7572010-07-14 16:24:56 -0700500 public CharSequence getTitle() {
501 return mUpperContextView.getTitle();
502 }
503
504 @Override
505 public CharSequence getSubtitle() {
506 return mUpperContextView.getSubtitle();
507 }
Adam Powell89e06452010-06-23 20:24:52 -0700508
Adam Powell29ed7572010-07-14 16:24:56 -0700509 @Override
510 public View getCustomView() {
511 return mCustomView != null ? mCustomView.get() : null;
512 }
513
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700514 public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
Adam Powell6e346362010-07-23 10:18:23 -0700515 return mCallback.onActionItemClicked(this, item);
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700516 }
517
518 public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
519 }
520
521 public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
522 if (!subMenu.hasVisibleItems()) {
523 return true;
Adam Powell89e06452010-06-23 20:24:52 -0700524 }
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700525
Adam Powelldec9dfd2010-08-09 15:27:54 -0700526 new MenuPopupHelper(mContext, subMenu).show();
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700527 return true;
528 }
529
530 public void onCloseSubMenu(SubMenuBuilder menu) {
531 }
532
533 public void onMenuModeChange(MenuBuilder menu) {
Adam Powellf6148c52010-08-11 21:10:16 -0700534 invalidate();
535 mUpperContextView.showOverflowMenu();
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700536 }
Adam Powell661c9082010-07-02 10:09:44 -0700537 }
538
539 /**
540 * @hide
541 */
542 public class TabImpl extends ActionBar.Tab {
543 private Fragment mFragment;
544 private Drawable mIcon;
545 private CharSequence mText;
546 private int mPosition;
547
548 @Override
549 public Fragment getFragment() {
550 return mFragment;
551 }
552
553 @Override
554 public Drawable getIcon() {
555 return mIcon;
556 }
557
558 @Override
559 public int getPosition() {
560 return mPosition;
561 }
562
563 public void setPosition(int position) {
564 mPosition = position;
565 }
566
567 @Override
568 public CharSequence getText() {
569 return mText;
570 }
571
572 @Override
573 public void setFragment(Fragment fragment) {
574 mFragment = fragment;
575 }
576
577 @Override
578 public void setIcon(Drawable icon) {
579 mIcon = icon;
580 }
581
582 @Override
583 public void setText(CharSequence text) {
584 mText = text;
585 }
586
587 @Override
588 public void select() {
589 selectTab(this);
Adam Powell89e06452010-06-23 20:24:52 -0700590 }
591 }
592}