Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Daniel Sandler | 325dc23 | 2013-06-05 22:57:57 -0400 | [diff] [blame] | 17 | package com.android.launcher3; |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 18 | |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 19 | import android.animation.AnimatorSet; |
| 20 | import android.animation.FloatArrayEvaluator; |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 21 | import android.animation.ObjectAnimator; |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 22 | import android.animation.ValueAnimator; |
| 23 | import android.animation.ValueAnimator.AnimatorUpdateListener; |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 24 | import android.annotation.TargetApi; |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 25 | import android.content.Context; |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 26 | import android.content.res.ColorStateList; |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 27 | import android.graphics.ColorMatrix; |
| 28 | import android.graphics.ColorMatrixColorFilter; |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 29 | import android.graphics.PointF; |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 30 | import android.graphics.Rect; |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 31 | import android.graphics.drawable.Drawable; |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 32 | import android.os.Build; |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 33 | import android.util.AttributeSet; |
Fabrice Di Meglio | d6a33c6 | 2013-02-06 15:40:46 -0800 | [diff] [blame] | 34 | import android.view.View; |
Sunny Goyal | 1a70cef | 2015-04-22 11:29:51 -0700 | [diff] [blame] | 35 | import android.view.View.OnClickListener; |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 36 | import android.view.ViewGroup; |
Sunny Goyal | e78e3d7 | 2015-09-24 11:23:31 -0700 | [diff] [blame^] | 37 | import android.view.accessibility.AccessibilityEvent; |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 38 | import android.view.animation.DecelerateInterpolator; |
| 39 | import android.view.animation.LinearInterpolator; |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 40 | import android.widget.TextView; |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 41 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 42 | import com.android.launcher3.util.Thunk; |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Implements a DropTarget. |
| 46 | */ |
Sunny Goyal | 1a70cef | 2015-04-22 11:29:51 -0700 | [diff] [blame] | 47 | public abstract class ButtonDropTarget extends TextView |
| 48 | implements DropTarget, DragController.DragListener, OnClickListener { |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 49 | |
| 50 | private static int DRAG_VIEW_DROP_DURATION = 285; |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 51 | |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 52 | protected Launcher mLauncher; |
Winson Chung | a62e9fd | 2011-07-11 15:20:48 -0700 | [diff] [blame] | 53 | private int mBottomDragPadding; |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 54 | protected SearchDropTargetBar mSearchDropTargetBar; |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 55 | |
| 56 | /** Whether this drop target is active for the current drag */ |
| 57 | protected boolean mActive; |
| 58 | |
| 59 | /** The paint applied to the drag view on hover */ |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 60 | protected int mHoverColor = 0; |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 61 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 62 | protected ColorStateList mOriginalTextColor; |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 63 | protected Drawable mDrawable; |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 64 | |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 65 | private AnimatorSet mCurrentColorAnim; |
Sunny Goyal | 316490e | 2015-06-02 09:38:28 -0700 | [diff] [blame] | 66 | @Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter; |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 67 | |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 68 | |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 69 | public ButtonDropTarget(Context context, AttributeSet attrs) { |
| 70 | this(context, attrs, 0); |
| 71 | } |
| 72 | |
| 73 | public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) { |
| 74 | super(context, attrs, defStyle); |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 75 | mBottomDragPadding = getResources().getDimensionPixelSize(R.dimen.drop_target_drag_padding); |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 78 | @Override |
| 79 | protected void onFinishInflate() { |
| 80 | super.onFinishInflate(); |
| 81 | mOriginalTextColor = getTextColors(); |
| 82 | |
| 83 | // Remove the text in the Phone UI in landscape |
Winson Chung | 7501adf | 2015-06-02 11:24:28 -0700 | [diff] [blame] | 84 | DeviceProfile grid = ((Launcher) getContext()).getDeviceProfile(); |
| 85 | if (grid.isVerticalBarLayout()) { |
| 86 | setText(""); |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 87 | } |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Sunny Goyal | 7066003 | 2015-05-14 00:07:08 -0700 | [diff] [blame] | 90 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 91 | protected void setDrawable(int resId) { |
Sunny Goyal | e0cab30 | 2015-05-20 16:40:30 -0700 | [diff] [blame] | 92 | // We do not set the drawable in the xml as that inflates two drawables corresponding to |
| 93 | // drawableLeft and drawableStart. |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 94 | mDrawable = getResources().getDrawable(resId); |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 95 | |
Sunny Goyal | 9fc953b | 2015-08-17 12:24:25 -0700 | [diff] [blame] | 96 | if (Utilities.ATLEAST_JB_MR1) { |
Sunny Goyal | e0cab30 | 2015-05-20 16:40:30 -0700 | [diff] [blame] | 97 | setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null); |
| 98 | } else { |
| 99 | setCompoundDrawablesWithIntrinsicBounds(mDrawable, null, null, null); |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 100 | } |
| 101 | } |
| 102 | |
| 103 | public void setLauncher(Launcher launcher) { |
| 104 | mLauncher = launcher; |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Adam Cohen | d4d7aa5 | 2011-07-19 21:47:37 -0700 | [diff] [blame] | 107 | public void setSearchDropTargetBar(SearchDropTargetBar searchDropTargetBar) { |
| 108 | mSearchDropTargetBar = searchDropTargetBar; |
| 109 | } |
| 110 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 111 | @Override |
Sunny Goyal | ddec734 | 2015-04-29 18:12:37 -0700 | [diff] [blame] | 112 | public void onFlingToDelete(DragObject d, PointF vec) { } |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 113 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 114 | @Override |
| 115 | public final void onDragEnter(DragObject d) { |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 116 | d.dragView.setColor(mHoverColor); |
Sunny Goyal | 9fc953b | 2015-08-17 12:24:25 -0700 | [diff] [blame] | 117 | if (Utilities.ATLEAST_LOLLIPOP) { |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 118 | animateTextColor(mHoverColor); |
| 119 | } else { |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 120 | if (mCurrentFilter == null) { |
| 121 | mCurrentFilter = new ColorMatrix(); |
| 122 | } |
| 123 | DragView.setColorScale(mHoverColor, mCurrentFilter); |
| 124 | mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter)); |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 125 | setTextColor(mHoverColor); |
| 126 | } |
Sunny Goyal | e78e3d7 | 2015-09-24 11:23:31 -0700 | [diff] [blame^] | 127 | sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 130 | @Override |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 131 | public void onDragOver(DragObject d) { |
| 132 | // Do nothing |
| 133 | } |
| 134 | |
Sunny Goyal | 9fc953b | 2015-08-17 12:24:25 -0700 | [diff] [blame] | 135 | protected void resetHoverColor() { |
| 136 | if (Utilities.ATLEAST_LOLLIPOP) { |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 137 | animateTextColor(mOriginalTextColor.getDefaultColor()); |
| 138 | } else { |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 139 | mDrawable.setColorFilter(null); |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 140 | setTextColor(mOriginalTextColor); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 145 | private void animateTextColor(int targetColor) { |
| 146 | if (mCurrentColorAnim != null) { |
| 147 | mCurrentColorAnim.cancel(); |
| 148 | } |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 149 | |
| 150 | mCurrentColorAnim = new AnimatorSet(); |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 151 | mCurrentColorAnim.setDuration(DragView.COLOR_CHANGE_DURATION); |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 152 | |
| 153 | if (mSrcFilter == null) { |
| 154 | mSrcFilter = new ColorMatrix(); |
| 155 | mDstFilter = new ColorMatrix(); |
| 156 | mCurrentFilter = new ColorMatrix(); |
| 157 | } |
| 158 | |
| 159 | DragView.setColorScale(getTextColor(), mSrcFilter); |
| 160 | DragView.setColorScale(targetColor, mDstFilter); |
| 161 | ValueAnimator anim1 = ValueAnimator.ofObject( |
| 162 | new FloatArrayEvaluator(mCurrentFilter.getArray()), |
| 163 | mSrcFilter.getArray(), mDstFilter.getArray()); |
| 164 | anim1.addUpdateListener(new AnimatorUpdateListener() { |
| 165 | |
| 166 | @Override |
| 167 | public void onAnimationUpdate(ValueAnimator animation) { |
| 168 | mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter)); |
| 169 | invalidate(); |
| 170 | } |
| 171 | }); |
| 172 | |
| 173 | mCurrentColorAnim.play(anim1); |
| 174 | mCurrentColorAnim.play(ObjectAnimator.ofArgb(this, "textColor", targetColor)); |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 175 | mCurrentColorAnim.start(); |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 178 | @Override |
| 179 | public final void onDragExit(DragObject d) { |
| 180 | if (!d.dragComplete) { |
| 181 | d.dragView.setColor(0); |
| 182 | resetHoverColor(); |
| 183 | } else { |
| 184 | // Restore the hover color |
| 185 | d.dragView.setColor(mHoverColor); |
| 186 | } |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 189 | @Override |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 190 | public final void onDragStart(DragSource source, Object info, int dragAction) { |
| 191 | mActive = supportsDrop(source, info); |
Sunny Goyal | 3a644ed | 2015-05-21 10:28:02 -0700 | [diff] [blame] | 192 | mDrawable.setColorFilter(null); |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 193 | if (mCurrentColorAnim != null) { |
| 194 | mCurrentColorAnim.cancel(); |
| 195 | mCurrentColorAnim = null; |
| 196 | } |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 197 | setTextColor(mOriginalTextColor); |
| 198 | ((ViewGroup) getParent()).setVisibility(mActive ? View.VISIBLE : View.GONE); |
| 199 | } |
| 200 | |
| 201 | @Override |
| 202 | public final boolean acceptDrop(DragObject dragObject) { |
| 203 | return supportsDrop(dragObject.dragSource, dragObject.dragInfo); |
| 204 | } |
| 205 | |
| 206 | protected abstract boolean supportsDrop(DragSource source, Object info); |
| 207 | |
| 208 | @Override |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 209 | public boolean isDropEnabled() { |
| 210 | return mActive; |
| 211 | } |
| 212 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 213 | @Override |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 214 | public void onDragEnd() { |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 215 | mActive = false; |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 218 | /** |
| 219 | * On drop animate the dropView to the icon. |
| 220 | */ |
| 221 | @Override |
| 222 | public void onDrop(final DragObject d) { |
| 223 | final DragLayer dragLayer = mLauncher.getDragLayer(); |
| 224 | final Rect from = new Rect(); |
| 225 | dragLayer.getViewRectRelativeToSelf(d.dragView, from); |
| 226 | |
| 227 | int width = mDrawable.getIntrinsicWidth(); |
| 228 | int height = mDrawable.getIntrinsicHeight(); |
| 229 | final Rect to = getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(), |
| 230 | width, height); |
| 231 | final float scale = (float) to.width() / from.width(); |
| 232 | mSearchDropTargetBar.deferOnDragEnd(); |
| 233 | |
| 234 | Runnable onAnimationEndRunnable = new Runnable() { |
| 235 | @Override |
| 236 | public void run() { |
| 237 | completeDrop(d); |
| 238 | mSearchDropTargetBar.onDragEnd(); |
| 239 | mLauncher.exitSpringLoadedDragModeDelayed(true, 0, null); |
| 240 | } |
| 241 | }; |
| 242 | dragLayer.animateView(d.dragView, from, to, scale, 1f, 1f, 0.1f, 0.1f, |
| 243 | DRAG_VIEW_DROP_DURATION, new DecelerateInterpolator(2), |
| 244 | new LinearInterpolator(), onAnimationEndRunnable, |
| 245 | DragLayer.ANIMATION_END_DISAPPEAR, null); |
| 246 | } |
| 247 | |
Sunny Goyal | e9b651e | 2015-04-24 11:44:51 -0700 | [diff] [blame] | 248 | @Override |
| 249 | public void prepareAccessibilityDrop() { } |
| 250 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 251 | @Thunk abstract void completeDrop(DragObject d); |
| 252 | |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 253 | @Override |
Adam Cohen | 7d30a37 | 2013-07-01 17:03:59 -0700 | [diff] [blame] | 254 | public void getHitRectRelativeToDragLayer(android.graphics.Rect outRect) { |
Winson Chung | a62e9fd | 2011-07-11 15:20:48 -0700 | [diff] [blame] | 255 | super.getHitRect(outRect); |
| 256 | outRect.bottom += mBottomDragPadding; |
Winson Chung | 156ab5b | 2013-07-12 14:14:16 -0700 | [diff] [blame] | 257 | |
| 258 | int[] coords = new int[2]; |
| 259 | mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, coords); |
| 260 | outRect.offsetTo(coords[0], coords[1]); |
Winson Chung | a62e9fd | 2011-07-11 15:20:48 -0700 | [diff] [blame] | 261 | } |
| 262 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 263 | protected Rect getIconRect(int viewWidth, int viewHeight, int drawableWidth, int drawableHeight) { |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 264 | DragLayer dragLayer = mLauncher.getDragLayer(); |
| 265 | |
| 266 | // Find the rect to animate to (the view is center aligned) |
| 267 | Rect to = new Rect(); |
| 268 | dragLayer.getViewRectRelativeToSelf(this, to); |
Fabrice Di Meglio | d6a33c6 | 2013-02-06 15:40:46 -0800 | [diff] [blame] | 269 | |
| 270 | final int width = drawableWidth; |
| 271 | final int height = drawableHeight; |
| 272 | |
| 273 | final int left; |
| 274 | final int right; |
| 275 | |
Sunny Goyal | 7066003 | 2015-05-14 00:07:08 -0700 | [diff] [blame] | 276 | if (Utilities.isRtl(getResources())) { |
Fabrice Di Meglio | d6a33c6 | 2013-02-06 15:40:46 -0800 | [diff] [blame] | 277 | right = to.right - getPaddingRight(); |
| 278 | left = right - width; |
| 279 | } else { |
| 280 | left = to.left + getPaddingLeft(); |
| 281 | right = left + width; |
| 282 | } |
| 283 | |
| 284 | final int top = to.top + (getMeasuredHeight() - height) / 2; |
| 285 | final int bottom = top + height; |
| 286 | |
| 287 | to.set(left, top, right, bottom); |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 288 | |
| 289 | // Center the destination rect about the trash icon |
Fabrice Di Meglio | d6a33c6 | 2013-02-06 15:40:46 -0800 | [diff] [blame] | 290 | final int xOffset = (int) -(viewWidth - width) / 2; |
| 291 | final int yOffset = (int) -(viewHeight - height) / 2; |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 292 | to.offset(xOffset, yOffset); |
| 293 | |
| 294 | return to; |
| 295 | } |
| 296 | |
Sunny Goyal | fa401a1 | 2015-04-10 13:45:42 -0700 | [diff] [blame] | 297 | @Override |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 298 | public void getLocationInDragLayer(int[] loc) { |
| 299 | mLauncher.getDragLayer().getLocationInDragLayer(this, loc); |
| 300 | } |
Sunny Goyal | 1a70cef | 2015-04-22 11:29:51 -0700 | [diff] [blame] | 301 | |
| 302 | public void enableAccessibleDrag(boolean enable) { |
| 303 | setOnClickListener(enable ? this : null); |
| 304 | } |
| 305 | |
| 306 | protected String getAccessibilityDropConfirmation() { |
| 307 | return null; |
| 308 | } |
| 309 | |
| 310 | @Override |
| 311 | public void onClick(View v) { |
| 312 | LauncherAppState.getInstance().getAccessibilityDelegate() |
| 313 | .handleAccessibleDrop(this, null, getAccessibilityDropConfirmation()); |
| 314 | } |
Sunny Goyal | fe0d1f2 | 2015-04-28 22:01:31 -0700 | [diff] [blame] | 315 | |
| 316 | public int getTextColor() { |
| 317 | return getTextColors().getDefaultColor(); |
| 318 | } |
Winson Chung | 61fa419 | 2011-06-12 15:15:29 -0700 | [diff] [blame] | 319 | } |