Use QSPanelController in QSContainerImpl
The QSContainerImpl was accessing the QSPanel directly and, in turn, accessing some of its injected members. By proxying calls through the controller, we should be able to remove the injected members. Bug: 168904199 Test: manual Change-Id: I3aa379f2b64aca12079281096d8134db58031e84
This commit is contained in:
@@ -35,7 +35,7 @@ import com.android.systemui.qs.customize.QSCustomizer;
|
||||
import com.android.wm.shell.animation.PhysicsAnimator;
|
||||
|
||||
/**
|
||||
* Wrapper view with background which contains {@link QSPanel} and {@link BaseStatusBarHeader}
|
||||
* Wrapper view with background which contains {@link QSPanel} and {@link QuickStatusBarHeader}
|
||||
*/
|
||||
public class QSContainerImpl extends FrameLayout {
|
||||
|
||||
@@ -57,7 +57,6 @@ public class QSContainerImpl extends FrameLayout {
|
||||
SpringForce.DAMPING_RATIO_LOW_BOUNCY);
|
||||
private int mBackgroundBottom = -1;
|
||||
private int mHeightOverride = -1;
|
||||
private QSPanel mQSPanel;
|
||||
private View mQSDetail;
|
||||
private QuickStatusBarHeader mHeader;
|
||||
private float mQsExpansion;
|
||||
@@ -81,7 +80,6 @@ public class QSContainerImpl extends FrameLayout {
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mQSPanel = findViewById(R.id.quick_settings_panel);
|
||||
mQSPanelContainer = findViewById(R.id.expanded_qs_scroll_view);
|
||||
mQSDetail = findViewById(R.id.qs_detail);
|
||||
mHeader = findViewById(R.id.header);
|
||||
@@ -90,22 +88,18 @@ public class QSContainerImpl extends FrameLayout {
|
||||
mBackground = findViewById(R.id.quick_settings_background);
|
||||
mStatusBarBackground = findViewById(R.id.quick_settings_status_bar_background);
|
||||
mBackgroundGradient = findViewById(R.id.quick_settings_gradient_view);
|
||||
updateResources();
|
||||
mHeader.getHeaderQsPanel().setMediaVisibilityChangedListener((visible) -> {
|
||||
if (mHeader.getHeaderQsPanel().isShown()) {
|
||||
mAnimateBottomOnNextLayout = true;
|
||||
}
|
||||
});
|
||||
mQSPanel.setMediaVisibilityChangedListener((visible) -> {
|
||||
if (mQSPanel.isShown()) {
|
||||
mAnimateBottomOnNextLayout = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||
}
|
||||
|
||||
void onMediaVisibilityChanged(boolean qsVisible) {
|
||||
mAnimateBottomOnNextLayout = qsVisible;
|
||||
}
|
||||
|
||||
private void setBackgroundBottom(int value) {
|
||||
// We're saving the bottom separately since otherwise the bottom would be overridden in
|
||||
// the layout and the animation wouldn't properly start at the old position.
|
||||
@@ -124,7 +118,6 @@ public class QSContainerImpl extends FrameLayout {
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
setBackgroundGradientVisibility(newConfig);
|
||||
updateResources();
|
||||
mSizePoint.set(0, 0); // Will be retrieved on next measure pass.
|
||||
}
|
||||
|
||||
@@ -197,7 +190,7 @@ public class QSContainerImpl extends FrameLayout {
|
||||
mBackground.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
private void updateResources() {
|
||||
void updateResources(QSPanelController qsPanelController) {
|
||||
LayoutParams layoutParams = (LayoutParams) mQSPanelContainer.getLayoutParams();
|
||||
layoutParams.topMargin = mContext.getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.quick_qs_offset_height);
|
||||
@@ -209,7 +202,7 @@ public class QSContainerImpl extends FrameLayout {
|
||||
boolean marginsChanged = padding != mContentPadding;
|
||||
mContentPadding = padding;
|
||||
if (marginsChanged) {
|
||||
updatePaddingsAndMargins();
|
||||
updatePaddingsAndMargins(qsPanelController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +268,7 @@ public class QSContainerImpl extends FrameLayout {
|
||||
updateExpansion();
|
||||
}
|
||||
|
||||
private void updatePaddingsAndMargins() {
|
||||
private void updatePaddingsAndMargins(QSPanelController qsPanelController) {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View view = getChildAt(i);
|
||||
if (view == mStatusBarBackground || view == mBackgroundGradient
|
||||
@@ -288,8 +281,8 @@ public class QSContainerImpl extends FrameLayout {
|
||||
lp.leftMargin = mSideMargins;
|
||||
if (view == mQSPanelContainer) {
|
||||
// QS panel lays out some of its content full width
|
||||
mQSPanel.setContentMargins(mContentPadding, mContentPadding);
|
||||
Pair<Integer, Integer> margins = mQSPanel.getVisualSideMargins();
|
||||
qsPanelController.setContentMargins(mContentPadding, mContentPadding);
|
||||
Pair<Integer, Integer> margins = qsPanelController.getVisualSideMargins();
|
||||
// Apply paddings based on QSPanel
|
||||
mQSCustomizer.setContentPaddings(margins.first, margins.second);
|
||||
} else if (view == mHeader) {
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import com.android.systemui.qs.dagger.QSScope;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.util.ViewController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -24,13 +27,26 @@ import javax.inject.Inject;
|
||||
/** */
|
||||
@QSScope
|
||||
public class QSContainerImplController extends ViewController<QSContainerImpl> {
|
||||
private final QSPanelController mQsPanelController;
|
||||
private final QuickStatusBarHeaderController mQuickStatusBarHeaderController;
|
||||
private final ConfigurationController mConfigurationController;
|
||||
|
||||
private final ConfigurationController.ConfigurationListener mConfigurationListener =
|
||||
new ConfigurationController.ConfigurationListener() {
|
||||
@Override
|
||||
public void onConfigChanged(Configuration newConfig) {
|
||||
mView.updateResources(mQsPanelController);
|
||||
}
|
||||
};
|
||||
|
||||
@Inject
|
||||
QSContainerImplController(QSContainerImpl view,
|
||||
QuickStatusBarHeaderController quickStatusBarHeaderController) {
|
||||
QSContainerImplController(QSContainerImpl view, QSPanelController qsPanelController,
|
||||
QuickStatusBarHeaderController quickStatusBarHeaderController,
|
||||
ConfigurationController configurationController) {
|
||||
super(view);
|
||||
mQsPanelController = qsPanelController;
|
||||
mQuickStatusBarHeaderController = quickStatusBarHeaderController;
|
||||
mConfigurationController = configurationController;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,10 +60,19 @@ public class QSContainerImplController extends ViewController<QSContainerImpl> {
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
mView.updateResources(mQsPanelController);
|
||||
mQsPanelController.setMediaVisibilityChangedListener((visible) -> {
|
||||
if (mQsPanelController.isShown()) {
|
||||
mView.onMediaVisibilityChanged(true);
|
||||
}
|
||||
});
|
||||
|
||||
mConfigurationController.addCallback(mConfigurationListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewDetached() {
|
||||
mConfigurationController.removeCallback(mConfigurationListener);
|
||||
}
|
||||
|
||||
public QSContainerImpl getView() {
|
||||
|
||||
@@ -20,6 +20,7 @@ import static com.android.systemui.qs.QSPanel.QS_SHOW_BRIGHTNESS;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.res.Configuration;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -35,6 +36,8 @@ import com.android.systemui.settings.BrightnessController;
|
||||
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
@@ -222,5 +225,24 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
|
||||
public void setPageListener(PagedTileLayout.PageListener listener) {
|
||||
mView.setPageListener(listener);
|
||||
}
|
||||
|
||||
/** */
|
||||
public void setMediaVisibilityChangedListener(Consumer<Boolean> visibilityChangedListener) {
|
||||
mView.setMediaVisibilityChangedListener(visibilityChangedListener);
|
||||
}
|
||||
|
||||
public boolean isShown() {
|
||||
return mView.isShown();
|
||||
}
|
||||
|
||||
/** */
|
||||
public void setContentMargins(int startMargin, int endMargin) {
|
||||
mView.setContentMargins(startMargin, endMargin);
|
||||
}
|
||||
|
||||
/** */
|
||||
public Pair<Integer, Integer> getVisualSideMargins() {
|
||||
return mView.getVisualSideMargins();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user