feat(subtitles): color picker. Clear data after this. (#547)

* feat(subtitle): custom color picker

* can't have two of the same buttons smh

* It was a misinput

* Too much
This commit is contained in:
Sadwhy 2024-12-19 10:33:15 +06:00 committed by GitHub
parent 01a64c25fd
commit 6f1bb10dec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 286 additions and 413 deletions

View file

@ -327,36 +327,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
} }
private fun setupSubFormatting(playerView: PlayerView) { private fun setupSubFormatting(playerView: PlayerView) {
val primaryColor = when (PrefManager.getVal<Int>(PrefName.PrimaryColor)) { val primaryColor = PrefManager.getVal<Int>(PrefName.PrimaryColor)
0 -> Color.BLACK
1 -> Color.DKGRAY val secondaryColor = PrefManager.getVal<Int>(PrefName.SecondaryColor)
2 -> Color.GRAY
3 -> Color.LTGRAY
4 -> Color.WHITE
5 -> Color.RED
6 -> Color.YELLOW
7 -> Color.GREEN
8 -> Color.CYAN
9 -> Color.BLUE
10 -> Color.MAGENTA
11 -> Color.TRANSPARENT
else -> Color.WHITE
}
val secondaryColor = when (PrefManager.getVal<Int>(PrefName.SecondaryColor)) {
0 -> Color.BLACK
1 -> Color.DKGRAY
2 -> Color.GRAY
3 -> Color.LTGRAY
4 -> Color.WHITE
5 -> Color.RED
6 -> Color.YELLOW
7 -> Color.GREEN
8 -> Color.CYAN
9 -> Color.BLUE
10 -> Color.MAGENTA
11 -> Color.TRANSPARENT
else -> Color.BLACK
}
val outline = when (PrefManager.getVal<Int>(PrefName.Outline)) { val outline = when (PrefManager.getVal<Int>(PrefName.Outline)) {
0 -> EDGE_TYPE_OUTLINE // Normal 0 -> EDGE_TYPE_OUTLINE // Normal
1 -> EDGE_TYPE_DEPRESSED // Shine 1 -> EDGE_TYPE_DEPRESSED // Shine
@ -364,36 +338,11 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
3 -> EDGE_TYPE_NONE // No outline 3 -> EDGE_TYPE_NONE // No outline
else -> EDGE_TYPE_OUTLINE // Normal else -> EDGE_TYPE_OUTLINE // Normal
} }
val subBackground = when (PrefManager.getVal<Int>(PrefName.SubBackground)) {
0 -> Color.TRANSPARENT val subBackground = PrefManager.getVal<Int>(PrefName.SubBackground)
1 -> Color.BLACK
2 -> Color.DKGRAY val subWindow = PrefManager.getVal<Int>(PrefName.SubWindow)
3 -> Color.GRAY
4 -> Color.LTGRAY
5 -> Color.WHITE
6 -> Color.RED
7 -> Color.YELLOW
8 -> Color.GREEN
9 -> Color.CYAN
10 -> Color.BLUE
11 -> Color.MAGENTA
else -> Color.TRANSPARENT
}
val subWindow = when (PrefManager.getVal<Int>(PrefName.SubWindow)) {
0 -> Color.TRANSPARENT
1 -> Color.BLACK
2 -> Color.DKGRAY
3 -> Color.GRAY
4 -> Color.LTGRAY
5 -> Color.WHITE
6 -> Color.RED
7 -> Color.YELLOW
8 -> Color.GREEN
9 -> Color.CYAN
10 -> Color.BLUE
11 -> Color.MAGENTA
else -> Color.TRANSPARENT
}
val font = when (PrefManager.getVal<Int>(PrefName.Font)) { val font = when (PrefManager.getVal<Int>(PrefName.Font)) {
0 -> ResourcesCompat.getFont(this, R.font.poppins_semi_bold) 0 -> ResourcesCompat.getFont(this, R.font.poppins_semi_bold)
1 -> ResourcesCompat.getFont(this, R.font.poppins_bold) 1 -> ResourcesCompat.getFont(this, R.font.poppins_bold)
@ -432,37 +381,15 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
} }
private fun applySubtitleStyles(textView: Xubtitle) { private fun applySubtitleStyles(textView: Xubtitle) {
val primaryColor = when (PrefManager.getVal<Int>(PrefName.PrimaryColor)) { val primaryColor = PrefManager.getVal<Int>(PrefName.PrimaryColor)
0 -> Color.BLACK
1 -> Color.DKGRAY
2 -> Color.GRAY
3 -> Color.LTGRAY
4 -> Color.WHITE
5 -> Color.RED
6 -> Color.YELLOW
7 -> Color.GREEN
8 -> Color.CYAN
9 -> Color.BLUE
10 -> Color.MAGENTA
11 -> Color.TRANSPARENT
else -> Color.WHITE
}
val subBackground = when (PrefManager.getVal<Int>(PrefName.SubBackground)) { val subBackground = PrefManager.getVal<Int>(PrefName.SubBackground)
0 -> Color.TRANSPARENT
1 -> Color.BLACK val secondaryColor = PrefManager.getVal<Int>(PrefName.SecondaryColor)
2 -> Color.DKGRAY
3 -> Color.GRAY val subStroke = PrefManager.getVal<Float>(PrefName.SubStroke)
4 -> Color.LTGRAY
5 -> Color.WHITE val fontSize = PrefManager.getVal<Int>(PrefName.FontSize).toFloat()
6 -> Color.RED
7 -> Color.YELLOW
8 -> Color.GREEN
9 -> Color.CYAN
10 -> Color.BLUE
11 -> Color.MAGENTA
else -> Color.TRANSPARENT
}
val font = when (PrefManager.getVal<Int>(PrefName.Font)) { val font = when (PrefManager.getVal<Int>(PrefName.Font)) {
0 -> ResourcesCompat.getFont(this, R.font.poppins_semi_bold) 0 -> ResourcesCompat.getFont(this, R.font.poppins_semi_bold)
@ -475,31 +402,11 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
else -> ResourcesCompat.getFont(this, R.font.poppins_semi_bold) else -> ResourcesCompat.getFont(this, R.font.poppins_semi_bold)
} }
val fontSize = PrefManager.getVal<Int>(PrefName.FontSize).toFloat()
textView.setBackgroundColor(subBackground) textView.setBackgroundColor(subBackground)
textView.setTextColor(primaryColor) textView.setTextColor(primaryColor)
textView.typeface = font textView.typeface = font
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize) textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize)
val secondaryColor = when (PrefManager.getVal<Int>(PrefName.SecondaryColor)) {
0 -> Color.BLACK
1 -> Color.DKGRAY
2 -> Color.GRAY
3 -> Color.LTGRAY
4 -> Color.WHITE
5 -> Color.RED
6 -> Color.YELLOW
7 -> Color.GREEN
8 -> Color.CYAN
9 -> Color.BLUE
10 -> Color.MAGENTA
11 -> Color.TRANSPARENT
else -> Color.BLACK
}
val subStroke = PrefManager.getVal<Float>(PrefName.SubStroke)
textView.apply { textView.apply {
when (PrefManager.getVal<Int>(PrefName.Outline)) { when (PrefManager.getVal<Int>(PrefName.Outline)) {
0 -> applyOutline(secondaryColor, subStroke) 0 -> applyOutline(secondaryColor, subStroke)
@ -516,7 +423,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
false -> 0f false -> 0f
} }
val textElevation = PrefManager.getVal<Float>(PrefName.SubBottomMargin) / 30 * resources.displayMetrics.heightPixels val textElevation = PrefManager.getVal<Float>(PrefName.SubBottomMargin) / 50 * resources.displayMetrics.heightPixels
textView.translationY = -textElevation textView.translationY = -textElevation
} }

View file

@ -1,9 +1,6 @@
package ani.dantotsu.settings package ani.dantotsu.settings
import android.app.AlertDialog
import android.app.Dialog
import android.content.res.Resources import android.content.res.Resources
import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.util.TypedValue import android.util.TypedValue
@ -31,9 +28,19 @@ import ani.dantotsu.themes.ThemeManager
import ani.dantotsu.toast import ani.dantotsu.toast
import ani.dantotsu.util.customAlertDialog import ani.dantotsu.util.customAlertDialog
import com.google.android.material.slider.Slider.OnChangeListener import com.google.android.material.slider.Slider.OnChangeListener
import eltos.simpledialogfragment.SimpleDialog
import eltos.simpledialogfragment.color.SimpleColorWheelDialog
import kotlin.math.roundToInt import kotlin.math.roundToInt
class PlayerSettingsActivity : AppCompatActivity() { class PlayerSettingsActivity :
AppCompatActivity(),
SimpleDialog.OnDialogResultListener {
interface ColorPickerCallback {
fun onColorSelected(color: Int)
}
private var colorPickerCallback: ColorPickerCallback? = null
lateinit var binding: ActivityPlayerSettingsBinding lateinit var binding: ActivityPlayerSettingsBinding
private val player = "player_settings" private val player = "player_settings"
@ -41,8 +48,11 @@ class PlayerSettingsActivity : AppCompatActivity() {
var subtitle: Subtitle? = null var subtitle: Subtitle? = null
private val Int.toSP private val Int.toSP
get() = TypedValue.applyDimension( get() =
TypedValue.COMPLEX_UNIT_SP, this.toFloat(), Resources.getSystem().displayMetrics TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP,
this.toFloat(),
Resources.getSystem().displayMetrics,
) )
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -70,7 +80,6 @@ class PlayerSettingsActivity : AppCompatActivity() {
bottomMargin = navBarHeight bottomMargin = navBarHeight
} }
binding.playerSettingsBack.setOnClickListener { binding.playerSettingsBack.setOnClickListener {
onBackPressedDispatcher.onBackPressed() onBackPressedDispatcher.onBackPressed()
} }
@ -91,7 +100,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
1.5f, 1.5f,
1.66f, 1.66f,
1.75f, 1.75f,
2f 2f,
) )
val cursedSpeeds = arrayOf(1f, 1.25f, 1.5f, 1.75f, 2f, 2.5f, 3f, 4f, 5f, 10f, 25f, 50f) val cursedSpeeds = arrayOf(1f, 1.25f, 1.5f, 1.75f, 2f, 2.5f, 3f, 4f, 5f, 10f, 25f, 50f)
var curSpeedArr = if (PrefManager.getVal(PrefName.CursedSpeeds)) cursedSpeeds else speeds var curSpeedArr = if (PrefManager.getVal(PrefName.CursedSpeeds)) cursedSpeeds else speeds
@ -99,14 +108,14 @@ class PlayerSettingsActivity : AppCompatActivity() {
binding.playerSettingsSpeed.text = binding.playerSettingsSpeed.text =
getString( getString(
R.string.default_playback_speed, R.string.default_playback_speed,
speedsName[PrefManager.getVal(PrefName.DefaultSpeed)] speedsName[PrefManager.getVal(PrefName.DefaultSpeed)],
) )
binding.playerSettingsSpeed.setOnClickListener { binding.playerSettingsSpeed.setOnClickListener {
customAlertDialog().apply { customAlertDialog().apply {
setTitle(getString(R.string.default_speed)) setTitle(getString(R.string.default_speed))
singleChoiceItems( singleChoiceItems(
speedsName, speedsName,
PrefManager.getVal(PrefName.DefaultSpeed) PrefManager.getVal(PrefName.DefaultSpeed),
) { i -> ) { i ->
PrefManager.setVal(PrefName.DefaultSpeed, i) PrefManager.setVal(PrefName.DefaultSpeed, i)
binding.playerSettingsSpeed.text = binding.playerSettingsSpeed.text =
@ -126,11 +135,10 @@ class PlayerSettingsActivity : AppCompatActivity() {
binding.playerSettingsSpeed.text = binding.playerSettingsSpeed.text =
getString( getString(
R.string.default_playback_speed, R.string.default_playback_speed,
speedsName[PrefManager.getVal(PrefName.DefaultSpeed)] speedsName[PrefManager.getVal(PrefName.DefaultSpeed)],
) )
} }
// Time Stamp // Time Stamp
binding.playerSettingsTimeStamps.isChecked = PrefManager.getVal(PrefName.TimeStampsEnabled) binding.playerSettingsTimeStamps.isChecked = PrefManager.getVal(PrefName.TimeStampsEnabled)
binding.playerSettingsTimeStamps.setOnCheckedChangeListener { _, isChecked -> binding.playerSettingsTimeStamps.setOnCheckedChangeListener { _, isChecked ->
@ -245,7 +253,10 @@ class PlayerSettingsActivity : AppCompatActivity() {
false false
} }
binding.exoSkipTime.addTextChangedListener { binding.exoSkipTime.addTextChangedListener {
val time = binding.exoSkipTime.text.toString().toIntOrNull() val time =
binding.exoSkipTime.text
.toString()
.toIntOrNull()
if (time != null) { if (time != null) {
PrefManager.setVal(PrefName.SkipTime, time) PrefManager.setVal(PrefName.SkipTime, time)
} }
@ -259,7 +270,9 @@ class PlayerSettingsActivity : AppCompatActivity() {
setOnCheckedChangeListener { _, isChecked -> setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.Pip, isChecked) PrefManager.setVal(PrefName.Pip, isChecked)
} }
} else visibility = View.GONE } else {
visibility = View.GONE
}
} }
binding.playerSettingsCast.isChecked = PrefManager.getVal(PrefName.Cast) binding.playerSettingsCast.isChecked = PrefManager.getVal(PrefName.Cast)
@ -288,7 +301,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
setTitle(getString(R.string.default_resize_mode)) setTitle(getString(R.string.default_resize_mode))
singleChoiceItems( singleChoiceItems(
resizeModes, resizeModes,
PrefManager.getVal<Int>(PrefName.Resize) PrefManager.getVal<Int>(PrefName.Resize),
) { count -> ) { count ->
PrefManager.setVal(PrefName.Resize, count) PrefManager.setVal(PrefName.Resize, count)
} }
@ -310,10 +323,11 @@ class PlayerSettingsActivity : AppCompatActivity() {
binding.subtitleFontSizeText, binding.subtitleFontSizeText,
binding.subtitleFontSize, binding.subtitleFontSize,
binding.videoSubLanguage, binding.videoSubLanguage,
binding.subTextSwitch binding.subTextSwitch,
).forEach { ).forEach {
it.isEnabled = isChecked it.isEnabled = isChecked
it.alpha = when (isChecked) { it.alpha =
when (isChecked) {
true -> 1f true -> 1f
false -> 0.5f false -> 0.5f
} }
@ -325,10 +339,11 @@ class PlayerSettingsActivity : AppCompatActivity() {
binding.videoSubStrokeButton, binding.videoSubStrokeButton,
binding.videoSubStroke, binding.videoSubStroke,
binding.videoSubBottomMarginButton, binding.videoSubBottomMarginButton,
binding.videoSubBottomMargin binding.videoSubBottomMargin,
).forEach { ).forEach {
it.isEnabled = isChecked it.isEnabled = isChecked
it.alpha = when (isChecked) { it.alpha =
when (isChecked) {
true -> 1f true -> 1f
false -> 0.5f false -> 0.5f
} }
@ -350,7 +365,8 @@ class PlayerSettingsActivity : AppCompatActivity() {
} }
toggleExpSubOptions(binding.subTextSwitch.isChecked) toggleExpSubOptions(binding.subTextSwitch.isChecked)
val subLanguages = arrayOf( val subLanguages =
arrayOf(
"Albanian", "Albanian",
"Arabic", "Arabic",
"Bosnian", "Bosnian",
@ -398,74 +414,51 @@ class PlayerSettingsActivity : AppCompatActivity() {
setTitle(getString(R.string.subtitle_langauge)) setTitle(getString(R.string.subtitle_langauge))
singleChoiceItems( singleChoiceItems(
subLanguages, subLanguages,
PrefManager.getVal(PrefName.SubLanguage) PrefManager.getVal(PrefName.SubLanguage),
) { count -> ) { count ->
PrefManager.setVal(PrefName.SubLanguage, count) PrefManager.setVal(PrefName.SubLanguage, count)
} }
show() show()
} }
} }
val colorsPrimary =
arrayOf(
"Black",
"Dark Gray",
"Gray",
"Light Gray",
"White",
"Red",
"Yellow",
"Green",
"Cyan",
"Blue",
"Magenta"
)
binding.videoSubColorPrimary.setOnClickListener { binding.videoSubColorPrimary.setOnClickListener {
customAlertDialog().apply { val color = PrefManager.getVal<Int>(PrefName.PrimaryColor)
setTitle(getString(R.string.primary_sub_color)) val title = getString(R.string.primary_sub_color)
singleChoiceItems( showColorPicker(
colorsPrimary, color,
PrefManager.getVal(PrefName.PrimaryColor) title,
) { count -> object : ColorPickerCallback {
PrefManager.setVal(PrefName.PrimaryColor, count) override fun onColorSelected(color: Int) {
PrefManager.setVal(PrefName.PrimaryColor, color)
updateSubPreview() updateSubPreview()
} }
show() },
}
}
val colorsSecondary = arrayOf(
"Black",
"Dark Gray",
"Gray",
"Light Gray",
"White",
"Red",
"Yellow",
"Green",
"Cyan",
"Blue",
"Magenta",
"Transparent"
) )
}
binding.videoSubColorSecondary.setOnClickListener { binding.videoSubColorSecondary.setOnClickListener {
customAlertDialog().apply { val color = PrefManager.getVal<Int>(PrefName.SecondaryColor)
setTitle(getString(R.string.outline_sub_color)) val title = getString(R.string.outline_sub_color)
singleChoiceItems( showColorPicker(
colorsSecondary, color,
PrefManager.getVal(PrefName.SecondaryColor) title,
) { count -> object : ColorPickerCallback {
PrefManager.setVal(PrefName.SecondaryColor, count) override fun onColorSelected(color: Int) {
PrefManager.setVal(PrefName.SecondaryColor, color)
updateSubPreview() updateSubPreview()
} }
show() },
} )
} }
val typesOutline = arrayOf("Outline", "Shine", "Drop Shadow", "None") val typesOutline = arrayOf("Outline", "Shine", "Drop Shadow", "None")
binding.videoSubOutline.setOnClickListener { binding.videoSubOutline.setOnClickListener {
customAlertDialog().apply { customAlertDialog().apply {
setTitle(getString(R.string.outline_type)) setTitle(getString(R.string.outline_type))
singleChoiceItems( singleChoiceItems(
typesOutline, typesOutline,
PrefManager.getVal(PrefName.Outline) PrefManager.getVal(PrefName.Outline),
) { count -> ) { count ->
PrefManager.setVal(PrefName.Outline, count) PrefManager.setVal(PrefName.Outline, count)
updateSubPreview() updateSubPreview()
@ -473,101 +466,83 @@ class PlayerSettingsActivity : AppCompatActivity() {
show() show()
} }
} }
val colorsSubBackground = arrayOf(
"Transparent",
"Black",
"Dark Gray",
"Gray",
"Light Gray",
"White",
"Red",
"Yellow",
"Green",
"Cyan",
"Blue",
"Magenta"
)
binding.videoSubColorBackground.setOnClickListener { binding.videoSubColorBackground.setOnClickListener {
customAlertDialog().apply { val color = PrefManager.getVal<Int>(PrefName.SubBackground)
setTitle(getString(R.string.sub_background_color_select)) val title = getString(R.string.sub_background_color_select)
singleChoiceItems( showColorPicker(
colorsSubBackground, color,
PrefManager.getVal(PrefName.SubBackground) title,
) { count -> object : ColorPickerCallback {
PrefManager.setVal(PrefName.SubBackground, count) override fun onColorSelected(color: Int) {
PrefManager.setVal(PrefName.SubBackground, color)
updateSubPreview() updateSubPreview()
} }
show() },
} )
} }
val colorsSubWindow = arrayOf(
"Transparent",
"Black",
"Dark Gray",
"Gray",
"Light Gray",
"White",
"Red",
"Yellow",
"Green",
"Cyan",
"Blue",
"Magenta"
)
binding.videoSubColorWindow.setOnClickListener { binding.videoSubColorWindow.setOnClickListener {
customAlertDialog().apply { val color = PrefManager.getVal<Int>(PrefName.SubWindow)
setTitle(getString(R.string.sub_window_color_select)) val title = getString(R.string.sub_window_color_select)
singleChoiceItems( showColorPicker(
colorsSubWindow, color,
PrefManager.getVal(PrefName.SubWindow) title,
) { count -> object : ColorPickerCallback {
PrefManager.setVal(PrefName.SubWindow, count) override fun onColorSelected(color: Int) {
PrefManager.setVal(PrefName.SubWindow, color)
updateSubPreview() updateSubPreview()
} }
show() },
} )
} }
binding.videoSubAlpha.value = PrefManager.getVal(PrefName.SubAlpha) binding.videoSubAlpha.value = PrefManager.getVal(PrefName.SubAlpha)
binding.videoSubAlpha.addOnChangeListener(OnChangeListener { _, value, fromUser -> binding.videoSubAlpha.addOnChangeListener(
OnChangeListener { _, value, fromUser ->
if (fromUser) { if (fromUser) {
PrefManager.setVal(PrefName.SubAlpha, value) PrefManager.setVal(PrefName.SubAlpha, value)
updateSubPreview() updateSubPreview()
} }
}) },
)
binding.videoSubStroke.value = PrefManager.getVal(PrefName.SubStroke) binding.videoSubStroke.value = PrefManager.getVal(PrefName.SubStroke)
binding.videoSubStroke.addOnChangeListener(OnChangeListener { _, value, fromUser -> binding.videoSubStroke.addOnChangeListener(
OnChangeListener { _, value, fromUser ->
if (fromUser) { if (fromUser) {
PrefManager.setVal(PrefName.SubStroke, value) PrefManager.setVal(PrefName.SubStroke, value)
updateSubPreview() updateSubPreview()
} }
}) },
)
binding.videoSubBottomMargin.value = PrefManager.getVal(PrefName.SubBottomMargin) binding.videoSubBottomMargin.value = PrefManager.getVal(PrefName.SubBottomMargin)
binding.videoSubBottomMargin.addOnChangeListener(OnChangeListener { _, value, fromUser -> binding.videoSubBottomMargin.addOnChangeListener(
OnChangeListener { _, value, fromUser ->
if (fromUser) { if (fromUser) {
PrefManager.setVal(PrefName.SubBottomMargin, value) PrefManager.setVal(PrefName.SubBottomMargin, value)
updateSubPreview() updateSubPreview()
} }
}) },
)
val fonts = arrayOf( val fonts =
arrayOf(
"Poppins Semi Bold", "Poppins Semi Bold",
"Poppins Bold", "Poppins Bold",
"Poppins", "Poppins",
"Poppins Thin", "Poppins Thin",
"Century Gothic", "Century Gothic",
"Levenim MT Bold", "Levenim MT Bold",
"Blocky" "Blocky",
) )
binding.videoSubFont.setOnClickListener { binding.videoSubFont.setOnClickListener {
customAlertDialog().apply { customAlertDialog().apply {
setTitle(getString(R.string.subtitle_font)) setTitle(getString(R.string.subtitle_font))
singleChoiceItems( singleChoiceItems(
fonts, fonts,
PrefManager.getVal(PrefName.Font) PrefManager.getVal(PrefName.Font),
) { count -> ) { count ->
PrefManager.setVal(PrefName.Font, count) PrefManager.setVal(PrefName.Font, count)
updateSubPreview() updateSubPreview()
@ -583,46 +558,67 @@ class PlayerSettingsActivity : AppCompatActivity() {
false false
} }
binding.subtitleFontSize.addTextChangedListener { binding.subtitleFontSize.addTextChangedListener {
val size = binding.subtitleFontSize.text.toString().toIntOrNull() val size =
binding.subtitleFontSize.text
.toString()
.toIntOrNull()
if (size != null) { if (size != null) {
PrefManager.setVal(PrefName.FontSize, size) PrefManager.setVal(PrefName.FontSize, size)
updateSubPreview() updateSubPreview()
} }
} }
binding.subtitleTest.addOnChangeListener(object : Xpandable.OnChangeListener { binding.subtitleTest.addOnChangeListener(
object : Xpandable.OnChangeListener {
override fun onExpand() { override fun onExpand() {
updateSubPreview() updateSubPreview()
} }
override fun onRetract() {} override fun onRetract() {}
}) },
)
updateSubPreview() updateSubPreview()
} }
private fun showColorPicker(
originalColor: Int,
title: String,
callback: ColorPickerCallback,
) {
colorPickerCallback = callback
SimpleColorWheelDialog()
.title(title)
.color(originalColor)
.alpha(true)
.neg()
.theme(R.style.MyPopup)
.show(this, "colorPicker")
}
override fun onResult(
dialogTag: String,
which: Int,
extras: Bundle,
): Boolean {
if (dialogTag == "colorPicker" && which == SimpleDialog.OnDialogResultListener.BUTTON_POSITIVE) {
val color = extras.getInt(SimpleColorWheelDialog.COLOR)
colorPickerCallback?.onColorSelected(color)
return true
}
return false
}
private fun updateSubPreview() { private fun updateSubPreview() {
binding.subtitleTestWindow.run { binding.subtitleTestWindow.run {
alpha = PrefManager.getVal(PrefName.SubAlpha) alpha = PrefManager.getVal(PrefName.SubAlpha)
setBackgroundColor( setBackgroundColor(PrefManager.getVal(PrefName.SubWindow))
when (PrefManager.getVal<Int>(PrefName.SubWindow)) {
0 -> Color.TRANSPARENT
1 -> Color.BLACK
2 -> Color.DKGRAY
3 -> Color.GRAY
4 -> Color.LTGRAY
5 -> Color.WHITE
6 -> Color.RED
7 -> Color.YELLOW
8 -> Color.GREEN
9 -> Color.CYAN
10 -> Color.BLUE
11 -> Color.MAGENTA
else -> Color.TRANSPARENT
}
)
} }
binding.subtitleTestText.run { binding.subtitleTestText.run {
textSize = PrefManager.getVal<Int>(PrefName.FontSize).toSP textSize = PrefManager.getVal<Int>(PrefName.FontSize).toSP
typeface = when (PrefManager.getVal<Int>(PrefName.Font)) { typeface =
when (PrefManager.getVal<Int>(PrefName.Font)) {
0 -> ResourcesCompat.getFont(this.context, R.font.poppins_semi_bold) 0 -> ResourcesCompat.getFont(this.context, R.font.poppins_semi_bold)
1 -> ResourcesCompat.getFont(this.context, R.font.poppins_bold) 1 -> ResourcesCompat.getFont(this.context, R.font.poppins_bold)
2 -> ResourcesCompat.getFont(this.context, R.font.poppins) 2 -> ResourcesCompat.getFont(this.context, R.font.poppins)
@ -632,40 +628,10 @@ class PlayerSettingsActivity : AppCompatActivity() {
6 -> ResourcesCompat.getFont(this.context, R.font.blocky) 6 -> ResourcesCompat.getFont(this.context, R.font.blocky)
else -> ResourcesCompat.getFont(this.context, R.font.poppins_semi_bold) else -> ResourcesCompat.getFont(this.context, R.font.poppins_semi_bold)
} }
setTextColor(
when (PrefManager.getVal<Int>(PrefName.PrimaryColor)) { setTextColor(PrefManager.getVal<Int>(PrefName.PrimaryColor))
0 -> Color.BLACK
1 -> Color.DKGRAY setBackgroundColor(PrefManager.getVal<Int>(PrefName.SubBackground))
2 -> Color.GRAY
3 -> Color.LTGRAY
4 -> Color.WHITE
5 -> Color.RED
6 -> Color.YELLOW
7 -> Color.GREEN
8 -> Color.CYAN
9 -> Color.BLUE
10 -> Color.MAGENTA
11 -> Color.TRANSPARENT
else -> Color.WHITE
}
)
setBackgroundColor(
when (PrefManager.getVal<Int>(PrefName.SubBackground)) {
0 -> Color.TRANSPARENT
1 -> Color.BLACK
2 -> Color.DKGRAY
3 -> Color.GRAY
4 -> Color.LTGRAY
5 -> Color.WHITE
6 -> Color.RED
7 -> Color.YELLOW
8 -> Color.GREEN
9 -> Color.CYAN
10 -> Color.BLUE
11 -> Color.MAGENTA
else -> Color.TRANSPARENT
}
)
} }
} }
} }

View file

@ -96,14 +96,14 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
Subtitles(Pref(Location.Player, Boolean::class, true)), Subtitles(Pref(Location.Player, Boolean::class, true)),
TextviewSubtitles(Pref(Location.Player, Boolean::class, false)), TextviewSubtitles(Pref(Location.Player, Boolean::class, false)),
SubLanguage(Pref(Location.Player, Int::class, 9)), SubLanguage(Pref(Location.Player, Int::class, 9)),
PrimaryColor(Pref(Location.Player, Int::class, 4)), PrimaryColor(Pref(Location.Player, Int::class, Color.WHITE)),
SecondaryColor(Pref(Location.Player, Int::class, 0)), SecondaryColor(Pref(Location.Player, Int::class, Color.BLACK)),
Outline(Pref(Location.Player, Int::class, 0)), Outline(Pref(Location.Player, Int::class, 0)),
SubBackground(Pref(Location.Player, Int::class, 0)), SubBackground(Pref(Location.Player, Int::class, Color.TRANSPARENT)),
SubWindow(Pref(Location.Player, Int::class, 0)), SubWindow(Pref(Location.Player, Int::class, Color.TRANSPARENT)),
SubAlpha(Pref(Location.Player, Float::class, 1f)), SubAlpha(Pref(Location.Player, Float::class, 1f)),
SubStroke(Pref(Location.Player, Float::class, 8f)), SubStroke(Pref(Location.Player, Float::class, 8f)),
SubBottomMargin(Pref(Location.Player, Float::class, 4f)), SubBottomMargin(Pref(Location.Player, Float::class, 1f)),
Font(Pref(Location.Player, Int::class, 0)), Font(Pref(Location.Player, Int::class, 0)),
FontSize(Pref(Location.Player, Int::class, 20)), FontSize(Pref(Location.Player, Int::class, 20)),
Locale(Pref(Location.Player, Int::class, 2)), Locale(Pref(Location.Player, Int::class, 2)),

View file

@ -225,25 +225,6 @@
app:showText="false" app:showText="false"
app:thumbTint="@color/button_switch_track" /> app:thumbTint="@color/button_switch_track" />
<Button
android:id="@+id/videoSubLanguage"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_marginBottom="8dp"
android:fontFamily="@font/poppins_bold"
android:insetTop="0dp"
android:insetBottom="0dp"
android:paddingHorizontal="32dp"
android:text="@string/subtitle_langauge"
android:textAlignment="viewStart"
android:textAllCaps="false"
android:textColor="@color/bg_opp"
app:cornerRadius="0dp"
app:icon="@drawable/ic_round_subtitles_24"
app:iconPadding="16dp"
app:iconSize="24dp" />
<Button <Button
android:id="@+id/videoSubColorPrimary" android:id="@+id/videoSubColorPrimary"
style="@style/Widget.Material3.Button.TextButton" style="@style/Widget.Material3.Button.TextButton"
@ -426,7 +407,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp" android:layout_marginHorizontal="32dp"
android:valueFrom="1" android:valueFrom="0"
android:stepSize="1.0" android:stepSize="1.0"
android:valueTo="30"> android:valueTo="30">
@ -457,9 +438,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp" android:layout_marginHorizontal="32dp"
android:valueFrom="1" android:valueFrom="0"
android:stepSize="1.0" android:stepSize="1.0"
android:valueTo="30"> android:valueTo="50">
</com.google.android.material.slider.Slider> </com.google.android.material.slider.Slider>
@ -544,6 +525,25 @@
</LinearLayout> </LinearLayout>
<Button
android:id="@+id/videoSubLanguage"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_marginBottom="8dp"
android:fontFamily="@font/poppins_bold"
android:insetTop="0dp"
android:insetBottom="0dp"
android:paddingHorizontal="32dp"
android:text="@string/subtitle_langauge"
android:textAlignment="viewStart"
android:textAllCaps="false"
android:textColor="@color/bg_opp"
app:cornerRadius="0dp"
app:icon="@drawable/ic_round_subtitles_24"
app:iconPadding="16dp"
app:iconSize="24dp" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -1073,7 +1073,7 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
<string name="private_mode">Private</string> <string name="private_mode">Private</string>
<string name="omega_cursed">you have been Ǫ̴̺̙͎̤̫͓̮̰̿͝M̴͇̤͗́̾̈́̑̍̿̈͌͝Ȅ̴̡̨̛͉̣̙̩̲̣̤̟̪̣̎͗̎̆̒̉͆̆̕ͅͅǴ̸̯̬̗̠̙͛͐̀̈͋̀̈̽́̎̿͘͘͝ͅĀ̶̧̲̀ͅ ̴̢̟͕̜̓̾̓C̶̬̜̰̘̝̱̫͓͙̭̈́͐͋̓̏̈̍̓̀̌̾̚Ư̸̛̤̱̈́͆̽͊͛̐̓́̑͘̕̕͝R̸̨̨͈̬̱̺͕̪̪̘͕͎̂͛́̅̆̓̀͝ͅS̴̨̨̛̩̭̗̹̰̭̥͉̮̝̠̓̔͆̂͊͆̀̈́̅̕͘̚͝È̴̢̛̝͈̳͉͈͒͒̒̄̏̈̈́D̸̢̡̨̜̞̩̼̫̹̗̮͛̀̈̋̾̇̕̕͜ͅ</string> <string name="omega_cursed">you have been Ǫ̴̺̙͎̤̫͓̮̰̿͝M̴͇̤͗́̾̈́̑̍̿̈͌͝Ȅ̴̡̨̛͉̣̙̩̲̣̤̟̪̣̎͗̎̆̒̉͆̆̕ͅͅǴ̸̯̬̗̠̙͛͐̀̈͋̀̈̽́̎̿͘͘͝ͅĀ̶̧̲̀ͅ ̴̢̟͕̜̓̾̓C̶̬̜̰̘̝̱̫͓͙̭̈́͐͋̓̏̈̍̓̀̌̾̚Ư̸̛̤̱̈́͆̽͊͛̐̓́̑͘̕̕͝R̸̨̨͈̬̱̺͕̪̪̘͕͎̂͛́̅̆̓̀͝ͅS̴̨̨̛̩̭̗̹̰̭̥͉̮̝̠̓̔͆̂͊͆̀̈́̅̕͘̚͝È̴̢̛̝͈̳͉͈͒͒̒̄̏̈̈́D̸̢̡̨̜̞̩̼̫̹̗̮͛̀̈̋̾̇̕̕͜ͅ</string>
<string name="omega_freed">you have been freed</string> <string name="omega_freed">you have been freed</string>
<string name="subtitle_langauge">Subtitle Langauge</string> <string name="subtitle_langauge">Preferred Langauge</string>
<string name="socks5">SOCKS5</string> <string name="socks5">SOCKS5</string>
<string name="host">Host</string> <string name="host">Host</string>
<string name="port">Port</string> <string name="port">Port</string>