From 94473e5660718f8a17ac65d8e78b9c25788d9a29 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Fri, 23 Feb 2018 11:20:23 -0600 Subject: [PATCH] [Android] Allow accessing react-native's in-app developer menu (in the emulator) --- .../org/jitsi/meet/sdk/JitsiMeetActivity.java | 23 +++++++++++++++++-- .../org/jitsi/meet/sdk/JitsiMeetView.java | 5 ++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java index 0250cda4a4..c4dcbe3c5d 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java @@ -23,11 +23,13 @@ import android.os.Bundle; import android.provider.Settings; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; +import android.view.KeyEvent; -import java.net.URL; - +import com.facebook.react.ReactInstanceManager; import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; +import java.net.URL; + /** * Base Activity for applications integrating Jitsi Meet at a higher level. It * contains all the required wiring between the {@code JKConferenceView} and @@ -199,6 +201,23 @@ public class JitsiMeetActivity JitsiMeetView.onHostDestroy(this); } + // ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + ReactInstanceManager reactInstanceManager; + + if (!super.onKeyUp(keyCode, event) + && BuildConfig.DEBUG + && (reactInstanceManager + = JitsiMeetView.getReactInstanceManager()) + != null + && keyCode == KeyEvent.KEYCODE_MENU) { + reactInstanceManager.showDevOptionsDialog(); + return true; + } + return false; + } + @Override public void onNewIntent(Intent intent) { JitsiMeetView.onNewIntent(intent); diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java index 8ba9c2e5a5..1717ee3290 100644 --- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java +++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java @@ -83,6 +83,11 @@ public class JitsiMeetView extends FrameLayout { return null; } + // XXX Strictly internal use only (at the time of this writing)! + static ReactInstanceManager getReactInstanceManager() { + return reactInstanceManager; + } + /** * Internal method to initialize the React Native instance manager. We * create a single instance in order to load the JavaScript bundle a single