• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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 package com.android.launcher3.allapps;
17 
18 import android.content.Context;
19 import android.graphics.Bitmap;
20 import android.util.AttributeSet;
21 import android.view.View;
22 import android.view.ViewGroup;
23 import android.widget.FrameLayout;
24 import android.widget.RelativeLayout;
25 
26 import com.android.launcher3.BubbleTextView;
27 import com.android.launcher3.BubbleTextView.BubbleTextShadowHandler;
28 import com.android.launcher3.ClickShadowView;
29 import com.android.launcher3.DeviceProfile;
30 import com.android.launcher3.Launcher;
31 import com.android.launcher3.R;
32 
33 /**
34  * A container for RecyclerView to allow for the click shadow view to be shown behind an icon that
35  * is launching.
36  */
37 public class AllAppsRecyclerViewContainerView extends RelativeLayout
38         implements BubbleTextShadowHandler {
39 
40     private final ClickShadowView mTouchFeedbackView;
41 
AllAppsRecyclerViewContainerView(Context context)42     public AllAppsRecyclerViewContainerView(Context context) {
43         this(context, null);
44     }
45 
AllAppsRecyclerViewContainerView(Context context, AttributeSet attrs)46     public AllAppsRecyclerViewContainerView(Context context, AttributeSet attrs) {
47         this(context, attrs, 0);
48     }
49 
AllAppsRecyclerViewContainerView(Context context, AttributeSet attrs, int defStyleAttr)50     public AllAppsRecyclerViewContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
51         super(context, attrs, defStyleAttr);
52 
53         Launcher launcher = Launcher.getLauncher(context);
54         DeviceProfile grid = launcher.getDeviceProfile();
55 
56         mTouchFeedbackView = new ClickShadowView(context);
57 
58         // Make the feedback view large enough to hold the blur bitmap.
59         int size = grid.allAppsIconSizePx + mTouchFeedbackView.getExtraSize();
60         addView(mTouchFeedbackView, size, size);
61     }
62 
63     @Override
setPressedIcon(BubbleTextView icon, Bitmap background)64     public void setPressedIcon(BubbleTextView icon, Bitmap background) {
65         if (icon == null || background == null) {
66             mTouchFeedbackView.setBitmap(null);
67             mTouchFeedbackView.animate().cancel();
68         } else if (mTouchFeedbackView.setBitmap(background)) {
69             View rv = findViewById(R.id.apps_list_view);
70             mTouchFeedbackView.alignWithIconView(icon, (ViewGroup) icon.getParent(), rv);
71             mTouchFeedbackView.animateShadow();
72         }
73     }
74 }
75