Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calculating View position within a Window in split-screen mode on Android #28449

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

package com.facebook.react.uimanager;

import android.content.res.Resources;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
Expand Down Expand Up @@ -721,14 +721,11 @@ public synchronized void measureInWindow(int tag, int[] outputBuffer) {

v.getLocationOnScreen(outputBuffer);

// We need to remove the status bar from the height. getLocationOnScreen will include the
// status bar.
Resources resources = v.getContext().getResources();
int statusBarId = resources.getIdentifier("status_bar_height", "dimen", "android");
if (statusBarId > 0) {
int height = (int) resources.getDimension(statusBarId);
outputBuffer[1] -= height;
}
// we need to subtract visibleWindowCoords - to subtract possible window insets, split screen or multi window
Rect visibleWindowFrame = new Rect();
v.getWindowVisibleDisplayFrame(visibleWindowFrame);
outputBuffer[0] = outputBuffer[0] - visibleWindowFrame.left;
outputBuffer[1] = outputBuffer[1] - visibleWindowFrame.top;

// outputBuffer[0,1] already contain what we want
outputBuffer[2] = v.getWidth();
Expand Down