Merge "Fix QS shadow disappearing on expand." into oc-dev

This commit is contained in:
Jason Monk
2017-04-24 12:53:34 +00:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 2 deletions

View File

@@ -23,18 +23,25 @@ import android.graphics.Canvas;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.view.ViewStub; import android.view.ViewStub;
import android.view.ViewStub.OnInflateListener;
import android.view.WindowInsets; import android.view.WindowInsets;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.fragments.FragmentHostManager;
import com.android.systemui.fragments.FragmentHostManager.FragmentListener;
import com.android.systemui.plugins.qs.QS; import com.android.systemui.plugins.qs.QS;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.statusbar.NotificationData.Entry;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
/** /**
* The container with notification stack scroller and quick settings inside. * The container with notification stack scroller and quick settings inside.
*/ */
public class NotificationsQuickSettingsContainer extends FrameLayout public class NotificationsQuickSettingsContainer extends FrameLayout
implements ViewStub.OnInflateListener, FragmentHostManager.FragmentListener { implements OnInflateListener, FragmentListener, OnHeadsUpChangedListener {
private FrameLayout mQsFrame; private FrameLayout mQsFrame;
private View mUserSwitcher; private View mUserSwitcher;
@@ -46,6 +53,8 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
private int mBottomPadding; private int mBottomPadding;
private int mStackScrollerMargin; private int mStackScrollerMargin;
private boolean mHeadsUp;
private HeadsUpManager mHeadsUpManager;
public NotificationsQuickSettingsContainer(Context context, AttributeSet attrs) { public NotificationsQuickSettingsContainer(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
@@ -67,12 +76,16 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();
FragmentHostManager.get(this).addTagListener(QS.TAG, this); FragmentHostManager.get(this).addTagListener(QS.TAG, this);
mHeadsUpManager = SysUiServiceProvider.getComponent(getContext(), StatusBar.class)
.mHeadsUpManager;
mHeadsUpManager.addListener(this);
} }
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
FragmentHostManager.get(this).removeTagListener(QS.TAG, this); FragmentHostManager.get(this).removeTagListener(QS.TAG, this);
mHeadsUpManager.removeListener(this);
} }
@Override @Override
@@ -101,7 +114,7 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
boolean userSwitcherVisible = mInflated && mUserSwitcher.getVisibility() == View.VISIBLE; boolean userSwitcherVisible = mInflated && mUserSwitcher.getVisibility() == View.VISIBLE;
boolean statusBarVisible = mKeyguardStatusBar.getVisibility() == View.VISIBLE; boolean statusBarVisible = mKeyguardStatusBar.getVisibility() == View.VISIBLE;
final boolean qsBottom = mQsExpanded && !mCustomizerAnimating; final boolean qsBottom = mHeadsUp;
View stackQsTop = qsBottom ? mStackScroller : mQsFrame; View stackQsTop = qsBottom ? mStackScroller : mQsFrame;
View stackQsBottom = !qsBottom ? mStackScroller : mQsFrame; View stackQsBottom = !qsBottom ? mStackScroller : mQsFrame;
// Invert the order of the scroll view and user switcher such that the notifications receive // Invert the order of the scroll view and user switcher such that the notifications receive
@@ -176,4 +189,14 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
params.bottomMargin = bottomMargin; params.bottomMargin = bottomMargin;
v.setLayoutParams(params); v.setLayoutParams(params);
} }
@Override
public void onHeadsUpStateChanged(Entry entry, boolean isHeadsUp) {
boolean hasHeadsUp = mHeadsUpManager.getAllEntries().size() != 0;
if (mHeadsUp == hasHeadsUp) {
return;
}
mHeadsUp = hasHeadsUp;
invalidate();
}
} }

View File

@@ -170,6 +170,10 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
mListeners.add(listener); mListeners.add(listener);
} }
public void removeListener(OnHeadsUpChangedListener listener) {
mListeners.remove(listener);
}
public StatusBar getBar() { public StatusBar getBar() {
return mBar; return mBar;
} }