File tree 5 files changed +80
-9
lines changed
Libraries/DevToolsSettings
ReactAndroid/src/main/java/com/facebook/react/modules/devtoolssettings 5 files changed +80
-9
lines changed Original file line number Diff line number Diff line change 4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
6
6
*
7
- * @flow strict
7
+ * @flow strict-local
8
8
* @format
9
9
*/
10
10
11
+ import DevSettings from '../Utilities/DevSettings' ;
11
12
import NativeDevToolsSettingsManager from './NativeDevToolsSettingsManager' ;
12
13
13
- module . exports = NativeDevToolsSettingsManager ;
14
+ module . exports = {
15
+ setConsolePatchSettings ( newSettings : string ) {
16
+ NativeDevToolsSettingsManager ?. setConsolePatchSettings ( newSettings ) ;
17
+ } ,
18
+ getConsolePatchSettings ( ) : ?string {
19
+ return NativeDevToolsSettingsManager ?. getConsolePatchSettings ( ) ;
20
+ } ,
21
+ setProfilingSettings ( newSettings : string ) {
22
+ if ( NativeDevToolsSettingsManager ?. setProfilingSettings != null ) {
23
+ NativeDevToolsSettingsManager . setProfilingSettings ( newSettings ) ;
24
+ }
25
+ } ,
26
+ getProfilingSettings ( ) : ?string {
27
+ if ( NativeDevToolsSettingsManager ?. getProfilingSettings != null ) {
28
+ return NativeDevToolsSettingsManager . getProfilingSettings ( ) ;
29
+ }
30
+ return null ;
31
+ } ,
32
+ reload ( ) : void {
33
+ DevSettings?. reload ( ) ;
34
+ } ,
35
+ } ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ * @format
9
+ */
10
+
11
+ export interface DevToolsSettingsManagerStatic {
12
+ reload ( ) : void ;
13
+ setConsolePatchSettings ( newSettings : string ) : void ;
14
+ getConsolePatchSettings ( ) : string | null ;
15
+ setProfilingSettings ( newSettings : string ) : void ;
16
+ getProfilingSettings ( ) : string | null ;
17
+ }
18
+
19
+ export const DevToolsSettingsManager : DevToolsSettingsManagerStatic ;
20
+ export type DevToolsSettingsManager = DevToolsSettingsManagerStatic ;
Original file line number Diff line number Diff line change 8
8
* @format
9
9
*/
10
10
11
- import type { Spec } from './NativeDevToolsSettingsManager' ;
12
-
13
11
import Settings from '../Settings/Settings' ;
12
+ import DevSettings from '../Utilities/DevSettings' ;
14
13
15
14
const CONSOLE_PATCH_SETTINGS_KEY = 'ReactDevTools::ConsolePatchSettings' ;
15
+ const PROFILING_SETTINGS_KEY = 'ReactDevTools::ProfilingSettings' ;
16
16
17
17
const DevToolsSettingsManager = {
18
- setConsolePatchSettings : ( newConsolePatchSettings : string ) => {
18
+ setConsolePatchSettings ( newConsolePatchSettings : string ) : void {
19
19
Settings. set ( {
20
20
[ CONSOLE_PATCH_SETTINGS_KEY ] : newConsolePatchSettings ,
21
21
} ) ;
22
22
} ,
23
- getConsolePatchSettings : ( ) => {
23
+ getConsolePatchSettings ( ) : ? string {
24
24
const value = Settings . get ( CONSOLE_PATCH_SETTINGS_KEY ) ;
25
25
if ( typeof value === 'string' ) {
26
- // $FlowFixMe[unclear-type]
27
- return ( ( value : any ) : string ) ;
26
+ return value ;
28
27
}
29
28
return null ;
30
29
} ,
30
+
31
+ setProfilingSettings ( newProfilingSettings : string ) : void {
32
+ Settings. set ( {
33
+ [ PROFILING_SETTINGS_KEY ] : newProfilingSettings ,
34
+ } ) ;
35
+ } ,
36
+ getProfilingSettings ( ) : ?string {
37
+ const value = Settings . get ( PROFILING_SETTINGS_KEY ) ;
38
+ if ( typeof value === 'string' ) {
39
+ return value ;
40
+ }
41
+ return null ;
42
+ } ,
43
+
44
+ reload ( ) : void {
45
+ DevSettings?. reload ( ) ;
46
+ } ,
31
47
} ;
32
48
33
- module . exports = ( DevToolsSettingsManager : Spec ) ;
49
+ module . exports = DevToolsSettingsManager ;
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
15
15
export interface Spec extends TurboModule {
16
16
+ setConsolePatchSettings : ( newConsolePatchSettings : string ) = > void ;
17
17
+ getConsolePatchSettings : ( ) = > ?string ;
18
+ + setProfilingSettings ?: ( newProfilingSettings : string ) => void ;
19
+ + getProfilingSettings ?: ( ) => ?string ;
18
20
}
19
21
20
22
export default ( TurboModuleRegistry . get < Spec > (
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ public class DevToolsSettingsManagerModule extends NativeDevToolsSettingsManager
21
21
22
22
private static final String SHARED_PREFERENCES_PREFIX = "ReactNative__DevToolsSettings" ;
23
23
private static final String KEY_CONSOLE_PATCH_SETTINGS = "ConsolePatchSettings" ;
24
+ private static final String KEY_PROFILING_SETTINGS = "ProfilingSettings" ;
24
25
25
26
private final SharedPreferences mSharedPreferences ;
26
27
@@ -46,4 +47,14 @@ public void setConsolePatchSettings(String newSettings) {
46
47
editor .putString (KEY_CONSOLE_PATCH_SETTINGS , newSettings );
47
48
editor .apply ();
48
49
}
50
+
51
+ @ Override
52
+ public @ Nullable String getProfilingSettings () {
53
+ return mSharedPreferences .getString (KEY_PROFILING_SETTINGS , null );
54
+ }
55
+
56
+ @ Override
57
+ public void setProfilingSettings (String newSettings ) {
58
+ mSharedPreferences .edit ().putString (KEY_PROFILING_SETTINGS , newSettings ).apply ();
59
+ }
49
60
}
You can’t perform that action at this time.
0 commit comments