Merge "Hide QS panel upon DISABLE2_QUICK_SETTINGS." into pi-dev
am: 859a132aa1
Change-Id: I9f52c523cf893d6e45563a54dee4548e3f2ef152
This commit is contained in:
@@ -16,17 +16,19 @@
|
||||
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SysUiServiceProvider;
|
||||
import com.android.systemui.qs.customize.QSCustomizer;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
|
||||
/**
|
||||
* Wrapper view with background which contains {@link QSPanel} and {@link BaseStatusBarHeader}
|
||||
@@ -48,6 +50,7 @@ public class QSContainerImpl extends FrameLayout {
|
||||
private View mStatusBarBackground;
|
||||
|
||||
private int mSideMargins;
|
||||
private boolean mQsDisabled;
|
||||
|
||||
public QSContainerImpl(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -96,6 +99,16 @@ public class QSContainerImpl extends FrameLayout {
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if (mQsDisabled) {
|
||||
// Only show the status bar contents in QQS header when QS is disabled.
|
||||
mHeader.measure(widthMeasureSpec, heightMeasureSpec);
|
||||
LayoutParams layoutParams = (LayoutParams) mHeader.getLayoutParams();
|
||||
int height = layoutParams.topMargin + layoutParams.bottomMargin
|
||||
+ mHeader.getMeasuredHeight();
|
||||
super.onMeasure(
|
||||
widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
|
||||
return;
|
||||
}
|
||||
// Since we control our own bottom, be whatever size we want.
|
||||
// Otherwise the QSPanel ends up with 0 height when the window is only the
|
||||
// size of the status bar.
|
||||
@@ -121,6 +134,15 @@ public class QSContainerImpl extends FrameLayout {
|
||||
updateExpansion();
|
||||
}
|
||||
|
||||
public void disable(int state1, int state2, boolean animate) {
|
||||
final boolean disabled = (state2 & DISABLE2_QUICK_SETTINGS) != 0;
|
||||
if (disabled == mQsDisabled) return;
|
||||
mQsDisabled = disabled;
|
||||
mBackgroundGradient.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
|
||||
mQSPanel.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
|
||||
mQSFooter.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
private void updateResources() {
|
||||
LayoutParams layoutParams = (LayoutParams) mQSPanel.getLayoutParams();
|
||||
layoutParams.topMargin = mContext.getResources().getDimensionPixelSize(
|
||||
|
||||
@@ -69,4 +69,6 @@ public interface QSFooter {
|
||||
*/
|
||||
@Nullable
|
||||
View getExpandView();
|
||||
|
||||
default void disable(int state1, int state2, boolean animate) {}
|
||||
}
|
||||
|
||||
@@ -47,10 +47,8 @@ import com.android.settingslib.graph.SignalDrawable;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.R.dimen;
|
||||
import com.android.systemui.SysUiServiceProvider;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
import com.android.systemui.qs.TouchAnimator.Builder;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.phone.MultiUserSwitch;
|
||||
import com.android.systemui.statusbar.phone.SettingsButton;
|
||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
@@ -62,8 +60,7 @@ import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChange
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
|
||||
public class QSFooterImpl extends FrameLayout implements QSFooter,
|
||||
OnClickListener, OnUserInfoChangedListener, EmergencyListener,
|
||||
SignalCallback, CommandQueue.Callbacks {
|
||||
OnClickListener, OnUserInfoChangedListener, EmergencyListener, SignalCallback {
|
||||
|
||||
private ActivityStarter mActivityStarter;
|
||||
private UserInfoController mUserInfoController;
|
||||
@@ -210,17 +207,10 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallbacks(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@VisibleForTesting
|
||||
public void onDetachedFromWindow() {
|
||||
setListening(false);
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).removeCallbacks(this);
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,12 @@
|
||||
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
@@ -35,12 +38,14 @@ import android.widget.FrameLayout.LayoutParams;
|
||||
import com.android.systemui.Interpolators;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.R.id;
|
||||
import com.android.systemui.SysUiServiceProvider;
|
||||
import com.android.systemui.plugins.qs.QS;
|
||||
import com.android.systemui.qs.customize.QSCustomizer;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer;
|
||||
import com.android.systemui.statusbar.stack.StackStateAnimator;
|
||||
|
||||
public class QSFragment extends Fragment implements QS {
|
||||
public class QSFragment extends Fragment implements QS, CommandQueue.Callbacks {
|
||||
private static final String TAG = "QS";
|
||||
private static final boolean DEBUG = false;
|
||||
private static final String EXTRA_EXPANDED = "expanded";
|
||||
@@ -65,6 +70,7 @@ public class QSFragment extends Fragment implements QS {
|
||||
private int mLayoutDirection;
|
||||
private QSFooter mFooter;
|
||||
private float mLastQSExpansion = -1;
|
||||
private boolean mQsDisabled;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@@ -176,6 +182,17 @@ public class QSFragment extends Fragment implements QS {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(int state1, int state2, boolean animate) {
|
||||
final boolean disabled = (state2 & DISABLE2_QUICK_SETTINGS) != 0;
|
||||
if (disabled == mQsDisabled) return;
|
||||
mQsDisabled = disabled;
|
||||
mContainer.disable(state1, state2, animate);
|
||||
mHeader.disable(state1, state2, animate);
|
||||
mFooter.disable(state1, state2, animate);
|
||||
updateQsState();
|
||||
}
|
||||
|
||||
private void updateQsState() {
|
||||
final boolean expandVisually = mQsExpanded || mStackScrollerOverscrolling
|
||||
|| mHeaderAnimating;
|
||||
@@ -189,6 +206,9 @@ public class QSFragment extends Fragment implements QS {
|
||||
mFooter.setVisibility((mQsExpanded || !mKeyguardShowing || mHeaderAnimating)
|
||||
? View.VISIBLE
|
||||
: View.INVISIBLE);
|
||||
if (mQsDisabled) {
|
||||
mFooter.setVisibility(View.GONE);
|
||||
}
|
||||
mFooter.setExpanded((mKeyguardShowing && !mHeaderAnimating)
|
||||
|| (mQsExpanded && !mStackScrollerOverscrolling));
|
||||
mQSPanel.setVisibility(expandVisually ? View.VISIBLE : View.INVISIBLE);
|
||||
@@ -258,6 +278,12 @@ public class QSFragment extends Fragment implements QS {
|
||||
mHeader.setListening(listening);
|
||||
mFooter.setListening(listening);
|
||||
mQSPanel.setListening(mListening && mQsExpanded);
|
||||
if (listening) {
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallbacks(this);
|
||||
} else {
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class)
|
||||
.removeCallbacks(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,7 +68,7 @@ import java.util.Locale;
|
||||
* battery) and also contains the {@link QuickQSPanel} along with some of the panel's inner
|
||||
* contents.
|
||||
*/
|
||||
public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue.Callbacks,
|
||||
public class QuickStatusBarHeader extends RelativeLayout implements
|
||||
View.OnClickListener, NextAlarmController.NextAlarmChangeCallback {
|
||||
private static final String TAG = "QuickStatusBarHeader";
|
||||
private static final boolean DEBUG = false;
|
||||
@@ -249,8 +249,9 @@ public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue
|
||||
com.android.internal.R.dimen.quick_qs_offset_height);
|
||||
mSystemIconsView.setLayoutParams(mSystemIconsView.getLayoutParams());
|
||||
|
||||
getLayoutParams().height =
|
||||
resources.getDimensionPixelSize(com.android.internal.R.dimen.quick_qs_total_height);
|
||||
getLayoutParams().height = resources.getDimensionPixelSize(mQsDisabled
|
||||
? com.android.internal.R.dimen.quick_qs_offset_height
|
||||
: com.android.internal.R.dimen.quick_qs_total_height);
|
||||
setLayoutParams(getLayoutParams());
|
||||
|
||||
updateStatusIconAlphaAnimator();
|
||||
@@ -320,20 +321,18 @@ public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue
|
||||
TOOLTIP_NOT_YET_SHOWN_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(int state1, int state2, boolean animate) {
|
||||
final boolean disabled = (state2 & DISABLE2_QUICK_SETTINGS) != 0;
|
||||
if (disabled == mQsDisabled) return;
|
||||
mQsDisabled = disabled;
|
||||
mHeaderQsPanel.setDisabledByPolicy(disabled);
|
||||
final int rawHeight = (int) getResources().getDimension(
|
||||
com.android.internal.R.dimen.quick_qs_total_height);
|
||||
getLayoutParams().height = disabled ? (rawHeight - mHeaderQsPanel.getHeight()) : rawHeight;
|
||||
mHeaderTextContainerView.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
|
||||
mQuickQsStatusIcons.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
|
||||
updateResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallbacks(this);
|
||||
Dependency.get(StatusBarIconController.class).addIconGroup(mIconManager);
|
||||
requestApplyInsets();
|
||||
}
|
||||
@@ -354,7 +353,6 @@ public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue
|
||||
@VisibleForTesting
|
||||
public void onDetachedFromWindow() {
|
||||
setListening(false);
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).removeCallbacks(this);
|
||||
Dependency.get(StatusBarIconController.class).removeIconGroup(mIconManager);
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user