diff --git a/app/src/main/java/com/termux/app/activities/SettingsActivity.java b/app/src/main/java/com/termux/app/activities/SettingsActivity.java index 7af92e17..70b0b44a 100644 --- a/app/src/main/java/com/termux/app/activities/SettingsActivity.java +++ b/app/src/main/java/com/termux/app/activities/SettingsActivity.java @@ -117,12 +117,15 @@ public class SettingsActivity extends AppCompatActivity { aboutString.append("\n\n").append(TermuxUtils.getImportantLinksMarkdownString(context)); String userActionName = UserAction.ABOUT.getName(); - ReportActivity.startReportActivity(context, new ReportInfo(userActionName, - TermuxConstants.TERMUX_APP.TERMUX_SETTINGS_ACTIVITY_NAME, title, null, - aboutString.toString(), null, false, - userActionName, + + ReportInfo reportInfo = new ReportInfo(userActionName, + TermuxConstants.TERMUX_APP.TERMUX_SETTINGS_ACTIVITY_NAME, title); + reportInfo.setReportString(aboutString.toString()); + reportInfo.setReportSaveFileLabelAndPath(userActionName, Environment.getExternalStorageDirectory() + "/" + - FileUtils.sanitizeFileName(TermuxConstants.TERMUX_APP_NAME + "-" + userActionName + ".log", true, true))); + FileUtils.sanitizeFileName(TermuxConstants.TERMUX_APP_NAME + "-" + userActionName + ".log", true, true)); + + ReportActivity.startReportActivity(context, reportInfo); } }.start(); diff --git a/app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java b/app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java index aafc90ae..700173ed 100644 --- a/app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java +++ b/app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java @@ -743,14 +743,16 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase { } String userActionName = UserAction.REPORT_ISSUE_FROM_TRANSCRIPT.getName(); - ReportActivity.startReportActivity(mActivity, - new ReportInfo(userActionName, - TermuxConstants.TERMUX_APP.TERMUX_ACTIVITY_NAME, title, null, - reportString.toString(), "\n\n" + TermuxUtils.getReportIssueMarkdownString(mActivity), - false, - userActionName, - Environment.getExternalStorageDirectory() + "/" + - FileUtils.sanitizeFileName(TermuxConstants.TERMUX_APP_NAME + "-" + userActionName + ".log", true, true))); + + ReportInfo reportInfo = new ReportInfo(userActionName, + TermuxConstants.TERMUX_APP.TERMUX_ACTIVITY_NAME, title); + reportInfo.setReportString(reportString.toString()); + reportInfo.setReportStringSuffix("\n\n" + TermuxUtils.getReportIssueMarkdownString(mActivity)); + reportInfo.setReportSaveFileLabelAndPath(userActionName, + Environment.getExternalStorageDirectory() + "/" + + FileUtils.sanitizeFileName(TermuxConstants.TERMUX_APP_NAME + "-" + userActionName + ".log", true, true)); + + ReportActivity.startReportActivity(mActivity, reportInfo); } }.start(); } diff --git a/app/src/main/java/com/termux/app/utils/CrashUtils.java b/app/src/main/java/com/termux/app/utils/CrashUtils.java index 70ad36e4..2a079b34 100644 --- a/app/src/main/java/com/termux/app/utils/CrashUtils.java +++ b/app/src/main/java/com/termux/app/utils/CrashUtils.java @@ -148,12 +148,16 @@ public class CrashUtils { reportString.append("\n\n").append(AndroidUtils.getDeviceInfoMarkdownString(context)); String userActionName = UserAction.CRASH_REPORT.getName(); - ReportActivity.NewInstanceResult result = ReportActivity.newInstance(context, new ReportInfo(userActionName, - logTag, title.toString(), null, reportString.toString(), - "\n\n" + TermuxUtils.getReportIssueMarkdownString(context), true, - userActionName, + + ReportInfo reportInfo = new ReportInfo(userActionName, logTag, title.toString()); + reportInfo.setReportString(reportString.toString()); + reportInfo.setReportStringSuffix("\n\n" + TermuxUtils.getReportIssueMarkdownString(context)); + reportInfo.setAddReportInfoHeaderToMarkdown(true); + reportInfo.setReportSaveFileLabelAndPath(userActionName, Environment.getExternalStorageDirectory() + "/" + - FileUtils.sanitizeFileName(TermuxConstants.TERMUX_APP_NAME + "-" + userActionName + ".log", true, true))); + FileUtils.sanitizeFileName(TermuxConstants.TERMUX_APP_NAME + "-" + userActionName + ".log", true, true)); + + ReportActivity.NewInstanceResult result = ReportActivity.newInstance(context, reportInfo); if (result.contentIntent == null) return; // Must ensure result code for PendingIntents and id for notification are unique otherwise will override previous diff --git a/app/src/main/java/com/termux/app/utils/PluginUtils.java b/app/src/main/java/com/termux/app/utils/PluginUtils.java index 52e2f55e..4dfc5c6c 100644 --- a/app/src/main/java/com/termux/app/utils/PluginUtils.java +++ b/app/src/main/java/com/termux/app/utils/PluginUtils.java @@ -266,12 +266,16 @@ public class PluginUtils { reportString.append("\n\n").append(AndroidUtils.getDeviceInfoMarkdownString(context)); String userActionName = UserAction.PLUGIN_EXECUTION_COMMAND.getName(); - ReportActivity.NewInstanceResult result = ReportActivity.newInstance(context, - new ReportInfo(userActionName, logTag, title.toString(), null, - reportString.toString(), null,true, - userActionName, - Environment.getExternalStorageDirectory() + "/" + - FileUtils.sanitizeFileName(TermuxConstants.TERMUX_APP_NAME + "-" + userActionName + ".log", true, true))); + + ReportInfo reportInfo = new ReportInfo(userActionName, logTag, title.toString()); + reportInfo.setReportString(reportString.toString()); + reportInfo.setReportStringSuffix("\n\n" + TermuxUtils.getReportIssueMarkdownString(context)); + reportInfo.setAddReportInfoHeaderToMarkdown(true); + reportInfo.setReportSaveFileLabelAndPath(userActionName, + Environment.getExternalStorageDirectory() + "/" + + FileUtils.sanitizeFileName(TermuxConstants.TERMUX_APP_NAME + "-" + userActionName + ".log", true, true)); + + ReportActivity.NewInstanceResult result = ReportActivity.newInstance(context, reportInfo); if (result.contentIntent == null) return; // Must ensure result code for PendingIntents and id for notification are unique otherwise will override previous diff --git a/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java b/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java index 253d9d37..129fb337 100644 --- a/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java +++ b/termux-shared/src/main/java/com/termux/shared/models/ReportInfo.java @@ -16,39 +16,61 @@ public class ReportInfo implements Serializable { public final String sender; /** The report title. */ public final String reportTitle; + /** The timestamp for the report. */ + public final String reportTimestamp; + /** The markdown report text prefix. Will not be part of copy and share operations, etc. */ public String reportStringPrefix; /** The markdown report text. */ public String reportString; /** The markdown report text suffix. Will not be part of copy and share operations, etc. */ public String reportStringSuffix; - /** If set to {@code true}, then report, app and device info will be added to the report when - * markdown is generated. - */ - public final boolean addReportInfoHeaderToMarkdown; - /** The timestamp for the report. */ - public final String reportTimestamp; + + /** If set to {@code true}, then report header info will be added to the report when markdown is + * generated. */ + public boolean addReportInfoHeaderToMarkdown = false; /** The label for the report file to save if user selects menu_item_save_report_to_file. */ - public final String reportSaveFileLabel; + public String reportSaveFileLabel; /** The path for the report file to save if user selects menu_item_save_report_to_file. */ - public final String reportSaveFilePath; + public String reportSaveFilePath; - public ReportInfo(String userAction, String sender, String reportTitle, String reportStringPrefix, - String reportString, String reportStringSuffix, boolean addReportInfoHeaderToMarkdown, - String reportSaveFileLabel, String reportSaveFilePath) { + public ReportInfo(String userAction, String sender, String reportTitle) { this.userAction = userAction; this.sender = sender; this.reportTitle = reportTitle; - this.reportStringPrefix = reportStringPrefix; - this.reportString = reportString; - this.reportStringSuffix = reportStringSuffix; - this.addReportInfoHeaderToMarkdown = addReportInfoHeaderToMarkdown; - this.reportSaveFileLabel = reportSaveFileLabel; - this.reportSaveFilePath = reportSaveFilePath; this.reportTimestamp = AndroidUtils.getCurrentMilliSecondUTCTimeStamp(); } + public void setReportStringPrefix(String reportStringPrefix) { + this.reportStringPrefix = reportStringPrefix; + } + + public void setReportString(String reportString) { + this.reportString = reportString; + } + + public void setReportStringSuffix(String reportStringSuffix) { + this.reportStringSuffix = reportStringSuffix; + } + + public void setAddReportInfoHeaderToMarkdown(boolean addReportInfoHeaderToMarkdown) { + this.addReportInfoHeaderToMarkdown = addReportInfoHeaderToMarkdown; + } + + public void setReportSaveFileLabelAndPath(String reportSaveFileLabel, String reportSaveFilePath) { + setReportSaveFileLabel(reportSaveFileLabel); + setReportSaveFilePath(reportSaveFilePath); + } + + public void setReportSaveFileLabel(String reportSaveFileLabel) { + this.reportSaveFileLabel = reportSaveFileLabel; + } + + public void setReportSaveFilePath(String reportSaveFilePath) { + this.reportSaveFilePath = reportSaveFilePath; + } + /** * Get a markdown {@link String} for {@link ReportInfo}. *