Skip to content

Commit d51700b

Browse files
author
Adam Cohen
committed
Fixing up overscroll asset / sizing
-> No more jaggies! yay (issue 7459049) -> Fixed up weird overscroll state (issue 7489094) Change-Id: I5d6714a6f5f007ea0f73e4cf34a20572c5f43f64
1 parent f988bdf commit d51700b

File tree

8 files changed

+31
-18
lines changed

8 files changed

+31
-18
lines changed
3.2 KB
Loading
3.08 KB
Loading
3.39 KB
Loading

core/res/res/values/symbols.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@
12561256
<java-symbol type="drawable" name="magnified_region_frame" />
12571257
<java-symbol type="drawable" name="menu_background" />
12581258
<java-symbol type="drawable" name="stat_sys_secure" />
1259-
<java-symbol type="drawable" name="kg_bouncer_bg_white" />
1259+
<java-symbol type="drawable" name="kg_widget_bg_padded" />
12601260
<java-symbol type="id" name="action_mode_bar_stub" />
12611261
<java-symbol type="id" name="alarm_status" />
12621262
<java-symbol type="id" name="backspace" />

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ public void onScrollStateChanged(int scrollState) {
214214
mKeyguardWidgetPager.setWidgetToResetOnPageFadeOut(mPageListeningToSlider);
215215
}
216216
}
217-
frame.hideFrame(this);
217+
if (scrollState != SlidingChallengeLayout.SCROLL_STATE_FADING) {
218+
frame.hideFrame(this);
219+
}
218220
updateEdgeSwiping();
219221

220222
if (mChallengeLayout.isChallengeShowing()) {
@@ -233,7 +235,9 @@ public void onScrollStateChanged(int scrollState) {
233235

234236
// Skip showing the frame and shrinking the widget if we are
235237
if (!mChallengeLayout.isBouncing()) {
236-
frame.showFrame(this);
238+
if (scrollState != SlidingChallengeLayout.SCROLL_STATE_FADING) {
239+
frame.showFrame(this);
240+
}
237241

238242
// As soon as the security begins sliding, the widget becomes small (if it wasn't
239243
// small to begin with).

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ public KeyguardWidgetFrame(Context context, AttributeSet attrs, int defStyle) {
110110
int padding = (int) (res.getDisplayMetrics().density * 8);
111111
setPadding(padding, padding, padding, padding);
112112

113-
mFrameStrokeAdjustment = (int) (2 * density);
113+
mFrameStrokeAdjustment = 2 + (int) (2 * density);
114114

115115
// This will be overriden on phones based on the current security mode, however on tablets
116116
// we need to specify a height.
117117
mSmallWidgetHeight =
118118
res.getDimensionPixelSize(com.android.internal.R.dimen.kg_small_widget_height);
119-
mBackgroundDrawable = res.getDrawable(R.drawable.kg_bouncer_bg_white);
119+
mBackgroundDrawable = res.getDrawable(R.drawable.kg_widget_bg_padded);
120120
mGradientColor = res.getColor(com.android.internal.R.color.kg_widget_pager_gradient);
121121
mGradientPaint.setXfermode(sAddBlendMode);
122122
}
@@ -372,6 +372,10 @@ public void resetSize() {
372372
public void setFrameHeight(int height) {
373373
mFrameHeight = height;
374374
mBackgroundRect.set(0, 0, getMeasuredWidth(), Math.min(mFrameHeight, getMeasuredHeight()));
375+
mForegroundRect.set(mFrameStrokeAdjustment, mFrameStrokeAdjustment,getMeasuredWidth() -
376+
mFrameStrokeAdjustment, Math.min(getMeasuredHeight(), mFrameHeight) -
377+
mFrameStrokeAdjustment);
378+
updateGradient();
375379
invalidate();
376380
}
377381

@@ -401,27 +405,30 @@ public void fadeFrame(Object caller, boolean takeControl, float alpha, int durat
401405
mFrameFade.start();
402406
}
403407

404-
@Override
405-
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
406-
super.onSizeChanged(w, h, oldw, oldh);
407-
408-
// mFrameStrokeAdjustment is a cludge to prevent the overlay from drawing outside the
409-
// rounded rect background.
410-
mForegroundRect.set(mFrameStrokeAdjustment, mFrameStrokeAdjustment,
411-
w - mFrameStrokeAdjustment, h - mFrameStrokeAdjustment);
412-
408+
private void updateGradient() {
413409
float x0 = mLeftToRight ? 0 : mForegroundRect.width();
414410
float x1 = mLeftToRight ? mForegroundRect.width(): 0;
415411
mLeftToRightGradient = new LinearGradient(x0, 0f, x1, 0f,
416412
mGradientColor, 0, Shader.TileMode.CLAMP);
417413
mRightToLeftGradient = new LinearGradient(x1, 0f, x0, 0f,
418414
mGradientColor, 0, Shader.TileMode.CLAMP);
415+
}
416+
417+
@Override
418+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
419+
super.onSizeChanged(w, h, oldw, oldh);
419420

420421
if (!mIsSmall) {
421422
mFrameHeight = h;
422423
}
423424

425+
// mFrameStrokeAdjustment is a cludge to prevent the overlay from drawing outside the
426+
// rounded rect background.
427+
mForegroundRect.set(mFrameStrokeAdjustment, mFrameStrokeAdjustment,
428+
w - mFrameStrokeAdjustment, Math.min(h, mFrameHeight) - mFrameStrokeAdjustment);
429+
424430
mBackgroundRect.set(0, 0, getMeasuredWidth(), Math.min(h, mFrameHeight));
431+
updateGradient();
425432
invalidate();
426433
}
427434

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@ protected void screenScrolled(int screenCenter) {
476476
v.setCameraDistance(mDensity * CAMERA_DISTANCE);
477477

478478
if (isOverScrollChild(i, scrollProgress) && PERFORM_OVERSCROLL_ROTATION) {
479+
float pivotX = v.getMeasuredWidth() / 2;
480+
float pivotY = v.getMeasuredHeight() / 2;
481+
v.setPivotX(pivotX);
482+
v.setPivotY(pivotY);
479483
v.setRotationY(- OVERSCROLL_MAX_ROTATION * scrollProgress);
480484
v.setOverScrollAmount(Math.abs(scrollProgress), scrollProgress < 0);
481485
} else {
@@ -762,6 +766,8 @@ void zoomOutToBouncer() {
762766
mZoomInOutAnim.cancel();
763767
}
764768
View currentPage = getPageAt(getCurrentPage());
769+
currentPage.setPivotY(0);
770+
currentPage.setPivotX(currentPage.getMeasuredWidth() / 2);
765771
if (!(currentPage.getScaleX() < 1f || currentPage.getScaleY() < 1f)) {
766772
mZoomInOutAnim = new AnimatorSet();
767773
mZoomInOutAnim.setDuration(BOUNCER_ZOOM_IN_OUT_DURATION);

policy/src/com/android/internal/policy/impl/keyguard/PagedView.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,6 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
658658
MeasureSpec.makeMeasureSpec(heightSize - verticalPadding, childHeightMode);
659659

660660
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
661-
if (shouldSetTopAlignedPivotForWidget(i)) {
662-
child.setPivotX(child.getWidth() / 2);
663-
child.setPivotY(0f);
664-
}
665661
}
666662
setMeasuredDimension(scaledWidthSize, scaledHeightSize);
667663

0 commit comments

Comments
 (0)