Skip to content

Commit

Permalink
Set dev menu title to "React Native Dev Menu", add JS executor descri…
Browse files Browse the repository at this point in the history
…ption (#37195)

Summary:
Pull Request resolved: #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
  • Loading branch information
huntie authored and facebook-github-bot committed May 3, 2023
1 parent ceebab4 commit 5eabbd7
Showing 1 changed file with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) -> {
Expand All @@ -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
Expand Down

0 comments on commit 5eabbd7

Please sign in to comment.