diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index e1961ca610..5fd35024bf 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -327,36 +327,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL } private fun setupSubFormatting(playerView: PlayerView) { - val primaryColor = when (PrefManager.getVal(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 secondaryColor = when (PrefManager.getVal(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 primaryColor = PrefManager.getVal(PrefName.PrimaryColor) + + val secondaryColor = PrefManager.getVal(PrefName.SecondaryColor) + val outline = when (PrefManager.getVal(PrefName.Outline)) { 0 -> EDGE_TYPE_OUTLINE // Normal 1 -> EDGE_TYPE_DEPRESSED // Shine @@ -364,36 +338,11 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL 3 -> EDGE_TYPE_NONE // No outline else -> EDGE_TYPE_OUTLINE // Normal } - val subBackground = when (PrefManager.getVal(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 - } - val subWindow = when (PrefManager.getVal(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 subBackground = PrefManager.getVal(PrefName.SubBackground) + + val subWindow = PrefManager.getVal(PrefName.SubWindow) + val font = when (PrefManager.getVal(PrefName.Font)) { 0 -> ResourcesCompat.getFont(this, R.font.poppins_semi_bold) 1 -> ResourcesCompat.getFont(this, R.font.poppins_bold) @@ -432,37 +381,15 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL } private fun applySubtitleStyles(textView: Xubtitle) { - val primaryColor = when (PrefManager.getVal(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(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 - } + val primaryColor = PrefManager.getVal(PrefName.PrimaryColor) + + val subBackground = PrefManager.getVal(PrefName.SubBackground) + + val secondaryColor = PrefManager.getVal(PrefName.SecondaryColor) + + val subStroke = PrefManager.getVal(PrefName.SubStroke) + + val fontSize = PrefManager.getVal(PrefName.FontSize).toFloat() val font = when (PrefManager.getVal(PrefName.Font)) { 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) } - val fontSize = PrefManager.getVal(PrefName.FontSize).toFloat() - textView.setBackgroundColor(subBackground) textView.setTextColor(primaryColor) textView.typeface = font textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize) - val secondaryColor = when (PrefManager.getVal(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(PrefName.SubStroke) - textView.apply { when (PrefManager.getVal(PrefName.Outline)) { 0 -> applyOutline(secondaryColor, subStroke) @@ -516,7 +423,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL false -> 0f } - val textElevation = PrefManager.getVal(PrefName.SubBottomMargin) / 30 * resources.displayMetrics.heightPixels + val textElevation = PrefManager.getVal(PrefName.SubBottomMargin) / 50 * resources.displayMetrics.heightPixels textView.translationY = -textElevation } diff --git a/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt index c3192f99cb..9181f24bf2 100644 --- a/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt @@ -1,9 +1,6 @@ package ani.dantotsu.settings -import android.app.AlertDialog -import android.app.Dialog import android.content.res.Resources -import android.graphics.Color import android.os.Build import android.os.Bundle import android.util.TypedValue @@ -31,9 +28,19 @@ import ani.dantotsu.themes.ThemeManager import ani.dantotsu.toast import ani.dantotsu.util.customAlertDialog import com.google.android.material.slider.Slider.OnChangeListener +import eltos.simpledialogfragment.SimpleDialog +import eltos.simpledialogfragment.color.SimpleColorWheelDialog 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 private val player = "player_settings" @@ -41,9 +48,12 @@ class PlayerSettingsActivity : AppCompatActivity() { var subtitle: Subtitle? = null private val Int.toSP - get() = TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_SP, this.toFloat(), Resources.getSystem().displayMetrics - ) + get() = + TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_SP, + this.toFloat(), + Resources.getSystem().displayMetrics, + ) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -70,12 +80,11 @@ class PlayerSettingsActivity : AppCompatActivity() { bottomMargin = navBarHeight } - binding.playerSettingsBack.setOnClickListener { onBackPressedDispatcher.onBackPressed() } - //Video + // Video val speeds = arrayOf( @@ -91,7 +100,7 @@ class PlayerSettingsActivity : AppCompatActivity() { 1.5f, 1.66f, 1.75f, - 2f + 2f, ) 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 @@ -99,14 +108,14 @@ class PlayerSettingsActivity : AppCompatActivity() { binding.playerSettingsSpeed.text = getString( R.string.default_playback_speed, - speedsName[PrefManager.getVal(PrefName.DefaultSpeed)] + speedsName[PrefManager.getVal(PrefName.DefaultSpeed)], ) binding.playerSettingsSpeed.setOnClickListener { customAlertDialog().apply { setTitle(getString(R.string.default_speed)) singleChoiceItems( speedsName, - PrefManager.getVal(PrefName.DefaultSpeed) + PrefManager.getVal(PrefName.DefaultSpeed), ) { i -> PrefManager.setVal(PrefName.DefaultSpeed, i) binding.playerSettingsSpeed.text = @@ -126,11 +135,10 @@ class PlayerSettingsActivity : AppCompatActivity() { binding.playerSettingsSpeed.text = getString( R.string.default_playback_speed, - speedsName[PrefManager.getVal(PrefName.DefaultSpeed)] + speedsName[PrefManager.getVal(PrefName.DefaultSpeed)], ) } - // Time Stamp binding.playerSettingsTimeStamps.isChecked = PrefManager.getVal(PrefName.TimeStampsEnabled) binding.playerSettingsTimeStamps.setOnCheckedChangeListener { _, isChecked -> @@ -182,7 +190,7 @@ class PlayerSettingsActivity : AppCompatActivity() { PrefManager.setVal(PrefName.AutoSkipFiller, isChecked) } - //Update Progress + // Update Progress binding.playerSettingsAskUpdateProgress.isChecked = PrefManager.getVal(PrefName.AskIndividualPlayer) binding.playerSettingsAskUpdateProgress.setOnCheckedChangeListener { _, isChecked -> @@ -208,7 +216,7 @@ class PlayerSettingsActivity : AppCompatActivity() { PrefManager.setVal(PrefName.WatchPercentage, value / 100) } - //Behaviour + // Behaviour binding.playerSettingsAlwaysContinue.isChecked = PrefManager.getVal(PrefName.AlwaysContinue) binding.playerSettingsAlwaysContinue.setOnCheckedChangeListener { _, isChecked -> PrefManager.setVal(PrefName.AlwaysContinue, isChecked) @@ -245,13 +253,16 @@ class PlayerSettingsActivity : AppCompatActivity() { false } binding.exoSkipTime.addTextChangedListener { - val time = binding.exoSkipTime.text.toString().toIntOrNull() + val time = + binding.exoSkipTime.text + .toString() + .toIntOrNull() if (time != null) { PrefManager.setVal(PrefName.SkipTime, time) } } - //Other + // Other binding.playerSettingsPiP.apply { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { visibility = View.VISIBLE @@ -259,7 +270,9 @@ class PlayerSettingsActivity : AppCompatActivity() { setOnCheckedChangeListener { _, isChecked -> PrefManager.setVal(PrefName.Pip, isChecked) } - } else visibility = View.GONE + } else { + visibility = View.GONE + } } binding.playerSettingsCast.isChecked = PrefManager.getVal(PrefName.Cast) @@ -288,7 +301,7 @@ class PlayerSettingsActivity : AppCompatActivity() { setTitle(getString(R.string.default_resize_mode)) singleChoiceItems( resizeModes, - PrefManager.getVal(PrefName.Resize) + PrefManager.getVal(PrefName.Resize), ) { count -> PrefManager.setVal(PrefName.Resize, count) } @@ -310,13 +323,14 @@ class PlayerSettingsActivity : AppCompatActivity() { binding.subtitleFontSizeText, binding.subtitleFontSize, binding.videoSubLanguage, - binding.subTextSwitch + binding.subTextSwitch, ).forEach { it.isEnabled = isChecked - it.alpha = when (isChecked) { - true -> 1f - false -> 0.5f - } + it.alpha = + when (isChecked) { + true -> 1f + false -> 0.5f + } } } @@ -325,13 +339,14 @@ class PlayerSettingsActivity : AppCompatActivity() { binding.videoSubStrokeButton, binding.videoSubStroke, binding.videoSubBottomMarginButton, - binding.videoSubBottomMargin + binding.videoSubBottomMargin, ).forEach { it.isEnabled = isChecked - it.alpha = when (isChecked) { - true -> 1f - false -> 0.5f - } + it.alpha = + when (isChecked) { + true -> 1f + false -> 0.5f + } } } @@ -350,122 +365,100 @@ class PlayerSettingsActivity : AppCompatActivity() { } toggleExpSubOptions(binding.subTextSwitch.isChecked) - val subLanguages = arrayOf( - "Albanian", - "Arabic", - "Bosnian", - "Bulgarian", - "Chinese", - "Croatian", - "Czech", - "Danish", - "Dutch", - "English", - "Estonian", - "Finnish", - "French", - "Georgian", - "German", - "Greek", - "Hebrew", - "Hindi", - "Indonesian", - "Irish", - "Italian", - "Japanese", - "Korean", - "Lithuanian", - "Luxembourgish", - "Macedonian", - "Mongolian", - "Norwegian", - "Polish", - "Portuguese", - "Punjabi", - "Romanian", - "Russian", - "Serbian", - "Slovak", - "Slovenian", - "Spanish", - "Turkish", - "Ukrainian", - "Urdu", - "Vietnamese", - ) + val subLanguages = + arrayOf( + "Albanian", + "Arabic", + "Bosnian", + "Bulgarian", + "Chinese", + "Croatian", + "Czech", + "Danish", + "Dutch", + "English", + "Estonian", + "Finnish", + "French", + "Georgian", + "German", + "Greek", + "Hebrew", + "Hindi", + "Indonesian", + "Irish", + "Italian", + "Japanese", + "Korean", + "Lithuanian", + "Luxembourgish", + "Macedonian", + "Mongolian", + "Norwegian", + "Polish", + "Portuguese", + "Punjabi", + "Romanian", + "Russian", + "Serbian", + "Slovak", + "Slovenian", + "Spanish", + "Turkish", + "Ukrainian", + "Urdu", + "Vietnamese", + ) binding.videoSubLanguage.setOnClickListener { customAlertDialog().apply { setTitle(getString(R.string.subtitle_langauge)) singleChoiceItems( subLanguages, - PrefManager.getVal(PrefName.SubLanguage) + PrefManager.getVal(PrefName.SubLanguage), ) { count -> - PrefManager.setVal(PrefName.SubLanguage, count) + PrefManager.setVal(PrefName.SubLanguage, count) } show() } } - val colorsPrimary = - arrayOf( - "Black", - "Dark Gray", - "Gray", - "Light Gray", - "White", - "Red", - "Yellow", - "Green", - "Cyan", - "Blue", - "Magenta" - ) + binding.videoSubColorPrimary.setOnClickListener { - customAlertDialog().apply { - setTitle(getString(R.string.primary_sub_color)) - singleChoiceItems( - colorsPrimary, - PrefManager.getVal(PrefName.PrimaryColor) - ) { count -> - PrefManager.setVal(PrefName.PrimaryColor, count) - updateSubPreview() - } - show() - } + val color = PrefManager.getVal(PrefName.PrimaryColor) + val title = getString(R.string.primary_sub_color) + showColorPicker( + color, + title, + object : ColorPickerCallback { + override fun onColorSelected(color: Int) { + PrefManager.setVal(PrefName.PrimaryColor, color) + updateSubPreview() + } + }, + ) } - val colorsSecondary = arrayOf( - "Black", - "Dark Gray", - "Gray", - "Light Gray", - "White", - "Red", - "Yellow", - "Green", - "Cyan", - "Blue", - "Magenta", - "Transparent" - ) + binding.videoSubColorSecondary.setOnClickListener { - customAlertDialog().apply { - setTitle(getString(R.string.outline_sub_color)) - singleChoiceItems( - colorsSecondary, - PrefManager.getVal(PrefName.SecondaryColor) - ) { count -> - PrefManager.setVal(PrefName.SecondaryColor, count) - updateSubPreview() - } - show() - } + val color = PrefManager.getVal(PrefName.SecondaryColor) + val title = getString(R.string.outline_sub_color) + showColorPicker( + color, + title, + object : ColorPickerCallback { + override fun onColorSelected(color: Int) { + PrefManager.setVal(PrefName.SecondaryColor, color) + updateSubPreview() + } + }, + ) } + val typesOutline = arrayOf("Outline", "Shine", "Drop Shadow", "None") binding.videoSubOutline.setOnClickListener { customAlertDialog().apply { setTitle(getString(R.string.outline_type)) singleChoiceItems( typesOutline, - PrefManager.getVal(PrefName.Outline) + PrefManager.getVal(PrefName.Outline), ) { count -> PrefManager.setVal(PrefName.Outline, count) updateSubPreview() @@ -473,101 +466,83 @@ class PlayerSettingsActivity : AppCompatActivity() { show() } } - val colorsSubBackground = arrayOf( - "Transparent", - "Black", - "Dark Gray", - "Gray", - "Light Gray", - "White", - "Red", - "Yellow", - "Green", - "Cyan", - "Blue", - "Magenta" - ) + binding.videoSubColorBackground.setOnClickListener { - customAlertDialog().apply { - setTitle(getString(R.string.sub_background_color_select)) - singleChoiceItems( - colorsSubBackground, - PrefManager.getVal(PrefName.SubBackground) - ) { count -> - PrefManager.setVal(PrefName.SubBackground, count) - updateSubPreview() - } - show() - } + val color = PrefManager.getVal(PrefName.SubBackground) + val title = getString(R.string.sub_background_color_select) + showColorPicker( + color, + title, + object : ColorPickerCallback { + override fun onColorSelected(color: Int) { + PrefManager.setVal(PrefName.SubBackground, color) + updateSubPreview() + } + }, + ) } - val colorsSubWindow = arrayOf( - "Transparent", - "Black", - "Dark Gray", - "Gray", - "Light Gray", - "White", - "Red", - "Yellow", - "Green", - "Cyan", - "Blue", - "Magenta" - ) binding.videoSubColorWindow.setOnClickListener { - customAlertDialog().apply { - setTitle(getString(R.string.sub_window_color_select)) - singleChoiceItems( - colorsSubWindow, - PrefManager.getVal(PrefName.SubWindow) - ) { count -> - PrefManager.setVal(PrefName.SubWindow, count) - updateSubPreview() - } - show() - } + val color = PrefManager.getVal(PrefName.SubWindow) + val title = getString(R.string.sub_window_color_select) + showColorPicker( + color, + title, + object : ColorPickerCallback { + override fun onColorSelected(color: Int) { + PrefManager.setVal(PrefName.SubWindow, color) + updateSubPreview() + } + }, + ) } binding.videoSubAlpha.value = PrefManager.getVal(PrefName.SubAlpha) - binding.videoSubAlpha.addOnChangeListener(OnChangeListener { _, value, fromUser -> - if (fromUser) { - PrefManager.setVal(PrefName.SubAlpha, value) - updateSubPreview() - } - }) + binding.videoSubAlpha.addOnChangeListener( + OnChangeListener { _, value, fromUser -> + if (fromUser) { + PrefManager.setVal(PrefName.SubAlpha, value) + updateSubPreview() + } + }, + ) binding.videoSubStroke.value = PrefManager.getVal(PrefName.SubStroke) - binding.videoSubStroke.addOnChangeListener(OnChangeListener { _, value, fromUser -> - if (fromUser) { - PrefManager.setVal(PrefName.SubStroke, value) - updateSubPreview() - } - }) + binding.videoSubStroke.addOnChangeListener( + OnChangeListener { _, value, fromUser -> + if (fromUser) { + PrefManager.setVal(PrefName.SubStroke, value) + updateSubPreview() + } + }, + ) binding.videoSubBottomMargin.value = PrefManager.getVal(PrefName.SubBottomMargin) - binding.videoSubBottomMargin.addOnChangeListener(OnChangeListener { _, value, fromUser -> - if (fromUser) { - PrefManager.setVal(PrefName.SubBottomMargin, value) - updateSubPreview() - } - }) - - val fonts = arrayOf( - "Poppins Semi Bold", - "Poppins Bold", - "Poppins", - "Poppins Thin", - "Century Gothic", - "Levenim MT Bold", - "Blocky" + binding.videoSubBottomMargin.addOnChangeListener( + OnChangeListener { _, value, fromUser -> + if (fromUser) { + PrefManager.setVal(PrefName.SubBottomMargin, value) + updateSubPreview() + } + }, ) + + val fonts = + arrayOf( + "Poppins Semi Bold", + "Poppins Bold", + "Poppins", + "Poppins Thin", + "Century Gothic", + "Levenim MT Bold", + "Blocky", + ) binding.videoSubFont.setOnClickListener { customAlertDialog().apply { setTitle(getString(R.string.subtitle_font)) singleChoiceItems( fonts, - PrefManager.getVal(PrefName.Font) + PrefManager.getVal(PrefName.Font), ) { count -> PrefManager.setVal(PrefName.Font, count) updateSubPreview() @@ -583,89 +558,80 @@ class PlayerSettingsActivity : AppCompatActivity() { false } binding.subtitleFontSize.addTextChangedListener { - val size = binding.subtitleFontSize.text.toString().toIntOrNull() + val size = + binding.subtitleFontSize.text + .toString() + .toIntOrNull() if (size != null) { PrefManager.setVal(PrefName.FontSize, size) updateSubPreview() } } - binding.subtitleTest.addOnChangeListener(object : Xpandable.OnChangeListener { - override fun onExpand() { - updateSubPreview() - } + binding.subtitleTest.addOnChangeListener( + object : Xpandable.OnChangeListener { + override fun onExpand() { + updateSubPreview() + } - override fun onRetract() {} - }) + override fun onRetract() {} + }, + ) 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() { binding.subtitleTestWindow.run { alpha = PrefManager.getVal(PrefName.SubAlpha) - setBackgroundColor( - when (PrefManager.getVal(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 - } - ) + setBackgroundColor(PrefManager.getVal(PrefName.SubWindow)) } + binding.subtitleTestText.run { textSize = PrefManager.getVal(PrefName.FontSize).toSP - typeface = when (PrefManager.getVal(PrefName.Font)) { - 0 -> ResourcesCompat.getFont(this.context, R.font.poppins_semi_bold) - 1 -> ResourcesCompat.getFont(this.context, R.font.poppins_bold) - 2 -> ResourcesCompat.getFont(this.context, R.font.poppins) - 3 -> ResourcesCompat.getFont(this.context, R.font.poppins_thin) - 4 -> ResourcesCompat.getFont(this.context, R.font.century_gothic_regular) - 5 -> ResourcesCompat.getFont(this.context, R.font.levenim_mt_bold) - 6 -> ResourcesCompat.getFont(this.context, R.font.blocky) - else -> ResourcesCompat.getFont(this.context, R.font.poppins_semi_bold) - } - setTextColor( - when (PrefManager.getVal(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 + typeface = + when (PrefManager.getVal(PrefName.Font)) { + 0 -> ResourcesCompat.getFont(this.context, R.font.poppins_semi_bold) + 1 -> ResourcesCompat.getFont(this.context, R.font.poppins_bold) + 2 -> ResourcesCompat.getFont(this.context, R.font.poppins) + 3 -> ResourcesCompat.getFont(this.context, R.font.poppins_thin) + 4 -> ResourcesCompat.getFont(this.context, R.font.century_gothic_regular) + 5 -> ResourcesCompat.getFont(this.context, R.font.levenim_mt_bold) + 6 -> ResourcesCompat.getFont(this.context, R.font.blocky) + else -> ResourcesCompat.getFont(this.context, R.font.poppins_semi_bold) } - ) - setBackgroundColor( - when (PrefManager.getVal(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 - } - ) + + setTextColor(PrefManager.getVal(PrefName.PrimaryColor)) + + setBackgroundColor(PrefManager.getVal(PrefName.SubBackground)) } } -} \ No newline at end of file +} diff --git a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt index 5aa9cdf487..659e399b1a 100644 --- a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt +++ b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt @@ -96,14 +96,14 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files Subtitles(Pref(Location.Player, Boolean::class, true)), TextviewSubtitles(Pref(Location.Player, Boolean::class, false)), SubLanguage(Pref(Location.Player, Int::class, 9)), - PrimaryColor(Pref(Location.Player, Int::class, 4)), - SecondaryColor(Pref(Location.Player, Int::class, 0)), + PrimaryColor(Pref(Location.Player, Int::class, Color.WHITE)), + SecondaryColor(Pref(Location.Player, Int::class, Color.BLACK)), Outline(Pref(Location.Player, Int::class, 0)), - SubBackground(Pref(Location.Player, Int::class, 0)), - SubWindow(Pref(Location.Player, Int::class, 0)), + SubBackground(Pref(Location.Player, Int::class, Color.TRANSPARENT)), + SubWindow(Pref(Location.Player, Int::class, Color.TRANSPARENT)), SubAlpha(Pref(Location.Player, Float::class, 1f)), 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)), FontSize(Pref(Location.Player, Int::class, 20)), Locale(Pref(Location.Player, Int::class, 2)), @@ -220,4 +220,4 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files Socks5ProxyPort(Pref(Location.Protected, String::class, "")), Socks5ProxyUsername(Pref(Location.Protected, String::class, "")), Socks5ProxyPassword(Pref(Location.Protected, String::class, "")), -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/activity_player_settings.xml b/app/src/main/res/layout/activity_player_settings.xml index d5fb0ebb7d..04244f031e 100644 --- a/app/src/main/res/layout/activity_player_settings.xml +++ b/app/src/main/res/layout/activity_player_settings.xml @@ -225,25 +225,6 @@ app:showText="false" app:thumbTint="@color/button_switch_track" /> -