Merge "Overscroll header when expanding the panel." into lmp-preview-dev

This commit is contained in:
Jorim Jaggi
2014-05-31 12:21:11 +00:00
committed by Android (Google) Code Review
3 changed files with 68 additions and 18 deletions

View File

@@ -45,9 +45,10 @@ import java.util.ArrayList;
public class NotificationPanelView extends PanelView implements
ExpandableView.OnHeightChangedListener, ObservableScrollView.Listener,
View.OnClickListener, KeyguardPageSwipeHelper.Callback {
View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener,
KeyguardPageSwipeHelper.Callback {
private static float EXPANSION_RUBBER_BAND_EXTRA_FACTOR = 0.4f;
private static float EXPANSION_RUBBER_BAND_EXTRA_FACTOR = 0.6f;
private KeyguardPageSwipeHelper mPageSwiper;
PhoneStatusBar mStatusBar;
@@ -86,6 +87,7 @@ public class NotificationPanelView extends PanelView implements
private int mQsPeekHeight;
private float mNotificationTranslation;
private int mStackScrollerIntrinsicPadding;
private boolean mStackScrollerOverscrolling;
private boolean mQsExpansionEnabled = true;
private ValueAnimator mQsExpansionAnimator;
private FlingAnimationUtils mFlingAnimationUtils;
@@ -139,6 +141,7 @@ public class NotificationPanelView extends PanelView implements
mNotificationStackScroller = (NotificationStackScrollLayout)
findViewById(R.id.notification_stack_scroller);
mNotificationStackScroller.setOnHeightChangedListener(this);
mNotificationStackScroller.setOverscrollTopChangedListener(this);
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
android.R.interpolator.fast_out_slow_in);
mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area);
@@ -172,7 +175,9 @@ public class NotificationPanelView extends PanelView implements
setQsStackScrollerPadding(mQsMaxExpansionHeight);
}
} else {
setQsExpansion(mQsMinExpansionHeight);
if (!mStackScrollerOverscrolling) {
setQsExpansion(mQsMinExpansionHeight);
}
positionClockAndNotifications();
mNotificationStackScroller.setStackHeight(getExpandedHeight());
}
@@ -185,7 +190,10 @@ public class NotificationPanelView extends PanelView implements
private void positionClockAndNotifications() {
boolean animateClock = mNotificationStackScroller.isAddOrRemoveAnimationPending();
if (mStatusBar.getBarState() != StatusBarState.KEYGUARD) {
mStackScrollerIntrinsicPadding = mHeader.getBottom() + mQsPeekHeight
int bottom = mStackScrollerOverscrolling
? mHeader.getCollapsedHeight()
: mHeader.getBottom();
mStackScrollerIntrinsicPadding = bottom + mQsPeekHeight
+ mNotificationTopPadding;
mTopPaddingAdjustment = 0;
} else {
@@ -489,6 +497,16 @@ public class NotificationPanelView extends PanelView implements
}
}
@Override
public void onOverscrollTopChanged(float amount) {
cancelAnimation();
float rounded = amount >= 1f ? amount : 0f;
mStackScrollerOverscrolling = rounded != 0f;
setQsExpansion(mQsMinExpansionHeight + rounded);
updateQsState();
}
private void onQsExpansionStarted() {
onQsExpansionStarted(0);
}
@@ -516,9 +534,10 @@ public class NotificationPanelView extends PanelView implements
}
private void updateQsState() {
mHeader.setExpanded(mQsExpanded);
boolean expandVisually = mQsExpanded || mStackScrollerOverscrolling;
mHeader.setExpanded(expandVisually, mStackScrollerOverscrolling);
mNotificationStackScroller.setEnabled(!mQsExpanded);
mQsPanel.setVisibility(mQsExpanded ? View.VISIBLE : View.INVISIBLE);
mQsPanel.setVisibility(expandVisually ? View.VISIBLE : View.INVISIBLE);
mQsContainer.setVisibility(mKeyguardShowing && !mQsExpanded
? View.INVISIBLE
: View.VISIBLE);
@@ -528,7 +547,7 @@ public class NotificationPanelView extends PanelView implements
private void setQsExpansion(float height) {
height = Math.min(Math.max(height, mQsMinExpansionHeight), mQsMaxExpansionHeight);
mQsFullyExpanded = height == mQsMaxExpansionHeight;
if (height > mQsMinExpansionHeight && !mQsExpanded) {
if (height > mQsMinExpansionHeight && !mQsExpanded && !mStackScrollerOverscrolling) {
setQsExpanded(true);
} else if (height <= mQsMinExpansionHeight && mQsExpanded) {
setQsExpanded(false);
@@ -536,7 +555,9 @@ public class NotificationPanelView extends PanelView implements
mQsExpansionHeight = height;
mHeader.setExpansion(height - mQsPeekHeight);
setQsTranslation(height);
setQsStackScrollerPadding(height);
if (!mStackScrollerOverscrolling) {
setQsStackScrollerPadding(height);
}
mStatusBar.userActivity();
}

View File

@@ -44,6 +44,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
private static final float EXPANSION_RUBBERBAND_FACTOR = 0.35f;
private boolean mExpanded;
private boolean mOverscrolled;
private boolean mKeyguardShowing;
private View mBackground;
@@ -125,10 +126,12 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
return mExpandedHeight;
}
public void setExpanded(boolean expanded) {
public void setExpanded(boolean expanded, boolean overscrolled) {
boolean changed = expanded != mExpanded;
boolean overscrollChanged = overscrolled != mOverscrolled;
mExpanded = expanded;
if (changed) {
mOverscrolled = overscrolled;
if (changed || overscrollChanged) {
updateHeights();
updateVisibilities();
updateSystemIconsLayoutParams();
@@ -136,7 +139,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
updateZTranslation();
updateClickTargets();
if (mQSPanel != null) {
mQSPanel.setExpanded(expanded);
mQSPanel.setExpanded(expanded && !overscrolled);
}
}
}
@@ -184,13 +187,13 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
mDateTime.setVisibility(onKeyguardAndCollapsed ? View.INVISIBLE : View.VISIBLE);
mKeyguardCarrierText.setVisibility(onKeyguardAndCollapsed ? View.VISIBLE : View.GONE);
mDate.setVisibility(mExpanded ? View.VISIBLE : View.GONE);
mSettingsButton.setVisibility(mExpanded ? View.VISIBLE : View.GONE);
mSettingsButton.setVisibility(mExpanded && !mOverscrolled ? View.VISIBLE : View.GONE);
mBrightnessContainer.setVisibility(mExpanded ? View.VISIBLE : View.GONE);
if (mStatusIcons != null) {
mStatusIcons.setVisibility(!mExpanded ? View.VISIBLE : View.GONE);
mStatusIcons.setVisibility(!mExpanded || mOverscrolled ? View.VISIBLE : View.GONE);
}
if (mSignalCluster != null) {
mSignalCluster.setVisibility(!mExpanded ? View.VISIBLE : View.GONE);
mSignalCluster.setVisibility(!mExpanded || mOverscrolled ? View.VISIBLE : View.GONE);
}
}

View File

@@ -18,13 +18,10 @@ package com.android.systemui.statusbar.stack;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
@@ -40,8 +37,8 @@ import com.android.systemui.SwipeHelper;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.SpeedBumpView;
import com.android.systemui.statusbar.stack.StackScrollState.ViewState;
import com.android.systemui.statusbar.policy.ScrollAdapter;
import com.android.systemui.statusbar.stack.StackScrollState.ViewState;
import java.util.ArrayList;
@@ -121,6 +118,7 @@ public class NotificationStackScrollLayout extends ViewGroup
private float mOverScrolledBottomPixels;
private OnChildLocationsChangedListener mListener;
private OnOverscrollTopChangedListener mOverscrollTopChangedListener;
private ExpandableView.OnHeightChangedListener mOnHeightChangedListener;
private boolean mNeedsAnimation;
private boolean mTopPaddingNeedsAnimation;
@@ -875,9 +873,24 @@ public class NotificationStackScrollLayout extends ViewGroup
setOverScrolledPixels(amount / RUBBER_BAND_FACTOR, onTop);
mAmbientState.setOverScrollAmount(amount, onTop);
requestChildrenUpdate();
if (onTop) {
float scrollAmount = mOwnScrollY < 0 ? -mOwnScrollY : 0;
notifyOverscrollTopListener(scrollAmount + amount);
}
}
}
private void notifyOverscrollTopListener(float amount) {
if (mOverscrollTopChangedListener != null) {
mOverscrollTopChangedListener.onOverscrollTopChanged(amount);
}
}
public void setOverscrollTopChangedListener(
OnOverscrollTopChangedListener overscrollTopChangedListener) {
mOverscrollTopChangedListener = overscrollTopChangedListener;
}
public float getCurrentOverScrollAmount(boolean top) {
return mAmbientState.getOverScrollAmount(top);
}
@@ -913,6 +926,12 @@ public class NotificationStackScrollLayout extends ViewGroup
onScrollChanged(mScrollX, mOwnScrollY, oldX, oldY);
invalidateParentIfNeeded();
updateChildren();
float overScrollTop = getCurrentOverScrollAmount(true);
if (mOwnScrollY < 0) {
notifyOverscrollTopListener(-mOwnScrollY + overScrollTop);
} else {
notifyOverscrollTopListener(overScrollTop);
}
}
} else {
customScrollTo(scrollY);
@@ -1596,6 +1615,13 @@ public class NotificationStackScrollLayout extends ViewGroup
public void onChildLocationsChanged(NotificationStackScrollLayout stackScrollLayout);
}
/**
* A listener that gets notified when the overscroll at the top has changed.
*/
public interface OnOverscrollTopChangedListener {
public void onOverscrollTopChanged(float amount);
}
static class AnimationEvent {
static AnimationFilter[] FILTERS = new AnimationFilter[] {