blob: e06f94100433d7da0e3efd64a1dc7452f8b0c456 [file] [log] [blame]
Tony Wickham34d2c912015-09-11 09:27:58 -07001/*
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
17package com.android.launcher3;
18
19import android.content.Context;
20import android.util.AttributeSet;
21
22import com.android.launcher3.dragndrop.DragController;
23
24public class AppInfoDropTargetBar extends BaseDropTargetBar {
25 private ButtonDropTarget mAppInfoDropTarget;
26
27 public AppInfoDropTargetBar(Context context, AttributeSet attrs) {
28 this(context, attrs, 0);
29 }
30
31 public AppInfoDropTargetBar(Context context, AttributeSet attrs, int defStyle) {
32 super(context, attrs, defStyle);
33 }
34
35 @Override
36 protected void onFinishInflate() {
37 super.onFinishInflate();
38
39 // Get the individual components
40 mAppInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target_text);
41
42 mAppInfoDropTarget.setDropTargetBar(this);
43 }
44
45 @Override
46 public void setup(Launcher launcher, DragController dragController) {
47 dragController.addDragListener(this);
48
49 dragController.addDragListener(mAppInfoDropTarget);
Tony Wickham34d2c912015-09-11 09:27:58 -070050 dragController.addDropTarget(mAppInfoDropTarget);
51
52 mAppInfoDropTarget.setLauncher(launcher);
53 }
54
55 @Override
Tony Wickham9aae47f2015-10-01 13:04:22 -070056 public void showDropTargets() {
Tony Wickham34d2c912015-09-11 09:27:58 -070057 animateDropTargetBarToAlpha(1f, DEFAULT_DRAG_FADE_DURATION);
58 }
59
60 @Override
Tony Wickham9aae47f2015-10-01 13:04:22 -070061 public void hideDropTargets() {
Tony Wickham34d2c912015-09-11 09:27:58 -070062 animateDropTargetBarToAlpha(0f, DEFAULT_DRAG_FADE_DURATION);
63 }
64
65 private void animateDropTargetBarToAlpha(float alpha, int duration) {
Sunny Goyal7c50b312016-02-10 12:26:23 -080066 resetAnimation(duration);
67 if (duration > 0) {
68 animateAlpha(mDropTargetBar, alpha, DEFAULT_INTERPOLATOR);
69 mCurrentAnimation.start();
70 } else {
71 mDropTargetBar.setAlpha(alpha);
72 AlphaUpdateListener.updateVisibility(mDropTargetBar, mAccessibilityEnabled);
73 }
Tony Wickham34d2c912015-09-11 09:27:58 -070074 }
75
76 @Override
77 public void enableAccessibleDrag(boolean enable) {
78 mAppInfoDropTarget.enableAccessibleDrag(enable);
79 }
80}