Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ed014e0 authored by Tyler Freeman's avatar Tyler Freeman Committed by Cherrypicker Worker
Browse files

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
parent 5cef3871
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -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(