Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | |
| 17 | package com.android.launcher3; |
| 18 | |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 19 | import static com.android.launcher3.ButtonDropTarget.TOOLTIP_DEFAULT; |
Sunny Goyal | 7185dd6 | 2018-03-14 17:51:49 -0700 | [diff] [blame] | 20 | import static com.android.launcher3.anim.AlphaUpdateListener.updateVisibility; |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 21 | |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 22 | import android.animation.TimeInterpolator; |
| 23 | import android.content.Context; |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 24 | import android.graphics.Rect; |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 25 | import android.util.AttributeSet; |
vadimt | 89d9423 | 2021-09-01 12:33:00 -0700 | [diff] [blame] | 26 | import android.util.Log; |
Alex Chau | a02eddc | 2021-04-29 00:36:06 +0100 | [diff] [blame] | 27 | import android.util.TypedValue; |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 28 | import android.view.Gravity; |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 29 | import android.view.View; |
| 30 | import android.view.ViewDebug; |
| 31 | import android.view.ViewPropertyAnimator; |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 32 | import android.widget.FrameLayout; |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 33 | |
vadimt | 89d9423 | 2021-09-01 12:33:00 -0700 | [diff] [blame] | 34 | import androidx.annotation.NonNull; |
| 35 | |
Sunny Goyal | 5bc6b6f | 2017-10-26 15:36:10 -0700 | [diff] [blame] | 36 | import com.android.launcher3.anim.Interpolators; |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 37 | import com.android.launcher3.dragndrop.DragController; |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 38 | import com.android.launcher3.dragndrop.DragController.DragListener; |
Sunny Goyal | 94b510c | 2016-08-16 15:36:48 -0700 | [diff] [blame] | 39 | import com.android.launcher3.dragndrop.DragOptions; |
vadimt | 89d9423 | 2021-09-01 12:33:00 -0700 | [diff] [blame] | 40 | import com.android.launcher3.testing.TestProtocol; |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 41 | |
Pat Manning | de25c0d | 2022-04-05 19:11:26 +0100 | [diff] [blame^] | 42 | import java.util.Arrays; |
| 43 | |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 44 | /* |
| 45 | * The top bar containing various drop targets: Delete/App Info/Uninstall. |
| 46 | */ |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 47 | public class DropTargetBar extends FrameLayout |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 48 | implements DragListener, Insettable { |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 49 | |
| 50 | protected static final int DEFAULT_DRAG_FADE_DURATION = 175; |
Sunny Goyal | 5bc6b6f | 2017-10-26 15:36:10 -0700 | [diff] [blame] | 51 | protected static final TimeInterpolator DEFAULT_INTERPOLATOR = Interpolators.ACCEL; |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 52 | |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 53 | private final Runnable mFadeAnimationEndRunnable = |
Sunny Goyal | 18d7184 | 2018-03-27 13:44:00 -0700 | [diff] [blame] | 54 | () -> updateVisibility(DropTargetBar.this); |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 55 | |
| 56 | @ViewDebug.ExportedProperty(category = "launcher") |
| 57 | protected boolean mDeferOnDragEnd; |
| 58 | |
| 59 | @ViewDebug.ExportedProperty(category = "launcher") |
| 60 | protected boolean mVisible = false; |
| 61 | |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 62 | private ButtonDropTarget[] mDropTargets; |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 63 | private ViewPropertyAnimator mCurrentAnimation; |
| 64 | |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 65 | private boolean mIsVertical = true; |
| 66 | |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 67 | public DropTargetBar(Context context, AttributeSet attrs) { |
| 68 | super(context, attrs); |
| 69 | } |
| 70 | |
| 71 | public DropTargetBar(Context context, AttributeSet attrs, int defStyle) { |
| 72 | super(context, attrs, defStyle); |
| 73 | } |
| 74 | |
| 75 | @Override |
| 76 | protected void onFinishInflate() { |
| 77 | super.onFinishInflate(); |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 78 | mDropTargets = new ButtonDropTarget[getChildCount()]; |
| 79 | for (int i = 0; i < mDropTargets.length; i++) { |
| 80 | mDropTargets[i] = (ButtonDropTarget) getChildAt(i); |
| 81 | mDropTargets[i].setDropTargetBar(this); |
| 82 | } |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 85 | @Override |
| 86 | public void setInsets(Rect insets) { |
| 87 | FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); |
| 88 | DeviceProfile grid = Launcher.getLauncher(getContext()).getDeviceProfile(); |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 89 | mIsVertical = grid.isVerticalBarLayout(); |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 90 | |
| 91 | lp.leftMargin = insets.left; |
| 92 | lp.topMargin = insets.top; |
| 93 | lp.bottomMargin = insets.bottom; |
| 94 | lp.rightMargin = insets.right; |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 95 | int tooltipLocation = TOOLTIP_DEFAULT; |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 96 | |
Pat Manning | de25c0d | 2022-04-05 19:11:26 +0100 | [diff] [blame^] | 97 | int horizontalMargin; |
| 98 | if (grid.isTablet) { |
| 99 | // XXX: If the icon size changes across orientations, we will have to take |
| 100 | // that into account here too. |
| 101 | horizontalMargin = ((grid.widthPx - 2 * grid.edgeMarginPx |
| 102 | - (grid.inv.numColumns * grid.cellWidthPx)) |
| 103 | / (2 * (grid.inv.numColumns + 1))) |
| 104 | + grid.edgeMarginPx; |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 105 | } else { |
Pat Manning | de25c0d | 2022-04-05 19:11:26 +0100 | [diff] [blame^] | 106 | horizontalMargin = getContext().getResources() |
| 107 | .getDimensionPixelSize(R.dimen.drop_target_bar_margin_horizontal); |
Pat Manning | e372366 | 2022-03-25 16:07:46 +0000 | [diff] [blame] | 108 | } |
Pat Manning | de25c0d | 2022-04-05 19:11:26 +0100 | [diff] [blame^] | 109 | lp.topMargin += grid.dropTargetBarTopMarginPx; |
| 110 | lp.bottomMargin += grid.dropTargetBarBottomMarginPx; |
| 111 | lp.width = grid.availableWidthPx - 2 * horizontalMargin; |
| 112 | if (mIsVertical) { |
| 113 | lp.leftMargin = (grid.widthPx - lp.width) / 2; |
| 114 | lp.rightMargin = (grid.widthPx - lp.width) / 2; |
| 115 | } |
| 116 | lp.height = grid.dropTargetBarSizePx; |
| 117 | lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; |
| 118 | |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 119 | setLayoutParams(lp); |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 120 | for (ButtonDropTarget button : mDropTargets) { |
Alex Chau | a02eddc | 2021-04-29 00:36:06 +0100 | [diff] [blame] | 121 | button.setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.dropTargetTextSizePx); |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 122 | button.setToolTipLocation(tooltipLocation); |
| 123 | } |
Sunny Goyal | 07b6929 | 2018-01-08 14:19:34 -0800 | [diff] [blame] | 124 | } |
| 125 | |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 126 | public void setup(DragController dragController) { |
| 127 | dragController.addDragListener(this); |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 128 | for (int i = 0; i < mDropTargets.length; i++) { |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 129 | dragController.addDragListener(mDropTargets[i]); |
| 130 | dragController.addDropTarget(mDropTargets[i]); |
| 131 | } |
| 132 | } |
| 133 | |
Jon Miranda | bfaa4a4 | 2017-08-21 15:31:51 -0700 | [diff] [blame] | 134 | @Override |
| 135 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 136 | int width = MeasureSpec.getSize(widthMeasureSpec); |
| 137 | int height = MeasureSpec.getSize(heightMeasureSpec); |
Jon Miranda | bfaa4a4 | 2017-08-21 15:31:51 -0700 | [diff] [blame] | 138 | |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 139 | int visibleCount = getVisibleButtonsCount(); |
Pat Manning | de25c0d | 2022-04-05 19:11:26 +0100 | [diff] [blame^] | 140 | if (visibleCount > 0) { |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 141 | int availableWidth = width / visibleCount; |
| 142 | boolean textVisible = true; |
| 143 | for (ButtonDropTarget buttons : mDropTargets) { |
| 144 | if (buttons.getVisibility() != GONE) { |
| 145 | textVisible = textVisible && !buttons.isTextTruncated(availableWidth); |
| 146 | } |
Jon Miranda | bfaa4a4 | 2017-08-21 15:31:51 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 149 | int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST); |
| 150 | int heightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); |
| 151 | for (ButtonDropTarget button : mDropTargets) { |
| 152 | if (button.getVisibility() != GONE) { |
| 153 | button.setTextVisible(textVisible); |
| 154 | button.measure(widthSpec, heightSpec); |
Jon Miranda | bfaa4a4 | 2017-08-21 15:31:51 -0700 | [diff] [blame] | 155 | } |
| 156 | } |
| 157 | } |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 158 | setMeasuredDimension(width, height); |
| 159 | } |
Jon Miranda | bfaa4a4 | 2017-08-21 15:31:51 -0700 | [diff] [blame] | 160 | |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 161 | @Override |
| 162 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 163 | int visibleCount = getVisibleButtonsCount(); |
| 164 | if (visibleCount == 0) { |
Pat Manning | de25c0d | 2022-04-05 19:11:26 +0100 | [diff] [blame^] | 165 | return; |
| 166 | } |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 167 | |
Pat Manning | de25c0d | 2022-04-05 19:11:26 +0100 | [diff] [blame^] | 168 | Launcher launcher = Launcher.getLauncher(getContext()); |
| 169 | Workspace workspace = launcher.getWorkspace(); |
| 170 | DeviceProfile dp = launcher.getDeviceProfile(); |
| 171 | int buttonHorizontalPadding = dp.dropTargetHorizontalPaddingPx; |
| 172 | int buttonVerticalPadding = dp.dropTargetVerticalPaddingPx; |
| 173 | int barCenter = (right - left) / 2; |
Pat Manning | 1acf2b1 | 2022-02-25 15:41:55 +0000 | [diff] [blame] | 174 | |
Pat Manning | de25c0d | 2022-04-05 19:11:26 +0100 | [diff] [blame^] | 175 | ButtonDropTarget[] visibleButtons = Arrays.stream(mDropTargets) |
| 176 | .filter(b -> b.getVisibility() != GONE) |
| 177 | .toArray(ButtonDropTarget[]::new); |
| 178 | Arrays.stream(visibleButtons).forEach( |
| 179 | b -> b.setPadding(buttonHorizontalPadding, buttonVerticalPadding, |
| 180 | buttonHorizontalPadding, buttonVerticalPadding)); |
| 181 | |
| 182 | if (visibleCount == 1) { |
| 183 | ButtonDropTarget button = visibleButtons[0]; |
| 184 | button.layout(barCenter - (button.getMeasuredWidth() / 2), 0, |
| 185 | barCenter + (button.getMeasuredWidth() / 2), button.getMeasuredHeight()); |
| 186 | } else if (visibleCount == 2) { |
| 187 | int buttonGap = dp.dropTargetGapPx; |
| 188 | |
| 189 | if (dp.isTwoPanels) { |
| 190 | ButtonDropTarget leftButton = visibleButtons[0]; |
| 191 | leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0, |
| 192 | barCenter - (buttonGap / 2), leftButton.getMeasuredHeight()); |
| 193 | |
| 194 | ButtonDropTarget rightButton = visibleButtons[1]; |
| 195 | rightButton.layout(barCenter + (buttonGap / 2), 0, |
| 196 | barCenter + rightButton.getMeasuredWidth() + (buttonGap / 2), |
| 197 | rightButton.getMeasuredHeight()); |
| 198 | } else if (dp.isTablet) { |
| 199 | int numberOfMargins = visibleCount - 1; |
| 200 | int buttonWidths = Arrays.stream(mDropTargets) |
| 201 | .filter(b -> b.getVisibility() != GONE) |
| 202 | .mapToInt(ButtonDropTarget::getMeasuredWidth) |
| 203 | .sum(); |
| 204 | int totalWidth = buttonWidths + (numberOfMargins * buttonGap); |
| 205 | int buttonsStartMargin = barCenter - (totalWidth / 2); |
| 206 | |
| 207 | int start = buttonsStartMargin; |
| 208 | for (ButtonDropTarget button : visibleButtons) { |
| 209 | int margin = (start != buttonsStartMargin) ? buttonGap : 0; |
| 210 | button.layout(start + margin, 0, start + margin + button.getMeasuredWidth(), |
| 211 | button.getMeasuredHeight()); |
| 212 | start += button.getMeasuredWidth() + margin; |
Pat Manning | 1acf2b1 | 2022-02-25 15:41:55 +0000 | [diff] [blame] | 213 | } |
Pat Manning | de25c0d | 2022-04-05 19:11:26 +0100 | [diff] [blame^] | 214 | } else if (mIsVertical) { |
| 215 | // Center buttons over workspace, not screen. |
| 216 | int verticalCenter = (workspace.getRight() - workspace.getLeft()) / 2; |
| 217 | ButtonDropTarget leftButton = visibleButtons[0]; |
| 218 | leftButton.layout(verticalCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), |
| 219 | 0, verticalCenter - (buttonGap / 2), leftButton.getMeasuredHeight()); |
| 220 | |
| 221 | ButtonDropTarget rightButton = visibleButtons[1]; |
| 222 | rightButton.layout(verticalCenter + (buttonGap / 2), 0, |
| 223 | verticalCenter + rightButton.getMeasuredWidth() + (buttonGap / 2), |
| 224 | rightButton.getMeasuredHeight()); |
| 225 | } else if (dp.isPhone) { |
| 226 | // Buttons aligned to outer edges of scaled workspace. |
| 227 | float shrunkTop = dp.getWorkspaceSpringLoadShrunkTop(); |
| 228 | float shrunkBottom = dp.getWorkspaceSpringLoadShrunkBottom(); |
| 229 | float scale = |
| 230 | (shrunkBottom - shrunkTop) / launcher.getWorkspace().getNormalChildHeight(); |
| 231 | int workspaceWidth = (int) (launcher.getWorkspace().getNormalChildWidth() * scale); |
| 232 | int start = barCenter - (workspaceWidth / 2); |
| 233 | int end = barCenter + (workspaceWidth / 2); |
| 234 | |
| 235 | ButtonDropTarget leftButton = visibleButtons[0]; |
| 236 | ButtonDropTarget rightButton = visibleButtons[1]; |
| 237 | |
| 238 | // If the text within the buttons is too long, the buttons can overlap |
| 239 | int overlap = start + leftButton.getMeasuredWidth() + rightButton.getMeasuredWidth() |
| 240 | - end; |
| 241 | if (overlap > 0) { |
| 242 | start -= overlap / 2; |
| 243 | end += overlap / 2; |
| 244 | } |
| 245 | |
| 246 | leftButton.layout(start, 0, start + leftButton.getMeasuredWidth(), |
| 247 | leftButton.getMeasuredHeight()); |
| 248 | rightButton.layout(end - rightButton.getMeasuredWidth(), 0, end, |
| 249 | rightButton.getMeasuredHeight()); |
Sunny Goyal | d1b3f5c | 2018-01-18 17:14:05 -0800 | [diff] [blame] | 250 | } |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | private int getVisibleButtonsCount() { |
| 255 | int visibleCount = 0; |
| 256 | for (ButtonDropTarget buttons : mDropTargets) { |
| 257 | if (buttons.getVisibility() != GONE) { |
| 258 | visibleCount++; |
| 259 | } |
| 260 | } |
| 261 | return visibleCount; |
Jon Miranda | bfaa4a4 | 2017-08-21 15:31:51 -0700 | [diff] [blame] | 262 | } |
| 263 | |
Hyunyoung Song | 497708c | 2019-05-01 16:16:53 -0700 | [diff] [blame] | 264 | public void animateToVisibility(boolean isVisible) { |
vadimt | 89d9423 | 2021-09-01 12:33:00 -0700 | [diff] [blame] | 265 | if (TestProtocol.sDebugTracing) { |
| 266 | Log.d(TestProtocol.NO_DROP_TARGET, "8"); |
| 267 | } |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 268 | if (mVisible != isVisible) { |
| 269 | mVisible = isVisible; |
| 270 | |
| 271 | // Cancel any existing animation |
| 272 | if (mCurrentAnimation != null) { |
| 273 | mCurrentAnimation.cancel(); |
| 274 | mCurrentAnimation = null; |
| 275 | } |
| 276 | |
| 277 | float finalAlpha = mVisible ? 1 : 0; |
| 278 | if (Float.compare(getAlpha(), finalAlpha) != 0) { |
| 279 | setVisibility(View.VISIBLE); |
| 280 | mCurrentAnimation = animate().alpha(finalAlpha) |
| 281 | .setInterpolator(DEFAULT_INTERPOLATOR) |
| 282 | .setDuration(DEFAULT_DRAG_FADE_DURATION) |
| 283 | .withEndAction(mFadeAnimationEndRunnable); |
| 284 | } |
| 285 | |
| 286 | } |
| 287 | } |
| 288 | |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 289 | /* |
| 290 | * DragController.DragListener implementation |
| 291 | */ |
| 292 | @Override |
Sunny Goyal | 94b510c | 2016-08-16 15:36:48 -0700 | [diff] [blame] | 293 | public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) { |
vadimt | 89d9423 | 2021-09-01 12:33:00 -0700 | [diff] [blame] | 294 | if (TestProtocol.sDebugTracing) { |
| 295 | Log.d(TestProtocol.NO_DROP_TARGET, "7"); |
| 296 | } |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 297 | animateToVisibility(true); |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * This is called to defer hiding the delete drop target until the drop animation has completed, |
| 302 | * instead of hiding immediately when the drag has ended. |
| 303 | */ |
| 304 | protected void deferOnDragEnd() { |
| 305 | mDeferOnDragEnd = true; |
| 306 | } |
| 307 | |
| 308 | @Override |
| 309 | public void onDragEnd() { |
| 310 | if (!mDeferOnDragEnd) { |
| 311 | animateToVisibility(false); |
| 312 | } else { |
| 313 | mDeferOnDragEnd = false; |
| 314 | } |
| 315 | } |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 316 | |
| 317 | public ButtonDropTarget[] getDropTargets() { |
| 318 | return mDropTargets; |
| 319 | } |
vadimt | 89d9423 | 2021-09-01 12:33:00 -0700 | [diff] [blame] | 320 | |
| 321 | @Override |
| 322 | protected void onVisibilityChanged(@NonNull View changedView, int visibility) { |
| 323 | super.onVisibilityChanged(changedView, visibility); |
Vadim Tryshev | 8629be7 | 2021-10-26 19:57:49 +0000 | [diff] [blame] | 324 | if (TestProtocol.sDebugTracing) { |
| 325 | if (visibility == VISIBLE) { |
| 326 | Log.d(TestProtocol.NO_DROP_TARGET, "9"); |
| 327 | } else { |
| 328 | Log.d(TestProtocol.NO_DROP_TARGET, "Hiding drop target", new Exception()); |
| 329 | } |
vadimt | 89d9423 | 2021-09-01 12:33:00 -0700 | [diff] [blame] | 330 | } |
| 331 | } |
Sunny Goyal | 47328fd | 2016-05-25 18:56:41 -0700 | [diff] [blame] | 332 | } |