Chromium Code Reviews| Index: remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java |
| diff --git a/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java b/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java |
| index 23d00647fe42fc8aeb9743446fa1c4cd1e4e5d0f..74e92892f27e2da124dd89f9f0beb982f525422e 100644 |
| --- a/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java |
| +++ b/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java |
| @@ -112,14 +112,25 @@ public class DesktopCanvas { |
| * @param parameter The set of values defining the current System UI state. |
| */ |
| public void onSystemUiVisibilityChanged(SystemUiVisibilityChangedEventParameter parameter) { |
| - if (parameter.softInputMethodVisible) { |
| - mSystemUiScreenRect.set( |
| - parameter.left, parameter.top, parameter.right, parameter.bottom); |
| + mSystemUiScreenRect.set(parameter.left, parameter.top, parameter.right, parameter.bottom); |
| + stopOffsetReductionAnimation(); |
| - stopOffsetReductionAnimation(); |
| + PointF targetOffset; |
| + if (mSystemUiScreenRect.isEmpty()) { |
| + targetOffset = new PointF(0.0f, 0.0f); |
| } else { |
| - mSystemUiScreenRect.setEmpty(); |
| - startOffsetReductionAnimation(); |
| + // If the System UI size has changed such viewport offset is affected, then start an |
| + // animation to adjust the amount of offset used. This functionality ensures that we |
| + // don't leave content-less areas on the screen when the System UI resizes. |
| + RectF systemUiOverlap = getSystemUiOverlap(); |
| + RectF newBounds = new RectF(-systemUiOverlap.left, -systemUiOverlap.top, |
| + systemUiOverlap.right, systemUiOverlap.bottom); |
| + targetOffset = new PointF(mViewportOffset.x, mViewportOffset.y); |
| + constrainPointToBounds(targetOffset, newBounds); |
| + } |
| + |
| + if (!targetOffset.equals(mViewportOffset.x, mViewportOffset.y)) { |
|
Lambros
2016/11/08 21:55:03
Is this a float equality comparison?
Maybe better
joedow
2016/11/08 23:04:17
I wanted to use the Android class functions for th
|
| + startOffsetReductionAnimation(targetOffset); |
| } |
| if (mRenderData.initialized()) { |
| @@ -401,7 +412,7 @@ public class DesktopCanvas { |
| * Starts an animation to smoothly reduce the viewport offset. Does nothing if an animation is |
| * already running or the offset is already 0. |
|
Lambros
2016/11/08 21:55:03
"already 0" still correct?
joedow
2016/11/08 23:04:16
Yeah this is correct. There is no work to do if t
|
| */ |
| - private void startOffsetReductionAnimation() { |
| + private void startOffsetReductionAnimation(final PointF targetOffset) { |
| if (mFrameRenderedCallback != null || mViewportOffset.length() < EPSILON) { |
|
Lambros
2016/11/08 21:55:02
Is this still the right test if targetOffset is no
joedow
2016/11/08 23:04:16
Yeah I think so. The point of this method is to r
|
| return; |
| } |
| @@ -412,8 +423,8 @@ public class DesktopCanvas { |
| private final Interpolator mInterpolator = new DecelerateInterpolator(); |
| private long mStartTime = 0; |
| - private float mOriginalX = 0.0f; |
| - private float mOriginalY = 0.0f; |
| + private final float mOriginalX = mViewportOffset.x - targetOffset.x; |
| + private final float mOriginalY = mViewportOffset.y - targetOffset.y; |
| @Override |
| public Boolean run(Void p) { |
| @@ -423,16 +434,15 @@ public class DesktopCanvas { |
| if (mStartTime == 0) { |
| mStartTime = SystemClock.elapsedRealtime(); |
| - mOriginalX = mViewportOffset.x; |
| - mOriginalY = mViewportOffset.y; |
| } |
| float progress = (SystemClock.elapsedRealtime() - mStartTime) / DURATION_MS; |
| if (progress < 1.0f) { |
| float reductionFactor = 1.0f - mInterpolator.getInterpolation(progress); |
| - mViewportOffset.set(mOriginalX * reductionFactor, mOriginalY * reductionFactor); |
| + mViewportOffset.set(mOriginalX * reductionFactor + targetOffset.x, |
| + mOriginalY * reductionFactor + targetOffset.y); |
| } else { |
| - mViewportOffset.set(0.0f, 0.0f); |
| + mViewportOffset.set(targetOffset.x, targetOffset.y); |
| mFrameRenderedCallback = null; |
| } |