The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
Joe Onorato | a590252 | 2009-07-30 13:37:37 -0700 | [diff] [blame] | 17 | package com.android.launcher2; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 18 | |
Michael Jurka | 577d017 | 2010-12-17 20:04:50 -0800 | [diff] [blame^] | 19 | import com.android.launcher.R; |
| 20 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 21 | import android.content.Context; |
Michael Jurka | 577d017 | 2010-12-17 20:04:50 -0800 | [diff] [blame^] | 22 | import android.content.res.Resources; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 23 | import android.content.res.TypedArray; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 24 | import android.graphics.PorterDuff; |
| 25 | import android.graphics.PorterDuffColorFilter; |
Michael Jurka | 3adcb0c | 2010-10-15 18:07:21 -0700 | [diff] [blame] | 26 | import android.graphics.Rect; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 27 | import android.graphics.RectF; |
| 28 | import android.graphics.drawable.TransitionDrawable; |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 29 | import android.util.AttributeSet; |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 30 | import android.view.View; |
| 31 | import android.view.animation.AccelerateInterpolator; |
| 32 | import android.view.animation.AlphaAnimation; |
| 33 | import android.view.animation.Animation; |
| 34 | import android.view.animation.AnimationSet; |
| 35 | import android.view.animation.TranslateAnimation; |
Romain Guy | edcce09 | 2010-03-04 13:03:17 -0800 | [diff] [blame] | 36 | |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 37 | public class DeleteZone extends IconDropTarget { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 38 | private static final int ORIENTATION_HORIZONTAL = 1; |
| 39 | private static final int TRANSITION_DURATION = 250; |
| 40 | private static final int ANIMATION_DURATION = 200; |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 41 | private static final int XLARGE_TRANSITION_DURATION = 150; |
| 42 | private static final int XLARGE_ANIMATION_DURATION = 200; |
Michael Jurka | 577d017 | 2010-12-17 20:04:50 -0800 | [diff] [blame^] | 43 | private static final int LEFT_DRAWABLE = 0; |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 44 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 45 | private AnimationSet mInAnimation; |
| 46 | private AnimationSet mOutAnimation; |
| 47 | private Animation mHandleInAnimation; |
| 48 | private Animation mHandleOutAnimation; |
| 49 | |
| 50 | private int mOrientation; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 51 | private DragController mDragController; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 52 | |
Michael Jurka | 3adcb0c | 2010-10-15 18:07:21 -0700 | [diff] [blame] | 53 | private final RectF mRegionF = new RectF(); |
| 54 | private final Rect mRegion = new Rect(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 55 | private TransitionDrawable mTransition; |
Michael Jurka | 577d017 | 2010-12-17 20:04:50 -0800 | [diff] [blame^] | 56 | private int mTextColor; |
| 57 | private int mDragTextColor; |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 58 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 59 | public DeleteZone(Context context, AttributeSet attrs) { |
| 60 | this(context, attrs, 0); |
| 61 | } |
| 62 | |
| 63 | public DeleteZone(Context context, AttributeSet attrs, int defStyle) { |
| 64 | super(context, attrs, defStyle); |
| 65 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 66 | final int srcColor = context.getResources().getColor(R.color.delete_color_filter); |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 67 | mHoverPaint.setColorFilter(new PorterDuffColorFilter(srcColor, PorterDuff.Mode.SRC_ATOP)); |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 68 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 69 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DeleteZone, defStyle, 0); |
| 70 | mOrientation = a.getInt(R.styleable.DeleteZone_direction, ORIENTATION_HORIZONTAL); |
| 71 | a.recycle(); |
Winson Chung | be5212b | 2010-12-20 11:36:33 -0800 | [diff] [blame] | 72 | |
| 73 | int tb = getResources().getDimensionPixelSize(R.dimen.delete_zone_vertical_drag_padding); |
| 74 | int lr = getResources().getDimensionPixelSize(R.dimen.delete_zone_horizontal_drag_padding); |
| 75 | setDragPadding(tb, lr, tb, lr); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | @Override |
| 79 | protected void onFinishInflate() { |
| 80 | super.onFinishInflate(); |
Michael Jurka | 577d017 | 2010-12-17 20:04:50 -0800 | [diff] [blame^] | 81 | mTransition = (TransitionDrawable) getCompoundDrawables()[LEFT_DRAWABLE]; |
| 82 | if (LauncherApplication.isScreenXLarge()) { |
| 83 | mTransition.setCrossFadeEnabled(false); |
| 84 | } |
| 85 | |
| 86 | Resources r = getResources(); |
| 87 | mTextColor = r.getColor(R.color.workspace_all_apps_and_delete_zone_text_color); |
| 88 | mDragTextColor = r.getColor(R.color.workspace_delete_zone_drag_text_color); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset, |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 92 | DragView dragView, Object dragInfo) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 93 | return true; |
| 94 | } |
| 95 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 96 | public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset, |
| 97 | DragView dragView, Object dragInfo) { |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 98 | if (!mDragAndDropEnabled) return; |
| 99 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 100 | final ItemInfo item = (ItemInfo) dragInfo; |
| 101 | |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 102 | // On x-large screens, you can uninstall an app by dragging from all apps |
| 103 | if (item instanceof ApplicationInfo && LauncherApplication.isScreenXLarge()) { |
Patrick Dubroy | 5539af7 | 2010-09-07 15:22:01 -0700 | [diff] [blame] | 104 | mLauncher.startApplicationUninstallActivity((ApplicationInfo) item); |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 105 | } |
| 106 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 107 | if (item.container == -1) return; |
| 108 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 109 | if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { |
The Android Open Source Project | 7376fae | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 110 | if (item instanceof LauncherAppWidgetInfo) { |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 111 | mLauncher.removeAppWidget((LauncherAppWidgetInfo) item); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 112 | } |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 113 | } else if (source instanceof UserFolder) { |
| 114 | final UserFolder userFolder = (UserFolder) source; |
| 115 | final UserFolderInfo userFolderInfo = (UserFolderInfo) userFolder.getInfo(); |
| 116 | // Item must be a ShortcutInfo otherwise it couldn't have been in the folder |
| 117 | // in the first place. |
| 118 | userFolderInfo.remove((ShortcutInfo)item); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 119 | } |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 120 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 121 | if (item instanceof UserFolderInfo) { |
| 122 | final UserFolderInfo userFolderInfo = (UserFolderInfo)item; |
| 123 | LauncherModel.deleteUserFolderContentsFromDatabase(mLauncher, userFolderInfo); |
Joe Onorato | 9c1289c | 2009-08-17 11:03:03 -0400 | [diff] [blame] | 124 | mLauncher.removeFolder(userFolderInfo); |
The Android Open Source Project | 7376fae | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 125 | } else if (item instanceof LauncherAppWidgetInfo) { |
| 126 | final LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) item; |
| 127 | final LauncherAppWidgetHost appWidgetHost = mLauncher.getAppWidgetHost(); |
| 128 | if (appWidgetHost != null) { |
Brad Fitzpatrick | 73013bf | 2010-09-14 12:15:32 -0700 | [diff] [blame] | 129 | // Deleting an app widget ID is a void call but writes to disk before returning |
| 130 | // to the caller... |
| 131 | new Thread("deleteAppWidgetId") { |
| 132 | public void run() { |
| 133 | appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId); |
| 134 | } |
| 135 | }.start(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 136 | } |
| 137 | } |
Patrick Dubroy | bc6840b | 2010-09-01 11:54:27 -0700 | [diff] [blame] | 138 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 139 | LauncherModel.deleteItemFromDatabase(mLauncher, item); |
| 140 | } |
| 141 | |
| 142 | public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset, |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 143 | DragView dragView, Object dragInfo) { |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 144 | if (mDragAndDropEnabled) { |
| 145 | mTransition.reverseTransition(getTransitionAnimationDuration()); |
Michael Jurka | 577d017 | 2010-12-17 20:04:50 -0800 | [diff] [blame^] | 146 | setTextColor(mDragTextColor); |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 147 | super.onDragEnter(source, x, y, xOffset, yOffset, dragView, dragInfo); |
| 148 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset, |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 152 | DragView dragView, Object dragInfo) { |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 153 | if (mDragAndDropEnabled) { |
| 154 | mTransition.reverseTransition(getTransitionAnimationDuration()); |
Michael Jurka | 577d017 | 2010-12-17 20:04:50 -0800 | [diff] [blame^] | 155 | setTextColor(mTextColor); |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 156 | super.onDragExit(source, x, y, xOffset, yOffset, dragView, dragInfo); |
| 157 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 158 | } |
| 159 | |
Joe Onorato | 5162ea9 | 2009-09-03 09:39:42 -0700 | [diff] [blame] | 160 | public void onDragStart(DragSource source, Object info, int dragAction) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 161 | final ItemInfo item = (ItemInfo) info; |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 162 | if (item != null && mDragAndDropEnabled) { |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 163 | mActive = true; |
Michael Jurka | 3adcb0c | 2010-10-15 18:07:21 -0700 | [diff] [blame] | 164 | getHitRect(mRegion); |
| 165 | mRegionF.set(mRegion); |
| 166 | |
| 167 | if (LauncherApplication.isScreenXLarge()) { |
| 168 | // This region will be a "dead zone" for scrolling; make it extend to the edge of |
| 169 | // the screen so users don't accidentally trigger a scroll while deleting items |
| 170 | mRegionF.top = mLauncher.getWorkspace().getTop(); |
| 171 | mRegionF.right = mLauncher.getWorkspace().getRight(); |
| 172 | } |
| 173 | |
| 174 | mDragController.setDeleteRegion(mRegionF); |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 175 | |
| 176 | // Make sure the icon is set to the default drawable, not the hover drawable |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 177 | mTransition.resetTransition(); |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 178 | |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 179 | createAnimations(); |
| 180 | startAnimation(mInAnimation); |
Michael Jurka | b8e1447 | 2010-12-20 16:06:10 -0800 | [diff] [blame] | 181 | if (mOverlappingViews != null) { |
| 182 | for (View view : mOverlappingViews) { |
| 183 | view.startAnimation(mHandleOutAnimation); |
| 184 | } |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 185 | } |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 186 | setVisibility(VISIBLE); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 187 | } |
| 188 | } |
| 189 | |
| 190 | public void onDragEnd() { |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 191 | if (mActive && mDragAndDropEnabled) { |
| 192 | mActive = false; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 193 | mDragController.setDeleteRegion(null); |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 194 | |
| 195 | if (mOutAnimation != null) startAnimation(mOutAnimation); |
Michael Jurka | b8e1447 | 2010-12-20 16:06:10 -0800 | [diff] [blame] | 196 | if (mHandleInAnimation != null && mOverlappingViews != null) { |
| 197 | for (View view : mOverlappingViews) { |
| 198 | view.startAnimation(mHandleInAnimation); |
| 199 | } |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 200 | } |
Adam Cohen | cdc30d5 | 2010-12-01 15:09:47 -0800 | [diff] [blame] | 201 | setVisibility(GONE); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 202 | } |
| 203 | } |
| 204 | |
| 205 | private void createAnimations() { |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 206 | int duration = getAnimationDuration(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 207 | if (mHandleInAnimation == null) { |
Daniel Sandler | c9b1877 | 2010-04-22 14:37:59 -0400 | [diff] [blame] | 208 | mHandleInAnimation = new AlphaAnimation(0.0f, 1.0f); |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 209 | mHandleInAnimation.setDuration(duration); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 210 | } |
Adam Lesinski | 6b879f0 | 2010-11-04 16:15:23 -0700 | [diff] [blame] | 211 | |
| 212 | if (mInAnimation == null) { |
| 213 | mInAnimation = new FastAnimationSet(); |
| 214 | if (!LauncherApplication.isScreenXLarge()) { |
| 215 | final AnimationSet animationSet = mInAnimation; |
| 216 | animationSet.setInterpolator(new AccelerateInterpolator()); |
| 217 | animationSet.addAnimation(new AlphaAnimation(0.0f, 1.0f)); |
| 218 | if (mOrientation == ORIENTATION_HORIZONTAL) { |
| 219 | animationSet.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, 0.0f, |
| 220 | Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, |
| 221 | Animation.RELATIVE_TO_SELF, 0.0f)); |
| 222 | } else { |
| 223 | animationSet.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, |
| 224 | 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.ABSOLUTE, 0.0f, |
| 225 | Animation.ABSOLUTE, 0.0f)); |
| 226 | } |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 227 | animationSet.setDuration(duration); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 228 | } else { |
Adam Lesinski | 6b879f0 | 2010-11-04 16:15:23 -0700 | [diff] [blame] | 229 | mInAnimation.addAnimation(mHandleInAnimation); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 230 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 231 | } |
Adam Lesinski | 6b879f0 | 2010-11-04 16:15:23 -0700 | [diff] [blame] | 232 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 233 | if (mHandleOutAnimation == null) { |
Daniel Sandler | c9b1877 | 2010-04-22 14:37:59 -0400 | [diff] [blame] | 234 | mHandleOutAnimation = new AlphaAnimation(1.0f, 0.0f); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 235 | mHandleOutAnimation.setFillAfter(true); |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 236 | mHandleOutAnimation.setDuration(duration); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 237 | } |
Adam Lesinski | 6b879f0 | 2010-11-04 16:15:23 -0700 | [diff] [blame] | 238 | |
| 239 | if (mOutAnimation == null) { |
| 240 | mOutAnimation = new FastAnimationSet(); |
| 241 | if (!LauncherApplication.isScreenXLarge()) { |
| 242 | final AnimationSet animationSet = mOutAnimation; |
| 243 | animationSet.setInterpolator(new AccelerateInterpolator()); |
| 244 | animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f)); |
| 245 | if (mOrientation == ORIENTATION_HORIZONTAL) { |
| 246 | animationSet.addAnimation(new FastTranslateAnimation(Animation.ABSOLUTE, 0.0f, |
| 247 | Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, |
| 248 | Animation.RELATIVE_TO_SELF, 1.0f)); |
| 249 | } else { |
| 250 | animationSet.addAnimation(new FastTranslateAnimation(Animation.RELATIVE_TO_SELF, |
| 251 | 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.ABSOLUTE, 0.0f, |
| 252 | Animation.ABSOLUTE, 0.0f)); |
| 253 | } |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 254 | animationSet.setDuration(duration); |
Adam Lesinski | 6b879f0 | 2010-11-04 16:15:23 -0700 | [diff] [blame] | 255 | } else { |
| 256 | mOutAnimation.addAnimation(mHandleOutAnimation); |
| 257 | } |
| 258 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 259 | } |
| 260 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 261 | void setDragController(DragController dragController) { |
| 262 | mDragController = dragController; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 263 | } |
| 264 | |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 265 | private int getTransitionAnimationDuration() { |
| 266 | return LauncherApplication.isScreenXLarge() ? |
| 267 | XLARGE_TRANSITION_DURATION : TRANSITION_DURATION; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 268 | } |
| 269 | |
Winson Chung | 760e537 | 2010-12-15 13:14:23 -0800 | [diff] [blame] | 270 | private int getAnimationDuration() { |
| 271 | return LauncherApplication.isScreenXLarge() ? |
| 272 | XLARGE_ANIMATION_DURATION : ANIMATION_DURATION; |
Patrick Dubroy | dea9e93 | 2010-09-22 15:04:29 -0700 | [diff] [blame] | 273 | } |
| 274 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 275 | private static class FastTranslateAnimation extends TranslateAnimation { |
| 276 | public FastTranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, |
| 277 | int fromYType, float fromYValue, int toYType, float toYValue) { |
| 278 | super(fromXType, fromXValue, toXType, toXValue, |
| 279 | fromYType, fromYValue, toYType, toYValue); |
| 280 | } |
| 281 | |
| 282 | @Override |
| 283 | public boolean willChangeTransformationMatrix() { |
| 284 | return true; |
| 285 | } |
| 286 | |
| 287 | @Override |
| 288 | public boolean willChangeBounds() { |
| 289 | return false; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | private static class FastAnimationSet extends AnimationSet { |
| 294 | FastAnimationSet() { |
| 295 | super(false); |
| 296 | } |
| 297 | |
| 298 | @Override |
| 299 | public boolean willChangeTransformationMatrix() { |
| 300 | return true; |
| 301 | } |
| 302 | |
| 303 | @Override |
| 304 | public boolean willChangeBounds() { |
| 305 | return false; |
| 306 | } |
| 307 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 308 | } |