fix code style issues
This commit is contained in:
@@ -3,6 +3,7 @@ package jadx.gui.update;
|
||||
import jadx.api.JadxDecompiler;
|
||||
import jadx.gui.update.data.Release;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Type;
|
||||
@@ -29,7 +30,8 @@ public class JadxUpdate {
|
||||
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
private static final Type RELEASES_LIST_TYPE = new TypeToken<List<Release>>() {}.getType();
|
||||
private static final Type RELEASES_LIST_TYPE = new TypeToken<List<Release>>() {
|
||||
}.getType();
|
||||
|
||||
private static final Comparator<Release> RELEASE_COMPARATOR = new Comparator<Release>() {
|
||||
@Override
|
||||
@@ -38,12 +40,15 @@ public class JadxUpdate {
|
||||
}
|
||||
};
|
||||
|
||||
public static interface IUpdateCallback {
|
||||
public interface IUpdateCallback {
|
||||
void onUpdate(Release r);
|
||||
}
|
||||
|
||||
private JadxUpdate() {
|
||||
}
|
||||
|
||||
public static void check(final IUpdateCallback callback) {
|
||||
Runnable run = new Runnable() {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -62,7 +67,7 @@ public class JadxUpdate {
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private static Release checkForNewRelease() throws Exception {
|
||||
private static Release checkForNewRelease() throws IOException {
|
||||
String version = JadxDecompiler.getVersion();
|
||||
if (version.contains("dev")) {
|
||||
LOG.debug("Ignore check for update: development version");
|
||||
@@ -92,7 +97,7 @@ public class JadxUpdate {
|
||||
return latest;
|
||||
}
|
||||
|
||||
private static <T> T get(String url, Type type) throws Exception {
|
||||
private static <T> T get(String url, Type type) throws IOException {
|
||||
URL obj = new URL(url);
|
||||
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
|
||||
@@ -2,6 +2,9 @@ package jadx.gui.update;
|
||||
|
||||
public class VersionComparator {
|
||||
|
||||
private VersionComparator() {
|
||||
}
|
||||
|
||||
public static int checkAndCompare(String str1, String str2) {
|
||||
try {
|
||||
return compare(clean(str1), clean(str2));
|
||||
|
||||
@@ -4,98 +4,79 @@ import java.util.prefs.Preferences;
|
||||
|
||||
public class JadxPreferences {
|
||||
|
||||
private static final String KEY_LAST_OPEN_FILE_PATH = "lastOpenFilePath";
|
||||
private static final String KEY_LAST_SAVE_FILE_PATH = "lastSaveFilePath";
|
||||
private static final String KEY_FLATTEN_PACKAGE = "flattenPackage";
|
||||
|
||||
private static Preferences prefs = null;
|
||||
|
||||
public static String getLastOpenFilePath() {
|
||||
String result = "";
|
||||
|
||||
try {
|
||||
result = getPreferences().get(KEY_LAST_OPEN_FILE_PATH, "");
|
||||
|
||||
if (result.isEmpty())
|
||||
{
|
||||
if (result.isEmpty()) {
|
||||
result = System.getProperty("user.home");
|
||||
}
|
||||
}
|
||||
catch (Exception anyEx) {
|
||||
} catch (Exception anyEx) {
|
||||
/* do nothing, no preferences */
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void putLastOpenFilePath(String path) {
|
||||
try {
|
||||
Preferences prefs = getPreferences();
|
||||
|
||||
prefs.put(KEY_LAST_OPEN_FILE_PATH, path);
|
||||
prefs.sync();
|
||||
}
|
||||
catch (Exception anyEx) {
|
||||
} catch (Exception anyEx) {
|
||||
/* do nothing, no preferences */
|
||||
}
|
||||
}
|
||||
|
||||
public static String getLastSaveFilePath() {
|
||||
String result = "";
|
||||
|
||||
try {
|
||||
result = getPreferences().get(KEY_LAST_SAVE_FILE_PATH, "");
|
||||
if (result.isEmpty())
|
||||
{
|
||||
if (result.isEmpty()) {
|
||||
result = getLastOpenFilePath();
|
||||
}
|
||||
}
|
||||
catch (Exception anyEx) {
|
||||
} catch (Exception anyEx) {
|
||||
/* do nothing, no preferences */
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void putLastSaveFilePath(String path) {
|
||||
try {
|
||||
Preferences prefs = getPreferences();
|
||||
|
||||
prefs.put(KEY_LAST_SAVE_FILE_PATH, path);
|
||||
prefs.sync();
|
||||
}
|
||||
catch (Exception anyEx) {
|
||||
} catch (Exception anyEx) {
|
||||
/* do nothing, no preferences */
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getFlattenPackage() {
|
||||
boolean result = false;
|
||||
|
||||
try {
|
||||
Preferences prefs = getPreferences();
|
||||
|
||||
result = prefs.getBoolean(KEY_FLATTEN_PACKAGE, false);
|
||||
}
|
||||
catch (Exception anyEx) {
|
||||
} catch (Exception anyEx) {
|
||||
/* do nothing, no preferences */
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void putFlattenPackage(boolean value) {
|
||||
try {
|
||||
Preferences prefs = getPreferences();
|
||||
|
||||
prefs.putBoolean(KEY_FLATTEN_PACKAGE, value);
|
||||
prefs.sync();
|
||||
}
|
||||
catch (Exception anyEx) {
|
||||
} catch (Exception anyEx) {
|
||||
/* do nothing, no preferences */
|
||||
}
|
||||
}
|
||||
|
||||
private static final String KEY_LAST_OPEN_FILE_PATH = "lastOpenFilePath";
|
||||
private static final String KEY_LAST_SAVE_FILE_PATH = "lastSaveFilePath";
|
||||
private static final String KEY_FLATTEN_PACKAGE = "flattenPackage";
|
||||
|
||||
private static Preferences prefs = null;
|
||||
|
||||
private static Preferences getPreferences() {
|
||||
if (prefs == null) {
|
||||
prefs = Preferences.userRoot();
|
||||
|
||||
@@ -12,9 +12,14 @@ import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static java.awt.Desktop.Action;
|
||||
|
||||
public class Link extends JLabel implements MouseListener {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JLabel.class);
|
||||
|
||||
private String url;
|
||||
|
||||
public Link(String text, String url) {
|
||||
@@ -42,10 +47,12 @@ public class Link extends JLabel implements MouseListener {
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent arg0) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent arg0) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
private void browse() {
|
||||
@@ -56,9 +63,9 @@ public class Link extends JLabel implements MouseListener {
|
||||
desktop.browse(new java.net.URI(url));
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOG.debug("Open url error", e);
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
LOG.debug("Open url error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,13 +85,13 @@ public class Link extends JLabel implements MouseListener {
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOG.debug("Open url error", e);
|
||||
}
|
||||
showUrlDialog();
|
||||
}
|
||||
|
||||
private void showUrlDialog() {
|
||||
JTextArea urlArea = new JTextArea("Can't open browser. Please browse to:\n"+url);
|
||||
JTextArea urlArea = new JTextArea("Can't open browser. Please browse to:\n" + url);
|
||||
JOptionPane.showMessageDialog(null, urlArea);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user