• 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.systemui.car.systembar.element.layout;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.content.Context;
22 import android.util.AttributeSet;
23 import android.widget.ImageView;
24 
25 import com.android.systemui.car.systembar.element.CarSystemBarElement;
26 import com.android.systemui.car.systembar.element.CarSystemBarElementFlags;
27 import com.android.systemui.car.systembar.element.CarSystemBarElementResolver;
28 
29 /** Implementation of ImageView  that supports {@link CarSystemBarElement} attributes */
30 public class CarSystemBarImageView extends ImageView implements CarSystemBarElement {
31     private Class<?> mElementControllerClassAttr;
32     private int mSystemBarDisableFlags;
33     private int mSystemBarDisable2Flags;
34     private boolean mDisableForLockTaskModeLocked;
35 
CarSystemBarImageView(@onNull Context context)36     public CarSystemBarImageView(@NonNull Context context) {
37         super(context);
38         init(context, /* attrs= */ null);
39     }
40 
CarSystemBarImageView(@onNull Context context, @Nullable AttributeSet attrs)41     public CarSystemBarImageView(@NonNull Context context,
42             @Nullable AttributeSet attrs) {
43         super(context, attrs);
44         init(context, attrs);
45     }
46 
CarSystemBarImageView(@onNull Context context, @Nullable AttributeSet attrs, int defStyleAttr)47     public CarSystemBarImageView(@NonNull Context context, @Nullable AttributeSet attrs,
48             int defStyleAttr) {
49         super(context, attrs, defStyleAttr);
50         init(context, attrs);
51     }
52 
CarSystemBarImageView(@onNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes)53     public CarSystemBarImageView(@NonNull Context context, @Nullable AttributeSet attrs,
54             int defStyleAttr, int defStyleRes) {
55         super(context, attrs, defStyleAttr, defStyleRes);
56         init(context, attrs);
57     }
58 
init(Context context, @Nullable AttributeSet attrs)59     private void init(Context context, @Nullable AttributeSet attrs) {
60         mElementControllerClassAttr =
61                 CarSystemBarElementResolver.getElementControllerClassFromAttributes(context, attrs);
62         mSystemBarDisableFlags =
63                 CarSystemBarElementFlags.getStatusBarManagerDisableFlagsFromAttributes(context,
64                         attrs);
65         mSystemBarDisable2Flags =
66                 CarSystemBarElementFlags.getStatusBarManagerDisable2FlagsFromAttributes(context,
67                         attrs);
68         mDisableForLockTaskModeLocked =
69                 CarSystemBarElementFlags.getDisableForLockTaskModeLockedFromAttributes(context,
70                         attrs);
71     }
72 
73     @Override
getElementControllerClass()74     public Class<?> getElementControllerClass() {
75         return mElementControllerClassAttr;
76     }
77 
78     @Override
getSystemBarDisableFlags()79     public int getSystemBarDisableFlags() {
80         return mSystemBarDisableFlags;
81     }
82 
83     @Override
getSystemBarDisable2Flags()84     public int getSystemBarDisable2Flags() {
85         return mSystemBarDisable2Flags;
86     }
87 
88     @Override
disableForLockTaskModeLocked()89     public boolean disableForLockTaskModeLocked() {
90         return mDisableForLockTaskModeLocked;
91     }
92 }
93