From 3e257d7708036458a976c25ca3da0dfdbbfe6c48 Mon Sep 17 00:00:00 2001 From: Ward Abbass Date: Mon, 30 Aug 2021 00:19:33 +0300 Subject: [PATCH 1/2] Update Presenter.java --- .../viewcontroller/Presenter.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java b/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java index fbc0412d787..3abc297cc49 100644 --- a/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java +++ b/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java @@ -136,15 +136,21 @@ private void setTextColorScheme(StatusBarOptions statusBar) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return; final View view = activity.getWindow().getDecorView(); + //This is a HACK, in certain devices, posted to DecorView queue + //in order to prevent ui freeze on certain devices: Samsungs with Android 9. + //When calling mergeOptions inside useEffect that has fast enough fetch that + //resolves before window even got to change, this way we can grant changes for status bar + //will be called in the correct order. + view.post(()->{ + int flags = view.getSystemUiVisibility(); + if (isDarkTextColorScheme(statusBar)) { + flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + } else { + flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + } - int flags = view.getSystemUiVisibility(); - if (isDarkTextColorScheme(statusBar)) { - flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; - } else { - flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; - } - - view.setSystemUiVisibility(flags); + view.setSystemUiVisibility(flags); + }); } private void mergeStatusBarOptions(View view, StatusBarOptions statusBar) { From 0b2366b5bb1733686077152bee4a1d2c0630ea8c Mon Sep 17 00:00:00 2001 From: Ward Abbass Date: Tue, 31 Aug 2021 10:53:49 +0300 Subject: [PATCH 2/2] Update Presenter.java Clear comment --- .../viewcontrollers/viewcontroller/Presenter.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java b/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java index 3abc297cc49..9feab908f3e 100644 --- a/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java +++ b/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java @@ -136,11 +136,8 @@ private void setTextColorScheme(StatusBarOptions statusBar) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return; final View view = activity.getWindow().getDecorView(); - //This is a HACK, in certain devices, posted to DecorView queue - //in order to prevent ui freeze on certain devices: Samsungs with Android 9. - //When calling mergeOptions inside useEffect that has fast enough fetch that - //resolves before window even got to change, this way we can grant changes for status bar - //will be called in the correct order. + //View.post is a Workaround, added to solve internal Samsung + //Android 9 issues. For more info see https://github.com/wix/react-native-navigation/pull/7231 view.post(()->{ int flags = view.getSystemUiVisibility(); if (isDarkTextColorScheme(statusBar)) {