Added 'Export logs' button to bug report page

This commit is contained in:
ByteHamster 2020-02-23 19:48:34 +01:00
parent 930642cb36
commit aa160355c3
3 changed files with 21 additions and 0 deletions

View File

@ -52,5 +52,19 @@ public class BugReportActivity extends AppCompatActivity {
clipboard.setPrimaryClip(clip);
Snackbar.make(findViewById(android.R.id.content), R.string.copied_to_clipboard, Snackbar.LENGTH_SHORT).show();
});
findViewById(R.id.btn_export_logcat).setOnClickListener(v -> {
try {
File filename = new File(UserPreferences.getDataFolder(null), "full-logs.txt");
filename.createNewFile();
String cmd = "logcat -d -f " + filename.getAbsolutePath();
Runtime.getRuntime().exec(cmd);
Snackbar.make(findViewById(android.R.id.content),
filename.getAbsolutePath(), Snackbar.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
Snackbar.make(findViewById(android.R.id.content), e.getMessage(), Snackbar.LENGTH_LONG).show();
}
});
}
}

View File

@ -16,6 +16,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/btn_export_logcat"
android:text="@string/export_logs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="8dp"
android:id="@+id/crash_report_logs"

View File

@ -489,6 +489,7 @@
<string name="view_mailing_list">View mailing list</string>
<string name="bug_report_title">Report bug</string>
<string name="open_bug_tracker">Open bug tracker</string>
<string name="export_logs">Export logs</string>
<string name="copy_to_clipboard">Copy to clipboard</string>
<string name="copied_to_clipboard">Copied to clipboard</string>
<string name="experimental_pref">Experimental</string>