Debian Codegraph @

libs/WindowManager/Shell/src/com/android/wm/shell/common/DismissCircleView.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 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.common;
18
19 import android.content.Context;
20 import android.content.res.Configuration;
21 import android.content.res.Resources;
22 import android.view.Gravity;
23 import android.widget.FrameLayout;
24 import android.widget.ImageView;
25
26 import com.android.wm.shell.R;
27
28 /**
29 * Circular view with a semitransparent, circular background with an 'X' inside it.
30 *
31 * This is used by both Bubbles and PIP as the dismiss target.
32 */
33 public class DismissCircleView extends FrameLayout {
34
35 private final ImageView mIconView = new ImageView(getContext());
36
37 public DismissCircleView(Context context) {
38 super(context);
39 final Resources res = getResources();
40
41 setBackground(res.getDrawable(R.drawable.dismiss_circle_background));
42
43 mIconView.setImageDrawable(res.getDrawable(R.drawable.pip_ic_close_white));
44 addView(mIconView);
45
46 setViewSizes();
47 }
48
49 @Override
50 protected void onConfigurationChanged(Configuration newConfig) {
51 super.onConfigurationChanged(newConfig);
52 final Resources res = getResources();
53 setBackground(res.getDrawable(R.drawable.dismiss_circle_background));
54 setViewSizes();
55 }
56
57 /** Retrieves the current dimensions for the icon and circle and applies them. */
58 private void setViewSizes() {
59 final Resources res = getResources();
60 final int iconSize = res.getDimensionPixelSize(R.dimen.dismiss_target_x_size);
61 mIconView.setLayoutParams(
62 new FrameLayout.LayoutParams(iconSize, iconSize, Gravity.CENTER));
63 }
64 }