Skip to content

SubtitleView more options for CaptionStyleCompat #10507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LagradOst opened this issue Aug 6, 2022 · 2 comments
Closed

SubtitleView more options for CaptionStyleCompat #10507

LagradOst opened this issue Aug 6, 2022 · 2 comments
Assignees

Comments

@LagradOst
Copy link

LagradOst commented Aug 6, 2022

Missing outlineWidth option

Currently I am trying to add subtitle options into my app, however I am missing the option to set the outline width as CaptionStyleCompat does not include it. It looks like SubtitlePainter sets these to Math.round((2f * displayMetrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT); and has no options to change it in runtime.

Proposed solution

Simply add outlineWidth/shadowRadius/shadowOffset as an option in CaptionStyleCompat and use those in SubtitlePainter.

Alternatives considered

Remove final from SubtitleView and SubtitlePainter so users can override specific parts.

@LagradOst
Copy link
Author

Possible duplicate of #9391

@icbaker
Copy link
Collaborator

icbaker commented Aug 15, 2022

CaptionStyleCompat contains the same properties as android.view.accessibility.CaptioningManager.CaptionStyle. These are also the same properties that an end-user can customise.

I'm afraid we won't be adding additional properties to this class.


Remove final from SubtitleView and SubtitlePainter so users can override specific parts.

These classes are not designed for to be inherited from, so it's deliberately forbidden. See Item 19 of Effective Java 3rd Edition: "Design and document for inheritance or else prohibit it".


I think the 'right' way to support customising this property of subtitles is to add it to Cue (either as a cue-level property, or a (possibly custom) styling span inside Cue.text) and update SubtitlePainter to respect this property (in the same way it considers e.g. the foreground color from both Cue and CaptionStyleCompat). This would be done as part of #9391 (in addition to parsing it from the TTML source file).

If this was done, you could then either use TTML subtitles to get support for this property, or mutate Cue objects before they're displayed on the screen to set this property, as described in #7243 (comment).

Given this is a subset of the work required for #9391, I'm going to mark it as a duplicate.

@icbaker icbaker closed this as completed Aug 15, 2022
@google google locked and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants