Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.internal.app; |
| 18 | |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 19 | import android.animation.ValueAnimator; |
| 20 | import android.view.ViewParent; |
Adam Powell | b8139af | 2012-04-19 13:52:46 -0700 | [diff] [blame] | 21 | import com.android.internal.view.ActionBarPolicy; |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 22 | import com.android.internal.view.menu.MenuBuilder; |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 23 | import com.android.internal.view.menu.MenuPopupHelper; |
| 24 | import com.android.internal.view.menu.SubMenuBuilder; |
Adam Powell | 01feaee | 2011-02-10 15:05:05 -0800 | [diff] [blame] | 25 | import com.android.internal.widget.ActionBarContainer; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 26 | import com.android.internal.widget.ActionBarContextView; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 27 | import com.android.internal.widget.ActionBarOverlayLayout; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 28 | import com.android.internal.widget.ActionBarView; |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 29 | import com.android.internal.widget.ScrollingTabContainerView; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 30 | |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 31 | import android.animation.Animator; |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 32 | import android.animation.Animator.AnimatorListener; |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 33 | import android.animation.AnimatorListenerAdapter; |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 34 | import android.animation.AnimatorSet; |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 35 | import android.animation.ObjectAnimator; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 36 | import android.app.ActionBar; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 37 | import android.app.Activity; |
Adam Powell | dec9dfd | 2010-08-09 15:27:54 -0700 | [diff] [blame] | 38 | import android.app.Dialog; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 39 | import android.app.FragmentTransaction; |
Adam Powell | dec9dfd | 2010-08-09 15:27:54 -0700 | [diff] [blame] | 40 | import android.content.Context; |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 41 | import android.content.res.Configuration; |
Adam Powell | 88ab697 | 2011-07-28 11:25:01 -0700 | [diff] [blame] | 42 | import android.content.res.Resources; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 43 | import android.graphics.drawable.Drawable; |
Adam Powell | 0e94b51 | 2010-06-29 17:58:20 -0700 | [diff] [blame] | 44 | import android.os.Handler; |
Adam Powell | 88ab697 | 2011-07-28 11:25:01 -0700 | [diff] [blame] | 45 | import android.util.TypedValue; |
Adam Powell | 6e34636 | 2010-07-23 10:18:23 -0700 | [diff] [blame] | 46 | import android.view.ActionMode; |
Adam Powell | 88ab697 | 2011-07-28 11:25:01 -0700 | [diff] [blame] | 47 | import android.view.ContextThemeWrapper; |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 48 | import android.view.LayoutInflater; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 49 | import android.view.Menu; |
Adam Powell | 9168f0b | 2010-08-02 15:46:24 -0700 | [diff] [blame] | 50 | import android.view.MenuInflater; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 51 | import android.view.MenuItem; |
| 52 | import android.view.View; |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 53 | import android.view.Window; |
Adam Powell | 86ed436 | 2011-09-14 16:18:53 -0700 | [diff] [blame] | 54 | import android.view.accessibility.AccessibilityEvent; |
Dianne Hackborn | 8eedb8b | 2012-04-16 19:31:58 -0700 | [diff] [blame] | 55 | import android.view.animation.AnimationUtils; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 56 | import android.widget.SpinnerAdapter; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 57 | |
Adam Powell | 29ed757 | 2010-07-14 16:24:56 -0700 | [diff] [blame] | 58 | import java.lang.ref.WeakReference; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 59 | import java.util.ArrayList; |
| 60 | |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 61 | /** |
| 62 | * ActionBarImpl is the ActionBar implementation used |
| 63 | * by devices of all screen sizes. If it detects a compatible decor, |
| 64 | * it will split contextual modes across both the ActionBarView at |
| 65 | * the top of the screen and a horizontal LinearLayout at the bottom |
| 66 | * which is normally hidden. |
| 67 | */ |
| 68 | public class ActionBarImpl extends ActionBar { |
Adam Powell | d814504 | 2011-03-24 14:18:27 -0700 | [diff] [blame] | 69 | private static final String TAG = "ActionBarImpl"; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 70 | |
Adam Powell | dec9dfd | 2010-08-09 15:27:54 -0700 | [diff] [blame] | 71 | private Context mContext; |
Adam Powell | 88ab697 | 2011-07-28 11:25:01 -0700 | [diff] [blame] | 72 | private Context mThemedContext; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 73 | private Activity mActivity; |
Adam Powell | dec9dfd | 2010-08-09 15:27:54 -0700 | [diff] [blame] | 74 | private Dialog mDialog; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 75 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 76 | private ActionBarOverlayLayout mOverlayLayout; |
Adam Powell | 01feaee | 2011-02-10 15:05:05 -0800 | [diff] [blame] | 77 | private ActionBarContainer mContainerView; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 78 | private ActionBarView mActionView; |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 79 | private ActionBarContextView mContextView; |
| 80 | private ActionBarContainer mSplitView; |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 81 | private View mContentView; |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 82 | private ScrollingTabContainerView mTabScrollView; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 83 | |
| 84 | private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>(); |
| 85 | |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 86 | private TabImpl mSelectedTab; |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 87 | private int mSavedTabPosition = INVALID_POSITION; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 88 | |
Adam Powell | dd8fab2 | 2012-03-22 17:47:27 -0700 | [diff] [blame] | 89 | private boolean mDisplayHomeAsUpSet; |
| 90 | |
Adam Powell | 060e3ca | 2011-07-19 20:39:16 -0700 | [diff] [blame] | 91 | ActionModeImpl mActionMode; |
| 92 | ActionMode mDeferredDestroyActionMode; |
| 93 | ActionMode.Callback mDeferredModeDestroyCallback; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 94 | |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 95 | private boolean mLastMenuVisibility; |
| 96 | private ArrayList<OnMenuVisibilityListener> mMenuVisibilityListeners = |
| 97 | new ArrayList<OnMenuVisibilityListener>(); |
| 98 | |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 99 | private static final int CONTEXT_DISPLAY_NORMAL = 0; |
| 100 | private static final int CONTEXT_DISPLAY_SPLIT = 1; |
| 101 | |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 102 | private static final int INVALID_POSITION = -1; |
| 103 | |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 104 | private int mContextDisplayMode; |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 105 | private boolean mHasEmbeddedTabs; |
Adam Powell | 0e94b51 | 2010-06-29 17:58:20 -0700 | [diff] [blame] | 106 | |
| 107 | final Handler mHandler = new Handler(); |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 108 | Runnable mTabSelector; |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 109 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 110 | private int mCurWindowVisibility = View.VISIBLE; |
| 111 | |
Dianne Hackborn | df7221c | 2013-02-26 14:53:55 -0800 | [diff] [blame] | 112 | private boolean mContentAnimations = true; |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 113 | private boolean mHiddenByApp; |
| 114 | private boolean mHiddenBySystem; |
| 115 | private boolean mShowingForMode; |
| 116 | |
| 117 | private boolean mNowShowing = true; |
| 118 | |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 119 | private Animator mCurrentShowAnim; |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 120 | private boolean mShowHideAnimationEnabled; |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 121 | |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 122 | final AnimatorListener mHideListener = new AnimatorListenerAdapter() { |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 123 | @Override |
| 124 | public void onAnimationEnd(Animator animation) { |
Dianne Hackborn | df7221c | 2013-02-26 14:53:55 -0800 | [diff] [blame] | 125 | if (mContentAnimations && mContentView != null) { |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 126 | mContentView.setTranslationY(0); |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 127 | mContainerView.setTranslationY(0); |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 128 | } |
Adam Powell | 993a63a | 2011-08-18 16:35:53 -0700 | [diff] [blame] | 129 | if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { |
| 130 | mSplitView.setVisibility(View.GONE); |
| 131 | } |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 132 | mContainerView.setVisibility(View.GONE); |
Adam Powell | 01feaee | 2011-02-10 15:05:05 -0800 | [diff] [blame] | 133 | mContainerView.setTransitioning(false); |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 134 | mCurrentShowAnim = null; |
Adam Powell | 060e3ca | 2011-07-19 20:39:16 -0700 | [diff] [blame] | 135 | completeDeferredDestroyActionMode(); |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 136 | if (mOverlayLayout != null) { |
| 137 | mOverlayLayout.requestFitSystemWindows(); |
| 138 | } |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 139 | } |
| 140 | }; |
| 141 | |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 142 | final AnimatorListener mShowListener = new AnimatorListenerAdapter() { |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 143 | @Override |
| 144 | public void onAnimationEnd(Animator animation) { |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 145 | mCurrentShowAnim = null; |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 146 | mContainerView.requestLayout(); |
| 147 | } |
| 148 | }; |
| 149 | |
| 150 | final ValueAnimator.AnimatorUpdateListener mUpdateListener = |
| 151 | new ValueAnimator.AnimatorUpdateListener() { |
| 152 | @Override |
| 153 | public void onAnimationUpdate(ValueAnimator animation) { |
| 154 | final ViewParent parent = mContainerView.getParent(); |
| 155 | ((View) parent).invalidate(); |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 156 | } |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 157 | }; |
| 158 | |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 159 | public ActionBarImpl(Activity activity) { |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 160 | mActivity = activity; |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 161 | Window window = activity.getWindow(); |
| 162 | View decor = window.getDecorView(); |
Dianne Hackborn | df7221c | 2013-02-26 14:53:55 -0800 | [diff] [blame] | 163 | boolean overlayMode = mActivity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY); |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 164 | init(decor); |
Dianne Hackborn | df7221c | 2013-02-26 14:53:55 -0800 | [diff] [blame] | 165 | if (!overlayMode) { |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 166 | mContentView = decor.findViewById(android.R.id.content); |
| 167 | } |
Adam Powell | dec9dfd | 2010-08-09 15:27:54 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | public ActionBarImpl(Dialog dialog) { |
| 171 | mDialog = dialog; |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 172 | init(dialog.getWindow().getDecorView()); |
Adam Powell | dec9dfd | 2010-08-09 15:27:54 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 175 | private void init(View decor) { |
Adam Powell | dec9dfd | 2010-08-09 15:27:54 -0700 | [diff] [blame] | 176 | mContext = decor.getContext(); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 177 | mOverlayLayout = (ActionBarOverlayLayout) decor.findViewById( |
| 178 | com.android.internal.R.id.action_bar_overlay_layout); |
| 179 | if (mOverlayLayout != null) { |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 180 | mOverlayLayout.setActionBar(this); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 181 | } |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 182 | mActionView = (ActionBarView) decor.findViewById(com.android.internal.R.id.action_bar); |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 183 | mContextView = (ActionBarContextView) decor.findViewById( |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 184 | com.android.internal.R.id.action_context_bar); |
Adam Powell | 01feaee | 2011-02-10 15:05:05 -0800 | [diff] [blame] | 185 | mContainerView = (ActionBarContainer) decor.findViewById( |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 186 | com.android.internal.R.id.action_bar_container); |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 187 | mSplitView = (ActionBarContainer) decor.findViewById( |
| 188 | com.android.internal.R.id.split_action_bar); |
Steve Block | 08f194b | 2010-08-24 18:20:48 +0100 | [diff] [blame] | 189 | |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 190 | if (mActionView == null || mContextView == null || mContainerView == null) { |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 191 | throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + |
| 192 | "with a compatible window decor layout"); |
| 193 | } |
Adam Powell | 0e94b51 | 2010-06-29 17:58:20 -0700 | [diff] [blame] | 194 | |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 195 | mActionView.setContextView(mContextView); |
Adam Powell | 9b4bee0 | 2011-04-27 19:24:47 -0700 | [diff] [blame] | 196 | mContextDisplayMode = mActionView.isSplitActionBar() ? |
| 197 | CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL; |
Adam Powell | dae7824 | 2011-04-25 15:23:41 -0700 | [diff] [blame] | 198 | |
Adam Powell | d40423a | 2012-05-02 14:06:03 -0700 | [diff] [blame] | 199 | // This was initially read from the action bar style |
| 200 | final int current = mActionView.getDisplayOptions(); |
| 201 | final boolean homeAsUp = (current & DISPLAY_HOME_AS_UP) != 0; |
| 202 | if (homeAsUp) { |
| 203 | mDisplayHomeAsUpSet = true; |
| 204 | } |
| 205 | |
Adam Powell | b8139af | 2012-04-19 13:52:46 -0700 | [diff] [blame] | 206 | ActionBarPolicy abp = ActionBarPolicy.get(mContext); |
Adam Powell | d40423a | 2012-05-02 14:06:03 -0700 | [diff] [blame] | 207 | setHomeButtonEnabled(abp.enableHomeButtonByDefault() || homeAsUp); |
Adam Powell | b8139af | 2012-04-19 13:52:46 -0700 | [diff] [blame] | 208 | setHasEmbeddedTabs(abp.hasEmbeddedTabs()); |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | public void onConfigurationChanged(Configuration newConfig) { |
Adam Powell | b8139af | 2012-04-19 13:52:46 -0700 | [diff] [blame] | 212 | setHasEmbeddedTabs(ActionBarPolicy.get(mContext).hasEmbeddedTabs()); |
Adam Powell | f5645cb | 2011-08-10 22:49:02 -0700 | [diff] [blame] | 213 | } |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 214 | |
Adam Powell | f5645cb | 2011-08-10 22:49:02 -0700 | [diff] [blame] | 215 | private void setHasEmbeddedTabs(boolean hasEmbeddedTabs) { |
| 216 | mHasEmbeddedTabs = hasEmbeddedTabs; |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 217 | // Switch tab layout configuration if needed |
| 218 | if (!mHasEmbeddedTabs) { |
| 219 | mActionView.setEmbeddedTabView(null); |
| 220 | mContainerView.setTabContainer(mTabScrollView); |
| 221 | } else { |
| 222 | mContainerView.setTabContainer(null); |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 223 | mActionView.setEmbeddedTabView(mTabScrollView); |
| 224 | } |
Adam Powell | f5645cb | 2011-08-10 22:49:02 -0700 | [diff] [blame] | 225 | final boolean isInTabMode = getNavigationMode() == NAVIGATION_MODE_TABS; |
| 226 | if (mTabScrollView != null) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 227 | if (isInTabMode) { |
| 228 | mTabScrollView.setVisibility(View.VISIBLE); |
| 229 | if (mOverlayLayout != null) { |
| 230 | mOverlayLayout.requestFitSystemWindows(); |
| 231 | } |
| 232 | } else { |
| 233 | mTabScrollView.setVisibility(View.GONE); |
| 234 | } |
Adam Powell | f5645cb | 2011-08-10 22:49:02 -0700 | [diff] [blame] | 235 | } |
| 236 | mActionView.setCollapsable(!mHasEmbeddedTabs && isInTabMode); |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 239 | public boolean hasNonEmbeddedTabs() { |
| 240 | return !mHasEmbeddedTabs && getNavigationMode() == NAVIGATION_MODE_TABS; |
| 241 | } |
| 242 | |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 243 | private void ensureTabsExist() { |
| 244 | if (mTabScrollView != null) { |
| 245 | return; |
| 246 | } |
| 247 | |
Adam Powell | f5645cb | 2011-08-10 22:49:02 -0700 | [diff] [blame] | 248 | ScrollingTabContainerView tabScroller = new ScrollingTabContainerView(mContext); |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 249 | |
| 250 | if (mHasEmbeddedTabs) { |
| 251 | tabScroller.setVisibility(View.VISIBLE); |
| 252 | mActionView.setEmbeddedTabView(tabScroller); |
| 253 | } else { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 254 | if (getNavigationMode() == NAVIGATION_MODE_TABS) { |
| 255 | tabScroller.setVisibility(View.VISIBLE); |
| 256 | if (mOverlayLayout != null) { |
| 257 | mOverlayLayout.requestFitSystemWindows(); |
| 258 | } |
| 259 | } else { |
| 260 | tabScroller.setVisibility(View.GONE); |
| 261 | } |
Adam Powell | dae7824 | 2011-04-25 15:23:41 -0700 | [diff] [blame] | 262 | mContainerView.setTabContainer(tabScroller); |
Adam Powell | dae7824 | 2011-04-25 15:23:41 -0700 | [diff] [blame] | 263 | } |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 264 | mTabScrollView = tabScroller; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Adam Powell | 060e3ca | 2011-07-19 20:39:16 -0700 | [diff] [blame] | 267 | void completeDeferredDestroyActionMode() { |
| 268 | if (mDeferredModeDestroyCallback != null) { |
| 269 | mDeferredModeDestroyCallback.onDestroyActionMode(mDeferredDestroyActionMode); |
| 270 | mDeferredDestroyActionMode = null; |
| 271 | mDeferredModeDestroyCallback = null; |
| 272 | } |
| 273 | } |
| 274 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 275 | public void setWindowVisibility(int visibility) { |
| 276 | mCurWindowVisibility = visibility; |
| 277 | } |
| 278 | |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 279 | /** |
| 280 | * Enables or disables animation between show/hide states. |
| 281 | * If animation is disabled using this method, animations in progress |
| 282 | * will be finished. |
| 283 | * |
| 284 | * @param enabled true to animate, false to not animate. |
| 285 | */ |
| 286 | public void setShowHideAnimationEnabled(boolean enabled) { |
| 287 | mShowHideAnimationEnabled = enabled; |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 288 | if (!enabled && mCurrentShowAnim != null) { |
| 289 | mCurrentShowAnim.end(); |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 290 | } |
| 291 | } |
| 292 | |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 293 | public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) { |
| 294 | mMenuVisibilityListeners.add(listener); |
| 295 | } |
| 296 | |
| 297 | public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) { |
| 298 | mMenuVisibilityListeners.remove(listener); |
| 299 | } |
| 300 | |
| 301 | public void dispatchMenuVisibilityChanged(boolean isVisible) { |
| 302 | if (isVisible == mLastMenuVisibility) { |
| 303 | return; |
| 304 | } |
| 305 | mLastMenuVisibility = isVisible; |
| 306 | |
| 307 | final int count = mMenuVisibilityListeners.size(); |
| 308 | for (int i = 0; i < count; i++) { |
| 309 | mMenuVisibilityListeners.get(i).onMenuVisibilityChanged(isVisible); |
| 310 | } |
| 311 | } |
| 312 | |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 313 | @Override |
Adam Powell | 3f476b3 | 2011-01-03 19:25:36 -0800 | [diff] [blame] | 314 | public void setCustomView(int resId) { |
Adam Powell | f242368 | 2011-08-11 14:29:45 -0700 | [diff] [blame] | 315 | setCustomView(LayoutInflater.from(getThemedContext()).inflate(resId, mActionView, false)); |
Adam Powell | 3f476b3 | 2011-01-03 19:25:36 -0800 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | @Override |
| 319 | public void setDisplayUseLogoEnabled(boolean useLogo) { |
| 320 | setDisplayOptions(useLogo ? DISPLAY_USE_LOGO : 0, DISPLAY_USE_LOGO); |
| 321 | } |
| 322 | |
| 323 | @Override |
| 324 | public void setDisplayShowHomeEnabled(boolean showHome) { |
| 325 | setDisplayOptions(showHome ? DISPLAY_SHOW_HOME : 0, DISPLAY_SHOW_HOME); |
| 326 | } |
| 327 | |
| 328 | @Override |
| 329 | public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) { |
| 330 | setDisplayOptions(showHomeAsUp ? DISPLAY_HOME_AS_UP : 0, DISPLAY_HOME_AS_UP); |
| 331 | } |
| 332 | |
| 333 | @Override |
| 334 | public void setDisplayShowTitleEnabled(boolean showTitle) { |
| 335 | setDisplayOptions(showTitle ? DISPLAY_SHOW_TITLE : 0, DISPLAY_SHOW_TITLE); |
| 336 | } |
| 337 | |
| 338 | @Override |
| 339 | public void setDisplayShowCustomEnabled(boolean showCustom) { |
| 340 | setDisplayOptions(showCustom ? DISPLAY_SHOW_CUSTOM : 0, DISPLAY_SHOW_CUSTOM); |
| 341 | } |
| 342 | |
| 343 | @Override |
Adam Powell | c29f4e5 | 2011-07-13 20:40:52 -0700 | [diff] [blame] | 344 | public void setHomeButtonEnabled(boolean enable) { |
| 345 | mActionView.setHomeButtonEnabled(enable); |
Adam Powell | dae7824 | 2011-04-25 15:23:41 -0700 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | @Override |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 349 | public void setTitle(int resId) { |
Adam Powell | dec9dfd | 2010-08-09 15:27:54 -0700 | [diff] [blame] | 350 | setTitle(mContext.getString(resId)); |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | @Override |
| 354 | public void setSubtitle(int resId) { |
Adam Powell | dec9dfd | 2010-08-09 15:27:54 -0700 | [diff] [blame] | 355 | setSubtitle(mContext.getString(resId)); |
Adam Powell | a66c7b0 | 2010-07-28 15:28:25 -0700 | [diff] [blame] | 356 | } |
| 357 | |
Adam Powell | 1780977 | 2010-07-21 13:25:11 -0700 | [diff] [blame] | 358 | public void setSelectedNavigationItem(int position) { |
| 359 | switch (mActionView.getNavigationMode()) { |
| 360 | case NAVIGATION_MODE_TABS: |
| 361 | selectTab(mTabs.get(position)); |
| 362 | break; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 363 | case NAVIGATION_MODE_LIST: |
Adam Powell | 1780977 | 2010-07-21 13:25:11 -0700 | [diff] [blame] | 364 | mActionView.setDropdownSelectedPosition(position); |
| 365 | break; |
| 366 | default: |
| 367 | throw new IllegalStateException( |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 368 | "setSelectedNavigationIndex not valid for current navigation mode"); |
Adam Powell | 1780977 | 2010-07-21 13:25:11 -0700 | [diff] [blame] | 369 | } |
| 370 | } |
| 371 | |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 372 | public void removeAllTabs() { |
| 373 | cleanupTabs(); |
Adam Powell | 1780977 | 2010-07-21 13:25:11 -0700 | [diff] [blame] | 374 | } |
| 375 | |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 376 | private void cleanupTabs() { |
| 377 | if (mSelectedTab != null) { |
| 378 | selectTab(null); |
| 379 | } |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 380 | mTabs.clear(); |
Adam Powell | d21aa12 | 2011-05-27 13:09:52 -0700 | [diff] [blame] | 381 | if (mTabScrollView != null) { |
| 382 | mTabScrollView.removeAllTabs(); |
| 383 | } |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 384 | mSavedTabPosition = INVALID_POSITION; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 385 | } |
| 386 | |
Adam Powell | 0e94b51 | 2010-06-29 17:58:20 -0700 | [diff] [blame] | 387 | public void setTitle(CharSequence title) { |
| 388 | mActionView.setTitle(title); |
| 389 | } |
| 390 | |
| 391 | public void setSubtitle(CharSequence subtitle) { |
| 392 | mActionView.setSubtitle(subtitle); |
| 393 | } |
| 394 | |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 395 | public void setDisplayOptions(int options) { |
Adam Powell | dd8fab2 | 2012-03-22 17:47:27 -0700 | [diff] [blame] | 396 | if ((options & DISPLAY_HOME_AS_UP) != 0) { |
| 397 | mDisplayHomeAsUpSet = true; |
| 398 | } |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 399 | mActionView.setDisplayOptions(options); |
| 400 | } |
Adam Powell | 0e94b51 | 2010-06-29 17:58:20 -0700 | [diff] [blame] | 401 | |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 402 | public void setDisplayOptions(int options, int mask) { |
| 403 | final int current = mActionView.getDisplayOptions(); |
Adam Powell | dd8fab2 | 2012-03-22 17:47:27 -0700 | [diff] [blame] | 404 | if ((mask & DISPLAY_HOME_AS_UP) != 0) { |
| 405 | mDisplayHomeAsUpSet = true; |
| 406 | } |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 407 | mActionView.setDisplayOptions((options & mask) | (current & ~mask)); |
| 408 | } |
| 409 | |
| 410 | public void setBackgroundDrawable(Drawable d) { |
Adam Powell | f88b915 | 2011-09-07 14:54:32 -0700 | [diff] [blame] | 411 | mContainerView.setPrimaryBackground(d); |
| 412 | } |
| 413 | |
| 414 | public void setStackedBackgroundDrawable(Drawable d) { |
| 415 | mContainerView.setStackedBackground(d); |
| 416 | } |
| 417 | |
| 418 | public void setSplitBackgroundDrawable(Drawable d) { |
| 419 | if (mSplitView != null) { |
| 420 | mSplitView.setSplitBackground(d); |
| 421 | } |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 422 | } |
| 423 | |
Adam Powell | ef70444 | 2010-11-16 14:48:22 -0800 | [diff] [blame] | 424 | public View getCustomView() { |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 425 | return mActionView.getCustomNavigationView(); |
| 426 | } |
| 427 | |
| 428 | public CharSequence getTitle() { |
| 429 | return mActionView.getTitle(); |
| 430 | } |
| 431 | |
| 432 | public CharSequence getSubtitle() { |
| 433 | return mActionView.getSubtitle(); |
| 434 | } |
| 435 | |
| 436 | public int getNavigationMode() { |
| 437 | return mActionView.getNavigationMode(); |
| 438 | } |
| 439 | |
| 440 | public int getDisplayOptions() { |
| 441 | return mActionView.getDisplayOptions(); |
| 442 | } |
| 443 | |
Adam Powell | 5d27977 | 2010-07-27 16:34:07 -0700 | [diff] [blame] | 444 | public ActionMode startActionMode(ActionMode.Callback callback) { |
| 445 | if (mActionMode != null) { |
| 446 | mActionMode.finish(); |
Adam Powell | 6e34636 | 2010-07-23 10:18:23 -0700 | [diff] [blame] | 447 | } |
Adam Powell | 3461b32 | 2010-07-14 11:34:43 -0700 | [diff] [blame] | 448 | |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 449 | mContextView.killMode(); |
Adam Powell | 5ee36c4 | 2011-06-02 12:59:43 -0700 | [diff] [blame] | 450 | ActionModeImpl mode = new ActionModeImpl(callback); |
| 451 | if (mode.dispatchOnCreate()) { |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 452 | mode.invalidate(); |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 453 | mContextView.initForMode(mode); |
| 454 | animateToMode(true); |
Adam Powell | 1ab418a | 2011-06-09 20:49:49 -0700 | [diff] [blame] | 455 | if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 456 | // TODO animate this |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 457 | if (mSplitView.getVisibility() != View.VISIBLE) { |
| 458 | mSplitView.setVisibility(View.VISIBLE); |
| 459 | if (mOverlayLayout != null) { |
| 460 | mOverlayLayout.requestFitSystemWindows(); |
| 461 | } |
| 462 | } |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 463 | } |
Adam Powell | 86ed436 | 2011-09-14 16:18:53 -0700 | [diff] [blame] | 464 | mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); |
Adam Powell | 5d27977 | 2010-07-27 16:34:07 -0700 | [diff] [blame] | 465 | mActionMode = mode; |
Adam Powell | ac695c6 | 2010-07-20 18:19:27 -0700 | [diff] [blame] | 466 | return mode; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 467 | } |
Adam Powell | ac695c6 | 2010-07-20 18:19:27 -0700 | [diff] [blame] | 468 | return null; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 469 | } |
| 470 | |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 471 | private void configureTab(Tab tab, int position) { |
| 472 | final TabImpl tabi = (TabImpl) tab; |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 473 | final ActionBar.TabListener callback = tabi.getCallback(); |
| 474 | |
| 475 | if (callback == null) { |
| 476 | throw new IllegalStateException("Action Bar Tab must have a Callback"); |
| 477 | } |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 478 | |
| 479 | tabi.setPosition(position); |
| 480 | mTabs.add(position, tabi); |
| 481 | |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 482 | final int count = mTabs.size(); |
| 483 | for (int i = position + 1; i < count; i++) { |
| 484 | mTabs.get(i).setPosition(i); |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 485 | } |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | @Override |
| 489 | public void addTab(Tab tab) { |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 490 | addTab(tab, mTabs.isEmpty()); |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | @Override |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 494 | public void addTab(Tab tab, int position) { |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 495 | addTab(tab, position, mTabs.isEmpty()); |
| 496 | } |
| 497 | |
| 498 | @Override |
| 499 | public void addTab(Tab tab, boolean setSelected) { |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 500 | ensureTabsExist(); |
| 501 | mTabScrollView.addTab(tab, setSelected); |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 502 | configureTab(tab, mTabs.size()); |
| 503 | if (setSelected) { |
| 504 | selectTab(tab); |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | @Override |
| 509 | public void addTab(Tab tab, int position, boolean setSelected) { |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 510 | ensureTabsExist(); |
| 511 | mTabScrollView.addTab(tab, position, setSelected); |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 512 | configureTab(tab, position); |
Adam Powell | 81b8944 | 2010-11-02 17:58:56 -0700 | [diff] [blame] | 513 | if (setSelected) { |
| 514 | selectTab(tab); |
| 515 | } |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | @Override |
| 519 | public Tab newTab() { |
| 520 | return new TabImpl(); |
| 521 | } |
| 522 | |
| 523 | @Override |
| 524 | public void removeTab(Tab tab) { |
| 525 | removeTabAt(tab.getPosition()); |
| 526 | } |
| 527 | |
| 528 | @Override |
| 529 | public void removeTabAt(int position) { |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 530 | if (mTabScrollView == null) { |
| 531 | // No tabs around to remove |
| 532 | return; |
| 533 | } |
| 534 | |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 535 | int selectedTabPosition = mSelectedTab != null |
| 536 | ? mSelectedTab.getPosition() : mSavedTabPosition; |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 537 | mTabScrollView.removeTabAt(position); |
Adam Powell | 0d8ec1d | 2011-05-03 14:49:13 -0700 | [diff] [blame] | 538 | TabImpl removedTab = mTabs.remove(position); |
| 539 | if (removedTab != null) { |
| 540 | removedTab.setPosition(-1); |
| 541 | } |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 542 | |
| 543 | final int newTabCount = mTabs.size(); |
| 544 | for (int i = position; i < newTabCount; i++) { |
| 545 | mTabs.get(i).setPosition(i); |
| 546 | } |
| 547 | |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 548 | if (selectedTabPosition == position) { |
| 549 | selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1))); |
| 550 | } |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | @Override |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 554 | public void selectTab(Tab tab) { |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 555 | if (getNavigationMode() != NAVIGATION_MODE_TABS) { |
| 556 | mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION; |
| 557 | return; |
| 558 | } |
| 559 | |
Dianne Hackborn | 48e7b45 | 2011-01-17 12:28:35 -0800 | [diff] [blame] | 560 | final FragmentTransaction trans = mActivity.getFragmentManager().beginTransaction() |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 561 | .disallowAddToBackStack(); |
Adam Powell | 7f9b905 | 2010-10-19 16:56:07 -0700 | [diff] [blame] | 562 | |
| 563 | if (mSelectedTab == tab) { |
| 564 | if (mSelectedTab != null) { |
| 565 | mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans); |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 566 | mTabScrollView.animateToTab(tab.getPosition()); |
Adam Powell | 7f9b905 | 2010-10-19 16:56:07 -0700 | [diff] [blame] | 567 | } |
| 568 | } else { |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 569 | mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION); |
Adam Powell | 7f9b905 | 2010-10-19 16:56:07 -0700 | [diff] [blame] | 570 | if (mSelectedTab != null) { |
| 571 | mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans); |
| 572 | } |
| 573 | mSelectedTab = (TabImpl) tab; |
| 574 | if (mSelectedTab != null) { |
| 575 | mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans); |
| 576 | } |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | if (!trans.isEmpty()) { |
| 580 | trans.commit(); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | @Override |
| 585 | public Tab getSelectedTab() { |
| 586 | return mSelectedTab; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 587 | } |
| 588 | |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 589 | @Override |
| 590 | public int getHeight() { |
Adam Powell | 58c5dc1 | 2011-07-14 21:08:10 -0700 | [diff] [blame] | 591 | return mContainerView.getHeight(); |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 592 | } |
| 593 | |
Dianne Hackborn | df7221c | 2013-02-26 14:53:55 -0800 | [diff] [blame] | 594 | public void enableContentAnimations(boolean enabled) { |
| 595 | mContentAnimations = enabled; |
| 596 | } |
| 597 | |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 598 | @Override |
| 599 | public void show() { |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 600 | if (mHiddenByApp) { |
| 601 | mHiddenByApp = false; |
| 602 | updateVisibility(false); |
| 603 | } |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 604 | } |
| 605 | |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 606 | private void showForActionMode() { |
| 607 | if (!mShowingForMode) { |
| 608 | mShowingForMode = true; |
| 609 | if (mOverlayLayout != null) { |
| 610 | mOverlayLayout.setShowingForActionMode(true); |
| 611 | } |
| 612 | updateVisibility(false); |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | public void showForSystem() { |
| 617 | if (mHiddenBySystem) { |
| 618 | mHiddenBySystem = false; |
| 619 | updateVisibility(true); |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | @Override |
| 624 | public void hide() { |
| 625 | if (!mHiddenByApp) { |
| 626 | mHiddenByApp = true; |
| 627 | updateVisibility(false); |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | private void hideForActionMode() { |
| 632 | if (mShowingForMode) { |
| 633 | mShowingForMode = false; |
| 634 | if (mOverlayLayout != null) { |
| 635 | mOverlayLayout.setShowingForActionMode(false); |
| 636 | } |
| 637 | updateVisibility(false); |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | public void hideForSystem() { |
| 642 | if (!mHiddenBySystem) { |
| 643 | mHiddenBySystem = true; |
| 644 | updateVisibility(true); |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | private static boolean checkShowingFlags(boolean hiddenByApp, boolean hiddenBySystem, |
| 649 | boolean showingForMode) { |
| 650 | if (showingForMode) { |
| 651 | return true; |
| 652 | } else if (hiddenByApp || hiddenBySystem) { |
| 653 | return false; |
| 654 | } else { |
| 655 | return true; |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | private void updateVisibility(boolean fromSystem) { |
| 660 | // Based on the current state, should we be hidden or shown? |
| 661 | final boolean shown = checkShowingFlags(mHiddenByApp, mHiddenBySystem, |
| 662 | mShowingForMode); |
| 663 | |
| 664 | if (shown) { |
| 665 | if (!mNowShowing) { |
| 666 | mNowShowing = true; |
| 667 | doShow(fromSystem); |
| 668 | } |
| 669 | } else { |
| 670 | if (mNowShowing) { |
| 671 | mNowShowing = false; |
| 672 | doHide(fromSystem); |
| 673 | } |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | public void doShow(boolean fromSystem) { |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 678 | if (mCurrentShowAnim != null) { |
| 679 | mCurrentShowAnim.end(); |
Adam Powell | 45f1e08 | 2010-12-10 14:20:13 -0800 | [diff] [blame] | 680 | } |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 681 | mContainerView.setVisibility(View.VISIBLE); |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 682 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 683 | if (mCurWindowVisibility == View.VISIBLE && (mShowHideAnimationEnabled |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 684 | || fromSystem)) { |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 685 | mContainerView.setTranslationY(0); // because we're about to ask its window loc |
| 686 | float startingY = -mContainerView.getHeight(); |
Chet Haase | e8118e1 | 2012-05-30 14:19:02 -0700 | [diff] [blame] | 687 | if (fromSystem) { |
| 688 | int topLeft[] = {0, 0}; |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 689 | mContainerView.getLocationInWindow(topLeft); |
Chet Haase | e8118e1 | 2012-05-30 14:19:02 -0700 | [diff] [blame] | 690 | startingY -= topLeft[1]; |
| 691 | } |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 692 | mContainerView.setTranslationY(startingY); |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 693 | AnimatorSet anim = new AnimatorSet(); |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 694 | ObjectAnimator a = ObjectAnimator.ofFloat(mContainerView, View.TRANSLATION_Y, 0); |
| 695 | a.addUpdateListener(mUpdateListener); |
| 696 | AnimatorSet.Builder b = anim.play(a); |
Dianne Hackborn | df7221c | 2013-02-26 14:53:55 -0800 | [diff] [blame] | 697 | if (mContentAnimations && mContentView != null) { |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 698 | b.with(ObjectAnimator.ofFloat(mContentView, View.TRANSLATION_Y, |
Chet Haase | e8118e1 | 2012-05-30 14:19:02 -0700 | [diff] [blame] | 699 | startingY, 0)); |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 700 | } |
Adam Powell | 1ab418a | 2011-06-09 20:49:49 -0700 | [diff] [blame] | 701 | if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { |
Dianne Hackborn | 8eedb8b | 2012-04-16 19:31:58 -0700 | [diff] [blame] | 702 | mSplitView.setTranslationY(mSplitView.getHeight()); |
Adam Powell | 993a63a | 2011-08-18 16:35:53 -0700 | [diff] [blame] | 703 | mSplitView.setVisibility(View.VISIBLE); |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 704 | b.with(ObjectAnimator.ofFloat(mSplitView, View.TRANSLATION_Y, 0)); |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 705 | } |
Dianne Hackborn | 8eedb8b | 2012-04-16 19:31:58 -0700 | [diff] [blame] | 706 | anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, |
Chet Haase | e8118e1 | 2012-05-30 14:19:02 -0700 | [diff] [blame] | 707 | com.android.internal.R.interpolator.decelerate_cubic)); |
| 708 | anim.setDuration(250); |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 709 | // If this is being shown from the system, add a small delay. |
| 710 | // This is because we will also be animating in the status bar, |
| 711 | // and these two elements can't be done in lock-step. So we give |
| 712 | // a little time for the status bar to start its animation before |
| 713 | // the action bar animates. (This corresponds to the corresponding |
| 714 | // case when hiding, where the status bar has a small delay before |
| 715 | // starting.) |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 716 | anim.addListener(mShowListener); |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 717 | mCurrentShowAnim = anim; |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 718 | anim.start(); |
| 719 | } else { |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 720 | mContainerView.setAlpha(1); |
| 721 | mContainerView.setTranslationY(0); |
Dianne Hackborn | df7221c | 2013-02-26 14:53:55 -0800 | [diff] [blame] | 722 | if (mContentAnimations && mContentView != null) { |
Dianne Hackborn | 80d5506 | 2012-05-22 18:03:20 -0700 | [diff] [blame] | 723 | mContentView.setTranslationY(0); |
| 724 | } |
| 725 | if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) { |
| 726 | mSplitView.setAlpha(1); |
| 727 | mSplitView.setTranslationY(0); |
| 728 | mSplitView.setVisibility(View.VISIBLE); |
| 729 | } |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 730 | mShowListener.onAnimationEnd(null); |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 731 | } |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 732 | if (mOverlayLayout != null) { |
| 733 | mOverlayLayout.requestFitSystemWindows(); |
| 734 | } |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 735 | } |
| 736 | |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 737 | public void doHide(boolean fromSystem) { |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 738 | if (mCurrentShowAnim != null) { |
| 739 | mCurrentShowAnim.end(); |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 740 | } |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 741 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 742 | if (mCurWindowVisibility == View.VISIBLE && (mShowHideAnimationEnabled |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 743 | || fromSystem)) { |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 744 | mContainerView.setAlpha(1); |
Adam Powell | 01feaee | 2011-02-10 15:05:05 -0800 | [diff] [blame] | 745 | mContainerView.setTransitioning(true); |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 746 | AnimatorSet anim = new AnimatorSet(); |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 747 | float endingY = -mContainerView.getHeight(); |
Chet Haase | e8118e1 | 2012-05-30 14:19:02 -0700 | [diff] [blame] | 748 | if (fromSystem) { |
| 749 | int topLeft[] = {0, 0}; |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 750 | mContainerView.getLocationInWindow(topLeft); |
Chet Haase | e8118e1 | 2012-05-30 14:19:02 -0700 | [diff] [blame] | 751 | endingY -= topLeft[1]; |
| 752 | } |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 753 | ObjectAnimator a = ObjectAnimator.ofFloat(mContainerView, View.TRANSLATION_Y, endingY); |
| 754 | a.addUpdateListener(mUpdateListener); |
| 755 | AnimatorSet.Builder b = anim.play(a); |
Dianne Hackborn | df7221c | 2013-02-26 14:53:55 -0800 | [diff] [blame] | 756 | if (mContentAnimations && mContentView != null) { |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 757 | b.with(ObjectAnimator.ofFloat(mContentView, View.TRANSLATION_Y, |
Chet Haase | e8118e1 | 2012-05-30 14:19:02 -0700 | [diff] [blame] | 758 | 0, endingY)); |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 759 | } |
Adam Powell | 1ab418a | 2011-06-09 20:49:49 -0700 | [diff] [blame] | 760 | if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) { |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 761 | mSplitView.setAlpha(1); |
Adam Powell | 9b0dc28 | 2013-07-31 13:58:43 -0700 | [diff] [blame] | 762 | b.with(ObjectAnimator.ofFloat(mSplitView, View.TRANSLATION_Y, |
Dianne Hackborn | 8eedb8b | 2012-04-16 19:31:58 -0700 | [diff] [blame] | 763 | mSplitView.getHeight())); |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 764 | } |
Dianne Hackborn | 8eedb8b | 2012-04-16 19:31:58 -0700 | [diff] [blame] | 765 | anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, |
Chet Haase | e8118e1 | 2012-05-30 14:19:02 -0700 | [diff] [blame] | 766 | com.android.internal.R.interpolator.accelerate_cubic)); |
| 767 | anim.setDuration(250); |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 768 | anim.addListener(mHideListener); |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 769 | mCurrentShowAnim = anim; |
Adam Powell | 50efbed | 2011-02-08 16:20:15 -0800 | [diff] [blame] | 770 | anim.start(); |
| 771 | } else { |
| 772 | mHideListener.onAnimationEnd(null); |
Adam Powell | e6ec732 | 2010-12-07 15:29:26 -0800 | [diff] [blame] | 773 | } |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 774 | } |
| 775 | |
| 776 | public boolean isShowing() { |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 777 | return mNowShowing; |
| 778 | } |
| 779 | |
| 780 | public boolean isSystemShowing() { |
| 781 | return !mHiddenBySystem; |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 782 | } |
| 783 | |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 784 | void animateToMode(boolean toActionMode) { |
Adam Powell | 060e3ca | 2011-07-19 20:39:16 -0700 | [diff] [blame] | 785 | if (toActionMode) { |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 786 | showForActionMode(); |
| 787 | } else { |
| 788 | hideForActionMode(); |
Adam Powell | 07e1f98 | 2011-03-24 11:11:15 -0700 | [diff] [blame] | 789 | } |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 790 | |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 791 | mActionView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE); |
| 792 | mContextView.animateToVisibility(toActionMode ? View.VISIBLE : View.GONE); |
Adam Powell | f6ce6a9 | 2011-06-29 10:25:01 -0700 | [diff] [blame] | 793 | if (mTabScrollView != null && !mActionView.hasEmbeddedTabs() && mActionView.isCollapsed()) { |
| 794 | mTabScrollView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE); |
| 795 | } |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 796 | } |
| 797 | |
Adam Powell | 88ab697 | 2011-07-28 11:25:01 -0700 | [diff] [blame] | 798 | public Context getThemedContext() { |
| 799 | if (mThemedContext == null) { |
| 800 | TypedValue outValue = new TypedValue(); |
| 801 | Resources.Theme currentTheme = mContext.getTheme(); |
| 802 | currentTheme.resolveAttribute(com.android.internal.R.attr.actionBarWidgetTheme, |
| 803 | outValue, true); |
| 804 | final int targetThemeRes = outValue.resourceId; |
| 805 | |
| 806 | if (targetThemeRes != 0 && mContext.getThemeResId() != targetThemeRes) { |
| 807 | mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes); |
| 808 | } else { |
| 809 | mThemedContext = mContext; |
| 810 | } |
| 811 | } |
| 812 | return mThemedContext; |
| 813 | } |
| 814 | |
Adam Powell | 27cba38 | 2013-01-22 18:55:20 -0800 | [diff] [blame] | 815 | @Override |
| 816 | public boolean isTitleTruncated() { |
| 817 | return mActionView != null && mActionView.isTitleTruncated(); |
| 818 | } |
| 819 | |
Adam Powell | e0e2f4f | 2013-04-05 16:27:35 -0700 | [diff] [blame] | 820 | @Override |
| 821 | public void setHomeAsUpIndicator(Drawable indicator) { |
| 822 | mActionView.setHomeAsUpIndicator(indicator); |
| 823 | } |
| 824 | |
| 825 | @Override |
| 826 | public void setHomeAsUpIndicator(int resId) { |
| 827 | mActionView.setHomeAsUpIndicator(resId); |
| 828 | } |
| 829 | |
| 830 | @Override |
| 831 | public void setHomeActionContentDescription(CharSequence description) { |
| 832 | mActionView.setHomeActionContentDescription(description); |
| 833 | } |
| 834 | |
| 835 | @Override |
| 836 | public void setHomeActionContentDescription(int resId) { |
| 837 | mActionView.setHomeActionContentDescription(resId); |
| 838 | } |
| 839 | |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 840 | /** |
| 841 | * @hide |
| 842 | */ |
Adam Powell | 5d27977 | 2010-07-27 16:34:07 -0700 | [diff] [blame] | 843 | public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback { |
Adam Powell | 6e34636 | 2010-07-23 10:18:23 -0700 | [diff] [blame] | 844 | private ActionMode.Callback mCallback; |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 845 | private MenuBuilder mMenu; |
Adam Powell | 29ed757 | 2010-07-14 16:24:56 -0700 | [diff] [blame] | 846 | private WeakReference<View> mCustomView; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 847 | |
Adam Powell | 5d27977 | 2010-07-27 16:34:07 -0700 | [diff] [blame] | 848 | public ActionModeImpl(ActionMode.Callback callback) { |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 849 | mCallback = callback; |
Adam Powell | f242368 | 2011-08-11 14:29:45 -0700 | [diff] [blame] | 850 | mMenu = new MenuBuilder(getThemedContext()) |
Adam Powell | 4d9861e | 2010-08-17 11:14:40 -0700 | [diff] [blame] | 851 | .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 852 | mMenu.setCallback(this); |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 853 | } |
Adam Powell | 9168f0b | 2010-08-02 15:46:24 -0700 | [diff] [blame] | 854 | |
| 855 | @Override |
| 856 | public MenuInflater getMenuInflater() { |
Adam Powell | f242368 | 2011-08-11 14:29:45 -0700 | [diff] [blame] | 857 | return new MenuInflater(getThemedContext()); |
Adam Powell | 9168f0b | 2010-08-02 15:46:24 -0700 | [diff] [blame] | 858 | } |
| 859 | |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 860 | @Override |
| 861 | public Menu getMenu() { |
| 862 | return mMenu; |
| 863 | } |
| 864 | |
| 865 | @Override |
| 866 | public void finish() { |
Adam Powell | 5d27977 | 2010-07-27 16:34:07 -0700 | [diff] [blame] | 867 | if (mActionMode != this) { |
| 868 | // Not the active action mode - no-op |
Adam Powell | 93b6bc3 | 2010-07-22 11:36:35 -0700 | [diff] [blame] | 869 | return; |
| 870 | } |
| 871 | |
Dianne Hackborn | 139e5aa | 2012-05-05 20:36:38 -0700 | [diff] [blame] | 872 | // If this change in state is going to cause the action bar |
| 873 | // to be hidden, defer the onDestroy callback until the animation |
| 874 | // is finished and associated relayout is about to happen. This lets |
| 875 | // apps better anticipate visibility and layout behavior. |
| 876 | if (!checkShowingFlags(mHiddenByApp, mHiddenBySystem, false)) { |
| 877 | // With the current state but the action bar hidden, our |
| 878 | // overall showing state is going to be false. |
Adam Powell | 060e3ca | 2011-07-19 20:39:16 -0700 | [diff] [blame] | 879 | mDeferredDestroyActionMode = this; |
| 880 | mDeferredModeDestroyCallback = mCallback; |
| 881 | } else { |
| 882 | mCallback.onDestroyActionMode(this); |
| 883 | } |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 884 | mCallback = null; |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 885 | animateToMode(false); |
Adam Powell | 0e94b51 | 2010-06-29 17:58:20 -0700 | [diff] [blame] | 886 | |
| 887 | // Clear out the context mode views after the animation finishes |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 888 | mContextView.closeMode(); |
Adam Powell | 86ed436 | 2011-09-14 16:18:53 -0700 | [diff] [blame] | 889 | mActionView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); |
Adam Powell | f6ce6a9 | 2011-06-29 10:25:01 -0700 | [diff] [blame] | 890 | |
Adam Powell | 5d27977 | 2010-07-27 16:34:07 -0700 | [diff] [blame] | 891 | mActionMode = null; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 892 | } |
| 893 | |
| 894 | @Override |
| 895 | public void invalidate() { |
Adam Powell | 5ee36c4 | 2011-06-02 12:59:43 -0700 | [diff] [blame] | 896 | mMenu.stopDispatchingItemsChanged(); |
| 897 | try { |
| 898 | mCallback.onPrepareActionMode(this, mMenu); |
| 899 | } finally { |
| 900 | mMenu.startDispatchingItemsChanged(); |
| 901 | } |
| 902 | } |
| 903 | |
| 904 | public boolean dispatchOnCreate() { |
| 905 | mMenu.stopDispatchingItemsChanged(); |
| 906 | try { |
| 907 | return mCallback.onCreateActionMode(this, mMenu); |
| 908 | } finally { |
| 909 | mMenu.startDispatchingItemsChanged(); |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 910 | } |
| 911 | } |
| 912 | |
| 913 | @Override |
| 914 | public void setCustomView(View view) { |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 915 | mContextView.setCustomView(view); |
Adam Powell | 29ed757 | 2010-07-14 16:24:56 -0700 | [diff] [blame] | 916 | mCustomView = new WeakReference<View>(view); |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 917 | } |
| 918 | |
| 919 | @Override |
| 920 | public void setSubtitle(CharSequence subtitle) { |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 921 | mContextView.setSubtitle(subtitle); |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 922 | } |
| 923 | |
| 924 | @Override |
| 925 | public void setTitle(CharSequence title) { |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 926 | mContextView.setTitle(title); |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 927 | } |
Adam Powell | 29ed757 | 2010-07-14 16:24:56 -0700 | [diff] [blame] | 928 | |
| 929 | @Override |
Adam Powell | c9ae2a2 | 2010-07-28 14:44:21 -0700 | [diff] [blame] | 930 | public void setTitle(int resId) { |
Adam Powell | 48e8ac3 | 2011-01-14 12:10:24 -0800 | [diff] [blame] | 931 | setTitle(mContext.getResources().getString(resId)); |
Adam Powell | c9ae2a2 | 2010-07-28 14:44:21 -0700 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | @Override |
| 935 | public void setSubtitle(int resId) { |
Adam Powell | 48e8ac3 | 2011-01-14 12:10:24 -0800 | [diff] [blame] | 936 | setSubtitle(mContext.getResources().getString(resId)); |
Adam Powell | c9ae2a2 | 2010-07-28 14:44:21 -0700 | [diff] [blame] | 937 | } |
| 938 | |
| 939 | @Override |
Adam Powell | 29ed757 | 2010-07-14 16:24:56 -0700 | [diff] [blame] | 940 | public CharSequence getTitle() { |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 941 | return mContextView.getTitle(); |
Adam Powell | 29ed757 | 2010-07-14 16:24:56 -0700 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | @Override |
| 945 | public CharSequence getSubtitle() { |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 946 | return mContextView.getSubtitle(); |
Adam Powell | 29ed757 | 2010-07-14 16:24:56 -0700 | [diff] [blame] | 947 | } |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 948 | |
Adam Powell | 29ed757 | 2010-07-14 16:24:56 -0700 | [diff] [blame] | 949 | @Override |
Adam Powell | b98a81f | 2012-02-24 11:09:07 -0800 | [diff] [blame] | 950 | public void setTitleOptionalHint(boolean titleOptional) { |
Adam Powell | 785c447 | 2012-05-02 21:25:39 -0700 | [diff] [blame] | 951 | super.setTitleOptionalHint(titleOptional); |
Adam Powell | b98a81f | 2012-02-24 11:09:07 -0800 | [diff] [blame] | 952 | mContextView.setTitleOptional(titleOptional); |
| 953 | } |
| 954 | |
| 955 | @Override |
| 956 | public boolean isTitleOptional() { |
| 957 | return mContextView.isTitleOptional(); |
| 958 | } |
| 959 | |
| 960 | @Override |
Adam Powell | 29ed757 | 2010-07-14 16:24:56 -0700 | [diff] [blame] | 961 | public View getCustomView() { |
| 962 | return mCustomView != null ? mCustomView.get() : null; |
| 963 | } |
| 964 | |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 965 | public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 966 | if (mCallback != null) { |
| 967 | return mCallback.onActionItemClicked(this, item); |
| 968 | } else { |
| 969 | return false; |
| 970 | } |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 971 | } |
| 972 | |
| 973 | public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) { |
| 974 | } |
| 975 | |
| 976 | public boolean onSubMenuSelected(SubMenuBuilder subMenu) { |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 977 | if (mCallback == null) { |
| 978 | return false; |
| 979 | } |
| 980 | |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 981 | if (!subMenu.hasVisibleItems()) { |
| 982 | return true; |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 983 | } |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 984 | |
Adam Powell | f242368 | 2011-08-11 14:29:45 -0700 | [diff] [blame] | 985 | new MenuPopupHelper(getThemedContext(), subMenu).show(); |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 986 | return true; |
| 987 | } |
| 988 | |
| 989 | public void onCloseSubMenu(SubMenuBuilder menu) { |
| 990 | } |
| 991 | |
| 992 | public void onMenuModeChange(MenuBuilder menu) { |
Adam Powell | d8b3f2e | 2010-12-02 13:37:03 -0800 | [diff] [blame] | 993 | if (mCallback == null) { |
| 994 | return; |
| 995 | } |
Adam Powell | f6148c5 | 2010-08-11 21:10:16 -0700 | [diff] [blame] | 996 | invalidate(); |
Adam Powell | 640a66e | 2011-04-29 10:18:53 -0700 | [diff] [blame] | 997 | mContextView.showOverflowMenu(); |
Adam Powell | 2c9c9fe | 2010-07-16 10:17:57 -0700 | [diff] [blame] | 998 | } |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 999 | } |
| 1000 | |
| 1001 | /** |
| 1002 | * @hide |
| 1003 | */ |
| 1004 | public class TabImpl extends ActionBar.Tab { |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1005 | private ActionBar.TabListener mCallback; |
| 1006 | private Object mTag; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1007 | private Drawable mIcon; |
| 1008 | private CharSequence mText; |
Adam Powell | 94e56ef | 2011-09-06 21:22:22 -0700 | [diff] [blame] | 1009 | private CharSequence mContentDesc; |
Adam Powell | 0d8ec1d | 2011-05-03 14:49:13 -0700 | [diff] [blame] | 1010 | private int mPosition = -1; |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1011 | private View mCustomView; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1012 | |
| 1013 | @Override |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1014 | public Object getTag() { |
| 1015 | return mTag; |
| 1016 | } |
| 1017 | |
| 1018 | @Override |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1019 | public Tab setTag(Object tag) { |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1020 | mTag = tag; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1021 | return this; |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1022 | } |
| 1023 | |
| 1024 | public ActionBar.TabListener getCallback() { |
| 1025 | return mCallback; |
| 1026 | } |
| 1027 | |
| 1028 | @Override |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1029 | public Tab setTabListener(ActionBar.TabListener callback) { |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1030 | mCallback = callback; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1031 | return this; |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | @Override |
| 1035 | public View getCustomView() { |
| 1036 | return mCustomView; |
| 1037 | } |
| 1038 | |
| 1039 | @Override |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1040 | public Tab setCustomView(View view) { |
Adam Powell | 2b6230e | 2010-09-07 17:55:25 -0700 | [diff] [blame] | 1041 | mCustomView = view; |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 1042 | if (mPosition >= 0) { |
| 1043 | mTabScrollView.updateTab(mPosition); |
| 1044 | } |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1045 | return this; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | @Override |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1049 | public Tab setCustomView(int layoutResId) { |
Adam Powell | f242368 | 2011-08-11 14:29:45 -0700 | [diff] [blame] | 1050 | return setCustomView(LayoutInflater.from(getThemedContext()) |
| 1051 | .inflate(layoutResId, null)); |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | @Override |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1055 | public Drawable getIcon() { |
| 1056 | return mIcon; |
| 1057 | } |
| 1058 | |
| 1059 | @Override |
| 1060 | public int getPosition() { |
| 1061 | return mPosition; |
| 1062 | } |
| 1063 | |
| 1064 | public void setPosition(int position) { |
| 1065 | mPosition = position; |
| 1066 | } |
| 1067 | |
| 1068 | @Override |
| 1069 | public CharSequence getText() { |
| 1070 | return mText; |
| 1071 | } |
| 1072 | |
| 1073 | @Override |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1074 | public Tab setIcon(Drawable icon) { |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1075 | mIcon = icon; |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 1076 | if (mPosition >= 0) { |
| 1077 | mTabScrollView.updateTab(mPosition); |
| 1078 | } |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1079 | return this; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1080 | } |
| 1081 | |
| 1082 | @Override |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1083 | public Tab setIcon(int resId) { |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame^] | 1084 | return setIcon(mContext.getDrawable(resId)); |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1085 | } |
| 1086 | |
| 1087 | @Override |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1088 | public Tab setText(CharSequence text) { |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1089 | mText = text; |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 1090 | if (mPosition >= 0) { |
| 1091 | mTabScrollView.updateTab(mPosition); |
| 1092 | } |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1093 | return this; |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1094 | } |
| 1095 | |
| 1096 | @Override |
Adam Powell | 32555f3 | 2010-11-17 13:49:22 -0800 | [diff] [blame] | 1097 | public Tab setText(int resId) { |
| 1098 | return setText(mContext.getResources().getText(resId)); |
| 1099 | } |
| 1100 | |
| 1101 | @Override |
Adam Powell | 661c908 | 2010-07-02 10:09:44 -0700 | [diff] [blame] | 1102 | public void select() { |
| 1103 | selectTab(this); |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 1104 | } |
Adam Powell | 94e56ef | 2011-09-06 21:22:22 -0700 | [diff] [blame] | 1105 | |
| 1106 | @Override |
| 1107 | public Tab setContentDescription(int resId) { |
| 1108 | return setContentDescription(mContext.getResources().getText(resId)); |
| 1109 | } |
| 1110 | |
| 1111 | @Override |
| 1112 | public Tab setContentDescription(CharSequence contentDesc) { |
| 1113 | mContentDesc = contentDesc; |
| 1114 | if (mPosition >= 0) { |
| 1115 | mTabScrollView.updateTab(mPosition); |
| 1116 | } |
| 1117 | return this; |
| 1118 | } |
| 1119 | |
| 1120 | @Override |
| 1121 | public CharSequence getContentDescription() { |
| 1122 | return mContentDesc; |
| 1123 | } |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 1124 | } |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1125 | |
| 1126 | @Override |
| 1127 | public void setCustomView(View view) { |
| 1128 | mActionView.setCustomNavigationView(view); |
| 1129 | } |
| 1130 | |
| 1131 | @Override |
| 1132 | public void setCustomView(View view, LayoutParams layoutParams) { |
| 1133 | view.setLayoutParams(layoutParams); |
| 1134 | mActionView.setCustomNavigationView(view); |
| 1135 | } |
| 1136 | |
| 1137 | @Override |
Adam Powell | 8515ee8 | 2010-11-30 14:09:55 -0800 | [diff] [blame] | 1138 | public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) { |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1139 | mActionView.setDropdownAdapter(adapter); |
| 1140 | mActionView.setCallback(callback); |
| 1141 | } |
| 1142 | |
| 1143 | @Override |
| 1144 | public int getSelectedNavigationIndex() { |
| 1145 | switch (mActionView.getNavigationMode()) { |
| 1146 | case NAVIGATION_MODE_TABS: |
Adam Powell | 0458796 | 2010-11-11 22:15:07 -0800 | [diff] [blame] | 1147 | return mSelectedTab != null ? mSelectedTab.getPosition() : -1; |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1148 | case NAVIGATION_MODE_LIST: |
| 1149 | return mActionView.getDropdownSelectedPosition(); |
| 1150 | default: |
| 1151 | return -1; |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | @Override |
| 1156 | public int getNavigationItemCount() { |
| 1157 | switch (mActionView.getNavigationMode()) { |
| 1158 | case NAVIGATION_MODE_TABS: |
| 1159 | return mTabs.size(); |
| 1160 | case NAVIGATION_MODE_LIST: |
| 1161 | SpinnerAdapter adapter = mActionView.getDropdownAdapter(); |
| 1162 | return adapter != null ? adapter.getCount() : 0; |
| 1163 | default: |
| 1164 | return 0; |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | @Override |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1169 | public int getTabCount() { |
| 1170 | return mTabs.size(); |
| 1171 | } |
| 1172 | |
| 1173 | @Override |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1174 | public void setNavigationMode(int mode) { |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1175 | final int oldMode = mActionView.getNavigationMode(); |
| 1176 | switch (oldMode) { |
| 1177 | case NAVIGATION_MODE_TABS: |
| 1178 | mSavedTabPosition = getSelectedNavigationIndex(); |
| 1179 | selectTab(null); |
Adam Powell | f5645cb | 2011-08-10 22:49:02 -0700 | [diff] [blame] | 1180 | mTabScrollView.setVisibility(View.GONE); |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1181 | break; |
| 1182 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1183 | if (oldMode != mode && !mHasEmbeddedTabs) { |
| 1184 | if (mOverlayLayout != null) { |
| 1185 | mOverlayLayout.requestFitSystemWindows(); |
| 1186 | } |
| 1187 | } |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1188 | mActionView.setNavigationMode(mode); |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1189 | switch (mode) { |
| 1190 | case NAVIGATION_MODE_TABS: |
Adam Powell | f8ac6b7 | 2011-05-23 18:14:09 -0700 | [diff] [blame] | 1191 | ensureTabsExist(); |
Adam Powell | f5645cb | 2011-08-10 22:49:02 -0700 | [diff] [blame] | 1192 | mTabScrollView.setVisibility(View.VISIBLE); |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1193 | if (mSavedTabPosition != INVALID_POSITION) { |
| 1194 | setSelectedNavigationItem(mSavedTabPosition); |
| 1195 | mSavedTabPosition = INVALID_POSITION; |
| 1196 | } |
| 1197 | break; |
| 1198 | } |
Adam Powell | d21aa12 | 2011-05-27 13:09:52 -0700 | [diff] [blame] | 1199 | mActionView.setCollapsable(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs); |
Adam Powell | 9ab9787 | 2010-10-26 21:47:29 -0700 | [diff] [blame] | 1200 | } |
| 1201 | |
| 1202 | @Override |
| 1203 | public Tab getTabAt(int index) { |
| 1204 | return mTabs.get(index); |
| 1205 | } |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1206 | |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1207 | |
Adam Powell | 1969b87 | 2011-03-22 11:52:48 -0700 | [diff] [blame] | 1208 | @Override |
| 1209 | public void setIcon(int resId) { |
Adam Powell | 45c515b | 2011-04-21 18:50:20 -0700 | [diff] [blame] | 1210 | mActionView.setIcon(resId); |
Adam Powell | 1969b87 | 2011-03-22 11:52:48 -0700 | [diff] [blame] | 1211 | } |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1212 | |
Adam Powell | 1969b87 | 2011-03-22 11:52:48 -0700 | [diff] [blame] | 1213 | @Override |
| 1214 | public void setIcon(Drawable icon) { |
| 1215 | mActionView.setIcon(icon); |
| 1216 | } |
| 1217 | |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1218 | public boolean hasIcon() { |
| 1219 | return mActionView.hasIcon(); |
| 1220 | } |
| 1221 | |
Adam Powell | 1969b87 | 2011-03-22 11:52:48 -0700 | [diff] [blame] | 1222 | @Override |
| 1223 | public void setLogo(int resId) { |
Adam Powell | 45c515b | 2011-04-21 18:50:20 -0700 | [diff] [blame] | 1224 | mActionView.setLogo(resId); |
Adam Powell | 1969b87 | 2011-03-22 11:52:48 -0700 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | @Override |
| 1228 | public void setLogo(Drawable logo) { |
| 1229 | mActionView.setLogo(logo); |
Adam Powell | 0c24a55 | 2010-11-03 16:44:11 -0700 | [diff] [blame] | 1230 | } |
Adam Powell | dd8fab2 | 2012-03-22 17:47:27 -0700 | [diff] [blame] | 1231 | |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1232 | public boolean hasLogo() { |
| 1233 | return mActionView.hasLogo(); |
| 1234 | } |
| 1235 | |
Adam Powell | dd8fab2 | 2012-03-22 17:47:27 -0700 | [diff] [blame] | 1236 | public void setDefaultDisplayHomeAsUpEnabled(boolean enable) { |
| 1237 | if (!mDisplayHomeAsUpSet) { |
| 1238 | setDisplayHomeAsUpEnabled(enable); |
| 1239 | } |
| 1240 | } |
Adam Powell | 89e0645 | 2010-06-23 20:24:52 -0700 | [diff] [blame] | 1241 | } |