Skip to content

Commit

Permalink
Correct AppPreferences class. Fix #139
Browse files Browse the repository at this point in the history
  • Loading branch information
developersu committed Mar 17, 2023
1 parent 94845c1 commit c1651e8
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/main/java/nsusbloader/AppPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public class AppPreferences {
private AppPreferences(){
this.preferences = Preferences.userRoot().node("NS-USBloader");
String localeCode = preferences.get("locale", Locale.getDefault().toString());
this.locale = new Locale(localeCode.substring(0, 2), localeCode.substring(3));
if (localeCode.length() < 5)
this.locale = new Locale("en", "EN");
else
this.locale = new Locale(localeCode.substring(0, 2), localeCode.substring(3));
}

public String getTheme(){
Expand Down Expand Up @@ -147,6 +150,6 @@ public int getGlVersion(){

public boolean getPatchesTabInvisible(){return preferences.getBoolean("patches_tab_visible", true); }
public void setPatchesTabInvisible(boolean value){preferences.putBoolean("patches_tab_visible", value);}
public String getPatchOffset(String type, int moduleNumber, int offsetId){ return preferences.get(String.format("%s_%02x_%02x", type, moduleNumber, offsetId), ""); }
public void setPatchOffset(String fullTypeSpecifier, String offset){ preferences.put(fullTypeSpecifier, offset); }
public String getPatchPattern(String type, int moduleNumber, int offsetId){ return preferences.get(String.format("%s_%02x_%02x", type, moduleNumber, offsetId), ""); }
public void setPatchPattern(String fullTypeSpecifier, String offset){ preferences.put(fullTypeSpecifier, offset); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private void setOffsets(File fileWithOffsets){
continue;
if (! lineValues[1].matches("^(([0-9A-Fa-f]{2})|\\.)+?$"))
continue;
preferences.setPatchOffset(lineValues[0], lineValues[1]);
preferences.setPatchPattern(lineValues[0], lineValues[1]);

System.out.println(pointer[0]+"_"+pointer[1]+"_"+pointer[2]+" = "+lineValues[1]);
count++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private boolean runInstaller(String pathToFile) {
return true;
}
catch (Exception e){
runInstallerStatusLabel.setText("Error: "+e.toString());
runInstallerStatusLabel.setText("Error: "+e);
e.printStackTrace();
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.List;

class HeuristicEs1 extends AHeuristic {
private static final String PATTERN = AppPreferences.getInstance().getPatchOffset("ES", 1, 0);
private static final String PATTERN = AppPreferences.getInstance().getPatchPattern("ES", 1, 0);

private final List<Integer> findings;
private final byte[] where;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.List;

class HeuristicEs2 extends AHeuristic {
private static final String PATTERN = AppPreferences.getInstance().getPatchOffset("ES", 2, 0);
private static final String PATTERN = AppPreferences.getInstance().getPatchPattern("ES", 2, 0);

private List<Integer> findings;
private final byte[] where;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import java.util.List;

class HeuristicEs3 extends AHeuristic {
private static final String PATTERN0 = AppPreferences.getInstance().getPatchOffset("ES", 3, 0);
private static final String PATTERN1 = AppPreferences.getInstance().getPatchOffset("ES", 3, 1);
private static final String PATTERN0 = AppPreferences.getInstance().getPatchPattern("ES", 3, 0);
private static final String PATTERN1 = AppPreferences.getInstance().getPatchPattern("ES", 3, 1);

private final List<Integer> findings;
private final byte[] where;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.List;

class HeuristicFs1 extends AHeuristic {
private static final String PATTERN = AppPreferences.getInstance().getPatchOffset("FS", 1, 0); // TBZ
private static final String PATTERN = AppPreferences.getInstance().getPatchPattern("FS", 1, 0); // TBZ

private final byte[] where;
private final List<Integer> findings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.List;

class HeuristicFs2 extends AHeuristic {
private static final String PATTERN = AppPreferences.getInstance().getPatchOffset("FS", 2, 0);
private static final String PATTERN = AppPreferences.getInstance().getPatchPattern("FS", 2, 0);

private final byte[] where;
private final List<Integer> findings;
Expand Down

0 comments on commit c1651e8

Please sign in to comment.