fix(magnification thumbnail): fix thumbnail area wrong when IME opens or orientation changes

This is because it was still using the old width/height from before
the layout change.

Fix: b/279538599
Fix: b/279527264

Test: manual
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:1a8ebc95c1a373b01bdf5db2e485d0a6971dae87)
Merged-In: I9f3cd40d9caba2a19ca93e1f87ff217840da771b
Change-Id: I9f3cd40d9caba2a19ca93e1f87ff217840da771b
This commit is contained in:
Tyler Freeman
2023-06-27 00:16:04 +00:00
committed by Cherrypicker Worker
parent 5cef387173
commit 7ed014e0ea

View File

@@ -270,21 +270,16 @@ public class MagnificationThumbnail {
mThumbnailView.setScaleX(scaleDown);
mThumbnailView.setScaleY(scaleDown);
}
float thumbnailWidth;
float thumbnailHeight;
if (mThumbnailView.getWidth() == 0 || mThumbnailView.getHeight() == 0) {
// if the thumbnail view size is not updated correctly, we just use the cached values.
thumbnailWidth = mThumbnailWidth;
thumbnailHeight = mThumbnailHeight;
} else {
thumbnailWidth = mThumbnailView.getWidth();
thumbnailHeight = mThumbnailView.getHeight();
}
if (!Float.isNaN(centerX)) {
if (!Float.isNaN(centerX)
&& !Float.isNaN(centerY)
&& mThumbnailWidth > 0
&& mThumbnailHeight > 0
) {
var padding = mThumbnailView.getPaddingTop();
var ratio = 1f / BG_ASPECT_RATIO;
var centerXScaled = centerX * ratio - (thumbnailWidth / 2f + padding);
var centerYScaled = centerY * ratio - (thumbnailHeight / 2f + padding);
var centerXScaled = centerX * ratio - (mThumbnailWidth / 2f + padding);
var centerYScaled = centerY * ratio - (mThumbnailHeight / 2f + padding);
if (DEBUG) {
Log.d(