Package com.castlabs.subtitles.presentation

# Class SubtitlesStyle.Builder

java.lang.Object
com.castlabs.subtitles.presentation.SubtitlesStyle.Builder

Enclosing class:
  `SubtitlesStyle`

public static class SubtitlesStyle.Builder extends Object

- ## Method Summary

  Modifier and Type
  Method
  Description
  `SubtitlesStyle.Builder`
  `backgroundColor(int backgroundColor, boolean overwrite)`
  Set the background color as ARGB.
  `SubtitlesStyle.Builder`
  `backgroundColorRGB(int backgroundColor, boolean overwrite)`
  Set the background color as RGB.
  `SubtitlesStyle.Builder`
  `backgroundOpacity(float opacity)`
  Set the opacity of the background color.
  `SubtitlesStyle.Builder`
  `bottomMargin(int bottomMarginPx)`
  Set the bottom margin in pixels, default is zero Note: not supported by com.castlabs.android.player.ExoSubtitlesRendererPlugin
  `static SubtitlesStyle.Builder`
  `create(Context context, boolean useSystemSettings)`
  Create a new instance of this builder.
  `static SubtitlesStyle.Builder`
  `create(SubtitlesStyle subtitlesStyle)`
  Create a new instance of this builder based on the provided subtitle style.
  `SubtitlesStyle.Builder`
  `disableAutoFlowText(boolean disableAutoFlowText)`
  If set to true the auto-flow text behaviour will be disabled regardless of the font-size and the font-scale.
  `SubtitlesStyle.Builder`
  `displayAlign(int displayAlign)`
  Set the display alignment.
  `SubtitlesStyle.Builder`
  `drawBeyondVideoArea(boolean drawBeyondVideoArea)`
  Enable or disable the drawing beyond video area, default is `false` Note: not supported by com.castlabs.android.player.ExoSubtitlesRendererPlugin
  `SubtitlesStyle.Builder`
  `edgeBlurRadius(int edgeBlurRadius, boolean overwrite)`
  Set the edge blur radius in pixels.
  `SubtitlesStyle.Builder`
  `edgeColor(int edgeColor, boolean overwrite)`
  Set the edge color as ARGB.
  `SubtitlesStyle.Builder`
  `edgeColorRGB(int edgeColor, boolean overwrite)`
  Set the edge color as RGB.
  `SubtitlesStyle.Builder`
  `edgeThickness(int edgeThickness, boolean overwrite)`
  Set the edge thickness in pixels.
  `SubtitlesStyle.Builder`
  `edgeType(int edgeType, boolean overwrite)`
  Set the edge type to one of `SubtitlesStyle.EDGE_TYPE_NONE`, `SubtitlesStyle.EDGE_TYPE_OUTLINE`, `SubtitlesStyle.EDGE_TYPE_DROP_SHADOW`, `SubtitlesStyle.EDGE_TYPE_RAISED`, or `SubtitlesStyle.EDGE_TYPE_DEPRESSED`.
  `SubtitlesStyle.Builder`
  `fontScale(float fontScale)`
  Set the font scale.
  `SubtitlesStyle.Builder`
  `fontSize(int fontSize, boolean overwrite)`
  Set the font size in pixels
  `SubtitlesStyle.Builder`
  `foregroundColor(int foregroundColor, boolean overwrite)`
  Set the foreground color as ARGB.
  `SubtitlesStyle.Builder`
  `foregroundColorRGB(int foregroundColor, boolean overwrite)`
  Set the foreground color as RGB
  `SubtitlesStyle.Builder`
  `foregroundOpacity(float opacity)`
  Set the opacity of the foreground color.
  `SubtitlesStyle`
  `get()`
  Create and return the new style from this builder.
  `SubtitlesStyle.Builder`
  `imageScalingMode(int imageScalingMode)`
  Set the Image scaling mode for pre rendered subtitle images
  `SubtitlesStyle.Builder`
  `leftMargin(int leftMarginPx)`
  Set the left margin in pixels, default is zero Note: not supported by com.castlabs.android.player.ExoSubtitlesRendererPlugin
  `SubtitlesStyle.Builder`
  `regionAutoSizedToFit(boolean regionAutoSizedToFit, boolean overwrite)`
  Set the auto-sized to fit region.
  `SubtitlesStyle.Builder`
  `regionColor(int regionColor, boolean overwrite)`
  Set the region color as ARGB.
  `SubtitlesStyle.Builder`
  `regionOpacity(float opacity)`
  Set the opacity of the region color.
  `SubtitlesStyle.Builder`
  `rightMargin(int rightMarginPx)`
  Set the right margin in pixels, default is zero Note: not supported by com.castlabs.android.player.ExoSubtitlesRendererPlugin
  `SubtitlesStyle.Builder`
  `textAlign(int textAlign)`
  Set the text alignment.
  `SubtitlesStyle.Builder`
  `topMargin(int topMarginPx)`
  Set the top margin in pixels, default is zero Note: not supported by com.castlabs.android.player.ExoSubtitlesRendererPlugin
  `SubtitlesStyle.Builder`
  `typeface(Typeface typeface)`
  Set the typeface.
  `SubtitlesStyle.Builder`
  `windowColor(int windowColor, boolean overwrite)`
  Set the window color as ARGB.
  `SubtitlesStyle.Builder`
  `windowColorRGB(int windowColor, boolean overwrite)`
  Set the window color as RGB.
  `SubtitlesStyle.Builder`
  `windowOpacity(float opacity)`
  Set the opacity of the window color.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### foregroundColor

    public SubtitlesStyle.Builder foregroundColor(int foregroundColor, boolean overwrite)
    Set the foreground color as ARGB. Note that this overwrite the current opacity setting.
    Parameters:
      `foregroundColor` - The color as ARGB
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasForegroundColor` will be set to `true`
    Returns:
      The builder

  - ### foregroundColorRGB

    public SubtitlesStyle.Builder foregroundColorRGB(int foregroundColor, boolean overwrite)
    Set the foreground color as RGB
    Parameters:
      `foregroundColor` - The color as RGB
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasForegroundColor` will be set to `true`
    Returns:
      The builder

  - ### backgroundColor

    public SubtitlesStyle.Builder backgroundColor(int backgroundColor, boolean overwrite)
    Set the background color as ARGB. Note that this overwrite the current opacity setting.
    Parameters:
      `backgroundColor` - The color as ARGB
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasBackgroundColor` will be set to `true`
    Returns:
      The builder

  - ### backgroundColorRGB

    public SubtitlesStyle.Builder backgroundColorRGB(int backgroundColor, boolean overwrite)
    Set the background color as RGB.
    Parameters:
      `backgroundColor` - The color as RGB
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasBackgroundColor` will be set to `true`
    Returns:
      The builder

  - ### windowColor

    public SubtitlesStyle.Builder windowColor(int windowColor, boolean overwrite)
    Set the window color as ARGB. Note that this overwrite the current opacity setting.
    Parameters:
      `windowColor` - The color as ARGB
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasWindowColor` will be set to `true`
    Returns:
      The builder

  - ### windowColorRGB

    public SubtitlesStyle.Builder windowColorRGB(int windowColor, boolean overwrite)
    Set the window color as RGB.
    Parameters:
      `windowColor` - The color as RGB
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasWindowColor` will be set to `true`
    Returns:
      The builder

  - ### edgeColor

    public SubtitlesStyle.Builder edgeColor(int edgeColor, boolean overwrite)
    Set the edge color as ARGB. Note that this overwrite the current opacity setting.
    Parameters:
      `edgeColor` - The color as ARGB
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasEdgeColor` will be set to `true`
    Returns:
      The builder

  - ### edgeThickness

    public SubtitlesStyle.Builder edgeThickness(int edgeThickness, boolean overwrite)
    Set the edge thickness in pixels.
    Parameters:
      `edgeThickness` - The edge thickness in pixels
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasEdgeThickness` will be set to `true`
    Returns:
      The builder

  - ### edgeBlurRadius

    public SubtitlesStyle.Builder edgeBlurRadius(int edgeBlurRadius, boolean overwrite)
    Set the edge blur radius in pixels.
    Parameters:
      `edgeBlurRadius` - The edge blur radius in pixels
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasEdgeBlurRadius` will be set to `true`
    Returns:
      The builder

  - ### regionColor

    public SubtitlesStyle.Builder regionColor(int regionColor, boolean overwrite)
    Set the region color as ARGB. Note that this overwrite the current opacity setting.
    Parameters:
      `regionColor` - The color as ARGB
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasRegionColor` will be set to `true`
    Returns:
      The builder

  - ### regionOpacity

    public SubtitlesStyle.Builder regionOpacity(float opacity)
    Set the opacity of the region color. The values needs to be 0 <= value <= 1.0.
    Parameters:
      `opacity` - The opacity as 0 <= value <= 1.0
    Returns:
      The builder

  - ### bottomMargin

    public SubtitlesStyle.Builder bottomMargin(int bottomMarginPx)
    Set the bottom margin in pixels, default is zero Note: not supported by com.castlabs.android.player.ExoSubtitlesRendererPlugin
    Parameters:
      `bottomMarginPx` - The bottom margin in pixels
    Returns:
      The builder

  - ### topMargin

    public SubtitlesStyle.Builder topMargin(int topMarginPx)
    Set the top margin in pixels, default is zero Note: not supported by com.castlabs.android.player.ExoSubtitlesRendererPlugin
    Parameters:
      `topMarginPx` - The top margin in pixels
    Returns:
      The builder

  - ### leftMargin

    public SubtitlesStyle.Builder leftMargin(int leftMarginPx)
    Set the left margin in pixels, default is zero Note: not supported by com.castlabs.android.player.ExoSubtitlesRendererPlugin
    Parameters:
      `leftMarginPx` - The left margin in pixels
    Returns:
      The builder

  - ### rightMargin

    public SubtitlesStyle.Builder rightMargin(int rightMarginPx)
    Set the right margin in pixels, default is zero Note: not supported by com.castlabs.android.player.ExoSubtitlesRendererPlugin
    Parameters:
      `rightMarginPx` - The right margin in pixels
    Returns:
      The builder

  - ### drawBeyondVideoArea

    public SubtitlesStyle.Builder drawBeyondVideoArea(boolean drawBeyondVideoArea)
    Enable or disable the drawing beyond video area, default is `false` Note: not supported by com.castlabs.android.player.ExoSubtitlesRendererPlugin
    Parameters:
      `drawBeyondVideoArea` - The draw beyond video area flag
    Returns:
      The builder

  - ### edgeColorRGB

    public SubtitlesStyle.Builder edgeColorRGB(int edgeColor, boolean overwrite)
    Set the edge color as RGB.
    Parameters:
      `edgeColor` - The color as RGB
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasEdgeColor` will be set to `true`
    Returns:
      The builder

  - ### edgeType

    public SubtitlesStyle.Builder edgeType(int edgeType, boolean overwrite)
    Set the edge type to one of `SubtitlesStyle.EDGE_TYPE_NONE`, `SubtitlesStyle.EDGE_TYPE_OUTLINE`, `SubtitlesStyle.EDGE_TYPE_DROP_SHADOW`, `SubtitlesStyle.EDGE_TYPE_RAISED`, or `SubtitlesStyle.EDGE_TYPE_DEPRESSED`.
    Parameters:
      `edgeType` - The edge type
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasEdgeType` will be set to `true`
    Returns:
      The builder

  - ### fontScale

    public SubtitlesStyle.Builder fontScale(float fontScale)
    Set the font scale. The value has to be > 0, otherwise the builder will fall back to the default font scale.
    Parameters:
      `fontScale` - The font scale
    Returns:
      The builder

  - ### fontSize

    public SubtitlesStyle.Builder fontSize(int fontSize, boolean overwrite)
    Set the font size in pixels
    Parameters:
      `fontSize` - The fontSize
      `overwrite` - If true, this is considers a user customization and the `SubtitlesStyle.hasFontSize` will be set to `true`
    Returns:
      The builder

  - ### regionAutoSizedToFit

    public SubtitlesStyle.Builder regionAutoSizedToFit(boolean regionAutoSizedToFit, boolean overwrite)
    Set the auto-sized to fit region.
    Parameters:
      `regionAutoSizedToFit` - The value to set
      `overwrite` - If true, this is considered a user customization and the `SubtitlesStyle.hasRegionAutoSizedToFit` will be set to `true`
    Returns:
      The builder

  - ### textAlign

    public SubtitlesStyle.Builder textAlign(int textAlign)
    Set the text alignment.
    Parameters:
      `textAlign` - The text alignment
    Returns:
      The builder

  - ### displayAlign

    public SubtitlesStyle.Builder displayAlign(int displayAlign)
    Set the display alignment.
    Parameters:
      `displayAlign` - The display alignment
    Returns:
      The builder

  - ### typeface

    public SubtitlesStyle.Builder typeface(@Nullable Typeface typeface)
    Set the typeface. `SubtitlesStyle.hasTypeface` will be set to true if the given typeface is not equal to the default type face. If null is passed, the typeface will be set to the default typeface.
    Parameters:
      `typeface` - The typeface
    Returns:
      The builder

  - ### disableAutoFlowText

    public SubtitlesStyle.Builder disableAutoFlowText(boolean disableAutoFlowText)
    If set to true the auto-flow text behaviour will be disabled regardless of the font-size and the font-scale.
    Parameters:
      `disableAutoFlowText` - The value
    Returns:
      The builder

  - ### foregroundOpacity

    public SubtitlesStyle.Builder foregroundOpacity(float opacity)
    Set the opacity of the foreground color. The values needs to be 0 <= value <= 1.0.
    Parameters:
      `opacity` - The opacity as 0 <= value <= 1.0
    Returns:
      The builder

  - ### backgroundOpacity

    public SubtitlesStyle.Builder backgroundOpacity(float opacity)
    Set the opacity of the background color. The values needs to be 0 <= value <= 1.0.
    Parameters:
      `opacity` - The opacity as 0 <= value <= 1.0
    Returns:
      The builder

  - ### windowOpacity

    public SubtitlesStyle.Builder windowOpacity(float opacity)
    Set the opacity of the window color. The values needs to be 0 <= value <= 1.0.
    Parameters:
      `opacity` - The opacity as 0 <= value <= 1.0
    Returns:
      The builder

  - ### imageScalingMode

    public SubtitlesStyle.Builder imageScalingMode(int imageScalingMode)
    Set the Image scaling mode for pre rendered subtitle images
    Parameters:
      `imageScalingMode` - the image scaling mode
    Returns:
      The Builder

  - ### get

    public SubtitlesStyle get()
    Create and return the new style from this builder.
    Returns:
      The new style created by this builder

  - ### create

    @NonNull public static SubtitlesStyle.Builder create(Context context, boolean useSystemSettings)
    Create a new instance of this builder. If `useSystemSettings` is `true`, the builder will be initialized based on the system configuration. Note that this only applies for Android API version >= 19.

    Please note that systems settings from API version >= 21 can be queried to check if a setting was overwritten by the user. For API versions 19 and 20, this is not possible, and the builder assumes that the system settings always overwrite the style.

    Parameters:
      `context` - The current context
      `useSystemSettings` - If true, the builder will be initialized with the system settings
    Returns:
      The builder

  - ### create

    @NonNull public static SubtitlesStyle.Builder create(@NonNull SubtitlesStyle subtitlesStyle)
    Create a new instance of this builder based on the provided subtitle style.
    Parameters:
      `subtitlesStyle` - The subtitle style to create the builder from
    Returns:
      The builder