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