Commit 10198bc8 authored by Skylot's avatar Skylot

gui: update RSyntaxTextArea version, refactor new version checks

parent a6b4043e
......@@ -5,7 +5,7 @@ mainClassName = "jadx.gui.JadxGUI"
dependencies {
compile(project(":jadx-core"))
compile(project(":jadx-cli"))
compile 'com.fifesoft:rsyntaxtextarea:2.5.0'
compile 'com.fifesoft:rsyntaxtextarea:2.5.4'
compile 'com.google.code.gson:gson:2.3.1'
}
......
......@@ -5,6 +5,7 @@ import jadx.gui.treemodel.JClass;
import jadx.gui.treemodel.JNode;
import jadx.gui.treemodel.JRoot;
import jadx.gui.update.JadxUpdate;
import jadx.gui.update.JadxUpdate.IUpdateCallback;
import jadx.gui.update.data.Release;
import jadx.gui.utils.JadxPreferences;
import jadx.gui.utils.Link;
......@@ -94,7 +95,12 @@ public class MainWindow extends JFrame {
initUI();
initMenuAndToolbar();
JadxUpdate.check(new JadxUpdate.IUpdateCallback() {
checkForUpdate();
}
private void checkForUpdate() {
// TODO: add option for disable update checks
JadxUpdate.check(new IUpdateCallback() {
@Override
public void onUpdate(final Release r) {
SwingUtilities.invokeLater(new Runnable() {
......
......@@ -19,6 +19,7 @@ import java.awt.event.KeyEvent;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rtextarea.SearchContext;
import org.fife.ui.rtextarea.SearchEngine;
import org.fife.ui.rtextarea.SearchResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -153,18 +154,13 @@ class SearchBar extends JToolBar {
boolean regex = regexCB.isSelected();
boolean wholeWord = wholeWordCB.isSelected();
if (markAllCB.isSelected()) {
rTextArea.markAll(searchText, matchCase, wholeWord, regex);
} else {
rTextArea.clearMarkAllHighlights();
}
SearchContext context = new SearchContext();
context.setSearchFor(searchText);
context.setMatchCase(matchCase);
context.setRegularExpression(regex);
context.setSearchForward(forward);
context.setWholeWord(wholeWord);
context.setMarkAll(markAllCB.isSelected());
// TODO hack: move cursor before previous search for not jump to next occurrence
if (direction == 0 && !COLOR_BG_ERROR.equals(searchField.getBackground())) {
......@@ -179,8 +175,8 @@ class SearchBar extends JToolBar {
}
}
boolean found = SearchEngine.find(rTextArea, context);
if (!found) {
SearchResult result = SearchEngine.find(rTextArea, context);
if (!result.wasFound()) {
int pos = SearchEngine.getNextMatchPos(searchText, rTextArea.getText(), forward, matchCase, wholeWord);
if (pos != -1) {
rTextArea.setCaretPosition(forward ? 0 : rTextArea.getDocument().getLength() - 1);
......
......@@ -81,7 +81,7 @@ public class JadxUpdate {
for (Iterator<Release> it = list.iterator(); it.hasNext(); ) {
Release release = it.next();
if (release.getName().equalsIgnoreCase(version)
|| release.isPrerelease()) {
|| release.isPreRelease()) {
it.remove();
}
}
......@@ -90,10 +90,10 @@ public class JadxUpdate {
}
Collections.sort(list, RELEASE_COMPARATOR);
Release latest = list.get(list.size() - 1);
if (VersionComparator.checkAndCompare(version, latest.getName()) == 0) {
if (VersionComparator.checkAndCompare(version, latest.getName()) >= 0) {
return null;
}
LOG.debug("Found new version: {}", latest);
LOG.info("Found new jadx version: {}", latest);
return latest;
}
......
package jadx.gui.update.data;
import com.google.gson.annotations.SerializedName;
public class Asset {
private int id;
private String url;
private String name;
private String label;
private long size;
private int download_count;
@SerializedName("download_count")
private int downloadCount;
@SerializedName("browser_download_url")
private String downloadUrl;
@SerializedName("created_at")
private String createdAt;
public int getId() {
return id;
......@@ -16,14 +24,6 @@ public class Asset {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getName() {
return name;
}
......@@ -32,14 +32,6 @@ public class Asset {
this.name = name;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public long getSize() {
return size;
}
......@@ -48,11 +40,36 @@ public class Asset {
this.size = size;
}
public int getDownload_count() {
return download_count;
public int getDownloadCount() {
return downloadCount;
}
public void setDownloadCount(int downloadCount) {
this.downloadCount = downloadCount;
}
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(String downloadUrl) {
this.downloadUrl = downloadUrl;
}
public String getCreatedAt() {
return createdAt;
}
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
public void setDownload_count(int download_count) {
this.download_count = download_count;
@Override
public String toString() {
return name
+ ", size: " + String.format("%.2fMB", size / 1024. /1024.)
+ ", downloads count: " + downloadCount
+ ", url: " + downloadUrl
+ ", date: " + createdAt;
}
}
......@@ -2,10 +2,15 @@ package jadx.gui.update.data;
import java.util.List;
import com.google.gson.annotations.SerializedName;
public class Release {
private int id;
private String name;
private boolean prerelease;
@SerializedName("prerelease")
private boolean preRelease;
private List<Asset> assets;
public String getName() {
......@@ -24,12 +29,12 @@ public class Release {
this.id = id;
}
public boolean isPrerelease() {
return prerelease;
public boolean isPreRelease() {
return preRelease;
}
public void setPrerelease(boolean prerelease) {
this.prerelease = prerelease;
public void setPreRelease(boolean preRelease) {
this.preRelease = preRelease;
}
public List<Asset> getAssets() {
......@@ -45,11 +50,8 @@ public class Release {
StringBuilder sb = new StringBuilder();
sb.append(name);
for (Asset asset : getAssets()) {
sb.append('\n');
sb.append(" ").append(asset.getName())
.append(", asset id: ").append(asset.getId())
.append(", size: ").append(asset.getSize())
.append(", dc: ").append(asset.getDownload_count());
sb.append("\n ");
sb.append(asset);
}
return sb.toString();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment