Class DynamicBottomNavigationView

All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewManager, ViewParent, BaseWidget, DynamicBackgroundWidget, DynamicCornerWidget<Float>, DynamicTextWidget, DynamicWidget, WindowInsetsWidget

public class DynamicBottomNavigationView extends BottomNavigationView implements WindowInsetsWidget, DynamicBackgroundWidget, DynamicTextWidget, DynamicCornerWidget<Float>
A BottomNavigationView to apply DynamicTheme according to the supplied parameters.
  • Field Details

    • mBackgroundColorType

      protected int mBackgroundColorType
      Color type applied to the background of this view.
      See Also:
    • mColorType

      protected int mColorType
      Color type applied to this view.
      See Also:
    • mTextColorType

      protected int mTextColorType
      Text color type applied to this view.
      See Also:
    • mContrastWithColorType

      protected int mContrastWithColorType
      Background color type for this view so that it will remain in contrast with this color type.
    • mBackgroundColor

      @ColorInt protected int mBackgroundColor
      Background color applied to this view.
    • mColor

      @ColorInt protected int mColor
      Color applied to this view.
    • mAppliedColor

      @ColorInt protected int mAppliedColor
      Color applied to this view after considering the background aware properties.
    • mTextColor

      @ColorInt protected int mTextColor
      Text color applied to this view.
    • mAppliedTextColor

      @ColorInt protected int mAppliedTextColor
      Text color applied to this view after considering the background aware properties.
    • mContrastWithColor

      @ColorInt protected int mContrastWithColor
      Background color for this view so that it will remain in contrast with this color.
    • mBackgroundAware

      protected int mBackgroundAware
      The background aware functionality to change this view color according to the background. It was introduced to provide better legibility for colored views and to avoid dark view on dark background like situations.

      If this is enabled then, it will check for the contrast color and do color calculations according to that color so that this text view will always be visible on that background. If no contrast color is found then, it will take the default background color.

      See Also:
    • mContrast

      protected int mContrast
      Minimum contrast value to generate contrast color for the background aware functionality.
    • mCornerSize

      protected float mCornerSize
      Corner size used by this view.
  • Constructor Details

  • Method Details

    • loadFromAttributes

      public void loadFromAttributes(@Nullable AttributeSet attrs)
      Description copied from interface: BaseWidget
      Load values from the supplied attribute set.
      Specified by:
      loadFromAttributes in interface BaseWidget
      Parameters:
      attrs - The supplied attribute set to load the values.
    • initialize

      public void initialize()
      Description copied from interface: BaseWidget
      Initialize this widget by setting color type. If it is background aware then, background color will also taken into account while setting the color filter.
      Specified by:
      initialize in interface BaseWidget
      See Also:
    • applyWindowInsets

      public void applyWindowInsets()
      Description copied from interface: WindowInsetsWidget
      Apply window insets for the widget.
      Specified by:
      applyWindowInsets in interface WindowInsetsWidget
    • getBackgroundColorType

      public int getBackgroundColorType()
      Description copied from interface: DynamicBackgroundWidget
      Returns the background color type applied to this widget.
      Specified by:
      getBackgroundColorType in interface DynamicBackgroundWidget
      Returns:
      The background color type applied to this widget.
      See Also:
    • setBackgroundColorType

      public void setBackgroundColorType(int backgroundColorType)
      Description copied from interface: DynamicBackgroundWidget
      Set the background color type to this widget.
      Specified by:
      setBackgroundColorType in interface DynamicBackgroundWidget
      Parameters:
      backgroundColorType - Text color type for this widget.
      See Also:
    • getColorType

      public int getColorType()
      Description copied from interface: DynamicWidget
      Returns the color type applied to this widget.
      Specified by:
      getColorType in interface DynamicWidget
      Returns:
      The color type applied to this widget.
      See Also:
    • setColorType

      public void setColorType(int colorType)
      Description copied from interface: DynamicWidget
      Set the color type to this widget.
      Specified by:
      setColorType in interface DynamicWidget
      Parameters:
      colorType - The color type for this widget.
      See Also:
    • getTextColorType

      public int getTextColorType()
      Description copied from interface: DynamicTextWidget
      Returns the text color type applied to this widget.
      Specified by:
      getTextColorType in interface DynamicTextWidget
      Returns:
      The text color type applied to this widget.
      See Also:
    • setTextColorType

      public void setTextColorType(int textColorType)
      Description copied from interface: DynamicTextWidget
      Set the text color type to this widget.
      Specified by:
      setTextColorType in interface DynamicTextWidget
      Parameters:
      textColorType - Text color type for this widget.
      See Also:
    • getContrastWithColorType

      public int getContrastWithColorType()
      Description copied from interface: DynamicWidget
      Returns the contrast with color type applied to this widget.
      Specified by:
      getContrastWithColorType in interface DynamicWidget
      Returns:
      The contrast with color type applied to this widget.
      See Also:
    • setContrastWithColorType

      public void setContrastWithColorType(int contrastWithColorType)
      Description copied from interface: DynamicWidget
      Set the contrast with color type to this widget.
      Specified by:
      setContrastWithColorType in interface DynamicWidget
      Parameters:
      contrastWithColorType - The contrast with color type for this widget.
      See Also:
    • getBackgroundColor

      @ColorInt public int getBackgroundColor()
      Description copied from interface: DynamicBackgroundWidget
      Returns the value of background color applied to this widget.
      Specified by:
      getBackgroundColor in interface DynamicBackgroundWidget
      Returns:
      The value of background color applied to this widget.
    • getColor

      @ColorInt public int getColor(boolean resolve)
      Description copied from interface: DynamicWidget
      Returns the value of color applied to this widget.
      Specified by:
      getColor in interface DynamicWidget
      Parameters:
      resolve - true to resolve the applied color.
      Returns:
      The value of color applied to this widget.
    • getColor

      @ColorInt public int getColor()
      Description copied from interface: DynamicWidget
      Returns the value of color applied to this widget.
      Specified by:
      getColor in interface DynamicWidget
      Returns:
      The value of color applied to this widget.
    • setColor

      public void setColor(@ColorInt int color)
      Description copied from interface: DynamicWidget
      Set the value of color for this widget.
      Specified by:
      setColor in interface DynamicWidget
      Parameters:
      color - Color for this widget.
    • getTextColor

      @ColorInt public int getTextColor(boolean resolve)
      Description copied from interface: DynamicTextWidget
      Returns the value of text color applied to this widget.
      Specified by:
      getTextColor in interface DynamicTextWidget
      Parameters:
      resolve - true to resolve the text color applied to this widget.
      Returns:
      The value of text color applied to this widget.
    • getTextColor

      @ColorInt public int getTextColor()
      Description copied from interface: DynamicTextWidget
      Returns the value of text color applied to this widget.
      Specified by:
      getTextColor in interface DynamicTextWidget
      Returns:
      The value of text color applied to this widget.
    • setTextColor

      public void setTextColor(@ColorInt int textColor)
      Description copied from interface: DynamicTextWidget
      Set the value of text color for this widget.
      Specified by:
      setTextColor in interface DynamicTextWidget
      Parameters:
      textColor - Text color for this widget.
    • getContrastWithColor

      @ColorInt public int getContrastWithColor()
      Description copied from interface: DynamicWidget
      Returns the value of contrast with color applied to this widget.
      Specified by:
      getContrastWithColor in interface DynamicWidget
      Returns:
      The value of contrast with color applied to this widget.
    • setContrastWithColor

      public void setContrastWithColor(@ColorInt int contrastWithColor)
      Description copied from interface: DynamicWidget
      Set the value of contrast with color for this widget.
      Specified by:
      setContrastWithColor in interface DynamicWidget
      Parameters:
      contrastWithColor - Contrast with color for this widget.
    • getBackgroundAware

      public int getBackgroundAware()
      Description copied from interface: DynamicWidget
      Returns the background aware functionality used by this widget.
      Specified by:
      getBackgroundAware in interface DynamicWidget
      Returns:
      The background aware functionality used by this widget.
    • isBackgroundAware

      public boolean isBackgroundAware()
      Description copied from interface: DynamicWidget
      Checks whether the background aware functionality is enabled.
      Specified by:
      isBackgroundAware in interface DynamicWidget
      Returns:
      true if this widget changes color according to the background.
    • setBackgroundAware

      public void setBackgroundAware(int backgroundAware)
      Description copied from interface: DynamicWidget
      Set the value to make this widget background aware or not.
      Specified by:
      setBackgroundAware in interface DynamicWidget
      Parameters:
      backgroundAware - The background aware functionality to be set.
    • getContrast

      public int getContrast(boolean resolve)
      Description copied from interface: DynamicWidget
      Get the contrast value used by this widget.
      Specified by:
      getContrast in interface DynamicWidget
      Parameters:
      resolve - true to resolve auto contrast.
      Returns:
      The contrast value used by this widget.
    • getContrast

      public int getContrast()
      Description copied from interface: DynamicWidget
      Get the contrast value used by this widget.
      Specified by:
      getContrast in interface DynamicWidget
      Returns:
      The contrast value used by this widget.
    • getContrastRatio

      public float getContrastRatio()
      Description copied from interface: DynamicWidget
      Returns the contrast ratio for by this widget.
      Specified by:
      getContrastRatio in interface DynamicWidget
      Returns:
      The contrast ratio for by this widget.
    • setContrast

      public void setContrast(int contrast)
      Description copied from interface: DynamicWidget
      Set the contrast value used for this widget.
      Specified by:
      setContrast in interface DynamicWidget
      Parameters:
      contrast - The contrast value to be set.
    • onLayout

      protected void onLayout(boolean changed, int l, int t, int r, int b)
      Overrides:
      onLayout in class FrameLayout
    • onSizeChanged

      protected void onSizeChanged(int w, int h, int oldw, int oldh)
      Overrides:
      onSizeChanged in class View
    • getCorner

      @NonNull public Float getCorner()
      Description copied from interface: DynamicCornerWidget
      Returns the corner radius used by this widget.
      Specified by:
      getCorner in interface DynamicCornerWidget<Float>
      Returns:
      The corner radius used by this widget.
    • setCorner

      public void setCorner(@NonNull Float cornerSize)
      Description copied from interface: DynamicCornerWidget
      Set the corner radius for this widget.
      Specified by:
      setCorner in interface DynamicCornerWidget<Float>
      Parameters:
      cornerSize - The corner radius to be set.
    • setBackgroundColor

      public void setBackgroundColor(@ColorInt int color)
      Description copied from interface: DynamicBackgroundWidget
      Set the value of background color for this widget.
      Specified by:
      setBackgroundColor in interface DynamicBackgroundWidget
      Overrides:
      setBackgroundColor in class View
      Parameters:
      color - Background color for this widget.
    • setColor

      public void setColor()
      Description copied from interface: DynamicWidget
      Set color for this widget according to the supplied values.
      Specified by:
      setColor in interface DynamicWidget
    • setTextColor

      public void setTextColor()
      Description copied from interface: DynamicTextWidget
      Set text color for this widget according to the supplied values.

      Generally, it should be a tint color so that text will be visible on this widget background.

      Specified by:
      setTextColor in interface DynamicTextWidget
    • setTextWidgetColor

      public void setTextWidgetColor(boolean setTextColor)
      Description copied from interface: DynamicTextWidget
      Set color and text color for this widget at once.
      Specified by:
      setTextWidgetColor in interface DynamicTextWidget
      Parameters:
      setTextColor - true to set the text color also.