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 ofDeviceTemplateVariablesis 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 StringgetDateFormatOrder()Gets date format order - like 'dmy'StringgetDeviceManufacturer()Gets device manufacturer - like 'Apple'StringgetDeviceModel()Gets device model string - like 'iPhone 11'floatgetDisplayDensityPpi()Gets the display density in pixels per inch.floatgetDisplayHeightDp()Gets display height in dp.intgetDisplayHeightPx()Gets display height in px.floatgetDisplayWidthDp()Gets display width in dp.intgetDisplayWidthPx()Gets display width in px.booleangetIsAndroid()Shortcut for checking for operating system being Android.booleangetIsIos()Shortcut for checking for operating system being iOS.booleangetIsLandscape()Shortcut for checking, whether the device is in landscape mode.booleangetIsPortrait()Shortcut for checking, whether the device is in portrait mode.LocalegetLocale()Gets the main locale being set by the user.DisplayService.OrientationgetOrientation()Gets the current orientation.PlatformService.OsTypegetOsType()Gets operating system type.PlatformService.VersiongetOsVersion()Gets the operating system version.intgetTimeMode()Gets time mode as 12 or 24StringgetTimeZoneId()Gets time zone id.floatgetViewportHeightDp()Deprecated.use getDisplayHeightDp insteadintgetViewportHeightPx()Deprecated.use getDisplayHeightPx insteadfloatgetViewportWidthDp()Deprecated.use getDisplayWidthDp instead.intgetViewportWidthPx()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
-
-