blob: 79a8f44811ab911168c104914d4e84fb5ccee860 [file] [log] [blame]
Adam Powell89e06452010-06-23 20:24:52 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.app;
18
Adam Powell9b0dc282013-07-31 13:58:43 -070019import android.animation.ValueAnimator;
Adam Powellb36e4f92014-05-01 10:23:33 -070020import android.content.res.TypedArray;
Adam Powell9b0dc282013-07-31 13:58:43 -070021import android.view.ViewParent;
Adam Powellb36e4f92014-05-01 10:23:33 -070022import com.android.internal.R;
Adam Powellb8139af2012-04-19 13:52:46 -070023import com.android.internal.view.ActionBarPolicy;
Adam Powell2c9c9fe2010-07-16 10:17:57 -070024import com.android.internal.view.menu.MenuBuilder;
Adam Powell2c9c9fe2010-07-16 10:17:57 -070025import com.android.internal.view.menu.MenuPopupHelper;
26import com.android.internal.view.menu.SubMenuBuilder;
Adam Powell01feaee2011-02-10 15:05:05 -080027import com.android.internal.widget.ActionBarContainer;
Adam Powell89e06452010-06-23 20:24:52 -070028import com.android.internal.widget.ActionBarContextView;
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -070029import com.android.internal.widget.ActionBarOverlayLayout;
Adam Powell89e06452010-06-23 20:24:52 -070030import com.android.internal.widget.ActionBarView;
Adam Powellf8ac6b72011-05-23 18:14:09 -070031import com.android.internal.widget.ScrollingTabContainerView;
Adam Powell89e06452010-06-23 20:24:52 -070032
Adam Powelld8b3f2e2010-12-02 13:37:03 -080033import android.animation.Animator;
Adam Powelld8b3f2e2010-12-02 13:37:03 -080034import android.animation.Animator.AnimatorListener;
Adam Powell07e1f982011-03-24 11:11:15 -070035import android.animation.AnimatorListenerAdapter;
Adam Powelld8b3f2e2010-12-02 13:37:03 -080036import android.animation.AnimatorSet;
Adam Powelle6ec7322010-12-07 15:29:26 -080037import android.animation.ObjectAnimator;
Adam Powell89e06452010-06-23 20:24:52 -070038import android.app.ActionBar;
Adam Powell661c9082010-07-02 10:09:44 -070039import android.app.Activity;
Adam Powelldec9dfd2010-08-09 15:27:54 -070040import android.app.Dialog;
Adam Powell661c9082010-07-02 10:09:44 -070041import android.app.FragmentTransaction;
Adam Powelldec9dfd2010-08-09 15:27:54 -070042import android.content.Context;
Adam Powellf8ac6b72011-05-23 18:14:09 -070043import android.content.res.Configuration;
Adam Powell88ab6972011-07-28 11:25:01 -070044import android.content.res.Resources;
Adam Powell89e06452010-06-23 20:24:52 -070045import android.graphics.drawable.Drawable;
Adam Powell88ab6972011-07-28 11:25:01 -070046import android.util.TypedValue;
Adam Powell6e346362010-07-23 10:18:23 -070047import android.view.ActionMode;
Adam Powell88ab6972011-07-28 11:25:01 -070048import android.view.ContextThemeWrapper;
Adam Powell32555f32010-11-17 13:49:22 -080049import android.view.LayoutInflater;
Adam Powell89e06452010-06-23 20:24:52 -070050import android.view.Menu;
Adam Powell9168f0b2010-08-02 15:46:24 -070051import android.view.MenuInflater;
Adam Powell89e06452010-06-23 20:24:52 -070052import android.view.MenuItem;
53import android.view.View;
Adam Powelle6ec7322010-12-07 15:29:26 -080054import android.view.Window;
Adam Powell86ed4362011-09-14 16:18:53 -070055import android.view.accessibility.AccessibilityEvent;
Dianne Hackborn8eedb8b2012-04-16 19:31:58 -070056import android.view.animation.AnimationUtils;
Adam Powell89e06452010-06-23 20:24:52 -070057import android.widget.SpinnerAdapter;
Adam Powell89e06452010-06-23 20:24:52 -070058
Adam Powell29ed7572010-07-14 16:24:56 -070059import java.lang.ref.WeakReference;
Adam Powell661c9082010-07-02 10:09:44 -070060import java.util.ArrayList;
61
Adam Powell89e06452010-06-23 20:24:52 -070062/**
Adam Powelle43340c2014-03-17 19:10:43 -070063 * WindowDecorActionBar is the ActionBar implementation used
64 * by devices of all screen sizes as part of the window decor layout.
65 * If it detects a compatible decor, it will split contextual modes
66 * across both the ActionBarView at the top of the screen and
67 * a horizontal LinearLayout at the bottom which is normally hidden.
Adam Powell89e06452010-06-23 20:24:52 -070068 */
Adam Powellb36e4f92014-05-01 10:23:33 -070069public class WindowDecorActionBar extends ActionBar implements
70 ActionBarOverlayLayout.ActionBarVisibilityCallback {
Adam Powelle43340c2014-03-17 19:10:43 -070071 private static final String TAG = "WindowDecorActionBar";
Adam Powell661c9082010-07-02 10:09:44 -070072
Adam Powelldec9dfd2010-08-09 15:27:54 -070073 private Context mContext;
Adam Powell88ab6972011-07-28 11:25:01 -070074 private Context mThemedContext;
Adam Powell661c9082010-07-02 10:09:44 -070075 private Activity mActivity;
Adam Powelldec9dfd2010-08-09 15:27:54 -070076 private Dialog mDialog;
Adam Powell661c9082010-07-02 10:09:44 -070077
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -070078 private ActionBarOverlayLayout mOverlayLayout;
Adam Powell01feaee2011-02-10 15:05:05 -080079 private ActionBarContainer mContainerView;
Adam Powell89e06452010-06-23 20:24:52 -070080 private ActionBarView mActionView;
Adam Powell640a66e2011-04-29 10:18:53 -070081 private ActionBarContextView mContextView;
82 private ActionBarContainer mSplitView;
Adam Powelle6ec7322010-12-07 15:29:26 -080083 private View mContentView;
Adam Powellf8ac6b72011-05-23 18:14:09 -070084 private ScrollingTabContainerView mTabScrollView;
Adam Powell661c9082010-07-02 10:09:44 -070085
86 private ArrayList<TabImpl> mTabs = new ArrayList<TabImpl>();
87
Adam Powell661c9082010-07-02 10:09:44 -070088 private TabImpl mSelectedTab;
Adam Powell0c24a552010-11-03 16:44:11 -070089 private int mSavedTabPosition = INVALID_POSITION;
Adam Powell89e06452010-06-23 20:24:52 -070090
Adam Powelldd8fab22012-03-22 17:47:27 -070091 private boolean mDisplayHomeAsUpSet;
92
Adam Powell060e3ca2011-07-19 20:39:16 -070093 ActionModeImpl mActionMode;
94 ActionMode mDeferredDestroyActionMode;
95 ActionMode.Callback mDeferredModeDestroyCallback;
Adam Powell89e06452010-06-23 20:24:52 -070096
Adam Powell8515ee82010-11-30 14:09:55 -080097 private boolean mLastMenuVisibility;
98 private ArrayList<OnMenuVisibilityListener> mMenuVisibilityListeners =
99 new ArrayList<OnMenuVisibilityListener>();
100
Adam Powell89e06452010-06-23 20:24:52 -0700101 private static final int CONTEXT_DISPLAY_NORMAL = 0;
102 private static final int CONTEXT_DISPLAY_SPLIT = 1;
103
Adam Powell0c24a552010-11-03 16:44:11 -0700104 private static final int INVALID_POSITION = -1;
105
Adam Powell89e06452010-06-23 20:24:52 -0700106 private int mContextDisplayMode;
Adam Powellf8ac6b72011-05-23 18:14:09 -0700107 private boolean mHasEmbeddedTabs;
Adam Powell0e94b512010-06-29 17:58:20 -0700108
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700109 private int mCurWindowVisibility = View.VISIBLE;
110
Dianne Hackborndf7221c2013-02-26 14:53:55 -0800111 private boolean mContentAnimations = true;
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700112 private boolean mHiddenByApp;
113 private boolean mHiddenBySystem;
114 private boolean mShowingForMode;
115
116 private boolean mNowShowing = true;
117
Adam Powell07e1f982011-03-24 11:11:15 -0700118 private Animator mCurrentShowAnim;
Adam Powell50efbed2011-02-08 16:20:15 -0800119 private boolean mShowHideAnimationEnabled;
Adam Powellb36e4f92014-05-01 10:23:33 -0700120 boolean mHideOnContentScroll;
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800121
Adam Powell07e1f982011-03-24 11:11:15 -0700122 final AnimatorListener mHideListener = new AnimatorListenerAdapter() {
Adam Powelle6ec7322010-12-07 15:29:26 -0800123 @Override
124 public void onAnimationEnd(Animator animation) {
Dianne Hackborndf7221c2013-02-26 14:53:55 -0800125 if (mContentAnimations && mContentView != null) {
Adam Powelle6ec7322010-12-07 15:29:26 -0800126 mContentView.setTranslationY(0);
Adam Powell9b0dc282013-07-31 13:58:43 -0700127 mContainerView.setTranslationY(0);
Adam Powelle6ec7322010-12-07 15:29:26 -0800128 }
Adam Powell993a63a2011-08-18 16:35:53 -0700129 if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
130 mSplitView.setVisibility(View.GONE);
131 }
Adam Powell9b0dc282013-07-31 13:58:43 -0700132 mContainerView.setVisibility(View.GONE);
Adam Powell01feaee2011-02-10 15:05:05 -0800133 mContainerView.setTransitioning(false);
Adam Powell07e1f982011-03-24 11:11:15 -0700134 mCurrentShowAnim = null;
Adam Powell060e3ca2011-07-19 20:39:16 -0700135 completeDeferredDestroyActionMode();
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700136 if (mOverlayLayout != null) {
Adam Powellb36e4f92014-05-01 10:23:33 -0700137 mOverlayLayout.requestApplyInsets();
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700138 }
Adam Powelle6ec7322010-12-07 15:29:26 -0800139 }
140 };
141
Adam Powell07e1f982011-03-24 11:11:15 -0700142 final AnimatorListener mShowListener = new AnimatorListenerAdapter() {
Adam Powelle6ec7322010-12-07 15:29:26 -0800143 @Override
144 public void onAnimationEnd(Animator animation) {
Adam Powell07e1f982011-03-24 11:11:15 -0700145 mCurrentShowAnim = null;
Adam Powell9b0dc282013-07-31 13:58:43 -0700146 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 Powelle6ec7322010-12-07 15:29:26 -0800156 }
Adam Powelle6ec7322010-12-07 15:29:26 -0800157 };
158
Adam Powelle43340c2014-03-17 19:10:43 -0700159 public WindowDecorActionBar(Activity activity) {
Adam Powell661c9082010-07-02 10:09:44 -0700160 mActivity = activity;
Adam Powelle6ec7322010-12-07 15:29:26 -0800161 Window window = activity.getWindow();
162 View decor = window.getDecorView();
Dianne Hackborndf7221c2013-02-26 14:53:55 -0800163 boolean overlayMode = mActivity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
Adam Powell9b0dc282013-07-31 13:58:43 -0700164 init(decor);
Dianne Hackborndf7221c2013-02-26 14:53:55 -0800165 if (!overlayMode) {
Adam Powelle6ec7322010-12-07 15:29:26 -0800166 mContentView = decor.findViewById(android.R.id.content);
167 }
Adam Powelldec9dfd2010-08-09 15:27:54 -0700168 }
169
Adam Powelle43340c2014-03-17 19:10:43 -0700170 public WindowDecorActionBar(Dialog dialog) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700171 mDialog = dialog;
Adam Powell9b0dc282013-07-31 13:58:43 -0700172 init(dialog.getWindow().getDecorView());
Adam Powelldec9dfd2010-08-09 15:27:54 -0700173 }
174
Deepanshu Gupta14bf0ce2013-12-12 12:16:24 -0800175 /**
176 * Only for edit mode.
177 * @hide
178 */
179 public WindowDecorActionBar(View layout) {
180 assert layout.isInEditMode();
181 init(layout);
182 }
183
Adam Powell9b0dc282013-07-31 13:58:43 -0700184 private void init(View decor) {
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700185 mOverlayLayout = (ActionBarOverlayLayout) decor.findViewById(
186 com.android.internal.R.id.action_bar_overlay_layout);
187 if (mOverlayLayout != null) {
Adam Powellb36e4f92014-05-01 10:23:33 -0700188 mOverlayLayout.setActionBarVisibilityCallback(this);
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700189 }
Adam Powell89e06452010-06-23 20:24:52 -0700190 mActionView = (ActionBarView) decor.findViewById(com.android.internal.R.id.action_bar);
Adam Powell640a66e2011-04-29 10:18:53 -0700191 mContextView = (ActionBarContextView) decor.findViewById(
Adam Powell89e06452010-06-23 20:24:52 -0700192 com.android.internal.R.id.action_context_bar);
Adam Powell01feaee2011-02-10 15:05:05 -0800193 mContainerView = (ActionBarContainer) decor.findViewById(
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800194 com.android.internal.R.id.action_bar_container);
Adam Powell640a66e2011-04-29 10:18:53 -0700195 mSplitView = (ActionBarContainer) decor.findViewById(
196 com.android.internal.R.id.split_action_bar);
Steve Block08f194b2010-08-24 18:20:48 +0100197
Adam Powell640a66e2011-04-29 10:18:53 -0700198 if (mActionView == null || mContextView == null || mContainerView == null) {
Adam Powell89e06452010-06-23 20:24:52 -0700199 throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
200 "with a compatible window decor layout");
201 }
Adam Powell0e94b512010-06-29 17:58:20 -0700202
Alan Viverette62599332014-04-01 14:57:39 -0700203 mContext = mActionView.getContext();
Adam Powell640a66e2011-04-29 10:18:53 -0700204 mActionView.setContextView(mContextView);
Adam Powell9b4bee02011-04-27 19:24:47 -0700205 mContextDisplayMode = mActionView.isSplitActionBar() ?
206 CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL;
Adam Powelldae78242011-04-25 15:23:41 -0700207
Adam Powelld40423a2012-05-02 14:06:03 -0700208 // This was initially read from the action bar style
209 final int current = mActionView.getDisplayOptions();
210 final boolean homeAsUp = (current & DISPLAY_HOME_AS_UP) != 0;
211 if (homeAsUp) {
212 mDisplayHomeAsUpSet = true;
213 }
214
Adam Powellb8139af2012-04-19 13:52:46 -0700215 ActionBarPolicy abp = ActionBarPolicy.get(mContext);
Adam Powelld40423a2012-05-02 14:06:03 -0700216 setHomeButtonEnabled(abp.enableHomeButtonByDefault() || homeAsUp);
Adam Powellb8139af2012-04-19 13:52:46 -0700217 setHasEmbeddedTabs(abp.hasEmbeddedTabs());
Adam Powellb36e4f92014-05-01 10:23:33 -0700218
219 final TypedArray a = mContext.obtainStyledAttributes(null,
220 com.android.internal.R.styleable.ActionBar,
221 com.android.internal.R.attr.actionBarStyle, 0);
222 if (a.getBoolean(R.styleable.ActionBar_hideOnContentScroll, false)) {
223 setHideOnContentScrollEnabled(true);
224 }
225 a.recycle();
Adam Powellf8ac6b72011-05-23 18:14:09 -0700226 }
227
228 public void onConfigurationChanged(Configuration newConfig) {
Adam Powellb8139af2012-04-19 13:52:46 -0700229 setHasEmbeddedTabs(ActionBarPolicy.get(mContext).hasEmbeddedTabs());
Adam Powellf5645cb2011-08-10 22:49:02 -0700230 }
Adam Powellf8ac6b72011-05-23 18:14:09 -0700231
Adam Powellf5645cb2011-08-10 22:49:02 -0700232 private void setHasEmbeddedTabs(boolean hasEmbeddedTabs) {
233 mHasEmbeddedTabs = hasEmbeddedTabs;
Adam Powellf8ac6b72011-05-23 18:14:09 -0700234 // Switch tab layout configuration if needed
235 if (!mHasEmbeddedTabs) {
236 mActionView.setEmbeddedTabView(null);
237 mContainerView.setTabContainer(mTabScrollView);
238 } else {
239 mContainerView.setTabContainer(null);
Adam Powellf8ac6b72011-05-23 18:14:09 -0700240 mActionView.setEmbeddedTabView(mTabScrollView);
241 }
Adam Powellf5645cb2011-08-10 22:49:02 -0700242 final boolean isInTabMode = getNavigationMode() == NAVIGATION_MODE_TABS;
243 if (mTabScrollView != null) {
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700244 if (isInTabMode) {
245 mTabScrollView.setVisibility(View.VISIBLE);
246 if (mOverlayLayout != null) {
Adam Powellb36e4f92014-05-01 10:23:33 -0700247 mOverlayLayout.requestApplyInsets();
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700248 }
249 } else {
250 mTabScrollView.setVisibility(View.GONE);
251 }
Adam Powellf5645cb2011-08-10 22:49:02 -0700252 }
253 mActionView.setCollapsable(!mHasEmbeddedTabs && isInTabMode);
Adam Powellb36e4f92014-05-01 10:23:33 -0700254 mOverlayLayout.setHasNonEmbeddedTabs(!mHasEmbeddedTabs && isInTabMode);
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700255 }
256
Adam Powellf8ac6b72011-05-23 18:14:09 -0700257 private void ensureTabsExist() {
258 if (mTabScrollView != null) {
259 return;
260 }
261
Adam Powellf5645cb2011-08-10 22:49:02 -0700262 ScrollingTabContainerView tabScroller = new ScrollingTabContainerView(mContext);
Adam Powellf8ac6b72011-05-23 18:14:09 -0700263
264 if (mHasEmbeddedTabs) {
265 tabScroller.setVisibility(View.VISIBLE);
266 mActionView.setEmbeddedTabView(tabScroller);
267 } else {
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700268 if (getNavigationMode() == NAVIGATION_MODE_TABS) {
269 tabScroller.setVisibility(View.VISIBLE);
270 if (mOverlayLayout != null) {
Adam Powell76d8f962014-05-14 20:13:47 -0700271 mOverlayLayout.requestApplyInsets();
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700272 }
273 } else {
274 tabScroller.setVisibility(View.GONE);
275 }
Adam Powelldae78242011-04-25 15:23:41 -0700276 mContainerView.setTabContainer(tabScroller);
Adam Powelldae78242011-04-25 15:23:41 -0700277 }
Adam Powellf8ac6b72011-05-23 18:14:09 -0700278 mTabScrollView = tabScroller;
Adam Powell89e06452010-06-23 20:24:52 -0700279 }
280
Adam Powell060e3ca2011-07-19 20:39:16 -0700281 void completeDeferredDestroyActionMode() {
282 if (mDeferredModeDestroyCallback != null) {
283 mDeferredModeDestroyCallback.onDestroyActionMode(mDeferredDestroyActionMode);
284 mDeferredDestroyActionMode = null;
285 mDeferredModeDestroyCallback = null;
286 }
287 }
288
Adam Powellb36e4f92014-05-01 10:23:33 -0700289 public void onWindowVisibilityChanged(int visibility) {
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700290 mCurWindowVisibility = visibility;
291 }
292
Adam Powell50efbed2011-02-08 16:20:15 -0800293 /**
294 * Enables or disables animation between show/hide states.
295 * If animation is disabled using this method, animations in progress
296 * will be finished.
297 *
298 * @param enabled true to animate, false to not animate.
299 */
300 public void setShowHideAnimationEnabled(boolean enabled) {
301 mShowHideAnimationEnabled = enabled;
Adam Powell07e1f982011-03-24 11:11:15 -0700302 if (!enabled && mCurrentShowAnim != null) {
303 mCurrentShowAnim.end();
Adam Powell50efbed2011-02-08 16:20:15 -0800304 }
305 }
306
Adam Powell8515ee82010-11-30 14:09:55 -0800307 public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
308 mMenuVisibilityListeners.add(listener);
309 }
310
311 public void removeOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
312 mMenuVisibilityListeners.remove(listener);
313 }
314
315 public void dispatchMenuVisibilityChanged(boolean isVisible) {
316 if (isVisible == mLastMenuVisibility) {
317 return;
318 }
319 mLastMenuVisibility = isVisible;
320
321 final int count = mMenuVisibilityListeners.size();
322 for (int i = 0; i < count; i++) {
323 mMenuVisibilityListeners.get(i).onMenuVisibilityChanged(isVisible);
324 }
325 }
326
Adam Powella66c7b02010-07-28 15:28:25 -0700327 @Override
Adam Powell3f476b32011-01-03 19:25:36 -0800328 public void setCustomView(int resId) {
Adam Powellf2423682011-08-11 14:29:45 -0700329 setCustomView(LayoutInflater.from(getThemedContext()).inflate(resId, mActionView, false));
Adam Powell3f476b32011-01-03 19:25:36 -0800330 }
331
332 @Override
333 public void setDisplayUseLogoEnabled(boolean useLogo) {
334 setDisplayOptions(useLogo ? DISPLAY_USE_LOGO : 0, DISPLAY_USE_LOGO);
335 }
336
337 @Override
338 public void setDisplayShowHomeEnabled(boolean showHome) {
339 setDisplayOptions(showHome ? DISPLAY_SHOW_HOME : 0, DISPLAY_SHOW_HOME);
340 }
341
342 @Override
343 public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
344 setDisplayOptions(showHomeAsUp ? DISPLAY_HOME_AS_UP : 0, DISPLAY_HOME_AS_UP);
345 }
346
347 @Override
348 public void setDisplayShowTitleEnabled(boolean showTitle) {
349 setDisplayOptions(showTitle ? DISPLAY_SHOW_TITLE : 0, DISPLAY_SHOW_TITLE);
350 }
351
352 @Override
353 public void setDisplayShowCustomEnabled(boolean showCustom) {
354 setDisplayOptions(showCustom ? DISPLAY_SHOW_CUSTOM : 0, DISPLAY_SHOW_CUSTOM);
355 }
356
357 @Override
Adam Powellc29f4e52011-07-13 20:40:52 -0700358 public void setHomeButtonEnabled(boolean enable) {
359 mActionView.setHomeButtonEnabled(enable);
Adam Powelldae78242011-04-25 15:23:41 -0700360 }
361
362 @Override
Adam Powella66c7b02010-07-28 15:28:25 -0700363 public void setTitle(int resId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700364 setTitle(mContext.getString(resId));
Adam Powella66c7b02010-07-28 15:28:25 -0700365 }
366
367 @Override
368 public void setSubtitle(int resId) {
Adam Powelldec9dfd2010-08-09 15:27:54 -0700369 setSubtitle(mContext.getString(resId));
Adam Powella66c7b02010-07-28 15:28:25 -0700370 }
371
Adam Powell17809772010-07-21 13:25:11 -0700372 public void setSelectedNavigationItem(int position) {
373 switch (mActionView.getNavigationMode()) {
374 case NAVIGATION_MODE_TABS:
375 selectTab(mTabs.get(position));
376 break;
Adam Powell9ab97872010-10-26 21:47:29 -0700377 case NAVIGATION_MODE_LIST:
Adam Powell17809772010-07-21 13:25:11 -0700378 mActionView.setDropdownSelectedPosition(position);
379 break;
380 default:
381 throw new IllegalStateException(
Adam Powell9ab97872010-10-26 21:47:29 -0700382 "setSelectedNavigationIndex not valid for current navigation mode");
Adam Powell17809772010-07-21 13:25:11 -0700383 }
384 }
385
Adam Powell9ab97872010-10-26 21:47:29 -0700386 public void removeAllTabs() {
387 cleanupTabs();
Adam Powell17809772010-07-21 13:25:11 -0700388 }
389
Adam Powell661c9082010-07-02 10:09:44 -0700390 private void cleanupTabs() {
391 if (mSelectedTab != null) {
392 selectTab(null);
393 }
Adam Powell2b6230e2010-09-07 17:55:25 -0700394 mTabs.clear();
Adam Powelld21aa122011-05-27 13:09:52 -0700395 if (mTabScrollView != null) {
396 mTabScrollView.removeAllTabs();
397 }
Adam Powell0c24a552010-11-03 16:44:11 -0700398 mSavedTabPosition = INVALID_POSITION;
Adam Powell661c9082010-07-02 10:09:44 -0700399 }
400
Adam Powell0e94b512010-06-29 17:58:20 -0700401 public void setTitle(CharSequence title) {
402 mActionView.setTitle(title);
403 }
404
405 public void setSubtitle(CharSequence subtitle) {
406 mActionView.setSubtitle(subtitle);
407 }
408
Adam Powell89e06452010-06-23 20:24:52 -0700409 public void setDisplayOptions(int options) {
Adam Powelldd8fab22012-03-22 17:47:27 -0700410 if ((options & DISPLAY_HOME_AS_UP) != 0) {
411 mDisplayHomeAsUpSet = true;
412 }
Adam Powell89e06452010-06-23 20:24:52 -0700413 mActionView.setDisplayOptions(options);
414 }
Adam Powell0e94b512010-06-29 17:58:20 -0700415
Adam Powell89e06452010-06-23 20:24:52 -0700416 public void setDisplayOptions(int options, int mask) {
417 final int current = mActionView.getDisplayOptions();
Adam Powelldd8fab22012-03-22 17:47:27 -0700418 if ((mask & DISPLAY_HOME_AS_UP) != 0) {
419 mDisplayHomeAsUpSet = true;
420 }
Adam Powell89e06452010-06-23 20:24:52 -0700421 mActionView.setDisplayOptions((options & mask) | (current & ~mask));
422 }
423
424 public void setBackgroundDrawable(Drawable d) {
Adam Powellf88b9152011-09-07 14:54:32 -0700425 mContainerView.setPrimaryBackground(d);
426 }
427
428 public void setStackedBackgroundDrawable(Drawable d) {
429 mContainerView.setStackedBackground(d);
430 }
431
432 public void setSplitBackgroundDrawable(Drawable d) {
433 if (mSplitView != null) {
434 mSplitView.setSplitBackground(d);
435 }
Adam Powell89e06452010-06-23 20:24:52 -0700436 }
437
Adam Powellef704442010-11-16 14:48:22 -0800438 public View getCustomView() {
Adam Powell89e06452010-06-23 20:24:52 -0700439 return mActionView.getCustomNavigationView();
440 }
441
442 public CharSequence getTitle() {
443 return mActionView.getTitle();
444 }
445
446 public CharSequence getSubtitle() {
447 return mActionView.getSubtitle();
448 }
449
450 public int getNavigationMode() {
451 return mActionView.getNavigationMode();
452 }
453
454 public int getDisplayOptions() {
455 return mActionView.getDisplayOptions();
456 }
457
Adam Powell5d279772010-07-27 16:34:07 -0700458 public ActionMode startActionMode(ActionMode.Callback callback) {
459 if (mActionMode != null) {
460 mActionMode.finish();
Adam Powell6e346362010-07-23 10:18:23 -0700461 }
Adam Powell3461b322010-07-14 11:34:43 -0700462
Adam Powellb36e4f92014-05-01 10:23:33 -0700463 mOverlayLayout.setHideOnContentScrollEnabled(false);
Adam Powell640a66e2011-04-29 10:18:53 -0700464 mContextView.killMode();
Adam Powell5ee36c42011-06-02 12:59:43 -0700465 ActionModeImpl mode = new ActionModeImpl(callback);
466 if (mode.dispatchOnCreate()) {
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700467 mode.invalidate();
Adam Powell640a66e2011-04-29 10:18:53 -0700468 mContextView.initForMode(mode);
469 animateToMode(true);
Adam Powell1ab418a2011-06-09 20:49:49 -0700470 if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
Adam Powell89e06452010-06-23 20:24:52 -0700471 // TODO animate this
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700472 if (mSplitView.getVisibility() != View.VISIBLE) {
473 mSplitView.setVisibility(View.VISIBLE);
474 if (mOverlayLayout != null) {
Adam Powellb36e4f92014-05-01 10:23:33 -0700475 mOverlayLayout.requestApplyInsets();
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700476 }
477 }
Adam Powell89e06452010-06-23 20:24:52 -0700478 }
Adam Powell86ed4362011-09-14 16:18:53 -0700479 mContextView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
Adam Powell5d279772010-07-27 16:34:07 -0700480 mActionMode = mode;
Adam Powellac695c62010-07-20 18:19:27 -0700481 return mode;
Adam Powell89e06452010-06-23 20:24:52 -0700482 }
Adam Powellac695c62010-07-20 18:19:27 -0700483 return null;
Adam Powell89e06452010-06-23 20:24:52 -0700484 }
485
Adam Powell661c9082010-07-02 10:09:44 -0700486 private void configureTab(Tab tab, int position) {
487 final TabImpl tabi = (TabImpl) tab;
Adam Powell2b6230e2010-09-07 17:55:25 -0700488 final ActionBar.TabListener callback = tabi.getCallback();
489
490 if (callback == null) {
491 throw new IllegalStateException("Action Bar Tab must have a Callback");
492 }
Adam Powell661c9082010-07-02 10:09:44 -0700493
494 tabi.setPosition(position);
495 mTabs.add(position, tabi);
496
Adam Powell81b89442010-11-02 17:58:56 -0700497 final int count = mTabs.size();
498 for (int i = position + 1; i < count; i++) {
499 mTabs.get(i).setPosition(i);
Adam Powell661c9082010-07-02 10:09:44 -0700500 }
Adam Powell661c9082010-07-02 10:09:44 -0700501 }
502
503 @Override
504 public void addTab(Tab tab) {
Adam Powell81b89442010-11-02 17:58:56 -0700505 addTab(tab, mTabs.isEmpty());
Adam Powell661c9082010-07-02 10:09:44 -0700506 }
507
508 @Override
Adam Powell2b6230e2010-09-07 17:55:25 -0700509 public void addTab(Tab tab, int position) {
Adam Powell81b89442010-11-02 17:58:56 -0700510 addTab(tab, position, mTabs.isEmpty());
511 }
512
513 @Override
514 public void addTab(Tab tab, boolean setSelected) {
Adam Powellf8ac6b72011-05-23 18:14:09 -0700515 ensureTabsExist();
516 mTabScrollView.addTab(tab, setSelected);
Adam Powell81b89442010-11-02 17:58:56 -0700517 configureTab(tab, mTabs.size());
518 if (setSelected) {
519 selectTab(tab);
520 }
521 }
522
523 @Override
524 public void addTab(Tab tab, int position, boolean setSelected) {
Adam Powellf8ac6b72011-05-23 18:14:09 -0700525 ensureTabsExist();
526 mTabScrollView.addTab(tab, position, setSelected);
Adam Powell661c9082010-07-02 10:09:44 -0700527 configureTab(tab, position);
Adam Powell81b89442010-11-02 17:58:56 -0700528 if (setSelected) {
529 selectTab(tab);
530 }
Adam Powell661c9082010-07-02 10:09:44 -0700531 }
532
533 @Override
534 public Tab newTab() {
535 return new TabImpl();
536 }
537
538 @Override
539 public void removeTab(Tab tab) {
540 removeTabAt(tab.getPosition());
541 }
542
543 @Override
544 public void removeTabAt(int position) {
Adam Powellf8ac6b72011-05-23 18:14:09 -0700545 if (mTabScrollView == null) {
546 // No tabs around to remove
547 return;
548 }
549
Adam Powell0c24a552010-11-03 16:44:11 -0700550 int selectedTabPosition = mSelectedTab != null
551 ? mSelectedTab.getPosition() : mSavedTabPosition;
Adam Powellf8ac6b72011-05-23 18:14:09 -0700552 mTabScrollView.removeTabAt(position);
Adam Powell0d8ec1d2011-05-03 14:49:13 -0700553 TabImpl removedTab = mTabs.remove(position);
554 if (removedTab != null) {
555 removedTab.setPosition(-1);
556 }
Adam Powell661c9082010-07-02 10:09:44 -0700557
558 final int newTabCount = mTabs.size();
559 for (int i = position; i < newTabCount; i++) {
560 mTabs.get(i).setPosition(i);
561 }
562
Adam Powell0c24a552010-11-03 16:44:11 -0700563 if (selectedTabPosition == position) {
564 selectTab(mTabs.isEmpty() ? null : mTabs.get(Math.max(0, position - 1)));
565 }
Adam Powell661c9082010-07-02 10:09:44 -0700566 }
567
568 @Override
Adam Powell661c9082010-07-02 10:09:44 -0700569 public void selectTab(Tab tab) {
Adam Powell0c24a552010-11-03 16:44:11 -0700570 if (getNavigationMode() != NAVIGATION_MODE_TABS) {
571 mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION;
572 return;
573 }
574
Deepanshu Gupta14bf0ce2013-12-12 12:16:24 -0800575 final FragmentTransaction trans = mActionView.isInEditMode() ? null :
576 mActivity.getFragmentManager().beginTransaction().disallowAddToBackStack();
Adam Powell7f9b9052010-10-19 16:56:07 -0700577
578 if (mSelectedTab == tab) {
579 if (mSelectedTab != null) {
580 mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans);
Adam Powellf8ac6b72011-05-23 18:14:09 -0700581 mTabScrollView.animateToTab(tab.getPosition());
Adam Powell7f9b9052010-10-19 16:56:07 -0700582 }
583 } else {
Adam Powellf8ac6b72011-05-23 18:14:09 -0700584 mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION);
Adam Powell7f9b9052010-10-19 16:56:07 -0700585 if (mSelectedTab != null) {
586 mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans);
587 }
588 mSelectedTab = (TabImpl) tab;
589 if (mSelectedTab != null) {
590 mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans);
591 }
Adam Powell2b6230e2010-09-07 17:55:25 -0700592 }
593
Deepanshu Gupta14bf0ce2013-12-12 12:16:24 -0800594 if (trans != null && !trans.isEmpty()) {
Adam Powell2b6230e2010-09-07 17:55:25 -0700595 trans.commit();
596 }
597 }
598
599 @Override
600 public Tab getSelectedTab() {
601 return mSelectedTab;
Adam Powell661c9082010-07-02 10:09:44 -0700602 }
603
Adam Powell6b336f82010-08-10 20:13:01 -0700604 @Override
605 public int getHeight() {
Adam Powell58c5dc12011-07-14 21:08:10 -0700606 return mContainerView.getHeight();
Adam Powell6b336f82010-08-10 20:13:01 -0700607 }
608
Dianne Hackborndf7221c2013-02-26 14:53:55 -0800609 public void enableContentAnimations(boolean enabled) {
610 mContentAnimations = enabled;
611 }
612
Adam Powell6b336f82010-08-10 20:13:01 -0700613 @Override
614 public void show() {
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700615 if (mHiddenByApp) {
616 mHiddenByApp = false;
617 updateVisibility(false);
618 }
Adam Powell07e1f982011-03-24 11:11:15 -0700619 }
620
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700621 private void showForActionMode() {
622 if (!mShowingForMode) {
623 mShowingForMode = true;
624 if (mOverlayLayout != null) {
625 mOverlayLayout.setShowingForActionMode(true);
626 }
627 updateVisibility(false);
628 }
629 }
630
631 public void showForSystem() {
632 if (mHiddenBySystem) {
633 mHiddenBySystem = false;
634 updateVisibility(true);
635 }
636 }
637
638 @Override
639 public void hide() {
640 if (!mHiddenByApp) {
641 mHiddenByApp = true;
642 updateVisibility(false);
643 }
644 }
645
646 private void hideForActionMode() {
647 if (mShowingForMode) {
648 mShowingForMode = false;
649 if (mOverlayLayout != null) {
650 mOverlayLayout.setShowingForActionMode(false);
651 }
652 updateVisibility(false);
653 }
654 }
655
656 public void hideForSystem() {
657 if (!mHiddenBySystem) {
658 mHiddenBySystem = true;
659 updateVisibility(true);
660 }
661 }
662
Adam Powellb36e4f92014-05-01 10:23:33 -0700663 @Override
664 public void setHideOnContentScrollEnabled(boolean hideOnContentScroll) {
665 if (hideOnContentScroll && !mOverlayLayout.isInOverlayMode()) {
666 throw new IllegalStateException("Action bar must be in overlay mode " +
667 "(Window.FEATURE_OVERLAY_ACTION_BAR) to enable hide on content scroll");
668 }
669 mHideOnContentScroll = hideOnContentScroll;
670 mOverlayLayout.setHideOnContentScrollEnabled(hideOnContentScroll);
671 }
672
673 @Override
674 public boolean isHideOnContentScrollEnabled() {
675 return mOverlayLayout.isHideOnContentScrollEnabled();
676 }
677
678 @Override
679 public int getHideOffset() {
680 return mOverlayLayout.getActionBarHideOffset();
681 }
682
683 @Override
684 public void setHideOffset(int offset) {
685 if (offset != 0 && !mOverlayLayout.isInOverlayMode()) {
686 throw new IllegalStateException("Action bar must be in overlay mode " +
687 "(Window.FEATURE_OVERLAY_ACTION_BAR) to set a non-zero hide offset");
688 }
689 mOverlayLayout.setActionBarHideOffset(offset);
690 }
691
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700692 private static boolean checkShowingFlags(boolean hiddenByApp, boolean hiddenBySystem,
693 boolean showingForMode) {
694 if (showingForMode) {
695 return true;
696 } else if (hiddenByApp || hiddenBySystem) {
697 return false;
698 } else {
699 return true;
700 }
701 }
702
703 private void updateVisibility(boolean fromSystem) {
704 // Based on the current state, should we be hidden or shown?
705 final boolean shown = checkShowingFlags(mHiddenByApp, mHiddenBySystem,
706 mShowingForMode);
707
708 if (shown) {
709 if (!mNowShowing) {
710 mNowShowing = true;
711 doShow(fromSystem);
712 }
713 } else {
714 if (mNowShowing) {
715 mNowShowing = false;
716 doHide(fromSystem);
717 }
718 }
719 }
720
721 public void doShow(boolean fromSystem) {
Adam Powell07e1f982011-03-24 11:11:15 -0700722 if (mCurrentShowAnim != null) {
723 mCurrentShowAnim.end();
Adam Powell45f1e082010-12-10 14:20:13 -0800724 }
Adam Powell9b0dc282013-07-31 13:58:43 -0700725 mContainerView.setVisibility(View.VISIBLE);
Adam Powell50efbed2011-02-08 16:20:15 -0800726
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700727 if (mCurWindowVisibility == View.VISIBLE && (mShowHideAnimationEnabled
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700728 || fromSystem)) {
Adam Powell9b0dc282013-07-31 13:58:43 -0700729 mContainerView.setTranslationY(0); // because we're about to ask its window loc
730 float startingY = -mContainerView.getHeight();
Chet Haasee8118e12012-05-30 14:19:02 -0700731 if (fromSystem) {
732 int topLeft[] = {0, 0};
Adam Powell9b0dc282013-07-31 13:58:43 -0700733 mContainerView.getLocationInWindow(topLeft);
Chet Haasee8118e12012-05-30 14:19:02 -0700734 startingY -= topLeft[1];
735 }
Adam Powell9b0dc282013-07-31 13:58:43 -0700736 mContainerView.setTranslationY(startingY);
Adam Powell50efbed2011-02-08 16:20:15 -0800737 AnimatorSet anim = new AnimatorSet();
Adam Powell9b0dc282013-07-31 13:58:43 -0700738 ObjectAnimator a = ObjectAnimator.ofFloat(mContainerView, View.TRANSLATION_Y, 0);
739 a.addUpdateListener(mUpdateListener);
740 AnimatorSet.Builder b = anim.play(a);
Dianne Hackborndf7221c2013-02-26 14:53:55 -0800741 if (mContentAnimations && mContentView != null) {
Adam Powell9b0dc282013-07-31 13:58:43 -0700742 b.with(ObjectAnimator.ofFloat(mContentView, View.TRANSLATION_Y,
Chet Haasee8118e12012-05-30 14:19:02 -0700743 startingY, 0));
Adam Powell50efbed2011-02-08 16:20:15 -0800744 }
Adam Powell1ab418a2011-06-09 20:49:49 -0700745 if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
Dianne Hackborn8eedb8b2012-04-16 19:31:58 -0700746 mSplitView.setTranslationY(mSplitView.getHeight());
Adam Powell993a63a2011-08-18 16:35:53 -0700747 mSplitView.setVisibility(View.VISIBLE);
Adam Powell9b0dc282013-07-31 13:58:43 -0700748 b.with(ObjectAnimator.ofFloat(mSplitView, View.TRANSLATION_Y, 0));
Adam Powell640a66e2011-04-29 10:18:53 -0700749 }
Dianne Hackborn8eedb8b2012-04-16 19:31:58 -0700750 anim.setInterpolator(AnimationUtils.loadInterpolator(mContext,
Chet Haasee8118e12012-05-30 14:19:02 -0700751 com.android.internal.R.interpolator.decelerate_cubic));
752 anim.setDuration(250);
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700753 // If this is being shown from the system, add a small delay.
754 // This is because we will also be animating in the status bar,
755 // and these two elements can't be done in lock-step. So we give
756 // a little time for the status bar to start its animation before
757 // the action bar animates. (This corresponds to the corresponding
758 // case when hiding, where the status bar has a small delay before
759 // starting.)
Adam Powell50efbed2011-02-08 16:20:15 -0800760 anim.addListener(mShowListener);
Adam Powell07e1f982011-03-24 11:11:15 -0700761 mCurrentShowAnim = anim;
Adam Powell50efbed2011-02-08 16:20:15 -0800762 anim.start();
763 } else {
Adam Powell9b0dc282013-07-31 13:58:43 -0700764 mContainerView.setAlpha(1);
765 mContainerView.setTranslationY(0);
Dianne Hackborndf7221c2013-02-26 14:53:55 -0800766 if (mContentAnimations && mContentView != null) {
Dianne Hackborn80d55062012-05-22 18:03:20 -0700767 mContentView.setTranslationY(0);
768 }
769 if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
770 mSplitView.setAlpha(1);
771 mSplitView.setTranslationY(0);
772 mSplitView.setVisibility(View.VISIBLE);
773 }
Adam Powell50efbed2011-02-08 16:20:15 -0800774 mShowListener.onAnimationEnd(null);
Adam Powelle6ec7322010-12-07 15:29:26 -0800775 }
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700776 if (mOverlayLayout != null) {
Adam Powellb36e4f92014-05-01 10:23:33 -0700777 mOverlayLayout.requestApplyInsets();
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700778 }
Adam Powell6b336f82010-08-10 20:13:01 -0700779 }
780
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700781 public void doHide(boolean fromSystem) {
Adam Powell07e1f982011-03-24 11:11:15 -0700782 if (mCurrentShowAnim != null) {
783 mCurrentShowAnim.end();
Adam Powelle6ec7322010-12-07 15:29:26 -0800784 }
Adam Powell50efbed2011-02-08 16:20:15 -0800785
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700786 if (mCurWindowVisibility == View.VISIBLE && (mShowHideAnimationEnabled
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700787 || fromSystem)) {
Adam Powell9b0dc282013-07-31 13:58:43 -0700788 mContainerView.setAlpha(1);
Adam Powell01feaee2011-02-10 15:05:05 -0800789 mContainerView.setTransitioning(true);
Adam Powell50efbed2011-02-08 16:20:15 -0800790 AnimatorSet anim = new AnimatorSet();
Adam Powell9b0dc282013-07-31 13:58:43 -0700791 float endingY = -mContainerView.getHeight();
Chet Haasee8118e12012-05-30 14:19:02 -0700792 if (fromSystem) {
793 int topLeft[] = {0, 0};
Adam Powell9b0dc282013-07-31 13:58:43 -0700794 mContainerView.getLocationInWindow(topLeft);
Chet Haasee8118e12012-05-30 14:19:02 -0700795 endingY -= topLeft[1];
796 }
Adam Powell9b0dc282013-07-31 13:58:43 -0700797 ObjectAnimator a = ObjectAnimator.ofFloat(mContainerView, View.TRANSLATION_Y, endingY);
798 a.addUpdateListener(mUpdateListener);
799 AnimatorSet.Builder b = anim.play(a);
Dianne Hackborndf7221c2013-02-26 14:53:55 -0800800 if (mContentAnimations && mContentView != null) {
Adam Powell9b0dc282013-07-31 13:58:43 -0700801 b.with(ObjectAnimator.ofFloat(mContentView, View.TRANSLATION_Y,
Chet Haasee8118e12012-05-30 14:19:02 -0700802 0, endingY));
Adam Powell50efbed2011-02-08 16:20:15 -0800803 }
Adam Powell1ab418a2011-06-09 20:49:49 -0700804 if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) {
Adam Powell640a66e2011-04-29 10:18:53 -0700805 mSplitView.setAlpha(1);
Adam Powell9b0dc282013-07-31 13:58:43 -0700806 b.with(ObjectAnimator.ofFloat(mSplitView, View.TRANSLATION_Y,
Dianne Hackborn8eedb8b2012-04-16 19:31:58 -0700807 mSplitView.getHeight()));
Adam Powell640a66e2011-04-29 10:18:53 -0700808 }
Dianne Hackborn8eedb8b2012-04-16 19:31:58 -0700809 anim.setInterpolator(AnimationUtils.loadInterpolator(mContext,
Chet Haasee8118e12012-05-30 14:19:02 -0700810 com.android.internal.R.interpolator.accelerate_cubic));
811 anim.setDuration(250);
Adam Powell50efbed2011-02-08 16:20:15 -0800812 anim.addListener(mHideListener);
Adam Powell07e1f982011-03-24 11:11:15 -0700813 mCurrentShowAnim = anim;
Adam Powell50efbed2011-02-08 16:20:15 -0800814 anim.start();
815 } else {
816 mHideListener.onAnimationEnd(null);
Adam Powelle6ec7322010-12-07 15:29:26 -0800817 }
Adam Powell6b336f82010-08-10 20:13:01 -0700818 }
819
820 public boolean isShowing() {
Adam Powellb36e4f92014-05-01 10:23:33 -0700821 return mNowShowing && getHideOffset() < getHeight();
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800822 }
823
Adam Powell640a66e2011-04-29 10:18:53 -0700824 void animateToMode(boolean toActionMode) {
Adam Powell060e3ca2011-07-19 20:39:16 -0700825 if (toActionMode) {
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700826 showForActionMode();
827 } else {
828 hideForActionMode();
Adam Powell07e1f982011-03-24 11:11:15 -0700829 }
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800830
Adam Powell640a66e2011-04-29 10:18:53 -0700831 mActionView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE);
832 mContextView.animateToVisibility(toActionMode ? View.VISIBLE : View.GONE);
Adam Powellf6ce6a92011-06-29 10:25:01 -0700833 if (mTabScrollView != null && !mActionView.hasEmbeddedTabs() && mActionView.isCollapsed()) {
834 mTabScrollView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE);
835 }
Adam Powell6b336f82010-08-10 20:13:01 -0700836 }
837
Adam Powell88ab6972011-07-28 11:25:01 -0700838 public Context getThemedContext() {
839 if (mThemedContext == null) {
840 TypedValue outValue = new TypedValue();
841 Resources.Theme currentTheme = mContext.getTheme();
842 currentTheme.resolveAttribute(com.android.internal.R.attr.actionBarWidgetTheme,
843 outValue, true);
844 final int targetThemeRes = outValue.resourceId;
845
846 if (targetThemeRes != 0 && mContext.getThemeResId() != targetThemeRes) {
847 mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes);
848 } else {
849 mThemedContext = mContext;
850 }
851 }
852 return mThemedContext;
853 }
854
Adam Powell27cba382013-01-22 18:55:20 -0800855 @Override
856 public boolean isTitleTruncated() {
857 return mActionView != null && mActionView.isTitleTruncated();
858 }
859
Adam Powelle0e2f4f2013-04-05 16:27:35 -0700860 @Override
861 public void setHomeAsUpIndicator(Drawable indicator) {
862 mActionView.setHomeAsUpIndicator(indicator);
863 }
864
865 @Override
866 public void setHomeAsUpIndicator(int resId) {
867 mActionView.setHomeAsUpIndicator(resId);
868 }
869
870 @Override
871 public void setHomeActionContentDescription(CharSequence description) {
872 mActionView.setHomeActionContentDescription(description);
873 }
874
875 @Override
876 public void setHomeActionContentDescription(int resId) {
877 mActionView.setHomeActionContentDescription(resId);
878 }
879
Adam Powellb36e4f92014-05-01 10:23:33 -0700880 @Override
881 public void onContentScrollStarted() {
882 if (mCurrentShowAnim != null) {
883 mCurrentShowAnim.cancel();
884 mCurrentShowAnim = null;
885 }
886 }
887
888 @Override
889 public void onContentScrollStopped() {
890 }
891
Adam Powell89e06452010-06-23 20:24:52 -0700892 /**
893 * @hide
894 */
Adam Powell5d279772010-07-27 16:34:07 -0700895 public class ActionModeImpl extends ActionMode implements MenuBuilder.Callback {
Adam Powell6e346362010-07-23 10:18:23 -0700896 private ActionMode.Callback mCallback;
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700897 private MenuBuilder mMenu;
Adam Powell29ed7572010-07-14 16:24:56 -0700898 private WeakReference<View> mCustomView;
Adam Powell89e06452010-06-23 20:24:52 -0700899
Adam Powell5d279772010-07-27 16:34:07 -0700900 public ActionModeImpl(ActionMode.Callback callback) {
Adam Powell89e06452010-06-23 20:24:52 -0700901 mCallback = callback;
Adam Powellf2423682011-08-11 14:29:45 -0700902 mMenu = new MenuBuilder(getThemedContext())
Adam Powell4d9861e2010-08-17 11:14:40 -0700903 .setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
Adam Powell2c9c9fe2010-07-16 10:17:57 -0700904 mMenu.setCallback(this);
Adam Powell89e06452010-06-23 20:24:52 -0700905 }
Adam Powell9168f0b2010-08-02 15:46:24 -0700906
907 @Override
908 public MenuInflater getMenuInflater() {
Adam Powellf2423682011-08-11 14:29:45 -0700909 return new MenuInflater(getThemedContext());
Adam Powell9168f0b2010-08-02 15:46:24 -0700910 }
911
Adam Powell89e06452010-06-23 20:24:52 -0700912 @Override
913 public Menu getMenu() {
914 return mMenu;
915 }
916
917 @Override
918 public void finish() {
Adam Powell5d279772010-07-27 16:34:07 -0700919 if (mActionMode != this) {
920 // Not the active action mode - no-op
Adam Powell93b6bc32010-07-22 11:36:35 -0700921 return;
922 }
923
Dianne Hackborn139e5aa2012-05-05 20:36:38 -0700924 // If this change in state is going to cause the action bar
925 // to be hidden, defer the onDestroy callback until the animation
926 // is finished and associated relayout is about to happen. This lets
927 // apps better anticipate visibility and layout behavior.
928 if (!checkShowingFlags(mHiddenByApp, mHiddenBySystem, false)) {
929 // With the current state but the action bar hidden, our
930 // overall showing state is going to be false.
Adam Powell060e3ca2011-07-19 20:39:16 -0700931 mDeferredDestroyActionMode = this;
932 mDeferredModeDestroyCallback = mCallback;
933 } else {
934 mCallback.onDestroyActionMode(this);
935 }
Adam Powelld8b3f2e2010-12-02 13:37:03 -0800936 mCallback = null;
Adam Powell640a66e2011-04-29 10:18:53 -0700937 animateToMode(false);
Adam Powell0e94b512010-06-29 17:58:20 -0700938
939 // Clear out the context mode views after the animation finishes
Adam Powell640a66e2011-04-29 10:18:53 -0700940 mContextView.closeMode();
Adam Powell86ed4362011-09-14 16:18:53 -0700941 mActionView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
Adam Powellb36e4f92014-05-01 10:23:33 -0700942 mOverlayLayout.setHideOnContentScrollEnabled(mHideOnContentScroll);
Adam Powellf6ce6a92011-06-29 10:25:01 -0700943
Adam Powell5d279772010-07-27 16:34:07 -0700944 mActionMode = null;
Adam Powell89e06452010-06-23 20:24:52 -0700945 }
946
947 @Override
948 public void invalidate() {
Adam Powell5ee36c42011-06-02 12:59:43 -0700949 mMenu.stopDispatchingItemsChanged();
950 try {
951 mCallback.onPrepareActionMode(this, mMenu);
952 } finally {
953 mMenu.startDispatchingItemsChanged();
954 }
955 }
956
957 public boolean dispatchOnCreate() {
958 mMenu.stopDispatchingItemsChanged();
959 try {
960 return mCallback.onCreateActionMode(this, mMenu);
961 } finally {
962 mMenu.startDispatchingItemsChanged();
Adam Powell89e06452010-06-23 20:24:52 -0700963 }
964 }
965
966 @Override
967 public void setCustomView(View view) {
Adam Powell640a66e2011-04-29 10:18:53 -0700968 mContextView.setCustomView(view);
Adam Powell29ed7572010-07-14 16:24:56 -0700969 mCustomView = new WeakReference<View>(view);
Adam Powell89e06452010-06-23 20:24:52 -0700970 }
971
972 @Override
973 public void setSubtitle(CharSequence subtitle) {
Adam Powell640a66e2011-04-29 10:18:53 -0700974 mContextView.setSubtitle(subtitle);
Adam Powell89e06452010-06-23 20:24:52 -0700975 }
976
977 @Override
978 public void setTitle(CharSequence title) {
Adam Powell640a66e2011-04-29 10:18:53 -0700979 mContextView.setTitle(title);
Adam Powell89e06452010-06-23 20:24:52 -0700980 }
Adam Powell29ed7572010-07-14 16:24:56 -0700981
982 @Override
Adam Powellc9ae2a22010-07-28 14:44:21 -0700983 public void setTitle(int resId) {
Adam Powell48e8ac32011-01-14 12:10:24 -0800984 setTitle(mContext.getResources().getString(resId));
Adam Powellc9ae2a22010-07-28 14:44:21 -0700985 }
986
987 @Override
988 public void setSubtitle(int resId) {
Adam Powell48e8ac32011-01-14 12:10:24 -0800989 setSubtitle(mContext.getResources().getString(resId));
Adam Powellc9ae2a22010-07-28 14:44:21 -0700990 }
991
992 @Override
Adam Powell29ed7572010-07-14 16:24:56 -0700993 public CharSequence getTitle() {
Adam Powell640a66e2011-04-29 10:18:53 -0700994 return mContextView.getTitle();
Adam Powell29ed7572010-07-14 16:24:56 -0700995 }
996
997 @Override
998 public CharSequence getSubtitle() {
Adam Powell640a66e2011-04-29 10:18:53 -0700999 return mContextView.getSubtitle();
Adam Powell29ed7572010-07-14 16:24:56 -07001000 }
Adam Powell89e06452010-06-23 20:24:52 -07001001
Adam Powell29ed7572010-07-14 16:24:56 -07001002 @Override
Adam Powellb98a81f2012-02-24 11:09:07 -08001003 public void setTitleOptionalHint(boolean titleOptional) {
Adam Powell785c4472012-05-02 21:25:39 -07001004 super.setTitleOptionalHint(titleOptional);
Adam Powellb98a81f2012-02-24 11:09:07 -08001005 mContextView.setTitleOptional(titleOptional);
1006 }
1007
1008 @Override
1009 public boolean isTitleOptional() {
1010 return mContextView.isTitleOptional();
1011 }
1012
1013 @Override
Adam Powell29ed7572010-07-14 16:24:56 -07001014 public View getCustomView() {
1015 return mCustomView != null ? mCustomView.get() : null;
1016 }
1017
Adam Powell2c9c9fe2010-07-16 10:17:57 -07001018 public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
Adam Powelld8b3f2e2010-12-02 13:37:03 -08001019 if (mCallback != null) {
1020 return mCallback.onActionItemClicked(this, item);
1021 } else {
1022 return false;
1023 }
Adam Powell2c9c9fe2010-07-16 10:17:57 -07001024 }
1025
1026 public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
1027 }
1028
1029 public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
Adam Powelld8b3f2e2010-12-02 13:37:03 -08001030 if (mCallback == null) {
1031 return false;
1032 }
1033
Adam Powell2c9c9fe2010-07-16 10:17:57 -07001034 if (!subMenu.hasVisibleItems()) {
1035 return true;
Adam Powell89e06452010-06-23 20:24:52 -07001036 }
Adam Powell2c9c9fe2010-07-16 10:17:57 -07001037
Adam Powellf2423682011-08-11 14:29:45 -07001038 new MenuPopupHelper(getThemedContext(), subMenu).show();
Adam Powell2c9c9fe2010-07-16 10:17:57 -07001039 return true;
1040 }
1041
1042 public void onCloseSubMenu(SubMenuBuilder menu) {
1043 }
1044
1045 public void onMenuModeChange(MenuBuilder menu) {
Adam Powelld8b3f2e2010-12-02 13:37:03 -08001046 if (mCallback == null) {
1047 return;
1048 }
Adam Powellf6148c52010-08-11 21:10:16 -07001049 invalidate();
Adam Powell640a66e2011-04-29 10:18:53 -07001050 mContextView.showOverflowMenu();
Adam Powell2c9c9fe2010-07-16 10:17:57 -07001051 }
Adam Powell661c9082010-07-02 10:09:44 -07001052 }
1053
1054 /**
1055 * @hide
1056 */
1057 public class TabImpl extends ActionBar.Tab {
Adam Powell2b6230e2010-09-07 17:55:25 -07001058 private ActionBar.TabListener mCallback;
1059 private Object mTag;
Adam Powell661c9082010-07-02 10:09:44 -07001060 private Drawable mIcon;
1061 private CharSequence mText;
Adam Powell94e56ef2011-09-06 21:22:22 -07001062 private CharSequence mContentDesc;
Adam Powell0d8ec1d2011-05-03 14:49:13 -07001063 private int mPosition = -1;
Adam Powell2b6230e2010-09-07 17:55:25 -07001064 private View mCustomView;
Adam Powell661c9082010-07-02 10:09:44 -07001065
1066 @Override
Adam Powell2b6230e2010-09-07 17:55:25 -07001067 public Object getTag() {
1068 return mTag;
1069 }
1070
1071 @Override
Adam Powell9ab97872010-10-26 21:47:29 -07001072 public Tab setTag(Object tag) {
Adam Powell2b6230e2010-09-07 17:55:25 -07001073 mTag = tag;
Adam Powell9ab97872010-10-26 21:47:29 -07001074 return this;
Adam Powell2b6230e2010-09-07 17:55:25 -07001075 }
1076
1077 public ActionBar.TabListener getCallback() {
1078 return mCallback;
1079 }
1080
1081 @Override
Adam Powell9ab97872010-10-26 21:47:29 -07001082 public Tab setTabListener(ActionBar.TabListener callback) {
Adam Powell2b6230e2010-09-07 17:55:25 -07001083 mCallback = callback;
Adam Powell9ab97872010-10-26 21:47:29 -07001084 return this;
Adam Powell2b6230e2010-09-07 17:55:25 -07001085 }
1086
1087 @Override
1088 public View getCustomView() {
1089 return mCustomView;
1090 }
1091
1092 @Override
Adam Powell9ab97872010-10-26 21:47:29 -07001093 public Tab setCustomView(View view) {
Adam Powell2b6230e2010-09-07 17:55:25 -07001094 mCustomView = view;
Adam Powellf8ac6b72011-05-23 18:14:09 -07001095 if (mPosition >= 0) {
1096 mTabScrollView.updateTab(mPosition);
1097 }
Adam Powell9ab97872010-10-26 21:47:29 -07001098 return this;
Adam Powell661c9082010-07-02 10:09:44 -07001099 }
1100
1101 @Override
Adam Powell32555f32010-11-17 13:49:22 -08001102 public Tab setCustomView(int layoutResId) {
Adam Powellf2423682011-08-11 14:29:45 -07001103 return setCustomView(LayoutInflater.from(getThemedContext())
1104 .inflate(layoutResId, null));
Adam Powell32555f32010-11-17 13:49:22 -08001105 }
1106
1107 @Override
Adam Powell661c9082010-07-02 10:09:44 -07001108 public Drawable getIcon() {
1109 return mIcon;
1110 }
1111
1112 @Override
1113 public int getPosition() {
1114 return mPosition;
1115 }
1116
1117 public void setPosition(int position) {
1118 mPosition = position;
1119 }
1120
1121 @Override
1122 public CharSequence getText() {
1123 return mText;
1124 }
1125
1126 @Override
Adam Powell9ab97872010-10-26 21:47:29 -07001127 public Tab setIcon(Drawable icon) {
Adam Powell661c9082010-07-02 10:09:44 -07001128 mIcon = icon;
Adam Powellf8ac6b72011-05-23 18:14:09 -07001129 if (mPosition >= 0) {
1130 mTabScrollView.updateTab(mPosition);
1131 }
Adam Powell9ab97872010-10-26 21:47:29 -07001132 return this;
Adam Powell661c9082010-07-02 10:09:44 -07001133 }
1134
1135 @Override
Adam Powell32555f32010-11-17 13:49:22 -08001136 public Tab setIcon(int resId) {
Alan Viverette8eea3ea2014-02-03 18:40:20 -08001137 return setIcon(mContext.getDrawable(resId));
Adam Powell32555f32010-11-17 13:49:22 -08001138 }
1139
1140 @Override
Adam Powell9ab97872010-10-26 21:47:29 -07001141 public Tab setText(CharSequence text) {
Adam Powell661c9082010-07-02 10:09:44 -07001142 mText = text;
Adam Powellf8ac6b72011-05-23 18:14:09 -07001143 if (mPosition >= 0) {
1144 mTabScrollView.updateTab(mPosition);
1145 }
Adam Powell9ab97872010-10-26 21:47:29 -07001146 return this;
Adam Powell661c9082010-07-02 10:09:44 -07001147 }
1148
1149 @Override
Adam Powell32555f32010-11-17 13:49:22 -08001150 public Tab setText(int resId) {
1151 return setText(mContext.getResources().getText(resId));
1152 }
1153
1154 @Override
Adam Powell661c9082010-07-02 10:09:44 -07001155 public void select() {
1156 selectTab(this);
Adam Powell89e06452010-06-23 20:24:52 -07001157 }
Adam Powell94e56ef2011-09-06 21:22:22 -07001158
1159 @Override
1160 public Tab setContentDescription(int resId) {
1161 return setContentDescription(mContext.getResources().getText(resId));
1162 }
1163
1164 @Override
1165 public Tab setContentDescription(CharSequence contentDesc) {
1166 mContentDesc = contentDesc;
1167 if (mPosition >= 0) {
1168 mTabScrollView.updateTab(mPosition);
1169 }
1170 return this;
1171 }
1172
1173 @Override
1174 public CharSequence getContentDescription() {
1175 return mContentDesc;
1176 }
Adam Powell89e06452010-06-23 20:24:52 -07001177 }
Adam Powell9ab97872010-10-26 21:47:29 -07001178
1179 @Override
1180 public void setCustomView(View view) {
1181 mActionView.setCustomNavigationView(view);
1182 }
1183
1184 @Override
1185 public void setCustomView(View view, LayoutParams layoutParams) {
1186 view.setLayoutParams(layoutParams);
1187 mActionView.setCustomNavigationView(view);
1188 }
1189
1190 @Override
Adam Powell8515ee82010-11-30 14:09:55 -08001191 public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) {
Adam Powell9ab97872010-10-26 21:47:29 -07001192 mActionView.setDropdownAdapter(adapter);
1193 mActionView.setCallback(callback);
1194 }
1195
1196 @Override
1197 public int getSelectedNavigationIndex() {
1198 switch (mActionView.getNavigationMode()) {
1199 case NAVIGATION_MODE_TABS:
Adam Powell04587962010-11-11 22:15:07 -08001200 return mSelectedTab != null ? mSelectedTab.getPosition() : -1;
Adam Powell9ab97872010-10-26 21:47:29 -07001201 case NAVIGATION_MODE_LIST:
1202 return mActionView.getDropdownSelectedPosition();
1203 default:
1204 return -1;
1205 }
1206 }
1207
1208 @Override
1209 public int getNavigationItemCount() {
1210 switch (mActionView.getNavigationMode()) {
1211 case NAVIGATION_MODE_TABS:
1212 return mTabs.size();
1213 case NAVIGATION_MODE_LIST:
1214 SpinnerAdapter adapter = mActionView.getDropdownAdapter();
1215 return adapter != null ? adapter.getCount() : 0;
1216 default:
1217 return 0;
1218 }
1219 }
1220
1221 @Override
Adam Powell0c24a552010-11-03 16:44:11 -07001222 public int getTabCount() {
1223 return mTabs.size();
1224 }
1225
1226 @Override
Adam Powell9ab97872010-10-26 21:47:29 -07001227 public void setNavigationMode(int mode) {
Adam Powell0c24a552010-11-03 16:44:11 -07001228 final int oldMode = mActionView.getNavigationMode();
1229 switch (oldMode) {
1230 case NAVIGATION_MODE_TABS:
1231 mSavedTabPosition = getSelectedNavigationIndex();
1232 selectTab(null);
Adam Powellf5645cb2011-08-10 22:49:02 -07001233 mTabScrollView.setVisibility(View.GONE);
Adam Powell0c24a552010-11-03 16:44:11 -07001234 break;
1235 }
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -07001236 if (oldMode != mode && !mHasEmbeddedTabs) {
1237 if (mOverlayLayout != null) {
1238 mOverlayLayout.requestFitSystemWindows();
1239 }
1240 }
Adam Powell9ab97872010-10-26 21:47:29 -07001241 mActionView.setNavigationMode(mode);
Adam Powell0c24a552010-11-03 16:44:11 -07001242 switch (mode) {
1243 case NAVIGATION_MODE_TABS:
Adam Powellf8ac6b72011-05-23 18:14:09 -07001244 ensureTabsExist();
Adam Powellf5645cb2011-08-10 22:49:02 -07001245 mTabScrollView.setVisibility(View.VISIBLE);
Adam Powell0c24a552010-11-03 16:44:11 -07001246 if (mSavedTabPosition != INVALID_POSITION) {
1247 setSelectedNavigationItem(mSavedTabPosition);
1248 mSavedTabPosition = INVALID_POSITION;
1249 }
1250 break;
1251 }
Adam Powelld21aa122011-05-27 13:09:52 -07001252 mActionView.setCollapsable(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs);
Adam Powellb36e4f92014-05-01 10:23:33 -07001253 mOverlayLayout.setHasNonEmbeddedTabs(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs);
Adam Powell9ab97872010-10-26 21:47:29 -07001254 }
1255
1256 @Override
1257 public Tab getTabAt(int index) {
1258 return mTabs.get(index);
1259 }
Adam Powell0c24a552010-11-03 16:44:11 -07001260
Adam Powell0c24a552010-11-03 16:44:11 -07001261
Adam Powell1969b872011-03-22 11:52:48 -07001262 @Override
1263 public void setIcon(int resId) {
Adam Powell45c515b2011-04-21 18:50:20 -07001264 mActionView.setIcon(resId);
Adam Powell1969b872011-03-22 11:52:48 -07001265 }
Adam Powell0c24a552010-11-03 16:44:11 -07001266
Adam Powell1969b872011-03-22 11:52:48 -07001267 @Override
1268 public void setIcon(Drawable icon) {
1269 mActionView.setIcon(icon);
1270 }
1271
Adam Powell04fe6eb2013-05-31 14:39:48 -07001272 public boolean hasIcon() {
1273 return mActionView.hasIcon();
1274 }
1275
Adam Powell1969b872011-03-22 11:52:48 -07001276 @Override
1277 public void setLogo(int resId) {
Adam Powell45c515b2011-04-21 18:50:20 -07001278 mActionView.setLogo(resId);
Adam Powell1969b872011-03-22 11:52:48 -07001279 }
1280
1281 @Override
1282 public void setLogo(Drawable logo) {
1283 mActionView.setLogo(logo);
Adam Powell0c24a552010-11-03 16:44:11 -07001284 }
Adam Powelldd8fab22012-03-22 17:47:27 -07001285
Adam Powell04fe6eb2013-05-31 14:39:48 -07001286 public boolean hasLogo() {
1287 return mActionView.hasLogo();
1288 }
1289
Adam Powelldd8fab22012-03-22 17:47:27 -07001290 public void setDefaultDisplayHomeAsUpEnabled(boolean enable) {
1291 if (!mDisplayHomeAsUpSet) {
1292 setDisplayHomeAsUpEnabled(enable);
1293 }
1294 }
Adam Powell89e06452010-06-23 20:24:52 -07001295}