blob: 3015363e72a8c80e667b31ea0b7db484af3aed35 [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);
Steve Block08f194b2010-08-24 18:20:48 +0100113
Adam Powell89e06452010-06-23 20:24:52 -0700114 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
Steve Block08f194b2010-08-24 18:20:48 +0100119 mActionView.setContextView(mUpperContextView);
Adam Powell89e06452010-06-23 20:24:52 -0700120 mContextDisplayMode = mLowerContextView == null ?
121 CONTEXT_DISPLAY_NORMAL : CONTEXT_DISPLAY_SPLIT;
122 }
123
Adam Powella66c7b02010-07-28 15:28:25 -0700124 @Override
Adam Powella66c7b02010-07-28 15:28:25 -0700125 public void setTitle(int resId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700126 setTitle(mContext.getString(resId));
Adam Powella66c7b02010-07-28 15:28:25 -0700127 }
128
129 @Override
130 public void setSubtitle(int resId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700131 setSubtitle(mContext.getString(resId));
Adam Powella66c7b02010-07-28 15:28:25 -0700132 }
133
Adam Powell89e06452010-06-23 20:24:52 -0700134 public void setCustomNavigationMode(View view) {
Adam Powell661c9082010-07-02 10:09:44 -0700135 cleanupTabs();
Adam Powell89e06452010-06-23 20:24:52 -0700136 mActionView.setCustomNavigationView(view);
137 mActionView.setCallback(null);
138 }
Adam Powell0e94b512010-06-29 17:58:20 -0700139
Adam Powell89e06452010-06-23 20:24:52 -0700140 public void setDropdownNavigationMode(SpinnerAdapter adapter, NavigationCallback callback) {
Adam Powell17809772010-07-21 13:25:11 -0700141 setDropdownNavigationMode(adapter, callback, -1);
142 }
143
144 public void setDropdownNavigationMode(SpinnerAdapter adapter, NavigationCallback callback,
145 int defaultSelectedPosition) {
Adam Powell661c9082010-07-02 10:09:44 -0700146 cleanupTabs();
Adam Powell89e06452010-06-23 20:24:52 -0700147 mActionView.setNavigationMode(NAVIGATION_MODE_DROPDOWN_LIST);
148 mActionView.setDropdownAdapter(adapter);
Adam Powell17809772010-07-21 13:25:11 -0700149 if (defaultSelectedPosition >= 0) {
150 mActionView.setDropdownSelectedPosition(defaultSelectedPosition);
151 }
152 mActionView.setCallback(callback);
Adam Powell89e06452010-06-23 20:24:52 -0700153 }
Adam Powell0e94b512010-06-29 17:58:20 -0700154
155 public void setStandardNavigationMode() {
Adam Powell661c9082010-07-02 10:09:44 -0700156 cleanupTabs();
Adam Powell0e94b512010-06-29 17:58:20 -0700157 mActionView.setNavigationMode(NAVIGATION_MODE_STANDARD);
158 mActionView.setCallback(null);
159 }
160
Adam Powell17809772010-07-21 13:25:11 -0700161 public void setSelectedNavigationItem(int position) {
162 switch (mActionView.getNavigationMode()) {
163 case NAVIGATION_MODE_TABS:
164 selectTab(mTabs.get(position));
165 break;
166 case NAVIGATION_MODE_DROPDOWN_LIST:
167 mActionView.setDropdownSelectedPosition(position);
168 break;
169 default:
170 throw new IllegalStateException(
171 "setSelectedNavigationItem not valid for current navigation mode");
172 }
173 }
174
175 public int getSelectedNavigationItem() {
176 switch (mActionView.getNavigationMode()) {
177 case NAVIGATION_MODE_TABS:
178 return mSelectedTab.getPosition();
179 case NAVIGATION_MODE_DROPDOWN_LIST:
180 return mActionView.getDropdownSelectedPosition();
181 default:
182 return -1;
183 }
184 }
185
Adam Powell661c9082010-07-02 10:09:44 -0700186 private void cleanupTabs() {
187 if (mSelectedTab != null) {
188 selectTab(null);
189 }
Adam Powell2b6230e2010-09-07 17:55:25 -0700190 mTabs.clear();
Adam Powell661c9082010-07-02 10:09:44 -0700191 }
192
Adam Powell0e94b512010-06-29 17:58:20 -0700193 public void setTitle(CharSequence title) {
194 mActionView.setTitle(title);
195 }
196
197 public void setSubtitle(CharSequence subtitle) {
198 mActionView.setSubtitle(subtitle);
199 }
200
Adam Powell89e06452010-06-23 20:24:52 -0700201 public void setDisplayOptions(int options) {
202 mActionView.setDisplayOptions(options);
203 }
Adam Powell0e94b512010-06-29 17:58:20 -0700204
Adam Powell89e06452010-06-23 20:24:52 -0700205 public void setDisplayOptions(int options, int mask) {
206 final int current = mActionView.getDisplayOptions();
207 mActionView.setDisplayOptions((options & mask) | (current & ~mask));
208 }
209
210 public void setBackgroundDrawable(Drawable d) {
211 mActionView.setBackgroundDrawable(d);
212 }
213
214 public View getCustomNavigationView() {
215 return mActionView.getCustomNavigationView();
216 }
217
218 public CharSequence getTitle() {
219 return mActionView.getTitle();
220 }
221
222 public CharSequence getSubtitle() {
223 return mActionView.getSubtitle();
224 }
225
226 public int getNavigationMode() {
227 return mActionView.getNavigationMode();
228 }
229
230 public int getDisplayOptions() {
231 return mActionView.getDisplayOptions();
232 }
233
Adam Powell5d279772010-07-27 16:34:07 -0700234 public ActionMode startActionMode(ActionMode.Callback callback) {
235 if (mActionMode != null) {
236 mActionMode.finish();
Adam Powell6e346362010-07-23 10:18:23 -0700237 }
Adam Powell3461b322010-07-14 11:34:43 -0700238
239 // Don't wait for the close context mode animation to finish.
240 if (mClosingContext) {
241 mAnimatorView.clearAnimation();
242 mHandler.removeCallbacks(mCloseContext);
243 mCloseContext.run();
244 }
245
Adam Powell5d279772010-07-27 16:34:07 -0700246 ActionMode mode = new ActionModeImpl(callback);
Adam Powell6e346362010-07-23 10:18:23 -0700247 if (callback.onCreateActionMode(mode, mode.getMenu())) {
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700248 mode.invalidate();
249 mUpperContextView.initForMode(mode);
Adam Powell89e06452010-06-23 20:24:52 -0700250 mAnimatorView.setDisplayedChild(CONTEXT_VIEW);
251 if (mLowerContextView != null) {
252 // TODO animate this
253 mLowerContextView.setVisibility(View.VISIBLE);
254 }
Adam Powell5d279772010-07-27 16:34:07 -0700255 mActionMode = mode;
Adam Powellac695c62010-07-20 18:19:27 -0700256 return mode;
Adam Powell89e06452010-06-23 20:24:52 -0700257 }
Adam Powellac695c62010-07-20 18:19:27 -0700258 return null;
Adam Powell89e06452010-06-23 20:24:52 -0700259 }
260
Adam Powell661c9082010-07-02 10:09:44 -0700261 private void configureTab(Tab tab, int position) {
262 final TabImpl tabi = (TabImpl) tab;
263 final boolean isFirstTab = mTabs.isEmpty();
Adam Powell2b6230e2010-09-07 17:55:25 -0700264 final ActionBar.TabListener callback = tabi.getCallback();
265
266 if (callback == null) {
267 throw new IllegalStateException("Action Bar Tab must have a Callback");
268 }
Adam Powell661c9082010-07-02 10:09:44 -0700269
270 tabi.setPosition(position);
271 mTabs.add(position, tabi);
272
Adam Powell661c9082010-07-02 10:09:44 -0700273 if (isFirstTab) {
Adam Powell2b6230e2010-09-07 17:55:25 -0700274 final FragmentTransaction trans = mActivity.getFragmentManager().openTransaction();
Adam Powell661c9082010-07-02 10:09:44 -0700275 mSelectedTab = tabi;
Adam Powell2b6230e2010-09-07 17:55:25 -0700276 callback.onTabSelected(tab, trans);
277 if (!trans.isEmpty()) {
278 trans.commit();
Adam Powell661c9082010-07-02 10:09:44 -0700279 }
280 }
Adam Powell661c9082010-07-02 10:09:44 -0700281 }
282
283 @Override
284 public void addTab(Tab tab) {
285 mActionView.addTab(tab);
286 configureTab(tab, mTabs.size());
287 }
288
289 @Override
Adam Powell2b6230e2010-09-07 17:55:25 -0700290 public void addTab(Tab tab, int position) {
291 mActionView.addTab(tab, position);
Adam Powell661c9082010-07-02 10:09:44 -0700292 configureTab(tab, position);
293 }
294
295 @Override
296 public Tab newTab() {
297 return new TabImpl();
298 }
299
300 @Override
301 public void removeTab(Tab tab) {
302 removeTabAt(tab.getPosition());
303 }
304
305 @Override
306 public void removeTabAt(int position) {
307 mActionView.removeTabAt(position);
308 mTabs.remove(position);
309
310 final int newTabCount = mTabs.size();
311 for (int i = position; i < newTabCount; i++) {
312 mTabs.get(i).setPosition(i);
313 }
314
315 selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1)));
316 }
317
318 @Override
319 public void setTabNavigationMode() {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700320 if (mActivity == null) {
321 throw new IllegalStateException(
322 "Tab navigation mode cannot be used outside of an Activity");
323 }
Adam Powell661c9082010-07-02 10:09:44 -0700324 mActionView.setNavigationMode(NAVIGATION_MODE_TABS);
325 }
326
327 @Override
Adam Powell661c9082010-07-02 10:09:44 -0700328 public void selectTab(Tab tab) {
Adam Powell2b6230e2010-09-07 17:55:25 -0700329 final FragmentTransaction trans = mActivity.getFragmentManager().openTransaction();
Adam Powell7f9b9052010-10-19 16:56:07 -0700330
331 if (mSelectedTab == tab) {
332 if (mSelectedTab != null) {
333 mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans);
334 }
335 } else {
336 mActionView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION);
337 if (mSelectedTab != null) {
338 mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans);
339 }
340 mSelectedTab = (TabImpl) tab;
341 if (mSelectedTab != null) {
342 mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans);
343 }
Adam Powell2b6230e2010-09-07 17:55:25 -0700344 }
345
346 if (!trans.isEmpty()) {
347 trans.commit();
348 }
349 }
350
351 @Override
352 public Tab getSelectedTab() {
353 return mSelectedTab;
Adam Powell661c9082010-07-02 10:09:44 -0700354 }
355
Adam Powell6b336f82010-08-10 20:13:01 -0700356 @Override
357 public int getHeight() {
358 return mActionView.getHeight();
359 }
360
361 @Override
362 public void show() {
363 // TODO animate!
364 mAnimatorView.setVisibility(View.VISIBLE);
365 }
366
367 @Override
368 public void hide() {
369 // TODO animate!
370 mAnimatorView.setVisibility(View.GONE);
371 }
372
373 public boolean isShowing() {
374 return mAnimatorView.getVisibility() == View.VISIBLE;
375 }
376
Adam Powell89e06452010-06-23 20:24:52 -0700377 /**
378 * @hide
379 */
Adam Powell5d279772010-07-27 16:34:07 -0700380 public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
Adam Powell6e346362010-07-23 10:18:23 -0700381 private ActionMode.Callback mCallback;
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700382 private MenuBuilder mMenu;
Adam Powell29ed7572010-07-14 16:24:56 -0700383 private WeakReference<View> mCustomView;
Adam Powell89e06452010-06-23 20:24:52 -0700384
Adam Powell5d279772010-07-27 16:34:07 -0700385 public ActionModeImpl(ActionMode.Callback callback) {
Adam Powell89e06452010-06-23 20:24:52 -0700386 mCallback = callback;
Adam Powell4d9861e2010-08-17 11:14:40 -0700387 mMenu = new MenuBuilder(mActionView.getContext())
388 .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700389 mMenu.setCallback(this);
Adam Powell89e06452010-06-23 20:24:52 -0700390 }
Adam Powell9168f0b2010-08-02 15:46:24 -0700391
392 @Override
393 public MenuInflater getMenuInflater() {
Adam Powell4d9861e2010-08-17 11:14:40 -0700394 return new MenuInflater(mContext);
Adam Powell9168f0b2010-08-02 15:46:24 -0700395 }
396
Adam Powell89e06452010-06-23 20:24:52 -0700397 @Override
398 public Menu getMenu() {
399 return mMenu;
400 }
401
402 @Override
403 public void finish() {
Adam Powell5d279772010-07-27 16:34:07 -0700404 if (mActionMode != this) {
405 // Not the active action mode - no-op
Adam Powell93b6bc32010-07-22 11:36:35 -0700406 return;
407 }
408
Adam Powell6e346362010-07-23 10:18:23 -0700409 mCallback.onDestroyActionMode(this);
Adam Powell89e06452010-06-23 20:24:52 -0700410 mAnimatorView.setDisplayedChild(NORMAL_VIEW);
Adam Powell0e94b512010-06-29 17:58:20 -0700411
412 // Clear out the context mode views after the animation finishes
Adam Powell3461b322010-07-14 11:34:43 -0700413 mClosingContext = true;
Adam Powell0e94b512010-06-29 17:58:20 -0700414 mHandler.postDelayed(mCloseContext, mAnimatorView.getOutAnimation().getDuration());
415
Adam Powell89e06452010-06-23 20:24:52 -0700416 if (mLowerContextView != null && mLowerContextView.getVisibility() != View.GONE) {
417 // TODO Animate this
418 mLowerContextView.setVisibility(View.GONE);
419 }
Adam Powell5d279772010-07-27 16:34:07 -0700420 mActionMode = null;
Adam Powell89e06452010-06-23 20:24:52 -0700421 }
422
423 @Override
424 public void invalidate() {
Adam Powell6e346362010-07-23 10:18:23 -0700425 if (mCallback.onPrepareActionMode(this, mMenu)) {
Adam Powell89e06452010-06-23 20:24:52 -0700426 // Refresh content in both context views
427 }
428 }
429
430 @Override
431 public void setCustomView(View view) {
432 mUpperContextView.setCustomView(view);
Adam Powell29ed7572010-07-14 16:24:56 -0700433 mCustomView = new WeakReference<View>(view);
Adam Powell89e06452010-06-23 20:24:52 -0700434 }
435
436 @Override
437 public void setSubtitle(CharSequence subtitle) {
438 mUpperContextView.setSubtitle(subtitle);
439 }
440
441 @Override
442 public void setTitle(CharSequence title) {
443 mUpperContextView.setTitle(title);
444 }
Adam Powell29ed7572010-07-14 16:24:56 -0700445
446 @Override
Adam Powellc9ae2a22010-07-28 14:44:21 -0700447 public void setTitle(int resId) {
448 setTitle(mActivity.getString(resId));
449 }
450
451 @Override
452 public void setSubtitle(int resId) {
453 setSubtitle(mActivity.getString(resId));
454 }
455
456 @Override
Adam Powell29ed7572010-07-14 16:24:56 -0700457 public CharSequence getTitle() {
458 return mUpperContextView.getTitle();
459 }
460
461 @Override
462 public CharSequence getSubtitle() {
463 return mUpperContextView.getSubtitle();
464 }
Adam Powell89e06452010-06-23 20:24:52 -0700465
Adam Powell29ed7572010-07-14 16:24:56 -0700466 @Override
467 public View getCustomView() {
468 return mCustomView != null ? mCustomView.get() : null;
469 }
470
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700471 public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
Adam Powell6e346362010-07-23 10:18:23 -0700472 return mCallback.onActionItemClicked(this, item);
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700473 }
474
475 public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
476 }
477
478 public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
479 if (!subMenu.hasVisibleItems()) {
480 return true;
Adam Powell89e06452010-06-23 20:24:52 -0700481 }
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700482
Adam Powelldec9dfd2010-08-09 15:27:54 -0700483 new MenuPopupHelper(mContext, subMenu).show();
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700484 return true;
485 }
486
487 public void onCloseSubMenu(SubMenuBuilder menu) {
488 }
489
490 public void onMenuModeChange(MenuBuilder menu) {
Adam Powellf6148c52010-08-11 21:10:16 -0700491 invalidate();
492 mUpperContextView.showOverflowMenu();
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700493 }
Adam Powell661c9082010-07-02 10:09:44 -0700494 }
495
496 /**
497 * @hide
498 */
499 public class TabImpl extends ActionBar.Tab {
Adam Powell2b6230e2010-09-07 17:55:25 -0700500 private ActionBar.TabListener mCallback;
501 private Object mTag;
Adam Powell661c9082010-07-02 10:09:44 -0700502 private Drawable mIcon;
503 private CharSequence mText;
504 private int mPosition;
Adam Powell2b6230e2010-09-07 17:55:25 -0700505 private View mCustomView;
Adam Powell661c9082010-07-02 10:09:44 -0700506
507 @Override
Adam Powell2b6230e2010-09-07 17:55:25 -0700508 public Object getTag() {
509 return mTag;
510 }
511
512 @Override
513 public void setTag(Object tag) {
514 mTag = tag;
515 }
516
517 public ActionBar.TabListener getCallback() {
518 return mCallback;
519 }
520
521 @Override
522 public void setTabListener(ActionBar.TabListener callback) {
523 mCallback = callback;
524 }
525
526 @Override
527 public View getCustomView() {
528 return mCustomView;
529 }
530
531 @Override
532 public void setCustomView(View view) {
533 mCustomView = view;
Adam Powell661c9082010-07-02 10:09:44 -0700534 }
535
536 @Override
537 public Drawable getIcon() {
538 return mIcon;
539 }
540
541 @Override
542 public int getPosition() {
543 return mPosition;
544 }
545
546 public void setPosition(int position) {
547 mPosition = position;
548 }
549
550 @Override
551 public CharSequence getText() {
552 return mText;
553 }
554
555 @Override
Adam Powell661c9082010-07-02 10:09:44 -0700556 public void setIcon(Drawable icon) {
557 mIcon = icon;
558 }
559
560 @Override
561 public void setText(CharSequence text) {
562 mText = text;
563 }
564
565 @Override
566 public void select() {
567 selectTab(this);
Adam Powell89e06452010-06-23 20:24:52 -0700568 }
569 }
570}