Winson Chung | 321e9ee | 2010-08-09 13:37:56 -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.launcher2; |
| 18 | |
Michael Jurka | af91de0 | 2010-11-23 16:23:58 -0800 | [diff] [blame] | 19 | import com.android.launcher.R; |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 20 | |
| 21 | import android.content.ComponentName; |
| 22 | import android.content.Context; |
Michael Jurka | 72b079e | 2010-12-10 01:03:53 -0800 | [diff] [blame] | 23 | import android.content.res.Resources; |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 24 | import android.content.res.TypedArray; |
Michael Jurka | d3ef306 | 2010-11-23 16:23:58 -0800 | [diff] [blame] | 25 | import android.graphics.Bitmap; |
| 26 | import android.graphics.Canvas; |
| 27 | import android.graphics.drawable.Drawable; |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 28 | import android.util.AttributeSet; |
| 29 | import android.view.LayoutInflater; |
| 30 | import android.view.View; |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 31 | import android.view.animation.AnimationUtils; |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 32 | import android.widget.Checkable; |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 33 | import android.widget.TextView; |
| 34 | |
Michael Jurka | af91de0 | 2010-11-23 16:23:58 -0800 | [diff] [blame] | 35 | import java.util.ArrayList; |
| 36 | import java.util.Collections; |
| 37 | import java.util.HashSet; |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * An implementation of PagedView that populates the pages of the workspace |
| 41 | * with all of the user's applications. |
| 42 | */ |
Michael Jurka | 72b079e | 2010-12-10 01:03:53 -0800 | [diff] [blame] | 43 | public class AllAppsPagedView extends PagedViewWithDraggableItems implements AllAppsView, |
| 44 | View.OnClickListener, DragSource, DropTarget { |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 45 | |
| 46 | private static final String TAG = "AllAppsPagedView"; |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 47 | |
| 48 | private Launcher mLauncher; |
| 49 | private DragController mDragController; |
| 50 | |
| 51 | // preserve compatibility with 3D all apps: |
| 52 | // 0.0 -> hidden |
| 53 | // 1.0 -> shown and opaque |
| 54 | // intermediate values -> partially shown & partially opaque |
| 55 | private float mZoom; |
| 56 | |
| 57 | // set of all applications |
| 58 | private ArrayList<ApplicationInfo> mApps; |
| 59 | private ArrayList<ApplicationInfo> mFilteredApps; |
| 60 | |
| 61 | // the types of applications to filter |
| 62 | static final int ALL_APPS_FLAG = -1; |
| 63 | private int mAppFilter = ALL_APPS_FLAG; |
| 64 | |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 65 | private final LayoutInflater mInflater; |
Michael Jurka | abded66 | 2011-03-04 12:06:57 -0800 | [diff] [blame] | 66 | private boolean mAllowHardwareLayerCreation; |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 67 | |
Michael Jurka | 12ac0d6 | 2011-02-23 11:48:32 -0800 | [diff] [blame] | 68 | private int mPageContentWidth; |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 69 | |
Patrick Dubroy | e61c6a3 | 2011-05-19 16:48:48 -0700 | [diff] [blame] | 70 | private int mLastMeasureWidth = -1; |
| 71 | private int mLastMeasureHeight = -1; |
| 72 | |
Patrick Dubroy | 1a00933 | 2011-05-23 16:15:09 -0700 | [diff] [blame^] | 73 | private int mMaxCellCountY; |
| 74 | |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 75 | public AllAppsPagedView(Context context) { |
| 76 | this(context, null); |
| 77 | } |
| 78 | |
| 79 | public AllAppsPagedView(Context context, AttributeSet attrs) { |
| 80 | this(context, attrs, 0); |
| 81 | } |
| 82 | |
| 83 | public AllAppsPagedView(Context context, AttributeSet attrs, int defStyle) { |
| 84 | super(context, attrs, defStyle); |
| 85 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, defStyle, 0); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 86 | mInflater = LayoutInflater.from(context); |
Winson Chung | 8b53478 | 2011-02-23 13:43:59 -0800 | [diff] [blame] | 87 | mApps = new ArrayList<ApplicationInfo>(); |
| 88 | mFilteredApps = new ArrayList<ApplicationInfo>(); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 89 | a.recycle(); |
| 90 | setSoundEffectsEnabled(false); |
Michael Jurka | 72b079e | 2010-12-10 01:03:53 -0800 | [diff] [blame] | 91 | |
Patrick Dubroy | 1a00933 | 2011-05-23 16:15:09 -0700 | [diff] [blame^] | 92 | final Resources r = context.getResources(); |
Michael Jurka | 72b079e | 2010-12-10 01:03:53 -0800 | [diff] [blame] | 93 | setDragSlopeThreshold( |
| 94 | r.getInteger(R.integer.config_allAppsDrawerDragSlopeThreshold) / 100.0f); |
Michael Jurka | 12ac0d6 | 2011-02-23 11:48:32 -0800 | [diff] [blame] | 95 | |
| 96 | // Create a dummy page and set it up to find out the content width (used by our parent) |
| 97 | PagedViewCellLayout layout = new PagedViewCellLayout(getContext()); |
| 98 | setupPage(layout); |
| 99 | mPageContentWidth = layout.getContentWidth(); |
Patrick Dubroy | 1a00933 | 2011-05-23 16:15:09 -0700 | [diff] [blame^] | 100 | mMaxCellCountY = r.getInteger(R.integer.all_apps_view_maxCellCountY); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | @Override |
Winson Chung | 7da1025 | 2010-10-28 16:07:04 -0700 | [diff] [blame] | 104 | protected void init() { |
| 105 | super.init(); |
| 106 | mCenterPagesVertically = false; |
| 107 | } |
| 108 | |
Michael Jurka | ea2daff | 2011-05-17 18:21:03 -0700 | [diff] [blame] | 109 | @Override |
| 110 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
Patrick Dubroy | e61c6a3 | 2011-05-19 16:48:48 -0700 | [diff] [blame] | 111 | final int width = MeasureSpec.getSize(widthMeasureSpec); |
| 112 | final int height = MeasureSpec.getSize(heightMeasureSpec); |
Michael Jurka | ea2daff | 2011-05-17 18:21:03 -0700 | [diff] [blame] | 113 | |
Patrick Dubroy | e61c6a3 | 2011-05-19 16:48:48 -0700 | [diff] [blame] | 114 | if (mLastMeasureWidth != width || mLastMeasureHeight != height) { |
Michael Jurka | ea2daff | 2011-05-17 18:21:03 -0700 | [diff] [blame] | 115 | // Create a dummy page and set it up to find out the content width (used by our parent) |
| 116 | PagedViewCellLayout layout = new PagedViewCellLayout(getContext()); |
| 117 | setupPage(layout); |
| 118 | mPageContentWidth = layout.getContentWidth(); |
Patrick Dubroy | e61c6a3 | 2011-05-19 16:48:48 -0700 | [diff] [blame] | 119 | |
| 120 | mCellCountX = determineCellCountX(width, layout); |
| 121 | mCellCountY = determineCellCountY(height, layout); |
| 122 | mLastMeasureWidth = width; |
| 123 | mLastMeasureHeight = height; |
Michael Jurka | ea2daff | 2011-05-17 18:21:03 -0700 | [diff] [blame] | 124 | } |
Patrick Dubroy | e61c6a3 | 2011-05-19 16:48:48 -0700 | [diff] [blame] | 125 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 126 | } |
| 127 | |
| 128 | @Override |
| 129 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
| 130 | if (mFirstLayout) { |
| 131 | invalidatePageData(); |
| 132 | |
| 133 | // invalidatePageData() is what causes the child pages to be created. We need the |
| 134 | // children to be measured before layout, so force a new measure here. |
| 135 | measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY), |
| 136 | MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY)); |
| 137 | } |
| 138 | super.onLayout(changed, left, top, right, bottom); |
| 139 | } |
| 140 | |
| 141 | private int determineCellCountX(int availableWidth, PagedViewCellLayout layout) { |
| 142 | int cellCountX = 0; |
| 143 | final int cellWidth = layout.getCellWidth(); |
| 144 | |
| 145 | // Subtract padding for current page and adjacent pages |
| 146 | availableWidth -= mPageLayoutPaddingLeft * 2 + mPageLayoutPaddingRight * 2; |
| 147 | |
| 148 | availableWidth -= cellWidth; // Assume at least one column |
| 149 | cellCountX = 1 + availableWidth / (cellWidth + mPageLayoutWidthGap); |
| 150 | availableWidth = availableWidth % (cellWidth + mPageLayoutWidthGap); |
| 151 | |
| 152 | // Ensures that we show at least 30% of the holo icons on each side |
| 153 | final int minLeftoverWidth = (int) (cellWidth * 0.6f); |
| 154 | |
| 155 | // Reserve room for the holo outlines |
| 156 | if (cellCountX <= 4) { |
| 157 | // When we're really tight on space, just pack the icons a bit closer together |
| 158 | final int missingWidth = minLeftoverWidth - availableWidth; |
| 159 | if (missingWidth > 0) { |
| 160 | mPageLayoutWidthGap -= Math.ceil(missingWidth * 1.0f / (cellCountX - 1)); |
| 161 | } |
| 162 | } else { |
| 163 | if (cellCountX >= 8) { |
| 164 | // Carve out a few extra columns for very large widths |
| 165 | cellCountX = (int) (cellCountX * 0.9f); |
| 166 | } else if (availableWidth < minLeftoverWidth) { |
| 167 | cellCountX -= 1; |
| 168 | } |
| 169 | } |
| 170 | return cellCountX; |
| 171 | } |
| 172 | |
| 173 | private int determineCellCountY(int availableHeight, PagedViewCellLayout layout) { |
| 174 | final int cellHeight = layout.getCellHeight(); |
| 175 | final int screenHeight = mLauncher.getResources().getDisplayMetrics().heightPixels; |
| 176 | |
| 177 | availableHeight -= mPageLayoutPaddingTop + mPageLayoutPaddingBottom; |
| 178 | availableHeight -= cellHeight; // Assume at least one row |
| 179 | availableHeight -= screenHeight * 0.16f; |
Patrick Dubroy | 1a00933 | 2011-05-23 16:15:09 -0700 | [diff] [blame^] | 180 | if (availableHeight > 0) { |
| 181 | return Math.min(mMaxCellCountY, |
| 182 | 1 + availableHeight / (cellHeight + mPageLayoutHeightGap)); |
| 183 | } |
| 184 | return 0; |
| 185 | } |
| 186 | |
| 187 | int getCellCountX() { |
| 188 | return mCellCountX; |
| 189 | } |
| 190 | |
| 191 | int getCellCountY() { |
| 192 | return mCellCountY; |
Michael Jurka | ea2daff | 2011-05-17 18:21:03 -0700 | [diff] [blame] | 193 | } |
| 194 | |
Michael Jurka | abded66 | 2011-03-04 12:06:57 -0800 | [diff] [blame] | 195 | void allowHardwareLayerCreation() { |
| 196 | // This is called after the first time we launch into All Apps. Before that point, |
| 197 | // there's no need for hardware layers here since there's a hardware layer set on the |
| 198 | // parent, AllAppsTabbed, during the AllApps transition -- creating hardware layers here |
| 199 | // before the animation is done slows down the animation |
| 200 | if (mAllowHardwareLayerCreation) { |
| 201 | return; |
| 202 | } |
| 203 | mAllowHardwareLayerCreation = true; |
| 204 | int childCount = getChildCount(); |
| 205 | for (int i = 0; i < childCount; i++) { |
| 206 | PagedViewCellLayout page = (PagedViewCellLayout) getChildAt(i); |
| 207 | page.allowHardwareLayerCreation(); |
| 208 | } |
| 209 | } |
| 210 | |
Winson Chung | 7da1025 | 2010-10-28 16:07:04 -0700 | [diff] [blame] | 211 | @Override |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 212 | public void setLauncher(Launcher launcher) { |
| 213 | mLauncher = launcher; |
Patrick Dubroy | 2b9ff37 | 2010-09-07 17:49:27 -0700 | [diff] [blame] | 214 | mLauncher.setAllAppsPagedView(this); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | @Override |
| 218 | public void setDragController(DragController dragger) { |
| 219 | mDragController = dragger; |
| 220 | } |
| 221 | |
| 222 | public void setAppFilter(int filterType) { |
| 223 | mAppFilter = filterType; |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 224 | if (mApps != null) { |
| 225 | mFilteredApps = rebuildFilteredApps(mApps); |
Winson Chung | 86f7753 | 2010-08-24 11:08:22 -0700 | [diff] [blame] | 226 | setCurrentPage(0); |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 227 | invalidatePageData(); |
| 228 | } |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | @Override |
| 232 | public void zoom(float zoom, boolean animate) { |
| 233 | mZoom = zoom; |
| 234 | cancelLongPress(); |
| 235 | |
| 236 | if (isVisible()) { |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 237 | if (animate) { |
| 238 | startAnimation(AnimationUtils.loadAnimation(getContext(), |
| 239 | R.anim.all_apps_2d_fade_in)); |
| 240 | } else { |
| 241 | onAnimationEnd(); |
| 242 | } |
| 243 | } else { |
| 244 | if (animate) { |
| 245 | startAnimation(AnimationUtils.loadAnimation(getContext(), |
| 246 | R.anim.all_apps_2d_fade_out)); |
| 247 | } else { |
| 248 | onAnimationEnd(); |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | protected void onAnimationEnd() { |
| 254 | if (!isVisible()) { |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 255 | mZoom = 0.0f; |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 256 | |
| 257 | endChoiceMode(); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 258 | } else { |
| 259 | mZoom = 1.0f; |
| 260 | } |
| 261 | |
| 262 | if (mLauncher != null) |
| 263 | mLauncher.zoomed(mZoom); |
| 264 | } |
| 265 | |
| 266 | private int getChildIndexForGrandChild(View v) { |
| 267 | final int childCount = getChildCount(); |
| 268 | for (int i = 0; i < childCount; ++i) { |
Michael Jurka | 8245a86 | 2011-02-01 17:53:59 -0800 | [diff] [blame] | 269 | final Page layout = (Page) getChildAt(i); |
| 270 | if (layout.indexOfChildOnPage(v) > -1) { |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 271 | return i; |
| 272 | } |
| 273 | } |
| 274 | return -1; |
| 275 | } |
| 276 | |
| 277 | @Override |
| 278 | public void onClick(View v) { |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 279 | // if we are already in a choice mode, then just change the selection |
| 280 | if (v instanceof Checkable) { |
| 281 | if (!isChoiceMode(CHOICE_MODE_NONE)) { |
Patrick Dubroy | 9f7aec8 | 2010-09-06 11:03:37 -0700 | [diff] [blame] | 282 | Checkable c = (Checkable) v; |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 283 | if (isChoiceMode(CHOICE_MODE_SINGLE)) { |
Patrick Dubroy | 9f7aec8 | 2010-09-06 11:03:37 -0700 | [diff] [blame] | 284 | // Uncheck all the other grandchildren, and toggle the clicked one |
| 285 | boolean wasChecked = c.isChecked(); |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 286 | resetCheckedGrandchildren(); |
Patrick Dubroy | 9f7aec8 | 2010-09-06 11:03:37 -0700 | [diff] [blame] | 287 | c.setChecked(!wasChecked); |
| 288 | } else { |
| 289 | c.toggle(); |
| 290 | } |
| 291 | if (getCheckedGrandchildren().size() == 0) { |
| 292 | endChoiceMode(); |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 293 | } |
| 294 | |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 295 | return; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | // otherwise continue and launch the application |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 300 | int childIndex = getChildIndexForGrandChild(v); |
Winson Chung | 86f7753 | 2010-08-24 11:08:22 -0700 | [diff] [blame] | 301 | if (childIndex == getCurrentPage()) { |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 302 | final ApplicationInfo app = (ApplicationInfo) v.getTag(); |
| 303 | |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 304 | // animate some feedback to the click |
| 305 | animateClickFeedback(v, new Runnable() { |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 306 | @Override |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 307 | public void run() { |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 308 | mLauncher.startActivitySafely(app.intent, app); |
| 309 | } |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 310 | }); |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 311 | |
| 312 | endChoiceMode(); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 313 | } |
| 314 | } |
| 315 | |
Patrick Dubroy | cd95371 | 2011-02-28 15:16:42 -0800 | [diff] [blame] | 316 | private void setupDragMode(ApplicationInfo info) { |
Michael Jurka | af91de0 | 2010-11-23 16:23:58 -0800 | [diff] [blame] | 317 | mLauncher.getWorkspace().shrink(Workspace.ShrinkState.BOTTOM_VISIBLE); |
Patrick Dubroy | cd95371 | 2011-02-28 15:16:42 -0800 | [diff] [blame] | 318 | |
| 319 | // Only show the uninstall button if the app is uninstallable. |
| 320 | if ((info.flags & ApplicationInfo.DOWNLOADED_FLAG) != 0) { |
| 321 | DeleteZone allAppsDeleteZone = (DeleteZone) |
| 322 | mLauncher.findViewById(R.id.all_apps_delete_zone); |
| 323 | allAppsDeleteZone.setDragAndDropEnabled(true); |
| 324 | |
| 325 | if ((info.flags & ApplicationInfo.UPDATED_SYSTEM_APP_FLAG) != 0) { |
| 326 | allAppsDeleteZone.setText(R.string.delete_zone_label_all_apps_system_app); |
| 327 | } else { |
| 328 | allAppsDeleteZone.setText(R.string.delete_zone_label_all_apps); |
| 329 | } |
| 330 | } |
Michael Jurka | b8e1447 | 2010-12-20 16:06:10 -0800 | [diff] [blame] | 331 | |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 332 | ApplicationInfoDropTarget allAppsInfoButton = |
| 333 | (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target); |
| 334 | allAppsInfoButton.setDragAndDropEnabled(true); |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | private void tearDownDragMode() { |
| 338 | post(new Runnable() { |
| 339 | // Once the drag operation has fully completed, hence the post, we want to disable the |
| 340 | // deleteZone and the appInfoButton in all apps, and re-enable the instance which |
| 341 | // live in the workspace |
| 342 | public void run() { |
Michael Jurka | b8e1447 | 2010-12-20 16:06:10 -0800 | [diff] [blame] | 343 | DeleteZone allAppsDeleteZone = |
| 344 | (DeleteZone) mLauncher.findViewById(R.id.all_apps_delete_zone); |
Michael Jurka | c31820d | 2011-01-16 16:57:05 -0800 | [diff] [blame] | 345 | // if onDestroy was called on Launcher, we might have already deleted the |
| 346 | // all apps delete zone / info button, so check if they are null |
| 347 | if (allAppsDeleteZone != null) allAppsDeleteZone.setDragAndDropEnabled(false); |
Michael Jurka | b8e1447 | 2010-12-20 16:06:10 -0800 | [diff] [blame] | 348 | |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 349 | ApplicationInfoDropTarget allAppsInfoButton = |
| 350 | (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target); |
Michael Jurka | c31820d | 2011-01-16 16:57:05 -0800 | [diff] [blame] | 351 | if (allAppsInfoButton != null) allAppsInfoButton.setDragAndDropEnabled(false); |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 352 | } |
| 353 | }); |
| 354 | resetCheckedGrandchildren(); |
| 355 | mDragController.removeDropTarget(this); |
| 356 | } |
| 357 | |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 358 | @Override |
Michael Jurka | 72b079e | 2010-12-10 01:03:53 -0800 | [diff] [blame] | 359 | protected boolean beginDragging(View v) { |
Winson Chung | 304dcde | 2011-01-07 11:17:23 -0800 | [diff] [blame] | 360 | if (!v.isInTouchMode()) return false; |
| 361 | if (!super.beginDragging(v)) return false; |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 362 | |
| 363 | ApplicationInfo app = (ApplicationInfo) v.getTag(); |
| 364 | app = new ApplicationInfo(app); |
| 365 | |
Patrick Dubroy | cd95371 | 2011-02-28 15:16:42 -0800 | [diff] [blame] | 366 | // Start drag mode after the item is selected |
| 367 | setupDragMode(app); |
| 368 | |
Michael Jurka | d3ef306 | 2010-11-23 16:23:58 -0800 | [diff] [blame] | 369 | // get icon (top compound drawable, index is 1) |
Winson Chung | cd4bc49 | 2010-12-09 18:52:32 -0800 | [diff] [blame] | 370 | final TextView tv = (TextView) v; |
| 371 | final Drawable icon = tv.getCompoundDrawables()[1]; |
| 372 | Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), |
Michael Jurka | d3ef306 | 2010-11-23 16:23:58 -0800 | [diff] [blame] | 373 | Bitmap.Config.ARGB_8888); |
| 374 | Canvas c = new Canvas(b); |
Winson Chung | cd4bc49 | 2010-12-09 18:52:32 -0800 | [diff] [blame] | 375 | c.translate((v.getWidth() - icon.getIntrinsicWidth()) / 2, v.getPaddingTop()); |
Michael Jurka | d3ef306 | 2010-11-23 16:23:58 -0800 | [diff] [blame] | 376 | icon.draw(c); |
Winson Chung | cd4bc49 | 2010-12-09 18:52:32 -0800 | [diff] [blame] | 377 | |
| 378 | // We toggle the checked state _after_ we create the view for the drag in case toggling the |
| 379 | // checked state changes the view's look |
| 380 | if (v instanceof Checkable) { |
| 381 | // In preparation for drag, we always reset the checked grand children regardless of |
| 382 | // what choice mode we are in |
| 383 | resetCheckedGrandchildren(); |
| 384 | |
| 385 | // Toggle the selection on the dragged app |
| 386 | Checkable checkable = (Checkable) v; |
Winson Chung | 59e1f9a | 2010-12-21 11:31:54 -0800 | [diff] [blame] | 387 | |
| 388 | // Note: we toggle the checkable state to actually cause an alpha fade for the duration |
| 389 | // of the drag of the item. (The fade-in will occur when all checked states are |
| 390 | // disabled when dragging ends) |
Winson Chung | cd4bc49 | 2010-12-09 18:52:32 -0800 | [diff] [blame] | 391 | checkable.toggle(); |
| 392 | } |
| 393 | |
| 394 | // Start the drag |
Winson Chung | 400438b | 2011-01-16 17:53:48 -0800 | [diff] [blame] | 395 | mLauncher.lockScreenOrientation(); |
Michael Jurka | d3ef306 | 2010-11-23 16:23:58 -0800 | [diff] [blame] | 396 | mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b); |
| 397 | mDragController.startDrag(v, b, this, app, DragController.DRAG_ACTION_COPY, null); |
Winson Chung | cd4bc49 | 2010-12-09 18:52:32 -0800 | [diff] [blame] | 398 | b.recycle(); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 399 | return true; |
| 400 | } |
| 401 | |
| 402 | @Override |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 403 | public void onDragViewVisible() { |
| 404 | } |
| 405 | |
| 406 | @Override |
Patrick Dubroy | 5f44542 | 2011-02-18 14:35:21 -0800 | [diff] [blame] | 407 | public void onDropCompleted(View target, Object dragInfo, boolean success) { |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 408 | // close the choice action mode if we have a proper drop |
| 409 | if (target != this) { |
| 410 | endChoiceMode(); |
| 411 | } |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 412 | tearDownDragMode(); |
Patrick Dubroy | 7bccb42 | 2011-01-20 14:50:55 -0800 | [diff] [blame] | 413 | mLauncher.getWorkspace().onDragStopped(success); |
Winson Chung | 400438b | 2011-01-16 17:53:48 -0800 | [diff] [blame] | 414 | mLauncher.unlockScreenOrientation(); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 415 | } |
| 416 | |
Michael Jurka | 12ac0d6 | 2011-02-23 11:48:32 -0800 | [diff] [blame] | 417 | int getPageContentWidth() { |
| 418 | return mPageContentWidth; |
| 419 | } |
| 420 | |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 421 | @Override |
| 422 | public boolean isVisible() { |
| 423 | return mZoom > 0.001f; |
| 424 | } |
| 425 | |
| 426 | @Override |
| 427 | public boolean isAnimating() { |
| 428 | return (getAnimation() != null); |
| 429 | } |
| 430 | |
| 431 | private ArrayList<ApplicationInfo> rebuildFilteredApps(ArrayList<ApplicationInfo> apps) { |
| 432 | ArrayList<ApplicationInfo> filteredApps = new ArrayList<ApplicationInfo>(); |
| 433 | if (mAppFilter == ALL_APPS_FLAG) { |
| 434 | return apps; |
| 435 | } else { |
| 436 | final int length = apps.size(); |
| 437 | for (int i = 0; i < length; ++i) { |
| 438 | ApplicationInfo info = apps.get(i); |
| 439 | if ((info.flags & mAppFilter) > 0) { |
| 440 | filteredApps.add(info); |
| 441 | } |
| 442 | } |
Winson Chung | 78403fe | 2011-01-21 15:38:02 -0800 | [diff] [blame] | 443 | Collections.sort(filteredApps, LauncherModel.APP_INSTALL_TIME_COMPARATOR); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 444 | } |
| 445 | return filteredApps; |
| 446 | } |
| 447 | |
| 448 | @Override |
| 449 | public void setApps(ArrayList<ApplicationInfo> list) { |
| 450 | mApps = list; |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 451 | Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 452 | mFilteredApps = rebuildFilteredApps(mApps); |
Winson Chung | 0499834 | 2011-01-05 13:54:43 -0800 | [diff] [blame] | 453 | mPageViewIconCache.retainAllApps(list); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 454 | invalidatePageData(); |
| 455 | } |
| 456 | |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 457 | private void addAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) { |
| 458 | // we add it in place, in alphabetical order |
| 459 | final int count = list.size(); |
| 460 | for (int i = 0; i < count; ++i) { |
| 461 | final ApplicationInfo info = list.get(i); |
| 462 | final int index = Collections.binarySearch(mApps, info, LauncherModel.APP_NAME_COMPARATOR); |
| 463 | if (index < 0) { |
| 464 | mApps.add(-(index + 1), info); |
Winson Chung | 452821f | 2011-01-14 16:39:47 -0800 | [diff] [blame] | 465 | } else { |
| 466 | mApps.add(index, info); |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 467 | } |
| 468 | } |
| 469 | mFilteredApps = rebuildFilteredApps(mApps); |
| 470 | } |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 471 | @Override |
| 472 | public void addApps(ArrayList<ApplicationInfo> list) { |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 473 | addAppsWithoutInvalidate(list); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 474 | invalidatePageData(); |
| 475 | } |
| 476 | |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 477 | private void removeAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) { |
Winson Chung | 10fefb1 | 2010-11-01 11:57:06 -0700 | [diff] [blame] | 478 | // End the choice mode if any of the items in the list that are being removed are |
| 479 | // currently selected |
| 480 | ArrayList<Checkable> checkedList = getCheckedGrandchildren(); |
| 481 | HashSet<ApplicationInfo> checkedAppInfos = new HashSet<ApplicationInfo>(); |
| 482 | for (Checkable checked : checkedList) { |
| 483 | PagedViewIcon icon = (PagedViewIcon) checked; |
| 484 | checkedAppInfos.add((ApplicationInfo) icon.getTag()); |
| 485 | } |
| 486 | for (ApplicationInfo info : list) { |
| 487 | if (checkedAppInfos.contains(info)) { |
| 488 | endChoiceMode(); |
| 489 | break; |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | // Loop through all the apps and remove apps that have the same component |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 494 | final int length = list.size(); |
| 495 | for (int i = 0; i < length; ++i) { |
Winson Chung | 241c3b4 | 2010-08-25 16:53:03 -0700 | [diff] [blame] | 496 | final ApplicationInfo info = list.get(i); |
| 497 | int removeIndex = findAppByComponent(mApps, info); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 498 | if (removeIndex > -1) { |
| 499 | mApps.remove(removeIndex); |
Winson Chung | 0499834 | 2011-01-05 13:54:43 -0800 | [diff] [blame] | 500 | mPageViewIconCache.removeOutline(new PagedViewIconCache.Key(info)); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 501 | } |
| 502 | } |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 503 | mFilteredApps = rebuildFilteredApps(mApps); |
| 504 | } |
Michael Jurka | abded66 | 2011-03-04 12:06:57 -0800 | [diff] [blame] | 505 | |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 506 | @Override |
| 507 | public void removeApps(ArrayList<ApplicationInfo> list) { |
| 508 | removeAppsWithoutInvalidate(list); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 509 | invalidatePageData(); |
| 510 | } |
| 511 | |
| 512 | @Override |
| 513 | public void updateApps(ArrayList<ApplicationInfo> list) { |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 514 | removeAppsWithoutInvalidate(list); |
| 515 | addAppsWithoutInvalidate(list); |
| 516 | invalidatePageData(); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | private int findAppByComponent(ArrayList<ApplicationInfo> list, ApplicationInfo item) { |
Winson Chung | 8b53478 | 2011-02-23 13:43:59 -0800 | [diff] [blame] | 520 | if (item != null && item.intent != null) { |
| 521 | ComponentName removeComponent = item.intent.getComponent(); |
| 522 | final int length = list.size(); |
| 523 | for (int i = 0; i < length; ++i) { |
| 524 | ApplicationInfo info = list.get(i); |
| 525 | if (info.intent.getComponent().equals(removeComponent)) { |
| 526 | return i; |
| 527 | } |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 528 | } |
| 529 | } |
| 530 | return -1; |
| 531 | } |
| 532 | |
| 533 | @Override |
| 534 | public void dumpState() { |
| 535 | ApplicationInfo.dumpApplicationInfoList(TAG, "mApps", mApps); |
| 536 | } |
| 537 | |
| 538 | @Override |
| 539 | public void surrender() { |
| 540 | // do nothing? |
| 541 | } |
| 542 | |
Michael Jurka | 12ac0d6 | 2011-02-23 11:48:32 -0800 | [diff] [blame] | 543 | private void setupPage(PagedViewCellLayout layout) { |
| 544 | layout.setCellCount(mCellCountX, mCellCountY); |
| 545 | layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop, mPageLayoutPaddingRight, |
| 546 | mPageLayoutPaddingBottom); |
| 547 | layout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap); |
| 548 | } |
| 549 | |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 550 | @Override |
| 551 | public void syncPages() { |
Patrick Dubroy | e61c6a3 | 2011-05-19 16:48:48 -0700 | [diff] [blame] | 552 | if (mCellCountX <= 0 || mCellCountY <= 0) { |
Michael Jurka | ea2daff | 2011-05-17 18:21:03 -0700 | [diff] [blame] | 553 | // We don't know our size yet, which means we haven't calculated cell count x/y; |
| 554 | // onMeasure will call us once we figure out our size |
| 555 | return; |
| 556 | } |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 557 | // ensure that we have the right number of pages (min of 1, since we have placeholders) |
| 558 | int numPages = Math.max(1, |
| 559 | (int) Math.ceil((float) mFilteredApps.size() / (mCellCountX * mCellCountY))); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 560 | int curNumPages = getChildCount(); |
| 561 | // remove any extra pages after the "last" page |
| 562 | int extraPageDiff = curNumPages - numPages; |
| 563 | for (int i = 0; i < extraPageDiff; ++i) { |
| 564 | removeViewAt(numPages); |
| 565 | } |
| 566 | // add any necessary pages |
| 567 | for (int i = curNumPages; i < numPages; ++i) { |
| 568 | PagedViewCellLayout layout = new PagedViewCellLayout(getContext()); |
Michael Jurka | abded66 | 2011-03-04 12:06:57 -0800 | [diff] [blame] | 569 | if (mAllowHardwareLayerCreation) { |
| 570 | layout.allowHardwareLayerCreation(); |
| 571 | } |
Michael Jurka | 12ac0d6 | 2011-02-23 11:48:32 -0800 | [diff] [blame] | 572 | setupPage(layout); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 573 | addView(layout); |
| 574 | } |
| 575 | |
| 576 | // bound the current page |
Winson Chung | 86f7753 | 2010-08-24 11:08:22 -0700 | [diff] [blame] | 577 | setCurrentPage(Math.max(0, Math.min(numPages - 1, getCurrentPage()))); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | @Override |
| 581 | public void syncPageItems(int page) { |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 582 | // Ensure that we have the right number of items on the pages |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 583 | final int cellsPerPage = mCellCountX * mCellCountY; |
| 584 | final int startIndex = page * cellsPerPage; |
| 585 | final int endIndex = Math.min(startIndex + cellsPerPage, mFilteredApps.size()); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 586 | PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page); |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 587 | |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 588 | if (!mFilteredApps.isEmpty()) { |
Michael Jurka | 8245a86 | 2011-02-01 17:53:59 -0800 | [diff] [blame] | 589 | int curNumPageItems = layout.getPageChildCount(); |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 590 | int numPageItems = endIndex - startIndex; |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 591 | |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 592 | // If we were previously an empty page, then restart anew |
| 593 | boolean wasEmptyPage = false; |
| 594 | if (curNumPageItems == 1) { |
Michael Jurka | 8245a86 | 2011-02-01 17:53:59 -0800 | [diff] [blame] | 595 | View icon = layout.getChildOnPageAt(0); |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 596 | if (icon.getTag() == null) { |
| 597 | wasEmptyPage = true; |
| 598 | } |
| 599 | } |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 600 | |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 601 | if (wasEmptyPage) { |
| 602 | // Remove all the previous items |
| 603 | curNumPageItems = 0; |
Michael Jurka | 8245a86 | 2011-02-01 17:53:59 -0800 | [diff] [blame] | 604 | layout.removeAllViewsOnPage(); |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 605 | } else { |
| 606 | // Remove any extra items |
| 607 | int extraPageItemsDiff = curNumPageItems - numPageItems; |
| 608 | for (int i = 0; i < extraPageItemsDiff; ++i) { |
Michael Jurka | 8245a86 | 2011-02-01 17:53:59 -0800 | [diff] [blame] | 609 | layout.removeViewOnPageAt(numPageItems); |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 610 | } |
| 611 | } |
Winson Chung | 80baf5a | 2010-08-09 16:03:15 -0700 | [diff] [blame] | 612 | |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 613 | // Add any necessary items |
| 614 | for (int i = curNumPageItems; i < numPageItems; ++i) { |
| 615 | TextView text = (TextView) mInflater.inflate( |
| 616 | R.layout.all_apps_paged_view_application, layout, false); |
| 617 | text.setOnClickListener(this); |
| 618 | text.setOnLongClickListener(this); |
Michael Jurka | 72b079e | 2010-12-10 01:03:53 -0800 | [diff] [blame] | 619 | text.setOnTouchListener(this); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 620 | |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 621 | layout.addViewToCellLayout(text, -1, i, |
| 622 | new PagedViewCellLayout.LayoutParams(0, 0, 1, 1)); |
| 623 | } |
| 624 | |
| 625 | // Actually reapply to the existing text views |
Winson Chung | 0499834 | 2011-01-05 13:54:43 -0800 | [diff] [blame] | 626 | final int numPages = getPageCount(); |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 627 | for (int i = startIndex; i < endIndex; ++i) { |
| 628 | final int index = i - startIndex; |
| 629 | final ApplicationInfo info = mFilteredApps.get(i); |
Michael Jurka | 8245a86 | 2011-02-01 17:53:59 -0800 | [diff] [blame] | 630 | PagedViewIcon icon = (PagedViewIcon) layout.getChildOnPageAt(index); |
Winson Chung | 0499834 | 2011-01-05 13:54:43 -0800 | [diff] [blame] | 631 | icon.applyFromApplicationInfo(info, mPageViewIconCache, true, (numPages > 1)); |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 632 | |
| 633 | PagedViewCellLayout.LayoutParams params = |
| 634 | (PagedViewCellLayout.LayoutParams) icon.getLayoutParams(); |
| 635 | params.cellX = index % mCellCountX; |
| 636 | params.cellY = index / mCellCountX; |
| 637 | } |
| 638 | |
| 639 | // Default to left-aligned icons |
| 640 | layout.enableCenteredContent(false); |
| 641 | } else { |
| 642 | // There are no items, so show the user a small message |
| 643 | TextView icon = (TextView) mInflater.inflate( |
| 644 | R.layout.all_apps_no_items_placeholder, layout, false); |
| 645 | switch (mAppFilter) { |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 646 | case ApplicationInfo.DOWNLOADED_FLAG: |
| 647 | icon.setText(mContext.getString(R.string.all_apps_no_downloads)); |
| 648 | break; |
| 649 | default: break; |
| 650 | } |
| 651 | |
| 652 | // Center-align the message |
| 653 | layout.enableCenteredContent(true); |
Michael Jurka | 8245a86 | 2011-02-01 17:53:59 -0800 | [diff] [blame] | 654 | layout.removeAllViewsOnPage(); |
Winson Chung | 9678557 | 2010-10-14 13:37:13 -0700 | [diff] [blame] | 655 | layout.addViewToCellLayout(icon, -1, 0, |
Winson Chung | 532a52a | 2011-01-18 12:18:00 -0800 | [diff] [blame] | 656 | new PagedViewCellLayout.LayoutParams(0, 0, 4, 1)); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 657 | } |
Michael Jurka | c5e4902 | 2011-02-16 12:04:02 -0800 | [diff] [blame] | 658 | layout.createHardwareLayers(); |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 659 | } |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 660 | |
| 661 | /* |
| 662 | * We don't actually use AllAppsPagedView as a drop target... it's only used to intercept a drop |
| 663 | * to the workspace. |
| 664 | */ |
| 665 | @Override |
| 666 | public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset, |
| 667 | DragView dragView, Object dragInfo) { |
| 668 | return false; |
| 669 | } |
| 670 | @Override |
Winson Chung | 5f2aa4e | 2010-08-20 14:49:25 -0700 | [diff] [blame] | 671 | public DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset, |
| 672 | int yOffset, DragView dragView, Object dragInfo) { |
| 673 | return null; |
| 674 | } |
| 675 | @Override |
| 676 | public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset, |
| 677 | DragView dragView, Object dragInfo) {} |
| 678 | @Override |
| 679 | public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset, |
| 680 | DragView dragView, Object dragInfo) {} |
| 681 | @Override |
| 682 | public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset, |
| 683 | DragView dragView, Object dragInfo) {} |
| 684 | @Override |
| 685 | public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset, |
| 686 | DragView dragView, Object dragInfo) {} |
Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 687 | |
| 688 | public boolean isDropEnabled() { |
| 689 | return true; |
| 690 | } |
Winson Chung | 321e9ee | 2010-08-09 13:37:56 -0700 | [diff] [blame] | 691 | } |