You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Android: Add new configuration for DevSupportManager (#53557)
Summary:
Following the [RFC](react-native-community/discussions-and-proposals#925), this PR adds new `DevMenuConfiguration` object and extends `ReactHost` API for passing settings to the particular `DevSupportManager`. The `DevMenuConfiguration` includes:
- isDevMenuEnabled,
- isShakeGestureEnabled,
- areKeyboardShortcutsEnabled,
## Changelog:
[ANDROID][ADDED] - Add new configuration for `RCTDevMenu`
Test Plan:
Tested with different configuration on `DevMenuConfiguration`:
<details>
<summary>Click to view code</summary>
```kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
fullyDrawnReporter.addReporter()
maybeUpdateBackgroundColor()
reactDelegate?.reactHost?.let { reactHost ->
val devMenuConfiguration = DevMenuConfiguration(
isDevMenuEnabled = true,
isShakeGestureEnabled = false,
areKeyboardShortcutsEnabled = false,
)
reactHost.setDevMenuConfiguration(devMenuConfiguration)
}
// register insets listener to update margins on the ReactRootView to avoid overlap w/ system
// bars
reactDelegate?.reactRootView?.let { rootView ->
val insetsType: Int =
WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()
val windowInsetsListener = { view: View, windowInsets: WindowInsetsCompat ->
val insets = windowInsets.getInsets(insetsType)
(view.layoutParams as FrameLayout.LayoutParams).apply {
setMargins(insets.left, insets.top, insets.right, insets.bottom)
}
WindowInsetsCompat.CONSUMED
}
ViewCompat.setOnApplyWindowInsetsListener(rootView, windowInsetsListener)
}
}
```
</details>
Reviewed By: vzaidman
Differential Revision: D81684310
Pulled By: coado
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/api/ReactAndroid.api
+37Lines changed: 37 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -244,6 +244,7 @@ public abstract interface class com/facebook/react/ReactHost {
244
244
public abstract fun reload (Ljava/lang/String;)Lcom/facebook/react/interfaces/TaskInterface;
245
245
public abstract fun removeBeforeDestroyListener (Lkotlin/jvm/functions/Function0;)V
246
246
public abstract fun removeReactInstanceEventListener (Lcom/facebook/react/ReactInstanceEventListener;)V
247
+
public abstract fun setDevMenuConfiguration (Lcom/facebook/react/devsupport/DevMenuConfiguration;)V
247
248
public abstract fun start ()Lcom/facebook/react/interfaces/TaskInterface;
248
249
}
249
250
@@ -1899,6 +1900,23 @@ public final class com/facebook/react/devsupport/DefaultDevLoadingViewImplementa
1899
1900
public final fun setDevLoadingEnabled (Z)V
1900
1901
}
1901
1902
1903
+
public final class com/facebook/react/devsupport/DevMenuConfiguration {
1904
+
public fun <init> ()V
1905
+
public fun <init> (ZZZ)V
1906
+
public synthetic fun <init> (ZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
1907
+
public final fun component1 ()Z
1908
+
public final fun component2 ()Z
1909
+
public final fun component3 ()Z
1910
+
public final fun copy (ZZZ)Lcom/facebook/react/devsupport/DevMenuConfiguration;
1911
+
public static synthetic fun copy$default (Lcom/facebook/react/devsupport/DevMenuConfiguration;ZZZILjava/lang/Object;)Lcom/facebook/react/devsupport/DevMenuConfiguration;
1912
+
public fun equals (Ljava/lang/Object;)Z
1913
+
public final fun getAreKeyboardShortcutsEnabled ()Z
1914
+
public fun hashCode ()I
1915
+
public final fun isDevMenuEnabled ()Z
1916
+
public final fun isShakeGestureEnabled ()Z
1917
+
public fun toString ()Ljava/lang/String;
1918
+
}
1919
+
1902
1920
public class com/facebook/react/devsupport/DevServerHelper {
1903
1921
public fun <init> (Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;Landroid/content/Context;Lcom/facebook/react/packagerconnection/PackagerConnectionSettings;)V
1904
1922
public final fun closeInspectorConnection ()V
@@ -1940,17 +1958,20 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
1940
1958
public fun getCurrentActivity ()Landroid/app/Activity;
1941
1959
public final fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
1942
1960
public final fun getDevLoadingViewManager ()Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;
1961
+
public fun getDevMenuEnabled ()Z
1943
1962
public final fun getDevServerHelper ()Lcom/facebook/react/devsupport/DevServerHelper;
1944
1963
public final fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
1945
1964
public final fun getDevSupportEnabled ()Z
1946
1965
public fun getDownloadedJSBundleFile ()Ljava/lang/String;
1947
1966
public final fun getJSAppBundleName ()Ljava/lang/String;
1967
+
public fun getKeyboardShortcutsEnabled ()Z
1948
1968
public final fun getLastErrorCookie ()I
1949
1969
public final fun getLastErrorStack ()[Lcom/facebook/react/devsupport/interfaces/StackFrame;
1950
1970
public final fun getLastErrorTitle ()Ljava/lang/String;
1951
1971
public final fun getLastErrorType ()Lcom/facebook/react/devsupport/interfaces/ErrorType;
1952
1972
public final fun getReactInstanceDevHelper ()Lcom/facebook/react/devsupport/ReactInstanceDevHelper;
1953
1973
public fun getRedBoxHandler ()Lcom/facebook/react/devsupport/interfaces/RedBoxHandler;
1974
+
public final fun getShakeGestureEnabled ()Z
1954
1975
public fun getSourceMapUrl ()Ljava/lang/String;
1955
1976
public fun getSourceUrl ()Ljava/lang/String;
1956
1977
protected abstract fun getUniqueTag ()Ljava/lang/String;
@@ -1969,14 +1990,17 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
1969
1990
public fun reloadSettings ()V
1970
1991
public fun setAdditionalOptionForPackager (Ljava/lang/String;Ljava/lang/String;)V
1971
1992
public final fun setDevLoadingViewManager (Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;)V
1993
+
public fun setDevMenuEnabled (Z)V
1972
1994
public final fun setDevSupportEnabled (Z)V
1973
1995
public fun setFpsDebugEnabled (Z)V
1974
1996
public fun setHotModuleReplacementEnabled (Z)V
1997
+
public fun setKeyboardShortcutsEnabled (Z)V
1975
1998
public final fun setLastErrorCookie (I)V
1976
1999
public final fun setLastErrorStack ([Lcom/facebook/react/devsupport/interfaces/StackFrame;)V
1977
2000
public final fun setLastErrorTitle (Ljava/lang/String;)V
1978
2001
public final fun setLastErrorType (Lcom/facebook/react/devsupport/interfaces/ErrorType;)V
1979
2002
public fun setPackagerLocationCustomizer (Lcom/facebook/react/devsupport/interfaces/DevSupportManager$PackagerLocationCustomizer;)V
2003
+
public final fun setShakeGestureEnabled (Z)V
1980
2004
protected final fun showDevLoadingViewForRemoteJSEnabled ()V
1981
2005
public fun showDevOptionsDialog ()V
1982
2006
public fun showNewJSError (Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;I)V
@@ -2033,14 +2057,17 @@ public class com/facebook/react/devsupport/ReleaseDevSupportManager : com/facebo
2033
2057
public fun downloadBundleResourceFromUrlSync (Ljava/lang/String;Ljava/io/File;)Ljava/io/File;
2034
2058
public fun getCurrentActivity ()Landroid/app/Activity;
2035
2059
public fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
2060
+
public fun getDevMenuEnabled ()Z
2036
2061
public fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
2037
2062
public fun getDevSupportEnabled ()Z
2038
2063
public fun getDownloadedJSBundleFile ()Ljava/lang/String;
2064
+
public fun getKeyboardShortcutsEnabled ()Z
2039
2065
public fun getLastErrorCookie ()I
2040
2066
public fun getLastErrorStack ()[Lcom/facebook/react/devsupport/interfaces/StackFrame;
2041
2067
public fun getLastErrorTitle ()Ljava/lang/String;
2042
2068
public fun getLastErrorType ()Lcom/facebook/react/devsupport/interfaces/ErrorType;
2043
2069
public fun getRedBoxHandler ()Lcom/facebook/react/devsupport/interfaces/RedBoxHandler;
2070
+
public fun getShakeGestureEnabled ()Z
2044
2071
public fun getSourceMapUrl ()Ljava/lang/String;
2045
2072
public fun getSourceUrl ()Ljava/lang/String;
2046
2073
public fun handleException (Ljava/lang/Exception;)V
@@ -2057,10 +2084,13 @@ public class com/facebook/react/devsupport/ReleaseDevSupportManager : com/facebo
2057
2084
public fun reloadJSFromServer (Ljava/lang/String;Lcom/facebook/react/devsupport/interfaces/BundleLoadCallback;)V
2058
2085
public fun reloadSettings ()V
2059
2086
public fun setAdditionalOptionForPackager (Ljava/lang/String;Ljava/lang/String;)V
2087
+
public fun setDevMenuEnabled (Z)V
2060
2088
public fun setDevSupportEnabled (Z)V
2061
2089
public fun setFpsDebugEnabled (Z)V
2062
2090
public fun setHotModuleReplacementEnabled (Z)V
2091
+
public fun setKeyboardShortcutsEnabled (Z)V
2063
2092
public fun setPackagerLocationCustomizer (Lcom/facebook/react/devsupport/interfaces/DevSupportManager$PackagerLocationCustomizer;)V
2093
+
public fun setShakeGestureEnabled (Z)V
2064
2094
public fun showDevOptionsDialog ()V
2065
2095
public fun showNewJSError (Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;I)V
2066
2096
public fun showNewJavaError (Ljava/lang/String;Ljava/lang/Throwable;)V
@@ -2134,14 +2164,17 @@ public abstract interface class com/facebook/react/devsupport/interfaces/DevSupp
2134
2164
public abstract fun downloadBundleResourceFromUrlSync (Ljava/lang/String;Ljava/io/File;)Ljava/io/File;
2135
2165
public abstract fun getCurrentActivity ()Landroid/app/Activity;
2136
2166
public abstract fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
2167
+
public abstract fun getDevMenuEnabled ()Z
2137
2168
public abstract fun getDevSettings ()Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;
2138
2169
public abstract fun getDevSupportEnabled ()Z
2139
2170
public abstract fun getDownloadedJSBundleFile ()Ljava/lang/String;
2171
+
public abstract fun getKeyboardShortcutsEnabled ()Z
2140
2172
public abstract fun getLastErrorCookie ()I
2141
2173
public abstract fun getLastErrorStack ()[Lcom/facebook/react/devsupport/interfaces/StackFrame;
2142
2174
public abstract fun getLastErrorTitle ()Ljava/lang/String;
2143
2175
public abstract fun getLastErrorType ()Lcom/facebook/react/devsupport/interfaces/ErrorType;
2144
2176
public abstract fun getRedBoxHandler ()Lcom/facebook/react/devsupport/interfaces/RedBoxHandler;
2177
+
public abstract fun getShakeGestureEnabled ()Z
2145
2178
public abstract fun getSourceMapUrl ()Ljava/lang/String;
2146
2179
public abstract fun getSourceUrl ()Ljava/lang/String;
2147
2180
public abstract fun handleReloadJS ()V
@@ -2158,10 +2191,13 @@ public abstract interface class com/facebook/react/devsupport/interfaces/DevSupp
2158
2191
public abstract fun reloadJSFromServer (Ljava/lang/String;Lcom/facebook/react/devsupport/interfaces/BundleLoadCallback;)V
2159
2192
public abstract fun reloadSettings ()V
2160
2193
public abstract fun setAdditionalOptionForPackager (Ljava/lang/String;Ljava/lang/String;)V
2194
+
public abstract fun setDevMenuEnabled (Z)V
2161
2195
public abstract fun setDevSupportEnabled (Z)V
2162
2196
public abstract fun setFpsDebugEnabled (Z)V
2163
2197
public abstract fun setHotModuleReplacementEnabled (Z)V
2198
+
public abstract fun setKeyboardShortcutsEnabled (Z)V
2164
2199
public abstract fun setPackagerLocationCustomizer (Lcom/facebook/react/devsupport/interfaces/DevSupportManager$PackagerLocationCustomizer;)V
2200
+
public abstract fun setShakeGestureEnabled (Z)V
2165
2201
public abstract fun showDevOptionsDialog ()V
2166
2202
public abstract fun showNewJSError (Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;I)V
2167
2203
public abstract fun showNewJavaError (Ljava/lang/String;Ljava/lang/Throwable;)V
@@ -3073,6 +3109,7 @@ public final class com/facebook/react/runtime/ReactHostImpl : com/facebook/react
3073
3109
public fun reload (Ljava/lang/String;)Lcom/facebook/react/interfaces/TaskInterface;
3074
3110
public fun removeBeforeDestroyListener (Lkotlin/jvm/functions/Function0;)V
3075
3111
public fun removeReactInstanceEventListener (Lcom/facebook/react/ReactInstanceEventListener;)V
3112
+
public fun setDevMenuConfiguration (Lcom/facebook/react/devsupport/DevMenuConfiguration;)V
3076
3113
public fun start ()Lcom/facebook/react/interfaces/TaskInterface;
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/ReleaseDevSupportManager.kt
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -72,6 +72,18 @@ public open class ReleaseDevSupportManager : DevSupportManager {
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/DevSupportManager.kt
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,9 @@ public interface DevSupportManager : JSExceptionHandler {
0 commit comments