am 6b770744: Merge "Fix quick settings on Keyguard" into lmp-mr1-dev

* commit '6b77074438f191de4fcfa1f1560fb5f038cb8173':
  Fix quick settings on Keyguard
This commit is contained in:
Jorim Jaggi
2014-11-24 20:01:19 +00:00
committed by Android Git Automerger
3 changed files with 54 additions and 13 deletions

View File

@@ -23,6 +23,9 @@ import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.MathUtils; import android.util.MathUtils;
import android.view.MotionEvent; import android.view.MotionEvent;
@@ -52,6 +55,8 @@ public class NotificationPanelView extends PanelView implements
View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener, View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener,
KeyguardAffordanceHelper.Callback, NotificationStackScrollLayout.OnEmptySpaceClickListener { KeyguardAffordanceHelper.Callback, NotificationStackScrollLayout.OnEmptySpaceClickListener {
private static final boolean DEBUG = false;
// Cap and total height of Roboto font. Needs to be adjusted when font for the big clock is // Cap and total height of Roboto font. Needs to be adjusted when font for the big clock is
// changed. // changed.
private static final int CAP_HEIGHT = 1456; private static final int CAP_HEIGHT = 1456;
@@ -169,6 +174,7 @@ public class NotificationPanelView extends PanelView implements
public NotificationPanelView(Context context, AttributeSet attrs) { public NotificationPanelView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
setWillNotDraw(!DEBUG);
} }
public void setStatusBar(PhoneStatusBar bar) { public void setStatusBar(PhoneStatusBar bar) {
@@ -503,11 +509,11 @@ public class NotificationPanelView extends PanelView implements
} }
if (Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX) if (Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX)
&& shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, h)) { && shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, h)) {
mQsTracking = true;
onQsExpansionStarted(); onQsExpansionStarted();
mInitialHeightOnTouch = mQsExpansionHeight; mInitialHeightOnTouch = mQsExpansionHeight;
mInitialTouchY = y; mInitialTouchY = y;
mInitialTouchX = x; mInitialTouchX = x;
mQsTracking = true;
mIntercepting = false; mIntercepting = false;
mNotificationStackScroller.removeLongPressCallback(); mNotificationStackScroller.removeLongPressCallback();
return true; return true;
@@ -747,11 +753,11 @@ public class NotificationPanelView extends PanelView implements
public void onOverscrolled(float lastTouchX, float lastTouchY, int amount) { public void onOverscrolled(float lastTouchX, float lastTouchY, int amount) {
if (mIntercepting && shouldQuickSettingsIntercept(lastTouchX, lastTouchY, if (mIntercepting && shouldQuickSettingsIntercept(lastTouchX, lastTouchY,
-1 /* yDiff: Not relevant here */)) { -1 /* yDiff: Not relevant here */)) {
mQsTracking = true;
onQsExpansionStarted(amount); onQsExpansionStarted(amount);
mInitialHeightOnTouch = mQsExpansionHeight; mInitialHeightOnTouch = mQsExpansionHeight;
mInitialTouchY = mLastTouchY; mInitialTouchY = mLastTouchY;
mInitialTouchX = mLastTouchX; mInitialTouchX = mLastTouchX;
mQsTracking = true;
} }
} }
@@ -798,6 +804,7 @@ public class NotificationPanelView extends PanelView implements
} }
mScrollView.scrollTo(0, 0); mScrollView.scrollTo(0, 0);
setQsExpansion(height); setQsExpansion(height);
requestPanelHeightUpdate();
} }
private void setQsExpanded(boolean expanded) { private void setQsExpanded(boolean expanded) {
@@ -1077,6 +1084,9 @@ public class NotificationPanelView extends PanelView implements
R.string.accessibility_desc_quick_settings)); R.string.accessibility_desc_quick_settings));
mLastAnnouncementWasQuickSettings = true; mLastAnnouncementWasQuickSettings = true;
} }
if (DEBUG) {
invalidate();
}
} }
private String getKeyguardOrLockScreenString() { private String getKeyguardOrLockScreenString() {
@@ -1239,11 +1249,9 @@ public class NotificationPanelView extends PanelView implements
@Override @Override
protected boolean isScrolledToBottom() { protected boolean isScrolledToBottom() {
if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
return true;
}
if (!isInSettings()) { if (!isInSettings()) {
return mNotificationStackScroller.isScrolledToBottom(); return mStatusBar.getBarState() == StatusBarState.KEYGUARD
|| mNotificationStackScroller.isScrolledToBottom();
} else { } else {
return mScrollView.isScrolledToBottom(); return mScrollView.isScrolledToBottom();
} }
@@ -1260,7 +1268,7 @@ public class NotificationPanelView extends PanelView implements
} }
int maxHeight; int maxHeight;
if (mTwoFingerQsExpand || mQsExpanded || mIsExpanding && mQsExpandedWhenExpandingStarted) { if (mTwoFingerQsExpand || mQsExpanded || mIsExpanding && mQsExpandedWhenExpandingStarted) {
maxHeight = Math.max(calculatePanelHeightQsExpanded(), calculatePanelHeightShade()); maxHeight = calculatePanelHeightQsExpanded();
} else { } else {
maxHeight = calculatePanelHeightShade(); maxHeight = calculatePanelHeightShade();
} }
@@ -1289,8 +1297,7 @@ public class NotificationPanelView extends PanelView implements
// In Shade, interpolate linearly such that QS is closed whenever panel height is // In Shade, interpolate linearly such that QS is closed whenever panel height is
// minimum QS expansion + minStackHeight // minimum QS expansion + minStackHeight
float panelHeightQsCollapsed = mNotificationStackScroller.getIntrinsicPadding() float panelHeightQsCollapsed = mNotificationStackScroller.getIntrinsicPadding()
+ mNotificationStackScroller.getMinStackHeight() + mNotificationStackScroller.getMinStackHeight();
+ mNotificationStackScroller.getNotificationTopPadding();
float panelHeightQsExpanded = calculatePanelHeightQsExpanded(); float panelHeightQsExpanded = calculatePanelHeightQsExpanded();
t = (expandedHeight - panelHeightQsCollapsed) t = (expandedHeight - panelHeightQsCollapsed)
/ (panelHeightQsExpanded - panelHeightQsCollapsed); / (panelHeightQsExpanded - panelHeightQsCollapsed);
@@ -1302,6 +1309,9 @@ public class NotificationPanelView extends PanelView implements
updateHeader(); updateHeader();
updateUnlockIcon(); updateUnlockIcon();
updateNotificationTranslucency(); updateNotificationTranslucency();
if (DEBUG) {
invalidate();
}
} }
/** /**
@@ -1340,7 +1350,9 @@ public class NotificationPanelView extends PanelView implements
} }
float totalHeight = Math.max( float totalHeight = Math.max(
mQsMaxExpansionHeight + mNotificationStackScroller.getNotificationTopPadding(), mQsMaxExpansionHeight + mNotificationStackScroller.getNotificationTopPadding(),
mClockPositionResult.stackScrollerPadding - mTopPaddingAdjustment) mStatusBarState == StatusBarState.KEYGUARD
? mClockPositionResult.stackScrollerPadding - mTopPaddingAdjustment
: 0)
+ notificationHeight; + notificationHeight;
if (totalHeight > mNotificationStackScroller.getHeight()) { if (totalHeight > mNotificationStackScroller.getHeight()) {
float fullyCollapsedHeight = mQsMaxExpansionHeight float fullyCollapsedHeight = mQsMaxExpansionHeight
@@ -1353,7 +1365,7 @@ public class NotificationPanelView extends PanelView implements
} }
private int getScrollViewScrollY() { private int getScrollViewScrollY() {
if (mScrollYOverride != -1) { if (mScrollYOverride != -1 && !mQsTracking) {
return mScrollYOverride; return mScrollYOverride;
} else { } else {
return mScrollView.getScrollY(); return mScrollView.getScrollY();
@@ -1874,4 +1886,30 @@ public class NotificationPanelView extends PanelView implements
public void onEmptySpaceClicked(float x, float y) { public void onEmptySpaceClicked(float x, float y) {
onEmptySpaceClick(x); onEmptySpaceClick(x);
} }
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (DEBUG) {
Paint p = new Paint();
p.setColor(Color.RED);
p.setStrokeWidth(2);
p.setStyle(Paint.Style.STROKE);
canvas.drawLine(0, getMaxPanelHeight(), getWidth(), getMaxPanelHeight(), p);
p.setColor(Color.BLUE);
canvas.drawLine(0, getExpandedHeight(), getWidth(), getExpandedHeight(), p);
p.setColor(Color.GREEN);
canvas.drawLine(0, calculatePanelHeightQsExpanded(), getWidth(),
calculatePanelHeightQsExpanded(), p);
p.setColor(Color.YELLOW);
canvas.drawLine(0, calculatePanelHeightShade(), getWidth(),
calculatePanelHeightShade(), p);
p.setColor(Color.MAGENTA);
canvas.drawLine(0, calculateQsTopPadding(), getWidth(),
calculateQsTopPadding(), p);
p.setColor(Color.CYAN);
canvas.drawLine(0, mNotificationStackScroller.getTopPadding(), getWidth(),
mNotificationStackScroller.getTopPadding(), p);
}
}
} }

View File

@@ -168,6 +168,7 @@ public class StatusBarWindowView extends FrameLayout {
if (mNotificationPanel.isFullyExpanded() if (mNotificationPanel.isFullyExpanded()
&& mStackScrollLayout.getVisibility() == View.VISIBLE && mStackScrollLayout.getVisibility() == View.VISIBLE
&& mService.getBarState() == StatusBarState.KEYGUARD && mService.getBarState() == StatusBarState.KEYGUARD
&& !mService.isQsExpanded()
&& !mService.isBouncerShowing()) { && !mService.isBouncerShowing()) {
intercept = mDragDownHelper.onInterceptTouchEvent(ev); intercept = mDragDownHelper.onInterceptTouchEvent(ev);
// wake up on a touch down event, if dozing // wake up on a touch down event, if dozing

View File

@@ -464,7 +464,8 @@ public class NotificationStackScrollLayout extends ViewGroup
int newStackHeight = (int) height; int newStackHeight = (int) height;
int minStackHeight = getMinStackHeight(); int minStackHeight = getMinStackHeight();
int stackHeight; int stackHeight;
if (newStackHeight - mTopPadding >= minStackHeight || getNotGoneChildCount() == 0) { if (newStackHeight - mTopPadding - mTopPaddingOverflow >= minStackHeight
|| getNotGoneChildCount() == 0) {
setTranslationY(mTopPaddingOverflow); setTranslationY(mTopPaddingOverflow);
stackHeight = newStackHeight; stackHeight = newStackHeight;
} else { } else {
@@ -474,7 +475,8 @@ public class NotificationStackScrollLayout extends ViewGroup
int translationY = (newStackHeight - minStackHeight); int translationY = (newStackHeight - minStackHeight);
// A slight parallax effect is introduced in order for the stack to catch up with // A slight parallax effect is introduced in order for the stack to catch up with
// the top card. // the top card.
float partiallyThere = (float) (newStackHeight - mTopPadding) / minStackHeight; float partiallyThere = (newStackHeight - mTopPadding - mTopPaddingOverflow)
/ minStackHeight;
partiallyThere = Math.max(0, partiallyThere); partiallyThere = Math.max(0, partiallyThere);
translationY += (1 - partiallyThere) * (mBottomStackPeekSize + translationY += (1 - partiallyThere) * (mBottomStackPeekSize +
mCollapseSecondCardPadding); mCollapseSecondCardPadding);