java.lang.Object
com.pranavpandey.android.dynamic.support.theme.DynamicTheme
All Implemented Interfaces:
DynamicListener, DynamicResolver, DynamicProductFlavor

public class DynamicTheme extends Object implements DynamicProductFlavor, DynamicListener, DynamicResolver
Helper class to manage theme for the whole application and its activities.

It must be initialized before using any activity or widget as they are heavily dependent on this class to generate colors dynamically.

  • Field Details

    • ADS_PREF_THEME_KEY

      public static final String ADS_PREF_THEME_KEY
      Key for the theme preference.
      See Also:
    • DELAY_NORMAL

      public static final long DELAY_NORMAL
      Normal delay in milliseconds for updating the views.
      See Also:
    • DELAY_THEME_CHANGE

      public static final long DELAY_THEME_CHANGE
      Theme change delay in milliseconds which will be useful in some situations like changing the app theme, updating the widgets, etc.
      See Also:
    • COLOR_SHIFT_DARK_DEFAULT

      public static final float COLOR_SHIFT_DARK_DEFAULT
      Default shift amount to generate the darker color.
      See Also:
    • COLOR_BACKGROUND_DEFAULT

      @ColorInt public static final int COLOR_BACKGROUND_DEFAULT
      Default primary color used by this theme if no color is supplied.
    • COLOR_PRIMARY_DEFAULT

      @ColorInt public static final int COLOR_PRIMARY_DEFAULT
      Default primary color used by this theme if no color is supplied.
    • COLOR_PRIMARY_DARK_DEFAULT

      @ColorInt public static final int COLOR_PRIMARY_DARK_DEFAULT
      Default dark primary color used by this theme if no color is supplied.
    • COLOR_ACCENT_DEFAULT

      @ColorInt public static final int COLOR_ACCENT_DEFAULT
      Default accent color used by this theme if no color is supplied.
    • COLOR_TEXT_PRIMARY_DEFAULT

      @ColorInt public static final int COLOR_TEXT_PRIMARY_DEFAULT
      Default text primary color used by this theme if no color is supplied.
      See Also:
    • COLOR_TEXT_SECONDARY_DEFAULT

      @ColorInt public static final int COLOR_TEXT_SECONDARY_DEFAULT
      Default text secondary color used by this theme if no color is supplied.
      See Also:
    • FONT_SCALE_DEFAULT

      public static final int FONT_SCALE_DEFAULT
      Default font scale for the theme.
      See Also:
  • Method Details

    • initialize

      public void initialize(@NonNull DynamicListener listener, @Nullable DynamicResolver dynamicResolver)
      Initialize this class with default values.
      Parameters:
      listener - The application dynamic listener to be attached with this theme.
      dynamicResolver - The resolver for the dynamic theme.

      Pass null to use the default implementation.

    • setDynamicThemeWork

      public void setDynamicThemeWork(boolean enqueue)
      Sets the dynamic theme work to schedule auto theme event according to the time.
      Parameters:
      enqueue - true to enqueue the dynamic theme work.
    • setWallpaperColors

      public void setWallpaperColors(boolean enable, boolean context)
      Sets the WallpaperManager.OnColorsChangedListener to enable dynamic colors from the wallpaper on API 27 and above. Otherwise, use the custom implementation for older API levels.
      Parameters:
      enable - true to enable wallpaper colors listener.
      context - true if there is a context change and it must be reinitialized.
      See Also:
    • attach

      @NonNull public DynamicTheme attach(@NonNull DynamicListener localListener, @Nullable LayoutInflater.Factory2 layoutInflater)
      Attach a local dynamic listener to this theme.

      It can be an activity in case different themes are required for different activities.

      Parameters:
      localListener - The local dynamic listener to be attached with this theme.
      layoutInflater - The layout inflater factory for the local context.

      null to use no custom layout inflater.

      Returns:
      The DynamicTheme object to allow for chaining of calls to set methods.
    • attach

      @NonNull public DynamicTheme attach(@NonNull DynamicListener localListener)
      Attach a local dynamic listener to this theme.

      It can be an activity in case different themes are required for different activities.

      Parameters:
      localListener - The local dynamic listener to be attached with this theme.
      Returns:
      The DynamicTheme object to allow for chaining of calls to set methods.
    • initializeInstance

      public static void initializeInstance(@Nullable DynamicListener listener, @Nullable DynamicResolver dynamicResolver)
      Initialize theme when application starts.

      Must be initialized once.

      Parameters:
      listener - The dynamic listener to retrieve resources.
      dynamicResolver - The resolver for the dynamic theme.

      Pass null to use the default implementation.

    • getInstance

      @NonNull public static DynamicTheme getInstance()
      Retrieves the singleton instance of DynamicTheme.

      Must be called before accessing the public methods.

      Returns:
      The singleton instance of DynamicTheme.
    • getHandler

      @NonNull public DynamicThemeHandler getHandler()
      Get the main thread handler.
      Returns:
      The main thread handler.
    • getSystemThemeRes

      @StyleRes public int getSystemThemeRes(@Nullable DynamicListener listener, @NonNull AppTheme<?> theme)
      Returns the style resource used by the system.
      Parameters:
      listener - The dynamic listener to be used.
      theme - The dynamic theme to be used.
      Returns:
      The style resource used by the system.
    • setThemeRes

      @NonNull public DynamicTheme setThemeRes(@StyleRes int themeRes, @Nullable AppTheme<?> theme, boolean initializeRemoteColors)
      Initialize colors from the supplied theme resource.
      Parameters:
      themeRes - The theme resource to initialize colors.
      theme - The dynamic theme to initialize colors.
      initializeRemoteColors - true to initialize remote colors also.
      Returns:
      The DynamicTheme object to allow for chaining of calls to set methods.
    • setTheme

      @NonNull public DynamicTheme setTheme(@StyleRes int themeRes, @Nullable AppTheme<?> theme, boolean initializeRemoteColors)
      Initialize colors from the supplied dynamic app theme.
      Parameters:
      themeRes - The theme resource to initialize colors.
      theme - The dynamic theme to initialize colors.
      initializeRemoteColors - true to initialize remote colors also.
      Returns:
      The DynamicTheme object to allow for chaining of calls to set methods.
    • setLocalThemeRes

      @NonNull public DynamicTheme setLocalThemeRes(@StyleRes int themeRes, @Nullable AppTheme<?> theme)
      Initialize colors from the supplied local theme resource.
      Parameters:
      themeRes - The local theme resource to initialize colors.
      theme - The local dynamic theme to initialize colors.
      Returns:
      The DynamicTheme object to allow for chaining of calls to set methods.
    • setLocalTheme

      @NonNull public DynamicTheme setLocalTheme(@StyleRes int themeRes, @Nullable AppTheme<?> theme)
      Initialize colors from the supplied local dynamic app theme.
      Parameters:
      themeRes - The local theme resource to initialize colors.
      theme - The local dynamic theme to initialize colors.
      Returns:
      The DynamicTheme object to allow for chaining of calls to set methods.
    • setRemoteTheme

      @NonNull public DynamicTheme setRemoteTheme(@Nullable AppTheme<?> theme)
      Initialize colors from the supplied remote dynamic app theme.
      Parameters:
      theme - The remote dynamic theme to initialize colors.
      Returns:
      The DynamicTheme object to allow for chaining of calls to set methods.
    • initializeRemoteColors

      @NonNull public DynamicTheme initializeRemoteColors()
      Initialize remote colors according to the base colors.

      They can be set individually by calling the appropriate methods.

      Returns:
      The DynamicTheme object to allow for chaining of calls to set methods.
    • resolveBackgroundAware

      public int resolveBackgroundAware(int backgroundAware)
      Resolve background aware according to the constant value.
      Parameters:
      backgroundAware - The background aware to be resolved.
      Returns:
      The resolved background aware value.

      Either Theme.BackgroundAware.ENABLE or Theme.BackgroundAware.DISABLE.

      See Also:
    • resolveColorType

      @ColorInt public int resolveColorType(int colorType)
      Resolve color according to the color type.
      Parameters:
      colorType - The color type to be resolved.
      Returns:
      The resolved color value.
      See Also:
    • getVersion

      public int getVersion()
      Get the application theme styles version.
      Returns:
      The application theme styles version.
    • setVersion

      public void setVersion(int version)
      Set the application theme styles version.
      Parameters:
      version - The version to be set.
    • getLocalVersion

      public int getLocalVersion()
      Get the local theme styles version.
      Returns:
      The local theme styles version.
    • setLocalVersion

      public void setLocalVersion(int version)
      Set the local theme styles version.
      Parameters:
      version - The version to be set.
    • resolveVersion

      public int resolveVersion()
      Resolves the theme version according to the attached local.
      Returns:
      The theme version according to the attached local.
      See Also:
    • getListener

      @NonNull public DynamicListener getListener()
      Get the application listener used by this theme.
      Returns:
      The application context used by this theme.
    • setListener

      @NonNull public DynamicTheme setListener(@NonNull DynamicListener listener)
      Set the application listener for this theme.
      Parameters:
      listener - The application listener to be set.
      Returns:
      The DynamicTheme object to allow for chaining of calls to set methods.
    • getLocalListener

      @Nullable public DynamicListener getLocalListener()
      Get the local listener used by this theme.
      Returns:
      The local listener used by this theme.
    • getLocalContext

      @Nullable public Context getLocalContext()
      Get the local listener used by this theme.
      Returns:
      The local listener used by this theme.
    • getUiModeManager

      @NonNull public UiModeManager getUiModeManager()
      Get the UI mode manager used by the application.
      Returns:
      The UI mode manager used by the application.
    • getPowerManager

      @NonNull public PowerManager getPowerManager()
      Get the power manager used by the application.
      Returns:
      The power manager used by the application.
    • isPowerSaveMode

      public boolean isPowerSaveMode()
      Returns whether the power save mode is enabled.
      Returns:
      true if the power save mode is enabled.
    • getDefaultApplication

      @NonNull public DynamicAppTheme getDefaultApplication()
      Get the default theme used by the application.
      Returns:
      The default theme used by the application.
    • getApplication

      @NonNull public DynamicAppTheme getApplication()
      Get the theme used by the application.
      Returns:
      The theme used by the application.
    • getDefaultLocal

      @NonNull public DynamicAppTheme getDefaultLocal()
      Get the default theme used by the local context.
      Returns:
      The default theme used by the local context.
    • getLocal

      @Nullable public DynamicAppTheme getLocal()
      Get the theme used by the local context.
      Returns:
      The theme used by the local context.
    • getRemote

      @NonNull public DynamicRemoteTheme getRemote()
      Get the theme used by the remote elements.
      Returns:
      The theme used by the remote elements.
    • getDynamicThemes

      @NonNull public Map<String,String> getDynamicThemes()
      Returns the saved dynamic themes currently in use or to be resumed later.
      Returns:
      The saved dynamic themes currently in use or to be resumed later.
    • getPreviewActivity

      @NonNull public Class<?> getPreviewActivity()
      Get the preview activity used by this manager.
      Returns:
      The preview activity used by this manager.
    • setPreviewActivity

      public void setPreviewActivity(@NonNull Class<?> previewActivity)
      Sets the preview activity for this instance.
      Parameters:
      previewActivity - The preview activity class to be set.
    • get

      @NonNull public DynamicAppTheme get(boolean resolve)
      Get the theme according to the supplied parameter.

      Either application theme or local theme.

      Parameters:
      resolve - true to resolve the local theme if present.
      Returns:
      The theme according to the supplied parameter.
    • get

      @NonNull public DynamicAppTheme get()
      Get the theme according to the current state.

      Either application theme or local theme.

      Returns:
      The theme according to the current state.
    • getDefault

      @NonNull public DynamicAppTheme getDefault(boolean resolve)
      Get the default theme according to the supplied parameter.

      Either default application theme or default local theme.

      Parameters:
      resolve - true to resolve the default local theme if present.
      Returns:
      The default theme according to the supplied parameter.
    • getDefault

      @NonNull public DynamicAppTheme getDefault()
      Get the default theme according to the current state.

      Either default application theme or default local theme.

      Returns:
      The default theme according to the current state.
      See Also:
    • recreateLocal

      public void recreateLocal()
      Recreate local activity to update all the views with new theme.
    • onDestroy

      public void onDestroy()
      Set the initialized instance to null when app terminates for better theme results when theme is changed.
    • onLocalDestroy

      public void onLocalDestroy(@Nullable DynamicListener listener)
      Set the initialized instance to null when local destroys for better theme results when theme is changed.
      Parameters:
      listener - The listener to be destroyed.
    • getDefaultBackgroundColor

      @ColorInt public int getDefaultBackgroundColor(boolean night)
      Generates default background color according to the application theme.
      Parameters:
      night - true if the night mode is enabled.
      Returns:
      The generated background color.
    • getSystemContrast

      public int getSystemContrast(int fallback)
      Try to get the contrast from the system.
      Parameters:
      fallback - The fallback contrast to be used in case of any issues.
      Returns:
      The contrast from the system.
    • getWidgetCornerRadius

      @Px public int getWidgetCornerRadius(int fallback)
      Try to get the corner radius for the widget background from the system.
      Parameters:
      fallback - The fallback radius to be used in case of any issues.
      Returns:
      The corner radius for the widget background from the system.
    • getDefaultContrastWith

      @ColorInt public int getDefaultContrastWith()
      Returns the default contrast with color to tint the background aware views accordingly.
      Returns:
      The default contrast with color.
    • generateDefaultTheme

      @NonNull public DynamicAppTheme generateDefaultTheme()
      Generates default theme according to the current settings.
      Returns:
      The generated default theme.
    • generateStrokeColor

      @ColorInt public int generateStrokeColor(@ColorInt int color)
      Generates stroke color according to the supplied color.
      Parameters:
      color - The color to generate the stroke color.
      Returns:
      The generated stroke color.
    • generateSurfaceColor

      @ColorInt public int generateSurfaceColor(@ColorInt int color)
      Generates surface color according to the supplied color.
      Parameters:
      color - The color to generate the surface color.
      Returns:
      The generated surface color.
    • generateErrorColor

      @ColorInt public int generateErrorColor(@ColorInt int primary, @ColorInt int secondary)
      Generates error color according to the supplied colors.
      Parameters:
      primary - The primary color to generate the error color.
      secondary - The secondary color to generate the error color.
      Returns:
      The generated error color.
    • generateSystemColor

      @ColorInt public int generateSystemColor(@ColorInt int color)
      Generates dark variant of the supplied color.
      Parameters:
      color - The color to generate the dark variant.
      Returns:
      The generated dark variant of the color.
    • generateSystemSecondaryColor

      @ColorInt public int generateSystemSecondaryColor(@ColorInt int color)
      Generates tint of the supplied color.
      Parameters:
      color - The color to generate the tint.
      Returns:
      The generated tint of the color.
    • getDynamicResolver

      @NonNull public DynamicResolver getDynamicResolver()
      Returns the resolver used by the dynamic theme.
      Returns:
      The resolver used by the dynamic theme.
    • setDynamicResolver

      public void setDynamicResolver(@Nullable DynamicResolver resolver)
      Sets the resolver used by the dynamic theme.
      Parameters:
      resolver - The resolver to be set.
    • addDynamicListener

      public void addDynamicListener(@Nullable DynamicListener listener)
      Add a dynamic listener to receive the various callbacks.
      Parameters:
      listener - The dynamic listener to be added.
      See Also:
    • removeDynamicListener

      public void removeDynamicListener(@Nullable DynamicListener listener)
      Remove a dynamic listener.
      Parameters:
      listener - The dynamic listener to be removed.
      See Also:
    • isDynamicListener

      public boolean isDynamicListener(@Nullable DynamicListener listener)
      Checks whether a dynamic listener is already registered.
      Parameters:
      listener - The dynamic listener to be checked.
      Returns:
      true if dynamic listener is already registered.
      See Also:
    • clearDynamicListeners

      public void clearDynamicListeners()
      Remove all the dynamic listeners and themes.
    • getProductFlavor

      public String getProductFlavor()
      Specified by:
      getProductFlavor in interface DynamicProductFlavor
    • getContext

      @NonNull public Context getContext()
      Description copied from interface: DynamicListener
      Returns the context used by this listener.
      Specified by:
      getContext in interface DynamicListener
      Returns:
      The context used by this listener.
    • getRequiredThemeVersion

      public int getRequiredThemeVersion()
      Description copied from interface: DynamicListener
      This method will be called to get the intended theme styles version for this listener.
      Specified by:
      getRequiredThemeVersion in interface DynamicListener
      Returns:
      The intended theme styles version for this listener.
    • isNightMode

      public boolean isNightMode(boolean resolve)
      Description copied from interface: DynamicListener
      Checks whether the night mode is enabled for this listener.
      Specified by:
      isNightMode in interface DynamicListener
      Parameters:
      resolve - true to resolve based on the theme data.
      Returns:
      true if the night mode is enabled for this listener.
    • getThemeRes

      @StyleRes public int getThemeRes(@Nullable AppTheme<?> theme)
      Description copied from interface: DynamicListener
      This method will be called to return the theme style resource for this listener.

      Override this method to supply your own customised style.

      Specified by:
      getThemeRes in interface DynamicListener
      Parameters:
      theme - The optional dynamic theme to resolve the style resource.
      Returns:
      The theme style resource for this listener.
      See Also:
    • getThemeRes

      @StyleRes public int getThemeRes()
      Description copied from interface: DynamicListener
      This method will be called to return the theme style resource for this listener.

      Override this method to supply your own customised style.

      Specified by:
      getThemeRes in interface DynamicListener
      Returns:
      The theme style resource for this listener.
      See Also:
    • getDynamicTheme

      @Nullable public AppTheme<?> getDynamicTheme()
      Description copied from interface: DynamicListener
      This method will be called to return the dynamic app theme for this listener.

      Override this method to supply your own customised theme.

      Specified by:
      getDynamicTheme in interface DynamicListener
      Returns:
      The dynamic app theme for this listener.
    • isDynamicColors

      public boolean isDynamicColors()
      Description copied from interface: DynamicListener
      Returns whether the dynamic colors are enabled for this listener.
      Specified by:
      isDynamicColors in interface DynamicListener
      Returns:
      true if the dynamic colors are enabled for this listener.
    • isDynamicColor

      public boolean isDynamicColor()
      Description copied from interface: DynamicListener
      Returns whether to apply the dynamic colors for this listener.
      Specified by:
      isDynamicColor in interface DynamicListener
      Returns:
      true if the dynamic colors should be applied for this listener.
    • isSystemColor

      public boolean isSystemColor()
      Description copied from interface: DynamicListener
      Returns whether the dynamic colors should be extracted from the system for this listener.
      Specified by:
      isSystemColor in interface DynamicListener
      Returns:
      true if the dynamic colors should be extracted from the system for this listener
    • isWallpaperColor

      public boolean isWallpaperColor()
      Description copied from interface: DynamicListener
      Returns whether the dynamic colors should be extracted from the wallpaper for this listener.
      Specified by:
      isWallpaperColor in interface DynamicListener
      Returns:
      true if the dynamic colors should be extracted from the wallpaper for this listener
    • isOnSharedPreferenceChangeListener

      public boolean isOnSharedPreferenceChangeListener()
      Description copied from interface: DynamicListener
      Returns whether to register a shared preferences listener for this listener.
      Specified by:
      isOnSharedPreferenceChangeListener in interface DynamicListener
      Returns:
      true to register a SharedPreferences.OnSharedPreferenceChangeListener to receive preference change callback.
    • getDefaultColor

      @ColorInt public int getDefaultColor(int colorType)
      Description copied from interface: DynamicListener
      This method will be called to resolve the default color according to it's type.

      It is useful in resolving the color if the default theme also has auto values.

      Specified by:
      getDefaultColor in interface DynamicListener
      Parameters:
      colorType - The color type to be resolved.
      Returns:
      The resolved default color according to the color type.
      See Also:
    • onDynamicChanged

      public void onDynamicChanged(boolean context, boolean recreate)
      Description copied from interface: DynamicListener
      This method will be called when the dynamic change event occurs (like theme, locale, etc.).

      Recreate the activity or application here to adapt changes.

      Specified by:
      onDynamicChanged in interface DynamicListener
      Parameters:
      context - true if there is a context change and it must be reinitialized.
      recreate - true if listener must be recreated to adapt the changes.
    • onDynamicConfigurationChanged

      public void onDynamicConfigurationChanged(boolean locale, boolean fontScale, boolean orientation, boolean uiMode, boolean density)
      Description copied from interface: DynamicListener
      This method will be called when the dynamic configuration change event occurs (like locale, font scale, orientation, ui mode, etc.).

      It will provide more control on DynamicListener.onDynamicChanged(boolean, boolean) method call.

      Specified by:
      onDynamicConfigurationChanged in interface DynamicListener
      Parameters:
      locale - true if locale is changed.
      fontScale - true if font scale is changed.
      orientation - true if there is an orientation change.
      uiMode - true if ui mode is changed.
      density - true if configuration density is changed.
      See Also:
    • onDynamicColorsChanged

      public void onDynamicColorsChanged(@Nullable DynamicColors colors, boolean context)
      Description copied from interface: DynamicListener
      This method will be called when the dynamic color change event occurs according to the wallpaper.

      Recreate the activity or application here to adapt changes.

      Specified by:
      onDynamicColorsChanged in interface DynamicListener
      Parameters:
      colors - The new dynamic colors.
      context - true if there is a context change and it must be reinitialized.
    • onAutoThemeChanged

      public void onAutoThemeChanged(boolean context)
      Description copied from interface: DynamicListener
      This method will be called when the auto theme change event occurs according to the time.

      Recreate the activity or application here to adapt changes.

      Specified by:
      onAutoThemeChanged in interface DynamicListener
      Parameters:
      context - true if there is a context change and it must be reinitialized.
    • onPowerSaveModeChanged

      public void onPowerSaveModeChanged(boolean powerSaveMode)
      Description copied from interface: DynamicListener
      This method will be called when the power save mode has been changed.

      It will be called only on API 21 and above.

      Specified by:
      onPowerSaveModeChanged in interface DynamicListener
      Parameters:
      powerSaveMode - true if the device is in power save mode.
    • setNavigationBarTheme

      public boolean setNavigationBarTheme()
      Description copied from interface: DynamicListener
      Returns whether the navigation bar theme should be applied for the activity.

      It will be applied only on the API 21 and above.

      Specified by:
      setNavigationBarTheme in interface DynamicListener
      Returns:
      true to apply navigation bar theme for the activity.
    • onNavigationBarThemeChanged

      public void onNavigationBarThemeChanged()
      Description copied from interface: DynamicListener
      This method will be called when the navigation bar theme has been changed.
      Specified by:
      onNavigationBarThemeChanged in interface DynamicListener
    • toString

      @NonNull public String toString()
      Overrides:
      toString in class Object
    • saveLocalTheme

      public void saveLocalTheme()
      Save the local context theme in shared preferences.
    • getLocalTheme

      @Nullable public String getLocalTheme(@NonNull DynamicListener listener)
      Returns the supplied listener theme from the shared preferences.
      Parameters:
      listener - The listener to retrieve the theme.
      Returns:
      The supplied listener theme from the shared preferences.
    • deleteLocalTheme

      public void deleteLocalTheme(@NonNull DynamicListener listener)
      Delete the supplied listener theme from the shared preferences.
      Parameters:
      listener - The listener to delete the theme.
    • getTheme

      @Nullable public DynamicAppTheme getTheme(@Nullable String theme)
      Returns the dynamic app theme from the JSON string.
      Parameters:
      theme - The dynamic app theme JSON string to be converted.
      Returns:
      The dynamic app theme from the JSON string.
    • getWidgetTheme

      @Nullable public DynamicWidgetTheme getWidgetTheme(@Nullable String theme)
      Returns the dynamic widget theme from the JSON string.
      Parameters:
      theme - The dynamic widget theme JSON string to be converted.
      Returns:
      The dynamic widget theme from the JSON string.
    • getRemoteTheme

      @Nullable public DynamicRemoteTheme getRemoteTheme(@Nullable String theme)
      Returns the dynamic remote theme from the JSON string.
      Parameters:
      theme - The dynamic remote theme JSON string to be converted.
      Returns:
      The dynamic remote theme from the JSON string.
    • getTheme

      @NonNull public DynamicTheme getTheme()
      Description copied from interface: DynamicResolver
      Get the dynamic theme instance used by this resolver.
      Specified by:
      getTheme in interface DynamicResolver
      Returns:
      The dynamic theme instance used by this resolver.
    • getColors

      @NonNull public DynamicColors getColors(boolean resolve)
      Description copied from interface: DynamicResolver
      Get the dynamic colors used by this resolver.
      Specified by:
      getColors in interface DynamicResolver
      Parameters:
      resolve - true to resolve the dynamic colors.
      Returns:
      The dynamic colors used by this resolver.
    • getColors

      @NonNull public DynamicColors getColors()
      Description copied from interface: DynamicResolver
      Get the dynamic colors used by this resolver.
      Specified by:
      getColors in interface DynamicResolver
      Returns:
      The dynamic colors used by this resolver.
    • isSystemNightMode

      public boolean isSystemNightMode()
      Description copied from interface: DynamicResolver
      Checks whether the system night mode is enabled.
      Specified by:
      isSystemNightMode in interface DynamicResolver
      Returns:
      true if the system night mode is enabled.
    • resolveSystemColor

      public int resolveSystemColor(boolean isNight)
      Description copied from interface: DynamicResolver
      Resolves system color according to the API level and night mode.
      Specified by:
      resolveSystemColor in interface DynamicResolver
      Parameters:
      isNight - true to resolve the night color.
      Returns:
      The system UI color according to the Android version and night mode.
    • isNight

      public boolean isNight()
      Description copied from interface: DynamicResolver
      Checks for the night time.

      Useful to apply themes based on the day and night.

      Specified by:
      isNight in interface DynamicResolver
      Returns:
      true if it is night.
    • isNight

      public boolean isNight(int theme)
      Description copied from interface: DynamicResolver
      Checks for the night time according to the supplied value.

      Useful to apply themes based on the day and night.

      Specified by:
      isNight in interface DynamicResolver
      Parameters:
      theme - The integer value of the theme.
      Returns:
      true if it is night.
    • isNight

      public boolean isNight(String theme)
      Description copied from interface: DynamicResolver
      Checks for the night time according to the supplied value.

      Useful to apply themes based on the day and night.

      Specified by:
      isNight in interface DynamicResolver
      Parameters:
      theme - The string value of the theme.
      Returns:
      true if it is night.
    • getNightTimeStart

      @NonNull public Date getNightTimeStart()
      Description copied from interface: DynamicResolver
      Returns start time for the night theme.
      Specified by:
      getNightTimeStart in interface DynamicResolver
      Returns:
      The start time for the night theme.
    • getNightTimeEnd

      @NonNull public Date getNightTimeEnd()
      Description copied from interface: DynamicResolver
      Returns end time for the night theme.
      Specified by:
      getNightTimeEnd in interface DynamicResolver
      Returns:
      The end time for the night theme.
    • resolveNightTheme

      public boolean resolveNightTheme(int theme, int implementation, boolean data)
      Description copied from interface: DynamicResolver
      Resolves night theme according to the selected implementation.
      Specified by:
      resolveNightTheme in interface DynamicResolver
      Parameters:
      theme - The app theme to resolve the auto night theme.
      implementation - The implementation for the night theme.
      data - true to resolve based on the theme data.
      Returns:
      true if the night theme is enabled according to the selected implementation.
    • resolveNightTheme

      public boolean resolveNightTheme(String theme, String implementation, boolean data)
      Description copied from interface: DynamicResolver
      Resolves night theme according to the selected implementation.
      Specified by:
      resolveNightTheme in interface DynamicResolver
      Parameters:
      theme - The app theme to resolve the auto night theme.
      implementation - The implementation for the night theme.
      data - true to resolve based on the theme data.
      Returns:
      true if the night theme is enabled according to the selected implementation.
    • resolveAppTheme

      public int resolveAppTheme(int theme, int night, boolean data)
      Description copied from interface: DynamicResolver
      Resolves current theme according to the supplied implementation.
      Specified by:
      resolveAppTheme in interface DynamicResolver
      Parameters:
      theme - The theme to be resolved.
      night - The implementation for the night theme.
      data - true to resolve based on the theme data.
      Returns:
      The resolved theme constant according to the supplied implementation.
      See Also:
    • resolveAppTheme

      public int resolveAppTheme(String theme, String night, boolean data)
      Description copied from interface: DynamicResolver
      Resolves current theme according to the supplied implementation.
      Specified by:
      resolveAppTheme in interface DynamicResolver
      Parameters:
      theme - The theme to be resolved.
      night - The implementation for the night theme.
      data - true to resolve based on the theme data.
      Returns:
      The resolved theme constant according to the supplied implementation.
      See Also:
    • copyThemeString

      public void copyThemeString(@NonNull Context context, @Nullable String theme)
      Copy the supplied theme string to the clipboard and show a Snackbar.
      Parameters:
      context - The context to get the ClipboardManager.
      theme - The theme string to be copied.
    • copyTheme

      public void copyTheme(@NonNull Context context, @Nullable String theme)
      Copy the supplied theme data to the clipboard and show a Snackbar.
      Parameters:
      context - The context to get the ClipboardManager.
      theme - The theme data to be copied.
    • saveTheme

      public void saveTheme(@NonNull Context context)
      Show a theme saved Snackbar.
      Parameters:
      context - The context to get the Snackbar.
    • invalidTheme

      public void invalidTheme(@NonNull Context context)
      Show a invalid theme Snackbar.
      Parameters:
      context - The context to get the Snackbar.