Class FontHelper


  • public class FontHelper
    extends java.lang.Object
    Helper class for fonts.
    • Constructor Summary

      Constructors 
      Constructor Description
      FontHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void applyDefaultFont​(android.app.Activity activity, android.content.res.Configuration appConfig)
      Applies the default font from app config.
      static android.graphics.Typeface getFontFromResource​(android.content.Context context, int resource)
      Returns the Typeface from resource.
      static boolean isDeviceFontIgnored​(android.content.Context context)
      Checks if device font is ignored based on shared preferences helper and context.
      static void setFontEnabledState​(android.content.Context context, boolean state)
      Enables the font size to change dynamically.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DYNAMIC_FONT_SIZE_KEY

        public static final java.lang.String DYNAMIC_FONT_SIZE_KEY
        See Also:
        Constant Field Values
    • Constructor Detail

      • FontHelper

        public FontHelper()
    • Method Detail

      • getFontFromResource

        public static android.graphics.Typeface getFontFromResource​(android.content.Context context,
                                                                    int resource)
        Returns the Typeface from resource.
        Parameters:
        context - used for getting resources
        resource - resource id to be extracted
        Returns:
        Typeface loaded from resource
      • applyDefaultFont

        public static void applyDefaultFont​(android.app.Activity activity,
                                            android.content.res.Configuration appConfig)
        Applies the default font from app config.
        Parameters:
        activity - Activity
        appConfig - Configuration
      • isDeviceFontIgnored

        public static boolean isDeviceFontIgnored​(android.content.Context context)
        Checks if device font is ignored based on shared preferences helper and context.
        Parameters:
        context - context of the application
        Returns:
        true if device font is ignored, else false.
      • setFontEnabledState

        public static void setFontEnabledState​(android.content.Context context,
                                               boolean state)
        Enables the font size to change dynamically.
        Parameters:
        context - context of the application
        state - true if font size can change dynamically, else false.