Added option to /configui to force the mobile console to be used

This commit is contained in:
str4d
2013-01-21 05:59:53 +00:00
parent 34aa3ac207
commit d5a870226c
5 changed files with 35 additions and 0 deletions

View File

@ -23,6 +23,7 @@ public class CSSHelper extends HelperBase {
public static final int MIN_REFRESH = 3; public static final int MIN_REFRESH = 3;
public static final String PROP_DISABLE_REFRESH = "routerconsole.summaryDisableRefresh"; public static final String PROP_DISABLE_REFRESH = "routerconsole.summaryDisableRefresh";
private static final String PROP_XFRAME = "routerconsole.disableXFrame"; private static final String PROP_XFRAME = "routerconsole.disableXFrame";
public static final String PROP_FORCE_MOBILE_CONSOLE = "routerconsole.forceMobileConsole";
private static final String _consoleNonce = Long.toString(RandomSource.getInstance().nextLong()); private static final String _consoleNonce = Long.toString(RandomSource.getInstance().nextLong());
@ -137,6 +138,9 @@ public class CSSHelper extends HelperBase {
* @since 0.8.5 * @since 0.8.5
*/ */
public boolean allowIFrame(String ua) { public boolean allowIFrame(String ua) {
boolean forceMobileConsole = _context.getBooleanProperty(PROP_FORCE_MOBILE_CONSOLE);
if (forceMobileConsole)
return false;
if (ua == null) if (ua == null)
return true; return true;
Boolean brv = _UACache.get(ua); Boolean brv = _UACache.get(ua);

View File

@ -9,6 +9,7 @@ import java.util.Map;
public class ConfigUIHandler extends FormHandler { public class ConfigUIHandler extends FormHandler {
private boolean _shouldSave; private boolean _shouldSave;
private boolean _universalTheming; private boolean _universalTheming;
private boolean _forceMobileConsole;
private String _config; private String _config;
@Override @Override
@ -26,6 +27,8 @@ public class ConfigUIHandler extends FormHandler {
public void setUniversalTheming(String baa) { _universalTheming = true; } public void setUniversalTheming(String baa) { _universalTheming = true; }
public void setForceMobileConsole(String baa) { _forceMobileConsole = true; }
public void setTheme(String val) { public void setTheme(String val) {
_config = val; _config = val;
} }
@ -37,6 +40,7 @@ public class ConfigUIHandler extends FormHandler {
Map<String, String> changes = new HashMap(); Map<String, String> changes = new HashMap();
List<String> removes = new ArrayList(); List<String> removes = new ArrayList();
String oldTheme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME); String oldTheme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
boolean oldForceMobileConsole = _context.getBooleanProperty(CSSHelper.PROP_FORCE_MOBILE_CONSOLE);
if (_config.equals("default")) // obsolete if (_config.equals("default")) // obsolete
removes.add(CSSHelper.PROP_THEME_NAME); removes.add(CSSHelper.PROP_THEME_NAME);
else else
@ -45,6 +49,10 @@ public class ConfigUIHandler extends FormHandler {
changes.put(CSSHelper.PROP_UNIVERSAL_THEMING, "true"); changes.put(CSSHelper.PROP_UNIVERSAL_THEMING, "true");
else else
removes.add(CSSHelper.PROP_UNIVERSAL_THEMING); removes.add(CSSHelper.PROP_UNIVERSAL_THEMING);
if (_forceMobileConsole)
changes.put(CSSHelper.PROP_FORCE_MOBILE_CONSOLE, "true");
else
removes.add(CSSHelper.PROP_FORCE_MOBILE_CONSOLE);
boolean ok = _context.router().saveConfig(changes, removes); boolean ok = _context.router().saveConfig(changes, removes);
if (ok) { if (ok) {
if (!oldTheme.equals(_config)) if (!oldTheme.equals(_config))
@ -52,6 +60,11 @@ public class ConfigUIHandler extends FormHandler {
" <a href=\"configui\">" + " <a href=\"configui\">" +
_("Refresh the page to view.") + _("Refresh the page to view.") +
"</a>"); "</a>");
if (oldForceMobileConsole != _forceMobileConsole)
addFormNotice(_("Mobile console option saved.") +
" <a href=\"configui\">" +
_("Refresh the page to view.") +
"</a>");
} else { } else {
addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs.")); addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs."));
} }

View File

@ -28,6 +28,18 @@ public class ConfigUIHelper extends HelperBase {
return buf.toString(); return buf.toString();
} }
public String getForceMobileConsole() {
StringBuilder buf = new StringBuilder(256);
boolean forceMobileConsole = _context.getBooleanProperty(CSSHelper.PROP_FORCE_MOBILE_CONSOLE);
buf.append("<input type=\"checkbox\" name=\"forceMobileConsole\" ");
if (forceMobileConsole)
buf.append("checked=\"checked\" ");
buf.append("value=\"1\">")
.append(_("Force the mobile console to be used"))
.append("<br>\n");
return buf.toString();
}
static final String PROP_THEME_PFX = "routerconsole.theme."; static final String PROP_THEME_PFX = "routerconsole.theme.";
/** @return standard and user-installed themes, sorted (untranslated) */ /** @return standard and user-installed themes, sorted (untranslated) */

View File

@ -44,6 +44,7 @@ input.default {
<hr> <hr>
<%=uihelper._("If you're not using IE, it's likely that your browser is pretending to be IE; please configure your browser (or proxy) to use a different User Agent string if you'd like to access the console themes.")%> <%=uihelper._("If you're not using IE, it's likely that your browser is pretending to be IE; please configure your browser (or proxy) to use a different User Agent string if you'd like to access the console themes.")%>
<% } %> <% } %>
<jsp:getProperty name="uihelper" property="forceMobileConsole" />
<h3><%=uihelper._("Router Console Language")%></h3> <h3><%=uihelper._("Router Console Language")%></h3>
<jsp:getProperty name="uihelper" property="langSettings" /> <jsp:getProperty name="uihelper" property="langSettings" />
<p><%=uihelper._("Please contribute to the router console translation project! Contact the developers in #i2p-dev on IRC to help.")%> <p><%=uihelper._("Please contribute to the router console translation project! Contact the developers in #i2p-dev on IRC to help.")%>

View File

@ -1,3 +1,8 @@
2013-01-21 str4d
* Console:
- Added option to /configui to force the mobile console to be used
(for cases where the UserAgent matching fails)
2013-01-19 str4d 2013-01-19 str4d
* Console: * Console:
- Added proper support for mobile browsers with a CSS override file - Added proper support for mobile browsers with a CSS override file