This commit is contained in:
rebelonion 2024-03-23 21:12:57 -05:00
commit 85d54e8f5e
13 changed files with 338 additions and 135 deletions

View file

@ -270,6 +270,32 @@ fun Activity.setNavigationTheme() {
} }
} }
fun Activity.reloadActivity() {
Refresh.all()
finish()
startActivity(Intent(this, this::class.java))
initActivity(this)
}
fun Context.restartApp(view: View) {
val mainIntent = Intent.makeRestartActivityTask(
packageManager.getLaunchIntentForPackage(this.packageName)!!.component
)
val component = ComponentName(this@restartApp.packageName, this@restartApp::class.qualifiedName!!)
Snackbar.make(view, R.string.restart_app, Snackbar.LENGTH_INDEFINITE).apply {
setAction(R.string.do_it) {
this.dismiss()
try {
startActivity(Intent().setComponent(component))
} catch (anything: Exception) {
startActivity(mainIntent)
}
Runtime.getRuntime().exit(0)
}
show()
}
}
open class BottomSheetDialogFragment : BottomSheetDialogFragment() { open class BottomSheetDialogFragment : BottomSheetDialogFragment() {
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -1272,7 +1298,7 @@ fun blurImage(imageView: ImageView, banner: String?) {
val url = PrefManager.getVal<String>(PrefName.ImageUrl).ifEmpty { banner } val url = PrefManager.getVal<String>(PrefName.ImageUrl).ifEmpty { banner }
Glide.with(context as Context) Glide.with(context as Context)
.load(GlideUrl(url)) .load(GlideUrl(url))
.diskCacheStrategy(DiskCacheStrategy.ALL).override(400) .diskCacheStrategy(DiskCacheStrategy.RESOURCE).override(400)
.apply(RequestOptions.bitmapTransform(BlurTransformation(radius, sampling))) .apply(RequestOptions.bitmapTransform(BlurTransformation(radius, sampling)))
.into(imageView) .into(imageView)
} }

View file

@ -159,8 +159,7 @@ class AnimeWatchAdapter(
} }
subscribeButton(false) subscribeButton(false)
fragment.loadEpisodes(media.selected!!.sourceIndex, true) fragment.loadEpisodes(media.selected!!.sourceIndex, true)
} ?: run { } ?: run { }
}
} }
//settings //settings
@ -430,6 +429,22 @@ class AnimeWatchAdapter(
val sourceFound = media.anime.episodes!!.isNotEmpty() val sourceFound = media.anime.episodes!!.isNotEmpty()
binding.animeSourceNotFound.isGone = sourceFound binding.animeSourceNotFound.isGone = sourceFound
binding.faqbutton.isGone = sourceFound binding.faqbutton.isGone = sourceFound
if (!sourceFound && PrefManager.getVal(PrefName.SearchSources)) {
if (binding.animeSource.adapter.count > media.selected!!.sourceIndex + 1) {
val nextIndex = media.selected!!.sourceIndex + 1
binding.animeSource.setText(binding.animeSource.adapter
.getItem(nextIndex).toString(), false)
fragment.onSourceChange(nextIndex).apply {
binding.animeSourceTitle.text = showUserText
showUserTextListener = { MainScope().launch { binding.animeSourceTitle.text = it } }
binding.animeSourceDubbed.isChecked = selectDub
binding.animeSourceDubbedCont.isVisible = isDubAvailableSeparately()
setLanguageList(0, nextIndex)
}
subscribeButton(false)
fragment.loadEpisodes(nextIndex, false)
}
}
} else { } else {
binding.animeSourceContinue.visibility = View.GONE binding.animeSourceContinue.visibility = View.GONE
binding.animeSourceNotFound.visibility = View.GONE binding.animeSourceNotFound.visibility = View.GONE

View file

@ -481,7 +481,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
playerView.subtitleView?.alpha = when (PrefManager.getVal<Boolean>(PrefName.Subtitles)) { playerView.subtitleView?.alpha = when (PrefManager.getVal<Boolean>(PrefName.Subtitles)) {
true -> 1f true -> PrefManager.getVal(PrefName.SubAlpha)
false -> 0f false -> 0f
} }
val fontSize = PrefManager.getVal<Int>(PrefName.FontSize).toFloat() val fontSize = PrefManager.getVal<Int>(PrefName.FontSize).toFloat()

View file

@ -481,6 +481,22 @@ class MangaReadAdapter(
val sourceFound = media.manga.chapters!!.isNotEmpty() val sourceFound = media.manga.chapters!!.isNotEmpty()
binding.animeSourceNotFound.isGone = sourceFound binding.animeSourceNotFound.isGone = sourceFound
binding.faqbutton.isGone = sourceFound binding.faqbutton.isGone = sourceFound
if (!sourceFound && PrefManager.getVal(PrefName.SearchSources)) {
if (binding.animeSource.adapter.count > media.selected!!.sourceIndex + 1) {
val nextIndex = media.selected!!.sourceIndex + 1
binding.animeSource.setText(binding.animeSource.adapter
.getItem(nextIndex).toString(), false)
fragment.onSourceChange(nextIndex).apply {
binding.animeSourceTitle.text = showUserText
showUserTextListener = { MainScope().launch { binding.animeSourceTitle.text = it } }
setLanguageList(0, nextIndex)
}
subscribeButton(false)
// invalidate if it's the last source
val invalidate = nextIndex == mangaReadSources.names.size - 1
fragment.loadChapters(nextIndex, invalidate)
}
}
} else { } else {
binding.animeSourceContinue.visibility = View.GONE binding.animeSourceContinue.visibility = View.GONE
binding.animeSourceNotFound.visibility = View.GONE binding.animeSourceNotFound.visibility = View.GONE

View file

@ -13,6 +13,7 @@ class Xpandable @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null context: Context, attrs: AttributeSet? = null
) : LinearLayout(context, attrs) { ) : LinearLayout(context, attrs) {
var expanded: Boolean = false var expanded: Boolean = false
private var listener: OnChangeListener? = null
init { init {
context.withStyledAttributes(attrs, R.styleable.Xpandable) { context.withStyledAttributes(attrs, R.styleable.Xpandable) {
@ -37,7 +38,6 @@ class Xpandable @JvmOverloads constructor(
super.onAttachedToWindow() super.onAttachedToWindow()
} }
private fun hideAll() { private fun hideAll() {
children.forEach { children.forEach {
if (it != getChildAt(0)) { if (it != getChildAt(0)) {
@ -48,8 +48,10 @@ class Xpandable @JvmOverloads constructor(
it.visibility = GONE it.visibility = GONE
}, 300) }, 300)
} }
} }
postDelayed({
listener?.onRetract()
}, 300)
} }
private fun showAll() { private fun showAll() {
@ -61,6 +63,19 @@ class Xpandable @JvmOverloads constructor(
ObjectAnimator.ofFloat(it, "alpha", 0f, 1f).setDuration(200).start() ObjectAnimator.ofFloat(it, "alpha", 0f, 1f).setDuration(200).start()
} }
} }
postDelayed({
listener?.onExpand()
}, 300)
}
@Suppress("unused")
fun setOnChangeListener(listener: OnChangeListener) {
this.listener = listener
}
interface OnChangeListener {
fun onExpand()
fun onRetract()
} }
} }

View file

@ -1,14 +1,17 @@
package ani.dantotsu.settings package ani.dantotsu.settings
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Intent 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.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.updateLayoutParams import androidx.core.view.updateLayoutParams
import androidx.core.widget.addTextChangedListener import androidx.core.widget.addTextChangedListener
import ani.dantotsu.R import ani.dantotsu.R
@ -16,6 +19,7 @@ import ani.dantotsu.databinding.ActivityPlayerSettingsBinding
import ani.dantotsu.initActivity import ani.dantotsu.initActivity
import ani.dantotsu.media.Media import ani.dantotsu.media.Media
import ani.dantotsu.navBarHeight import ani.dantotsu.navBarHeight
import ani.dantotsu.others.Xpandable
import ani.dantotsu.others.getSerialized import ani.dantotsu.others.getSerialized
import ani.dantotsu.parsers.Subtitle import ani.dantotsu.parsers.Subtitle
import ani.dantotsu.settings.saving.PrefManager import ani.dantotsu.settings.saving.PrefManager
@ -24,7 +28,7 @@ import ani.dantotsu.snackString
import ani.dantotsu.statusBarHeight import ani.dantotsu.statusBarHeight
import ani.dantotsu.themes.ThemeManager import ani.dantotsu.themes.ThemeManager
import ani.dantotsu.toast import ani.dantotsu.toast
import com.google.android.material.snackbar.Snackbar import com.google.android.material.slider.Slider.OnChangeListener
import kotlin.math.roundToInt import kotlin.math.roundToInt
@ -35,6 +39,9 @@ class PlayerSettingsActivity : AppCompatActivity() {
var media: Media? = null var media: Media? = null
var subtitle: Subtitle? = null var subtitle: Subtitle? = null
private val Int.toSP get() = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP, this.toFloat(), Resources.getSystem().displayMetrics
)
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -273,66 +280,33 @@ class PlayerSettingsActivity : AppCompatActivity() {
dialog.window?.setDimAmount(0.8f) dialog.window?.setDimAmount(0.8f)
} }
fun restartApp() {
Snackbar.make(
binding.root,
R.string.restart_app, Snackbar.LENGTH_SHORT
).apply {
val mainIntent =
Intent.makeRestartActivityTask(
context.packageManager.getLaunchIntentForPackage(
context.packageName
)!!.component
)
setAction("Do it!") {
context.startActivity(mainIntent)
Runtime.getRuntime().exit(0)
}
show()
}
}
fun toggleButton(button: android.widget.Button, toggle: Boolean) {
button.isClickable = toggle
button.alpha = when (toggle) {
true -> 1f
false -> 0.5f
}
}
fun toggleSubOptions(isChecked: Boolean) { fun toggleSubOptions(isChecked: Boolean) {
toggleButton(binding.videoSubColorPrimary, isChecked) arrayOf(
toggleButton(binding.videoSubColorSecondary, isChecked) binding.videoSubColorPrimary,
toggleButton(binding.videoSubOutline, isChecked) binding.videoSubColorSecondary,
toggleButton(binding.videoSubFont, isChecked) binding.videoSubOutline,
binding.subtitleFontSizeCard.isEnabled = isChecked binding.videoSubColorBackground,
binding.subtitleFontSizeCard.isClickable = isChecked binding.videoSubAlphaButton,
binding.subtitleFontSizeCard.alpha = when (isChecked) { binding.videoSubColorWindow,
true -> 1f binding.videoSubFont,
false -> 0.5f binding.videoSubAlpha,
} binding.subtitleFontSizeText,
binding.subtitleFontSize.isEnabled = isChecked binding.subtitleFontSize
binding.subtitleFontSize.isClickable = isChecked ).forEach {
binding.subtitleFontSize.alpha = when (isChecked) { it.isEnabled = isChecked
true -> 1f it.isClickable = isChecked
false -> 0.5f it.alpha = when (isChecked) {
}
ActivityPlayerSettingsBinding.bind(binding.root).subtitleFontSizeText.isEnabled =
isChecked
ActivityPlayerSettingsBinding.bind(binding.root).subtitleFontSizeText.isClickable =
isChecked
ActivityPlayerSettingsBinding.bind(binding.root).subtitleFontSizeText.alpha =
when (isChecked) {
true -> 1f true -> 1f
false -> 0.5f false -> 0.5f
} }
}
} }
binding.subSwitch.isChecked = PrefManager.getVal(PrefName.Subtitles) binding.subSwitch.isChecked = PrefManager.getVal(PrefName.Subtitles)
binding.subSwitch.setOnCheckedChangeListener { _, isChecked -> binding.subSwitch.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.Subtitles, isChecked) PrefManager.setVal(PrefName.Subtitles, isChecked)
toggleSubOptions(isChecked) toggleSubOptions(isChecked)
restartApp()
} }
toggleSubOptions(binding.subSwitch.isChecked)
val colorsPrimary = val colorsPrimary =
arrayOf( arrayOf(
"Black", "Black",
@ -356,6 +330,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
) { dialog, count -> ) { dialog, count ->
PrefManager.setVal(PrefName.PrimaryColor, count) PrefManager.setVal(PrefName.PrimaryColor, count)
dialog.dismiss() dialog.dismiss()
updateSubPreview()
}.show() }.show()
dialog.window?.setDimAmount(0.8f) dialog.window?.setDimAmount(0.8f)
} }
@ -382,6 +357,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
) { dialog, count -> ) { dialog, count ->
PrefManager.setVal(PrefName.SecondaryColor, count) PrefManager.setVal(PrefName.SecondaryColor, count)
dialog.dismiss() dialog.dismiss()
updateSubPreview()
}.show() }.show()
dialog.window?.setDimAmount(0.8f) dialog.window?.setDimAmount(0.8f)
} }
@ -395,6 +371,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
) { dialog, count -> ) { dialog, count ->
PrefManager.setVal(PrefName.Outline, count) PrefManager.setVal(PrefName.Outline, count)
dialog.dismiss() dialog.dismiss()
updateSubPreview()
}.show() }.show()
dialog.window?.setDimAmount(0.8f) dialog.window?.setDimAmount(0.8f)
} }
@ -421,6 +398,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
) { dialog, count -> ) { dialog, count ->
PrefManager.setVal(PrefName.SubBackground, count) PrefManager.setVal(PrefName.SubBackground, count)
dialog.dismiss() dialog.dismiss()
updateSubPreview()
}.show() }.show()
dialog.window?.setDimAmount(0.8f) dialog.window?.setDimAmount(0.8f)
} }
@ -448,9 +426,19 @@ class PlayerSettingsActivity : AppCompatActivity() {
) { dialog, count -> ) { dialog, count ->
PrefManager.setVal(PrefName.SubWindow, count) PrefManager.setVal(PrefName.SubWindow, count)
dialog.dismiss() dialog.dismiss()
updateSubPreview()
}.show() }.show()
dialog.window?.setDimAmount(0.8f) dialog.window?.setDimAmount(0.8f)
} }
binding.videoSubAlpha.value = PrefManager.getVal(PrefName.SubAlpha)
binding.videoSubAlpha.addOnChangeListener(OnChangeListener { _, value, fromUser ->
if (fromUser) {
PrefManager.setVal(PrefName.SubAlpha, value)
updateSubPreview()
}
})
val fonts = arrayOf( val fonts = arrayOf(
"Poppins Semi Bold", "Poppins Semi Bold",
"Poppins Bold", "Poppins Bold",
@ -469,6 +457,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
) { dialog, count -> ) { dialog, count ->
PrefManager.setVal(PrefName.Font, count) PrefManager.setVal(PrefName.Font, count)
dialog.dismiss() dialog.dismiss()
updateSubPreview()
}.show() }.show()
dialog.window?.setDimAmount(0.8f) dialog.window?.setDimAmount(0.8f)
} }
@ -483,8 +472,79 @@ class PlayerSettingsActivity : AppCompatActivity() {
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()
} }
} }
toggleSubOptions(PrefManager.getVal(PrefName.Subtitles)) binding.subtitleTest.setOnChangeListener(object: Xpandable.OnChangeListener {
override fun onExpand() {
updateSubPreview()
}
override fun onRetract() {}
})
updateSubPreview()
}
private fun updateSubPreview() {
binding.subtitleTestWindow.run {
alpha = PrefManager.getVal(PrefName.SubAlpha)
setBackgroundColor(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 {
textSize = PrefManager.getVal<Int>(PrefName.FontSize).toSP
typeface = when (PrefManager.getVal<Int>(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<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
})
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

@ -1,6 +1,5 @@
package ani.dantotsu.settings package ani.dantotsu.settings
import android.annotation.SuppressLint
import android.app.AlarmManager import android.app.AlarmManager
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Context import android.content.Context
@ -33,7 +32,6 @@ import androidx.media3.common.util.UnstableApi
import androidx.media3.exoplayer.offline.DownloadService import androidx.media3.exoplayer.offline.DownloadService
import ani.dantotsu.BuildConfig import ani.dantotsu.BuildConfig
import ani.dantotsu.R import ani.dantotsu.R
import ani.dantotsu.Refresh
import ani.dantotsu.connections.anilist.Anilist import ani.dantotsu.connections.anilist.Anilist
import ani.dantotsu.connections.anilist.api.NotificationType import ani.dantotsu.connections.anilist.api.NotificationType
import ani.dantotsu.connections.discord.Discord import ani.dantotsu.connections.discord.Discord
@ -66,6 +64,8 @@ import ani.dantotsu.openSettings
import ani.dantotsu.others.AppUpdater import ani.dantotsu.others.AppUpdater
import ani.dantotsu.others.CustomBottomDialog import ani.dantotsu.others.CustomBottomDialog
import ani.dantotsu.pop import ani.dantotsu.pop
import ani.dantotsu.reloadActivity
import ani.dantotsu.restartApp
import ani.dantotsu.savePrefsToDownloads import ani.dantotsu.savePrefsToDownloads
import ani.dantotsu.setSafeOnClickListener import ani.dantotsu.setSafeOnClickListener
import ani.dantotsu.settings.saving.PrefManager import ani.dantotsu.settings.saving.PrefManager
@ -79,7 +79,6 @@ import ani.dantotsu.statusBarHeight
import ani.dantotsu.themes.ThemeManager import ani.dantotsu.themes.ThemeManager
import ani.dantotsu.toast import ani.dantotsu.toast
import ani.dantotsu.util.Logger import ani.dantotsu.util.Logger
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputEditText
import eltos.simpledialogfragment.SimpleDialog import eltos.simpledialogfragment.SimpleDialog
import eltos.simpledialogfragment.SimpleDialog.OnDialogResultListener.BUTTON_POSITIVE import eltos.simpledialogfragment.SimpleDialog.OnDialogResultListener.BUTTON_POSITIVE
@ -144,7 +143,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
return@passwordAlertDialog return@passwordAlertDialog
} }
if (PreferencePackager.unpack(decryptedJson)) if (PreferencePackager.unpack(decryptedJson))
restartApp() restartApp(binding.root)
} else { } else {
toast(getString(R.string.password_cannot_be_empty)) toast(getString(R.string.password_cannot_be_empty))
} }
@ -152,7 +151,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
} else if (name.endsWith(".ani")) { } else if (name.endsWith(".ani")) {
val decryptedJson = jsonString.toString(Charsets.UTF_8) val decryptedJson = jsonString.toString(Charsets.UTF_8)
if (PreferencePackager.unpack(decryptedJson)) if (PreferencePackager.unpack(decryptedJson))
restartApp() restartApp(binding.root)
} else { } else {
toast(getString(R.string.unknown_file_type)) toast(getString(R.string.unknown_file_type))
} }
@ -316,7 +315,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
settingsUseMaterialYou.setOnCheckedChangeListener { _, isChecked -> settingsUseMaterialYou.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.UseMaterialYou, isChecked) PrefManager.setVal(PrefName.UseMaterialYou, isChecked)
if (isChecked) settingsUseCustomTheme.isChecked = false if (isChecked) settingsUseCustomTheme.isChecked = false
restartApp() restartApp(binding.root)
} }
settingsUseCustomTheme.isChecked = settingsUseCustomTheme.isChecked =
@ -327,20 +326,20 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
settingsUseMaterialYou.isChecked = false settingsUseMaterialYou.isChecked = false
} }
restartApp() restartApp(binding.root)
} }
settingsUseSourceTheme.isChecked = settingsUseSourceTheme.isChecked =
PrefManager.getVal(PrefName.UseSourceTheme) PrefManager.getVal(PrefName.UseSourceTheme)
settingsUseSourceTheme.setOnCheckedChangeListener { _, isChecked -> settingsUseSourceTheme.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.UseSourceTheme, isChecked) PrefManager.setVal(PrefName.UseSourceTheme, isChecked)
restartApp() restartApp(binding.root)
} }
settingsUseOLED.isChecked = PrefManager.getVal(PrefName.UseOLED) settingsUseOLED.isChecked = PrefManager.getVal(PrefName.UseOLED)
settingsUseOLED.setOnCheckedChangeListener { _, isChecked -> settingsUseOLED.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.UseOLED, isChecked) PrefManager.setVal(PrefName.UseOLED, isChecked)
restartApp() restartApp(binding.root)
} }
val themeString: String = PrefManager.getVal(PrefName.Theme) val themeString: String = PrefManager.getVal(PrefName.Theme)
@ -359,17 +358,15 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
PrefManager.setVal(PrefName.Theme, ThemeManager.Companion.Theme.entries[i].theme) PrefManager.setVal(PrefName.Theme, ThemeManager.Companion.Theme.entries[i].theme)
//ActivityHelper.shouldRefreshMainActivity = true //ActivityHelper.shouldRefreshMainActivity = true
themeSwitcher.clearFocus() themeSwitcher.clearFocus()
restartApp() restartApp(binding.root)
} }
customTheme.setOnClickListener { customTheme.setOnClickListener {
val originalColor: Int = PrefManager.getVal(PrefName.CustomThemeInt) val originalColor: Int = PrefManager.getVal(PrefName.CustomThemeInt)
class CustomColorDialog : SimpleColorDialog() { //idk where to put it class CustomColorDialog : SimpleColorDialog() { //idk where to put it
override fun onPositiveButtonClick() { override fun onPositiveButtonClick() {
restartApp() restartApp(binding.root)
super.onPositiveButtonClick() super.onPositiveButtonClick()
} }
} }
@ -398,10 +395,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
previous = current previous = current
current.alpha = 1f current.alpha = 1f
PrefManager.setVal(PrefName.DarkMode, mode) PrefManager.setVal(PrefName.DarkMode, mode)
Refresh.all() reloadActivity()
finish()
startActivity(Intent(this@SettingsActivity, SettingsActivity::class.java))
initActivity(this@SettingsActivity)
} }
settingsUiAuto.setOnClickListener { settingsUiAuto.setOnClickListener {
@ -688,7 +682,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
settingsExtensionDns.setOnItemClickListener { _, _, i, _ -> settingsExtensionDns.setOnItemClickListener { _, _, i, _ ->
PrefManager.setVal(PrefName.DohProvider, i) PrefManager.setVal(PrefName.DohProvider, i)
settingsExtensionDns.clearFocus() settingsExtensionDns.clearFocus()
restartApp() restartApp(binding.root)
} }
settingsDownloadInSd.isChecked = PrefManager.getVal(PrefName.SdDl) settingsDownloadInSd.isChecked = PrefManager.getVal(PrefName.SdDl)
@ -710,6 +704,11 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
PrefManager.setVal(PrefName.ContinueMedia, isChecked) PrefManager.setVal(PrefName.ContinueMedia, isChecked)
} }
settingsSearchSources.isChecked = PrefManager.getVal(PrefName.SearchSources)
settingsSearchSources.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.SearchSources, isChecked)
}
settingsRecentlyListOnly.isChecked = PrefManager.getVal(PrefName.RecentlyListOnly) settingsRecentlyListOnly.isChecked = PrefManager.getVal(PrefName.RecentlyListOnly)
settingsRecentlyListOnly.setOnCheckedChangeListener { _, isChecked -> settingsRecentlyListOnly.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.RecentlyListOnly, isChecked) PrefManager.setVal(PrefName.RecentlyListOnly, isChecked)
@ -968,7 +967,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
settingsLogToFile.isChecked = PrefManager.getVal(PrefName.LogToFile) settingsLogToFile.isChecked = PrefManager.getVal(PrefName.LogToFile)
settingsLogToFile.setOnCheckedChangeListener { _, isChecked -> settingsLogToFile.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.LogToFile, isChecked) PrefManager.setVal(PrefName.LogToFile, isChecked)
restartApp() restartApp(binding.root)
} }
settingsShareLog.setOnClickListener { settingsShareLog.setOnClickListener {
@ -1050,25 +1049,6 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
return true return true
} }
private fun restartApp() {
Snackbar.make(
binding.root,
R.string.restart_app, Snackbar.LENGTH_SHORT
).apply {
val mainIntent =
Intent.makeRestartActivityTask(
context.packageManager.getLaunchIntentForPackage(
context.packageName
)!!.component
)
setAction(getString(R.string.do_it)) {
context.startActivity(mainIntent)
Runtime.getRuntime().exit(0)
}
show()
}
}
private fun passwordAlertDialog(isExporting: Boolean, callback: (CharArray?) -> Unit) { private fun passwordAlertDialog(isExporting: Boolean, callback: (CharArray?) -> Unit) {
val password = CharArray(16).apply { fill('0') } val password = CharArray(16).apply { fill('0') }

View file

@ -10,6 +10,7 @@ import ani.dantotsu.R
import ani.dantotsu.databinding.ActivityUserInterfaceSettingsBinding import ani.dantotsu.databinding.ActivityUserInterfaceSettingsBinding
import ani.dantotsu.initActivity import ani.dantotsu.initActivity
import ani.dantotsu.navBarHeight import ani.dantotsu.navBarHeight
import ani.dantotsu.restartApp
import ani.dantotsu.settings.saving.PrefManager import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.statusBarHeight import ani.dantotsu.statusBarHeight
@ -49,7 +50,7 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
} }
setPositiveButton("Done") { _, _ -> setPositiveButton("Done") { _, _ ->
PrefManager.setVal(PrefName.HomeLayoutShow, set) PrefManager.setVal(PrefName.HomeLayoutShow, set)
restartApp() restartApp(binding.root)
} }
}.show() }.show()
dialog.window?.setDimAmount(0.8f) dialog.window?.setDimAmount(0.8f)
@ -58,24 +59,24 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
binding.uiSettingsSmallView.isChecked = PrefManager.getVal(PrefName.SmallView) binding.uiSettingsSmallView.isChecked = PrefManager.getVal(PrefName.SmallView)
binding.uiSettingsSmallView.setOnCheckedChangeListener { _, isChecked -> binding.uiSettingsSmallView.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.SmallView, isChecked) PrefManager.setVal(PrefName.SmallView, isChecked)
restartApp() restartApp(binding.root)
} }
binding.uiSettingsImmersive.isChecked = PrefManager.getVal(PrefName.ImmersiveMode) binding.uiSettingsImmersive.isChecked = PrefManager.getVal(PrefName.ImmersiveMode)
binding.uiSettingsImmersive.setOnCheckedChangeListener { _, isChecked -> binding.uiSettingsImmersive.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.ImmersiveMode, isChecked) PrefManager.setVal(PrefName.ImmersiveMode, isChecked)
restartApp() restartApp(binding.root)
} }
binding.uiSettingsBannerAnimation.isChecked = PrefManager.getVal(PrefName.BannerAnimations) binding.uiSettingsBannerAnimation.isChecked = PrefManager.getVal(PrefName.BannerAnimations)
binding.uiSettingsBannerAnimation.setOnCheckedChangeListener { _, isChecked -> binding.uiSettingsBannerAnimation.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.BannerAnimations, isChecked) PrefManager.setVal(PrefName.BannerAnimations, isChecked)
restartApp() restartApp(binding.root)
} }
binding.uiSettingsLayoutAnimation.isChecked = PrefManager.getVal(PrefName.LayoutAnimations) binding.uiSettingsLayoutAnimation.isChecked = PrefManager.getVal(PrefName.LayoutAnimations)
binding.uiSettingsLayoutAnimation.setOnCheckedChangeListener { _, isChecked -> binding.uiSettingsLayoutAnimation.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.LayoutAnimations, isChecked) PrefManager.setVal(PrefName.LayoutAnimations, isChecked)
restartApp() restartApp(binding.root)
} }
val map = mapOf( val map = mapOf(
@ -94,41 +95,22 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
mapReverse[PrefManager.getVal(PrefName.AnimationSpeed)] ?: 1f mapReverse[PrefManager.getVal(PrefName.AnimationSpeed)] ?: 1f
binding.uiSettingsAnimationSpeed.addOnChangeListener { _, value, _ -> binding.uiSettingsAnimationSpeed.addOnChangeListener { _, value, _ ->
PrefManager.setVal(PrefName.AnimationSpeed, map[value] ?: 1f) PrefManager.setVal(PrefName.AnimationSpeed, map[value] ?: 1f)
restartApp() restartApp(binding.root)
} }
binding.uiSettingsBlurBanners.isChecked = PrefManager.getVal(PrefName.BlurBanners) binding.uiSettingsBlurBanners.isChecked = PrefManager.getVal(PrefName.BlurBanners)
binding.uiSettingsBlurBanners.setOnCheckedChangeListener { _, isChecked -> binding.uiSettingsBlurBanners.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.BlurBanners, isChecked) PrefManager.setVal(PrefName.BlurBanners, isChecked)
restartApp() restartApp(binding.root)
} }
binding.uiSettingsBlurRadius.value = (PrefManager.getVal(PrefName.BlurRadius) as Float) binding.uiSettingsBlurRadius.value = (PrefManager.getVal(PrefName.BlurRadius) as Float)
binding.uiSettingsBlurRadius.addOnChangeListener { _, value, _ -> binding.uiSettingsBlurRadius.addOnChangeListener { _, value, _ ->
PrefManager.setVal(PrefName.BlurRadius, value) PrefManager.setVal(PrefName.BlurRadius, value)
restartApp() restartApp(binding.root)
} }
binding.uiSettingsBlurSampling.value = (PrefManager.getVal(PrefName.BlurSampling) as Float) binding.uiSettingsBlurSampling.value = (PrefManager.getVal(PrefName.BlurSampling) as Float)
binding.uiSettingsBlurSampling.addOnChangeListener { _, value, _ -> binding.uiSettingsBlurSampling.addOnChangeListener { _, value, _ ->
PrefManager.setVal(PrefName.BlurSampling, value) PrefManager.setVal(PrefName.BlurSampling, value)
restartApp() restartApp(binding.root)
}
}
private fun restartApp() {
Snackbar.make(
binding.root,
R.string.restart_app, Snackbar.LENGTH_SHORT
).apply {
val mainIntent =
Intent.makeRestartActivityTask(
context.packageManager.getLaunchIntentForPackage(
context.packageName
)!!.component
)
setAction("Do it!") {
context.startActivity(mainIntent)
Runtime.getRuntime().exit(0)
}
show()
} }
} }
} }

View file

@ -15,6 +15,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
NSFWExtension(Pref(Location.General, Boolean::class, true)), NSFWExtension(Pref(Location.General, Boolean::class, true)),
SdDl(Pref(Location.General, Boolean::class, false)), SdDl(Pref(Location.General, Boolean::class, false)),
ContinueMedia(Pref(Location.General, Boolean::class, true)), ContinueMedia(Pref(Location.General, Boolean::class, true)),
SearchSources(Pref(Location.General, Boolean::class, true)),
RecentlyListOnly(Pref(Location.General, Boolean::class, false)), RecentlyListOnly(Pref(Location.General, Boolean::class, false)),
SettingsPreferDub(Pref(Location.General, Boolean::class, false)), SettingsPreferDub(Pref(Location.General, Boolean::class, false)),
SubscriptionCheckingNotifications(Pref(Location.General, Boolean::class, true)), SubscriptionCheckingNotifications(Pref(Location.General, Boolean::class, true)),
@ -86,6 +87,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
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, 0)),
SubWindow(Pref(Location.Player, Int::class, 0)), SubWindow(Pref(Location.Player, Int::class, 0)),
SubAlpha(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

@ -0,0 +1,17 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:tint="#000000"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp">
<path
android:fillColor="@android:color/white"
android:pathData="M11.5,3.5m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
<path
android:fillColor="@android:color/white"
android:pathData="M12.13,7.12c-0.17,-0.35 -0.44,-0.65 -0.8,-0.85C10.72,5.91 9.99,5.93 9.4,6.24l0,-0.01L4,9.3V14h2v-3.54l1.5,-0.85C7.18,10.71 7,11.85 7,13v5.33L4.4,21.8L6,23l3,-4l0.22,-3.54L11,18v5h2v-6.5l-1.97,-2.81c-0.04,-0.52 -0.14,-1.76 0.45,-3.4c0.75,1.14 1.88,1.98 3.2,2.41L20.63,23l0.87,-0.5L16.02,13H17v-2c-0.49,0 -2.88,0.17 -4.08,-2.21"/>
</vector>

View file

@ -166,6 +166,44 @@
app:drawableEndCompat="@drawable/ic_round_arrow_drop_down_24" app:drawableEndCompat="@drawable/ic_round_arrow_drop_down_24"
tools:ignore="TextContrastCheck" /> tools:ignore="TextContrastCheck" />
<ani.dantotsu.others.Xpandable
android:id="@+id/subtitleTest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="64dp"
android:fontFamily="@font/poppins_bold"
android:gravity="center_vertical"
android:paddingHorizontal="32dp"
android:text="@string/sub_text_example"
android:textColor="?attr/colorSecondary"
app:drawableEndCompat="@drawable/ic_round_arrow_drop_down_24"
tools:ignore="TextContrastCheck" />
<LinearLayout
android:id="@+id/subtitleTestWindow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/subtitleTestText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="32dp"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/sub_text_example" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="8dp" />
</ani.dantotsu.others.Xpandable>
<com.google.android.material.materialswitch.MaterialSwitch <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/subSwitch" android:id="@+id/subSwitch"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -292,6 +330,37 @@
android:text="@string/sub_window_color_info" android:text="@string/sub_window_color_info"
android:textSize="14sp" /> android:textSize="14sp" />
<Button
android:id="@+id/videoSubAlphaButton"
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/sub_alpha"
android:textAlignment="viewStart"
android:textAllCaps="false"
android:textColor="@color/bg_opp"
app:cornerRadius="0dp"
app:icon="@drawable/ic_round_color_24"
app:iconPadding="16dp"
app:iconSize="24dp"
android:clickable="false" />
<com.google.android.material.slider.Slider
android:id="@+id/videoSubAlpha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp"
android:valueFrom="0"
android:valueTo="1"
android:stepSize="0.1">
</com.google.android.material.slider.Slider>
<Button <Button
android:id="@+id/videoSubFont" android:id="@+id/videoSubFont"
style="@style/Widget.Material3.Button.TextButton" style="@style/Widget.Material3.Button.TextButton"

View file

@ -255,7 +255,25 @@
android:elegantTextHeight="true" android:elegantTextHeight="true"
android:fontFamily="@font/poppins_bold" android:fontFamily="@font/poppins_bold"
android:minHeight="64dp" android:minHeight="64dp"
android:text="@string/always_continue_shows" android:text="@string/always_continue_content"
android:textAlignment="viewStart"
android:textColor="?attr/colorOnBackground"
app:cornerRadius="0dp"
app:drawableTint="?attr/colorPrimary"
app:showText="false"
app:thumbTint="@color/button_switch_track" />
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/settingsSearchSources"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:drawableStart="@drawable/ic_round_search_sources_24"
android:drawablePadding="16dp"
android:elegantTextHeight="true"
android:fontFamily="@font/poppins_bold"
android:minHeight="64dp"
android:text="@string/search_source_list"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="?attr/colorOnBackground" android:textColor="?attr/colorOnBackground"
app:cornerRadius="0dp" app:cornerRadius="0dp"

View file

@ -174,7 +174,7 @@
<string name="settings">Settings</string> <string name="settings">Settings</string>
<string name="extensions">Extensions</string> <string name="extensions">Extensions</string>
<string name="player_settings">Player Settings</string> <string name="player_settings">Player Settings</string>
<string name="recentlyListOnly">Only show My Shows in Recently Updated</string> <string name="recentlyListOnly">Only show my content in \"Recently Updated\"</string>
<string name="download_manager_select">Download Manager</string> <string name="download_manager_select">Download Manager</string>
<string name="downloadInSd">Download in SD card</string> <string name="downloadInSd">Download in SD card</string>
<string name="noSdFound">No SD card was Found.</string> <string name="noSdFound">No SD card was Found.</string>
@ -243,6 +243,8 @@
<string name="sub_window_color_select">Subtitle Window Color</string> <string name="sub_window_color_select">Subtitle Window Color</string>
<string name="sub_window_color_info">"The subtitle window is the part left and right from them. (where the background isn\'t)"</string> <string name="sub_window_color_info">"The subtitle window is the part left and right from them. (where the background isn\'t)"</string>
<string name="sub_color_info"><b>Note:</b> Changing above settings only affects Soft-Subtitles!</string> <string name="sub_color_info"><b>Note:</b> Changing above settings only affects Soft-Subtitles!</string>
<string name="sub_alpha">Subtitle Transparency</string>
<string name="sub_text_example">Example Subtitle</string>
<string name="sub_font_select">Subtitle Font</string> <string name="sub_font_select">Subtitle Font</string>
<string name="subtitle_font_size">Subtitle Size</string> <string name="subtitle_font_size">Subtitle Size</string>
@ -344,14 +346,7 @@
<string name="reload">Reload</string> <string name="reload">Reload</string>
<string name="share">Share</string> <string name="share">Share</string>
<string name="skip">Skip</string> <string name="skip">Skip</string>
<string name="show_skip_time_stamp_button">Show Skip Time Stamp Button</string>
<string name="always_load_time_stamps">Always Load Time Stamps</string>
<string name="auto_hide_time_stamps">Auto Hide Time Stamps</string>string
<string name="hide_skip_button">Hide Skip Button</string>
<string name="timestamps">Time Stamps</string>
<string name="other">Other</string> <string name="other">Other</string>
<string name="auto_skip_op_ed">Auto Skip OP / ED</string>
<string name="requires_time_stamps_to_be_enabled">Requires Time Stamps to be Enabled</string>
<string name="total_repeats">TOTAL REPEATS</string> <string name="total_repeats">TOTAL REPEATS</string>
<string name="custom_lists">Custom Lists</string> <string name="custom_lists">Custom Lists</string>
<string name="donate_desc">Want to support Dantotsu\'s Maintainer?\nConsider Donating</string> <string name="donate_desc">Want to support Dantotsu\'s Maintainer?\nConsider Donating</string>
@ -369,7 +364,8 @@
<string name="planned_anime">Planned Anime</string> <string name="planned_anime">Planned Anime</string>
<string name="planned_manga">Planned Manga</string> <string name="planned_manga">Planned Manga</string>
<string name="image_long_clicking">Open image by Long Clicking</string> <string name="image_long_clicking">Open image by Long Clicking</string>
<string name="always_continue_shows">Always continue Shows</string> <string name="always_continue_content">Always continue previous items</string>
<string name="search_source_list">Search next available source</string>
<string name="timestamp_proxy_desc">Useful if you are getting Handshake Fails</string> <string name="timestamp_proxy_desc">Useful if you are getting Handshake Fails</string>
<string name="timestamp_proxy">Use Proxy for Timestamps</string> <string name="timestamp_proxy">Use Proxy for Timestamps</string>
<string name="check_app_updates">Always check for App Updates</string> <string name="check_app_updates">Always check for App Updates</string>
@ -428,6 +424,13 @@
<string name="anilist_not_found">Seems like that wasn\'t found on Anilist.</string> <string name="anilist_not_found">Seems like that wasn\'t found on Anilist.</string>
<string name="disabled_auto_skip">Disabled Auto Skipping OP &amp; ED</string> <string name="disabled_auto_skip">Disabled Auto Skipping OP &amp; ED</string>
<string name="auto_skip">Auto Skipping OP &amp; ED</string> <string name="auto_skip">Auto Skipping OP &amp; ED</string>
<string name="show_skip_time_stamp_button">Show Skip Time Stamp Button</string>
<string name="always_load_time_stamps">Always Load Time Stamps</string>
<string name="auto_hide_time_stamps">Auto Hide Time Stamps</string>string
<string name="timestamps">Time Stamps</string>
<string name="auto_skip_op_ed">Auto Skip OP / ED</string>
<string name="requires_time_stamps_to_be_enabled">Requires Time Stamps to be Enabled</string>
<string name="hide_skip_button">Make the skip time stamp button disappear after 5 seconds</string>
<string name="copied_to_clipboard">Copied to Clipboard</string> <string name="copied_to_clipboard">Copied to Clipboard</string>
<string name="first_episode">This is the 1st Episode!</string> <string name="first_episode">This is the 1st Episode!</string>
<string name="reset_auto_update">You can long click List Editor button to Reset Auto Update</string> <string name="reset_auto_update">You can long click List Editor button to Reset Auto Update</string>