mirror of
https://github.com/react/react-native.git
synced 2026-09-28 05:13:06 +08:00
Close the Android dev menu when the menu key is pressed again (#58668)
Summary: On Android, the menu key (`Cmd+M`) opens the dev menu, but a second press does not close it. On iOS, `Cmd+D` toggles the dev menu. This PR makes Android work the same way. ## Changelog: [ANDROID] [FIXED] - Pressing the menu key while the dev menu is open now closes it Pull Request resolved: https://github.com/react/react-native/pull/58668 Test Plan: RNTester on an emulator. Toggling works as expected Reviewed By: andrewdacenko Differential Revision: D121616477 Pulled By: shwanton fbshipit-source-id: 9d16a3349c5f9ddff5c7e46d5a590b9dbd525d3b
This commit is contained in:
committed by
meta-codesync[bot]
parent
585b28c5f0
commit
0e9d314184
+10
@@ -23,6 +23,7 @@ import android.hardware.SensorManager
|
||||
import android.os.Build
|
||||
import android.util.Pair
|
||||
import android.view.Gravity
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ArrayAdapter
|
||||
@@ -587,6 +588,15 @@ public abstract class DevSupportManagerBase(
|
||||
devOptionsDialog = null
|
||||
}
|
||||
.setOnCancelListener { devOptionsDialog = null }
|
||||
.setOnKeyListener { dialog: DialogInterface, keyCode: Int, event: KeyEvent ->
|
||||
if (keyCode != KeyEvent.KEYCODE_MENU) {
|
||||
return@setOnKeyListener false
|
||||
}
|
||||
if (event.action == KeyEvent.ACTION_UP) {
|
||||
dialog.cancel()
|
||||
}
|
||||
true
|
||||
}
|
||||
.create()
|
||||
|
||||
devOptionsDialog?.show()
|
||||
|
||||
Reference in New Issue
Block a user