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 | |
Adam Cohen | 2801caf | 2011-05-13 20:57:39 -0700 | [diff] [blame] | 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
Adam Cohen | 2801caf | 2011-05-13 20:57:39 -0700 | [diff] [blame] | 21 | import android.animation.ValueAnimator; |
| 22 | import android.animation.ValueAnimator.AnimatorUpdateListener; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 23 | import android.content.Context; |
| 24 | import android.content.res.Resources; |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 25 | import android.graphics.Canvas; |
Adam Cohen | f4b0891 | 2011-05-17 18:45:47 -0700 | [diff] [blame] | 26 | import android.graphics.Color; |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 27 | import android.graphics.Paint; |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 28 | import android.graphics.PorterDuff; |
Adam Cohen | 3e8f811 | 2011-07-02 18:03:00 -0700 | [diff] [blame] | 29 | import android.graphics.Rect; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 30 | import android.graphics.drawable.Drawable; |
| 31 | import android.util.AttributeSet; |
| 32 | import android.view.LayoutInflater; |
Adam Cohen | 7c69321 | 2011-05-18 15:26:57 -0700 | [diff] [blame] | 33 | import android.view.View; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 34 | import android.view.ViewGroup; |
Adam Cohen | 3e8f811 | 2011-07-02 18:03:00 -0700 | [diff] [blame] | 35 | import android.view.animation.AccelerateInterpolator; |
| 36 | import android.view.animation.DecelerateInterpolator; |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 37 | import android.widget.ImageView; |
| 38 | import android.widget.LinearLayout; |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 39 | import android.widget.TextView; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 40 | |
Romain Guy | edcce09 | 2010-03-04 13:03:17 -0800 | [diff] [blame] | 41 | import com.android.launcher.R; |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 42 | import com.android.launcher2.DropTarget.DragObject; |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 43 | import com.android.launcher2.FolderInfo.FolderListener; |
Romain Guy | edcce09 | 2010-03-04 13:03:17 -0800 | [diff] [blame] | 44 | |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 45 | import java.util.ArrayList; |
| 46 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 47 | /** |
| 48 | * An icon that can appear on in the workspace representing an {@link UserFolder}. |
| 49 | */ |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 50 | public class FolderIcon extends LinearLayout implements FolderListener { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 51 | private Launcher mLauncher; |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 52 | Folder mFolder; |
| 53 | FolderInfo mInfo; |
| 54 | |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 55 | // The number of icons to display in the |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 56 | private static final int NUM_ITEMS_IN_PREVIEW = 3; |
Adam Cohen | f4b0891 | 2011-05-17 18:45:47 -0700 | [diff] [blame] | 57 | private static final int CONSUMPTION_ANIMATION_DURATION = 100; |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 58 | private static final int DROP_IN_ANIMATION_DURATION = 400; |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 59 | private static final int INITIAL_ITEM_ANIMATION_DURATION = 350; |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 60 | |
| 61 | // The degree to which the inner ring grows when accepting drop |
Adam Cohen | 69ce2e5 | 2011-07-03 19:25:21 -0700 | [diff] [blame] | 62 | private static final float INNER_RING_GROWTH_FACTOR = 0.15f; |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 63 | |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 64 | // The degree to which the outer ring is scaled in its natural state |
Adam Cohen | 69ce2e5 | 2011-07-03 19:25:21 -0700 | [diff] [blame] | 65 | private static final float OUTER_RING_GROWTH_FACTOR = 0.3f; |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 66 | |
| 67 | // The amount of vertical spread between items in the stack [0...1] |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 68 | private static final float PERSPECTIVE_SHIFT_FACTOR = 0.24f; |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 69 | |
| 70 | // The degree to which the item in the back of the stack is scaled [0...1] |
| 71 | // (0 means it's not scaled at all, 1 means it's scaled to nothing) |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 72 | private static final float PERSPECTIVE_SCALE_FACTOR = 0.35f; |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 73 | |
Adam Cohen | c51934b | 2011-07-26 21:07:43 -0700 | [diff] [blame] | 74 | public static Drawable sSharedFolderLeaveBehind = null; |
| 75 | |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 76 | private ImageView mPreviewBackground; |
| 77 | private BubbleTextView mFolderName; |
Adam Cohen | 073a46f | 2011-05-17 16:28:09 -0700 | [diff] [blame] | 78 | |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 79 | FolderRingAnimator mFolderRingAnimator = null; |
Adam Cohen | 2801caf | 2011-05-13 20:57:39 -0700 | [diff] [blame] | 80 | |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 81 | // These variables are all associated with the drawing of the preview; they are stored |
| 82 | // as member variables for shared usage and to avoid computation on each frame |
| 83 | private int mIntrinsicIconSize; |
| 84 | private float mBaselineIconScale; |
| 85 | private int mBaselineIconSize; |
| 86 | private int mAvailableSpaceInPreview; |
| 87 | private int mTotalWidth = -1; |
| 88 | private int mPreviewOffsetX; |
| 89 | private int mPreviewOffsetY; |
| 90 | private float mMaxPerspectiveShift; |
| 91 | boolean mAnimating = false; |
| 92 | private PreviewItemDrawingParams mParams = new PreviewItemDrawingParams(0, 0, 0, 0); |
| 93 | private PreviewItemDrawingParams mAnimParams = new PreviewItemDrawingParams(0, 0, 0, 0); |
| 94 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 95 | public FolderIcon(Context context, AttributeSet attrs) { |
| 96 | super(context, attrs); |
| 97 | } |
| 98 | |
| 99 | public FolderIcon(Context context) { |
| 100 | super(context); |
| 101 | } |
| 102 | |
Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 103 | public boolean isDropEnabled() { |
Winson Chung | 7a1d165 | 2011-03-18 15:56:01 -0700 | [diff] [blame] | 104 | final ViewGroup cellLayoutChildren = (ViewGroup) getParent(); |
| 105 | final ViewGroup cellLayout = (ViewGroup) cellLayoutChildren.getParent(); |
| 106 | final Workspace workspace = (Workspace) cellLayout.getParent(); |
| 107 | return !workspace.isSmall(); |
Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 108 | } |
| 109 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 110 | static FolderIcon fromXml(int resId, Launcher launcher, ViewGroup group, |
Adam Cohen | df2cc41 | 2011-04-27 16:56:57 -0700 | [diff] [blame] | 111 | FolderInfo folderInfo, IconCache iconCache) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 112 | |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 113 | if (INITIAL_ITEM_ANIMATION_DURATION >= DROP_IN_ANIMATION_DURATION) { |
| 114 | throw new IllegalStateException("DROP_IN_ANIMATION_DURATION must be greater than " + |
| 115 | "INITIAL_ITEM_ANIMATION_DURATION, as sequencing of adding first two items " + |
| 116 | "is dependent on this"); |
| 117 | } |
| 118 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 119 | FolderIcon icon = (FolderIcon) LayoutInflater.from(launcher).inflate(resId, group, false); |
| 120 | |
Adam Cohen | d2eca6b | 2011-07-26 22:49:13 -0700 | [diff] [blame] | 121 | icon.mFolderName = (BubbleTextView) icon.findViewById(R.id.folder_icon_name); |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 122 | icon.mFolderName.setText(folderInfo.title); |
| 123 | icon.mPreviewBackground = (ImageView) icon.findViewById(R.id.preview_background); |
Winson Chung | 6a0f57d | 2011-06-29 20:10:49 -0700 | [diff] [blame] | 124 | icon.mPreviewBackground.setContentDescription(folderInfo.title); |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 125 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 126 | icon.setTag(folderInfo); |
| 127 | icon.setOnClickListener(launcher); |
| 128 | icon.mInfo = folderInfo; |
| 129 | icon.mLauncher = launcher; |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 130 | |
| 131 | Folder folder = Folder.fromXml(launcher); |
| 132 | folder.setDragController(launcher.getDragController()); |
Adam Cohen | 2801caf | 2011-05-13 20:57:39 -0700 | [diff] [blame] | 133 | folder.setFolderIcon(icon); |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 134 | folder.bind(folderInfo); |
| 135 | icon.mFolder = folder; |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 136 | icon.mFolderRingAnimator = new FolderRingAnimator(launcher, icon); |
Adam Cohen | 69ce2e5 | 2011-07-03 19:25:21 -0700 | [diff] [blame] | 137 | |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 138 | folderInfo.addListener(icon); |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 139 | |
Adam Cohen | c51934b | 2011-07-26 21:07:43 -0700 | [diff] [blame] | 140 | Resources res = launcher.getResources(); |
| 141 | if (sSharedFolderLeaveBehind == null) { |
| 142 | sSharedFolderLeaveBehind = res.getDrawable(R.drawable.portal_ring_rest); |
| 143 | } |
| 144 | |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 145 | return icon; |
| 146 | } |
| 147 | |
| 148 | public static class FolderRingAnimator { |
Adam Cohen | 69ce2e5 | 2011-07-03 19:25:21 -0700 | [diff] [blame] | 149 | public int mCellX; |
| 150 | public int mCellY; |
| 151 | private CellLayout mCellLayout; |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 152 | public float mOuterRingSize; |
| 153 | public float mInnerRingSize; |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 154 | public FolderIcon mFolderIcon = null; |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 155 | public Drawable mOuterRingDrawable = null; |
| 156 | public Drawable mInnerRingDrawable = null; |
| 157 | public static Drawable sSharedOuterRingDrawable = null; |
| 158 | public static Drawable sSharedInnerRingDrawable = null; |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 159 | public static int sPreviewSize = -1; |
| 160 | public static int sPreviewPadding = -1; |
| 161 | |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 162 | private ValueAnimator mAcceptAnimator; |
| 163 | private ValueAnimator mNeutralAnimator; |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 164 | |
| 165 | public FolderRingAnimator(Launcher launcher, FolderIcon folderIcon) { |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 166 | mFolderIcon = folderIcon; |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 167 | Resources res = launcher.getResources(); |
| 168 | mOuterRingDrawable = res.getDrawable(R.drawable.portal_ring_outer_holo); |
| 169 | mInnerRingDrawable = res.getDrawable(R.drawable.portal_ring_inner_holo); |
| 170 | |
| 171 | if (sPreviewSize < 0 || sPreviewPadding < 0) { |
| 172 | sPreviewSize = res.getDimensionPixelSize(R.dimen.folder_preview_size); |
| 173 | sPreviewPadding = res.getDimensionPixelSize(R.dimen.folder_preview_padding); |
| 174 | } |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 175 | if (sSharedOuterRingDrawable == null) { |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 176 | sSharedOuterRingDrawable = res.getDrawable(R.drawable.portal_ring_outer_holo); |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 177 | } |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 178 | if (sSharedInnerRingDrawable == null) { |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 179 | sSharedInnerRingDrawable = res.getDrawable(R.drawable.portal_ring_inner_holo); |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 180 | } |
Adam Cohen | 073a46f | 2011-05-17 16:28:09 -0700 | [diff] [blame] | 181 | } |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 182 | |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 183 | public void animateToAcceptState() { |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 184 | if (mNeutralAnimator != null) { |
| 185 | mNeutralAnimator.cancel(); |
| 186 | } |
| 187 | mAcceptAnimator = ValueAnimator.ofFloat(0f, 1f); |
| 188 | mAcceptAnimator.setDuration(CONSUMPTION_ANIMATION_DURATION); |
| 189 | mAcceptAnimator.addUpdateListener(new AnimatorUpdateListener() { |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 190 | public void onAnimationUpdate(ValueAnimator animation) { |
| 191 | final float percent = (Float) animation.getAnimatedValue(); |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 192 | mOuterRingSize = (1 + percent * OUTER_RING_GROWTH_FACTOR) * sPreviewSize; |
| 193 | mInnerRingSize = (1 + percent * INNER_RING_GROWTH_FACTOR) * sPreviewSize; |
Adam Cohen | 69ce2e5 | 2011-07-03 19:25:21 -0700 | [diff] [blame] | 194 | if (mCellLayout != null) { |
| 195 | mCellLayout.invalidate(); |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | }); |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 199 | mAcceptAnimator.addListener(new AnimatorListenerAdapter() { |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 200 | @Override |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 201 | public void onAnimationStart(Animator animation) { |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 202 | if (mFolderIcon != null) { |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 203 | mFolderIcon.mPreviewBackground.setVisibility(INVISIBLE); |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | }); |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 207 | mAcceptAnimator.start(); |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | public void animateToNaturalState() { |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 211 | if (mAcceptAnimator != null) { |
| 212 | mAcceptAnimator.cancel(); |
| 213 | } |
| 214 | mNeutralAnimator = ValueAnimator.ofFloat(0f, 1f); |
| 215 | mNeutralAnimator.setDuration(CONSUMPTION_ANIMATION_DURATION); |
| 216 | mNeutralAnimator.addUpdateListener(new AnimatorUpdateListener() { |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 217 | public void onAnimationUpdate(ValueAnimator animation) { |
| 218 | final float percent = (Float) animation.getAnimatedValue(); |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 219 | mOuterRingSize = (1 + (1 - percent) * OUTER_RING_GROWTH_FACTOR) * sPreviewSize; |
| 220 | mInnerRingSize = (1 + (1 - percent) * INNER_RING_GROWTH_FACTOR) * sPreviewSize; |
Adam Cohen | 69ce2e5 | 2011-07-03 19:25:21 -0700 | [diff] [blame] | 221 | if (mCellLayout != null) { |
| 222 | mCellLayout.invalidate(); |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 223 | } |
| 224 | } |
| 225 | }); |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 226 | mNeutralAnimator.addListener(new AnimatorListenerAdapter() { |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 227 | @Override |
| 228 | public void onAnimationEnd(Animator animation) { |
Adam Cohen | 69ce2e5 | 2011-07-03 19:25:21 -0700 | [diff] [blame] | 229 | if (mCellLayout != null) { |
| 230 | mCellLayout.hideFolderAccept(FolderRingAnimator.this); |
| 231 | } |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 232 | if (mFolderIcon != null) { |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 233 | mFolderIcon.mPreviewBackground.setVisibility(VISIBLE); |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 234 | } |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 235 | } |
| 236 | }); |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 237 | mNeutralAnimator.start(); |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 240 | // Location is expressed in window coordinates |
Adam Cohen | 69ce2e5 | 2011-07-03 19:25:21 -0700 | [diff] [blame] | 241 | public void getCell(int[] loc) { |
| 242 | loc[0] = mCellX; |
| 243 | loc[1] = mCellY; |
| 244 | } |
| 245 | |
| 246 | // Location is expressed in window coordinates |
| 247 | public void setCell(int x, int y) { |
| 248 | mCellX = x; |
| 249 | mCellY = y; |
| 250 | } |
| 251 | |
| 252 | public void setCellLayout(CellLayout layout) { |
| 253 | mCellLayout = layout; |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 256 | public float getOuterRingSize() { |
| 257 | return mOuterRingSize; |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 258 | } |
| 259 | |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 260 | public float getInnerRingSize() { |
| 261 | return mInnerRingSize; |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 262 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 263 | } |
| 264 | |
Adam Cohen | 073a46f | 2011-05-17 16:28:09 -0700 | [diff] [blame] | 265 | private boolean willAcceptItem(ItemInfo item) { |
| 266 | final int itemType = item.itemType; |
| 267 | return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION || |
| 268 | itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) && |
Adam Cohen | c51934b | 2011-07-26 21:07:43 -0700 | [diff] [blame] | 269 | !mFolder.isFull() && item != mInfo && !mInfo.opened); |
Adam Cohen | 073a46f | 2011-05-17 16:28:09 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 272 | public boolean acceptDrop(Object dragInfo) { |
| 273 | final ItemInfo item = (ItemInfo) dragInfo; |
Adam Cohen | 073a46f | 2011-05-17 16:28:09 -0700 | [diff] [blame] | 274 | return willAcceptItem(item); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 275 | } |
| 276 | |
Adam Cohen | df03538 | 2011-04-11 17:22:04 -0700 | [diff] [blame] | 277 | public void addItem(ShortcutInfo item) { |
| 278 | mInfo.add(item); |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 279 | LauncherModel.addOrMoveItemInDatabase(mLauncher, item, mInfo.id, 0, item.cellX, item.cellY); |
Adam Cohen | df03538 | 2011-04-11 17:22:04 -0700 | [diff] [blame] | 280 | } |
| 281 | |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 282 | public void onDragEnter(Object dragInfo) { |
| 283 | if (!willAcceptItem((ItemInfo) dragInfo)) return; |
Adam Cohen | 69ce2e5 | 2011-07-03 19:25:21 -0700 | [diff] [blame] | 284 | CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams(); |
| 285 | CellLayout layout = (CellLayout) getParent().getParent(); |
| 286 | mFolderRingAnimator.setCell(lp.cellX, lp.cellY); |
| 287 | mFolderRingAnimator.setCellLayout(layout); |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 288 | mFolderRingAnimator.animateToAcceptState(); |
Adam Cohen | 69ce2e5 | 2011-07-03 19:25:21 -0700 | [diff] [blame] | 289 | layout.showFolderAccept(mFolderRingAnimator); |
Adam Cohen | 073a46f | 2011-05-17 16:28:09 -0700 | [diff] [blame] | 290 | } |
| 291 | |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 292 | public void onDragOver(Object dragInfo) { |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 293 | } |
| 294 | |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 295 | public void performCreateAnimation(final ShortcutInfo destInfo, final View destView, |
Winson Chung | 557d6ed | 2011-07-08 15:34:52 -0700 | [diff] [blame] | 296 | final ShortcutInfo srcInfo, final View srcView, Rect dstRect, |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 297 | float scaleRelativeToDragLayer, Runnable postAnimationRunnable) { |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 298 | |
| 299 | Drawable animateDrawable = ((TextView) destView).getCompoundDrawables()[1]; |
| 300 | computePreviewDrawingParams(animateDrawable.getIntrinsicWidth(), destView.getMeasuredWidth()); |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 301 | |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 302 | // This will animate the dragView (srcView) into the new folder |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 303 | onDrop(srcInfo, srcView, dstRect, scaleRelativeToDragLayer, 1, postAnimationRunnable); |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 304 | |
| 305 | // This will animate the first item from it's position as an icon into its |
| 306 | // position as the first item in the preview |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 307 | animateFirstItem(animateDrawable, INITIAL_ITEM_ANIMATION_DURATION); |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 308 | |
| 309 | postDelayed(new Runnable() { |
| 310 | public void run() { |
| 311 | addItem(destInfo); |
| 312 | } |
| 313 | }, INITIAL_ITEM_ANIMATION_DURATION); |
| 314 | } |
| 315 | |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 316 | public void onDragExit(Object dragInfo) { |
| 317 | if (!willAcceptItem((ItemInfo) dragInfo)) return; |
Adam Cohen | 19072da | 2011-05-31 14:30:45 -0700 | [diff] [blame] | 318 | mFolderRingAnimator.animateToNaturalState(); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 319 | } |
Patrick Dubroy | 440c360 | 2010-07-13 17:50:32 -0700 | [diff] [blame] | 320 | |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 321 | private void onDrop(final ShortcutInfo item, View animateView, Rect finalRect, |
| 322 | float scaleRelativeToDragLayer, int index, Runnable postAnimationRunnable) { |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 323 | item.cellX = -1; |
| 324 | item.cellY = -1; |
| 325 | DragLayer dragLayer = mLauncher.getDragLayer(); |
| 326 | Rect from = new Rect(); |
| 327 | dragLayer.getViewRectRelativeToSelf(animateView, from); |
| 328 | Rect to = finalRect; |
| 329 | if (to == null) { |
| 330 | to = new Rect(); |
Adam Cohen | 4b285c5 | 2011-07-21 14:24:06 -0700 | [diff] [blame] | 331 | Workspace workspace = mLauncher.getWorkspace(); |
Adam Cohen | 67bd9cc | 2011-07-29 14:07:04 -0700 | [diff] [blame^] | 332 | // Set cellLayout and this to it's final state to compute final animation locations |
Adam Cohen | 4b285c5 | 2011-07-21 14:24:06 -0700 | [diff] [blame] | 333 | workspace.setFinalTransitionTransform((CellLayout) getParent().getParent()); |
Adam Cohen | 67bd9cc | 2011-07-29 14:07:04 -0700 | [diff] [blame^] | 334 | float scaleX = getScaleX(); |
| 335 | float scaleY = getScaleY(); |
| 336 | setScaleX(1.0f); |
| 337 | setScaleY(1.0f); |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 338 | scaleRelativeToDragLayer = dragLayer.getDescendantRectRelativeToSelf(this, to); |
Adam Cohen | 67bd9cc | 2011-07-29 14:07:04 -0700 | [diff] [blame^] | 339 | // Finished computing final animation locations, restore current state |
| 340 | setScaleX(scaleX); |
| 341 | setScaleY(scaleY); |
Adam Cohen | 4b285c5 | 2011-07-21 14:24:06 -0700 | [diff] [blame] | 342 | workspace.resetTransitionTransform((CellLayout) getParent().getParent()); |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 345 | int[] center = new int[2]; |
| 346 | float scale = getLocalCenterForIndex(index, center); |
| 347 | center[0] = (int) Math.round(scaleRelativeToDragLayer * center[0]); |
| 348 | center[1] = (int) Math.round(scaleRelativeToDragLayer * center[1]); |
| 349 | |
| 350 | to.offset(center[0] - animateView.getMeasuredWidth() / 2, |
| 351 | center[1] - animateView.getMeasuredHeight() / 2); |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 352 | |
| 353 | float finalAlpha = index < NUM_ITEMS_IN_PREVIEW ? 0.5f : 0f; |
| 354 | |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 355 | dragLayer.animateView(animateView, from, to, finalAlpha, scale * scaleRelativeToDragLayer, |
| 356 | DROP_IN_ANIMATION_DURATION, new DecelerateInterpolator(2), |
| 357 | new AccelerateInterpolator(2), postAnimationRunnable, false); |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 358 | postDelayed(new Runnable() { |
| 359 | public void run() { |
| 360 | addItem(item); |
| 361 | } |
| 362 | }, DROP_IN_ANIMATION_DURATION); |
| 363 | } |
| 364 | |
Adam Cohen | 3e8f811 | 2011-07-02 18:03:00 -0700 | [diff] [blame] | 365 | public void onDrop(DragObject d) { |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 366 | ShortcutInfo item; |
Adam Cohen | 3e8f811 | 2011-07-02 18:03:00 -0700 | [diff] [blame] | 367 | if (d.dragInfo instanceof ApplicationInfo) { |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 368 | // Came from all apps -- make a copy |
Adam Cohen | 3e8f811 | 2011-07-02 18:03:00 -0700 | [diff] [blame] | 369 | item = ((ApplicationInfo) d.dragInfo).makeShortcut(); |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 370 | } else { |
Adam Cohen | 3e8f811 | 2011-07-02 18:03:00 -0700 | [diff] [blame] | 371 | item = (ShortcutInfo) d.dragInfo; |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 372 | } |
Adam Cohen | 67bd9cc | 2011-07-29 14:07:04 -0700 | [diff] [blame^] | 373 | mFolder.notifyDrop(); |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 374 | onDrop(item, d.dragView, null, 1.0f, mInfo.contents.size(), d.postAnimationRunnable); |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 375 | } |
| 376 | |
Adam Cohen | cb3382b | 2011-05-24 14:07:08 -0700 | [diff] [blame] | 377 | public DropTarget getDropTargetDelegate(DragObject d) { |
Patrick Dubroy | 440c360 | 2010-07-13 17:50:32 -0700 | [diff] [blame] | 378 | return null; |
| 379 | } |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 380 | |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 381 | private void computePreviewDrawingParams(int drawableSize, int totalSize) { |
| 382 | if (mIntrinsicIconSize != drawableSize || mTotalWidth != totalSize) { |
| 383 | mIntrinsicIconSize = drawableSize; |
| 384 | mTotalWidth = totalSize; |
| 385 | |
| 386 | final int previewSize = FolderRingAnimator.sPreviewSize; |
| 387 | final int previewPadding = FolderRingAnimator.sPreviewPadding; |
| 388 | |
| 389 | mAvailableSpaceInPreview = (previewSize - 2 * previewPadding); |
| 390 | // cos(45) = 0.707 + ~= 0.1) = 0.8f |
| 391 | int adjustedAvailableSpace = (int) ((mAvailableSpaceInPreview / 2) * (1 + 0.8f)); |
| 392 | |
| 393 | int unscaledHeight = (int) (mIntrinsicIconSize * (1 + PERSPECTIVE_SHIFT_FACTOR)); |
| 394 | mBaselineIconScale = (1.0f * adjustedAvailableSpace / unscaledHeight); |
| 395 | |
| 396 | mBaselineIconSize = (int) (mIntrinsicIconSize * mBaselineIconScale); |
| 397 | mMaxPerspectiveShift = mBaselineIconSize * PERSPECTIVE_SHIFT_FACTOR; |
| 398 | |
| 399 | mPreviewOffsetX = (mTotalWidth - mAvailableSpaceInPreview) / 2; |
| 400 | mPreviewOffsetY = previewPadding; |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | private void computePreviewDrawingParams(Drawable d) { |
| 405 | computePreviewDrawingParams(d.getIntrinsicWidth(), getMeasuredWidth()); |
| 406 | } |
| 407 | |
| 408 | class PreviewItemDrawingParams { |
| 409 | PreviewItemDrawingParams(float transX, float transY, float scale, int overlayAlpha) { |
| 410 | this.transX = transX; |
| 411 | this.transY = transY; |
| 412 | this.scale = scale; |
| 413 | this.overlayAlpha = overlayAlpha; |
| 414 | } |
| 415 | float transX; |
| 416 | float transY; |
| 417 | float scale; |
| 418 | int overlayAlpha; |
| 419 | Drawable drawable; |
| 420 | } |
| 421 | |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 422 | private float getLocalCenterForIndex(int index, int[] center) { |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 423 | mParams = computePreviewItemDrawingParams(Math.min(NUM_ITEMS_IN_PREVIEW, index), mParams); |
| 424 | |
| 425 | mParams.transX += mPreviewOffsetX; |
| 426 | mParams.transY += mPreviewOffsetY; |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 427 | float offsetX = mParams.transX + (mParams.scale * mIntrinsicIconSize) / 2; |
| 428 | float offsetY = mParams.transY + (mParams.scale * mIntrinsicIconSize) / 2; |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 429 | |
Adam Cohen | ac8c876 | 2011-07-13 11:15:27 -0700 | [diff] [blame] | 430 | center[0] = (int) Math.round(offsetX); |
| 431 | center[1] = (int) Math.round(offsetY); |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 432 | return mParams.scale; |
| 433 | } |
| 434 | |
| 435 | private PreviewItemDrawingParams computePreviewItemDrawingParams(int index, |
| 436 | PreviewItemDrawingParams params) { |
| 437 | index = NUM_ITEMS_IN_PREVIEW - index - 1; |
| 438 | float r = (index * 1.0f) / (NUM_ITEMS_IN_PREVIEW - 1); |
| 439 | float scale = (1 - PERSPECTIVE_SCALE_FACTOR * (1 - r)); |
| 440 | |
| 441 | float offset = (1 - r) * mMaxPerspectiveShift; |
| 442 | float scaledSize = scale * mBaselineIconSize; |
| 443 | float scaleOffsetCorrection = (1 - scale) * mBaselineIconSize; |
| 444 | |
| 445 | // We want to imagine our coordinates from the bottom left, growing up and to the |
| 446 | // right. This is natural for the x-axis, but for the y-axis, we have to invert things. |
| 447 | float transY = mAvailableSpaceInPreview - (offset + scaledSize + scaleOffsetCorrection); |
| 448 | float transX = offset + scaleOffsetCorrection; |
| 449 | float totalScale = mBaselineIconScale * scale; |
| 450 | final int overlayAlpha = (int) (80 * (1 - r)); |
| 451 | |
| 452 | if (params == null) { |
| 453 | params = new PreviewItemDrawingParams(transX, transY, totalScale, overlayAlpha); |
| 454 | } else { |
| 455 | params.transX = transX; |
| 456 | params.transY = transY; |
| 457 | params.scale = totalScale; |
| 458 | params.overlayAlpha = overlayAlpha; |
| 459 | } |
| 460 | return params; |
| 461 | } |
| 462 | |
| 463 | private void drawPreviewItem(Canvas canvas, PreviewItemDrawingParams params) { |
| 464 | canvas.save(); |
| 465 | canvas.translate(params.transX + mPreviewOffsetX, params.transY + mPreviewOffsetY); |
| 466 | canvas.scale(params.scale, params.scale); |
| 467 | Drawable d = params.drawable; |
| 468 | |
| 469 | if (d != null) { |
| 470 | d.setBounds(0, 0, mIntrinsicIconSize, mIntrinsicIconSize); |
| 471 | d.setFilterBitmap(true); |
| 472 | d.setColorFilter(Color.argb(params.overlayAlpha, 0, 0, 0), PorterDuff.Mode.SRC_ATOP); |
| 473 | d.draw(canvas); |
| 474 | d.clearColorFilter(); |
| 475 | d.setFilterBitmap(false); |
| 476 | } |
| 477 | canvas.restore(); |
| 478 | } |
| 479 | |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 480 | @Override |
Adam Cohen | c0dcf59 | 2011-06-01 15:30:43 -0700 | [diff] [blame] | 481 | protected void dispatchDraw(Canvas canvas) { |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 482 | super.dispatchDraw(canvas); |
| 483 | |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 484 | if (mFolder == null) return; |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 485 | if (mFolder.getItemCount() == 0 && !mAnimating) return; |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 486 | |
Adam Cohen | 76078c4 | 2011-06-09 15:06:52 -0700 | [diff] [blame] | 487 | ArrayList<View> items = mFolder.getItemsInReadingOrder(false); |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 488 | Drawable d; |
| 489 | TextView v; |
Adam Cohen | badf71e | 2011-05-26 19:08:29 -0700 | [diff] [blame] | 490 | |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 491 | // Update our drawing parameters if necessary |
| 492 | if (mAnimating) { |
| 493 | computePreviewDrawingParams(mAnimParams.drawable); |
| 494 | } else { |
| 495 | v = (TextView) items.get(0); |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 496 | d = v.getCompoundDrawables()[1]; |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 497 | computePreviewDrawingParams(d); |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 498 | } |
Adam Cohen | d044526 | 2011-07-04 23:53:22 -0700 | [diff] [blame] | 499 | |
| 500 | int nItemsInPreview = Math.min(items.size(), NUM_ITEMS_IN_PREVIEW); |
| 501 | if (!mAnimating) { |
| 502 | for (int i = nItemsInPreview - 1; i >= 0; i--) { |
| 503 | v = (TextView) items.get(i); |
| 504 | d = v.getCompoundDrawables()[1]; |
| 505 | |
| 506 | mParams = computePreviewItemDrawingParams(i, mParams); |
| 507 | mParams.drawable = d; |
| 508 | drawPreviewItem(canvas, mParams); |
| 509 | } |
| 510 | } else { |
| 511 | drawPreviewItem(canvas, mAnimParams); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | private void animateFirstItem(final Drawable d, int duration) { |
| 516 | computePreviewDrawingParams(d); |
| 517 | final PreviewItemDrawingParams finalParams = computePreviewItemDrawingParams(0, null); |
| 518 | |
| 519 | final float scale0 = 1.0f; |
| 520 | final float transX0 = 0; |
| 521 | final float transY0 = 0; |
| 522 | mAnimParams.drawable = d; |
| 523 | |
| 524 | ValueAnimator va = ValueAnimator.ofFloat(0f, 1.0f); |
| 525 | va.addUpdateListener(new AnimatorUpdateListener(){ |
| 526 | public void onAnimationUpdate(ValueAnimator animation) { |
| 527 | float progress = (Float) animation.getAnimatedValue(); |
| 528 | |
| 529 | mAnimParams.transX = transX0 + progress * (finalParams.transX - transX0); |
| 530 | mAnimParams.transY = transY0 + progress * (finalParams.transY - transY0); |
| 531 | mAnimParams.scale = scale0 + progress * (finalParams.scale - scale0); |
| 532 | invalidate(); |
| 533 | } |
| 534 | }); |
| 535 | va.addListener(new AnimatorListenerAdapter() { |
| 536 | @Override |
| 537 | public void onAnimationStart(Animator animation) { |
| 538 | mAnimating = true; |
| 539 | } |
| 540 | @Override |
| 541 | public void onAnimationEnd(Animator animation) { |
| 542 | mAnimating = false; |
| 543 | } |
| 544 | }); |
| 545 | va.setDuration(duration); |
| 546 | va.start(); |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 547 | } |
| 548 | |
Adam Cohen | 76078c4 | 2011-06-09 15:06:52 -0700 | [diff] [blame] | 549 | public void onItemsChanged() { |
| 550 | invalidate(); |
| 551 | requestLayout(); |
| 552 | } |
| 553 | |
Adam Cohen | a9cf38f | 2011-05-02 15:36:58 -0700 | [diff] [blame] | 554 | public void onAdd(ShortcutInfo item) { |
| 555 | invalidate(); |
| 556 | requestLayout(); |
| 557 | } |
| 558 | |
| 559 | public void onRemove(ShortcutInfo item) { |
| 560 | invalidate(); |
| 561 | requestLayout(); |
| 562 | } |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 563 | |
| 564 | public void onTitleChanged(CharSequence title) { |
Adam Cohen | d63cfa9 | 2011-06-24 14:17:17 -0700 | [diff] [blame] | 565 | mFolderName.setText(title.toString()); |
Winson Chung | 6a0f57d | 2011-06-29 20:10:49 -0700 | [diff] [blame] | 566 | mPreviewBackground.setContentDescription(title.toString()); |
Adam Cohen | 76fc085 | 2011-06-17 13:26:23 -0700 | [diff] [blame] | 567 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 568 | } |