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.systemui.car.systembar;
18 
19 import android.content.Context;
20 import android.content.Intent;
21 import android.content.res.TypedArray;
22 import android.util.AttributeSet;
23 
24 import com.android.systemui.statusbar.AlphaOptimizedImageView;
25 
26 /**
27  * AppGridButton is used to display the app grid and toggle recents.
28  */
29 public class AppGridButton extends CarSystemBarButton {
30     private RecentsButtonStateProvider mRecentsButtonStateProvider;
31 
AppGridButton(Context context, AttributeSet attrs)32     public AppGridButton(Context context, AttributeSet attrs) {
33         super(context, attrs);
34     }
35 
36     @Override
init()37     protected void init() {
38         mRecentsButtonStateProvider = new RecentsButtonStateProvider(getContext(), this);
39     }
40 
41     @Override
setUpIntents(TypedArray typedArray)42     protected void setUpIntents(TypedArray typedArray) {
43         mRecentsButtonStateProvider.setUpIntents(typedArray, super::setUpIntents);
44     }
45 
46     @Override
getButtonClickListener(Intent toSend)47     protected OnClickListener getButtonClickListener(Intent toSend) {
48         return mRecentsButtonStateProvider.getButtonClickListener(toSend,
49                 super::getButtonClickListener);
50     }
51 
52     @Override
updateImage(AlphaOptimizedImageView icon)53     protected void updateImage(AlphaOptimizedImageView icon) {
54         mRecentsButtonStateProvider.updateImage(icon, super::updateImage);
55     }
56 
57     @Override
refreshIconAlpha(AlphaOptimizedImageView icon)58     protected void refreshIconAlpha(AlphaOptimizedImageView icon) {
59         mRecentsButtonStateProvider.refreshIconAlpha(icon, super::refreshIconAlpha);
60     }
61 }
62