IDEMPIERE-3461 For Mobile Compatibility of zk / thanks to Eduardo Gil

This commit is contained in:
Carlos Ruiz 2017-09-18 17:11:30 +02:00
parent fa258f891a
commit db66155f8d
5 changed files with 46 additions and 21 deletions

View File

@ -448,7 +448,7 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
String ua = Servlets.getUserAgent((ServletRequest) Executions.getCurrent().getNativeRequest());
clientInfo.userAgent = ua;
ua = ua.toLowerCase();
clientInfo.tablet = ua.indexOf("ipad") >= 0 || ua.indexOf("iphone") >= 0 || ua.indexOf("android") >= 0;
clientInfo.tablet = Executions.getCurrent().getBrowser("mobile") !=null;
if (getDesktop() != null && getDesktop().getSession() != null) {
getDesktop().getSession().setAttribute(CLIENT_INFO, clientInfo);
}
@ -456,6 +456,7 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
Env.setContext(Env.getCtx(), "#clientInfo_desktopWidth", clientInfo.desktopWidth);
Env.setContext(Env.getCtx(), "#clientInfo_desktopHeight", clientInfo.desktopHeight);
Env.setContext(Env.getCtx(), "#clientInfo_orientation", clientInfo.orientation);
Env.setContext(Env.getCtx(), "#clientInfo_mobile", clientInfo.tablet);
}
}

View File

@ -17,24 +17,21 @@ package org.adempiere.webui;
import java.util.Locale;
import java.util.Properties;
import javax.servlet.ServletRequest;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.part.AbstractUIPart;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.LoginWindow;
import org.zkoss.web.servlet.Servlets;
import org.zkoss.zhtml.Text;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.metainfo.PageDefinition;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Div;
import org.zkoss.zul.East;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.West;
import org.zkoss.zul.Div;
import org.zkoss.zul.Window;
/**
@ -82,15 +79,13 @@ public class WLogin extends AbstractUIPart
browserWarningWindow.doOverlapped();
}
String ua = Servlets.getUserAgent((ServletRequest) Executions.getCurrent().getNativeRequest());
ua = ua.toLowerCase();
boolean mobile = ua.indexOf("ipad") >= 0 || ua.indexOf("iphone") >= 0 || ua.indexOf("android") >= 0;
boolean mobile = Executions.getCurrent().getBrowser("mobile") !=null;
West west = layout.getWest();
if (west.getFirstChild() != null && west.getFirstChild().getFirstChild() != null) {
west.setCollapsible(true);
west.setSplittable(true);
if (mobile) {
west.setCollapsible(true);
west.setOpen(false);
}
} else {

View File

@ -224,6 +224,13 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
boolean menuCollapsed= pref.isPropertyBool(UserPreference.P_MENU_COLLAPSED);
w.setOpen(!menuCollapsed);
boolean mobile = Executions.getCurrent().getBrowser("mobile") !=null;
w.setCollapsible(true);
if (mobile) {
w.setOpen(false);
}
East e = layout.getEast();
e.addEventListener(Events.ON_OPEN, new EventListener<Event>() {
@Override
@ -293,6 +300,11 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
helpController.render(e, this);
if (mobile) {
e.setVisible(false);
e.setOpen(false);
}
Center windowArea = layout.getCenter();
windowContainer.createPart(windowArea);

View File

@ -231,3 +231,25 @@
height: 16px;
padding: 3px 3px;
}
@media screen and (min-width: 720px) {
.desktop-header > .z-hlayout-inner {
width: 50%;
height: 100%;
}
}
@media screen and (max-width: 720px) {
.desktop-header {
width: 100%;
height: 100%;
}
.desktop-user-panel {
float: none;
}
.desktop-header > .z-hlayout-inner {
width: 100%;
height: 40%;
display: block;
}
}

View File

@ -1,19 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<zk>
<div sclass="desktop-header" use="org.adempiere.webui.panel.HeaderPanel" id="header">
<borderlayout sclass="desktop-header">
<west width="50%" sclass="desktop-header-left">
<hbox height="100%" pack="center" align="left">
<hlayout vflex="1" sclass="desktop-header">
<hbox height="100%" pack="center" align="left" sclass="desktop-header-left">
<image id="logo"/>
<div id="menuLookup"/>
<button id="menuButton" sclass="btn-small"/>
</hbox>
</west>
<center sclass="desktop-header-right">
<vbox apply="org.adempiere.webui.panel.UserPanel" align="right"
hflex="1" vflex="1"
</hbox>
<vbox apply="org.adempiere.webui.panel.UserPanel" align="right"
sclass="desktop-user-panel">
<vbox align="right">
<vbox align="right">
<label use="org.adempiere.webui.component.Label" id="loginUserAndRole"
style="cursor: pointer;"
sclass="desktop-header-font desktop-header-username"/>
@ -32,7 +28,6 @@
</hbox>
</vbox>
</vbox>
</center>
</borderlayout>
</hlayout>
</div>
</zk>