Skip to content

Commit

Permalink
Merge pull request #510 from yermak/feature/509_bug_reporting
Browse files Browse the repository at this point in the history
Improve bug reporting
  • Loading branch information
yermak committed Nov 17, 2023
2 parents d4aff8e + 08c3f74 commit a48e7f8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/main/java/uk/yermak/audiobookconverter/Settings.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package uk.yermak.audiobookconverter;

import com.google.gson.*;
import org.apache.commons.io.FileUtils;
import uk.yermak.audiobookconverter.formats.Format;

import java.io.File;
Expand All @@ -11,7 +10,6 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.prefs.Preferences;
import java.util.regex.Pattern;

public class Settings {

Expand Down Expand Up @@ -70,6 +68,11 @@ public static Settings loadSetting() {
return settings;
}

public static String getRawData() {
String settingsJson = preferences.get(Version.getVersionString(), null);
return settingsJson;
}

public boolean isDarkMode() {
return darkMode;
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/uk/yermak/audiobookconverter/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.time.Duration;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

Expand Down Expand Up @@ -167,6 +168,16 @@ static String formatWithLeadingZeros(int size, int i) {
return String.format("%0" + digits + "d", i);
}

public static String propertiesToString(Properties properties) {
StringBuilder stringBuilder = new StringBuilder();

for (String key : properties.stringPropertyNames()) {
String value = properties.getProperty(key);
stringBuilder.append(key).append(": ").append(value).append(System.lineSeparator());
}

return stringBuilder.toString();
}

private static class DurationRender implements AttributeRenderer<Duration> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import javafx.fxml.FXML;
import javafx.geometry.Side;
import javafx.scene.control.*;
import javafx.scene.control.Button;
import javafx.scene.control.MenuItem;
import javafx.scene.input.TransferMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -22,9 +24,13 @@
import uk.yermak.audiobookconverter.book.Organisable;
import uk.yermak.audiobookconverter.loaders.FFMediaLoader;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.io.File;
import java.lang.invoke.MethodHandles;
import java.util.*;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -458,7 +464,18 @@ public void settings(ActionEvent actionEvent) {
}

public void openIssues(ActionEvent actionEvent) {
AudiobookConverter.getEnv().showDocument("https://github.com/yermak/AudioBookConverter/issues");
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Report bug");
alert.setContentText("Your setting will be copied into buffer and you will be redirected to GitHub issues page.\n" +
"Please describe your problem and paste settings into the issue.\n" +
"Note: Your settings may contain sensitive information like your user name, paths to your files, etc.\n");
Optional<ButtonType> result = alert.showAndWait();
if ((result.isPresent()) && (result.get() == ButtonType.OK)) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Properties properties = System.getProperties();
clipboard.setContents(new StringSelection(Utils.propertiesToString(properties)+"\n"+Settings.getRawData()), null);
AudiobookConverter.getEnv().showDocument("https://github.com/yermak/AudioBookConverter/issues");
}
}

public void repair(ActionEvent actionEvent) {
Expand Down

0 comments on commit a48e7f8

Please sign in to comment.