Class DeviceTemplateVariables


  • public class DeviceTemplateVariables
    extends Object
    Class that gives the template engine access to device specific information and configuration parameters. An instance of DeviceTemplateVariables 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 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 service
        displayService - the display service
        platformService - the platform service
    • Method Detail

      • 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
      • 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 instead
        Gets 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 instead
        Gets 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