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
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the IP-address of the web browser.doubleGet the browser user-agent string.intGets the major version of the browser the user is using.intGets the minor version of the browser the user is using.Get the default locate of the browser.doubledoubleintGets the height of the screen in pixels.intGets the width of the screen in pixels.Get the default timezone of the browser.booleanTests if the browser is run on Android.booleanisChrome()Tests whether the user is using Chrome.booleanTests whether the user is using Chrome Frame.booleanTests whether the user's browser is Chrome Frame capable.booleanisEdge()Tests whether the user is using Edge.booleanTests whether the user is using Firefox.booleanisIE()Tests whether the user is using Internet Explorer.booleanisIOS()Tests if the browser is run in iOS.booleanisIPad()Tests if the browser is run on IPad.booleanisIPhone()Tests if the browser is run on IPhone.booleanisLinux()Tests whether the user is using Linux.booleanisMacOSX()Tests whether the user is using Mac OS X.booleanisOpera()Tests whether the user is using Opera.booleanisSafari()Tests whether the user is using Safari.booleanIs the connection made using HTTPS?booleanbooleanTests whether the user is using Windows.booleanTests whether the user is using Windows Phone.voidsetAddress(String address) voidsetBrowserApplication(String browserApplication) voidsetBrowserMajorVersion(int browserMajorVersion) voidsetBrowserMinorVersion(int browserMinorVersion) voidsetChrome(boolean chrome) voidsetChromeFrame(boolean chromeFrame) voidsetChromeFrameCapable(boolean chromeFrameCapable) voidsetEdge(boolean edge) voidsetFirefox(boolean firefox) voidsetIE(boolean IE) voidsetIPad(boolean IPad) voidsetIPhone(boolean IPhone) voidvoidsetOpera(boolean opera) voidsetOperatingSystem(DeviceInfo.OperatingSystem operatingSystem) voidsetSafari(boolean safari) voidsetScreenHeight(int screenHeight) voidsetScreenWidth(int screenWidth) voidsetSecureConnection(boolean secureConnection) voidsetTimeZone(TimeZone timeZone) voidsetTouchDevice(boolean touchDevice) voidsetWindowsPhone(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()
-