use of org.eclipse.scout.rt.shared.ui.UserAgents in project scout.rt by eclipse.
the class UiSession method createUserAgent.
protected UserAgent createUserAgent(JsonStartupRequest jsonStartupReq) {
HttpClientInfo httpClientInfo = HttpClientInfo.get(currentHttpRequest());
UserAgents userAgentBuilder = UserAgents.create().withUiLayer(UiLayer.HTML).withUiDeviceType(UiDeviceType.DESKTOP).withUiEngineType(httpClientInfo.getEngineType()).withUiSystem(httpClientInfo.getSystem()).withDeviceId(httpClientInfo.getUserAgent());
JSONObject userAgent = jsonStartupReq.getUserAgent();
if (userAgent != null) {
// TODO [7.0] cgu: it would be great if UserAgent could be changed dynamically, to switch from mobile to tablet mode on the fly, should be done as event in JsonClientSession
String uiDeviceTypeStr = userAgent.optString("deviceType", null);
if (uiDeviceTypeStr != null) {
userAgentBuilder.withUiDeviceType(UiDeviceType.createByIdentifier(uiDeviceTypeStr));
}
String uiLayerStr = userAgent.optString("uiLayer", null);
if (uiLayerStr != null) {
userAgentBuilder.withUiLayer(UiLayer.createByIdentifier(uiLayerStr));
}
boolean touch = userAgent.optBoolean("touch", false);
userAgentBuilder.withTouch(touch);
boolean standalone = userAgent.optBoolean("standalone", false);
userAgentBuilder.withStandalone(standalone);
}
return userAgentBuilder.build();
}
Aggregations