-
-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add subtitles font size and background switch
Added five font sizes to choose from (Extra Large, Large, Normal, Small, Extra Small) Added an option to disable the subtitles black background and text outline
- Loading branch information
1 parent
b21a222
commit f2cd547
Showing
6 changed files
with
157 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/src/main/java/org/jellyfin/androidtv/preference/constant/SubtitlesSize.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.jellyfin.androidtv.preference.constant | ||
|
||
import org.jellyfin.androidtv.R | ||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions | ||
|
||
enum class SubtitlesSize { | ||
/** | ||
* Sets the subtitles size to huge. | ||
*/ | ||
@EnumDisplayOptions(R.string.subs_size_xlarge) | ||
SUBS_SIZE_XLARGE, | ||
|
||
/** | ||
* Sets the subtitles size to big. | ||
*/ | ||
@EnumDisplayOptions(R.string.subs_size_large) | ||
SUBS_SIZE_LARGE, | ||
|
||
/** | ||
* Sets the subtitles size to normal. | ||
*/ | ||
@EnumDisplayOptions(R.string.subs_size_normal) | ||
SUBS_SIZE_NORMAL, | ||
|
||
/** | ||
* Sets the subtitles size to small. | ||
*/ | ||
@EnumDisplayOptions(R.string.subs_size_small) | ||
SUBS_SIZE_SMALL, | ||
|
||
/** | ||
* Sets the subtitles size to xsmall. | ||
*/ | ||
@EnumDisplayOptions(R.string.subs_size_xsmall) | ||
SUBS_SIZE_XSMALL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
app/src/main/java/org/jellyfin/androidtv/ui/shared/OutlineSpan.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.jellyfin.androidtv.ui.shared | ||
|
||
import android.graphics.Canvas | ||
import android.graphics.Paint | ||
import android.text.style.ReplacementSpan; | ||
import androidx.annotation.ColorInt | ||
import androidx.annotation.Dimension | ||
|
||
class OutlineSpan( | ||
@ColorInt private val strokeColor: Int, | ||
@Dimension private val strokeWidth: Float | ||
): ReplacementSpan() { | ||
|
||
override fun getSize( | ||
paint: Paint, | ||
text: CharSequence, | ||
start: Int, | ||
end: Int, | ||
fontMetrics: Paint.FontMetricsInt? | ||
): Int { | ||
if (fontMetrics != null && paint.fontMetricsInt != null) { | ||
fontMetrics.bottom = paint.fontMetricsInt.bottom | ||
fontMetrics.top = paint.fontMetricsInt.top | ||
fontMetrics.descent = paint.fontMetricsInt.descent | ||
fontMetrics.leading = paint.fontMetricsInt.leading | ||
fontMetrics.ascent = paint.fontMetricsInt.ascent; | ||
} | ||
return paint.measureText(text.toString().substring(start until end)).toInt() | ||
} | ||
|
||
|
||
override fun draw( | ||
canvas: Canvas, | ||
text: CharSequence, | ||
start: Int, | ||
end: Int, | ||
x: Float, | ||
top: Int, | ||
y: Int, | ||
bottom: Int, | ||
paint: Paint | ||
) { | ||
val originTextColor = paint.color | ||
|
||
paint.apply { | ||
color = strokeColor | ||
style = Paint.Style.STROKE | ||
this.strokeWidth = this@OutlineSpan.strokeWidth | ||
} | ||
canvas.drawText(text, start, end, x, y.toFloat(), paint) | ||
|
||
paint.apply { | ||
color = originTextColor | ||
style = Paint.Style.FILL | ||
} | ||
canvas.drawText(text, start, end, x, y.toFloat(), paint) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters