Skip to content
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 @@ -12,9 +12,12 @@
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Build;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.PopupWindow;
import android.widget.TextView;

Expand Down Expand Up @@ -53,7 +56,7 @@ public DevLoadingViewController(Context context, ReactInstanceManagerDevHelper r
}

public void showMessage(final String message, final int color, final int backgroundColor) {
if (!sEnabled ) {
if (!sEnabled) {
return;
}

Expand Down Expand Up @@ -147,6 +150,16 @@ private void showInternal() {
return;
}

int topOffset = 0;
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
// On Android SDK <= 19 PopupWindow#showAtLocation uses absolute screen position. In order for
// loading view to be placed below status bar (if the status bar is present) we need to pass
// an appropriate Y offset.
Rect rectangle = new Rect();
currentActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rectangle);
topOffset = rectangle.top;
}

mDevLoadingPopup = new PopupWindow(
mDevLoadingView,
ViewGroup.LayoutParams.MATCH_PARENT,
Expand All @@ -156,8 +169,9 @@ private void showInternal() {
mDevLoadingPopup.showAtLocation(
currentActivity.getWindow().getDecorView(),
Gravity.NO_GRAVITY,

0,
0);
topOffset);
}

private void hideInternal() {
Expand Down