• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 static com.android.systemui.classifier.Classifier.QS_SWIPE_NESTED;
20 
21 import android.content.res.Configuration;
22 import android.view.MotionEvent;
23 import android.view.View;
24 
25 import com.android.systemui.plugins.FalsingManager;
26 import com.android.systemui.qs.dagger.QSScope;
27 import com.android.systemui.statusbar.policy.ConfigurationController;
28 import com.android.systemui.util.ViewController;
29 
30 import javax.inject.Inject;
31 
32 /** */
33 @QSScope
34 public class QSContainerImplController extends ViewController<QSContainerImpl> {
35     private final QSPanelController mQsPanelController;
36     private final QuickStatusBarHeaderController mQuickStatusBarHeaderController;
37     private final ConfigurationController mConfigurationController;
38     private final FalsingManager mFalsingManager;
39     private final NonInterceptingScrollView mQSPanelContainer;
40     private final ConfigurationController.ConfigurationListener mConfigurationListener =
41             new ConfigurationController.ConfigurationListener() {
42         @Override
43         public void onConfigChanged(Configuration newConfig) {
44             mView.updateResources(mQsPanelController, mQuickStatusBarHeaderController);
45         }
46     };
47 
48     private final View.OnTouchListener mContainerTouchHandler = new View.OnTouchListener() {
49         @Override
50         public boolean onTouch(View v, MotionEvent event) {
51             if (event.getActionMasked() == MotionEvent.ACTION_UP) {
52                 if (mQSPanelContainer.isPreventingIntercept()) {
53                     // There's really no action here to take, but we need to tell the FalsingManager
54                     mFalsingManager.isFalseTouch(QS_SWIPE_NESTED);
55                 }
56             }
57             return false;
58         }
59     };
60 
61     @Inject
QSContainerImplController( QSContainerImpl view, QSPanelController qsPanelController, QuickStatusBarHeaderController quickStatusBarHeaderController, ConfigurationController configurationController, FalsingManager falsingManager)62     QSContainerImplController(
63             QSContainerImpl view,
64             QSPanelController qsPanelController,
65             QuickStatusBarHeaderController quickStatusBarHeaderController,
66             ConfigurationController configurationController,
67             FalsingManager falsingManager) {
68         super(view);
69         mQsPanelController = qsPanelController;
70         mQuickStatusBarHeaderController = quickStatusBarHeaderController;
71         mConfigurationController = configurationController;
72         mFalsingManager = falsingManager;
73         mQSPanelContainer = mView.getQSPanelContainer();
74     }
75 
76     @Override
onInit()77     public void onInit() {
78         mQuickStatusBarHeaderController.init();
79     }
80 
setListening(boolean listening)81     public void setListening(boolean listening) {
82         mQuickStatusBarHeaderController.setListening(listening);
83     }
84 
85     @Override
onViewAttached()86     protected void onViewAttached() {
87         mView.updateResources(mQsPanelController, mQuickStatusBarHeaderController);
88         mConfigurationController.addCallback(mConfigurationListener);
89         mQSPanelContainer.setOnTouchListener(mContainerTouchHandler);
90     }
91 
92     @Override
onViewDetached()93     protected void onViewDetached() {
94         mConfigurationController.removeCallback(mConfigurationListener);
95         mQSPanelContainer.setOnTouchListener(null);
96     }
97 
getView()98     public QSContainerImpl getView() {
99         return mView;
100     }
101 }
102