* enable review reminder for Ubuntu Software Center package

This commit is contained in:
Reinhard Pointner 2015-03-09 08:55:10 +00:00
parent 4c5886c248
commit 8ceac180f5
2 changed files with 29 additions and 6 deletions

View File

@ -246,10 +246,10 @@ public class Main {
int renameCount = HistorySpooler.getInstance().getPersistentHistoryTotalSize(); int renameCount = HistorySpooler.getInstance().getPersistentHistoryTotalSize();
if (renameCount > 2000 && Math.random() < chance) { if (renameCount > 2000 && Math.random() < chance) {
if (!isAppStore()) { if (isAppStore()) {
showAppStoreReviewReminder();
} else {
showDonationReminder(); showDonationReminder();
} else if (isMacApp() && isAppStore()) {
showMacAppStoreReviewReminder();
} }
} }
@ -379,7 +379,7 @@ public class Main {
} }
} }
private static void showMacAppStoreReviewReminder() { private static void showAppStoreReviewReminder() {
PreferencesEntry<String> donation = Settings.forPackage(Main.class).entry("review").defaultValue("0"); PreferencesEntry<String> donation = Settings.forPackage(Main.class).entry("review").defaultValue("0");
int donationRev = Integer.parseInt(donation.getValue()); int donationRev = Integer.parseInt(donation.getValue());
if (donationRev > 0) { if (donationRev > 0) {
@ -390,13 +390,13 @@ public class Main {
int currentRev = getApplicationRevisionNumber(); int currentRev = getApplicationRevisionNumber();
donation.setValue(String.valueOf(currentRev)); donation.setValue(String.valueOf(currentRev));
String message = String.format(Locale.ROOT, "<html><p style='font-size:16pt; font-weight:bold'>Thank you for using FileBot!</p><br><p>It has taken many nights to develop this application. If you enjoy using it,<br>please consider writing a nice little review on the Mac App Store.<p><p style='font-size:14pt; font-weight:bold'>You've renamed %,d files.</p><br><html>", HistorySpooler.getInstance().getPersistentHistoryTotalSize()); String message = String.format(Locale.ROOT, "<html><p style='font-size:16pt; font-weight:bold'>Thank you for using FileBot!</p><br><p>It has taken many nights to develop this application. If you enjoy using it,<br>please consider writing a nice little review on the %s.<p><p style='font-size:14pt; font-weight:bold'>You've renamed %,d files.</p><br><html>", getAppStoreName(), HistorySpooler.getInstance().getPersistentHistoryTotalSize());
String[] actions = new String[] { "Review! I like FileBot. :)", "Never! Don't bother me again." }; String[] actions = new String[] { "Review! I like FileBot. :)", "Never! Don't bother me again." };
JOptionPane pane = new JOptionPane(message, INFORMATION_MESSAGE, YES_NO_OPTION, ResourceManager.getIcon("window.icon.large"), actions, actions[0]); JOptionPane pane = new JOptionPane(message, INFORMATION_MESSAGE, YES_NO_OPTION, ResourceManager.getIcon("window.icon.large"), actions, actions[0]);
pane.createDialog(null, "Please rate FileBot").setVisible(true); pane.createDialog(null, "Please rate FileBot").setVisible(true);
if (pane.getValue() == actions[0]) { if (pane.getValue() == actions[0]) {
try { try {
Desktop.getDesktop().browse(URI.create("macappstore://itunes.apple.com/app/id905384638")); // this will naturally only work on Mac ;) Desktop.getDesktop().browse(getAppStoreURI()); // this will naturally only work on Mac or Ubuntu ;)
} catch (Exception e) { } catch (Exception e) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "Failed to browse URI", e); Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "Failed to browse URI", e);
} }

View File

@ -4,6 +4,7 @@ import static net.filebot.util.StringUtilities.*;
import java.awt.GraphicsEnvironment; import java.awt.GraphicsEnvironment;
import java.io.File; import java.io.File;
import java.net.URI;
import java.util.Locale; import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@ -82,6 +83,10 @@ public final class Settings {
return isApplicationDeployment("mas", "usc"); return isApplicationDeployment("mas", "usc");
} }
public static boolean isUbuntuApp() {
return isApplicationDeployment("usc");
}
public static boolean isMacApp() { public static boolean isMacApp() {
return isApplicationDeployment("mas", "app"); return isApplicationDeployment("mas", "app");
} }
@ -169,6 +174,24 @@ public final class Settings {
return new File(System.getProperty("user.home")); return new File(System.getProperty("user.home"));
} }
public static String getAppStoreName() {
if (isMacApp())
return "Mac App Store";
if (isUbuntuApp())
return "Ubuntu Software Center";
return null;
}
public static URI getAppStoreURI() {
if (isMacApp())
return URI.create("macappstore://itunes.apple.com/app/id905384638");
if (isUbuntuApp())
return URI.create("apt://filebot");
return null;
}
public static Settings forPackage(Class<?> type) { public static Settings forPackage(Class<?> type) {
return new Settings(Preferences.userNodeForPackage(type)); return new Settings(Preferences.userNodeForPackage(type));
} }