Class DeviceTemplateVariables
- java.lang.Object
-
- io.nevernull.mobileui.core.template.DeviceTemplateVariables
-
public class DeviceTemplateVariables extends Object
Class that gives the template engine access to device specific information and configuration parameters. An instance ofDeviceTemplateVariables
is given into each template process. The device's properties are accessible via the 'device' variable within the MVEL template. You can access them e.g. like so: 'device.deviceModel', meaning you can use short property notation instead using the full getter names.
-
-
Constructor Summary
Constructors Constructor Description DeviceTemplateVariables(dagger.Lazy<I18nService> i18nService, dagger.Lazy<DisplayService> displayService, dagger.Lazy<PlatformService> platformService)
Instantiates a new Device template variables.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
getDateFormatOrder()
Gets date format order - like 'dmy'String
getDeviceManufacturer()
Gets device manufacturer - like 'Apple'String
getDeviceModel()
Gets device model string - like 'iPhone 11'float
getDisplayDensityPpi()
Gets the display density in pixels per inch.float
getDisplayHeightDp()
Gets display height in dp.int
getDisplayHeightPx()
Gets display height in px.float
getDisplayWidthDp()
Gets display width in dp.int
getDisplayWidthPx()
Gets display width in px.boolean
getIsAndroid()
Shortcut for checking for operating system being Android.boolean
getIsIos()
Shortcut for checking for operating system being iOS.boolean
getIsLandscape()
Shortcut for checking, whether the device is in landscape mode.boolean
getIsPortrait()
Shortcut for checking, whether the device is in portrait mode.Locale
getLocale()
Gets the main locale being set by the user.DisplayService.Orientation
getOrientation()
Gets the current orientation.PlatformService.OsType
getOsType()
Gets operating system type.PlatformService.Version
getOsVersion()
Gets the operating system version.int
getTimeMode()
Gets time mode as 12 or 24String
getTimeZoneId()
Gets time zone id.float
getViewportHeightDp()
Deprecated.use getDisplayHeightDp insteadint
getViewportHeightPx()
Deprecated.use getDisplayHeightPx insteadfloat
getViewportWidthDp()
Deprecated.use getDisplayWidthDp instead.int
getViewportWidthPx()
Deprecated.use getDisplayWidthPx instead.
-
-
-
Constructor Detail
-
DeviceTemplateVariables
public DeviceTemplateVariables(dagger.Lazy<I18nService> i18nService, dagger.Lazy<DisplayService> displayService, dagger.Lazy<PlatformService> platformService)
Instantiates a new Device template variables. This is internal.- Parameters:
i18nService
- the 18 n servicedisplayService
- the display serviceplatformService
- the platform service
-
-
Method Detail
-
getOsType
public PlatformService.OsType getOsType()
Gets operating system type.- Returns:
- the os type
-
getOsVersion
public PlatformService.Version getOsVersion()
Gets the operating system version.- Returns:
- the os version
-
getIsAndroid
public boolean getIsAndroid()
Shortcut for checking for operating system being Android.- Returns:
- true, if the app is running on an Android device
-
getIsIos
public boolean getIsIos()
Shortcut for checking for operating system being iOS.- Returns:
- true, if the app is running on an iOS device
-
getLocale
public Locale getLocale()
Gets the main locale being set by the user.- Returns:
- the locale
-
getDateFormatOrder
public String getDateFormatOrder()
Gets date format order - like 'dmy'- Returns:
- the date format order
-
getTimeZoneId
public String getTimeZoneId()
Gets time zone id.- Returns:
- the time zone id
-
getTimeMode
public int getTimeMode()
Gets time mode as 12 or 24- Returns:
- the time mode as 12 or 24
-
getOrientation
public DisplayService.Orientation getOrientation()
Gets the current orientation.- Returns:
- the orientation
-
getIsLandscape
public boolean getIsLandscape()
Shortcut for checking, whether the device is in landscape mode.- Returns:
- true when the device is in landscape mode.
-
getIsPortrait
public boolean getIsPortrait()
Shortcut for checking, whether the device is in portrait mode.- Returns:
- true when the device is in portrait mode.
-
getDisplayWidthPx
public int getDisplayWidthPx()
Gets display width in px.- Returns:
- the display width in px
-
getDisplayHeightPx
public int getDisplayHeightPx()
Gets display height in px.- Returns:
- the display height in px
-
getDisplayWidthDp
public float getDisplayWidthDp()
Gets display width in dp.- Returns:
- the display width in dp
-
getDisplayHeightDp
public float getDisplayHeightDp()
Gets display height in dp.- Returns:
- the display height in dp
-
getViewportWidthDp
public float getViewportWidthDp()
Deprecated.use getDisplayWidthDp instead.Gets the display width in dp.- Returns:
- the display width in dp.
-
getViewportHeightDp
public float getViewportHeightDp()
Deprecated.use getDisplayHeightDp insteadGets display height in dp.- Returns:
- the display height dp
-
getViewportWidthPx
public int getViewportWidthPx()
Deprecated.use getDisplayWidthPx instead.Gets display width in px.- Returns:
- the display width in px
-
getViewportHeightPx
public int getViewportHeightPx()
Deprecated.use getDisplayHeightPx insteadGets display height in px.- Returns:
- the display height px
-
getDisplayDensityPpi
public float getDisplayDensityPpi()
Gets the display density in pixels per inch.- Returns:
- the display density in pixels per inch.
-
getDeviceModel
public String getDeviceModel()
Gets device model string - like 'iPhone 11'- Returns:
- the device model
-
getDeviceManufacturer
public String getDeviceManufacturer()
Gets device manufacturer - like 'Apple'- Returns:
- the device manufacturer
-
-