From 5eabbd706708e5a5e9dee1cc369f76644a0e5a60 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Wed, 3 May 2023 04:14:36 -0700 Subject: [PATCH] Set dev menu title to "React Native Dev Menu", add JS executor description (#37195) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37195 Updates the Dev Menu header on Android. - Small alignment related to D44872456. - Add subheading label showing current JS executor description (matching iOS) (note: on Android this is unformatted (but informative), e.g. `JSIExecutor+HermesRuntime`). Changelog: [Internal] Reviewed By: cortinico Differential Revision: D45142924 fbshipit-source-id: 5c95fc85e6d3b6879287440f76165b02957283e5 --- .../devsupport/DevSupportManagerBase.java | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java index 249738028f0afa..8e3b4680fd3733 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java @@ -24,6 +24,7 @@ import android.view.Gravity; import android.view.View; import android.widget.EditText; +import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.Nullable; @@ -526,17 +527,30 @@ public void onOptionSelected() { return; } - final TextView textView = new TextView(getApplicationContext()); - textView.setText("React Native DevMenu (" + getUniqueTag() + ")"); - textView.setPadding(0, 50, 0, 0); - textView.setGravity(Gravity.CENTER); - textView.setTextColor(Color.BLACK); - textView.setTextSize(17); - textView.setTypeface(textView.getTypeface(), Typeface.BOLD); + final LinearLayout header = new LinearLayout(getApplicationContext()); + header.setOrientation(LinearLayout.VERTICAL); + + final TextView title = new TextView(getApplicationContext()); + title.setText("React Native Dev Menu (" + getUniqueTag() + ")"); + title.setPadding(0, 50, 0, 0); + title.setGravity(Gravity.CENTER); + title.setTextColor(Color.DKGRAY); + title.setTextSize(16); + title.setTypeface(title.getTypeface(), Typeface.BOLD); + + final TextView jsExecutorLabel = new TextView(getApplicationContext()); + jsExecutorLabel.setText(getJSExecutorDescription()); + jsExecutorLabel.setPadding(0, 20, 0, 0); + jsExecutorLabel.setGravity(Gravity.CENTER); + jsExecutorLabel.setTextColor(Color.GRAY); + jsExecutorLabel.setTextSize(14); + + header.addView(title); + header.addView(jsExecutorLabel); mDevOptionsDialog = new AlertDialog.Builder(context) - .setCustomTitle(textView) + .setCustomTitle(header) .setItems( options.keySet().toArray(new String[0]), (dialog, which) -> { @@ -551,6 +565,10 @@ public void onOptionSelected() { } } + private String getJSExecutorDescription() { + return "Running " + getReactInstanceDevHelper().getJavaScriptExecutorFactory().toString(); + } + /** * {@link ReactInstanceDevCommandsHandler} is responsible for enabling/disabling dev support when * a React view is attached/detached or when application state changes (e.g. the application is