I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit a623d924 authored by str4d's avatar str4d
Browse files

Reverted routerconsole to storing theme itself, also store universal theming boolean

parent 3d69d2bf
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ public class CSSHelper extends HelperBase {
public CSSHelper() {}
public static final String THEME_CONFIG_FILE = "themes.config";
public static final String PROP_UNIVERSAL_THEMING = "routerconsole.theme.universal";
public static final String PROP_THEME_NAME = "routerconsole.theme";
public static final String DEFAULT_THEME = "light";
public static final String BASE_THEME_PATH = "/themes/console/";
......@@ -32,7 +32,7 @@ public class CSSHelper extends HelperBase {
// This is the first thing to use _context on most pages
if (_context == null)
throw new IllegalStateException("No contexts. This is usually because the router is either starting up or shutting down.");
String theme = _context.readConfigFile(THEME_CONFIG_FILE).getProperty(PROP_THEME_NAME, DEFAULT_THEME);
String theme = _context.getProperty(PROP_THEME_NAME, DEFAULT_THEME);
url += theme + "/";
}
return url;
......
package net.i2p.router.web;
import java.util.Iterator;
import java.util.Properties;
/** set the theme */
public class ConfigUIHandler extends FormHandler {
private boolean _shouldSave;
......@@ -27,21 +24,18 @@ public class ConfigUIHandler extends FormHandler {
private void saveChanges() {
if (_config == null)
return;
Properties props = _context.readConfigFile(CSSHelper.THEME_CONFIG_FILE);
String oldTheme = props.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
// Save routerconsole theme first to ensure it is in config file
String oldTheme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
boolean ok;
if (_config.equals("default")) // obsolete
props.put(CSSHelper.PROP_THEME_NAME, null);
ok = _context.router().saveConfig(CSSHelper.PROP_THEME_NAME, null);
else
props.put(CSSHelper.PROP_THEME_NAME, _config);
if (_universalTheming) {
// The routerconsole theme gets set again, but oh well
for (Iterator it = props.keySet().iterator(); it.hasNext();) {
String key = (String) it.next();
props.put(key, _config);
}
ok = _context.router().saveConfig(CSSHelper.PROP_THEME_NAME, _config);
if (ok) {
if (_universalTheming)
ok = _context.router().saveConfig(CSSHelper.PROP_UNIVERSAL_THEMING, "true");
else
ok = _context.router().saveConfig(CSSHelper.PROP_UNIVERSAL_THEMING, null);
}
boolean ok = _context.writeConfigFile(CSSHelper.THEME_CONFIG_FILE, props);
if (ok) {
if (!oldTheme.equals(_config))
addFormNotice(_("Theme change saved.") +
......
......@@ -9,7 +9,7 @@ public class ConfigUIHelper extends HelperBase {
public String getSettings() {
StringBuilder buf = new StringBuilder(512);
String current = _context.readConfigFile(CSSHelper.THEME_CONFIG_FILE).getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
String current = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
Set<String> themes = themeSet();
for (String theme : themes) {
buf.append("<input type=\"radio\" class=\"optbox\" name=\"theme\" ");
......@@ -17,7 +17,11 @@ public class ConfigUIHelper extends HelperBase {
buf.append("checked=\"checked\" ");
buf.append("value=\"").append(theme).append("\">").append(_(theme)).append("<br>\n");
}
buf.append("<input type=\"checkbox\" name=\"universalTheming\" value=\"1\">")
boolean universalTheming = _context.getBooleanProperty(CSSHelper.PROP_UNIVERSAL_THEMING);
buf.append("<input type=\"checkbox\" name=\"universalTheming\" ");
if (universalTheming)
buf.append("checked=\"checked\" ");
buf.append("value=\"1\">")
.append(_("Set theme universally across all apps"))
.append("<br>\n");
return buf.toString();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment