1212import android .app .Activity ;
1313import android .content .Context ;
1414import android .graphics .Color ;
15+ import android .graphics .Rect ;
16+ import android .os .Build ;
1517import android .view .Gravity ;
1618import android .view .LayoutInflater ;
1719import android .view .ViewGroup ;
20+ import android .view .Window ;
1821import android .widget .PopupWindow ;
1922import android .widget .TextView ;
2023
@@ -53,7 +56,7 @@ public DevLoadingViewController(Context context, ReactInstanceManagerDevHelper r
5356 }
5457
5558 public void showMessage (final String message , final int color , final int backgroundColor ) {
56- if (!sEnabled ) {
59+ if (!sEnabled ) {
5760 return ;
5861 }
5962
@@ -147,6 +150,16 @@ private void showInternal() {
147150 return ;
148151 }
149152
153+ int topOffset = 0 ;
154+ if (Build .VERSION .SDK_INT <= Build .VERSION_CODES .KITKAT ) {
155+ // On Android SDK <= 19 PopupWindow#showAtLocation uses absolute screen position. In order for
156+ // loading view to be placed below status bar (if the status bar is present) we need to pass
157+ // an appropriate Y offset.
158+ Rect rectangle = new Rect ();
159+ currentActivity .getWindow ().getDecorView ().getWindowVisibleDisplayFrame (rectangle );
160+ topOffset = rectangle .top ;
161+ }
162+
150163 mDevLoadingPopup = new PopupWindow (
151164 mDevLoadingView ,
152165 ViewGroup .LayoutParams .MATCH_PARENT ,
@@ -156,8 +169,9 @@ private void showInternal() {
156169 mDevLoadingPopup .showAtLocation (
157170 currentActivity .getWindow ().getDecorView (),
158171 Gravity .NO_GRAVITY ,
172+
159173 0 ,
160- 0 );
174+ topOffset );
161175 }
162176
163177 private void hideInternal () {
0 commit comments