[FEATURE] Alert of new version

Related to issue #195
This commit is contained in:
Emma Stone
2017-05-31 03:15:43 +01:00
parent 85c00e8880
commit d6547e3b84
3 changed files with 38 additions and 26 deletions
+2 -4
View File
@@ -1,7 +1,6 @@
package org.parabot; package org.parabot;
import org.parabot.api.translations.TranslationHelper; import org.parabot.api.translations.TranslationHelper;
import org.parabot.core.Configuration;
import org.parabot.core.Core; import org.parabot.core.Core;
import org.parabot.core.Directories; import org.parabot.core.Directories;
import org.parabot.core.forum.AccountManager; import org.parabot.core.forum.AccountManager;
@@ -10,13 +9,10 @@ import org.parabot.core.network.proxy.ProxySocket;
import org.parabot.core.network.proxy.ProxyType; import org.parabot.core.network.proxy.ProxyType;
import org.parabot.core.ui.BotUI; import org.parabot.core.ui.BotUI;
import org.parabot.core.ui.ServerSelector; import org.parabot.core.ui.ServerSelector;
import org.parabot.core.ui.utils.UILog;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URI;
/** /**
* Parabot v2.6 * Parabot v2.6
@@ -46,9 +42,11 @@ public final class Landing {
} }
if (!Core.inDebugMode() && Core.hasValidation() && !Core.isValid()) { if (!Core.inDebugMode() && Core.hasValidation() && !Core.isValid()) {
if (Core.newVersionAlert() == JOptionPane.YES_OPTION) {
Core.downloadNewVersion(); Core.downloadNewVersion();
return; return;
} }
}
Core.verbose(TranslationHelper.translate("VALIDATION_ACCOUNT_MANAGER")); Core.verbose(TranslationHelper.translate("VALIDATION_ACCOUNT_MANAGER"));
AccountManager.validate(); AccountManager.validate();
+7 -2
View File
@@ -14,13 +14,11 @@ import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Date;
/** /**
* The core of parabot * The core of parabot
@@ -251,4 +249,11 @@ public class Core {
return true; return true;
} }
} }
/**
* Alerts the user that there is a new version
*/
public static int newVersionAlert() {
return UILog.alert("Parabot Update", "There's a new version of Parabot! \nDo you wish to download it?\n\nThe current version could have some problems!", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
}
} }
@@ -1,13 +1,11 @@
package org.parabot.core.ui.utils; package org.parabot.core.ui.utils;
import javax.swing.JOptionPane; import javax.swing.*;
/** /**
*
* Log messages to the log user interface which is attached to the bot user interface * Log messages to the log user interface which is attached to the bot user interface
* *
* @author Everel * @author Everel
*
*/ */
public class UILog { public class UILog {
@@ -21,4 +19,15 @@ public class UILog {
messageType); messageType);
} }
public static int alert(final String title, final String message) {
alert(title, message, JOptionPane.YES_NO_OPTION);
}
public static int alert(final String title, final String message, int option) {
alert(title, message, option, JOptionPane.DEFAULT_OPTION);
}
public static int alert(final String title, final String message, int optionType, int messageType) {
JOptionPane.showConfirmDialog(null, message, title, optionType, messageType);
}
} }