persistentDonateLv = Settings.forPackage(Main.class).entry("donate.lv").defaultValue("0");
+ int donateLv = Integer.parseInt(persistentDonateLv.getValue());
+ int donateStep = 10000;
+ int usage = history.totalSize();
+
+ if (usage / donateStep > donateLv) {
+ persistentDonateLv.setValue(String.valueOf(Math.max(donateLv + 1, usage / donateStep)));
+
+ String message = String.format(Locale.ROOT, "Thank you for using FileBot!
It has taken many nights to develop this application. If you enjoy using it,
please consider a donation to the author of this software. It will help to
make FileBot even better!
You've renamed %,d files.
", history.totalSize());
+ String[] actions = new String[] { "Donate!", "Later" };
+ JOptionPane pane = new JOptionPane(message, INFORMATION_MESSAGE, YES_NO_OPTION, ResourceManager.getIcon("message.donate"), actions, actions[0]);
+ pane.createDialog(null, "Please Donate").setVisible(true);
+ if (pane.getValue() == actions[0]) {
+ Desktop.getDesktop().browse(URI.create(getApplicationProperty("donate.url")));
+ }
+ }
+ } catch (Exception e) {
+ Logger.getLogger(Main.class.getName()).log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+
+ @Override
+ public History read() throws IOException {
+ return fileStorage.read();
+ }
+ });
+ }
} catch (CmdLineException e) {
// illegal arguments => just print CLI error message and stop
System.err.println(e.getMessage());
@@ -213,7 +269,15 @@ public class Main {
}
frame.setLocationByPlatform(true);
- frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
+ frame.addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ e.getWindow().setVisible(false);
+ HistorySpooler.getInstance().commit();
+ System.exit(0);
+ }
+ });
try {
// restore previous size and location
diff --git a/source/net/sourceforge/filebot/Settings.java b/source/net/sourceforge/filebot/Settings.java
index e6f0b7d7..2e35077b 100644
--- a/source/net/sourceforge/filebot/Settings.java
+++ b/source/net/sourceforge/filebot/Settings.java
@@ -64,6 +64,16 @@ public final class Settings {
}
+ public static boolean useDonationReminder() {
+ String value = System.getProperty("useDonationReminder");
+ if (value != null) {
+ return Boolean.parseBoolean(value);
+ } else {
+ return getApplicationDeployment() == null || !getApplicationDeployment().equalsIgnoreCase("ppa");
+ }
+ }
+
+
public static int getPreferredThreadPoolSize() {
try {
return Integer.parseInt(System.getProperty("threadPool"));
diff --git a/source/net/sourceforge/filebot/Settings.properties b/source/net/sourceforge/filebot/Settings.properties
index 781303ea..4039a3b6 100644
--- a/source/net/sourceforge/filebot/Settings.properties
+++ b/source/net/sourceforge/filebot/Settings.properties
@@ -5,6 +5,7 @@ application.revision: @{svn.revision}
# application updates
update.url: http://filebot.sourceforge.net/update.xml
+donate.url: http://filebot.sourceforge.net/donate.html
# base URL for resolving script resources
script.fn: http://filebot.sourceforge.net/scripts/%s.groovy