mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-11 16:26:22 +00:00
update mobile BugReporter savetofile
This commit is contained in:
@@ -15,7 +15,7 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
GuiBase.setInterface(new GuiMobile(Files.exists(Paths.get("./res"))?"./":"../forge-gui/"));
|
||||
GuiBase.setDeviceInfo(null, 0, 0);
|
||||
GuiBase.setDeviceInfo(null, 0, 0, System.getProperty("user.home") + "/Downloads/");
|
||||
new EditorMainWindow(Config.instance());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class Forge implements ApplicationListener {
|
||||
scope.getContexts().setOperatingSystem(hwInfo.os());
|
||||
});
|
||||
}
|
||||
GuiBase.setDeviceInfo(hwInfo, AndroidAPI, totalRAM);
|
||||
GuiBase.setDeviceInfo(hwInfo, AndroidAPI, totalRAM, deviceAdapter.getDownloadsDir());
|
||||
}
|
||||
return app;
|
||||
}
|
||||
@@ -171,18 +171,7 @@ public class Forge implements ApplicationListener {
|
||||
//install our error handler
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
//init hwInfo to log
|
||||
HWInfo info = GuiBase.getHWInfo();
|
||||
if (info != null) {
|
||||
System.out.println(
|
||||
"##########################################\n" +
|
||||
"APP: Forge v." + GuiBase.getInterface().getCurrentVersion() +
|
||||
"\nDEV: " + info.device().getName() +
|
||||
"\nCPU: " + info.device().getCpuDescription() +
|
||||
"\nRAM: " + GuiBase.getDeviceRAM() + " MB" +
|
||||
"\nOS: " + info.os().getRawDescription() +
|
||||
"\n##########################################"
|
||||
);
|
||||
}
|
||||
System.out.println(GuiBase.getHWInfo());
|
||||
// closeSplashScreen() is called early on non-Windows OS so it will not crash, LWJGL3 bug on AWT Splash.
|
||||
if (OperatingSystem.isWindows())
|
||||
getDeviceAdapter().closeSplashScreen();
|
||||
|
||||
@@ -44,7 +44,10 @@ public class BugReportDialog extends FScreen { //use screen rather than dialog s
|
||||
BugReporter.sendSentry();
|
||||
Forge.back();
|
||||
});
|
||||
btnSave.setCommand(e -> BugReporter.saveToFile(tvDetails.text));
|
||||
btnSave.setCommand(e -> {
|
||||
BugReporter.saveToFile(tvDetails.text);
|
||||
Forge.back();
|
||||
});
|
||||
btnDiscard.setCommand(e -> Forge.back());
|
||||
if (showExitAppBtn) {
|
||||
btnExit.setCommand(e -> Forge.exit(true));
|
||||
|
||||
@@ -13,6 +13,7 @@ public class GuiBase {
|
||||
private static boolean interrupted = false;
|
||||
private static int androidAPI = 0;
|
||||
private static int deviceRAM = 0;
|
||||
private static String downloadsDir = "";
|
||||
private static boolean usingAppDirectory = false;
|
||||
private static ForgePreferences forgePrefs;
|
||||
private static HWInfo hwInfo;
|
||||
@@ -34,14 +35,29 @@ public class GuiBase {
|
||||
public static void setUsingAppDirectory(boolean value) { usingAppDirectory = value; }
|
||||
public static boolean isUsingAppDirectory() { return usingAppDirectory; }
|
||||
|
||||
public static void setDeviceInfo(HWInfo hw, int AndroidAPI, int RAM) {
|
||||
public static void setDeviceInfo(HWInfo hw, int AndroidAPI, int RAM, String dir) {
|
||||
hwInfo = hw;
|
||||
androidAPI = AndroidAPI;
|
||||
deviceRAM = RAM;
|
||||
downloadsDir = dir;
|
||||
}
|
||||
public static String getHWInfo() {
|
||||
if (hwInfo != null) {
|
||||
return "##########################################\n" +
|
||||
"APP: Forge v." + getInterface().getCurrentVersion() +
|
||||
"\nDEV: " + hwInfo.device().getName() +
|
||||
"\nCPU: " + hwInfo.device().getCpuDescription() +
|
||||
"\nRAM: " + deviceRAM + " MB" +
|
||||
"\nOS: " + hwInfo.os().getRawDescription() +
|
||||
"\n##########################################";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public static String getDownloadsDir() {
|
||||
return downloadsDir;
|
||||
}
|
||||
public static int getAndroidAPILevel() { return androidAPI; }
|
||||
public static int getDeviceRAM() { return deviceRAM; }
|
||||
public static HWInfo getHWInfo() { return hwInfo; }
|
||||
|
||||
public static boolean isNetworkplay() { return networkplay; }
|
||||
public static void setNetworkplay(boolean value) { networkplay = value; }
|
||||
|
||||
@@ -26,6 +26,8 @@ import forge.util.Localizer;
|
||||
import io.sentry.Sentry;
|
||||
|
||||
import java.io.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* The class ErrorViewer. Enables showing and saving error messages that
|
||||
@@ -86,7 +88,7 @@ public class BugReporter {
|
||||
if (isSentryEnabled()) {
|
||||
sendSentry();
|
||||
} else {
|
||||
GuiBase.getInterface().showBugReportDialog(Localizer.getInstance().getMessage("lblReportCrash"), sb.toString(), true);
|
||||
GuiBase.getInterface().showBugReportDialog(Localizer.getInstance().getMessageorUseDefault("lblReportCrash", "Report a Crash"), sb.toString(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,22 +123,31 @@ public class BugReporter {
|
||||
if (isSentryEnabled()) {
|
||||
sendSentry();
|
||||
} else {
|
||||
GuiBase.getInterface().showBugReportDialog(Localizer.getInstance().getMessage("btnReportBug"), message, false);
|
||||
GuiBase.getInterface().showBugReportDialog(Localizer.getInstance().getMessageorUseDefault("btnReportBug", "Report a Bug"), message, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveToFile(final String text) {
|
||||
public static void saveToFile(final String error) {
|
||||
File f;
|
||||
final long curTime = System.currentTimeMillis();
|
||||
for (int i = 0;; i++) {
|
||||
final String name = String.format("%TF-%02d.txt", curTime, i);
|
||||
f = new File(name);
|
||||
if (!f.exists()) {
|
||||
break;
|
||||
String text;
|
||||
if (GuiBase.getInterface().isLibgdxPort()) {
|
||||
text = GuiBase.getHWInfo() + "\n\n" + error;
|
||||
// Save in downloads directory instead for easy access without filepicker
|
||||
String filename = "forge-bug-" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HHmmss")) + ".txt";
|
||||
f = new File(GuiBase.getDownloadsDir() + filename);
|
||||
} else {
|
||||
text = error;
|
||||
final long curTime = System.currentTimeMillis();
|
||||
for (int i = 0; ; i++) {
|
||||
final String name = String.format("%TF-%02d.txt", curTime, i);
|
||||
f = new File(name);
|
||||
if (!f.exists()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
f = GuiBase.getInterface().getSaveFile(f);
|
||||
f = GuiBase.getInterface().getSaveFile(f);
|
||||
}
|
||||
|
||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(f))){
|
||||
bw.write(text);
|
||||
@@ -147,11 +158,13 @@ public class BugReporter {
|
||||
}
|
||||
|
||||
public static void sendSentry() {
|
||||
if (exception != null) {
|
||||
Sentry.captureException(exception);
|
||||
} else if (message !=null) {
|
||||
Sentry.captureMessage(message);
|
||||
}
|
||||
try {
|
||||
if (exception != null) {
|
||||
Sentry.captureException(exception);
|
||||
} else if (message !=null) {
|
||||
Sentry.captureMessage(message);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user