Skip to content

Commit

Permalink
Fix Popover location in Events
Browse files Browse the repository at this point in the history
Reviewed By: andreicoman11

Differential Revision: D3219054

fb-gh-sync-id: cc25bd63be284ae7e8232652936a67fd792feabc
fbshipit-source-id: cc25bd63be284ae7e8232652936a67fd792feabc
  • Loading branch information
Dave Miller authored and Facebook Github Bot 4 committed Apr 25, 2016
1 parent 1dc82a9 commit 8e7ea11
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;

import android.content.res.Resources;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.view.Menu;
Expand Down Expand Up @@ -483,7 +484,7 @@ public void measure(int tag, int[] outputBuffer) {
}

/**
* Returns the coordinates of a view relative to the entire phone screen (not just the RootView
* Returns the coordinates of a view relative to the window (not just the RootView
* which is what measure will return)
*
* @param tag - the tag for the view
Expand All @@ -499,6 +500,15 @@ public 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;
}

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

2 comments on commit 8e7ea11

@mkonicek
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely a breaking change for the next release, who writes release notes for 0.26 should make this clear.

@dmmiller
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially, though most people are not going to be using this. We only use it internally for displaying popovers in a few cases. And this actually fixes popovers.

Please sign in to comment.