diff --git a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java index 2731753cc8..f6e65dc10e 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java +++ b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java @@ -132,6 +132,9 @@ public class SnarkManager implements CompleteListener, ClientApp { public static final String RC_PROP_UNIVERSAL_THEMING = "routerconsole.universal.theme"; public static final String PROP_THEME = "i2psnark.theme"; public static final String DEFAULT_THEME = "ubergine"; + /** From CSSHelper */ + private static final String PROP_DISABLE_OLD = "routerconsole.disableOldThemes"; + private static final boolean DEFAULT_DISABLE_OLD = false; /** @since 0.9.32 */ public static final String PROP_COLLAPSE_PANELS = "i2psnark.collapsePanels"; private static final String PROP_USE_OPENTRACKERS = "i2psnark.useOpentrackers"; @@ -832,7 +835,7 @@ public class SnarkManager implements CompleteListener, ClientApp { * @return String -- the current theme */ public String getTheme() { - String theme = _config.getProperty(PROP_THEME); + String theme; if (getUniversalTheming()) { // Fetch routerconsole theme (or use our default if it doesn't exist) theme = _context.getProperty(RC_PROP_THEME, DEFAULT_THEME); @@ -840,8 +843,10 @@ public class SnarkManager implements CompleteListener, ClientApp { String[] themes = getThemes(); boolean themeExists = false; for (int i = 0; i < themes.length; i++) { - if (themes[i].equals(theme)) + if (themes[i].equals(theme)) { themeExists = true; + break; + } } if (!themeExists) { // Since the default is not "light", explicitly check if universal theme is "classic" @@ -851,6 +856,16 @@ public class SnarkManager implements CompleteListener, ClientApp { theme = DEFAULT_THEME; _config.setProperty(PROP_THEME, DEFAULT_THEME); } + } else { + theme = _config.getProperty(PROP_THEME, DEFAULT_THEME); + } + // remap deprecated themes + if (theme.equals("midnight")) { + if (_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD)) + theme = "dark"; + } else if (theme.equals("classic")) { + if (_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD)) + theme = "light"; } return theme; } @@ -862,21 +877,24 @@ public class SnarkManager implements CompleteListener, ClientApp { public String[] getThemes() { String[] themes; if (_context.isRouterContext()) { - // "docs/themes/snark/" File dir = new File(_context.getBaseDir(), "docs/themes/snark"); FileFilter fileFilter = new FileFilter() { public boolean accept(File file) { return file.isDirectory(); } }; - // Walk the themes dir, collecting the theme names, and append them to the map File[] dirnames = dir.listFiles(fileFilter); if (dirnames != null) { - themes = new String[dirnames.length]; - for(int i = 0; i < dirnames.length; i++) { - themes[i] = dirnames[i].getName(); + List th = new ArrayList(dirnames.length); + boolean skipOld = _context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD); + for (int i = 0; i < dirnames.length; i++) { + String name = dirnames[i].getName(); + if (skipOld && (name.equals("midnight") || name.equals("classic"))) + continue; + th.add(name); } + themes = th.toArray(new String[th.size()]); } else { themes = new String[0]; } } else { - themes = new String[] { "classic", "dark", "light", "midnight", "ubergine", "vanilla" }; + themes = new String[] { "dark", "light", "ubergine", "vanilla" }; } return themes; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java index 47ae4eb5a6..fea4fd94df 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java @@ -77,8 +77,11 @@ public class IndexBean { private static final List _nonces = new ArrayList(MAX_NONCES + 1); private static final UIMessages _messages = new UIMessages(100); - public static final String PROP_THEME_NAME = "routerconsole.theme"; - public static final String DEFAULT_THEME = "light"; + private static final String PROP_THEME_NAME = "routerconsole.theme"; + private static final String DEFAULT_THEME = "light"; + /** From CSSHelper */ + private static final String PROP_DISABLE_OLD = "routerconsole.disableOldThemes"; + private static final boolean DEFAULT_DISABLE_OLD = false; public static final String PROP_CSS_DISABLED = "routerconsole.css.disabled"; public static final String PROP_JS_DISABLED = "routerconsole.javascript.disabled"; private static final String PROP_PW_ENABLE = "routerconsole.auth.enable"; @@ -336,6 +339,14 @@ public class IndexBean { public String getTheme() { String theme = _context.getProperty(PROP_THEME_NAME, DEFAULT_THEME); + // remap deprecated themes + if (theme.equals("midnight")) { + if (_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD)) + theme = "dark"; + } else if (theme.equals("classic")) { + if (_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD)) + theme = "light"; + } return "/themes/console/" + theme + "/"; } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java index 87bdc9b2f7..f1301fa9f4 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java @@ -31,6 +31,9 @@ public class CSSHelper extends HelperBase { public static final String PROP_FORCE_MOBILE_CONSOLE = "routerconsole.forceMobileConsole"; /** @since 0.9.32 */ public static final String PROP_EMBED_APPS = "routerconsole.embedApps"; + /** @since 0.9.36 */ + public static final String PROP_DISABLE_OLD = "routerconsole.disableOldThemes"; + public static final boolean DEFAULT_DISABLE_OLD = false; private static final String _consoleNonce = Long.toString(RandomSource.getInstance().nextLong()); @@ -44,13 +47,22 @@ public class CSSHelper extends HelperBase { public String getTheme(String userAgent) { String url = BASE_THEME_PATH; - if (userAgent != null && (userAgent.contains("MSIE") && !userAgent.contains("Trident/6"))) { + if (userAgent != null && userAgent.contains("MSIE") && !userAgent.contains("Trident/6") && + !_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD)) { url += FORCE + "/"; } else { // 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.getProperty(PROP_THEME_NAME, DEFAULT_THEME); + // remap deprecated themes + if (theme.equals("midnight")) { + if (_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD)) + theme = "dark"; + } else if (theme.equals("classic")) { + if (_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD)) + theme = "light"; + } url += theme + "/"; } return url; diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigUIHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigUIHelper.java index 29cc1c6b4a..fac2989e08 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigUIHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigUIHelper.java @@ -11,12 +11,23 @@ import net.i2p.router.web.HelperBase; import net.i2p.router.web.Messages; import net.i2p.router.web.RouterConsoleRunner; +/** + * Helper for /configui + */ public class ConfigUIHelper extends HelperBase { public String getSettings() { StringBuilder buf = new StringBuilder(512); buf.append("
"); String current = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME); + // remap deprecated themes + if (current.equals("midnight")) { + if (_context.getProperty(CSSHelper.PROP_DISABLE_OLD, CSSHelper.DEFAULT_DISABLE_OLD)) + current = "dark"; + } else if (current.equals("classic")) { + if (_context.getProperty(CSSHelper.PROP_DISABLE_OLD, CSSHelper.DEFAULT_DISABLE_OLD)) + current = "light"; + } Set themes = themeSet(); for (String theme : themes) { buf.append("