Ensure Gesture Nav Edu animation scales to fit different screen sizes

The lottie animation in the gesture nav tutorial wasn't scaling correctly for certain devices
leading to gaps around the animation. This change uses animation's scale transformation to ensure it fits the
dimensions of the device.

Flag: ENABLE_NEW_GESTURE_NAV_TUTORIAL
Fix: 295809541
Test: Went through the tutorial on different types of devices and ensure
the animation takes up the entire screen.
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3ca10a1325f2db21185d6143d310f55056865f05)
Merged-In: Iadee0d0389a11aa38c9e947b4b40466acd8f4422
Change-Id: Iadee0d0389a11aa38c9e947b4b40466acd8f4422
This commit is contained in:
Saumya Prakash
2023-08-31 23:08:54 +00:00
committed by Cherrypicker Worker
parent c9ca8eb4a1
commit 7146fc249f

View File

@@ -226,13 +226,11 @@ abstract class TutorialController implements BackGestureAttemptCallback,
return;
}
Matrix scaleMatrix = new Matrix();
float pivotX = mScreenWidth / 2f;
float pivotY = mScreenHeight;
float scaleFactor = mScreenWidth / animationBoundsRect.width();
float heightTranslate = (mScreenHeight - (scaleFactor * animationBoundsRect.height()));
scaleMatrix.postScale(scaleFactor, scaleFactor, pivotX, pivotY);
scaleMatrix.postTranslate(0,
mTutorialFragment.getDeviceProfile().heightPx - animationBoundsRect.height());
scaleMatrix.postScale(scaleFactor, scaleFactor);
scaleMatrix.postTranslate(0, heightTranslate);
mAnimatedGestureDemonstration.setImageMatrix(scaleMatrix);
}