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