Merge pull request #3886 from ByteHamster/export-logcat

Added 'Export logs' button to bug report page
This commit is contained in:
H. Lehmann 2020-03-01 00:05:13 +01:00 committed by GitHub
commit b80bb03d27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View File

@ -52,5 +52,19 @@ public class BugReportActivity extends AppCompatActivity {
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
Snackbar.make(findViewById(android.R.id.content), R.string.copied_to_clipboard, Snackbar.LENGTH_SHORT).show(); 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_width="match_parent"
android:layout_height="wrap_content"/> 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 <TextView
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:id="@+id/crash_report_logs" android:id="@+id/crash_report_logs"

View File

@ -490,6 +490,7 @@
<string name="visit_user_forum">Visit user forum</string> <string name="visit_user_forum">Visit user forum</string>
<string name="bug_report_title">Report bug</string> <string name="bug_report_title">Report bug</string>
<string name="open_bug_tracker">Open bug tracker</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="copy_to_clipboard">Copy to clipboard</string>
<string name="copied_to_clipboard">Copied to clipboard</string> <string name="copied_to_clipboard">Copied to clipboard</string>
<string name="experimental_pref">Experimental</string> <string name="experimental_pref">Experimental</string>