1 /*
2  * Copyright (C) 2019 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.qs;
18 
19 import com.android.systemui.qs.dagger.QSScope;
20 import com.android.systemui.util.ViewController;
21 
22 import javax.inject.Inject;
23 
24 /**
25  * Controller for {@link QuickStatusBarHeader}.
26  */
27 @QSScope
28 class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader> {
29 
30     private final QuickQSPanelController mQuickQSPanelController;
31     private boolean mListening;
32 
33     @Inject
QuickStatusBarHeaderController(QuickStatusBarHeader view, QuickQSPanelController quickQSPanelController )34     QuickStatusBarHeaderController(QuickStatusBarHeader view,
35             QuickQSPanelController quickQSPanelController
36     ) {
37         super(view);
38         mQuickQSPanelController = quickQSPanelController;
39     }
40 
41     @Override
onViewAttached()42     protected void onViewAttached() {
43     }
44 
45     @Override
onViewDetached()46     protected void onViewDetached() {
47         setListening(false);
48     }
49 
setListening(boolean listening)50     public void setListening(boolean listening) {
51         if (listening == mListening) {
52             return;
53         }
54         mListening = listening;
55 
56         mQuickQSPanelController.setListening(listening);
57 
58         if (mQuickQSPanelController.switchTileLayout(false)) {
59             mView.updateResources();
60         }
61     }
62 
setContentMargins(int marginStart, int marginEnd)63     public void setContentMargins(int marginStart, int marginEnd) {
64         mQuickQSPanelController.setContentMargins(marginStart, marginEnd);
65     }
66 }
67