Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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.launcher2; |
| 18 | |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 19 | import android.animation.Animator; |
Winson Chung | b44b524 | 2011-06-13 11:32:14 -0700 | [diff] [blame] | 20 | import android.animation.AnimatorListenerAdapter; |
Winson Chung | f314b0e | 2011-08-16 11:54:27 -0700 | [diff] [blame] | 21 | import android.animation.AnimatorSet; |
Winson Chung | b44b524 | 2011-06-13 11:32:14 -0700 | [diff] [blame] | 22 | import android.animation.ObjectAnimator; |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 23 | import android.content.Context; |
| 24 | import android.content.res.Resources; |
| 25 | import android.util.AttributeSet; |
| 26 | import android.view.LayoutInflater; |
Winson Chung | 4179b4e | 2011-05-31 17:28:12 -0700 | [diff] [blame] | 27 | import android.view.MotionEvent; |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 28 | import android.view.View; |
| 29 | import android.view.ViewGroup; |
Michael Jurka | 141dbd0 | 2011-11-03 13:50:45 -0700 | [diff] [blame] | 30 | import android.widget.FrameLayout; |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 31 | import android.widget.TabHost; |
Winson Chung | faa1325 | 2011-06-13 18:15:54 -0700 | [diff] [blame] | 32 | import android.widget.TabWidget; |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 33 | import android.widget.TextView; |
| 34 | |
| 35 | import com.android.launcher.R; |
| 36 | |
Michael Jurka | 141dbd0 | 2011-11-03 13:50:45 -0700 | [diff] [blame] | 37 | import java.util.ArrayList; |
| 38 | |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 39 | public class AppsCustomizeTabHost extends TabHost implements LauncherTransitionable, |
| 40 | TabHost.OnTabChangeListener { |
| 41 | static final String LOG_TAG = "AppsCustomizeTabHost"; |
| 42 | |
| 43 | private static final String APPS_TAB_TAG = "APPS"; |
| 44 | private static final String WIDGETS_TAB_TAG = "WIDGETS"; |
| 45 | |
| 46 | private final LayoutInflater mLayoutInflater; |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 47 | private ViewGroup mTabs; |
Winson Chung | fd3385f | 2011-06-15 19:51:24 -0700 | [diff] [blame] | 48 | private ViewGroup mTabsContainer; |
Winson Chung | 4179b4e | 2011-05-31 17:28:12 -0700 | [diff] [blame] | 49 | private AppsCustomizePagedView mAppsCustomizePane; |
Adam Cohen | 0cd3b64 | 2011-10-14 14:58:00 -0700 | [diff] [blame] | 50 | private boolean mSuppressContentCallback = false; |
Michael Jurka | 141dbd0 | 2011-11-03 13:50:45 -0700 | [diff] [blame] | 51 | private FrameLayout mAnimationBuffer; |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 52 | |
Winson Chung | c100e8e | 2011-08-09 16:02:43 -0700 | [diff] [blame] | 53 | private boolean mInTransition; |
| 54 | private boolean mResetAfterTransition; |
| 55 | |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 56 | public AppsCustomizeTabHost(Context context, AttributeSet attrs) { |
| 57 | super(context, attrs); |
| 58 | mLayoutInflater = LayoutInflater.from(context); |
| 59 | } |
| 60 | |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 61 | /** |
Winson Chung | 5a80835 | 2011-06-27 19:08:49 -0700 | [diff] [blame] | 62 | * Convenience methods to select specific tabs. We want to set the content type immediately |
| 63 | * in these cases, but we note that we still call setCurrentTabByTag() so that the tab view |
| 64 | * reflects the new content (but doesn't do the animation and logic associated with changing |
| 65 | * tabs manually). |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 66 | */ |
Winson Chung | 5a80835 | 2011-06-27 19:08:49 -0700 | [diff] [blame] | 67 | private void setContentTypeImmediate(AppsCustomizePagedView.ContentType type) { |
| 68 | onTabChangedStart(); |
| 69 | onTabChangedEnd(type); |
| 70 | } |
Winson Chung | 55b6550 | 2011-05-26 12:03:43 -0700 | [diff] [blame] | 71 | void selectAppsTab() { |
Winson Chung | 5a80835 | 2011-06-27 19:08:49 -0700 | [diff] [blame] | 72 | setContentTypeImmediate(AppsCustomizePagedView.ContentType.Applications); |
Winson Chung | 55b6550 | 2011-05-26 12:03:43 -0700 | [diff] [blame] | 73 | setCurrentTabByTag(APPS_TAB_TAG); |
| 74 | } |
| 75 | void selectWidgetsTab() { |
Winson Chung | 5a80835 | 2011-06-27 19:08:49 -0700 | [diff] [blame] | 76 | setContentTypeImmediate(AppsCustomizePagedView.ContentType.Widgets); |
Winson Chung | 5a80835 | 2011-06-27 19:08:49 -0700 | [diff] [blame] | 77 | setCurrentTabByTag(WIDGETS_TAB_TAG); |
| 78 | } |
Winson Chung | 55b6550 | 2011-05-26 12:03:43 -0700 | [diff] [blame] | 79 | |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 80 | /** |
| 81 | * Setup the tab host and create all necessary tabs. |
| 82 | */ |
| 83 | @Override |
| 84 | protected void onFinishInflate() { |
| 85 | // Setup the tab host |
| 86 | setup(); |
| 87 | |
Winson Chung | fd3385f | 2011-06-15 19:51:24 -0700 | [diff] [blame] | 88 | final ViewGroup tabsContainer = (ViewGroup) findViewById(R.id.tabs_container); |
Winson Chung | faa1325 | 2011-06-13 18:15:54 -0700 | [diff] [blame] | 89 | final TabWidget tabs = (TabWidget) findViewById(com.android.internal.R.id.tabs); |
Winson Chung | 4179b4e | 2011-05-31 17:28:12 -0700 | [diff] [blame] | 90 | final AppsCustomizePagedView appsCustomizePane = (AppsCustomizePagedView) |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 91 | findViewById(R.id.apps_customize_pane_content); |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 92 | mTabs = tabs; |
Winson Chung | fd3385f | 2011-06-15 19:51:24 -0700 | [diff] [blame] | 93 | mTabsContainer = tabsContainer; |
Winson Chung | 4179b4e | 2011-05-31 17:28:12 -0700 | [diff] [blame] | 94 | mAppsCustomizePane = appsCustomizePane; |
Michael Jurka | 141dbd0 | 2011-11-03 13:50:45 -0700 | [diff] [blame] | 95 | mAnimationBuffer = (FrameLayout) findViewById(R.id.animation_buffer); |
Winson Chung | 4179b4e | 2011-05-31 17:28:12 -0700 | [diff] [blame] | 96 | if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException(); |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 97 | |
| 98 | // Configure the tabs content factory to return the same paged view (that we change the |
| 99 | // content filter on) |
| 100 | TabContentFactory contentFactory = new TabContentFactory() { |
| 101 | public View createTabContent(String tag) { |
Winson Chung | 4179b4e | 2011-05-31 17:28:12 -0700 | [diff] [blame] | 102 | return appsCustomizePane; |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 103 | } |
| 104 | }; |
| 105 | |
| 106 | // Create the tabs |
| 107 | TextView tabView; |
Winson Chung | d2c1f80 | 2011-10-14 12:26:54 -0700 | [diff] [blame] | 108 | String label; |
| 109 | label = mContext.getString(R.string.all_apps_button_label); |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 110 | tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false); |
Winson Chung | d2c1f80 | 2011-10-14 12:26:54 -0700 | [diff] [blame] | 111 | tabView.setText(label); |
| 112 | tabView.setContentDescription(label); |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 113 | addTab(newTabSpec(APPS_TAB_TAG).setIndicator(tabView).setContent(contentFactory)); |
Winson Chung | d2c1f80 | 2011-10-14 12:26:54 -0700 | [diff] [blame] | 114 | label = mContext.getString(R.string.widgets_tab_label); |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 115 | tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false); |
Winson Chung | d2c1f80 | 2011-10-14 12:26:54 -0700 | [diff] [blame] | 116 | tabView.setText(label); |
| 117 | tabView.setContentDescription(label); |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 118 | addTab(newTabSpec(WIDGETS_TAB_TAG).setIndicator(tabView).setContent(contentFactory)); |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 119 | setOnTabChangedListener(this); |
Winson Chung | faa1325 | 2011-06-13 18:15:54 -0700 | [diff] [blame] | 120 | |
| 121 | // Setup the key listener to jump between the last tab view and the market icon |
| 122 | AppsCustomizeTabKeyEventListener keyListener = new AppsCustomizeTabKeyEventListener(); |
| 123 | View lastTab = tabs.getChildTabViewAt(tabs.getTabCount() - 1); |
| 124 | lastTab.setOnKeyListener(keyListener); |
| 125 | View shopButton = findViewById(R.id.market_button); |
| 126 | shopButton.setOnKeyListener(keyListener); |
Winson Chung | fd3385f | 2011-06-15 19:51:24 -0700 | [diff] [blame] | 127 | |
| 128 | // Hide the tab bar until we measure |
| 129 | mTabsContainer.setAlpha(0f); |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 130 | } |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 131 | |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 132 | @Override |
| 133 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 134 | boolean remeasureTabWidth = (mTabs.getLayoutParams().width <= 0); |
| 135 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 136 | |
| 137 | // Set the width of the tab list to the content width |
| 138 | if (remeasureTabWidth) { |
Winson Chung | fd3385f | 2011-06-15 19:51:24 -0700 | [diff] [blame] | 139 | int contentWidth = mAppsCustomizePane.getPageContentWidth(); |
Michael Jurka | 141dbd0 | 2011-11-03 13:50:45 -0700 | [diff] [blame] | 140 | if (contentWidth > 0 && mTabs.getLayoutParams().width != contentWidth) { |
| 141 | // Set the width and show the tab bar |
Winson Chung | fd3385f | 2011-06-15 19:51:24 -0700 | [diff] [blame] | 142 | mTabs.getLayoutParams().width = contentWidth; |
Michael Jurka | c57b7a8 | 2011-08-09 22:02:20 -0700 | [diff] [blame] | 143 | post(new Runnable() { |
| 144 | public void run() { |
| 145 | mTabs.requestLayout(); |
Winson Chung | 7ed3774 | 2011-09-08 15:45:51 -0700 | [diff] [blame] | 146 | mTabsContainer.setAlpha(1f); |
Michael Jurka | c57b7a8 | 2011-08-09 22:02:20 -0700 | [diff] [blame] | 147 | } |
| 148 | }); |
Winson Chung | fd3385f | 2011-06-15 19:51:24 -0700 | [diff] [blame] | 149 | } |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 150 | } |
Winson Chung | fd3385f | 2011-06-15 19:51:24 -0700 | [diff] [blame] | 151 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
Winson Chung | 4179b4e | 2011-05-31 17:28:12 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | @Override |
| 155 | public boolean onTouchEvent(MotionEvent event) { |
| 156 | // Intercept all touch events up to the bottom of the AppsCustomizePane so they do not fall |
| 157 | // through to the workspace and trigger showWorkspace() |
| 158 | if (event.getY() < mAppsCustomizePane.getBottom()) { |
| 159 | return true; |
| 160 | } |
| 161 | return super.onTouchEvent(event); |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Winson Chung | 5a80835 | 2011-06-27 19:08:49 -0700 | [diff] [blame] | 164 | private void onTabChangedStart() { |
| 165 | mAppsCustomizePane.hideScrollingIndicator(false); |
| 166 | } |
Adam Cohen | 0cd3b64 | 2011-10-14 14:58:00 -0700 | [diff] [blame] | 167 | |
Winson Chung | 097e6c7 | 2011-10-20 13:58:30 -0700 | [diff] [blame] | 168 | private void reloadCurrentPage() { |
| 169 | if (!LauncherApplication.isScreenLarge()) { |
| 170 | mAppsCustomizePane.flashScrollingIndicator(); |
| 171 | } |
| 172 | mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage()); |
| 173 | mAppsCustomizePane.requestFocus(); |
| 174 | } |
| 175 | |
Winson Chung | 5a80835 | 2011-06-27 19:08:49 -0700 | [diff] [blame] | 176 | private void onTabChangedEnd(AppsCustomizePagedView.ContentType type) { |
| 177 | mAppsCustomizePane.setContentType(type); |
| 178 | } |
| 179 | |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 180 | @Override |
| 181 | public void onTabChanged(String tabId) { |
Winson Chung | b44b524 | 2011-06-13 11:32:14 -0700 | [diff] [blame] | 182 | final AppsCustomizePagedView.ContentType type = getContentTypeForTabTag(tabId); |
Adam Cohen | 0cd3b64 | 2011-10-14 14:58:00 -0700 | [diff] [blame] | 183 | if (mSuppressContentCallback) { |
| 184 | mSuppressContentCallback = false; |
| 185 | return; |
Winson Chung | b44b524 | 2011-06-13 11:32:14 -0700 | [diff] [blame] | 186 | } |
Adam Cohen | 0cd3b64 | 2011-10-14 14:58:00 -0700 | [diff] [blame] | 187 | |
| 188 | // Animate the changing of the tab content by fading pages in and out |
| 189 | final Resources res = getResources(); |
| 190 | final int duration = res.getInteger(R.integer.config_tabTransitionDuration); |
| 191 | |
| 192 | // We post a runnable here because there is a delay while the first page is loading and |
| 193 | // the feedback from having changed the tab almost feels better than having it stick |
| 194 | post(new Runnable() { |
| 195 | @Override |
| 196 | public void run() { |
Winson Chung | 097e6c7 | 2011-10-20 13:58:30 -0700 | [diff] [blame] | 197 | if (mAppsCustomizePane.getMeasuredWidth() <= 0 || |
| 198 | mAppsCustomizePane.getMeasuredHeight() <= 0) { |
| 199 | reloadCurrentPage(); |
| 200 | return; |
| 201 | } |
| 202 | |
Michael Jurka | 141dbd0 | 2011-11-03 13:50:45 -0700 | [diff] [blame] | 203 | // Take the visible pages and re-parent them temporarily to mAnimatorBuffer |
| 204 | // and then cross fade to the new pages |
| 205 | |
| 206 | // We want the pages to be rendered in exactly the same way as they were when |
| 207 | // their parent was mAppsCustomizePane -- so set the scroll on mAnimationBuffer |
| 208 | // to be exactly the same as mAppsCustomizePane, and below, set the left/top |
| 209 | // parameters to be correct for each of the pages |
| 210 | mAnimationBuffer.scrollTo(mAppsCustomizePane.getScrollX(), 0); |
| 211 | |
| 212 | int[] visiblePageRange = new int[2]; |
| 213 | mAppsCustomizePane.getVisiblePages(visiblePageRange); |
| 214 | ArrayList<View> visiblePages = new ArrayList<View>(); |
| 215 | for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) { |
| 216 | visiblePages.add(mAppsCustomizePane.getPageAt(i)); |
| 217 | } |
| 218 | // mAppsCustomizePane renders its children in reverse order, so |
| 219 | // add the pages to mAnimationBuffer in reverse order to match that behavior |
| 220 | for (int i = visiblePages.size() - 1; i >= 0; i--) { |
| 221 | View child = visiblePages.get(i); |
| 222 | PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(false); |
| 223 | mAppsCustomizePane.removeView(child); |
| 224 | PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(true); |
| 225 | mAnimationBuffer.setAlpha(1f); |
| 226 | mAnimationBuffer.setVisibility(View.VISIBLE); |
| 227 | LayoutParams p = new FrameLayout.LayoutParams(child.getWidth(), |
| 228 | child.getHeight()); |
| 229 | p.setMargins((int) child.getLeft(), (int) child.getTop(), 0, 0); |
| 230 | mAnimationBuffer.addView(child, p); |
| 231 | } |
Adam Cohen | 0cd3b64 | 2011-10-14 14:58:00 -0700 | [diff] [blame] | 232 | |
| 233 | // Toggle the new content |
| 234 | onTabChangedStart(); |
| 235 | onTabChangedEnd(type); |
| 236 | |
| 237 | // Animate the transition |
| 238 | ObjectAnimator outAnim = ObjectAnimator.ofFloat(mAnimationBuffer, "alpha", 0f); |
| 239 | outAnim.addListener(new AnimatorListenerAdapter() { |
| 240 | @Override |
| 241 | public void onAnimationEnd(Animator animation) { |
| 242 | mAnimationBuffer.setVisibility(View.GONE); |
Michael Jurka | 141dbd0 | 2011-11-03 13:50:45 -0700 | [diff] [blame] | 243 | mAnimationBuffer.removeAllViews(); |
| 244 | } |
| 245 | @Override |
| 246 | public void onAnimationCancel(Animator animation) { |
| 247 | mAnimationBuffer.setVisibility(View.GONE); |
| 248 | mAnimationBuffer.removeAllViews(); |
Adam Cohen | 0cd3b64 | 2011-10-14 14:58:00 -0700 | [diff] [blame] | 249 | } |
| 250 | }); |
| 251 | ObjectAnimator inAnim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f); |
| 252 | inAnim.addListener(new AnimatorListenerAdapter() { |
| 253 | @Override |
| 254 | public void onAnimationEnd(Animator animation) { |
Winson Chung | 097e6c7 | 2011-10-20 13:58:30 -0700 | [diff] [blame] | 255 | reloadCurrentPage(); |
Adam Cohen | 0cd3b64 | 2011-10-14 14:58:00 -0700 | [diff] [blame] | 256 | } |
| 257 | }); |
| 258 | AnimatorSet animSet = new AnimatorSet(); |
| 259 | animSet.playTogether(outAnim, inAnim); |
| 260 | animSet.setDuration(duration); |
| 261 | animSet.start(); |
| 262 | } |
| 263 | }); |
| 264 | } |
| 265 | |
| 266 | public void setCurrentTabFromContent(AppsCustomizePagedView.ContentType type) { |
| 267 | mSuppressContentCallback = true; |
| 268 | setCurrentTabByTag(getTabTagForContentType(type)); |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | /** |
| 272 | * Returns the content type for the specified tab tag. |
| 273 | */ |
| 274 | public AppsCustomizePagedView.ContentType getContentTypeForTabTag(String tag) { |
| 275 | if (tag.equals(APPS_TAB_TAG)) { |
| 276 | return AppsCustomizePagedView.ContentType.Applications; |
| 277 | } else if (tag.equals(WIDGETS_TAB_TAG)) { |
| 278 | return AppsCustomizePagedView.ContentType.Widgets; |
| 279 | } |
| 280 | return AppsCustomizePagedView.ContentType.Applications; |
| 281 | } |
| 282 | |
| 283 | /** |
Winson Chung | fc79c80 | 2011-05-02 13:35:34 -0700 | [diff] [blame] | 284 | * Returns the tab tag for a given content type. |
| 285 | */ |
| 286 | public String getTabTagForContentType(AppsCustomizePagedView.ContentType type) { |
| 287 | if (type == AppsCustomizePagedView.ContentType.Applications) { |
| 288 | return APPS_TAB_TAG; |
| 289 | } else if (type == AppsCustomizePagedView.ContentType.Widgets) { |
| 290 | return WIDGETS_TAB_TAG; |
| 291 | } |
| 292 | return APPS_TAB_TAG; |
| 293 | } |
| 294 | |
| 295 | /** |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 296 | * Disable focus on anything under this view in the hierarchy if we are not visible. |
| 297 | */ |
| 298 | @Override |
| 299 | public int getDescendantFocusability() { |
| 300 | if (getVisibility() != View.VISIBLE) { |
| 301 | return ViewGroup.FOCUS_BLOCK_DESCENDANTS; |
| 302 | } |
| 303 | return super.getDescendantFocusability(); |
| 304 | } |
| 305 | |
Winson Chung | c100e8e | 2011-08-09 16:02:43 -0700 | [diff] [blame] | 306 | void reset() { |
| 307 | if (mInTransition) { |
| 308 | // Defer to after the transition to reset |
| 309 | mResetAfterTransition = true; |
| 310 | } else { |
| 311 | // Reset immediately |
| 312 | mAppsCustomizePane.reset(); |
| 313 | } |
| 314 | } |
| 315 | |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 316 | /* LauncherTransitionable overrides */ |
| 317 | @Override |
Winson Chung | 7d7541e | 2011-09-16 20:14:36 -0700 | [diff] [blame] | 318 | public void onLauncherTransitionStart(Launcher l, Animator animation, boolean toWorkspace) { |
Winson Chung | c100e8e | 2011-08-09 16:02:43 -0700 | [diff] [blame] | 319 | mInTransition = true; |
Michael Jurka | 19e0fc5 | 2011-07-22 18:00:21 -0700 | [diff] [blame] | 320 | // isHardwareAccelerated() checks if we're attached to a window and if that |
| 321 | // window is HW accelerated-- we were sometimes not attached to a window |
| 322 | // and buildLayer was throwing an IllegalStateException |
| 323 | if (animation != null && isHardwareAccelerated()) { |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 324 | // Turn on hardware layers for performance |
| 325 | setLayerType(LAYER_TYPE_HARDWARE, null); |
| 326 | |
| 327 | // force building the layer at the beginning of the animation, so you don't get a |
| 328 | // blip early in the animation |
| 329 | buildLayer(); |
| 330 | } |
Michael Jurka | 430e8a5 | 2011-08-08 15:52:14 -0700 | [diff] [blame] | 331 | if (!toWorkspace && !LauncherApplication.isScreenLarge()) { |
| 332 | mAppsCustomizePane.showScrollingIndicator(false); |
| 333 | } |
Winson Chung | c100e8e | 2011-08-09 16:02:43 -0700 | [diff] [blame] | 334 | if (mResetAfterTransition) { |
| 335 | mAppsCustomizePane.reset(); |
| 336 | mResetAfterTransition = false; |
| 337 | } |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 338 | } |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 339 | |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 340 | @Override |
Winson Chung | 7d7541e | 2011-09-16 20:14:36 -0700 | [diff] [blame] | 341 | public void onLauncherTransitionEnd(Launcher l, Animator animation, boolean toWorkspace) { |
Winson Chung | c100e8e | 2011-08-09 16:02:43 -0700 | [diff] [blame] | 342 | mInTransition = false; |
Winson Chung | f0ea4d3 | 2011-06-06 14:27:16 -0700 | [diff] [blame] | 343 | if (animation != null) { |
| 344 | setLayerType(LAYER_TYPE_NONE, null); |
| 345 | } |
Winson Chung | 3ac74c5 | 2011-06-30 17:39:37 -0700 | [diff] [blame] | 346 | |
Winson Chung | 7d7541e | 2011-09-16 20:14:36 -0700 | [diff] [blame] | 347 | if (!toWorkspace) { |
| 348 | // Dismiss the cling if necessary |
| 349 | l.dismissWorkspaceCling(null); |
| 350 | |
| 351 | if (!LauncherApplication.isScreenLarge()) { |
| 352 | mAppsCustomizePane.hideScrollingIndicator(false); |
| 353 | } |
Winson Chung | 5a80835 | 2011-06-27 19:08:49 -0700 | [diff] [blame] | 354 | } |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 355 | } |
Winson Chung | 70d7210 | 2011-08-12 11:24:35 -0700 | [diff] [blame] | 356 | |
| 357 | boolean isTransitioning() { |
| 358 | return mInTransition; |
| 359 | } |
Winson Chung | 785d2eb | 2011-04-14 16:08:02 -0700 | [diff] [blame] | 360 | } |