blob: 31ff42a7f8ca25535aea5837e9d2c2176123aff4 [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);
50
51 dragController.addDropTarget(mAppInfoDropTarget);
52
53 mAppInfoDropTarget.setLauncher(launcher);
54 }
55
56 @Override
57 public void showDropTarget() {
58 animateDropTargetBarToAlpha(1f, DEFAULT_DRAG_FADE_DURATION);
59 }
60
61 @Override
62 public void hideDropTarget() {
63 animateDropTargetBarToAlpha(0f, DEFAULT_DRAG_FADE_DURATION);
64 }
65
66 private void animateDropTargetBarToAlpha(float alpha, int duration) {
67 animateViewAlpha(mDropTargetBarAnimator, mDropTargetBar, alpha,duration);
68 }
69
70 @Override
71 public void enableAccessibleDrag(boolean enable) {
72 mAppInfoDropTarget.enableAccessibleDrag(enable);
73 }
74}