Skip to content

Commit

Permalink
fix(gui): allow partial settings sync to not save command line options
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Oct 29, 2018
1 parent 1d7bb43 commit 557667b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package jadx.gui.settings;

public interface ISettingsUpdater {
void update(JadxSettings settings);
}
16 changes: 11 additions & 5 deletions jadx-gui/src/main/java/jadx/gui/settings/JadxSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public void sync() {
JadxSettingsAdapter.store(this);
}

public void partialSync(ISettingsUpdater updater) {
JadxSettings settings = JadxSettingsAdapter.load();
updater.update(settings);
JadxSettingsAdapter.store(settings);
}

public void fixOnLoad() {
if (threadsCount <= 0) {
threadsCount = JadxArgs.DEFAULT_THREADS_COUNT;
Expand All @@ -75,7 +81,7 @@ public String getLastOpenFilePath() {

public void setLastOpenFilePath(String lastOpenFilePath) {
this.lastOpenFilePath = lastOpenFilePath;
sync();
partialSync(settings -> settings.lastOpenFilePath = JadxSettings.this.lastOpenFilePath);
}

public String getLastSaveFilePath() {
Expand All @@ -84,7 +90,7 @@ public String getLastSaveFilePath() {

public void setLastSaveFilePath(String lastSaveFilePath) {
this.lastSaveFilePath = lastSaveFilePath;
sync();
partialSync(settings -> settings.lastSaveFilePath = JadxSettings.this.lastSaveFilePath);
}

public boolean isFlattenPackage() {
Expand All @@ -93,7 +99,7 @@ public boolean isFlattenPackage() {

public void setFlattenPackage(boolean flattenPackage) {
this.flattenPackage = flattenPackage;
sync();
partialSync(settings -> settings.flattenPackage = JadxSettings.this.flattenPackage);
}

public boolean isCheckForUpdates() {
Expand All @@ -116,7 +122,7 @@ public void addRecentFile(String filePath) {
if (count > RECENT_FILES_COUNT) {
recentFiles.subList(RECENT_FILES_COUNT, count).clear();
}
sync();
partialSync(settings -> settings.recentFiles = recentFiles);
}

public void saveWindowPos(Window window) {
Expand All @@ -125,7 +131,7 @@ public void saveWindowPos(Window window) {
window.getWidth(), window.getHeight()
);
windowPos.put(pos.getWindowId(), pos);
sync();
partialSync(settings -> settings.windowPos = windowPos);
}

public boolean loadWindowPos(Window window) {
Expand Down

0 comments on commit 557667b

Please sign in to comment.