mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
//xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/devtoolssettings:devtoolssettingsAndroid (#43922)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43922 Changelog: [Internal] Reviewed By: cortinico Differential Revision: D55725626 fbshipit-source-id: 1cb1ced5adab5c3c20f12ae0783d1f01d73b4829
This commit is contained in:
committed by
Facebook GitHub Bot
parent
13432b5d8c
commit
0a7984435f
@@ -3230,7 +3230,7 @@ public class com/facebook/react/modules/devloading/DevLoadingModule : com/facebo
|
||||
public fun showMessage (Ljava/lang/String;Ljava/lang/Double;Ljava/lang/Double;)V
|
||||
}
|
||||
|
||||
public class com/facebook/react/modules/devtoolssettings/DevToolsSettingsManagerModule : com/facebook/fbreact/specs/NativeDevToolsSettingsManagerSpec {
|
||||
public final class com/facebook/react/modules/devtoolssettings/DevToolsSettingsManagerModule : com/facebook/fbreact/specs/NativeDevToolsSettingsManagerSpec {
|
||||
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
|
||||
public fun getConsolePatchSettings ()Ljava/lang/String;
|
||||
public fun getProfilingSettings ()Ljava/lang/String;
|
||||
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.devtoolssettings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.fbreact.specs.NativeDevToolsSettingsManagerSpec;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
|
||||
@ReactModule(name = NativeDevToolsSettingsManagerSpec.NAME)
|
||||
public class DevToolsSettingsManagerModule extends NativeDevToolsSettingsManagerSpec {
|
||||
private static final String SHARED_PREFERENCES_PREFIX = "ReactNative__DevToolsSettings";
|
||||
private static final String KEY_CONSOLE_PATCH_SETTINGS = "ConsolePatchSettings";
|
||||
private static final String KEY_PROFILING_SETTINGS = "ProfilingSettings";
|
||||
|
||||
private final SharedPreferences mSharedPreferences;
|
||||
|
||||
public DevToolsSettingsManagerModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
mSharedPreferences =
|
||||
reactContext.getSharedPreferences(SHARED_PREFERENCES_PREFIX, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getConsolePatchSettings() {
|
||||
return mSharedPreferences.getString(KEY_CONSOLE_PATCH_SETTINGS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConsolePatchSettings(String newSettings) {
|
||||
Editor editor = mSharedPreferences.edit();
|
||||
editor.putString(KEY_CONSOLE_PATCH_SETTINGS, newSettings);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getProfilingSettings() {
|
||||
return mSharedPreferences.getString(KEY_PROFILING_SETTINGS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfilingSettings(String newSettings) {
|
||||
mSharedPreferences.edit().putString(KEY_PROFILING_SETTINGS, newSettings).apply();
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.devtoolssettings
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.facebook.fbreact.specs.NativeDevToolsSettingsManagerSpec
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.module.annotations.ReactModule
|
||||
|
||||
@ReactModule(name = NativeDevToolsSettingsManagerSpec.NAME)
|
||||
public class DevToolsSettingsManagerModule(reactContext: ReactApplicationContext) :
|
||||
NativeDevToolsSettingsManagerSpec(reactContext) {
|
||||
|
||||
private val sharedPreferences: SharedPreferences =
|
||||
reactContext.getSharedPreferences(SHARED_PREFERENCES_PREFIX, Context.MODE_PRIVATE)
|
||||
|
||||
public override fun getConsolePatchSettings(): String? =
|
||||
sharedPreferences.getString(KEY_CONSOLE_PATCH_SETTINGS, null)
|
||||
|
||||
public override fun setConsolePatchSettings(newSettings: String?): Unit =
|
||||
sharedPreferences.edit().putString(KEY_CONSOLE_PATCH_SETTINGS, newSettings).apply()
|
||||
|
||||
public override fun getProfilingSettings(): String? =
|
||||
sharedPreferences.getString(KEY_PROFILING_SETTINGS, null)
|
||||
|
||||
public override fun setProfilingSettings(newSettings: String?): Unit =
|
||||
sharedPreferences.edit().putString(KEY_PROFILING_SETTINGS, newSettings).apply()
|
||||
|
||||
private companion object {
|
||||
private const val SHARED_PREFERENCES_PREFIX = "ReactNative__DevToolsSettings"
|
||||
private const val KEY_CONSOLE_PATCH_SETTINGS = "ConsolePatchSettings"
|
||||
private const val KEY_PROFILING_SETTINGS = "ProfilingSettings"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user