-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Android implementation for DevMenu Module (#46694)
Summary: Pull Request resolved: #46694 The DevMenu module was never implemented on Android. This adds its implementation by mirroring the iOS implementation. Fixes #46679 Changelog: [Android] [Fixed] - Add missing Android implementation for DevMenu Module Reviewed By: cipolleschi Differential Revision: D63535172 fbshipit-source-id: 791e72b46b7d3264b98e85a73f2d9025dc3a2c7d
- Loading branch information
1 parent
8bfd7e1
commit 1bdae07
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...react-native/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DevMenuModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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.debug | ||
|
||
import com.facebook.fbreact.specs.NativeDevMenuSpec | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.UiThreadUtil | ||
import com.facebook.react.devsupport.interfaces.DevSupportManager | ||
import com.facebook.react.module.annotations.ReactModule | ||
|
||
/** Module that exposes the DevMenu to JS so that it can be used to programmatically open it. */ | ||
@ReactModule(name = NativeDevMenuSpec.NAME) | ||
public class DevMenuModule( | ||
reactContext: ReactApplicationContext?, | ||
private val devSupportManager: DevSupportManager | ||
) : NativeDevMenuSpec(reactContext) { | ||
|
||
override fun show() { | ||
if (devSupportManager.devSupportEnabled) { | ||
devSupportManager.showDevOptionsDialog() | ||
} | ||
} | ||
|
||
override fun reload() { | ||
if (devSupportManager.devSupportEnabled) { | ||
UiThreadUtil.runOnUiThread { devSupportManager.handleReloadJS() } | ||
} | ||
} | ||
|
||
override fun debugRemotely(enableDebug: Boolean) { | ||
devSupportManager.setRemoteJSDebugEnabled(enableDebug) | ||
} | ||
|
||
override fun setProfilingEnabled(enabled: Boolean) { | ||
// iOS only | ||
} | ||
|
||
override fun setHotLoadingEnabled(enabled: Boolean) { | ||
devSupportManager.setHotModuleReplacementEnabled(enabled) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters