forked from I2P_Developers/i2p.i2p
Reverted i2psnark to storing theme itself, but checking routerconsole for universal theming
This commit is contained in:
@ -53,7 +53,6 @@ public class SnarkManager implements Snark.CompleteListener {
|
|||||||
private final Object _addSnarkLock;
|
private final Object _addSnarkLock;
|
||||||
private /* FIXME final FIXME */ File _configFile;
|
private /* FIXME final FIXME */ File _configFile;
|
||||||
private Properties _config;
|
private Properties _config;
|
||||||
private String _theme;
|
|
||||||
private final I2PAppContext _context;
|
private final I2PAppContext _context;
|
||||||
private final Log _log;
|
private final Log _log;
|
||||||
private final Queue<String> _messages;
|
private final Queue<String> _messages;
|
||||||
@ -86,7 +85,8 @@ public class SnarkManager implements Snark.CompleteListener {
|
|||||||
//public static final String DEFAULT_LINK_PREFIX = "file:///";
|
//public static final String DEFAULT_LINK_PREFIX = "file:///";
|
||||||
public static final String PROP_STARTUP_DELAY = "i2psnark.startupDelay";
|
public static final String PROP_STARTUP_DELAY = "i2psnark.startupDelay";
|
||||||
public static final String PROP_REFRESH_DELAY = "i2psnark.refreshSeconds";
|
public static final String PROP_REFRESH_DELAY = "i2psnark.refreshSeconds";
|
||||||
public static final String THEME_CONFIG_FILE = "themes.config";
|
public static final String RC_PROP_THEME = "routerconsole.theme";
|
||||||
|
public static final String RC_PROP_UNIVERSAL_THEMING = "routerconsole.theme.universal";
|
||||||
public static final String PROP_THEME = "i2psnark.theme";
|
public static final String PROP_THEME = "i2psnark.theme";
|
||||||
public static final String DEFAULT_THEME = "ubergine";
|
public static final String DEFAULT_THEME = "ubergine";
|
||||||
private static final String PROP_USE_OPENTRACKERS = "i2psnark.useOpentrackers";
|
private static final String PROP_USE_OPENTRACKERS = "i2psnark.useOpentrackers";
|
||||||
@ -288,31 +288,33 @@ public class SnarkManager implements Snark.CompleteListener {
|
|||||||
_config.setProperty(PROP_REFRESH_DELAY, Integer.toString(DEFAULT_REFRESH_DELAY_SECS));
|
_config.setProperty(PROP_REFRESH_DELAY, Integer.toString(DEFAULT_REFRESH_DELAY_SECS));
|
||||||
if (!_config.containsKey(PROP_STARTUP_DELAY))
|
if (!_config.containsKey(PROP_STARTUP_DELAY))
|
||||||
_config.setProperty(PROP_STARTUP_DELAY, Integer.toString(DEFAULT_STARTUP_DELAY));
|
_config.setProperty(PROP_STARTUP_DELAY, Integer.toString(DEFAULT_STARTUP_DELAY));
|
||||||
// Fetch theme
|
if (!_config.containsKey(PROP_THEME))
|
||||||
_theme = getTheme();
|
_config.setProperty(PROP_THEME, DEFAULT_THEME);
|
||||||
updateConfig();
|
updateConfig();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get current theme - reads config file on every call.
|
* Get current theme.
|
||||||
* FIXME: only read in _theme on first call for each page load.
|
|
||||||
* @return String -- the current theme
|
* @return String -- the current theme
|
||||||
*/
|
*/
|
||||||
public String getTheme() {
|
public String getTheme() {
|
||||||
Properties themeProps = _context.readConfigFile(THEME_CONFIG_FILE);
|
String theme = _config.getProperty(PROP_THEME);
|
||||||
_theme = themeProps.getProperty(PROP_THEME);
|
boolean universalTheming = _context.getBooleanProperty(RC_PROP_UNIVERSAL_THEMING);
|
||||||
// Ensure that theme config line exists in config file, and theme exists
|
if (universalTheming) {
|
||||||
String[] themes = getThemes();
|
// Fetch routerconsole theme (or use our default if it doesn't exist)
|
||||||
boolean themeExists = false;
|
theme = _context.getProperty(RC_PROP_THEME_NAME, DEFAULT_THEME);
|
||||||
for (int i = 0; i < themes.length; i++) {
|
// Ensure that theme exists
|
||||||
if (themes[i].equals(_theme))
|
String[] themes = getThemes();
|
||||||
themeExists = true;
|
boolean themeExists = false;
|
||||||
|
for (int i = 0; i < themes.length; i++) {
|
||||||
|
if (themes[i].equals(_theme))
|
||||||
|
themeExists = true;
|
||||||
|
}
|
||||||
|
if (!themeExists) {
|
||||||
|
theme = DEFAULT_THEME;
|
||||||
|
_config.setProperty(PROP_THEME, DEFAULT_THEME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (_theme == null || !themeExists) {
|
return theme;
|
||||||
_theme = DEFAULT_THEME;
|
|
||||||
themeProps.put(PROP_THEME, _theme);
|
|
||||||
_context.writeConfigFile(THEME_CONFIG_FILE, themeProps);
|
|
||||||
}
|
|
||||||
return _theme;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -581,8 +583,8 @@ public class SnarkManager implements Snark.CompleteListener {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (theme != null) {
|
if (theme != null) {
|
||||||
if(!theme.equals(_theme)) {
|
if(!theme.equals(_config.getProperty(PROP_THEME))) {
|
||||||
_theme = theme;
|
_config.setProperty(PROP_THEME, theme);
|
||||||
addMessage(_("{0} theme loaded, return to main i2psnark page to view.", theme));
|
addMessage(_("{0} theme loaded, return to main i2psnark page to view.", theme));
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@ -677,9 +679,6 @@ public class SnarkManager implements Snark.CompleteListener {
|
|||||||
synchronized (_configFile) {
|
synchronized (_configFile) {
|
||||||
DataHelper.storeProps(_config, _configFile);
|
DataHelper.storeProps(_config, _configFile);
|
||||||
}
|
}
|
||||||
Properties props = _context.readConfigFile(THEME_CONFIG_FILE);
|
|
||||||
props.put(PROP_THEME, _theme);
|
|
||||||
_context.writeConfigFile(THEME_CONFIG_FILE, props);
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
addMessage(_("Unable to save the config to {0}", _configFile.getAbsolutePath()));
|
addMessage(_("Unable to save the config to {0}", _configFile.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user