ns-usbloader/src/main/java/nsusbloader/AppPreferences.java
2019-02-18 05:40:19 +03:00

32 lines
1.3 KiB
Java

package nsusbloader;
import java.util.prefs.Preferences;
public class AppPreferences {
private static final AppPreferences INSTANCE = new AppPreferences();
public static AppPreferences getInstance() { return INSTANCE; }
private Preferences preferences;
private AppPreferences(){ preferences = Preferences.userRoot().node("NS-USBloader"); }
public String getTheme(){
String theme = preferences.get("THEME", "/res/app_dark.css"); // Don't let user to change settings manually
if (!theme.matches("(^/res/app_dark.css$)|(^/res/app_light.css$)"))
theme = "/res/app_dark.css";
return theme;
}
public String getProtocol(){
String protocol = preferences.get("PROTOCOL", "TinFoil"); // Don't let user to change settings manually
if (!protocol.matches("(^TinFoil$)|(^GoldLeaf$)"))
protocol = "TinFoil";
return protocol;
}
public void setTheme(String theme){ preferences.put("THEME", theme); }
public void setProtocol(String protocol){ preferences.put("PROTOCOL", protocol); }
public String getRecent(){ return preferences.get("RECENT", System.getProperty("user.home")); }
public void setRecent(String path){ preferences.put("RECENT", path); }
}