Skip to content

Commit cf69c56

Browse files
author
John Spurlock
committed
"Fix camera widget scale-up regression." -> frameworks/base
lockhotness change-id: I69ccfa3a873943ab2e159d15937d5fb13f7acabd Bug:7439300 Change-Id: I9e9eeae16b4e76d85a8145f3b198c22ad2e923e9
1 parent 567fa75 commit cf69c56

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,32 +169,45 @@ public void render() {
169169
}
170170

171171
private void transitionToCamera() {
172-
final View child = getChildAt(0);
173172
if (mTransitioning || mChallengeActive || mDown) return;
174-
if (DEBUG) Log.d(TAG, "Transitioning to camera...");
173+
175174
mTransitioning = true;
176-
int startWidth = child.getWidth();
177-
int startHeight = child.getHeight();
178175

179-
int finishWidth = getRootView().getWidth();
180-
int finishHeight = getRootView().getHeight();
176+
final View child = getChildAt(0);
177+
final View root = getRootView();
178+
179+
final int startWidth = child.getWidth();
180+
final int startHeight = child.getHeight();
181181

182-
float scaleX = (float) finishWidth / startWidth;
183-
float scaleY = (float) finishHeight / startHeight;
182+
final int finishWidth = root.getWidth();
183+
final int finishHeight = root.getHeight();
184184

185-
float scale = Math.max(scaleX, scaleY);
186-
final int screenCenter = getResources().getDisplayMetrics().heightPixels / 2;
185+
final float scaleX = (float) finishWidth / startWidth;
186+
final float scaleY = (float) finishHeight / startHeight;
187+
final float scale = Math.round( Math.max(scaleX, scaleY) * 100) / 100f;
187188

188189
final int[] loc = new int[2];
190+
root.getLocationInWindow(loc);
191+
final int finishCenter = loc[1] + finishHeight / 2;
192+
189193
child.getLocationInWindow(loc);
190-
final int childCenter = loc[1] + startHeight / 2;
194+
final int startCenter = loc[1] + startHeight / 2;
195+
196+
if (DEBUG) Log.d(TAG, String.format("Transitioning to camera. " +
197+
"(start=%sx%s, finish=%sx%s, scale=%s,%s, startCenter=%s, finishCenter=%s)",
198+
startWidth, startHeight,
199+
finishWidth, finishHeight,
200+
scaleX, scaleY,
201+
startCenter, finishCenter));
202+
191203
animate()
192204
.scaleX(scale)
193205
.scaleY(scale)
194-
.translationY(screenCenter - childCenter)
206+
.translationY(finishCenter - startCenter)
195207
.setDuration(WIDGET_ANIMATION_DURATION)
196208
.withEndAction(mLaunchCameraRunnable)
197209
.start();
210+
198211
mCallbacks.onLaunchingCamera();
199212
}
200213

0 commit comments

Comments
 (0)