mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 09:47:35 +08:00
Add a 'Report Bug' button
This also attaches the entire 'adb logcat' in Android. This way, we can hopefully get useful info about why something is not working. This currently breaks the build as we need to migrate to Android X
This commit is contained in:
@ -0,0 +1,29 @@
|
||||
package io.gitjournal.gitjournal;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class LogDumper {
|
||||
public static void dumpLogs(String filePath) throws Exception {
|
||||
File file = new File(filePath);
|
||||
|
||||
// Truncate the existing file
|
||||
PrintWriter pw = new PrintWriter(file);
|
||||
pw.close();
|
||||
|
||||
FileOutputStream stream = new FileOutputStream(file, true);
|
||||
|
||||
Process logcat = Runtime.getRuntime().exec(new String[]{"logcat", "-d"});
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(logcat.getInputStream()), 4 * 1024);
|
||||
String line;
|
||||
String separator = System.getProperty("line.separator");
|
||||
while ((line = br.readLine()) != null) {
|
||||
stream.write(line.getBytes());
|
||||
stream.write(separator.getBytes());
|
||||
}
|
||||
stream.close();
|
||||
}
|
||||
}
|
@ -227,6 +227,17 @@ public class MainActivity extends FlutterActivity implements MethodCallHandler {
|
||||
|
||||
result.success(publicKey);
|
||||
return;
|
||||
} else if (call.method.equals("dumpAppLogs")) {
|
||||
String filePath = filesDir + "/app-logs.txt";
|
||||
|
||||
try {
|
||||
LogDumper.dumpLogs(filePath);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.error("FAILED", e.toString(), null);
|
||||
}
|
||||
|
||||
result.success(filePath);
|
||||
}
|
||||
|
||||
result.notImplemented();
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
|
||||
import 'app.dart';
|
||||
@ -19,6 +20,14 @@ Future<String> getVersionString() async {
|
||||
return versionText;
|
||||
}
|
||||
|
||||
/// adb logcat
|
||||
/// Returns the file path where the logs were dumped
|
||||
Future<String> dumpAppLogs() async {
|
||||
const _platform = const MethodChannel('gitjournal.io/git');
|
||||
final String logsFilePath = await _platform.invokeMethod('dumpAppLogs');
|
||||
return logsFilePath;
|
||||
}
|
||||
|
||||
SnackBar buildUndoDeleteSnackbar(
|
||||
BuildContext context,
|
||||
Note deletedNote,
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_email_sender/flutter_email_sender.dart';
|
||||
import 'package:journal/analytics.dart';
|
||||
import 'package:journal/state_container.dart';
|
||||
import 'package:journal/utils.dart';
|
||||
@ -84,7 +85,7 @@ class AppDrawer extends StatelessWidget {
|
||||
onTap: () async {
|
||||
var versionText = await getVersionString();
|
||||
|
||||
var emailAddress = 'gitjournal.io@gmail.com';
|
||||
var emailAddress = 'gitjournal.io+feedback@gmail.com';
|
||||
var subject = 'GitJournal Feedback';
|
||||
var body =
|
||||
"Hey!\n\nHere are some ways to improve GitJournal - \n \n\nVersion: $versionText";
|
||||
@ -98,6 +99,30 @@ class AppDrawer extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.bug_report, color: textStyle.color),
|
||||
title: Text('Bug Report', style: textStyle),
|
||||
onTap: () async {
|
||||
var versionText = await getVersionString();
|
||||
var appLogsFilePath = await dumpAppLogs();
|
||||
|
||||
final Email email = Email(
|
||||
body:
|
||||
"Hey!\n\nI found a bug in GitJournal - \n \n\nVersion: $versionText",
|
||||
subject: 'GitJournal Bug',
|
||||
recipients: ['gitjournal.io+bugs@gmail.com'],
|
||||
attachmentPath: appLogsFilePath,
|
||||
);
|
||||
|
||||
await FlutterEmailSender.send(email);
|
||||
|
||||
Navigator.pop(context);
|
||||
|
||||
getAnalytics().logEvent(
|
||||
name: "drawer_bugreport",
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.settings, color: textStyle.color),
|
||||
title: Text('Settings', style: textStyle),
|
||||
|
@ -132,6 +132,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_email_sender:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_email_sender
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
flutter_launcher_icons:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
|
@ -21,6 +21,7 @@ dependencies:
|
||||
launch_review: ^1.0.1
|
||||
device_info: ^0.4.0+1
|
||||
flutter_markdown: ^0.2.0
|
||||
flutter_email_sender: ^2.0.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_launcher_icons: "^0.7.0"
|
||||
|
Reference in New Issue
Block a user