diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.java index 00e075c509fdb7..bb485af8ba63f5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.java @@ -40,7 +40,7 @@ public void setFpsDebugViewVisible(boolean fpsDebugViewVisible) { WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, - WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, + WindowOverlayCompat.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT); diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevLoadingViewController.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevLoadingViewController.java index 44e9a816c62ac5..f9573acdce5f40 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevLoadingViewController.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevLoadingViewController.java @@ -143,7 +143,7 @@ private void setVisible(boolean visible) { WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, - WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, + WindowOverlayCompat.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); params.gravity = Gravity.TOP; diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java index ce8a4938a643b1..d7c9e23e4e0901 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java @@ -34,7 +34,6 @@ import android.hardware.SensorManager; import android.net.Uri; import android.os.AsyncTask; -import android.view.WindowManager; import android.widget.Toast; import com.facebook.common.logging.FLog; @@ -336,7 +335,7 @@ private void showNewError( public void run() { if (mRedBoxDialog == null) { mRedBoxDialog = new RedBoxDialog(mApplicationContext, DevSupportManagerImpl.this, mRedBoxHandler); - mRedBoxDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + mRedBoxDialog.getWindow().setType(WindowOverlayCompat.TYPE_SYSTEM_ALERT); } if (mRedBoxDialog.isShowing()) { // Sometimes errors cause multiple errors to be thrown in JS in quick succession. Only @@ -478,7 +477,7 @@ public void onCancel(DialogInterface dialog) { } }) .create(); - mDevOptionsDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + mDevOptionsDialog.getWindow().setType(WindowOverlayCompat.TYPE_SYSTEM_ALERT); mDevOptionsDialog.show(); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/WindowOverlayCompat.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/WindowOverlayCompat.java new file mode 100644 index 00000000000000..b4bfa91eeba915 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/WindowOverlayCompat.java @@ -0,0 +1,18 @@ +package com.facebook.react.devsupport; + +import android.os.Build; +import android.view.WindowManager; + +/** + * Compatibility wrapper for apps targeting API level 26 or later. + * See https://developer.android.com/about/versions/oreo/android-8.0-changes.html#cwt + */ +/* package */ class WindowOverlayCompat { + + private static final int ANDROID_OREO = 26; + private static final int TYPE_APPLICATION_OVERLAY = 2038; + + static final int TYPE_SYSTEM_ALERT = Build.VERSION.SDK_INT < ANDROID_OREO ? WindowManager.LayoutParams.TYPE_SYSTEM_ALERT : TYPE_APPLICATION_OVERLAY; + static final int TYPE_SYSTEM_OVERLAY = Build.VERSION.SDK_INT < ANDROID_OREO ? WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY : TYPE_APPLICATION_OVERLAY; + +}