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