Merge changes I8a56254b,I618e363c into nyc-dev

* changes:
  Fix QS input handling
  Extract QS animations to QSContainer
This commit is contained in:
Jason Monk
2016-02-10 21:56:17 +00:00
committed by Android (Google) Code Review
7 changed files with 213 additions and 312 deletions

View File

@@ -18,13 +18,16 @@
android:id="@+id/quick_settings_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/qs_background_primary"
android:paddingBottom="8dp"
android:elevation="2dp">
android:background="@drawable/qs_background_primary">
<com.android.systemui.qs.QSPanel
android:id="@+id/quick_settings_panel"
android:background="#0000"
android:layout_marginTop="@dimen/status_bar_header_height"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:paddingBottom="8dp" />
<include layout="@layout/quick_status_bar_expanded_header" />
</com.android.systemui.qs.QSContainer>

View File

@@ -39,32 +39,11 @@
android:clipToPadding="false"
android:clipChildren="false">
<com.android.systemui.statusbar.phone.ObservableScrollView
android:id="@+id/scroll_view"
<include
layout="@layout/qs_panel"
android:layout_width="@dimen/notification_panel_width"
android:layout_height="match_parent"
android:layout_gravity="@integer/notification_panel_layout_gravity"
android:scrollbars="none"
android:overScrollMode="never"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
layout="@layout/qs_panel"
android:layout_marginTop="@dimen/status_bar_header_height_expanded"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- A view to reserve space for the collapsed stack -->
<!-- Layout height: notification_min_height + bottom_stack_peek_amount -->
<View
android:id="@+id/reserve_notification_space"
android:layout_height="@dimen/min_stack_height"
android:layout_width="match_parent" />
</LinearLayout>
</com.android.systemui.statusbar.phone.ObservableScrollView>
android:layout_height="wrap_content"
android:layout_gravity="@integer/notification_panel_layout_gravity" />
<com.android.systemui.statusbar.stack.NotificationStackScrollLayout
android:id="@+id/notification_stack_scroller"
@@ -90,12 +69,6 @@
layout="@layout/keyguard_bottom_area"
android:visibility="gone" />
<ViewStub
android:id="@+id/status_bar_header"
android:layout_width="@dimen/notification_panel_width"
android:layout_height="@dimen/status_bar_header_height"
android:layout_gravity="@integer/notification_panel_layout_gravity" />
<com.android.systemui.statusbar.AlphaOptimizedView
android:id="@+id/qs_navbar_scrim"
android:layout_height="96dp"

View File

@@ -16,19 +16,38 @@
package com.android.systemui.qs;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.BaseStatusBarHeader;
import com.android.systemui.statusbar.stack.StackStateAnimator;
/**
* Wrapper view with background which contains {@link QSPanel}
* Wrapper view with background which contains {@link QSPanel} and {@link BaseStatusBarHeader}
*
* Also manages animations for the QS Header and Panel.
*/
public class QSContainer extends FrameLayout {
private static final String TAG = "QSContainer";
private static final boolean DEBUG = false;
private int mHeightOverride = -1;
private QSPanel mQSPanel;
protected BaseStatusBarHeader mHeader;
private float mQsExpansion;
private boolean mQsExpanded;
private boolean mHeaderAnimating;
private boolean mKeyguardShowing;
private boolean mStackScrollerOverscrolling;
private long mDelay;
public QSContainer(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -38,6 +57,7 @@ public class QSContainer extends FrameLayout {
protected void onFinishInflate() {
super.onFinishInflate();
mQSPanel = (QSPanel) findViewById(R.id.quick_settings_panel);
mHeader = (BaseStatusBarHeader) findViewById(R.id.header);
}
@Override
@@ -63,14 +83,132 @@ public class QSContainer extends FrameLayout {
*/
public int getDesiredHeight() {
if (mQSPanel.isClosingDetail()) {
return mQSPanel.getGridHeight() + getPaddingTop() + getPaddingBottom();
return mQSPanel.getGridHeight() + mHeader.getCollapsedHeight() + getPaddingBottom();
} else {
return getMeasuredHeight();
}
}
private void updateBottom() {
int height = mHeightOverride != -1 ? mHeightOverride : getMeasuredHeight();
int heightOverride = mHeightOverride != -1 ? mHeightOverride : getMeasuredHeight();
int height = (int) (mQsExpansion * (heightOverride - mHeader.getCollapsedHeight()))
+ mHeader.getCollapsedHeight();
setBottom(getTop() + height);
}
private void updateQsState() {
boolean expandVisually = mQsExpanded || mStackScrollerOverscrolling || mHeaderAnimating;
mQSPanel.setExpanded(mQsExpanded);
mHeader.setVisibility((mQsExpanded || !mKeyguardShowing || mHeaderAnimating)
? View.VISIBLE
: View.INVISIBLE);
mHeader.setExpanded((mKeyguardShowing && !mHeaderAnimating)
|| (mQsExpanded && !mStackScrollerOverscrolling));
mQSPanel.setVisibility(expandVisually ? View.VISIBLE : View.INVISIBLE);
}
public BaseStatusBarHeader getHeader() {
return mHeader;
}
public QSPanel getQsPanel() {
return mQSPanel;
}
public void setHeaderClickable(boolean clickable) {
if (DEBUG) Log.d(TAG, "setHeaderClickable " + clickable);
mHeader.setClickable(clickable);
}
public void setExpanded(boolean expanded) {
if (DEBUG) Log.d(TAG, "setExpanded " + expanded);
mQsExpanded = expanded;
updateQsState();
}
public void setKeyguardShowing(boolean keyguardShowing) {
if (DEBUG) Log.d(TAG, "setKeyguardShowing " + keyguardShowing);
mKeyguardShowing = keyguardShowing;
updateQsState();
}
public void setOverscrolling(boolean stackScrollerOverscrolling) {
if (DEBUG) Log.d(TAG, "setOverscrolling " + stackScrollerOverscrolling);
mStackScrollerOverscrolling = stackScrollerOverscrolling;
updateQsState();
}
public void setListening(boolean listening) {
if (DEBUG) Log.d(TAG, "setListening " + listening);
mQSPanel.setListening(listening);
mHeader.setListening(listening);
}
public void setQsExpansion(float expansion, float headerTranslation) {
if (DEBUG) Log.d(TAG, "setQSExpansion " + expansion + " " + headerTranslation);
mQsExpansion = expansion;
final float translationScaleY = expansion - 1;
if (!mHeaderAnimating) {
setTranslationY(mKeyguardShowing ? (translationScaleY * mHeader.getHeight())
: headerTranslation);
}
mHeader.setExpansion(mKeyguardShowing ? 1 : expansion);
mQSPanel.setTranslationY(translationScaleY * mQSPanel.getHeight());
updateBottom();
}
public void animateHeaderSlidingIn(long delay) {
if (DEBUG) Log.d(TAG, "animateHeaderSlidingIn");
// If the QS is already expanded we don't need to slide in the header as it's already
// visible.
if (!mQsExpanded) {
mHeaderAnimating = true;
mDelay = delay;
getViewTreeObserver().addOnPreDrawListener(mStartHeaderSlidingIn);
}
}
public void animateHeaderSlidingOut() {
if (DEBUG) Log.d(TAG, "animateHeaderSlidingOut");
mHeaderAnimating = true;
animate().y(-mHeader.getHeight())
.setStartDelay(0)
.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD)
.setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
animate().setListener(null);
mHeaderAnimating = false;
updateQsState();
}
})
.start();
}
private final ViewTreeObserver.OnPreDrawListener mStartHeaderSlidingIn
= new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(this);
animate()
.translationY(0f)
.setStartDelay(mDelay)
.setDuration(StackStateAnimator.ANIMATION_DURATION_GO_TO_FULL_SHADE)
.setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
.setListener(mAnimateHeaderSlidingInListener)
.start();
setY(-mHeader.getHeight());
return true;
}
};
private final Animator.AnimatorListener mAnimateHeaderSlidingInListener
= new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mHeaderAnimating = false;
updateQsState();
}
};
}

View File

@@ -19,7 +19,6 @@ package com.android.systemui.statusbar.phone;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.app.ActivityManager;
import android.app.StatusBarManager;
@@ -35,13 +34,11 @@ import android.util.MathUtils;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewStub;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.accessibility.AccessibilityEvent;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.android.internal.logging.MetricsLogger;
import com.android.keyguard.KeyguardStatusView;
import com.android.systemui.DejankUtils;
@@ -51,7 +48,6 @@ import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.qs.QSContainer;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.FlingAnimationUtils;
@@ -91,13 +87,10 @@ public class NotificationPanelView extends PanelView implements
public static final long DOZE_ANIMATION_DURATION = 700;
private KeyguardAffordanceHelper mAfforanceHelper;
protected BaseStatusBarHeader mHeader;
private KeyguardUserSwitcher mKeyguardUserSwitcher;
private KeyguardStatusBarView mKeyguardStatusBar;
private QSContainer mQsContainer;
private QSPanel mQsPanel;
private KeyguardStatusView mKeyguardStatusView;
private ObservableScrollView mScrollView;
private TextView mClockView;
private View mReserveNotificationSpace;
private View mQsNavbarScrim;
@@ -168,15 +161,12 @@ public class NotificationPanelView extends PanelView implements
* If we are in a panel collapsing motion, we reset scrollY of our scroll view but still
* need to take this into account in our panel height calculation.
*/
private int mScrollYOverride = -1;
private boolean mQsAnimatorExpand;
private boolean mIsLaunchTransitionFinished;
private boolean mIsLaunchTransitionRunning;
private Runnable mLaunchAnimationEndRunnable;
private boolean mOnlyAffordanceInThisMotion;
private boolean mKeyguardStatusViewAnimating;
private boolean mHeaderAnimating;
private ObjectAnimator mQsContainerAnimator;
private ValueAnimator mQsSizeChangeAnimator;
private boolean mShadeEmpty;
@@ -223,19 +213,11 @@ public class NotificationPanelView extends PanelView implements
@Override
protected void onFinishInflate() {
super.onFinishInflate();
ViewStub stub = (ViewStub) findViewById(R.id.status_bar_header);
stub.setLayoutResource(R.layout.quick_status_bar_expanded_header);
mHeader = (BaseStatusBarHeader) stub.inflate();
mHeader.setOnClickListener(this);
mKeyguardStatusBar = (KeyguardStatusBarView) findViewById(R.id.keyguard_header);
mKeyguardStatusView = (KeyguardStatusView) findViewById(R.id.keyguard_status_view);
mQsContainer = (QSContainer) findViewById(R.id.quick_settings_container);
mQsPanel = (QSPanel) findViewById(R.id.quick_settings_panel);
mQsContainer.getHeader().setOnClickListener(this);
mClockView = (TextView) findViewById(R.id.clock_view);
mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view);
mScrollView.setListener(this);
mScrollView.setFocusable(false);
mReserveNotificationSpace = findViewById(R.id.reserve_notification_space);
mNotificationContainerParent = (NotificationsQuickSettingsContainer)
findViewById(R.id.notification_container_parent);
mNotificationStackScroller = (NotificationStackScrollLayout)
@@ -243,7 +225,7 @@ public class NotificationPanelView extends PanelView implements
mNotificationStackScroller.setOnHeightChangedListener(this);
mNotificationStackScroller.setOverscrollTopChangedListener(this);
mNotificationStackScroller.setOnEmptySpaceClickListener(this);
mNotificationStackScroller.setScrollView(mScrollView);
mNotificationStackScroller.setQsContainer(mQsContainer);
mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area);
mQsNavbarScrim = findViewById(R.id.qs_navbar_scrim);
mAfforanceHelper = new KeyguardAffordanceHelper(this, getContext());
@@ -285,12 +267,12 @@ public class NotificationPanelView extends PanelView implements
public void updateResources() {
int panelWidth = getResources().getDimensionPixelSize(R.dimen.notification_panel_width);
int panelGravity = getResources().getInteger(R.integer.notification_panel_layout_gravity);
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mHeader.getLayoutParams();
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mQsContainer.getLayoutParams();
if (lp.width != panelWidth) {
lp.width = panelWidth;
lp.gravity = panelGravity;
mHeader.setLayoutParams(lp);
mHeader.post(mUpdateHeader);
mQsContainer.setLayoutParams(lp);
mQsContainer.post(mUpdateHeader);
}
lp = (FrameLayout.LayoutParams) mNotificationStackScroller.getLayoutParams();
@@ -299,13 +281,6 @@ public class NotificationPanelView extends PanelView implements
lp.gravity = panelGravity;
mNotificationStackScroller.setLayoutParams(lp);
}
lp = (FrameLayout.LayoutParams) mScrollView.getLayoutParams();
if (lp.width != panelWidth) {
lp.width = panelWidth;
lp.gravity = panelGravity;
mScrollView.setLayoutParams(lp);
}
}
@Override
@@ -318,8 +293,8 @@ public class NotificationPanelView extends PanelView implements
// Calculate quick setting heights.
int oldMaxHeight = mQsMaxExpansionHeight;
mQsMinExpansionHeight = mKeyguardShowing ? 0 : mHeader.getCollapsedHeight() + mQsPeekHeight;
mQsMaxExpansionHeight = mHeader.getExpandedHeight() + mQsContainer.getDesiredHeight();
mQsMinExpansionHeight = mKeyguardShowing ? 0 : mQsContainer.getHeader().getHeight();
mQsMaxExpansionHeight = mQsContainer.getDesiredHeight();
positionClockAndNotifications();
if (mQsExpanded && mQsFullyExpanded) {
mQsExpansionHeight = mQsMaxExpansionHeight;
@@ -361,7 +336,7 @@ public class NotificationPanelView extends PanelView implements
requestScrollerTopPaddingUpdate(false /* animate */);
requestPanelHeightUpdate();
int height = (int) mQsSizeChangeAnimator.getAnimatedValue();
mQsContainer.setHeightOverride(height - mHeader.getExpandedHeight());
mQsContainer.setHeightOverride(height);
}
});
mQsSizeChangeAnimator.addListener(new AnimatorListenerAdapter() {
@@ -381,7 +356,7 @@ public class NotificationPanelView extends PanelView implements
boolean animate = mNotificationStackScroller.isAddOrRemoveAnimationPending();
int stackScrollerPadding;
if (mStatusBarState != StatusBarState.KEYGUARD) {
int bottom = mHeader.getCollapsedHeight();
int bottom = mQsContainer.getHeader().getHeight();
stackScrollerPadding = mStatusBarState == StatusBarState.SHADE
? bottom + mQsPeekHeight
: mKeyguardStatusBar.getHeight();
@@ -485,7 +460,7 @@ public class NotificationPanelView extends PanelView implements
public void setQsExpansionEnabled(boolean qsExpansionEnabled) {
mQsExpansionEnabled = qsExpansionEnabled;
mHeader.setClickable(qsExpansionEnabled);
mQsContainer.setHeaderClickable(qsExpansionEnabled);
}
@Override
@@ -676,17 +651,6 @@ public class NotificationPanelView extends PanelView implements
}
}
@Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
// Block request when interacting with the scroll view so we can still intercept the
// scrolling when QS is expanded.
if (mScrollView.isHandlingTouchEvent()) {
return;
}
super.requestDisallowInterceptTouchEvent(disallowIntercept);
}
private void flingQsWithCurrentVelocity(float y, boolean isCancelMotionEvent) {
float vel = getCurrentVelocity();
final boolean expandsQs = flingExpandsQs(vel);
@@ -808,7 +772,7 @@ public class NotificationPanelView extends PanelView implements
}
private boolean isInQsArea(float x, float y) {
return (x >= mScrollView.getX() && x <= mScrollView.getX() + mScrollView.getWidth()) &&
return (x >= mQsContainer.getX() && x <= mQsContainer.getX() + mQsContainer.getWidth()) &&
(y <= mNotificationStackScroller.getBottomMostNotificationBottom()
|| y <= mQsContainer.getY() + mQsContainer.getHeight());
}
@@ -948,7 +912,7 @@ public class NotificationPanelView extends PanelView implements
amount = 0f;
}
float rounded = amount >= 1f ? amount : 0f;
mStackScrollerOverscrolling = rounded != 0f && isRubberbanded;
setOverScrolling(rounded != 0f && isRubberbanded);
mQsExpansionFromOverscroll = rounded != 0f;
mLastOverscroll = rounded;
updateQsState();
@@ -964,12 +928,17 @@ public class NotificationPanelView extends PanelView implements
@Override
public void run() {
mStackScrollerOverscrolling = false;
mQsExpansionFromOverscroll = false;
setOverScrolling(false);
updateQsState();
}
}, false /* isClick */);
}
private void setOverScrolling(boolean overscrolling) {
mStackScrollerOverscrolling = overscrolling;
mQsContainer.setOverscrolling(overscrolling);
}
private void onQsExpansionStarted() {
onQsExpansionStarted(0);
}
@@ -979,11 +948,7 @@ public class NotificationPanelView extends PanelView implements
cancelHeightAnimator();
// Reset scroll position and apply that position to the expanded height.
float height = mQsExpansionHeight - mScrollView.getScrollY() - overscrollAmount;
if (mScrollView.getScrollY() != 0) {
mScrollYOverride = mScrollView.getScrollY();
}
mScrollView.scrollTo(0, 0);
float height = mQsExpansionHeight - overscrollAmount;
setQsExpansion(height);
requestPanelHeightUpdate();
}
@@ -995,9 +960,7 @@ public class NotificationPanelView extends PanelView implements
updateQsState();
requestPanelHeightUpdate();
mFalsingManager.setQsExpanded(expanded);
mNotificationStackScroller.setInterceptDelegateEnabled(expanded);
mStatusBar.setQsExpanded(expanded);
mQsPanel.setExpanded(expanded);
mNotificationContainerParent.setQsExpanded(expanded);
}
}
@@ -1011,15 +974,18 @@ public class NotificationPanelView extends PanelView implements
mStatusBarState = statusBarState;
mKeyguardShowing = keyguardShowing;
mQsContainer.setKeyguardShowing(mKeyguardShowing);
if (goingToFullShade || (oldState == StatusBarState.KEYGUARD
&& statusBarState == StatusBarState.SHADE_LOCKED)) {
animateKeyguardStatusBarOut();
animateHeaderSlidingIn();
long delay = mStatusBarState == StatusBarState.SHADE_LOCKED
? 0 : mStatusBar.calculateGoingToFullShadeDelay();
mQsContainer.animateHeaderSlidingIn(delay);
} else if (oldState == StatusBarState.SHADE_LOCKED
&& statusBarState == StatusBarState.KEYGUARD) {
animateKeyguardStatusBarIn(StackStateAnimator.ANIMATION_DURATION_STANDARD);
animateHeaderSlidingOut();
mQsContainer.animateHeaderSlidingOut();
} else {
mKeyguardStatusBar.setAlpha(1f);
mKeyguardStatusBar.setVisibility(keyguardShowing ? View.VISIBLE : View.INVISIBLE);
@@ -1050,95 +1016,6 @@ public class NotificationPanelView extends PanelView implements
}
};
private final Animator.AnimatorListener mAnimateHeaderSlidingInListener
= new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mHeaderAnimating = false;
mQsContainerAnimator = null;
mQsContainer.removeOnLayoutChangeListener(mQsContainerAnimatorUpdater);
}
};
private final OnLayoutChangeListener mQsContainerAnimatorUpdater
= new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
int oldTop, int oldRight, int oldBottom) {
int oldHeight = oldBottom - oldTop;
int height = bottom - top;
if (height != oldHeight && mQsContainerAnimator != null) {
PropertyValuesHolder[] values = mQsContainerAnimator.getValues();
float newEndValue = mHeader.getCollapsedHeight() + mQsPeekHeight - height - top;
float newStartValue = -height - top;
values[0].setFloatValues(newStartValue, newEndValue);
mQsContainerAnimator.setCurrentPlayTime(mQsContainerAnimator.getCurrentPlayTime());
}
}
};
private final ViewTreeObserver.OnPreDrawListener mStartHeaderSlidingIn
= new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(this);
long delay = mStatusBarState == StatusBarState.SHADE_LOCKED
? 0
: mStatusBar.calculateGoingToFullShadeDelay();
mHeader.setTranslationY(-mHeader.getCollapsedHeight() - mQsPeekHeight);
mHeader.animate()
.translationY(0f)
.setStartDelay(delay)
.setDuration(StackStateAnimator.ANIMATION_DURATION_GO_TO_FULL_SHADE)
.setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
.start();
mQsContainer.setY(-mQsContainer.getHeight());
mQsContainerAnimator = ObjectAnimator.ofFloat(mQsContainer, View.TRANSLATION_Y,
mQsContainer.getTranslationY(),
mHeader.getCollapsedHeight() + mQsPeekHeight - mQsContainer.getHeight()
- mQsContainer.getTop());
mQsContainerAnimator.setStartDelay(delay);
mQsContainerAnimator.setDuration(StackStateAnimator.ANIMATION_DURATION_GO_TO_FULL_SHADE);
mQsContainerAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
mQsContainerAnimator.addListener(mAnimateHeaderSlidingInListener);
mQsContainerAnimator.start();
mQsContainer.addOnLayoutChangeListener(mQsContainerAnimatorUpdater);
return true;
}
};
private void animateHeaderSlidingIn() {
// If the QS is already expanded we don't need to slide in the header as it's already
// visible.
if (!mQsExpanded) {
mHeaderAnimating = true;
getViewTreeObserver().addOnPreDrawListener(mStartHeaderSlidingIn);
}
}
private void animateHeaderSlidingOut() {
mHeaderAnimating = true;
mHeader.animate().y(-mHeader.getHeight())
.setStartDelay(0)
.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD)
.setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mHeader.animate().setListener(null);
mHeaderAnimating = false;
updateQsState();
}
})
.start();
mQsContainer.animate()
.y(-mQsContainer.getHeight())
.setStartDelay(0)
.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD)
.setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
.start();
}
private final Runnable mAnimateKeyguardStatusBarInvisibleEndRunnable = new Runnable() {
@Override
public void run() {
@@ -1262,19 +1139,10 @@ public class NotificationPanelView extends PanelView implements
}
private void updateQsState() {
boolean expandVisually = mQsExpanded || mStackScrollerOverscrolling || mHeaderAnimating;
mHeader.setVisibility((mQsExpanded || !mKeyguardShowing || mHeaderAnimating)
? View.VISIBLE
: View.INVISIBLE);
mHeader.setExpanded((mKeyguardShowing && !mHeaderAnimating)
|| (mQsExpanded && !mStackScrollerOverscrolling));
mQsContainer.setExpanded(mQsExpanded);
mNotificationStackScroller.setScrollingEnabled(
mStatusBarState != StatusBarState.KEYGUARD && (!mQsExpanded
|| mQsExpansionFromOverscroll));
mQsPanel.setVisibility(expandVisually ? View.VISIBLE : View.INVISIBLE);
mQsContainer.setVisibility(
mKeyguardShowing && !expandVisually ? View.INVISIBLE : View.VISIBLE);
mScrollView.setTouchEnabled(mQsExpanded);
updateEmptyShadeView();
mQsNavbarScrim.setVisibility(mStatusBarState == StatusBarState.SHADE && mQsExpanded
&& !mStackScrollerOverscrolling && mQsScrimEnabled
@@ -1298,11 +1166,10 @@ public class NotificationPanelView extends PanelView implements
}
}
mQsExpansionHeight = height;
mHeader.setExpansion(getHeaderExpansionFraction());
setQsTranslation(height);
updateQsExpansion();
requestScrollerTopPaddingUpdate(false /* animate */);
if (mKeyguardShowing) {
updateHeaderKeyguard();
updateHeaderKeyguardAlpha();
}
if (mStatusBarState == StatusBarState.SHADE_LOCKED
|| mStatusBarState == StatusBarState.KEYGUARD) {
@@ -1329,6 +1196,10 @@ public class NotificationPanelView extends PanelView implements
}
}
private void updateQsExpansion() {
mQsContainer.setQsExpansion(getQsExpansionFraction(), getHeaderTranslation());
}
private String getKeyguardOrLockScreenString() {
if (mStatusBarState == StatusBarState.KEYGUARD) {
return getContext().getString(R.string.accessibility_desc_lock_screen);
@@ -1337,23 +1208,6 @@ public class NotificationPanelView extends PanelView implements
}
}
private float getHeaderExpansionFraction() {
if (!mKeyguardShowing) {
return getQsExpansionFraction();
} else {
return 1f;
}
}
private void setQsTranslation(float height) {
if (!mHeaderAnimating) {
mQsContainer.setY(height - mQsContainer.getDesiredHeight() + getHeaderTranslation());
}
if (mKeyguardShowing && !mHeaderAnimating) {
mHeader.setY(interpolate(getQsExpansionFraction(), -mHeader.getHeight(), 0));
}
}
private float calculateQsTopPadding() {
if (mKeyguardShowing
&& (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted)) {
@@ -1372,7 +1226,7 @@ public class NotificationPanelView extends PanelView implements
mQsMinExpansionHeight, max);
} else if (mQsSizeChangeAnimator != null) {
return (int) mQsSizeChangeAnimator.getAnimatedValue();
} else if (mKeyguardShowing && mScrollYOverride == -1) {
} else if (mKeyguardShowing) {
// We can only do the smoother transition on Keyguard when we also are not collapsing
// from a scrolled quick settings.
@@ -1386,7 +1240,6 @@ public class NotificationPanelView extends PanelView implements
private void requestScrollerTopPaddingUpdate(boolean animate) {
mNotificationStackScroller.updateTopPadding(calculateQsTopPadding(),
mScrollView.getScrollY(),
mAnimateNextTopPaddingChange || animate,
mKeyguardShowing
&& (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted));
@@ -1428,7 +1281,6 @@ public class NotificationPanelView extends PanelView implements
boolean isClick) {
float target = expand ? mQsMaxExpansionHeight : mQsMinExpansionHeight;
if (target == mQsExpansionHeight) {
mScrollYOverride = -1;
if (onFinishRunnable != null) {
onFinishRunnable.run();
}
@@ -1438,7 +1290,6 @@ public class NotificationPanelView extends PanelView implements
if (belowFalsingThreshold) {
vel = 0;
}
mScrollView.setBlockFlinging(true);
ValueAnimator animator = ValueAnimator.ofFloat(mQsExpansionHeight, target);
if (isClick) {
animator.setInterpolator(Interpolators.TOUCH_RESPONSE);
@@ -1458,8 +1309,6 @@ public class NotificationPanelView extends PanelView implements
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mScrollView.setBlockFlinging(false);
mScrollYOverride = -1;
mQsExpansionAnimator = null;
if (onFinishRunnable != null) {
onFinishRunnable.run();
@@ -1478,11 +1327,11 @@ public class NotificationPanelView extends PanelView implements
if (!mQsExpansionEnabled || mCollapsedOnDown) {
return false;
}
View header = mKeyguardShowing ? mKeyguardStatusBar : mHeader;
View header = mKeyguardShowing ? mKeyguardStatusBar : mQsContainer.getHeader();
boolean onHeader = x >= header.getX() && x <= header.getX() + header.getWidth()
&& y >= header.getTop() && y <= header.getBottom();
if (mQsExpanded) {
return onHeader || (mScrollView.isScrolledToBottom() && yDiff < 0) && isInQsArea(x, y);
return onHeader || (yDiff < 0 && isInQsArea(x, y));
} else {
return onHeader;
}
@@ -1494,7 +1343,7 @@ public class NotificationPanelView extends PanelView implements
return mStatusBar.getBarState() == StatusBarState.KEYGUARD
|| mNotificationStackScroller.isScrolledToBottom();
} else {
return mScrollView.isScrolledToBottom();
return true;
}
}
@@ -1571,11 +1420,7 @@ public class NotificationPanelView extends PanelView implements
* collapsing QS / the panel when QS was scrolled
*/
private int getTempQsMaxExpansion() {
int qsTempMaxExpansion = mQsMaxExpansionHeight;
if (mScrollYOverride != -1) {
qsTempMaxExpansion -= mScrollYOverride;
}
return qsTempMaxExpansion;
return mQsMaxExpansionHeight;
}
private int calculatePanelHeightShade() {
@@ -1613,20 +1458,12 @@ public class NotificationPanelView extends PanelView implements
+ notificationHeight;
if (totalHeight > mNotificationStackScroller.getHeight()) {
float fullyCollapsedHeight = maxQsHeight
+ mNotificationStackScroller.getMinStackHeight()
- getScrollViewScrollY();
+ mNotificationStackScroller.getMinStackHeight();
totalHeight = Math.max(fullyCollapsedHeight, mNotificationStackScroller.getHeight());
}
return (int) totalHeight;
}
private int getScrollViewScrollY() {
if (mScrollYOverride != -1 && !mQsTracking) {
return mScrollYOverride;
} else {
return mScrollView.getScrollY();
}
}
private void updateNotificationTranslucency() {
float alpha = 1f;
if (mClosingWithAlphaFadeOut && !mExpandingFromHeadsUp && !mHeadsUpManager.hasPinnedHeadsUp()) {
@@ -1678,18 +1515,9 @@ public class NotificationPanelView extends PanelView implements
*/
private void updateHeader() {
if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
updateHeaderKeyguard();
} else {
updateHeaderShade();
updateHeaderKeyguardAlpha();
}
}
private void updateHeaderShade() {
if (!mHeaderAnimating) {
mHeader.setTranslationY(getHeaderTranslation());
}
setQsTranslation(mQsExpansionHeight);
updateQsExpansion();
}
private float getHeaderTranslation() {
@@ -1744,11 +1572,6 @@ public class NotificationPanelView extends PanelView implements
&& !mDozing ? VISIBLE : INVISIBLE);
}
private void updateHeaderKeyguard() {
updateHeaderKeyguardAlpha();
setQsTranslation(mQsExpansionHeight);
}
private void updateKeyguardBottomAreaAlpha() {
float alpha = Math.min(getKeyguardContentsAlpha(), 1 - getQsExpansionFraction());
mKeyguardBottomArea.setAlpha(alpha);
@@ -1781,7 +1604,6 @@ public class NotificationPanelView extends PanelView implements
mNotificationStackScroller.onExpansionStopped();
mHeadsUpManager.onExpandingFinished();
mIsExpanding = false;
mScrollYOverride = -1;
if (isFullyCollapsed()) {
DejankUtils.postAfterTraversal(new Runnable() {
@Override
@@ -1811,9 +1633,8 @@ public class NotificationPanelView extends PanelView implements
}
private void setListening(boolean listening) {
mHeader.setListening(listening);
mQsContainer.setListening(listening);
mKeyguardStatusBar.setListening(listening);
mQsPanel.setListening(listening);
}
@Override
@@ -1931,7 +1752,7 @@ public class NotificationPanelView extends PanelView implements
@Override
public void onClick(View v) {
if (v == mHeader) {
if (v == mQsContainer.getHeader()) {
onQsExpansionStarted();
if (mQsExpanded) {
flingSettings(0 /* vel */, false /* expand */, null, true /* isClick */);
@@ -2149,24 +1970,16 @@ public class NotificationPanelView extends PanelView implements
return mConflictingQsExpansionGesture && mQsExpanded;
}
public void notifyVisibleChildrenChanged() {
if (mNotificationStackScroller.getNotGoneChildCount() != 0) {
mReserveNotificationSpace.setVisibility(View.VISIBLE);
} else {
mReserveNotificationSpace.setVisibility(View.GONE);
}
}
public boolean isQsExpanded() {
return mQsExpanded;
}
public boolean isQsDetailShowing() {
return mQsPanel.isShowingDetail();
return mQsContainer.getQsPanel().isShowingDetail();
}
public void closeQsDetail() {
mQsPanel.closeDetail();
mQsContainer.getQsPanel().closeDetail();
}
@Override
@@ -2254,7 +2067,7 @@ public class NotificationPanelView extends PanelView implements
private final Runnable mUpdateHeader = new Runnable() {
@Override
public void run() {
mHeader.updateEverything();
mQsContainer.getHeader().updateEverything();
}
};
@@ -2400,8 +2213,7 @@ public class NotificationPanelView extends PanelView implements
protected void setVerticalPanelTranslation(float translation) {
mNotificationStackScroller.setTranslationX(translation);
mScrollView.setTranslationX(translation);
mHeader.setTranslationX(translation);
mQsContainer.setTranslationX(translation);
}
private void updateStackHeight(float stackHeight) {

View File

@@ -33,7 +33,7 @@ import com.android.systemui.R;
public class NotificationsQuickSettingsContainer extends FrameLayout
implements ViewStub.OnInflateListener {
private View mScrollView;
private View mQsContainer;
private View mUserSwitcher;
private View mStackScroller;
private View mKeyguardStatusBar;
@@ -47,7 +47,7 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mScrollView = findViewById(R.id.scroll_view);
mQsContainer = findViewById(R.id.quick_settings_container);
mStackScroller = findViewById(R.id.notification_stack_scroller);
mKeyguardStatusBar = findViewById(R.id.keyguard_header);
ViewStub userSwitcher = (ViewStub) findViewById(R.id.keyguard_user_switcher);
@@ -58,7 +58,7 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
reloadWidth(mScrollView);
reloadWidth(mQsContainer);
reloadWidth(mStackScroller);
}
@@ -80,11 +80,11 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
boolean userSwitcherVisible = mInflated && mUserSwitcher.getVisibility() == View.VISIBLE;
boolean statusBarVisible = mKeyguardStatusBar.getVisibility() == View.VISIBLE;
View stackQsTop = mQsExpanded ? mStackScroller : mScrollView;
View stackQsBottom = !mQsExpanded ? mStackScroller : mScrollView;
View stackQsTop = mQsExpanded ? mStackScroller : mQsContainer;
View stackQsBottom = !mQsExpanded ? mStackScroller : mQsContainer;
// Invert the order of the scroll view and user switcher such that the notifications receive
// touches first but the panel gets drawn above.
if (child == mScrollView) {
if (child == mQsContainer) {
return super.drawChild(canvas, userSwitcherVisible && statusBarVisible ? mUserSwitcher
: statusBarVisible ? mKeyguardStatusBar
: userSwitcherVisible ? mUserSwitcher
@@ -104,7 +104,7 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
return super.drawChild(canvas,
stackQsTop,
drawingTime);
}else {
} else {
return super.drawChild(canvas, child, drawingTime);
}
}

View File

@@ -1599,12 +1599,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
updateNotifications();
}
@Override
protected void updateRowStates() {
super.updateRowStates();
mNotificationPanel.notifyVisibleChildrenChanged();
}
@Override
protected void setAreThereNotifications() {

View File

@@ -213,7 +213,6 @@ public class NotificationStackScrollLayout extends ViewGroup
* animating.
*/
private boolean mOnlyScrollingInThisMotion;
private ViewGroup mScrollView;
private boolean mInterceptDelegateEnabled;
private boolean mDelegateToScrollView;
private boolean mDisallowScrollingInThisMotion;
@@ -281,6 +280,7 @@ public class NotificationStackScrollLayout extends ViewGroup
setDimAmount((Float) animation.getAnimatedValue());
}
};
private ViewGroup mQsContainer;
public NotificationStackScrollLayout(Context context) {
this(context, null);
@@ -630,12 +630,8 @@ public class NotificationStackScrollLayout extends ViewGroup
mLongPressListener = listener;
}
public void setScrollView(ViewGroup scrollView) {
mScrollView = scrollView;
}
public void setInterceptDelegateEnabled(boolean interceptDelegateEnabled) {
mInterceptDelegateEnabled = interceptDelegateEnabled;
public void setQsContainer(ViewGroup qsContainer) {
mQsContainer = qsContainer;
}
public void onChildDismissed(View v) {
@@ -883,13 +879,6 @@ public class NotificationStackScrollLayout extends ViewGroup
public boolean onTouchEvent(MotionEvent ev) {
boolean isCancelOrUp = ev.getActionMasked() == MotionEvent.ACTION_CANCEL
|| ev.getActionMasked()== MotionEvent.ACTION_UP;
if (mDelegateToScrollView) {
if (isCancelOrUp) {
mDelegateToScrollView = false;
}
transformTouchEvent(ev, this, mScrollView);
return mScrollView.onTouchEvent(ev);
}
handleEmptySpaceClick(ev);
boolean expandWantsIt = false;
if (mIsExpanded && !mSwipingInProgress && !mOnlyScrollingInThisMotion) {
@@ -929,6 +918,9 @@ public class NotificationStackScrollLayout extends ViewGroup
if (!isScrollingEnabled()) {
return false;
}
if (ev.getY() < mQsContainer.getBottom()) {
return false;
}
initVelocityTrackerIfNotExists();
mVelocityTracker.addMovement(ev);
@@ -1776,15 +1768,13 @@ public class NotificationStackScrollLayout extends ViewGroup
* account.
*
* @param qsHeight the top padding imposed by the quick settings panel
* @param scrollY how much the notifications are scrolled inside the QS/notifications scroll
* container
* @param animate whether to animate the change
* @param ignoreIntrinsicPadding if true, {@link #getIntrinsicPadding()} is ignored and
* {@code qsHeight} is the final top padding
*/
public void updateTopPadding(float qsHeight, int scrollY, boolean animate,
public void updateTopPadding(float qsHeight, boolean animate,
boolean ignoreIntrinsicPadding) {
float start = qsHeight - scrollY;
float start = qsHeight;
float stackHeight = getHeight() - start;
int minStackHeight = getMinStackHeight();
if (stackHeight <= minStackHeight) {
@@ -1867,15 +1857,6 @@ public class NotificationStackScrollLayout extends ViewGroup
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (mInterceptDelegateEnabled) {
transformTouchEvent(ev, this, mScrollView);
if (mScrollView.onInterceptTouchEvent(ev)) {
mDelegateToScrollView = true;
removeLongPressCallback();
return true;
}
transformTouchEvent(ev, mScrollView, this);
}
initDownStates(ev);
handleEmptySpaceClick(ev);
boolean expandWantsIt = false;