Tony Wickham | 34d2c91 | 2015-09-11 09:27:58 -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 | |
| 19 | import android.content.Context; |
| 20 | import android.util.AttributeSet; |
| 21 | |
| 22 | import com.android.launcher3.dragndrop.DragController; |
| 23 | |
| 24 | public 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 |
Tony Wickham | 9aae47f | 2015-10-01 13:04:22 -0700 | [diff] [blame] | 57 | public void showDropTargets() { |
Tony Wickham | 34d2c91 | 2015-09-11 09:27:58 -0700 | [diff] [blame] | 58 | animateDropTargetBarToAlpha(1f, DEFAULT_DRAG_FADE_DURATION); |
| 59 | } |
| 60 | |
| 61 | @Override |
Tony Wickham | 9aae47f | 2015-10-01 13:04:22 -0700 | [diff] [blame] | 62 | public void hideDropTargets() { |
Tony Wickham | 34d2c91 | 2015-09-11 09:27:58 -0700 | [diff] [blame] | 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 | } |