1 /*
2  * Copyright (C) 2021 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.wm.shell.pip.phone;
18 
19 import android.content.Context;
20 import android.graphics.drawable.Drawable;
21 import android.util.AttributeSet;
22 import android.view.View;
23 import android.widget.FrameLayout;
24 import android.widget.ImageView;
25 
26 import com.android.wm.shell.R;
27 
28 /**
29  * Container layout wraps single action image view drawn in PiP menu and can restrict the size of
30  * action image view (see pip_menu_action.xml).
31  */
32 public class PipMenuActionView extends FrameLayout {
33     private ImageView mImageView;
34     private View mCustomCloseBackground;
35 
PipMenuActionView(Context context, AttributeSet attrs)36     public PipMenuActionView(Context context, AttributeSet attrs) {
37         super(context, attrs);
38     }
39 
40     @Override
onFinishInflate()41     protected void onFinishInflate() {
42         super.onFinishInflate();
43         mImageView = findViewById(R.id.image);
44         mCustomCloseBackground = findViewById(R.id.custom_close_bg);
45     }
46 
47     /** pass through to internal {@link #mImageView} */
setImageDrawable(Drawable drawable)48     public void setImageDrawable(Drawable drawable) {
49         mImageView.setImageDrawable(drawable);
50     }
51 
52     /** pass through to internal {@link #mCustomCloseBackground} */
setCustomCloseBackgroundVisibility(@iew.Visibility int visibility)53     public void setCustomCloseBackgroundVisibility(@View.Visibility int visibility) {
54         mCustomCloseBackground.setVisibility(visibility);
55     }
56 }
57