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