Package com.castlabs.android.subtitles
Class SubtitlesStyle.Builder
- java.lang.Object
-
- com.castlabs.android.subtitles.SubtitlesStyle.Builder
-
- Enclosing class:
- SubtitlesStyle
public static class SubtitlesStyle.Builder extends Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SubtitlesStyle.BuilderbackgroundColor(int backgroundColor, boolean overwrite)Set the background color as ARGB.SubtitlesStyle.BuilderbackgroundColorRGB(int backgroundColor, boolean overwrite)Set the background color as RGB.SubtitlesStyle.BuilderbackgroundOpacity(float opacity)Set the opacity of the background color.SubtitlesStyle.BuilderbottomMargin(int bottomMarginPx)Set the bottom margin in pixels, default is zero Note: not supported byExoSubtitlesRendererPluginstatic SubtitlesStyle.Buildercreate(Context context, boolean useSystemSettings)Create a new instance of this builder.static SubtitlesStyle.Buildercreate(SubtitlesStyle subtitlesStyle)Create a new instance of this builder based on the provided subtitle style.SubtitlesStyle.BuilderdrawBeyondVideoArea(boolean drawBeyondVideoArea)Enable or disable the drawing beyond video area, default isfalseNote: not supported byExoSubtitlesRendererPluginSubtitlesStyle.BuilderedgeBlurRadius(int edgeBlurRadius, boolean overwrite)Set the edge blur radius in pixels.SubtitlesStyle.BuilderedgeColor(int edgeColor, boolean overwrite)Set the edge color as ARGB.SubtitlesStyle.BuilderedgeColorRGB(int edgeColor, boolean overwrite)Set the edge color as RGB.SubtitlesStyle.BuilderedgeThickness(int edgeThickness, boolean overwrite)Set the edge thickness in pixels.SubtitlesStyle.BuilderedgeType(int edgeType, boolean overwrite)SubtitlesStyle.BuilderfontScale(float fontScale)Set the font scale.SubtitlesStyle.BuilderfontSize(int fontSize, boolean overwrite)Set the font size in pixelsSubtitlesStyle.BuilderforegroundColor(int foregroundColor, boolean overwrite)Set the foreground color as ARGB.SubtitlesStyle.BuilderforegroundColorRGB(int foregroundColor, boolean overwrite)Set the foreground color as RGBSubtitlesStyle.BuilderforegroundOpacity(float opacity)Set the opacity of the foreground color.SubtitlesStyleget()Create and return the new style from this builder.SubtitlesStyle.BuilderimageScalingMode(int imageScalingMode)Set the Image scaling mode for pre rendered subtitle imagesSubtitlesStyle.BuilderleftMargin(int leftMarginPx)Set the left margin in pixels, default is zero Note: not supported byExoSubtitlesRendererPluginSubtitlesStyle.BuilderregionColor(int regionColor, boolean overwrite)Set the region color as ARGB.SubtitlesStyle.BuilderregionOpacity(float opacity)Set the opacity of the region color.SubtitlesStyle.BuilderrightMargin(int rightMarginPx)Set the right margin in pixels, default is zero Note: not supported byExoSubtitlesRendererPluginSubtitlesStyle.BuildertopMargin(int topMarginPx)Set the top margin in pixels, default is zero Note: not supported byExoSubtitlesRendererPluginSubtitlesStyle.Buildertypeface(Typeface typeface)Set the typeface.SubtitlesStyle.BuilderwindowColor(int windowColor, boolean overwrite)Set the window color as ARGB.SubtitlesStyle.BuilderwindowColorRGB(int windowColor, boolean overwrite)Set the window color as RGB.SubtitlesStyle.BuilderwindowOpacity(float opacity)Set the opacity of the window color.
-
-
-
Method Detail
-
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 ARGBoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasForegroundColorwill be set totrue- Returns:
- The builder
-
foregroundColorRGB
public SubtitlesStyle.Builder foregroundColorRGB(int foregroundColor, boolean overwrite)
Set the foreground color as RGB- Parameters:
foregroundColor- The color as RGBoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasForegroundColorwill be set totrue- 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 ARGBoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasBackgroundColorwill be set totrue- Returns:
- The builder
-
backgroundColorRGB
public SubtitlesStyle.Builder backgroundColorRGB(int backgroundColor, boolean overwrite)
Set the background color as RGB.- Parameters:
backgroundColor- The color as RGBoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasBackgroundColorwill be set totrue- 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 ARGBoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasWindowColorwill be set totrue- Returns:
- The builder
-
windowColorRGB
public SubtitlesStyle.Builder windowColorRGB(int windowColor, boolean overwrite)
Set the window color as RGB.- Parameters:
windowColor- The color as RGBoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasWindowColorwill be set totrue- 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 ARGBoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasEdgeColorwill be set totrue- Returns:
- The builder
-
edgeThickness
public SubtitlesStyle.Builder edgeThickness(int edgeThickness, boolean overwrite)
Set the edge thickness in pixels.- Parameters:
edgeThickness- The edge thickness in pixelsoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasEdgeThicknesswill be set totrue- 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 pixelsoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasEdgeBlurRadiuswill be set totrue- 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 ARGBoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasRegionColorwill be set totrue- 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 byExoSubtitlesRendererPlugin- 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 byExoSubtitlesRendererPlugin- 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 byExoSubtitlesRendererPlugin- 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 byExoSubtitlesRendererPlugin- 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 isfalseNote: not supported byExoSubtitlesRendererPlugin- 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 RGBoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasEdgeColorwill be set totrue- Returns:
- The builder
-
edgeType
public SubtitlesStyle.Builder edgeType(int edgeType, boolean overwrite)
Set the edge type to one ofSubtitlesStyle.EDGE_TYPE_NONE,SubtitlesStyle.EDGE_TYPE_OUTLINE,SubtitlesStyle.EDGE_TYPE_DROP_SHADOW,SubtitlesStyle.EDGE_TYPE_RAISED, orSubtitlesStyle.EDGE_TYPE_DEPRESSED.- Parameters:
edgeType- The edge typeoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasEdgeTypewill be set totrue- 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 fontSizeoverwrite- If true, this is considers a user customization and theSubtitlesStyle.hasFontSizewill be set totrue- Returns:
- The builder
-
typeface
public SubtitlesStyle.Builder typeface(@Nullable Typeface typeface)
Set the typeface.SubtitlesStyle.hasTypefacewill 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
-
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. IfuseSystemSettingsistrue, 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 contextuseSystemSettings- 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
-
-