Pārlūkot izejas kodu

Apply translucent flag only if needed

This works around a rare edge case where applying the translucent flag
resulted in white screens when pushing or showing modals.
So far, I've managed to reproduce this only when when showing external component as modal in the Wix app.

closes #5742
Guy Carmeli 5 gadus atpakaļ
vecāks
revīzija
6782362035

+ 3
- 3
lib/android/app/src/main/java/com/reactnativenavigation/presentation/Presenter.java Parādīt failu

@@ -97,7 +97,7 @@ public class Presenter {
97 97
         Window window = activity.getWindow();
98 98
         if (options.translucent.isTrue()) {
99 99
             window.setFlags(FLAG_TRANSLUCENT_STATUS, FLAG_TRANSLUCENT_STATUS);
100
-        } else {
100
+        } else if (StatusBarUtils.isTranslucent(window)) {
101 101
             window.clearFlags(FLAG_TRANSLUCENT_STATUS);
102 102
         }
103 103
     }
@@ -132,7 +132,7 @@ public class Presenter {
132 132
         }
133 133
     }
134 134
 
135
-    private static void clearDarkTextColorScheme(View view) {
135
+    private void clearDarkTextColorScheme(View view) {
136 136
         if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;
137 137
         int flags = view.getSystemUiVisibility();
138 138
         flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
@@ -168,7 +168,7 @@ public class Presenter {
168 168
         Window window = activity.getWindow();
169 169
         if (options.translucent.isTrue()) {
170 170
             window.setFlags(FLAG_TRANSLUCENT_STATUS, FLAG_TRANSLUCENT_STATUS);
171
-        } else if (options.translucent.isFalse()) {
171
+        } else if (options.translucent.isFalse() && StatusBarUtils.isTranslucent(window)) {
172 172
             window.clearFlags(FLAG_TRANSLUCENT_STATUS);
173 173
         }
174 174
     }

+ 7
- 0
lib/android/app/src/main/java/com/reactnativenavigation/utils/StatusBarUtils.java Parādīt failu

@@ -3,7 +3,10 @@ package com.reactnativenavigation.utils;
3 3
 import android.content.Context;
4 4
 import android.content.res.Resources;
5 5
 import android.os.Build;
6
+import android.view.Window;
7
+import android.view.WindowManager;
6 8
 
9
+import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
7 10
 import static com.reactnativenavigation.utils.UiUtils.dpToPx;
8 11
 
9 12
 public class StatusBarUtils {
@@ -27,4 +30,8 @@ public class StatusBarUtils {
27 30
         return statusBarHeight;
28 31
     }
29 32
 
33
+    public static boolean isTranslucent(Window window) {
34
+        WindowManager.LayoutParams lp = window.getAttributes();
35
+        return (lp.flags & FLAG_TRANSLUCENT_STATUS) == FLAG_TRANSLUCENT_STATUS;
36
+    }
30 37
 }