• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.allapps;
18 
19 import android.content.Context;
20 import android.util.AttributeSet;
21 import android.view.ViewGroup;
22 import android.widget.ImageView;
23 
24 import androidx.constraintlayout.widget.ConstraintLayout;
25 
26 import com.android.launcher3.R;
27 import com.android.launcher3.views.ActivityContext;
28 
29 public class FloatingMaskView extends ConstraintLayout {
30 
31     private final ActivityContext mActivityContext;
32     private ImageView mBottomBox;
33 
FloatingMaskView(Context context)34     public FloatingMaskView(Context context) {
35         this(context, null, 0);
36     }
37 
FloatingMaskView(Context context, AttributeSet attrs)38     public FloatingMaskView(Context context, AttributeSet attrs) {
39         this(context, attrs, 0);
40     }
41 
FloatingMaskView(Context context, AttributeSet attrs, int defStyleAttr)42     public FloatingMaskView(Context context, AttributeSet attrs, int defStyleAttr) {
43         super(context, attrs, defStyleAttr);
44         mActivityContext = ActivityContext.lookupContext(context);
45     }
46 
47     @Override
onFinishInflate()48     protected void onFinishInflate() {
49         super.onFinishInflate();
50         mBottomBox = findViewById(R.id.bottom_box);
51     }
52 
53     @Override
onLayout(boolean changed, int left, int top, int right, int bottom)54     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
55         super.onLayout(changed, left, top, right, bottom);
56         ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) getLayoutParams();
57         AllAppsRecyclerView allAppsContainerView =
58                 mActivityContext.getAppsView().getActiveRecyclerView();
59         if (lp != null) {
60             lp.rightMargin = allAppsContainerView.getPaddingRight();
61             lp.leftMargin = allAppsContainerView.getPaddingLeft();
62             mBottomBox.setMinimumHeight(allAppsContainerView.getPaddingBottom());
63         }
64     }
65 }
66