termux-app

Форк
0
98 строк · 3.7 Кб
1
package com.termux.shared.models;
2

3
import com.termux.shared.markdown.MarkdownUtils;
4
import com.termux.shared.android.AndroidUtils;
5

6
import java.io.Serializable;
7

8
/**
9
 * An object that stored info for {@link com.termux.shared.activities.ReportActivity}.
10
 */
11
public class ReportInfo implements Serializable {
12

13
    /** The user action that was being processed for which the report was generated. */
14
    public final String userAction;
15
    /** The internal app component that sent the report. */
16
    public final String sender;
17
    /** The report title. */
18
    public final String reportTitle;
19
    /** The timestamp for the report. */
20
    public final String reportTimestamp;
21

22
    /** The markdown report text prefix. Will not be part of copy and share operations, etc. */
23
    public String reportStringPrefix;
24
    /** The markdown report text. */
25
    public String reportString;
26
    /** The markdown report text suffix. Will not be part of copy and share operations, etc. */
27
    public String reportStringSuffix;
28

29
    /** If set to {@code true}, then report header info will be added to the report when markdown is
30
     * generated. */
31
    public boolean addReportInfoHeaderToMarkdown = false;
32

33
    /** The label for the report file to save if user selects menu_item_save_report_to_file. */
34
    public String reportSaveFileLabel;
35
    /** The path for the report file to save if user selects menu_item_save_report_to_file. */
36
    public String reportSaveFilePath;
37

38
    public ReportInfo(String userAction, String sender, String reportTitle) {
39
        this.userAction = userAction;
40
        this.sender = sender;
41
        this.reportTitle = reportTitle;
42
        this.reportTimestamp = AndroidUtils.getCurrentMilliSecondUTCTimeStamp();
43
    }
44

45
    public void setReportStringPrefix(String reportStringPrefix) {
46
        this.reportStringPrefix = reportStringPrefix;
47
    }
48

49
    public void setReportString(String reportString) {
50
        this.reportString = reportString;
51
    }
52

53
    public void setReportStringSuffix(String reportStringSuffix) {
54
        this.reportStringSuffix = reportStringSuffix;
55
    }
56

57
    public void setAddReportInfoHeaderToMarkdown(boolean addReportInfoHeaderToMarkdown) {
58
        this.addReportInfoHeaderToMarkdown = addReportInfoHeaderToMarkdown;
59
    }
60

61
    public void setReportSaveFileLabelAndPath(String reportSaveFileLabel, String reportSaveFilePath) {
62
        setReportSaveFileLabel(reportSaveFileLabel);
63
        setReportSaveFilePath(reportSaveFilePath);
64
    }
65

66
    public void setReportSaveFileLabel(String reportSaveFileLabel) {
67
        this.reportSaveFileLabel = reportSaveFileLabel;
68
    }
69

70
    public void setReportSaveFilePath(String reportSaveFilePath) {
71
        this.reportSaveFilePath = reportSaveFilePath;
72
    }
73

74
    /**
75
     * Get a markdown {@link String} for {@link ReportInfo}.
76
     *
77
     * @param reportInfo The {@link ReportInfo} to convert.
78
     * @return Returns the markdown {@link String}.
79
     */
80
    public static String getReportInfoMarkdownString(final ReportInfo reportInfo) {
81
        if (reportInfo == null) return "null";
82

83
        StringBuilder markdownString = new StringBuilder();
84

85
        if (reportInfo.addReportInfoHeaderToMarkdown) {
86
            markdownString.append("## Report Info\n\n");
87
            markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("User Action", reportInfo.userAction, "-"));
88
            markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Sender", reportInfo.sender, "-"));
89
            markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Report Timestamp", reportInfo.reportTimestamp, "-"));
90
            markdownString.append("\n##\n\n");
91
        }
92

93
        markdownString.append(reportInfo.reportString);
94

95
        return markdownString.toString();
96
    }
97

98
}
99

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.