import/export settings
This commit is contained in:
parent
b559a13bab
commit
49e90a27b8
97 changed files with 1721 additions and 1441 deletions
|
@ -1,7 +1,6 @@
|
|||
package ani.dantotsu.media.anime
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.view.LayoutInflater
|
||||
|
@ -28,7 +27,7 @@ import ani.dantotsu.parsers.AnimeSources
|
|||
import ani.dantotsu.parsers.DynamicAnimeParser
|
||||
import ani.dantotsu.parsers.WatchSources
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.settings.saving.PrefWrapper
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.subcriptions.Notifications.Companion.openSettings
|
||||
import ani.dantotsu.subcriptions.Subscription.Companion.getChannelId
|
||||
import com.google.android.material.chip.Chip
|
||||
|
@ -61,7 +60,7 @@ class AnimeWatchAdapter(
|
|||
_binding = binding
|
||||
|
||||
//Youtube
|
||||
if (media.anime!!.youtube != null && fragment.uiSettings.showYtButton) {
|
||||
if (media.anime!!.youtube != null && PrefManager.getVal(PrefName.ShowYtButton)) {
|
||||
binding.animeSourceYT.visibility = View.VISIBLE
|
||||
binding.animeSourceYT.setOnClickListener {
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(media.anime.youtube))
|
||||
|
@ -92,9 +91,8 @@ class AnimeWatchAdapter(
|
|||
null
|
||||
)
|
||||
}
|
||||
val offline = if (!isOnline(binding.root.context) || PrefWrapper.getVal(
|
||||
PrefName.OfflineMode,
|
||||
false
|
||||
val offline = if (!isOnline(binding.root.context) || PrefManager.getVal(
|
||||
PrefName.OfflineMode
|
||||
)
|
||||
) View.GONE else View.VISIBLE
|
||||
|
||||
|
@ -200,7 +198,7 @@ class AnimeWatchAdapter(
|
|||
var refresh = false
|
||||
var run = false
|
||||
var reversed = media.selected!!.recyclerReversed
|
||||
var style = media.selected!!.recyclerStyle ?: fragment.uiSettings.animeDefaultView
|
||||
var style = media.selected!!.recyclerStyle ?: PrefManager.getVal(PrefName.AnimeDefaultView)
|
||||
dialogBinding.animeSourceTop.rotation = if (reversed) -90f else 90f
|
||||
dialogBinding.sortText.text = if (reversed) "Down to Up" else "Up to Down"
|
||||
dialogBinding.animeSourceTop.setOnClickListener {
|
||||
|
@ -358,7 +356,7 @@ class AnimeWatchAdapter(
|
|||
val episodes = media.anime.episodes!!.keys.toTypedArray()
|
||||
|
||||
val anilistEp = (media.userProgress ?: 0).plus(1)
|
||||
val appEp = loadData<String>("${media.id}_current_ep")?.toIntOrNull() ?: 1
|
||||
val appEp = PrefManager.getNullableCustomVal<String?>("${media.id}_current_ep", null)?.toIntOrNull() ?: 1
|
||||
|
||||
var continueEp = (if (anilistEp > appEp) anilistEp else appEp).toString()
|
||||
if (episodes.contains(continueEp)) {
|
||||
|
@ -370,7 +368,7 @@ class AnimeWatchAdapter(
|
|||
media.id,
|
||||
continueEp
|
||||
)
|
||||
if ((binding.itemEpisodeProgress.layoutParams as LinearLayout.LayoutParams).weight > fragment.playerSettings.watchPercentage) {
|
||||
if ((binding.itemEpisodeProgress.layoutParams as LinearLayout.LayoutParams).weight > PrefManager.getVal<Float>(PrefName.WatchPercentage)) {
|
||||
val e = episodes.indexOf(continueEp)
|
||||
if (e != -1 && e + 1 < episodes.size) {
|
||||
continueEp = episodes[e + 1]
|
||||
|
@ -397,7 +395,7 @@ class AnimeWatchAdapter(
|
|||
fragment.onEpisodeClick(continueEp)
|
||||
}
|
||||
if (fragment.continueEp) {
|
||||
if ((binding.itemEpisodeProgress.layoutParams as LinearLayout.LayoutParams).weight < fragment.playerSettings.watchPercentage) {
|
||||
if ((binding.itemEpisodeProgress.layoutParams as LinearLayout.LayoutParams).weight < PrefManager.getVal<Float>(PrefName.WatchPercentage)) {
|
||||
binding.animeSourceContinue.performClick()
|
||||
fragment.continueEp = false
|
||||
}
|
||||
|
|
|
@ -40,10 +40,9 @@ import ani.dantotsu.others.LanguageMapper
|
|||
import ani.dantotsu.parsers.AnimeParser
|
||||
import ani.dantotsu.parsers.AnimeSources
|
||||
import ani.dantotsu.parsers.HAnimeSources
|
||||
import ani.dantotsu.settings.PlayerSettings
|
||||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.settings.extensionprefs.AnimeSourcePreferencesFragment
|
||||
import ani.dantotsu.settings.saving.PrefWrapper
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.subcriptions.Notifications
|
||||
import ani.dantotsu.subcriptions.Notifications.Group.ANIME_GROUP
|
||||
import ani.dantotsu.subcriptions.Subscription.Companion.getChannelId
|
||||
|
@ -86,8 +85,6 @@ class AnimeWatchFragment : Fragment() {
|
|||
var continueEp: Boolean = false
|
||||
var loaded = false
|
||||
|
||||
lateinit var playerSettings: PlayerSettings
|
||||
lateinit var uiSettings: UserInterfaceSettings
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
@ -120,12 +117,6 @@ class AnimeWatchFragment : Fragment() {
|
|||
var maxGridSize = (screenWidth / 100f).roundToInt()
|
||||
maxGridSize = max(4, maxGridSize - (maxGridSize % 2))
|
||||
|
||||
playerSettings =
|
||||
loadData("player_settings", toast = false)
|
||||
?: PlayerSettings().apply { saveData("player_settings", this) }
|
||||
uiSettings = loadData("ui_settings", toast = false)
|
||||
?: UserInterfaceSettings().apply { saveData("ui_settings", this) }
|
||||
|
||||
val gridLayoutManager = GridLayoutManager(requireContext(), maxGridSize)
|
||||
|
||||
gridLayoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
|
@ -174,7 +165,7 @@ class AnimeWatchFragment : Fragment() {
|
|||
media.selected = model.loadSelected(media)
|
||||
|
||||
subscribed =
|
||||
SubscriptionHelper.getSubscriptions(requireContext()).containsKey(media.id)
|
||||
SubscriptionHelper.getSubscriptions().containsKey(media.id)
|
||||
|
||||
style = media.selected!!.recyclerStyle
|
||||
reverse = media.selected!!.recyclerReversed
|
||||
|
@ -191,7 +182,7 @@ class AnimeWatchFragment : Fragment() {
|
|||
headerAdapter = AnimeWatchAdapter(it, this, model.watchSources!!)
|
||||
episodeAdapter =
|
||||
EpisodeAdapter(
|
||||
style ?: uiSettings.animeDefaultView,
|
||||
style ?: PrefManager.getVal(PrefName.AnimeDefaultView),
|
||||
media,
|
||||
this,
|
||||
offlineMode = offlineMode
|
||||
|
@ -292,7 +283,7 @@ class AnimeWatchFragment : Fragment() {
|
|||
model.watchSources?.get(selected.sourceIndex)?.showUserTextListener = null
|
||||
selected.sourceIndex = i
|
||||
selected.server = null
|
||||
model.saveSelected(media.id, selected, requireActivity())
|
||||
model.saveSelected(media.id, selected)
|
||||
media.selected = selected
|
||||
return model.watchSources?.get(i)!!
|
||||
}
|
||||
|
@ -300,7 +291,7 @@ class AnimeWatchFragment : Fragment() {
|
|||
fun onLangChange(i: Int) {
|
||||
val selected = model.loadSelected(media)
|
||||
selected.langIndex = i
|
||||
model.saveSelected(media.id, selected, requireActivity())
|
||||
model.saveSelected(media.id, selected)
|
||||
media.selected = selected
|
||||
}
|
||||
|
||||
|
@ -308,7 +299,7 @@ class AnimeWatchFragment : Fragment() {
|
|||
val selected = model.loadSelected(media)
|
||||
model.watchSources?.get(selected.sourceIndex)?.selectDub = checked
|
||||
selected.preferDub = checked
|
||||
model.saveSelected(media.id, selected, requireActivity())
|
||||
model.saveSelected(media.id, selected)
|
||||
media.selected = selected
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
model.forceLoadEpisode(
|
||||
|
@ -327,7 +318,7 @@ class AnimeWatchFragment : Fragment() {
|
|||
reverse = rev
|
||||
media.selected!!.recyclerStyle = style
|
||||
media.selected!!.recyclerReversed = reverse
|
||||
model.saveSelected(media.id, media.selected!!, requireActivity())
|
||||
model.saveSelected(media.id, media.selected!!)
|
||||
reload()
|
||||
}
|
||||
|
||||
|
@ -335,7 +326,7 @@ class AnimeWatchFragment : Fragment() {
|
|||
media.selected!!.chip = i
|
||||
start = s
|
||||
end = e
|
||||
model.saveSelected(media.id, media.selected!!, requireActivity())
|
||||
model.saveSelected(media.id, media.selected!!)
|
||||
reload()
|
||||
}
|
||||
|
||||
|
@ -436,7 +427,7 @@ class AnimeWatchFragment : Fragment() {
|
|||
|
||||
fun onEpisodeClick(i: String) {
|
||||
model.continueMedia = false
|
||||
model.saveSelected(media.id, media.selected!!, requireActivity())
|
||||
model.saveSelected(media.id, media.selected!!)
|
||||
model.onEpisodeClick(media, i, requireActivity().supportFragmentManager)
|
||||
}
|
||||
|
||||
|
@ -475,11 +466,11 @@ class AnimeWatchFragment : Fragment() {
|
|||
)
|
||||
)
|
||||
val taskName = AnimeDownloaderService.AnimeDownloadTask.getTaskName(media.mainName(), i)
|
||||
val id = PrefWrapper.getAnimeDownloadPreferences().getString(
|
||||
val id = PrefManager.getAnimeDownloadPreferences().getString(
|
||||
taskName,
|
||||
""
|
||||
) ?: ""
|
||||
PrefWrapper.getAnimeDownloadPreferences().edit().remove(taskName).apply()
|
||||
PrefManager.getAnimeDownloadPreferences().edit().remove(taskName).apply()
|
||||
DownloadService.sendRemoveDownload(
|
||||
requireContext(),
|
||||
ExoplayerDownloadService::class.java,
|
||||
|
@ -531,7 +522,7 @@ class AnimeWatchFragment : Fragment() {
|
|||
selected.latest =
|
||||
media.userProgress?.toFloat()?.takeIf { selected.latest < it } ?: selected.latest
|
||||
|
||||
model.saveSelected(media.id, selected, requireActivity())
|
||||
model.saveSelected(media.id, selected)
|
||||
headerAdapter.handleEpisodes()
|
||||
val isDownloaded = model.watchSources!!.isDownloadedSource(media.selected!!.sourceIndex)
|
||||
episodeAdapter.offlineMode = isDownloaded
|
||||
|
@ -547,7 +538,7 @@ class AnimeWatchFragment : Fragment() {
|
|||
arr = (arr.reversed() as? ArrayList<Episode>) ?: arr
|
||||
}
|
||||
episodeAdapter.arr = arr
|
||||
episodeAdapter.updateType(style ?: uiSettings.animeDefaultView)
|
||||
episodeAdapter.updateType(style ?: PrefManager.getVal(PrefName.AnimeDefaultView))
|
||||
episodeAdapter.notifyItemRangeInserted(0, arr.size)
|
||||
for (download in downloadManager.animeDownloadedTypes) {
|
||||
if (download.title == media.mainName()) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import ani.dantotsu.databinding.ItemEpisodeListBinding
|
|||
import ani.dantotsu.download.anime.AnimeDownloaderService
|
||||
import ani.dantotsu.download.video.Helper
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.settings.saving.PrefWrapper
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.model.GlideUrl
|
||||
import kotlinx.coroutines.delay
|
||||
|
@ -29,8 +29,8 @@ import kotlin.math.ln
|
|||
import kotlin.math.pow
|
||||
|
||||
fun handleProgress(cont: LinearLayout, bar: View, empty: View, mediaId: Int, ep: String) {
|
||||
val curr = loadData<Long>("${mediaId}_${ep}")
|
||||
val max = loadData<Long>("${mediaId}_${ep}_max")
|
||||
val curr = PrefManager.getNullableCustomVal("${mediaId}_${ep}", null as Long?)
|
||||
val max = PrefManager.getNullableCustomVal("${mediaId}_${ep}_max", null as Long?)
|
||||
if (curr != null && max != null) {
|
||||
cont.visibility = View.VISIBLE
|
||||
val div = curr.toFloat() / max.toFloat()
|
||||
|
@ -109,7 +109,7 @@ class EpisodeAdapter(
|
|||
when (holder) {
|
||||
is EpisodeListViewHolder -> {
|
||||
val binding = holder.binding
|
||||
setAnimation(fragment.requireContext(), holder.binding.root, fragment.uiSettings)
|
||||
setAnimation(fragment.requireContext(), holder.binding.root)
|
||||
|
||||
val thumb =
|
||||
ep.thumb?.let { if (it.url.isNotEmpty()) GlideUrl(it.url) { it.headers } else null }
|
||||
|
@ -158,7 +158,7 @@ class EpisodeAdapter(
|
|||
|
||||
is EpisodeGridViewHolder -> {
|
||||
val binding = holder.binding
|
||||
setAnimation(fragment.requireContext(), holder.binding.root, fragment.uiSettings)
|
||||
setAnimation(fragment.requireContext(), holder.binding.root)
|
||||
|
||||
val thumb =
|
||||
ep.thumb?.let { if (it.url.isNotEmpty()) GlideUrl(it.url) { it.headers } else null }
|
||||
|
@ -201,7 +201,7 @@ class EpisodeAdapter(
|
|||
|
||||
is EpisodeCompactViewHolder -> {
|
||||
val binding = holder.binding
|
||||
setAnimation(fragment.requireContext(), holder.binding.root, fragment.uiSettings)
|
||||
setAnimation(fragment.requireContext(), holder.binding.root)
|
||||
binding.itemEpisodeNumber.text = ep.number
|
||||
binding.itemEpisodeFillerView.visibility =
|
||||
if (ep.filler) View.VISIBLE else View.GONE
|
||||
|
@ -252,7 +252,7 @@ class EpisodeAdapter(
|
|||
media.mainName(),
|
||||
episodeNumber
|
||||
)
|
||||
val id = PrefWrapper.getAnimeDownloadPreferences().getString(
|
||||
val id = PrefManager.getAnimeDownloadPreferences().getString(
|
||||
taskName,
|
||||
""
|
||||
) ?: ""
|
||||
|
|
|
@ -80,11 +80,9 @@ import ani.dantotsu.others.AniSkip.getType
|
|||
import ani.dantotsu.others.ResettableTimer
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.parsers.*
|
||||
import ani.dantotsu.settings.PlayerSettings
|
||||
import ani.dantotsu.settings.PlayerSettingsActivity
|
||||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.settings.saving.PrefWrapper
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||
|
@ -185,9 +183,6 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
private var pipEnabled = false
|
||||
private var aspectRatio = Rational(16, 9)
|
||||
|
||||
var settings = PlayerSettings()
|
||||
private var uiSettings = UserInterfaceSettings()
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
val model: MediaDetailsViewModel by viewModels()
|
||||
|
||||
|
@ -241,8 +236,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupSubFormatting(playerView: PlayerView, settings: PlayerSettings) {
|
||||
val primaryColor = when (settings.primaryColor) {
|
||||
private fun setupSubFormatting(playerView: PlayerView) {
|
||||
val primaryColor = when (PrefManager.getVal<Int>(PrefName.PrimaryColor)) {
|
||||
0 -> Color.BLACK
|
||||
1 -> Color.DKGRAY
|
||||
2 -> Color.GRAY
|
||||
|
@ -257,7 +252,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
11 -> Color.TRANSPARENT
|
||||
else -> Color.WHITE
|
||||
}
|
||||
val secondaryColor = when (settings.secondaryColor) {
|
||||
val secondaryColor = when (PrefManager.getVal<Int>(PrefName.SecondaryColor)) {
|
||||
0 -> Color.BLACK
|
||||
1 -> Color.DKGRAY
|
||||
2 -> Color.GRAY
|
||||
|
@ -272,14 +267,14 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
11 -> Color.TRANSPARENT
|
||||
else -> Color.BLACK
|
||||
}
|
||||
val outline = when (settings.outline) {
|
||||
val outline = when (PrefManager.getVal<Int>(PrefName.Outline)) {
|
||||
0 -> EDGE_TYPE_OUTLINE // Normal
|
||||
1 -> EDGE_TYPE_DEPRESSED // Shine
|
||||
2 -> EDGE_TYPE_DROP_SHADOW // Drop shadow
|
||||
3 -> EDGE_TYPE_NONE // No outline
|
||||
else -> EDGE_TYPE_OUTLINE // Normal
|
||||
}
|
||||
val subBackground = when (settings.subBackground) {
|
||||
val subBackground = when (PrefManager.getVal<Int>(PrefName.SubBackground)) {
|
||||
0 -> Color.TRANSPARENT
|
||||
1 -> Color.BLACK
|
||||
2 -> Color.DKGRAY
|
||||
|
@ -294,7 +289,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
11 -> Color.MAGENTA
|
||||
else -> Color.TRANSPARENT
|
||||
}
|
||||
val subWindow = when (settings.subWindow) {
|
||||
val subWindow = when (PrefManager.getVal<Int>(PrefName.SubWindow)) {
|
||||
0 -> Color.TRANSPARENT
|
||||
1 -> Color.BLACK
|
||||
2 -> Color.DKGRAY
|
||||
|
@ -309,7 +304,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
11 -> Color.MAGENTA
|
||||
else -> Color.TRANSPARENT
|
||||
}
|
||||
val font = when (settings.font) {
|
||||
val font = when (PrefManager.getVal<Int>(PrefName.Font)) {
|
||||
0 -> ResourcesCompat.getFont(this, R.font.poppins_semi_bold)
|
||||
1 -> ResourcesCompat.getFont(this, R.font.poppins_bold)
|
||||
2 -> ResourcesCompat.getFont(this, R.font.poppins)
|
||||
|
@ -332,7 +327,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityExoplayerBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
@ -355,19 +350,6 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
finishAndRemoveTask()
|
||||
}
|
||||
|
||||
settings = loadData("player_settings") ?: PlayerSettings().apply {
|
||||
saveData(
|
||||
"player_settings",
|
||||
this
|
||||
)
|
||||
}
|
||||
uiSettings = loadData("ui_settings") ?: UserInterfaceSettings().apply {
|
||||
saveData(
|
||||
"ui_settings",
|
||||
this
|
||||
)
|
||||
}
|
||||
|
||||
playerView = findViewById(R.id.player_view)
|
||||
exoPlay = playerView.findViewById(androidx.media3.ui.R.id.exo_play)
|
||||
exoSource = playerView.findViewById(R.id.exo_source)
|
||||
|
@ -426,14 +408,14 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
}
|
||||
|
||||
setupSubFormatting(playerView, settings)
|
||||
setupSubFormatting(playerView)
|
||||
|
||||
|
||||
playerView.subtitleView?.alpha = when (settings.subtitles) {
|
||||
playerView.subtitleView?.alpha = when (PrefManager.getVal<Boolean>(PrefName.Subtitles)) {
|
||||
true -> 1f
|
||||
false -> 0f
|
||||
}
|
||||
val fontSize = settings.fontSize.toFloat()
|
||||
val fontSize = PrefManager.getVal<Int>(PrefName.FontSize).toFloat()
|
||||
playerView.subtitleView?.setFixedTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize)
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
|
@ -466,17 +448,16 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
} else View.GONE
|
||||
}
|
||||
|
||||
exoSkipOpEd.alpha = if (settings.autoSkipOPED) 1f else 0.3f
|
||||
exoSkipOpEd.alpha = if (PrefManager.getVal(PrefName.AutoSkipOPED)) 1f else 0.3f
|
||||
exoSkipOpEd.setOnClickListener {
|
||||
settings.autoSkipOPED = if (settings.autoSkipOPED) {
|
||||
if (PrefManager.getVal(PrefName.AutoSkipOPED)) {
|
||||
snackString(getString(R.string.disabled_auto_skip))
|
||||
false
|
||||
PrefManager.setVal(PrefName.AutoSkipOPED, false)
|
||||
} else {
|
||||
snackString(getString(R.string.auto_skip))
|
||||
true
|
||||
PrefManager.setVal(PrefName.AutoSkipOPED, true)
|
||||
}
|
||||
saveData("player_settings", settings)
|
||||
exoSkipOpEd.alpha = if (settings.autoSkipOPED) 1f else 0.3f
|
||||
exoSkipOpEd.alpha = if (PrefManager.getVal(PrefName.AutoSkipOPED)) 1f else 0.3f
|
||||
}
|
||||
|
||||
//Play Pause
|
||||
|
@ -503,7 +484,9 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
// Picture-in-picture
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
pipEnabled =
|
||||
packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) && settings.pip
|
||||
packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) && PrefManager.getVal(
|
||||
PrefName.Pip
|
||||
)
|
||||
if (pipEnabled) {
|
||||
exoPip.visibility = View.VISIBLE
|
||||
exoPip.setOnClickListener {
|
||||
|
@ -536,11 +519,12 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
|
||||
//Skip Time Button
|
||||
if (settings.skipTime > 0) {
|
||||
exoSkip.findViewById<TextView>(R.id.exo_skip_time).text = settings.skipTime.toString()
|
||||
var skipTime = PrefManager.getVal<Int>(PrefName.SkipTime)
|
||||
if (skipTime > 0) {
|
||||
exoSkip.findViewById<TextView>(R.id.exo_skip_time).text = skipTime.toString()
|
||||
exoSkip.setOnClickListener {
|
||||
if (isInitialized)
|
||||
exoPlayer.seekTo(exoPlayer.currentPosition + settings.skipTime * 1000)
|
||||
exoPlayer.seekTo(exoPlayer.currentPosition + skipTime * 1000)
|
||||
}
|
||||
exoSkip.setOnLongClickListener {
|
||||
val dialog = Dialog(this, R.style.MyPopup)
|
||||
|
@ -551,18 +535,19 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
if (settings.skipTime <= 120) {
|
||||
dialog.findViewById<Slider>(R.id.seekbar).value = settings.skipTime.toFloat()
|
||||
if (skipTime <= 120) {
|
||||
dialog.findViewById<Slider>(R.id.seekbar).value = skipTime.toFloat()
|
||||
} else {
|
||||
dialog.findViewById<Slider>(R.id.seekbar).value = 120f
|
||||
}
|
||||
dialog.findViewById<Slider>(R.id.seekbar).addOnChangeListener { _, value, _ ->
|
||||
settings.skipTime = value.toInt()
|
||||
saveData(player, settings)
|
||||
skipTime = value.toInt()
|
||||
//saveData(player, settings)
|
||||
PrefManager.setVal(PrefName.SkipTime, skipTime)
|
||||
playerView.findViewById<TextView>(R.id.exo_skip_time).text =
|
||||
settings.skipTime.toString()
|
||||
skipTime.toString()
|
||||
dialog.findViewById<TextView>(R.id.seekbar_value).text =
|
||||
settings.skipTime.toString()
|
||||
skipTime.toString()
|
||||
}
|
||||
dialog.findViewById<Slider>(R.id.seekbar)
|
||||
.addOnSliderTouchListener(object : Slider.OnSliderTouchListener {
|
||||
|
@ -574,7 +559,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
dialog.findViewById<TextView>(R.id.seekbar_title).text =
|
||||
getString(R.string.skip_time)
|
||||
dialog.findViewById<TextView>(R.id.seekbar_value).text =
|
||||
settings.skipTime.toString()
|
||||
skipTime.toString()
|
||||
@Suppress("DEPRECATION")
|
||||
dialog.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
dialog.show()
|
||||
|
@ -584,7 +569,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
exoSkip.visibility = View.GONE
|
||||
}
|
||||
|
||||
val gestureSpeed = (300 * uiSettings.animationSpeed).toLong()
|
||||
val gestureSpeed = (300 * PrefManager.getVal<Float>(PrefName.AnimationSpeed)).toLong()
|
||||
//Player UI Visibility Handler
|
||||
val brightnessRunnable = Runnable {
|
||||
if (exoBrightnessCont.alpha == 1f)
|
||||
|
@ -614,7 +599,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
})
|
||||
val overshoot = AnimationUtils.loadInterpolator(this, R.anim.over_shoot)
|
||||
val controllerDuration = (uiSettings.animationSpeed * 200).toLong()
|
||||
val controllerDuration = (300 * PrefManager.getVal<Float>(PrefName.AnimationSpeed)).toLong()
|
||||
fun handleController() {
|
||||
if (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) !isInPictureInPictureMode else true) {
|
||||
if (playerView.isControllerFullyVisible) {
|
||||
|
@ -699,13 +684,14 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
var seekTimesR = 0
|
||||
|
||||
fun seek(forward: Boolean, event: MotionEvent? = null) {
|
||||
val seekTime = PrefManager.getVal<Int>(PrefName.SeekTime)
|
||||
val (card, text) = if (forward) {
|
||||
forwardText.text = "+${settings.seekTime * ++seekTimesF}"
|
||||
handler.post { exoPlayer.seekTo(exoPlayer.currentPosition + settings.seekTime * 1000) }
|
||||
forwardText.text = "+${seekTime * ++seekTimesF}"
|
||||
handler.post { exoPlayer.seekTo(exoPlayer.currentPosition + seekTime * 1000) }
|
||||
fastForwardCard to forwardText
|
||||
} else {
|
||||
rewindText.text = "-${settings.seekTime * ++seekTimesR}"
|
||||
handler.post { exoPlayer.seekTo(exoPlayer.currentPosition - settings.seekTime * 1000) }
|
||||
rewindText.text = "-${seekTime * ++seekTimesR}"
|
||||
handler.post { exoPlayer.seekTo(exoPlayer.currentPosition - seekTime * 1000) }
|
||||
fastRewindCard to rewindText
|
||||
}
|
||||
|
||||
|
@ -760,7 +746,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
}
|
||||
|
||||
if (!settings.doubleTap) {
|
||||
if (!PrefManager.getVal<Boolean>(PrefName.DoubleTap)) {
|
||||
playerView.findViewById<View>(R.id.exo_fast_forward_button_cont).visibility =
|
||||
View.VISIBLE
|
||||
playerView.findViewById<View>(R.id.exo_fast_rewind_button_cont).visibility =
|
||||
|
@ -781,10 +767,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
keyMap[KEYCODE_DPAD_LEFT] = { seek(false) }
|
||||
|
||||
//Screen Gestures
|
||||
if (settings.gestures || settings.doubleTap) {
|
||||
if (PrefManager.getVal<Boolean>(PrefName.Gestures) || PrefManager.getVal<Boolean>(PrefName.DoubleTap)) {
|
||||
|
||||
fun doubleTap(forward: Boolean, event: MotionEvent) {
|
||||
if (!locked && isInitialized && settings.doubleTap) {
|
||||
if (!locked && isInitialized && PrefManager.getVal<Boolean>(PrefName.DoubleTap)) {
|
||||
seek(forward, event)
|
||||
}
|
||||
}
|
||||
|
@ -855,7 +841,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
//FastRewind (Left Panel)
|
||||
val fastRewindDetector = GestureDetector(this, object : GesturesListener() {
|
||||
override fun onLongClick(event: MotionEvent) {
|
||||
if (settings.fastforward) fastForward()
|
||||
if (PrefManager.getVal(PrefName.FastForward)) fastForward()
|
||||
}
|
||||
|
||||
override fun onDoubleClick(event: MotionEvent) {
|
||||
|
@ -863,7 +849,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
|
||||
override fun onScrollYClick(y: Float) {
|
||||
if (!locked && settings.gestures) {
|
||||
if (!locked && PrefManager.getVal(PrefName.Gestures)) {
|
||||
exoBrightness.value = clamp(exoBrightness.value + y / 100, 0f, 10f)
|
||||
if (exoBrightnessCont.visibility != View.VISIBLE) {
|
||||
exoBrightnessCont.visibility = View.VISIBLE
|
||||
|
@ -887,7 +873,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
//FastForward (Right Panel)
|
||||
val fastForwardDetector = GestureDetector(this, object : GesturesListener() {
|
||||
override fun onLongClick(event: MotionEvent) {
|
||||
if (settings.fastforward) fastForward()
|
||||
if (PrefManager.getVal(PrefName.FastForward)) fastForward()
|
||||
}
|
||||
|
||||
override fun onDoubleClick(event: MotionEvent) {
|
||||
|
@ -895,7 +881,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
|
||||
override fun onScrollYClick(y: Float) {
|
||||
if (!locked && settings.gestures) {
|
||||
if (!locked && PrefManager.getVal(PrefName.Gestures)) {
|
||||
exoVolume.value = clamp(exoVolume.value + y / 100, 0f, 10f)
|
||||
if (exoVolumeCont.visibility != View.VISIBLE) {
|
||||
exoVolumeCont.visibility = View.VISIBLE
|
||||
|
@ -949,10 +935,9 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
fun change(index: Int) {
|
||||
if (isInitialized) {
|
||||
changingServer = false
|
||||
saveData(
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_${episodeArr[currentEpisodeIndex]}",
|
||||
exoPlayer.currentPosition,
|
||||
this
|
||||
exoPlayer.currentPosition
|
||||
)
|
||||
exoPlayer.seekTo(0)
|
||||
val prev = episodeArr[currentEpisodeIndex]
|
||||
|
@ -1009,12 +994,15 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
currentEpisodeIndex = episodeArr.indexOf(ep.number)
|
||||
episodeTitle.setSelection(currentEpisodeIndex)
|
||||
if (isInitialized) releasePlayer()
|
||||
playbackPosition = loadData("${media.id}_${ep.number}", this) ?: 0
|
||||
playbackPosition = PrefManager.getCustomVal(
|
||||
"${media.id}_${ep.number}",
|
||||
0
|
||||
)
|
||||
initPlayer()
|
||||
preloading = false
|
||||
val context = this
|
||||
val offline = PrefWrapper.getVal(PrefName.OfflineMode, false)
|
||||
val incognito = PrefWrapper.getVal(PrefName.Incognito, false)
|
||||
val offline: Boolean = PrefManager.getVal(PrefName.OfflineMode)
|
||||
val incognito: Boolean = PrefManager.getVal(PrefName.Incognito)
|
||||
if ((isOnline(context) && !offline) && Discord.token != null && !incognito) {
|
||||
lifecycleScope.launch {
|
||||
val presence = RPC.createPresence(RPC.Companion.RPCData(
|
||||
|
@ -1059,7 +1047,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
|
||||
//FullScreen
|
||||
isFullscreen = loadData("${media.id}_fullscreenInt", this) ?: isFullscreen
|
||||
isFullscreen = PrefManager.getCustomVal("${media.id}_fullscreenInt", isFullscreen)
|
||||
playerView.resizeMode = when (isFullscreen) {
|
||||
0 -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
1 -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
|
@ -1083,11 +1071,11 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
else -> "Original"
|
||||
}
|
||||
)
|
||||
saveData("${media.id}_fullscreenInt", isFullscreen, this)
|
||||
PrefManager.setCustomVal("${media.id}_fullscreenInt", isFullscreen)
|
||||
}
|
||||
|
||||
//Cast
|
||||
if (settings.cast) {
|
||||
if (PrefManager.getVal(PrefName.Cast)) {
|
||||
playerView.findViewById<MediaRouteButton>(R.id.exo_cast).apply {
|
||||
visibility = View.VISIBLE
|
||||
try {
|
||||
|
@ -1105,10 +1093,9 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
|
||||
//Settings
|
||||
exoSettings.setOnClickListener {
|
||||
saveData(
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_${media.anime!!.selectedEpisode}",
|
||||
exoPlayer.currentPosition,
|
||||
this
|
||||
exoPlayer.currentPosition
|
||||
)
|
||||
val intent = Intent(this, PlayerSettingsActivity::class.java).apply {
|
||||
putExtra("subtitle", subtitle)
|
||||
|
@ -1119,7 +1106,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
|
||||
//Speed
|
||||
val speeds =
|
||||
if (settings.cursedSpeeds)
|
||||
if (PrefManager.getVal(PrefName.CursedSpeeds))
|
||||
arrayOf(1f, 1.25f, 1.5f, 1.75f, 2f, 2.5f, 3f, 4f, 5f, 10f, 25f, 50f)
|
||||
else
|
||||
arrayOf(
|
||||
|
@ -1139,7 +1126,11 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
)
|
||||
|
||||
val speedsName = speeds.map { "${it}x" }.toTypedArray()
|
||||
var curSpeed = loadData("${media.id}_speed", this) ?: settings.defaultSpeed
|
||||
//var curSpeed = loadData("${media.id}_speed", this) ?: settings.defaultSpeed
|
||||
var curSpeed = PrefManager.getCustomVal(
|
||||
"${media.id}_speed",
|
||||
PrefManager.getVal<Int>(PrefName.DefaultSpeed)
|
||||
)
|
||||
|
||||
playbackParameters = PlaybackParameters(speeds[curSpeed])
|
||||
var speed: Float
|
||||
|
@ -1148,7 +1139,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
exoSpeed.setOnClickListener {
|
||||
val dialog = speedDialog.setSingleChoiceItems(speedsName, curSpeed) { dialog, i ->
|
||||
if (isInitialized) {
|
||||
saveData("${media.id}_speed", i, this)
|
||||
PrefManager.setCustomVal("${media.id}_speed", i)
|
||||
speed = speeds[i]
|
||||
curSpeed = i
|
||||
playbackParameters = PlaybackParameters(speed)
|
||||
|
@ -1161,7 +1152,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
speedDialog.setOnCancelListener { hideSystemBars() }
|
||||
|
||||
if (settings.autoPlay) {
|
||||
if (PrefManager.getVal(PrefName.AutoPlay)) {
|
||||
var touchTimer = Timer()
|
||||
fun touched() {
|
||||
interacted = true
|
||||
|
@ -1182,8 +1173,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
}
|
||||
|
||||
isFullscreen = settings.resize
|
||||
playerView.resizeMode = when (settings.resize) {
|
||||
isFullscreen = PrefManager.getVal(PrefName.Resize)
|
||||
playerView.resizeMode = when (isFullscreen) {
|
||||
0 -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
1 -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
2 -> AspectRatioFrameLayout.RESIZE_MODE_FILL
|
||||
|
@ -1191,25 +1182,42 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
|
||||
preloading = false
|
||||
val incognito = PrefWrapper.getVal(PrefName.Incognito, false)
|
||||
val incognito: Boolean = PrefManager.getVal(PrefName.Incognito)
|
||||
val showProgressDialog =
|
||||
if (settings.askIndividual) loadData<Boolean>("${media.id}_progressDialog")
|
||||
?: true else false
|
||||
if (!incognito && showProgressDialog && Anilist.userid != null && if (media.isAdult) settings.updateForH else true)
|
||||
if (PrefManager.getVal(PrefName.AskIndividualPlayer)) PrefManager.getCustomVal(
|
||||
"${media.id}_progressDialog",
|
||||
true
|
||||
) else false
|
||||
if (!incognito && showProgressDialog && Anilist.userid != null && if (media.isAdult) PrefManager.getVal<Boolean>(
|
||||
PrefName.UpdateForHPlayer
|
||||
) else true
|
||||
)
|
||||
AlertDialog.Builder(this, R.style.MyPopup)
|
||||
.setTitle(getString(R.string.auto_update, media.userPreferredName))
|
||||
.apply {
|
||||
setOnCancelListener { hideSystemBars() }
|
||||
setCancelable(false)
|
||||
setPositiveButton(getString(R.string.yes)) { dialog, _ ->
|
||||
saveData("${media.id}_progressDialog", false)
|
||||
saveData("${media.id}_save_progress", true)
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_ProgressDialog",
|
||||
false
|
||||
)
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_save_progress",
|
||||
true
|
||||
)
|
||||
dialog.dismiss()
|
||||
model.setEpisode(episodes[media.anime!!.selectedEpisode!!]!!, "invoke")
|
||||
}
|
||||
setNegativeButton(getString(R.string.no)) { dialog, _ ->
|
||||
saveData("${media.id}_progressDialog", false)
|
||||
saveData("${media.id}_save_progress", false)
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_ProgressDialog",
|
||||
false
|
||||
)
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_save_progress",
|
||||
false
|
||||
)
|
||||
toast(getString(R.string.reset_auto_update))
|
||||
dialog.dismiss()
|
||||
model.setEpisode(episodes[media.anime!!.selectedEpisode!!]!!, "invoke")
|
||||
|
@ -1219,7 +1227,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
else model.setEpisode(episodes[media.anime!!.selectedEpisode!!]!!, "invoke")
|
||||
|
||||
//Start the recursive Fun
|
||||
if (settings.timeStampsEnabled)
|
||||
if (PrefManager.getVal(PrefName.TimeStampsEnabled))
|
||||
updateTimeStamp()
|
||||
|
||||
}
|
||||
|
@ -1227,12 +1235,15 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
private fun initPlayer() {
|
||||
checkNotch()
|
||||
|
||||
saveData("${media.id}_current_ep", media.anime!!.selectedEpisode!!, this)
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_current_ep",
|
||||
media.anime!!.selectedEpisode!!
|
||||
)
|
||||
|
||||
val set = loadData<MutableSet<Int>>("continue_ANIME", this) ?: mutableSetOf()
|
||||
val set = PrefManager.getVal<Set<Int>>(PrefName.ContinueAnime).toMutableSet()
|
||||
if (set.contains(media.id)) set.remove(media.id)
|
||||
set.add(media.id)
|
||||
saveData("continue_ANIME", set, this)
|
||||
PrefManager.setVal(PrefName.ContinueAnime, set.toSet())
|
||||
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
extractor?.onVideoStopped(video)
|
||||
|
@ -1243,7 +1254,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
video = ext.videos.getOrNull(episode.selectedVideo) ?: return
|
||||
|
||||
subtitle = intent.getSerialized("subtitle")
|
||||
?: when (val subLang: String? = loadData("subLang_${media.id}", this)) {
|
||||
?: when (val subLang: String? =
|
||||
PrefManager.getCustomVal("subLang_${media.id}", null as String?)) {
|
||||
null -> {
|
||||
when (episode.selectedSubtitle) {
|
||||
null -> null
|
||||
|
@ -1342,7 +1354,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
|
||||
val downloadedMediaItem = if (ext.server.offline) {
|
||||
val key = ext.server.name
|
||||
downloadId = PrefWrapper.getAnimeDownloadPreferences()
|
||||
downloadId = PrefManager.getAnimeDownloadPreferences()
|
||||
.getString(key, null)
|
||||
if (downloadId != null) {
|
||||
Helper.downloadManager(this)
|
||||
|
@ -1399,7 +1411,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
// TrackSelectionOverride(trackSelector, 2))
|
||||
)
|
||||
|
||||
if (playbackPosition != 0L && !changingServer && !settings.alwaysContinue) {
|
||||
if (playbackPosition != 0L && !changingServer && !PrefManager.getVal<Boolean>(PrefName.AlwaysContinue)) {
|
||||
val time = String.format(
|
||||
"%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(playbackPosition),
|
||||
TimeUnit.MILLISECONDS.toMinutes(playbackPosition) - TimeUnit.HOURS.toMinutes(
|
||||
|
@ -1441,9 +1453,12 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
this.playbackParameters = this@ExoplayerView.playbackParameters
|
||||
setMediaItem(mediaItem)
|
||||
prepare()
|
||||
loadData<Long>("${media.id}_${media.anime!!.selectedEpisode}_max")?.apply {
|
||||
if (this <= playbackPosition) playbackPosition = max(0, this - 5)
|
||||
}
|
||||
PrefManager.getCustomVal(
|
||||
"${media.id}_${media.anime!!.selectedEpisode}_max",
|
||||
Long.MAX_VALUE
|
||||
)
|
||||
.takeIf { it != Long.MAX_VALUE }
|
||||
?.let { if (it <= playbackPosition) playbackPosition = max(0, it - 5) }
|
||||
seekTo(playbackPosition)
|
||||
}
|
||||
playerView.player = exoPlayer
|
||||
|
@ -1516,8 +1531,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
changingServer = true
|
||||
|
||||
media.selected!!.server = null
|
||||
saveData("${media.id}_${media.anime!!.selectedEpisode}", exoPlayer.currentPosition, this)
|
||||
model.saveSelected(media.id, media.selected!!, this)
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_${media.anime!!.selectedEpisode}", exoPlayer.currentPosition
|
||||
)
|
||||
model.saveSelected(media.id, media.selected!!)
|
||||
model.onEpisodeClick(
|
||||
media, episode.number, this.supportFragmentManager,
|
||||
launch = false
|
||||
|
@ -1525,8 +1542,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
|
||||
private fun subClick() {
|
||||
saveData("${media.id}_${media.anime!!.selectedEpisode}", exoPlayer.currentPosition, this)
|
||||
model.saveSelected(media.id, media.selected!!, this)
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_${media.anime!!.selectedEpisode}", exoPlayer.currentPosition
|
||||
)
|
||||
model.saveSelected(media.id, media.selected!!)
|
||||
SubtitleDialogFragment().show(supportFragmentManager, "dialog")
|
||||
}
|
||||
|
||||
|
@ -1538,10 +1557,9 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
playerView.player?.pause()
|
||||
}
|
||||
if (exoPlayer.currentPosition > 5000) {
|
||||
saveData(
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_${media.anime!!.selectedEpisode}",
|
||||
exoPlayer.currentPosition,
|
||||
this
|
||||
exoPlayer.currentPosition
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1566,7 +1584,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
|
||||
private var wasPlaying = false
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
if (settings.focusPause && !epChanging) {
|
||||
if (PrefManager.getVal(PrefName.FocusPause) && !epChanging) {
|
||||
if (isInitialized && !hasFocus) wasPlaying = exoPlayer.isPlaying
|
||||
if (hasFocus) {
|
||||
if (isInitialized && wasPlaying) exoPlayer.play()
|
||||
|
@ -1590,7 +1608,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
|
||||
override fun onRenderedFirstFrame() {
|
||||
super.onRenderedFirstFrame()
|
||||
saveData("${media.id}_${media.anime!!.selectedEpisode}_max", exoPlayer.duration, this)
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_${media.anime!!.selectedEpisode}_max",
|
||||
exoPlayer.duration
|
||||
)
|
||||
val height = (exoPlayer.videoFormat ?: return).height
|
||||
val width = (exoPlayer.videoFormat ?: return).width
|
||||
|
||||
|
@ -1607,14 +1628,14 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
exoPlayer.seekTo(0)
|
||||
}
|
||||
|
||||
if (!isTimeStampsLoaded && settings.timeStampsEnabled) {
|
||||
if (!isTimeStampsLoaded && PrefManager.getVal(PrefName.TimeStampsEnabled)) {
|
||||
val dur = exoPlayer.duration
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
model.loadTimeStamps(
|
||||
media.idMAL,
|
||||
media.anime?.selectedEpisode?.trim()?.toIntOrNull(),
|
||||
dur / 1000,
|
||||
settings.useProxyForTimeStamps
|
||||
PrefManager.getVal(PrefName.UseProxyForTimeStamps)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1624,7 +1645,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
private var preloading = false
|
||||
private fun updateProgress() {
|
||||
if (isInitialized) {
|
||||
if (exoPlayer.currentPosition.toFloat() / exoPlayer.duration > settings.watchPercentage) {
|
||||
if (exoPlayer.currentPosition.toFloat() / exoPlayer.duration > PrefManager.getVal<Float>(
|
||||
PrefName.WatchPercentage
|
||||
)
|
||||
) {
|
||||
preloading = true
|
||||
nextEpisode(false) { i ->
|
||||
val ep = episodes[episodeArr[currentEpisodeIndex + i]] ?: return@nextEpisode
|
||||
|
@ -1655,7 +1679,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
|
||||
val new = currentTimeStamp
|
||||
timeStampText.text = if (new != null) {
|
||||
if (settings.showTimeStampButton) {
|
||||
if (PrefManager.getVal(PrefName.ShowTimeStampButton)) {
|
||||
skipTimeButton.visibility = View.VISIBLE
|
||||
exoSkip.visibility = View.GONE
|
||||
skipTimeText.text = new.skipType.getType()
|
||||
|
@ -1663,7 +1687,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
exoPlayer.seekTo((new.interval.endTime * 1000).toLong())
|
||||
}
|
||||
}
|
||||
if (settings.autoSkipOPED && (new.skipType == "op" || new.skipType == "ed") && !skippedTimeStamps.contains(
|
||||
if (PrefManager.getVal(PrefName.AutoSkipOPED) && (new.skipType == "op" || new.skipType == "ed") && !skippedTimeStamps.contains(
|
||||
new
|
||||
)
|
||||
) {
|
||||
|
@ -1673,7 +1697,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
new.skipType.getType()
|
||||
} else {
|
||||
skipTimeButton.visibility = View.GONE
|
||||
if (settings.skipTime > 0) exoSkip.visibility = View.VISIBLE
|
||||
if (PrefManager.getVal<Int>(PrefName.SkipTime) > 0) exoSkip.visibility =
|
||||
View.VISIBLE
|
||||
""
|
||||
}
|
||||
}
|
||||
|
@ -1735,7 +1760,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
}
|
||||
isBuffering = playbackState == Player.STATE_BUFFERING
|
||||
if (playbackState == Player.STATE_ENDED && settings.autoPlay) {
|
||||
if (playbackState == Player.STATE_ENDED && PrefManager.getVal(PrefName.AutoPlay)) {
|
||||
if (interacted) exoNext.performClick()
|
||||
else toast(getString(R.string.autoplay_cancelled))
|
||||
}
|
||||
|
@ -1743,9 +1768,16 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
|
||||
private fun updateAniProgress() {
|
||||
val incognito = PrefWrapper.getVal(PrefName.Incognito, false)
|
||||
if (!incognito && exoPlayer.currentPosition / episodeLength > settings.watchPercentage && Anilist.userid != null)
|
||||
if (loadData<Boolean>("${media.id}_save_progress") != false && if (media.isAdult) settings.updateForH else true) {
|
||||
val incognito: Boolean = PrefManager.getVal(PrefName.Incognito)
|
||||
if (!incognito && exoPlayer.currentPosition / episodeLength > PrefManager.getVal<Float>(
|
||||
PrefName.WatchPercentage
|
||||
) && Anilist.userid != null
|
||||
)
|
||||
if (PrefManager.getCustomVal(
|
||||
"${media.id}_save_progress",
|
||||
true
|
||||
) && (if (media.isAdult) PrefManager.getVal(PrefName.UpdateForHPlayer) else true)
|
||||
) {
|
||||
media.anime!!.selectedEpisode?.apply {
|
||||
updateProgress(media, this)
|
||||
}
|
||||
|
@ -1758,7 +1790,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
while (isFiller) {
|
||||
if (episodeArr.size > currentEpisodeIndex + i) {
|
||||
isFiller =
|
||||
if (settings.autoSkipFiller) episodes[episodeArr[currentEpisodeIndex + i]]?.filler
|
||||
if (PrefManager.getVal(PrefName.AutoSkipFiller)) episodes[episodeArr[currentEpisodeIndex + i]]?.filler
|
||||
?: false else false
|
||||
if (!isFiller) runnable.invoke(i)
|
||||
i++
|
||||
|
@ -1855,7 +1887,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
orientationListener?.enable()
|
||||
}
|
||||
if (isInitialized) {
|
||||
saveData("${media.id}_${episode.number}", exoPlayer.currentPosition, this)
|
||||
PrefManager.setCustomVal(
|
||||
"${media.id}_${episode.number}",
|
||||
exoPlayer.currentPosition
|
||||
)
|
||||
if (wasPlaying) exoPlayer.play()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import ani.dantotsu.parsers.Subtitle
|
|||
import ani.dantotsu.parsers.VideoExtractor
|
||||
import ani.dantotsu.parsers.VideoType
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.settings.saving.PrefWrapper
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -94,7 +94,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
|||
binding.selectorAutoText.text = selected
|
||||
binding.selectorCancel.setOnClickListener {
|
||||
media!!.selected!!.server = null
|
||||
model.saveSelected(media!!.id, media!!.selected!!, requireActivity())
|
||||
model.saveSelected(media!!.id, media!!.selected!!)
|
||||
tryWith {
|
||||
dismiss()
|
||||
}
|
||||
|
@ -143,11 +143,11 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
|||
}
|
||||
binding.selectorRecyclerView.adapter = null
|
||||
binding.selectorProgressBar.visibility = View.VISIBLE
|
||||
makeDefault = loadData("make_default") ?: true
|
||||
makeDefault = PrefManager.getVal(PrefName.MakeDefault)
|
||||
binding.selectorMakeDefault.isChecked = makeDefault
|
||||
binding.selectorMakeDefault.setOnClickListener {
|
||||
makeDefault = binding.selectorMakeDefault.isChecked
|
||||
saveData("make_default", makeDefault)
|
||||
PrefManager.setVal(PrefName.MakeDefault, makeDefault)
|
||||
}
|
||||
binding.selectorRecyclerView.layoutManager =
|
||||
LinearLayoutManager(
|
||||
|
@ -301,7 +301,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
|||
extractor.server.name
|
||||
media!!.anime!!.episodes!![media!!.anime!!.selectedEpisode!!]!!.selectedVideo =
|
||||
position
|
||||
if (PrefWrapper.getVal(PrefName.DownloadManager, 0) != 0) {
|
||||
if ((PrefManager.getVal(PrefName.DownloadManager) as Int) != 0) {
|
||||
download(
|
||||
requireActivity(),
|
||||
media!!.anime!!.episodes!![media!!.anime!!.selectedEpisode!!]!!,
|
||||
|
@ -412,7 +412,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
|||
if (makeDefault) {
|
||||
media!!.selected!!.server = extractor.server.name
|
||||
media!!.selected!!.video = bindingAdapterPosition
|
||||
model.saveSelected(media!!.id, media!!.selected!!, requireActivity())
|
||||
model.saveSelected(media!!.id, media!!.selected!!)
|
||||
}
|
||||
startExoplayer(media!!)
|
||||
}
|
||||
|
|
|
@ -15,10 +15,9 @@ import ani.dantotsu.BottomSheetDialogFragment
|
|||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.BottomSheetSubtitlesBinding
|
||||
import ani.dantotsu.databinding.ItemSubtitleTextBinding
|
||||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.media.MediaDetailsViewModel
|
||||
import ani.dantotsu.parsers.Subtitle
|
||||
import ani.dantotsu.saveData
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
|
||||
class SubtitleDialogFragment : BottomSheetDialogFragment() {
|
||||
private var _binding: BottomSheetSubtitlesBinding? = null
|
||||
|
@ -69,7 +68,7 @@ class SubtitleDialogFragment : BottomSheetDialogFragment() {
|
|||
binding.subtitleTitle.setText(R.string.none)
|
||||
model.getMedia().observe(viewLifecycleOwner) { media ->
|
||||
val mediaID: Int = media.id
|
||||
val selSubs: String? = loadData("subLang_${mediaID}", activity)
|
||||
val selSubs = PrefManager.getCustomVal<String?>("subLang_${mediaID}", null)
|
||||
if (episode.selectedSubtitle != null && selSubs != "None") {
|
||||
binding.root.setCardBackgroundColor(TRANSPARENT)
|
||||
}
|
||||
|
@ -79,7 +78,7 @@ class SubtitleDialogFragment : BottomSheetDialogFragment() {
|
|||
model.setEpisode(episode, "Subtitle")
|
||||
model.getMedia().observe(viewLifecycleOwner) { media ->
|
||||
val mediaID: Int = media.id
|
||||
saveData("subLang_${mediaID}", "None", activity)
|
||||
PrefManager.setCustomVal("subLang_${mediaID}", "None")
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
|
@ -108,7 +107,7 @@ class SubtitleDialogFragment : BottomSheetDialogFragment() {
|
|||
}
|
||||
model.getMedia().observe(viewLifecycleOwner) { media ->
|
||||
val mediaID: Int = media.id
|
||||
val selSubs: String? = loadData("subLang_${mediaID}", activity)
|
||||
val selSubs: String? = PrefManager.getCustomVal<String?>("subLang_${mediaID}", null)
|
||||
if (episode.selectedSubtitle != position - 1 && selSubs != subtitles[position - 1].language) {
|
||||
binding.root.setCardBackgroundColor(TRANSPARENT)
|
||||
}
|
||||
|
@ -119,7 +118,7 @@ class SubtitleDialogFragment : BottomSheetDialogFragment() {
|
|||
model.setEpisode(episode, "Subtitle")
|
||||
model.getMedia().observe(viewLifecycleOwner) { media ->
|
||||
val mediaID: Int = media.id
|
||||
saveData("subLang_${mediaID}", subtitles[position - 1].language, activity)
|
||||
PrefManager.setCustomVal("subLang_${mediaID}", subtitles[position - 1].language)
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue