Skip to content

Commit 2f82825

Browse files
Generate potentially long running reports in background threads instead of main UI thread
1 parent 339b2a2 commit 2f82825

File tree

3 files changed

+37
-22
lines changed

3 files changed

+37
-22
lines changed

app/src/main/java/com/termux/app/activities/SettingsActivity.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,24 @@ private void configureAboutPreference(@NonNull Context context) {
6969
Preference aboutPreference = findPreference("about");
7070
if (aboutPreference != null) {
7171
aboutPreference.setOnPreferenceClickListener(preference -> {
72-
String title = "About";
72+
new Thread() {
73+
@Override
74+
public void run() {
75+
String title = "About";
7376

74-
StringBuilder aboutString = new StringBuilder();
75-
aboutString.append(TermuxUtils.getAppInfoMarkdownString(context, false));
77+
StringBuilder aboutString = new StringBuilder();
78+
aboutString.append(TermuxUtils.getAppInfoMarkdownString(context, false));
7679

77-
String termuxPluginAppsInfo = TermuxUtils.getTermuxPluginAppsInfoMarkdownString(context);
78-
if (termuxPluginAppsInfo != null)
79-
aboutString.append("\n\n").append(termuxPluginAppsInfo);
80+
String termuxPluginAppsInfo = TermuxUtils.getTermuxPluginAppsInfoMarkdownString(context);
81+
if (termuxPluginAppsInfo != null)
82+
aboutString.append("\n\n").append(termuxPluginAppsInfo);
8083

81-
aboutString.append("\n\n").append(TermuxUtils.getDeviceInfoMarkdownString(context));
82-
aboutString.append("\n\n").append(TermuxUtils.getImportantLinksMarkdownString(context));
84+
aboutString.append("\n\n").append(TermuxUtils.getDeviceInfoMarkdownString(context));
85+
aboutString.append("\n\n").append(TermuxUtils.getImportantLinksMarkdownString(context));
8386

84-
ReportActivity.startReportActivity(context, new ReportInfo(UserAction.ABOUT, TermuxConstants.TERMUX_APP.TERMUX_SETTINGS_ACTIVITY_NAME, title, null, aboutString.toString(), null, false));
87+
ReportActivity.startReportActivity(context, new ReportInfo(UserAction.ABOUT, TermuxConstants.TERMUX_APP.TERMUX_SETTINGS_ACTIVITY_NAME, title, null, aboutString.toString(), null, false));
88+
}
89+
}.start();
8590

8691
return true;
8792
});

app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java

+20-12
Original file line numberDiff line numberDiff line change
@@ -494,26 +494,34 @@ public void reportIssueFromTranscript() {
494494
TerminalSession session = mActivity.getCurrentSession();
495495
if (session == null) return;
496496

497-
String transcriptText = ShellUtils.getTerminalSessionTranscriptText(session, false, true);
497+
final String transcriptText = ShellUtils.getTerminalSessionTranscriptText(session, false, true);
498498
if (transcriptText == null) return;
499499

500-
transcriptText = DataUtils.getTruncatedCommandOutput(transcriptText, DataUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES, false, true, false).trim();
500+
Logger.showToast(mActivity, mActivity.getString(R.string.msg_generating_report), true);
501+
502+
new Thread() {
503+
@Override
504+
public void run() {
501505

502-
StringBuilder reportString = new StringBuilder();
506+
String transcriptTextTruncated = DataUtils.getTruncatedCommandOutput(transcriptText, DataUtils.TRANSACTION_SIZE_LIMIT_IN_BYTES, false, true, false).trim();
503507

504-
String title = TermuxConstants.TERMUX_APP_NAME + " Report Issue";
508+
StringBuilder reportString = new StringBuilder();
505509

506-
reportString.append("## Transcript\n");
507-
reportString.append("\n").append(MarkdownUtils.getMarkdownCodeForString(transcriptText, true));
510+
String title = TermuxConstants.TERMUX_APP_NAME + " Report Issue";
508511

509-
reportString.append("\n\n").append(TermuxUtils.getAppInfoMarkdownString(mActivity, true));
510-
reportString.append("\n\n").append(TermuxUtils.getDeviceInfoMarkdownString(mActivity));
512+
reportString.append("## Transcript\n");
513+
reportString.append("\n").append(MarkdownUtils.getMarkdownCodeForString(transcriptTextTruncated, true));
511514

512-
String termuxAptInfo = TermuxUtils.geAPTInfoMarkdownString(mActivity);
513-
if (termuxAptInfo != null)
514-
reportString.append("\n\n").append(termuxAptInfo);
515+
reportString.append("\n\n").append(TermuxUtils.getAppInfoMarkdownString(mActivity, true));
516+
reportString.append("\n\n").append(TermuxUtils.getDeviceInfoMarkdownString(mActivity));
515517

516-
ReportActivity.startReportActivity(mActivity, new ReportInfo(UserAction.REPORT_ISSUE_FROM_TRANSCRIPT, TermuxConstants.TERMUX_APP.TERMUX_ACTIVITY_NAME, title, null, reportString.toString(), "\n\n" + TermuxUtils.getReportIssueMarkdownString(mActivity), false));
518+
String termuxAptInfo = TermuxUtils.geAPTInfoMarkdownString(mActivity);
519+
if (termuxAptInfo != null)
520+
reportString.append("\n\n").append(termuxAptInfo);
521+
522+
ReportActivity.startReportActivity(mActivity, new ReportInfo(UserAction.REPORT_ISSUE_FROM_TRANSCRIPT, TermuxConstants.TERMUX_APP.TERMUX_ACTIVITY_NAME, title, null, reportString.toString(), "\n\n" + TermuxUtils.getReportIssueMarkdownString(mActivity), false));
523+
}
524+
}.start();
517525
}
518526

519527
public void doPaste() {

app/src/main/res/values/strings.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<string name="action_autofill_password">Autofill password</string>
6767

6868
<string name="action_reset_terminal">Reset</string>
69-
<string name="msg_terminal_reset">Terminal reset.</string>
69+
<string name="msg_terminal_reset">Terminal reset</string>
7070

7171
<string name="action_kill_process">Kill process (%d)</string>
7272
<string name="title_confirm_kill_process">Really kill this session?</string>
@@ -75,7 +75,9 @@
7575
<string name="action_toggle_keep_screen_on">Keep screen on</string>
7676
<string name="action_open_help">Help</string>
7777
<string name="action_open_settings">Settings</string>
78+
7879
<string name="action_report_issue">Report Issue</string>
80+
<string name="msg_generating_report">Generating Report</string>
7981

8082
<string name="error_styling_not_installed">The &TERMUX_STYLING_APP_NAME; Plugin App is not installed.</string>
8183
<string name="action_styling_install">Install</string>

0 commit comments

Comments
 (0)