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