Package io.jmix.ui.deviceinfo
Class DeviceInfo
java.lang.Object
io.jmix.ui.deviceinfo.DeviceInfo
Class that represents information about the web browser the user is using.
Provides information such as browser name and version, screen resolution and IP address.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the IP-address of the web browser.double
Get the browser user-agent string.int
Gets the major version of the browser the user is using.int
Gets the minor version of the browser the user is using.Get the default locate of the browser.double
double
int
Gets the height of the screen in pixels.int
Gets the width of the screen in pixels.Get the default timezone of the browser.boolean
Tests if the browser is run on Android.boolean
isChrome()
Tests whether the user is using Chrome.boolean
Tests whether the user is using Chrome Frame.boolean
Tests whether the user's browser is Chrome Frame capable.boolean
isEdge()
Tests whether the user is using Edge.boolean
Tests whether the user is using Firefox.boolean
isIE()
Tests whether the user is using Internet Explorer.boolean
isIOS()
Tests if the browser is run in iOS.boolean
isIPad()
Tests if the browser is run on IPad.boolean
isIPhone()
Tests if the browser is run on IPhone.boolean
isLinux()
Tests whether the user is using Linux.boolean
isMacOSX()
Tests whether the user is using Mac OS X.boolean
isOpera()
Tests whether the user is using Opera.boolean
isSafari()
Tests whether the user is using Safari.boolean
Is the connection made using HTTPS?boolean
boolean
Tests whether the user is using Windows.boolean
Tests whether the user is using Windows Phone.void
setAddress
(String address) void
setBrowserApplication
(String browserApplication) void
setBrowserMajorVersion
(int browserMajorVersion) void
setBrowserMinorVersion
(int browserMinorVersion) void
setChrome
(boolean chrome) void
setChromeFrame
(boolean chromeFrame) void
setChromeFrameCapable
(boolean chromeFrameCapable) void
setEdge
(boolean edge) void
setFirefox
(boolean firefox) void
setIE
(boolean IE) void
setIPad
(boolean IPad) void
setIPhone
(boolean IPhone) void
void
setOpera
(boolean opera) void
setOperatingSystem
(DeviceInfo.OperatingSystem operatingSystem) void
setSafari
(boolean safari) void
setScreenHeight
(int screenHeight) void
setScreenWidth
(int screenWidth) void
setSecureConnection
(boolean secureConnection) void
setTimeZone
(TimeZone timeZone) void
setTouchDevice
(boolean touchDevice) void
setWindowsPhone
(boolean windowsPhone)
-
Constructor Details
-
DeviceInfo
public DeviceInfo()
-
-
Method Details
-
getScreenHeight
public int getScreenHeight()Gets the height of the screen in pixels. This is the full screen resolution and not the height available for the application.- Returns:
- the height of the screen in pixels.
-
setScreenHeight
public void setScreenHeight(int screenHeight) -
getScreenWidth
public int getScreenWidth()Gets the width of the screen in pixels. This is the full screen resolution and not the width available for the application.- Returns:
- the width of the screen in pixels.
-
setScreenWidth
public void setScreenWidth(int screenWidth) -
getBrowserApplication
Get the browser user-agent string.- Returns:
- The raw browser userAgent string
-
setBrowserApplication
-
getLocale
Get the default locate of the browser. -
setLocale
-
getTimeZone
Get the default timezone of the browser. -
setTimeZone
-
isSecureConnection
public boolean isSecureConnection()Is the connection made using HTTPS? -
setSecureConnection
public void setSecureConnection(boolean secureConnection) -
isFirefox
public boolean isFirefox()Tests whether the user is using Firefox.- Returns:
- true if the user is using Firefox, false if the user is not using Firefox or if no information on the browser is present
-
setFirefox
public void setFirefox(boolean firefox) -
isIE
public boolean isIE()Tests whether the user is using Internet Explorer.- Returns:
- true if the user is using Internet Explorer, false if the user is not using Internet Explorer or if no information on the browser is present
-
setIE
public void setIE(boolean IE) -
isEdge
public boolean isEdge()Tests whether the user is using Edge.- Returns:
- true if the user is using Edge, false if the user is not using Edge or if no information on the browser is present
-
setEdge
public void setEdge(boolean edge) -
isSafari
public boolean isSafari()Tests whether the user is using Safari.- Returns:
- true if the user is using Safari, false if the user is not using Safari or if no information on the browser is present
-
setSafari
public void setSafari(boolean safari) -
isOpera
public boolean isOpera()Tests whether the user is using Opera.- Returns:
- true if the user is using Opera, false if the user is not using Opera or if no information on the browser is present
-
setOpera
public void setOpera(boolean opera) -
isChrome
public boolean isChrome()Tests whether the user is using Chrome.- Returns:
- true if the user is using Chrome, false if the user is not using Chrome or if no information on the browser is present
-
setChrome
public void setChrome(boolean chrome) -
isChromeFrame
public boolean isChromeFrame()Tests whether the user is using Chrome Frame.- Returns:
- true if the user is using Chrome Frame, false if the user is not using Chrome or if no information on the browser is present
-
setChromeFrame
public void setChromeFrame(boolean chromeFrame) -
isChromeFrameCapable
public boolean isChromeFrameCapable()Tests whether the user's browser is Chrome Frame capable.- Returns:
- true if the user can use Chrome Frame, false if the user can not or if no information on the browser is present
-
setChromeFrameCapable
public void setChromeFrameCapable(boolean chromeFrameCapable) -
getBrowserMajorVersion
public int getBrowserMajorVersion()Gets the major version of the browser the user is using.Note that Internet Explorer in IE7 compatibility mode might return 8 in some cases even though it should return 7.
- Returns:
- The major version of the browser or -1 if not known.
-
setBrowserMajorVersion
public void setBrowserMajorVersion(int browserMajorVersion) -
getBrowserMinorVersion
public int getBrowserMinorVersion()Gets the minor version of the browser the user is using.- Returns:
- The minor version of the browser or -1 if not known.
- See Also:
-
setBrowserMinorVersion
public void setBrowserMinorVersion(int browserMinorVersion) -
isLinux
public boolean isLinux()Tests whether the user is using Linux.- Returns:
- true if the user is using Linux, false if the user is not using Linux or if no information on the browser is present
-
isMacOSX
public boolean isMacOSX()Tests whether the user is using Mac OS X.- Returns:
- true if the user is using Mac OS X, false if the user is not using Mac OS X or if no information on the browser is present
-
isWindows
public boolean isWindows()Tests whether the user is using Windows.- Returns:
- true if the user is using Windows, false if the user is not using Windows or if no information on the browser is present
-
isWindowsPhone
public boolean isWindowsPhone()Tests whether the user is using Windows Phone.- Returns:
- true if the user is using Windows Phone, false if the user is not using Windows Phone or if no information on the browser is present
-
setWindowsPhone
public void setWindowsPhone(boolean windowsPhone) -
isAndroid
public boolean isAndroid()Tests if the browser is run on Android.- Returns:
- true if run on Android false if the user is not using Android or if no information on the browser is present
-
isIOS
public boolean isIOS()Tests if the browser is run in iOS.- Returns:
- true if run in iOS false if the user is not using iOS or if no information on the browser is present
-
isIPhone
public boolean isIPhone()Tests if the browser is run on IPhone.- Returns:
- true if run on IPhone false if the user is not using IPhone or if no information on the browser is present
-
setIPhone
public void setIPhone(boolean IPhone) -
isIPad
public boolean isIPad()Tests if the browser is run on IPad.- Returns:
- true if run on IPad false if the user is not using IPad or if no information on the browser is present
-
setIPad
public void setIPad(boolean IPad) -
isTouchDevice
public boolean isTouchDevice()- Returns:
- true if the browser is detected to support touch events
-
setTouchDevice
public void setTouchDevice(boolean touchDevice) -
getAddress
Gets the IP-address of the web browser. -
setAddress
-
getOperatingSystem
- Returns:
- operating system of device, one of
DeviceInfo.OperatingSystem
-
setOperatingSystem
-
getAspectRatio
public double getAspectRatio()- Returns:
- aspect ratio of device view port
-
getMaximumDimension
public double getMaximumDimension()- Returns:
- maximum of
getScreenHeight()
andgetScreenWidth()
-
getMinimumDimension
public double getMinimumDimension()- Returns:
- minimum of
getScreenHeight()
andgetScreenWidth()
-