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