themes and various bugs
This commit is contained in:
parent
dc165fa6bc
commit
63526c6ed3
114 changed files with 1719 additions and 558 deletions
|
@ -1,7 +1,11 @@
|
|||
package ani.dantotsu
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.net.Uri
|
||||
|
@ -10,6 +14,7 @@ import android.os.Bundle
|
|||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.AnticipateInterpolator
|
||||
|
@ -41,8 +46,10 @@ import ani.dantotsu.media.MediaDetailsActivity
|
|||
import ani.dantotsu.others.CustomBottomDialog
|
||||
import ani.dantotsu.parsers.AnimeSources
|
||||
import ani.dantotsu.parsers.MangaSources
|
||||
import ani.dantotsu.settings.SettingsActivity
|
||||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
|
||||
import io.noties.markwon.Markwon
|
||||
import io.noties.markwon.SoftBreakAddsNewLinePlugin
|
||||
|
@ -68,6 +75,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
@ -228,6 +236,18 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (ActivityHelper.shouldRefreshMainActivity) {
|
||||
ActivityHelper.shouldRefreshMainActivity = false
|
||||
Refresh.all()
|
||||
finish()
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
initActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ViewPager
|
||||
private class ViewPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) :
|
||||
FragmentStateAdapter(fragmentManager, lifecycle) {
|
||||
|
@ -245,3 +265,7 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
object ActivityHelper {
|
||||
var shouldRefreshMainActivity: Boolean = false
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import ani.dantotsu.logError
|
||||
import ani.dantotsu.logger
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class Login : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
val data: Uri? = intent?.data
|
||||
logger(data.toString())
|
||||
try {
|
||||
|
|
|
@ -6,10 +6,12 @@ import android.os.Bundle
|
|||
import androidx.core.os.bundleOf
|
||||
import ani.dantotsu.loadMedia
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class UrlMedia : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
var id: Int? = intent?.extras?.getInt("media", 0) ?: 0
|
||||
var isMAL = false
|
||||
var continueMedia = true
|
||||
|
|
|
@ -11,12 +11,14 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.discord.Discord.saveToken
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class Login : AppCompatActivity() {
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
val process = getProcessName()
|
||||
if (packageName != process) WebView.setDataDirectorySuffix(process)
|
||||
|
|
|
@ -7,12 +7,14 @@ import androidx.lifecycle.lifecycleScope
|
|||
import ani.dantotsu.*
|
||||
import ani.dantotsu.connections.mal.MAL.clientId
|
||||
import ani.dantotsu.connections.mal.MAL.saveResponse
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class Login : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
try {
|
||||
val data: Uri = intent?.data
|
||||
?: throw Exception(getString(R.string.mal_login_uri_not_found))
|
||||
|
|
|
@ -63,6 +63,7 @@ object Helper {
|
|||
SubtitleType.VTT -> MimeTypes.TEXT_VTT
|
||||
SubtitleType.ASS -> MimeTypes.TEXT_SSA
|
||||
SubtitleType.SRT -> MimeTypes.APPLICATION_SUBRIP
|
||||
SubtitleType.UNKNOWN -> MimeTypes.TEXT_SSA
|
||||
}
|
||||
)
|
||||
.build()
|
||||
|
|
|
@ -163,6 +163,7 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
|
|||
fun updateAvatar() {
|
||||
if (Anilist.avatar != null && ready.value == true) {
|
||||
binding.animeUserAvatar.loadImage(Anilist.avatar)
|
||||
binding.animeUserAvatar.imageTintList = null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import androidx.viewpager2.widget.ViewPager2
|
||||
import ani.dantotsu.media.GenreActivity
|
||||
import ani.dantotsu.MediaPageTransformer
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.databinding.ItemMangaPageBinding
|
||||
import ani.dantotsu.loadData
|
||||
|
@ -153,6 +154,7 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
|
|||
fun updateAvatar() {
|
||||
if (Anilist.avatar != null && ready.value == true) {
|
||||
binding.mangaUserAvatar.loadImage(Anilist.avatar)
|
||||
binding.mangaUserAvatar.imageTintList = null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,10 +9,12 @@ import ani.dantotsu.isOnline
|
|||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class NoInternet : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
|
||||
val binding = ActivityNoInternetBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
|
|
@ -15,6 +15,7 @@ import androidx.recyclerview.widget.GridLayoutManager
|
|||
import ani.dantotsu.*
|
||||
import ani.dantotsu.databinding.ActivityAuthorBinding
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
@ -28,6 +29,7 @@ class AuthorActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityAuthorBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import ani.dantotsu.R
|
|||
import ani.dantotsu.Refresh
|
||||
import ani.dantotsu.databinding.ActivityListBinding
|
||||
import ani.dantotsu.media.user.ListViewPagerAdapter
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -27,6 +28,7 @@ class CalendarActivity : AppCompatActivity() {
|
|||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityListBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import ani.dantotsu.databinding.ActivityCharacterBinding
|
|||
import ani.dantotsu.others.ImageViewDialog
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -33,6 +34,7 @@ class CharacterDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChang
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityCharacterBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import ani.dantotsu.initActivity
|
|||
import ani.dantotsu.loadData
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -25,6 +26,7 @@ class GenreActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityGenreBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
initActivity(this)
|
||||
|
|
|
@ -47,6 +47,7 @@ import ani.dantotsu.saveData
|
|||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.flaviofaria.kenburnsview.RandomTransitionGenerator
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.google.android.material.navigation.NavigationBarView
|
||||
|
@ -71,6 +72,7 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityMediaBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
screenWidth = resources.displayMetrics.widthPixels.toFloat()
|
||||
|
@ -79,7 +81,8 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
|
||||
initActivity(this)
|
||||
uiSettings = loadData<UserInterfaceSettings>("ui_settings") ?: UserInterfaceSettings()
|
||||
if (!uiSettings.immersiveMode) this.window.statusBarColor = ContextCompat.getColor(this, R.color.nav_bg_inv)
|
||||
if (!uiSettings.immersiveMode) this.window.statusBarColor =
|
||||
ContextCompat.getColor(this, R.color.nav_bg_inv)
|
||||
|
||||
binding.mediaBanner.updateLayoutParams { height += statusBarHeight }
|
||||
binding.mediaBannerNoKen.updateLayoutParams { height += statusBarHeight }
|
||||
|
@ -101,10 +104,14 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
|
||||
if (uiSettings.bannerAnimations) {
|
||||
val adi = AccelerateDecelerateInterpolator()
|
||||
val generator = RandomTransitionGenerator((10000 + 15000 * (uiSettings.animationSpeed)).toLong(), adi)
|
||||
val generator = RandomTransitionGenerator(
|
||||
(10000 + 15000 * (uiSettings.animationSpeed)).toLong(),
|
||||
adi
|
||||
)
|
||||
binding.mediaBanner.setTransitionGenerator(generator)
|
||||
}
|
||||
val banner = if (uiSettings.bannerAnimations) binding.mediaBanner else binding.mediaBannerNoKen
|
||||
val banner =
|
||||
if (uiSettings.bannerAnimations) binding.mediaBanner else binding.mediaBannerNoKen
|
||||
val viewPager = binding.mediaViewPager
|
||||
tabLayout = binding.mediaTab as NavigationBarView
|
||||
viewPager.isUserInputEnabled = false
|
||||
|
@ -167,8 +174,8 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
binding.mediaFav,
|
||||
R.drawable.ic_round_favorite_24,
|
||||
R.drawable.ic_round_favorite_border_24,
|
||||
R.color.nav_tab,
|
||||
R.color.fav,
|
||||
com.google.android.material.R.attr.colorSecondary,
|
||||
com.google.android.material.R.attr.colorSecondary,
|
||||
media.isFav
|
||||
) {
|
||||
media.isFav = it
|
||||
|
@ -180,17 +187,32 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
null
|
||||
}
|
||||
|
||||
@SuppressLint("ResourceType")
|
||||
fun total() {
|
||||
val text = SpannableStringBuilder().apply {
|
||||
val white = ContextCompat.getColor(this@MediaDetailsActivity, R.color.bg_opp)
|
||||
val typedValue = TypedValue()
|
||||
this@MediaDetailsActivity.theme.resolveAttribute(com.google.android.material.R.attr.colorOnBackground, typedValue, true)
|
||||
val white = typedValue.data
|
||||
if (media.userStatus != null) {
|
||||
append(if (media.anime != null) getString(R.string.watched_num) else getString(R.string.read_num))
|
||||
val typedValue = TypedValue()
|
||||
theme.resolveAttribute(com.google.android.material.R.attr.colorSecondary, typedValue, true)
|
||||
theme.resolveAttribute(
|
||||
com.google.android.material.R.attr.colorSecondary,
|
||||
typedValue,
|
||||
true
|
||||
)
|
||||
bold { color(typedValue.data) { append("${media.userProgress}") } }
|
||||
append(if (media.anime != null) getString(R.string.episodes_out_of) else getString(R.string.chapters_out_of))
|
||||
append(
|
||||
if (media.anime != null) getString(R.string.episodes_out_of) else getString(
|
||||
R.string.chapters_out_of
|
||||
)
|
||||
)
|
||||
} else {
|
||||
append(if (media.anime != null) getString(R.string.episodes_total_of) else getString(R.string.chapters_total_of))
|
||||
append(
|
||||
if (media.anime != null) getString(R.string.episodes_total_of) else getString(
|
||||
R.string.chapters_total_of
|
||||
)
|
||||
)
|
||||
}
|
||||
if (media.anime != null) {
|
||||
if (media.anime!!.nextAiringEpisode != null) {
|
||||
|
@ -206,8 +228,12 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
|
||||
fun progress() {
|
||||
val statuses: Array<String> = resources.getStringArray(R.array.status)
|
||||
val statusStrings = if (media.manga==null) resources.getStringArray(R.array.status_anime) else resources.getStringArray(R.array.status_manga)
|
||||
val userStatus = if(media.userStatus != null) statusStrings[statuses.indexOf(media.userStatus)] else statusStrings[0]
|
||||
val statusStrings =
|
||||
if (media.manga == null) resources.getStringArray(R.array.status_anime) else resources.getStringArray(
|
||||
R.array.status_manga
|
||||
)
|
||||
val userStatus =
|
||||
if (media.userStatus != null) statusStrings[statuses.indexOf(media.userStatus)] else statusStrings[0]
|
||||
|
||||
if (media.userStatus != null) {
|
||||
binding.mediaTotal.visibility = View.VISIBLE
|
||||
|
@ -234,7 +260,7 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
if (it != null) {
|
||||
media = it
|
||||
scope.launch {
|
||||
if(media.isFav!=favButton?.clicked) favButton?.clicked()
|
||||
if (media.isFav != favButton?.clicked) favButton?.clicked()
|
||||
}
|
||||
|
||||
binding.mediaNotify.setOnClickListener {
|
||||
|
@ -258,10 +284,15 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
|
||||
tabLayout.menu.clear()
|
||||
if (media.anime != null) {
|
||||
viewPager.adapter = ViewPagerAdapter(supportFragmentManager, lifecycle, SupportedMedia.ANIME)
|
||||
viewPager.adapter =
|
||||
ViewPagerAdapter(supportFragmentManager, lifecycle, SupportedMedia.ANIME)
|
||||
tabLayout.inflateMenu(R.menu.anime_menu_detail)
|
||||
} else if (media.manga != null) {
|
||||
viewPager.adapter = ViewPagerAdapter(supportFragmentManager, lifecycle, if(media.format=="NOVEL") SupportedMedia.NOVEL else SupportedMedia.MANGA)
|
||||
viewPager.adapter = ViewPagerAdapter(
|
||||
supportFragmentManager,
|
||||
lifecycle,
|
||||
if (media.format == "NOVEL") SupportedMedia.NOVEL else SupportedMedia.MANGA
|
||||
)
|
||||
tabLayout.inflateMenu(R.menu.manga_menu_detail)
|
||||
anime = false
|
||||
}
|
||||
|
@ -303,9 +334,10 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
|
||||
private fun selectFromID(id: Int) {
|
||||
when (id) {
|
||||
R.id.info -> {
|
||||
R.id.info -> {
|
||||
selected = 0
|
||||
}
|
||||
|
||||
R.id.watch, R.id.read -> {
|
||||
selected = 1
|
||||
}
|
||||
|
@ -329,9 +361,10 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
super.onResume()
|
||||
}
|
||||
|
||||
private enum class SupportedMedia{
|
||||
private enum class SupportedMedia {
|
||||
ANIME, MANGA, NOVEL
|
||||
}
|
||||
|
||||
//ViewPager
|
||||
private class ViewPagerAdapter(
|
||||
fragmentManager: FragmentManager,
|
||||
|
@ -342,13 +375,14 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
|
||||
override fun getItemCount(): Int = 2
|
||||
|
||||
override fun createFragment(position: Int): Fragment = when (position){
|
||||
override fun createFragment(position: Int): Fragment = when (position) {
|
||||
0 -> MediaInfoFragment()
|
||||
1 -> when(media){
|
||||
1 -> when (media) {
|
||||
SupportedMedia.ANIME -> AnimeWatchFragment()
|
||||
SupportedMedia.MANGA -> MangaReadFragment()
|
||||
SupportedMedia.NOVEL -> NovelReadFragment()
|
||||
}
|
||||
|
||||
else -> MediaInfoFragment()
|
||||
}
|
||||
}
|
||||
|
@ -363,27 +397,41 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
if (mMaxScrollSize == 0) mMaxScrollSize = appBar.totalScrollRange
|
||||
val percentage = abs(i) * 100 / mMaxScrollSize
|
||||
|
||||
binding.mediaCover.visibility = if (binding.mediaCover.scaleX == 0f) View.GONE else View.VISIBLE
|
||||
binding.mediaCover.visibility =
|
||||
if (binding.mediaCover.scaleX == 0f) View.GONE else View.VISIBLE
|
||||
val duration = (200 * uiSettings.animationSpeed).toLong()
|
||||
val typedValue = TypedValue()
|
||||
this@MediaDetailsActivity.theme.resolveAttribute(com.google.android.material.R.attr.colorSecondary, typedValue, true)
|
||||
val color = typedValue.data
|
||||
if (percentage >= percent && !isCollapsed) {
|
||||
isCollapsed = true
|
||||
ObjectAnimator.ofFloat(binding.mediaTitle, "translationX", 0f).setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaAccessContainer, "translationX", screenWidth).setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaCover, "translationX", screenWidth).setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaCollapseContainer, "translationX", screenWidth).setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaTitle, "translationX", 0f).setDuration(duration)
|
||||
.start()
|
||||
ObjectAnimator.ofFloat(binding.mediaAccessContainer, "translationX", screenWidth)
|
||||
.setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaCover, "translationX", screenWidth)
|
||||
.setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaCollapseContainer, "translationX", screenWidth)
|
||||
.setDuration(duration).start()
|
||||
binding.mediaBanner.pause()
|
||||
if (!uiSettings.immersiveMode) this.window.statusBarColor = ContextCompat.getColor(this, R.color.nav_bg)
|
||||
if (!uiSettings.immersiveMode) this.window.statusBarColor = color
|
||||
}
|
||||
if (percentage <= percent && isCollapsed) {
|
||||
isCollapsed = false
|
||||
ObjectAnimator.ofFloat(binding.mediaTitle, "translationX", -screenWidth).setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaAccessContainer, "translationX", 0f).setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaCover, "translationX", 0f).setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaCollapseContainer, "translationX", 0f).setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaTitle, "translationX", -screenWidth)
|
||||
.setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaAccessContainer, "translationX", 0f)
|
||||
.setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.mediaCover, "translationX", 0f).setDuration(duration)
|
||||
.start()
|
||||
ObjectAnimator.ofFloat(binding.mediaCollapseContainer, "translationX", 0f)
|
||||
.setDuration(duration).start()
|
||||
if (uiSettings.bannerAnimations) binding.mediaBanner.resume()
|
||||
if (!uiSettings.immersiveMode) this.window.statusBarColor = ContextCompat.getColor(this, R.color.nav_bg_inv)
|
||||
if (!uiSettings.immersiveMode) this.window.statusBarColor = color
|
||||
}
|
||||
if (percentage == 1 && model.scrolledToTop.value != false) model.scrolledToTop.postValue(false)
|
||||
if (percentage == 1 && model.scrolledToTop.value != false) model.scrolledToTop.postValue(
|
||||
false
|
||||
)
|
||||
if (percentage == 0 && model.scrolledToTop.value != true) model.scrolledToTop.postValue(true)
|
||||
}
|
||||
|
||||
|
@ -426,7 +474,8 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
ObjectAnimator.ofFloat(image, "scaleY", 1f, 0f).setDuration(100).start()
|
||||
delay(100)
|
||||
if (clicked) {
|
||||
ObjectAnimator.ofArgb(image,
|
||||
ObjectAnimator.ofArgb(
|
||||
image,
|
||||
"ColorFilter",
|
||||
ContextCompat.getColor(context, c1),
|
||||
ContextCompat.getColor(context, c2)
|
||||
|
@ -449,7 +498,7 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
|
||||
fun enabled(enabled: Boolean) {
|
||||
disabled = !enabled
|
||||
image.alpha = if(disabled) 0.33f else 1f
|
||||
image.alpha = if (disabled) 0.33f else 1f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import ani.dantotsu.connections.anilist.Anilist
|
|||
import ani.dantotsu.databinding.BottomSheetMediaListSmallBinding
|
||||
import ani.dantotsu.connections.mal.MAL
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
|
|
@ -16,6 +16,7 @@ import ani.dantotsu.connections.anilist.Anilist
|
|||
import ani.dantotsu.connections.anilist.AnilistSearch
|
||||
import ani.dantotsu.connections.anilist.SearchResults
|
||||
import ani.dantotsu.databinding.ActivitySearchBinding
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.*
|
||||
|
@ -37,6 +38,7 @@ class SearchActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivitySearchBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
initActivity(this)
|
||||
|
|
|
@ -15,6 +15,7 @@ import androidx.recyclerview.widget.GridLayoutManager
|
|||
import ani.dantotsu.*
|
||||
import ani.dantotsu.databinding.ActivityStudioBinding
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
@ -28,6 +29,7 @@ class StudioActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityStudioBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
48
app/src/main/java/ani/dantotsu/media/SubtitleDownloader.kt
Normal file
48
app/src/main/java/ani/dantotsu/media/SubtitleDownloader.kt
Normal file
|
@ -0,0 +1,48 @@
|
|||
package ani.dantotsu.media
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Environment
|
||||
import ani.dantotsu.parsers.SubtitleType
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import okhttp3.Request
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.FileInputStream
|
||||
|
||||
class SubtitleDownloader {
|
||||
|
||||
companion object {
|
||||
//doesn't really download the subtitles -\_(o_o)_/-
|
||||
suspend fun downloadSubtitles(context: Context, url: String): SubtitleType =
|
||||
withContext(Dispatchers.IO) {
|
||||
// Initialize the NetworkHelper instance. Replace this line based on how you usually initialize it
|
||||
val networkHelper = Injekt.get<NetworkHelper>()
|
||||
val request = Request.Builder()
|
||||
.url(url)
|
||||
.build()
|
||||
|
||||
val response = networkHelper.client.newCall(request).execute()
|
||||
|
||||
// Check if response is successful
|
||||
if (response.isSuccessful) {
|
||||
val responseBody = response.body?.string()
|
||||
|
||||
|
||||
val subtitleType = when {
|
||||
responseBody?.contains("[Script Info]") == true -> SubtitleType.ASS
|
||||
responseBody?.contains("WEBVTT") == true -> SubtitleType.VTT
|
||||
else -> SubtitleType.SRT
|
||||
}
|
||||
|
||||
return@withContext subtitleType
|
||||
} else {
|
||||
return@withContext SubtitleType.UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,6 +53,7 @@ import androidx.media3.datasource.okhttp.OkHttpDataSource
|
|||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
|
||||
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector
|
||||
import androidx.media3.exoplayer.util.EventLogger
|
||||
import androidx.media3.session.MediaSession
|
||||
import androidx.media3.ui.*
|
||||
import androidx.media3.ui.CaptionStyleCompat.*
|
||||
|
@ -65,6 +66,7 @@ import ani.dantotsu.connections.updateProgress
|
|||
import ani.dantotsu.databinding.ActivityExoplayerBinding
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaDetailsViewModel
|
||||
import ani.dantotsu.media.SubtitleDownloader
|
||||
import ani.dantotsu.others.AniSkip
|
||||
import ani.dantotsu.others.AniSkip.getType
|
||||
import ani.dantotsu.others.Download.download
|
||||
|
@ -74,6 +76,7 @@ import ani.dantotsu.parsers.*
|
|||
import ani.dantotsu.settings.PlayerSettings
|
||||
import ani.dantotsu.settings.PlayerSettingsActivity
|
||||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.android.material.slider.Slider
|
||||
import com.lagradost.nicehttp.ignoreAllSSLErrors
|
||||
|
@ -81,12 +84,15 @@ import kotlinx.coroutines.CoroutineScope
|
|||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import okhttp3.internal.immutableListOf
|
||||
import java.util.*
|
||||
import java.util.concurrent.*
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
@UnstableApi
|
||||
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
|
||||
class ExoplayerView : AppCompatActivity(), Player.Listener {
|
||||
|
@ -183,7 +189,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
val displayCutout = window.decorView.rootWindowInsets.displayCutout
|
||||
if (displayCutout != null) {
|
||||
if (displayCutout.boundingRects.size > 0) {
|
||||
notchHeight = min(displayCutout.boundingRects[0].width(), displayCutout.boundingRects[0].height())
|
||||
notchHeight = min(
|
||||
displayCutout.boundingRects[0].width(),
|
||||
displayCutout.boundingRects[0].height()
|
||||
)
|
||||
checkNotch()
|
||||
}
|
||||
}
|
||||
|
@ -194,101 +203,104 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
private fun checkNotch() {
|
||||
if (notchHeight != 0) {
|
||||
val orientation = resources.configuration.orientation
|
||||
playerView.findViewById<View>(R.id.exo_controller_margin).updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
marginStart = notchHeight
|
||||
marginEnd = notchHeight
|
||||
topMargin = 0
|
||||
} else {
|
||||
topMargin = notchHeight
|
||||
marginStart = 0
|
||||
marginEnd = 0
|
||||
playerView.findViewById<View>(R.id.exo_controller_margin)
|
||||
.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
marginStart = notchHeight
|
||||
marginEnd = notchHeight
|
||||
topMargin = 0
|
||||
} else {
|
||||
topMargin = notchHeight
|
||||
marginStart = 0
|
||||
marginEnd = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
playerView.findViewById<View>(androidx.media3.ui.R.id.exo_buffering).translationY =
|
||||
(if (orientation == Configuration.ORIENTATION_LANDSCAPE) 0 else (notchHeight + 8f.px)).dp
|
||||
exoBrightnessCont.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
marginEnd = if (orientation == Configuration.ORIENTATION_LANDSCAPE) notchHeight else 0
|
||||
marginEnd =
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) notchHeight else 0
|
||||
}
|
||||
exoVolumeCont.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
marginStart = if (orientation == Configuration.ORIENTATION_LANDSCAPE) notchHeight else 0
|
||||
marginStart =
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) notchHeight else 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSubFormatting(playerView: PlayerView, settings: PlayerSettings) {
|
||||
val primaryColor = when (settings.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
|
||||
0 -> Color.BLACK
|
||||
1 -> Color.DKGRAY
|
||||
2 -> Color.GRAY
|
||||
3 -> Color.LTGRAY
|
||||
4 -> Color.WHITE
|
||||
5 -> Color.RED
|
||||
6 -> Color.YELLOW
|
||||
7 -> Color.GREEN
|
||||
8 -> Color.CYAN
|
||||
9 -> Color.BLUE
|
||||
10 -> Color.MAGENTA
|
||||
11 -> Color.TRANSPARENT
|
||||
else -> Color.WHITE
|
||||
}
|
||||
val secondaryColor = when (settings.secondaryColor) {
|
||||
0 -> Color.BLACK
|
||||
1 -> Color.DKGRAY
|
||||
2 -> Color.GRAY
|
||||
3 -> Color.LTGRAY
|
||||
4 -> Color.WHITE
|
||||
5 -> Color.RED
|
||||
6 -> Color.YELLOW
|
||||
7 -> Color.GREEN
|
||||
8 -> Color.CYAN
|
||||
9 -> Color.BLUE
|
||||
10 -> Color.MAGENTA
|
||||
11 -> Color.TRANSPARENT
|
||||
0 -> Color.BLACK
|
||||
1 -> Color.DKGRAY
|
||||
2 -> Color.GRAY
|
||||
3 -> Color.LTGRAY
|
||||
4 -> Color.WHITE
|
||||
5 -> Color.RED
|
||||
6 -> Color.YELLOW
|
||||
7 -> Color.GREEN
|
||||
8 -> Color.CYAN
|
||||
9 -> Color.BLUE
|
||||
10 -> Color.MAGENTA
|
||||
11 -> Color.TRANSPARENT
|
||||
else -> Color.BLACK
|
||||
}
|
||||
val outline = when (settings.outline) {
|
||||
0 -> EDGE_TYPE_OUTLINE // Normal
|
||||
1 -> EDGE_TYPE_DEPRESSED // Shine
|
||||
2 -> EDGE_TYPE_DROP_SHADOW // Drop shadow
|
||||
3 -> EDGE_TYPE_NONE // No 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) {
|
||||
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
|
||||
0 -> Color.TRANSPARENT
|
||||
1 -> Color.BLACK
|
||||
2 -> Color.DKGRAY
|
||||
3 -> Color.GRAY
|
||||
4 -> Color.LTGRAY
|
||||
5 -> Color.WHITE
|
||||
6 -> Color.RED
|
||||
7 -> Color.YELLOW
|
||||
8 -> Color.GREEN
|
||||
9 -> Color.CYAN
|
||||
10 -> Color.BLUE
|
||||
11 -> Color.MAGENTA
|
||||
else -> Color.TRANSPARENT
|
||||
}
|
||||
val subWindow = when (settings.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
|
||||
0 -> Color.TRANSPARENT
|
||||
1 -> Color.BLACK
|
||||
2 -> Color.DKGRAY
|
||||
3 -> Color.GRAY
|
||||
4 -> Color.LTGRAY
|
||||
5 -> Color.WHITE
|
||||
6 -> Color.RED
|
||||
7 -> Color.YELLOW
|
||||
8 -> Color.GREEN
|
||||
9 -> Color.CYAN
|
||||
10 -> Color.BLUE
|
||||
11 -> Color.MAGENTA
|
||||
else -> Color.TRANSPARENT
|
||||
}
|
||||
val font = when (settings.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)
|
||||
3 -> ResourcesCompat.getFont(this, R.font.poppins_thin)
|
||||
0 -> ResourcesCompat.getFont(this, R.font.poppins_semi_bold)
|
||||
1 -> ResourcesCompat.getFont(this, R.font.poppins_bold)
|
||||
2 -> ResourcesCompat.getFont(this, R.font.poppins)
|
||||
3 -> ResourcesCompat.getFont(this, R.font.poppins_thin)
|
||||
else -> ResourcesCompat.getFont(this, R.font.poppins_semi_bold)
|
||||
}
|
||||
playerView.subtitleView?.setStyle(
|
||||
|
@ -305,6 +317,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityExoplayerBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
@ -316,8 +329,18 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
finishAndRemoveTask()
|
||||
}
|
||||
|
||||
settings = loadData("player_settings") ?: PlayerSettings().apply { saveData("player_settings", this) }
|
||||
uiSettings = loadData("ui_settings") ?: UserInterfaceSettings().apply { saveData("ui_settings", this) }
|
||||
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)
|
||||
exoQuality = playerView.findViewById(R.id.exo_quality)
|
||||
|
@ -360,17 +383,20 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
requestedOrientation = rotation
|
||||
it.visibility = View.GONE
|
||||
}
|
||||
orientationListener = object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) {
|
||||
override fun onOrientationChanged(orientation: Int) {
|
||||
if (orientation in 45..135) {
|
||||
if (rotation != ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) exoRotate.visibility = View.VISIBLE
|
||||
rotation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
|
||||
} else if (orientation in 225..315) {
|
||||
if (rotation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) exoRotate.visibility = View.VISIBLE
|
||||
rotation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
orientationListener =
|
||||
object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) {
|
||||
override fun onOrientationChanged(orientation: Int) {
|
||||
if (orientation in 45..135) {
|
||||
if (rotation != ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) exoRotate.visibility =
|
||||
View.VISIBLE
|
||||
rotation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
|
||||
} else if (orientation in 225..315) {
|
||||
if (rotation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) exoRotate.visibility =
|
||||
View.VISIBLE
|
||||
rotation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
orientationListener?.enable()
|
||||
}
|
||||
|
||||
|
@ -378,7 +404,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
|
||||
|
||||
playerView.subtitleView?.alpha = when (settings.subtitles) {
|
||||
true -> 1f
|
||||
true -> 1f
|
||||
false -> 0f
|
||||
}
|
||||
val fontSize = settings.fontSize.toFloat()
|
||||
|
@ -401,7 +427,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
isTimeStampsLoaded = true
|
||||
exoSkipOpEd.visibility = if (it != null) {
|
||||
val adGroups = it.flatMap {
|
||||
listOf(it.interval.startTime.toLong() * 1000, it.interval.endTime.toLong() * 1000)
|
||||
listOf(
|
||||
it.interval.startTime.toLong() * 1000,
|
||||
it.interval.endTime.toLong() * 1000
|
||||
)
|
||||
}.toLongArray()
|
||||
val playedAdGroups = it.flatMap {
|
||||
listOf(false, false)
|
||||
|
@ -441,7 +470,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
|
||||
// Picture-in-picture
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
pipEnabled = packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) && settings.pip
|
||||
pipEnabled =
|
||||
packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) && settings.pip
|
||||
if (pipEnabled) {
|
||||
exoPip.visibility = View.VISIBLE
|
||||
exoPip.setOnClickListener {
|
||||
|
@ -456,7 +486,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
val container = playerView.findViewById<View>(R.id.exo_controller_cont)
|
||||
val screen = playerView.findViewById<View>(R.id.exo_black_screen)
|
||||
val lockButton = playerView.findViewById<ImageButton>(R.id.exo_unlock)
|
||||
val timeline = playerView.findViewById<ExtendedTimeBar>(androidx.media3.ui.R.id.exo_progress)
|
||||
val timeline =
|
||||
playerView.findViewById<ExtendedTimeBar>(androidx.media3.ui.R.id.exo_progress)
|
||||
playerView.findViewById<ImageButton>(R.id.exo_lock).setOnClickListener {
|
||||
locked = true
|
||||
screen.visibility = View.GONE
|
||||
|
@ -496,17 +527,22 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
dialog.findViewById<Slider>(R.id.seekbar).addOnChangeListener { _, value, _ ->
|
||||
settings.skipTime = value.toInt()
|
||||
saveData(player, settings)
|
||||
playerView.findViewById<TextView>(R.id.exo_skip_time).text = settings.skipTime.toString()
|
||||
dialog.findViewById<TextView>(R.id.seekbar_value).text = settings.skipTime.toString()
|
||||
playerView.findViewById<TextView>(R.id.exo_skip_time).text =
|
||||
settings.skipTime.toString()
|
||||
dialog.findViewById<TextView>(R.id.seekbar_value).text =
|
||||
settings.skipTime.toString()
|
||||
}
|
||||
dialog.findViewById<Slider>(R.id.seekbar).addOnSliderTouchListener(object : Slider.OnSliderTouchListener {
|
||||
override fun onStartTrackingTouch(slider: Slider) {}
|
||||
override fun onStopTrackingTouch(slider: Slider) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
})
|
||||
dialog.findViewById<TextView>(R.id.seekbar_title).text = getString(R.string.skip_time)
|
||||
dialog.findViewById<TextView>(R.id.seekbar_value).text = settings.skipTime.toString()
|
||||
dialog.findViewById<Slider>(R.id.seekbar)
|
||||
.addOnSliderTouchListener(object : Slider.OnSliderTouchListener {
|
||||
override fun onStartTrackingTouch(slider: Slider) {}
|
||||
override fun onStopTrackingTouch(slider: Slider) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
})
|
||||
dialog.findViewById<TextView>(R.id.seekbar_title).text =
|
||||
getString(R.string.skip_time)
|
||||
dialog.findViewById<TextView>(R.id.seekbar_value).text =
|
||||
settings.skipTime.toString()
|
||||
@Suppress("DEPRECATION")
|
||||
dialog.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
dialog.show()
|
||||
|
@ -521,7 +557,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
val brightnessRunnable = Runnable {
|
||||
if (exoBrightnessCont.alpha == 1f)
|
||||
lifecycleScope.launch {
|
||||
ObjectAnimator.ofFloat(exoBrightnessCont, "alpha", 1f, 0f).setDuration(gestureSpeed).start()
|
||||
ObjectAnimator.ofFloat(exoBrightnessCont, "alpha", 1f, 0f)
|
||||
.setDuration(gestureSpeed).start()
|
||||
delay(gestureSpeed)
|
||||
exoBrightnessCont.visibility = View.GONE
|
||||
checkNotch()
|
||||
|
@ -530,7 +567,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
val volumeRunnable = Runnable {
|
||||
if (exoVolumeCont.alpha == 1f)
|
||||
lifecycleScope.launch {
|
||||
ObjectAnimator.ofFloat(exoVolumeCont, "alpha", 1f, 0f).setDuration(gestureSpeed).start()
|
||||
ObjectAnimator.ofFloat(exoVolumeCont, "alpha", 1f, 0f).setDuration(gestureSpeed)
|
||||
.start()
|
||||
delay(gestureSpeed)
|
||||
exoVolumeCont.visibility = View.GONE
|
||||
checkNotch()
|
||||
|
@ -548,25 +586,65 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
fun handleController() {
|
||||
if (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) !isInPictureInPictureMode else true) {
|
||||
if (playerView.isControllerFullyVisible) {
|
||||
ObjectAnimator.ofFloat(playerView.findViewById(R.id.exo_controller), "alpha", 1f, 0f)
|
||||
ObjectAnimator.ofFloat(
|
||||
playerView.findViewById(R.id.exo_controller),
|
||||
"alpha",
|
||||
1f,
|
||||
0f
|
||||
)
|
||||
.setDuration(controllerDuration).start()
|
||||
ObjectAnimator.ofFloat(playerView.findViewById(R.id.exo_bottom_cont), "translationY", 0f, 128f)
|
||||
ObjectAnimator.ofFloat(
|
||||
playerView.findViewById(R.id.exo_bottom_cont),
|
||||
"translationY",
|
||||
0f,
|
||||
128f
|
||||
)
|
||||
.apply { interpolator = overshoot;duration = controllerDuration;start() }
|
||||
ObjectAnimator.ofFloat(playerView.findViewById(R.id.exo_timeline_cont), "translationY", 0f, 128f)
|
||||
ObjectAnimator.ofFloat(
|
||||
playerView.findViewById(R.id.exo_timeline_cont),
|
||||
"translationY",
|
||||
0f,
|
||||
128f
|
||||
)
|
||||
.apply { interpolator = overshoot;duration = controllerDuration;start() }
|
||||
ObjectAnimator.ofFloat(playerView.findViewById(R.id.exo_top_cont), "translationY", 0f, -128f)
|
||||
ObjectAnimator.ofFloat(
|
||||
playerView.findViewById(R.id.exo_top_cont),
|
||||
"translationY",
|
||||
0f,
|
||||
-128f
|
||||
)
|
||||
.apply { interpolator = overshoot;duration = controllerDuration;start() }
|
||||
playerView.postDelayed({ playerView.hideController() }, controllerDuration)
|
||||
} else {
|
||||
checkNotch()
|
||||
playerView.showController()
|
||||
ObjectAnimator.ofFloat(playerView.findViewById(R.id.exo_controller), "alpha", 0f, 1f)
|
||||
ObjectAnimator.ofFloat(
|
||||
playerView.findViewById(R.id.exo_controller),
|
||||
"alpha",
|
||||
0f,
|
||||
1f
|
||||
)
|
||||
.setDuration(controllerDuration).start()
|
||||
ObjectAnimator.ofFloat(playerView.findViewById(R.id.exo_bottom_cont), "translationY", 128f, 0f)
|
||||
ObjectAnimator.ofFloat(
|
||||
playerView.findViewById(R.id.exo_bottom_cont),
|
||||
"translationY",
|
||||
128f,
|
||||
0f
|
||||
)
|
||||
.apply { interpolator = overshoot;duration = controllerDuration;start() }
|
||||
ObjectAnimator.ofFloat(playerView.findViewById(R.id.exo_timeline_cont), "translationY", 128f, 0f)
|
||||
ObjectAnimator.ofFloat(
|
||||
playerView.findViewById(R.id.exo_timeline_cont),
|
||||
"translationY",
|
||||
128f,
|
||||
0f
|
||||
)
|
||||
.apply { interpolator = overshoot;duration = controllerDuration;start() }
|
||||
ObjectAnimator.ofFloat(playerView.findViewById(R.id.exo_top_cont), "translationY", -128f, 0f)
|
||||
ObjectAnimator.ofFloat(
|
||||
playerView.findViewById(R.id.exo_top_cont),
|
||||
"translationY",
|
||||
-128f,
|
||||
0f
|
||||
)
|
||||
.apply { interpolator = overshoot;duration = controllerDuration;start() }
|
||||
}
|
||||
}
|
||||
|
@ -651,8 +729,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
}
|
||||
|
||||
if (!settings.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 = View.VISIBLE
|
||||
playerView.findViewById<View>(R.id.exo_fast_forward_button_cont).visibility =
|
||||
View.VISIBLE
|
||||
playerView.findViewById<View>(R.id.exo_fast_rewind_button_cont).visibility =
|
||||
View.VISIBLE
|
||||
playerView.findViewById<ImageButton>(R.id.exo_fast_forward_button).setOnClickListener {
|
||||
if (isInitialized) {
|
||||
seek(true)
|
||||
|
@ -696,7 +776,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
|
||||
exoBrightness.addOnChangeListener { _, value, _ ->
|
||||
val lp = window.attributes
|
||||
lp.screenBrightness = brightnessConverter((value.takeIf { !it.isNaN() } ?: 0f) / 10, false)
|
||||
lp.screenBrightness =
|
||||
brightnessConverter((value.takeIf { !it.isNaN() } ?: 0f) / 10, false)
|
||||
window.attributes = lp
|
||||
brightnessHide()
|
||||
}
|
||||
|
@ -757,7 +838,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onSingleClick(event: MotionEvent) = if (isSeeking) doubleTap(false, event) else handleController()
|
||||
override fun onSingleClick(event: MotionEvent) =
|
||||
if (isSeeking) doubleTap(false, event) else handleController()
|
||||
})
|
||||
val rewindArea = playerView.findViewById<View>(R.id.exo_rewind_area)
|
||||
rewindArea.isClickable = true
|
||||
|
@ -786,7 +868,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onSingleClick(event: MotionEvent) = if (isSeeking) doubleTap(true, event) else handleController()
|
||||
override fun onSingleClick(event: MotionEvent) =
|
||||
if (isSeeking) doubleTap(true, event) else handleController()
|
||||
})
|
||||
val forwardArea = playerView.findViewById<View>(R.id.exo_forward_area)
|
||||
forwardArea.isClickable = true
|
||||
|
@ -817,7 +900,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
}
|
||||
|
||||
model.watchSources = if (media.isAdult) HAnimeSources else AnimeSources
|
||||
serverInfo.text = model.watchSources!!.names.getOrNull(media.selected!!.sourceIndex) ?: model.watchSources!!.names[0]
|
||||
serverInfo.text = model.watchSources!!.names.getOrNull(media.selected!!.sourceIndex)
|
||||
?: model.watchSources!!.names[0]
|
||||
|
||||
model.epChanged.observe(this) {
|
||||
epChanging = !it
|
||||
|
@ -906,7 +990,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
rpc?.send {
|
||||
type = RPC.Type.WATCHING
|
||||
activityName = media.userPreferredName
|
||||
details = ep.title?.takeIf { it.isNotEmpty() } ?: getString(R.string.episode_num, ep.number)
|
||||
details = ep.title?.takeIf { it.isNotEmpty() } ?: getString(
|
||||
R.string.episode_num,
|
||||
ep.number
|
||||
)
|
||||
state = "Episode : ${ep.number}/${media.anime?.totalEpisodes ?: "??"}"
|
||||
media.cover?.let { cover ->
|
||||
largeImage = RPC.Link(media.userPreferredName, cover)
|
||||
|
@ -922,25 +1009,25 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
//FullScreen
|
||||
isFullscreen = loadData("${media.id}_fullscreenInt", this) ?: isFullscreen
|
||||
playerView.resizeMode = when (isFullscreen) {
|
||||
0 -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
1 -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
2 -> AspectRatioFrameLayout.RESIZE_MODE_FILL
|
||||
0 -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
1 -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
2 -> AspectRatioFrameLayout.RESIZE_MODE_FILL
|
||||
else -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
}
|
||||
|
||||
exoScreen.setOnClickListener {
|
||||
if (isFullscreen < 2) isFullscreen += 1 else isFullscreen = 0
|
||||
playerView.resizeMode = when (isFullscreen) {
|
||||
0 -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
1 -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
2 -> AspectRatioFrameLayout.RESIZE_MODE_FILL
|
||||
0 -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
1 -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
2 -> AspectRatioFrameLayout.RESIZE_MODE_FILL
|
||||
else -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
}
|
||||
snackString(
|
||||
when (isFullscreen) {
|
||||
0 -> "Original"
|
||||
1 -> "Zoom"
|
||||
2 -> "Stretch"
|
||||
0 -> "Original"
|
||||
1 -> "Zoom"
|
||||
2 -> "Stretch"
|
||||
else -> "Original"
|
||||
}
|
||||
)
|
||||
|
@ -959,7 +1046,11 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
|
||||
//Settings
|
||||
exoSettings.setOnClickListener {
|
||||
saveData("${media.id}_${media.anime!!.selectedEpisode}", exoPlayer.currentPosition, this)
|
||||
saveData(
|
||||
"${media.id}_${media.anime!!.selectedEpisode}",
|
||||
exoPlayer.currentPosition,
|
||||
this
|
||||
)
|
||||
val intent = Intent(this, PlayerSettingsActivity::class.java).apply {
|
||||
putExtra("subtitle", subtitle)
|
||||
}
|
||||
|
@ -979,7 +1070,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
|
||||
playbackParameters = PlaybackParameters(speeds[curSpeed])
|
||||
var speed: Float
|
||||
val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.speed))
|
||||
val speedDialog =
|
||||
AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.speed))
|
||||
exoSpeed.setOnClickListener {
|
||||
speedDialog.setSingleChoiceItems(speedsName, curSpeed) { dialog, i ->
|
||||
if (isInitialized) {
|
||||
|
@ -1018,16 +1110,19 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
|
||||
isFullscreen = settings.resize
|
||||
playerView.resizeMode = when (settings.resize) {
|
||||
0 -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
1 -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
2 -> AspectRatioFrameLayout.RESIZE_MODE_FILL
|
||||
0 -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
1 -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
2 -> AspectRatioFrameLayout.RESIZE_MODE_FILL
|
||||
else -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
}
|
||||
|
||||
preloading = false
|
||||
val showProgressDialog = if (settings.askIndividual) loadData<Boolean>("${media.id}_progressDialog") ?: true else false
|
||||
val showProgressDialog =
|
||||
if (settings.askIndividual) loadData<Boolean>("${media.id}_progressDialog")
|
||||
?: true else false
|
||||
if (showProgressDialog && Anilist.userid != null && if (media.isAdult) settings.updateForH else true)
|
||||
AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.auto_update, media.userPreferredName))
|
||||
AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.auto_update, media.userPreferredName))
|
||||
.apply {
|
||||
setOnCancelListener { hideSystemBars() }
|
||||
setCancelable(false)
|
||||
|
@ -1074,16 +1169,16 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
|
||||
subtitle = intent.getSerialized("subtitle")
|
||||
?: when (val subLang: String? = loadData("subLang_${media.id}", this)) {
|
||||
null -> {
|
||||
null -> {
|
||||
when (episode.selectedSubtitle) {
|
||||
null -> null
|
||||
-1 -> ext.subtitles.find { it.language.trim() == "English" || it.language == "en-US" }
|
||||
-1 -> ext.subtitles.find { it.language.trim() == "English" || it.language == "en-US" }
|
||||
else -> ext.subtitles.getOrNull(episode.selectedSubtitle!!)
|
||||
}
|
||||
}
|
||||
|
||||
"None" -> ext.subtitles.let { null }
|
||||
else -> ext.subtitles.find { it.language == subLang }
|
||||
else -> ext.subtitles.find { it.language == subLang }
|
||||
}
|
||||
|
||||
//Subtitles
|
||||
|
@ -1091,21 +1186,44 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
exoSubtitle.setOnClickListener {
|
||||
subClick()
|
||||
}
|
||||
|
||||
var sub: MediaItem.SubtitleConfiguration? = null
|
||||
if (subtitle != null) {
|
||||
sub = MediaItem.SubtitleConfiguration
|
||||
.Builder(Uri.parse(subtitle!!.file.url))
|
||||
.setSelectionFlags(C.SELECTION_FLAG_FORCED)
|
||||
.setMimeType(
|
||||
when (subtitle?.type) {
|
||||
SubtitleType.VTT -> MimeTypes.TEXT_VTT
|
||||
SubtitleType.ASS -> MimeTypes.TEXT_SSA
|
||||
SubtitleType.SRT -> MimeTypes.APPLICATION_SUBRIP
|
||||
else -> MimeTypes.TEXT_UNKNOWN
|
||||
}
|
||||
)
|
||||
.build()
|
||||
//var localFile: String? = null
|
||||
if (subtitle?.type == SubtitleType.UNKNOWN) {
|
||||
val context = this
|
||||
runBlocking {
|
||||
val type = SubtitleDownloader.downloadSubtitles(context, subtitle!!.file.url)
|
||||
val fileUri = Uri.parse(subtitle!!.file.url)
|
||||
sub = MediaItem.SubtitleConfiguration
|
||||
.Builder(fileUri)
|
||||
.setSelectionFlags(C.SELECTION_FLAG_DEFAULT)
|
||||
.setMimeType(
|
||||
when (type) {
|
||||
SubtitleType.VTT -> MimeTypes.TEXT_SSA
|
||||
SubtitleType.ASS -> MimeTypes.TEXT_SSA
|
||||
SubtitleType.SRT -> MimeTypes.TEXT_SSA
|
||||
else -> MimeTypes.TEXT_SSA
|
||||
}
|
||||
)
|
||||
.setId("2")
|
||||
.build()
|
||||
}
|
||||
println("sub: $sub")
|
||||
} else {
|
||||
sub = MediaItem.SubtitleConfiguration
|
||||
.Builder(Uri.parse(subtitle!!.file.url))
|
||||
.setSelectionFlags(C.SELECTION_FLAG_FORCED)
|
||||
.setMimeType(
|
||||
when (subtitle?.type) {
|
||||
SubtitleType.VTT -> MimeTypes.TEXT_VTT
|
||||
SubtitleType.ASS -> MimeTypes.TEXT_SSA
|
||||
SubtitleType.SRT -> MimeTypes.APPLICATION_SUBRIP
|
||||
else -> MimeTypes.TEXT_UNKNOWN
|
||||
}
|
||||
)
|
||||
.setId("2")
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
|
@ -1113,7 +1231,9 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
}
|
||||
|
||||
val but = playerView.findViewById<ImageButton>(R.id.exo_download)
|
||||
if (video?.format == VideoType.CONTAINER || (loadData<Int>("settings_download_manager") ?: 0) != 0) {
|
||||
if (video?.format == VideoType.CONTAINER || (loadData<Int>("settings_download_manager")
|
||||
?: 0) != 0
|
||||
) {
|
||||
but.visibility = View.VISIBLE
|
||||
but.setOnClickListener {
|
||||
download(this, episode, animeTitle.text.toString())
|
||||
|
@ -1146,12 +1266,15 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
val mimeType = when (video?.format) {
|
||||
VideoType.M3U8 -> MimeTypes.APPLICATION_M3U8
|
||||
VideoType.DASH -> MimeTypes.APPLICATION_MPD
|
||||
else -> MimeTypes.APPLICATION_MP4
|
||||
else -> MimeTypes.APPLICATION_MP4
|
||||
}
|
||||
|
||||
val builder = MediaItem.Builder().setUri(video!!.file.url).setMimeType(mimeType)
|
||||
|
||||
if (sub != null) builder.setSubtitleConfigurations(mutableListOf(sub))
|
||||
if (sub != null) {
|
||||
val listofnotnullsubs = immutableListOf(sub).filterNotNull()
|
||||
builder.setSubtitleConfigurations(listofnotnullsubs)
|
||||
}
|
||||
mediaItem = builder.build()
|
||||
|
||||
//Source
|
||||
|
@ -1163,8 +1286,22 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
trackSelector = DefaultTrackSelector(this)
|
||||
trackSelector.setParameters(
|
||||
trackSelector.buildUponParameters()
|
||||
.setMinVideoSize(loadData("maxWidth", this) ?: 720, loadData("maxHeight", this) ?: 480)
|
||||
.setAllowVideoMixedMimeTypeAdaptiveness(true)
|
||||
.setAllowVideoNonSeamlessAdaptiveness(true)
|
||||
.setSelectUndeterminedTextLanguage(true)
|
||||
.setAllowAudioMixedMimeTypeAdaptiveness(true)
|
||||
.setAllowMultipleAdaptiveSelections(true)
|
||||
.setPreferredTextLanguage(subtitle?.language ?: "en")
|
||||
.setPreferredTextRoleFlags(C.ROLE_FLAG_SUBTITLE)
|
||||
.setRendererDisabled(C.TRACK_TYPE_VIDEO, false)
|
||||
.setRendererDisabled(C.TRACK_TYPE_AUDIO, false)
|
||||
.setRendererDisabled(C.TRACK_TYPE_TEXT, false)
|
||||
.setMinVideoSize(
|
||||
loadData("maxWidth", this) ?: 720,
|
||||
loadData("maxHeight", this) ?: 480
|
||||
)
|
||||
.setMaxVideoSize(1, 1)
|
||||
//.setOverrideForType(
|
||||
)
|
||||
|
||||
if (playbackPosition != 0L && !changingServer && !settings.alwaysContinue) {
|
||||
|
@ -1181,7 +1318,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
)
|
||||
)
|
||||
)
|
||||
AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.continue_from, time)).apply {
|
||||
AlertDialog.Builder(this, R.style.DialogTheme)
|
||||
.setTitle(getString(R.string.continue_from, time)).apply {
|
||||
setCancelable(false)
|
||||
setPositiveButton(getString(R.string.yes)) { d, _ ->
|
||||
buildExoplayer()
|
||||
|
@ -1221,8 +1359,34 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
}
|
||||
|
||||
exoPlayer.addListener(this)
|
||||
exoPlayer.addAnalyticsListener(EventLogger())
|
||||
isInitialized = true
|
||||
}
|
||||
/*private fun selectSubtitleTrack() {
|
||||
// Get the current track groups
|
||||
val trackGroups = exoPlayer.currentTrackGroups
|
||||
|
||||
// Prepare a track selector parameters builder
|
||||
val parametersBuilder = DefaultTrackSelector.ParametersBuilder(this)
|
||||
|
||||
// Iterate through the track groups to find the subtitle tracks
|
||||
for (i in 0 until trackGroups.length) {
|
||||
val trackGroup = trackGroups[i]
|
||||
for (j in 0 until trackGroup.length) {
|
||||
val trackMetadata = trackGroup.getFormat(j)
|
||||
|
||||
// Check if the track is a subtitle track
|
||||
if (MimeTypes.isText(trackMetadata.sampleMimeType)) {
|
||||
parametersBuilder.setRendererDisabled(i, false) // Enable the renderer for this track group
|
||||
parametersBuilder.setSelectionOverride(i, trackGroups, DefaultTrackSelector.SelectionOverride(j, 0)) // Override to select this track
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the track selector parameters to select the subtitle
|
||||
trackSelector.setParameters(parametersBuilder)
|
||||
}*/
|
||||
|
||||
private fun releasePlayer() {
|
||||
isPlayerPlaying = exoPlayer.playWhenReady
|
||||
|
@ -1266,7 +1430,11 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
orientationListener?.disable()
|
||||
if (isInitialized) {
|
||||
playerView.player?.pause()
|
||||
saveData("${media.id}_${media.anime!!.selectedEpisode}", exoPlayer.currentPosition, this)
|
||||
saveData(
|
||||
"${media.id}_${media.anime!!.selectedEpisode}",
|
||||
exoPlayer.currentPosition,
|
||||
this
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1304,7 +1472,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
playerView.keepScreenOn = isPlaying
|
||||
(exoPlay.drawable as Animatable?)?.start()
|
||||
if (!this.isDestroyed) Glide.with(this)
|
||||
.load(if (isPlaying) R.drawable.anim_play_to_pause else R.drawable.anim_pause_to_play).into(exoPlay)
|
||||
.load(if (isPlaying) R.drawable.anim_play_to_pause else R.drawable.anim_pause_to_play)
|
||||
.into(exoPlay)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1383,7 +1552,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
exoPlayer.seekTo((new.interval.endTime * 1000).toLong())
|
||||
}
|
||||
}
|
||||
if (settings.autoSkipOPED && (new.skipType == "op" || new.skipType == "ed") && !skippedTimeStamps.contains(new)) {
|
||||
if (settings.autoSkipOPED && (new.skipType == "op" || new.skipType == "ed") && !skippedTimeStamps.contains(
|
||||
new
|
||||
)
|
||||
) {
|
||||
exoPlayer.seekTo((new.interval.endTime * 1000).toLong())
|
||||
skippedTimeStamps.add(new)
|
||||
}
|
||||
|
@ -1426,6 +1598,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
private var isBuffering = true
|
||||
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||
if (playbackState == ExoPlayer.STATE_READY) {
|
||||
|
||||
exoPlayer.play()
|
||||
if (episodeLength == 0f) {
|
||||
episodeLength = exoPlayer.duration.toFloat()
|
||||
|
@ -1453,7 +1626,9 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
var i = 1
|
||||
while (isFiller) {
|
||||
if (episodeArr.size > currentEpisodeIndex + i) {
|
||||
isFiller = if (settings.autoSkipFiller) episodes[episodeArr[currentEpisodeIndex + i]]?.filler ?: false else false
|
||||
isFiller =
|
||||
if (settings.autoSkipFiller) episodes[episodeArr[currentEpisodeIndex + i]]?.filler
|
||||
?: false else false
|
||||
if (!isFiller) runnable.invoke(i)
|
||||
i++
|
||||
} else {
|
||||
|
@ -1509,7 +1684,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
shareVideo.setDataAndType(Uri.parse(videoURL), "video/*")
|
||||
shareVideo.setPackage("com.instantbits.cast.webvideo")
|
||||
if (subtitle != null) shareVideo.putExtra("subtitle", subtitle!!.file.url)
|
||||
shareVideo.putExtra("title", media.userPreferredName + " : Ep " + episodeTitleArr[currentEpisodeIndex])
|
||||
shareVideo.putExtra(
|
||||
"title",
|
||||
media.userPreferredName + " : Ep " + episodeTitleArr[currentEpisodeIndex]
|
||||
)
|
||||
shareVideo.putExtra("poster", episode.thumb?.url ?: media.cover)
|
||||
val headers = Bundle()
|
||||
defaultHeaders.forEach {
|
||||
|
@ -1579,7 +1757,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
|
|||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) {
|
||||
override fun onPictureInPictureModeChanged(
|
||||
isInPictureInPictureMode: Boolean,
|
||||
newConfig: Configuration
|
||||
) {
|
||||
onPiPChanged(isInPictureInPictureMode)
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import ani.dantotsu.media.MediaDetailsViewModel
|
|||
import ani.dantotsu.others.Download.download
|
||||
import ani.dantotsu.parsers.VideoExtractor
|
||||
import ani.dantotsu.parsers.VideoType
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
|
@ -174,7 +174,9 @@ class MangaReadAdapter(
|
|||
val anilistEp = (media.userProgress ?: 0).plus(1)
|
||||
val appEp = loadData<String>("${media.id}_current_chp")?.toIntOrNull() ?: 1
|
||||
var continueEp = (if (anilistEp > appEp) anilistEp else appEp).toString()
|
||||
if (chapters.contains(continueEp)) {
|
||||
val formattedChapters = chapters.map { MangaNameAdapter.findChapterNumber(it)?.toInt()?.toString() }
|
||||
if (formattedChapters.contains(continueEp)) {
|
||||
continueEp = chapters[formattedChapters.indexOf(continueEp)]
|
||||
binding.animeSourceContinue.visibility = View.VISIBLE
|
||||
handleProgress(
|
||||
binding.itemEpisodeProgressCont,
|
||||
|
|
|
@ -116,10 +116,10 @@ abstract class BaseImageAdapter(
|
|||
abstract suspend fun loadImage(position: Int, parent: View): Boolean
|
||||
|
||||
companion object {
|
||||
/*suspend fun Context.loadBitmap(link: FileUrl, transforms: List<BitmapTransformation>): Bitmap? {
|
||||
suspend fun Context.loadBitmap_old(link: FileUrl, transforms: List<BitmapTransformation>): Bitmap? {
|
||||
return tryWithSuspend {
|
||||
withContext(Dispatchers.IO) {
|
||||
Glide.with(this@loadBitmap)
|
||||
Glide.with(this@loadBitmap_old)
|
||||
.asBitmap()
|
||||
.let {
|
||||
if (link.url.startsWith("file://")) {
|
||||
|
@ -142,7 +142,7 @@ abstract class BaseImageAdapter(
|
|||
.get()
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
suspend fun Context.loadBitmap(link: FileUrl, transforms: List<BitmapTransformation>): Bitmap? {
|
||||
return tryWithSuspend {
|
||||
|
|
|
@ -45,6 +45,7 @@ import ani.dantotsu.settings.CurrentReaderSettings.DualPageModes.*
|
|||
import ani.dantotsu.settings.CurrentReaderSettings.Layouts.*
|
||||
import ani.dantotsu.settings.ReaderSettings
|
||||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.alexvasilkov.gestures.views.GestureFrameLayout
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
|
@ -125,6 +126,7 @@ class MangaReaderActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityMangaReaderBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import ani.dantotsu.loadImage
|
|||
import ani.dantotsu.media.MediaDetailsViewModel
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.parsers.ShowResponse
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import ani.dantotsu.settings.CurrentReaderSettings
|
|||
import ani.dantotsu.settings.NovelReaderSettings
|
||||
import ani.dantotsu.settings.UserInterfaceSettings
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.tryWith
|
||||
import com.google.android.material.slider.Slider
|
||||
import com.vipulog.ebookreader.Book
|
||||
|
@ -135,6 +136,7 @@ class NovelReaderActivity : AppCompatActivity(), EbookReaderEventListener {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityNovelReaderBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.lifecycle.lifecycleScope
|
|||
import ani.dantotsu.R
|
||||
import ani.dantotsu.Refresh
|
||||
import ani.dantotsu.databinding.ActivityListBinding
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -26,6 +27,7 @@ class ListActivity : AppCompatActivity() {
|
|||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityListBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import ani.dantotsu.databinding.FragmentListBinding
|
|||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaAdaptor
|
||||
import ani.dantotsu.media.OtherDetailsViewModel
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class ListFragment : Fragment() {
|
||||
private var _binding: FragmentListBinding? = null
|
||||
|
|
|
@ -11,13 +11,14 @@ import ani.dantotsu.BottomSheetDialogFragment
|
|||
import ani.dantotsu.FileUrl
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.BottomSheetImageBinding
|
||||
import ani.dantotsu.media.manga.mangareader.BaseImageAdapter.Companion.loadBitmap
|
||||
import ani.dantotsu.media.manga.mangareader.BaseImageAdapter.Companion.loadBitmap_old
|
||||
import ani.dantotsu.media.manga.mangareader.BaseImageAdapter.Companion.mergeBitmap
|
||||
import ani.dantotsu.openLinkInBrowser
|
||||
import ani.dantotsu.saveImageToDownloads
|
||||
import ani.dantotsu.setSafeOnClickListener
|
||||
import ani.dantotsu.shareImage
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.toast
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||
|
@ -76,8 +77,8 @@ class ImageViewDialog : BottomSheetDialogFragment() {
|
|||
lifecycleScope.launch {
|
||||
val binding = _binding ?: return@launch
|
||||
|
||||
var bitmap = requireContext().loadBitmap(image, trans1 ?: listOf())
|
||||
val bitmap2 = if (image2 != null) requireContext().loadBitmap(image2, trans2 ?: listOf()) else null
|
||||
var bitmap = requireContext().loadBitmap_old(image, trans1 ?: listOf())
|
||||
val bitmap2 = if (image2 != null) requireContext().loadBitmap_old(image2, trans2 ?: listOf()) else null
|
||||
|
||||
bitmap = if (bitmap2 != null && bitmap != null) mergeBitmap(bitmap, bitmap2,) else bitmap
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import ani.dantotsu.R
|
|||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.databinding.ActivityImageSearchBinding
|
||||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.toast
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -46,6 +47,7 @@ class ImageSearchActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityImageSearchBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -32,8 +32,10 @@ abstract class AnimeParser : BaseParser() {
|
|||
* Returns null, if no latest episode is found.
|
||||
* **/
|
||||
open suspend fun getLatestEpisode(animeLink: String, extra: Map<String, String>?, sAnime: SAnime, latest: Float): Episode?{
|
||||
return loadEpisodes(animeLink, extra, sAnime)
|
||||
val episodes = loadEpisodes(animeLink, extra, sAnime)
|
||||
val max = episodes
|
||||
.maxByOrNull { it.number.toFloatOrNull()?:0f }
|
||||
return max
|
||||
?.takeIf { latest < (it.number.toFloatOrNull() ?: 0.001f) }
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,10 @@ import kotlinx.coroutines.async
|
|||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.OutputStream
|
||||
|
@ -498,7 +501,24 @@ class VideoServerPassthrough(val videoServer: VideoServer) : VideoExtractor() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun TrackToSubtitle(track: Track, type: SubtitleType = SubtitleType.VTT): Subtitle {
|
||||
return Subtitle(track.lang, track.url, type)
|
||||
private fun TrackToSubtitle(track: Track): Subtitle {
|
||||
//use Dispatchers.IO to make a HTTP request to determine the subtitle type
|
||||
var type: SubtitleType? = null
|
||||
runBlocking {
|
||||
type = findSubtitleType(track.url)
|
||||
}
|
||||
return Subtitle(track.lang, track.url, type?: SubtitleType.SRT)
|
||||
}
|
||||
|
||||
private fun findSubtitleType(url: String): SubtitleType? {
|
||||
// First, try to determine the type based on the URL file extension
|
||||
var type: SubtitleType? = when {
|
||||
url.endsWith(".vtt", true) -> SubtitleType.VTT
|
||||
url.endsWith(".ass", true) -> SubtitleType.ASS
|
||||
url.endsWith(".srt", true) -> SubtitleType.SRT
|
||||
else -> SubtitleType.UNKNOWN
|
||||
}
|
||||
|
||||
return type
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package ani.dantotsu.parsers
|
|||
import android.graphics.Bitmap
|
||||
import ani.dantotsu.FileUrl
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.manga.MangaNameAdapter
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
|
@ -23,9 +24,11 @@ abstract class MangaParser : BaseParser() {
|
|||
* Returns null, if no latest chapter is found.
|
||||
* **/
|
||||
open suspend fun getLatestChapter(mangaLink: String, extra: Map<String, String>?, sManga: SManga, latest: Float): MangaChapter? {
|
||||
return loadChapters(mangaLink, extra, sManga)
|
||||
.maxByOrNull { it.number.toFloatOrNull() ?: 0f }
|
||||
?.takeIf { latest < (it.number.toFloatOrNull() ?: 0.001f) }
|
||||
val chapter = loadChapters(mangaLink, extra, sManga)
|
||||
val max = chapter
|
||||
.maxByOrNull { MangaNameAdapter.findChapterNumber(it.number) ?: 0f }
|
||||
return max
|
||||
?.takeIf { latest < (MangaNameAdapter.findChapterNumber(it.number) ?: 0.001f) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,22 +36,6 @@ abstract class MangaParser : BaseParser() {
|
|||
* **/
|
||||
abstract suspend fun loadImages(chapterLink: String, sChapter: SChapter): List<MangaImage>
|
||||
|
||||
/*override suspend fun autoSearch(mediaObj: Media): ShowResponse? {
|
||||
var response = loadSavedShowResponse(mediaObj.id)
|
||||
if (response != null) {
|
||||
saveShowResponse(mediaObj.id, response, true)
|
||||
} else {
|
||||
setUserText("Searching : ${mediaObj.mangaName()}")
|
||||
response = search(mediaObj.mangaName()).let { if (it.isNotEmpty()) it[0] else null }
|
||||
|
||||
if (response == null) {
|
||||
setUserText("Searching : ${mediaObj.nameRomaji}")
|
||||
response = search(mediaObj.nameRomaji).let { if (it.isNotEmpty()) it[0] else null }
|
||||
}
|
||||
saveShowResponse(mediaObj.id, response)
|
||||
}
|
||||
return response
|
||||
}*/
|
||||
|
||||
open fun getTransformation(): BitmapTransformation? = null
|
||||
}
|
||||
|
|
|
@ -159,5 +159,5 @@ enum class VideoType{
|
|||
}
|
||||
|
||||
enum class SubtitleType{
|
||||
VTT, ASS, SRT
|
||||
VTT, ASS, SRT, UNKNOWN
|
||||
}
|
|
@ -23,6 +23,7 @@ import ani.dantotsu.R
|
|||
import ani.dantotsu.databinding.FragmentAnimeExtensionsBinding
|
||||
import ani.dantotsu.loadData
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager
|
||||
import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension
|
||||
|
@ -67,13 +68,14 @@ class AnimeExtensionsFragment : Fragment(),
|
|||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{ error ->
|
||||
FirebaseCrashlytics.getInstance().recordException(error)
|
||||
Log.e("AnimeExtensionsAdapter", "Error: ", error) // Log the error
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_ERROR
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_info_24)
|
||||
.setContentTitle("Update failed")
|
||||
.setContentTitle("Update failed: ${error.message}")
|
||||
.setContentText("Error: ${error.message}")
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
notificationManager.notify(1, builder.build())
|
||||
|
@ -97,48 +99,51 @@ class AnimeExtensionsFragment : Fragment(),
|
|||
}, skipIcons)
|
||||
|
||||
private val allExtensionsAdapter = AllAnimeExtensionsAdapter(lifecycleScope, { pkgName ->
|
||||
val context = requireContext()
|
||||
if (isAdded) {
|
||||
val notificationManager =
|
||||
requireContext().getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
|
||||
val notificationManager =
|
||||
requireContext().getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
|
||||
// Start the installation process
|
||||
animeExtensionManager.installExtension(pkgName)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{ installStep ->
|
||||
val builder = NotificationCompat.Builder(
|
||||
requireContext(),
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_sync_24)
|
||||
.setContentTitle("Installing extension")
|
||||
.setContentText("Step: $installStep")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{ error ->
|
||||
val builder = NotificationCompat.Builder(
|
||||
requireContext(),
|
||||
Notifications.CHANNEL_DOWNLOADER_ERROR
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_info_24)
|
||||
.setContentTitle("Installation failed")
|
||||
.setContentText("Error: ${error.message}")
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{
|
||||
val builder = NotificationCompat.Builder(
|
||||
requireContext(),
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(androidx.media3.ui.R.drawable.exo_ic_check)
|
||||
.setContentTitle("Installation complete")
|
||||
.setContentText("The extension has been successfully installed.")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
}
|
||||
)
|
||||
// Start the installation process
|
||||
animeExtensionManager.installExtension(pkgName)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{ installStep ->
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_sync_24)
|
||||
.setContentTitle("Installing extension")
|
||||
.setContentText("Step: $installStep")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{ error ->
|
||||
FirebaseCrashlytics.getInstance().recordException(error)
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_ERROR
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_info_24)
|
||||
.setContentTitle("Installation failed: ${error.message}")
|
||||
.setContentText("Error: ${error.message}")
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(androidx.media3.ui.R.drawable.exo_ic_check)
|
||||
.setContentTitle("Installation complete")
|
||||
.setContentText("The extension has been successfully installed.")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
}
|
||||
)
|
||||
}
|
||||
}, skipIcons)
|
||||
|
||||
override fun onCreateView(
|
||||
|
|
|
@ -34,6 +34,7 @@ import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension
|
|||
import ani.dantotsu.databinding.ActivityExtensionsBinding
|
||||
import ani.dantotsu.home.AnimeFragment
|
||||
import ani.dantotsu.home.MangaFragment
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
|
@ -60,6 +61,7 @@ class ExtensionsActivity : AppCompatActivity() {
|
|||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityExtensionsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import ani.dantotsu.R
|
|||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.databinding.ActivityFaqBinding
|
||||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class FAQActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityFaqBinding
|
||||
|
@ -104,6 +105,7 @@ class FAQActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityFaqBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import ani.dantotsu.databinding.FragmentMangaBinding
|
|||
import ani.dantotsu.databinding.FragmentMangaExtensionsBinding
|
||||
import ani.dantotsu.loadData
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
|
||||
import eu.kanade.tachiyomi.extension.manga.model.MangaExtension
|
||||
|
@ -67,6 +68,7 @@ class MangaExtensionsFragment : Fragment(),
|
|||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{ error ->
|
||||
FirebaseCrashlytics.getInstance().recordException(error)
|
||||
Log.e("MangaExtensionsAdapter", "Error: ", error) // Log the error
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
|
@ -98,48 +100,51 @@ class MangaExtensionsFragment : Fragment(),
|
|||
|
||||
private val allExtensionsAdapter =
|
||||
AllMangaExtensionsAdapter(lifecycleScope, { pkgName ->
|
||||
if (isAdded) { // Check if the fragment is currently added to its activity
|
||||
val context = requireContext()
|
||||
val notificationManager =
|
||||
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
|
||||
val notificationManager =
|
||||
requireContext().getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
|
||||
// Start the installation process
|
||||
mangaExtensionManager.installExtension(pkgName)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{ installStep ->
|
||||
val builder = NotificationCompat.Builder(
|
||||
requireContext(),
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_sync_24)
|
||||
.setContentTitle("Installing extension")
|
||||
.setContentText("Step: $installStep")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{ error ->
|
||||
val builder = NotificationCompat.Builder(
|
||||
requireContext(),
|
||||
Notifications.CHANNEL_DOWNLOADER_ERROR
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_info_24)
|
||||
.setContentTitle("Installation failed")
|
||||
.setContentText("Error: ${error.message}")
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{
|
||||
val builder = NotificationCompat.Builder(
|
||||
requireContext(),
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(androidx.media3.ui.R.drawable.exo_ic_check)
|
||||
.setContentTitle("Installation complete")
|
||||
.setContentText("The extension has been successfully installed.")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
}
|
||||
)
|
||||
// Start the installation process
|
||||
mangaExtensionManager.installExtension(pkgName)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{ installStep ->
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_sync_24)
|
||||
.setContentTitle("Installing extension")
|
||||
.setContentText("Step: $installStep")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{ error ->
|
||||
FirebaseCrashlytics.getInstance().recordException(error)
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_ERROR
|
||||
)
|
||||
.setSmallIcon(R.drawable.ic_round_info_24)
|
||||
.setContentTitle("Installation failed: ${error.message}")
|
||||
.setContentText("Error: ${error.message}")
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
notificationManager.notify(1, builder.build())
|
||||
},
|
||||
{
|
||||
val builder = NotificationCompat.Builder(
|
||||
context,
|
||||
Notifications.CHANNEL_DOWNLOADER_PROGRESS
|
||||
)
|
||||
.setSmallIcon(androidx.media3.ui.R.drawable.exo_ic_check)
|
||||
.setContentTitle("Installation complete")
|
||||
.setContentText("The extension has been successfully installed.")
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
notificationManager.notify(1, builder.build())
|
||||
}
|
||||
)
|
||||
}
|
||||
}, skipIcons)
|
||||
|
||||
override fun onCreateView(
|
||||
|
|
|
@ -16,6 +16,7 @@ import ani.dantotsu.databinding.ActivityPlayerSettingsBinding
|
|||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.parsers.Subtitle
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
@ -30,6 +31,7 @@ class PlayerSettingsActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityPlayerSettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -12,12 +12,14 @@ import ani.dantotsu.navBarHeight
|
|||
import ani.dantotsu.saveData
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
class ReaderSettingsActivity : AppCompatActivity() {
|
||||
lateinit var binding: ActivityReaderSettingsBinding
|
||||
private val reader = "reader_settings"
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityReaderSettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
|
@ -31,6 +32,7 @@ import ani.dantotsu.subcriptions.Notifications.Companion.openSettings
|
|||
import ani.dantotsu.subcriptions.Subscription.Companion.defaultTime
|
||||
import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription
|
||||
import ani.dantotsu.subcriptions.Subscription.Companion.timeMinutes
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.tachiyomi.network.NetworkPreferences
|
||||
import io.noties.markwon.Markwon
|
||||
|
@ -54,6 +56,7 @@ class SettingsActivity : AppCompatActivity() {
|
|||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
@ -98,6 +101,23 @@ OS Version: $CODENAME $RELEASE ($SDK_INT)
|
|||
binding.settingsUseMaterialYou.isChecked = getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean("use_material_you", false)
|
||||
binding.settingsUseMaterialYou.setOnCheckedChangeListener { _, isChecked ->
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putBoolean("use_material_you", isChecked).apply()
|
||||
Toast.makeText(this, "Restart app to apply changes", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
val themeString = getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getString("theme", "PURPLE")!!
|
||||
binding.themeSwitcher.setText(themeString.substring(0, 1) + themeString.substring(1).lowercase())
|
||||
|
||||
binding.themeSwitcher.setAdapter(ArrayAdapter(this, R.layout.item_dropdown, ThemeManager.Companion.Theme.values().map { it.theme.substring(0, 1) + it.theme.substring(1).lowercase() }))
|
||||
|
||||
binding.themeSwitcher.setOnItemClickListener { _, _, i, _ ->
|
||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putString("theme", ThemeManager.Companion.Theme.values()[i].theme).apply()
|
||||
ActivityHelper.shouldRefreshMainActivity = true
|
||||
binding.themeSwitcher.clearFocus()
|
||||
Refresh.all()
|
||||
finish()
|
||||
startActivity(Intent(this, SettingsActivity::class.java))
|
||||
initActivity(this)
|
||||
|
||||
}
|
||||
|
||||
//val animeSource = loadData<Int>("settings_def_anime_source_s")?.let { if (it >= AnimeSources.names.size) 0 else it } ?: 0
|
||||
|
@ -150,6 +170,15 @@ OS Version: $CODENAME $RELEASE ($SDK_INT)
|
|||
true
|
||||
}
|
||||
|
||||
val exDns = listOf("None", "Cloudflare", "Google", "AdGuard", "Quad9", "AliDNS", "DNSPod", "360", "Quad101", "Mullvad", "Controld", "Njalla", "Shecan")
|
||||
binding.settingsExtensionDns.setText(exDns[networkPreferences.dohProvider().get()], false)
|
||||
binding.settingsExtensionDns.setAdapter(ArrayAdapter(this, R.layout.item_dropdown, exDns))
|
||||
binding.settingsExtensionDns.setOnItemClickListener { _, _, i, _ ->
|
||||
networkPreferences.dohProvider().set(i)
|
||||
binding.settingsExtensionDns.clearFocus()
|
||||
Toast.makeText(this, "Restart app to apply changes", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
binding.settingsDownloadInSd.isChecked = loadData("sd_dl") ?: false
|
||||
binding.settingsDownloadInSd.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
|
@ -381,7 +410,7 @@ OS Version: $CODENAME $RELEASE ($SDK_INT)
|
|||
}
|
||||
}
|
||||
|
||||
var curTime = loadData<Int>("subscriptions_time") ?: defaultTime
|
||||
var curTime = loadData<Int>("subscriptions_time_r") ?: defaultTime
|
||||
val timeNames = timeMinutes.map {
|
||||
val mins = it % 60
|
||||
val hours = it / 60
|
||||
|
@ -394,7 +423,7 @@ OS Version: $CODENAME $RELEASE ($SDK_INT)
|
|||
speedDialog.setSingleChoiceItems(timeNames, curTime) { dialog, i ->
|
||||
curTime = i
|
||||
binding.settingsSubscriptionsTime.text = getString(R.string.subscriptions_checking_time_s, timeNames[i])
|
||||
saveData("subscriptions_time", curTime)
|
||||
saveData("subscriptions_time_r", curTime)
|
||||
dialog.dismiss()
|
||||
startSubscription(true)
|
||||
}.show()
|
||||
|
@ -538,7 +567,7 @@ OS Version: $CODENAME $RELEASE ($SDK_INT)
|
|||
title = "Enjoying the App?"
|
||||
addView(TextView(this@SettingsActivity).apply {
|
||||
text =
|
||||
"Consider donating!r"
|
||||
"Consider donating!"
|
||||
})
|
||||
|
||||
setNegativeButton("no moners :(") {
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.core.view.updateLayoutParams
|
||||
import ani.dantotsu.*
|
||||
import ani.dantotsu.databinding.ActivityUserInterfaceSettingsBinding
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
class UserInterfaceSettingsActivity : AppCompatActivity() {
|
||||
|
@ -15,6 +16,7 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
|
|||
private val ui = "ui_settings"
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeManager(this).applyTheme()
|
||||
binding = ActivityUserInterfaceSettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class AlarmReceiver : BroadcastReceiver() {
|
|||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
val curTime = loadData<Int>("subscriptions_time", context) ?: defaultTime
|
||||
val curTime = loadData<Int>("subscriptions_time_r", context) ?: defaultTime
|
||||
|
||||
if (timeMinutes[curTime] > 0)
|
||||
alarmManager.setRepeating(
|
||||
|
|
|
@ -16,8 +16,8 @@ import kotlinx.coroutines.launch
|
|||
@SuppressLint("MissingPermission")
|
||||
class Subscription {
|
||||
companion object {
|
||||
const val defaultTime = 8
|
||||
val timeMinutes = arrayOf(0L, 5, 10, 15, 30, 45, 60, 90, 120, 180, 240, 360, 480, 720, 1440)
|
||||
const val defaultTime = 3
|
||||
val timeMinutes = arrayOf(0L, 120, 180, 240, 360, 480, 720, 1440)
|
||||
|
||||
private var alreadyStarted = false
|
||||
fun Context.startSubscription(force: Boolean = false) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import ani.dantotsu.parsers.*
|
|||
import ani.dantotsu.saveData
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.media.manga.MangaNameAdapter
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
|
||||
class SubscriptionHelper {
|
||||
|
@ -76,7 +77,7 @@ class SubscriptionHelper {
|
|||
}
|
||||
|
||||
return chp?.apply {
|
||||
selected.latest = number.toFloat()
|
||||
selected.latest = MangaNameAdapter.findChapterNumber(number) ?: 0f
|
||||
saveSelected(context, id, selected)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class SubscriptionWorker(val context: Context, params: WorkerParameters) : Corou
|
|||
|
||||
private const val SUBSCRIPTION_WORK_NAME = "work_subscription"
|
||||
fun enqueue(context: Context) {
|
||||
val curTime = loadData<Int>("subscriptions_time") ?: defaultTime
|
||||
val curTime = loadData<Int>("subscriptions_time_r") ?: defaultTime
|
||||
if(timeMinutes[curTime]>0L) {
|
||||
val constraints = Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()
|
||||
val periodicSyncDataWork = PeriodicWorkRequest.Builder(
|
||||
|
|
48
app/src/main/java/ani/dantotsu/themes/ThemeManager.kt
Normal file
48
app/src/main/java/ani/dantotsu/themes/ThemeManager.kt
Normal file
|
@ -0,0 +1,48 @@
|
|||
package ani.dantotsu.themes
|
||||
|
||||
import android.content.Context
|
||||
import ani.dantotsu.R
|
||||
|
||||
class ThemeManager(private val context: Context) {
|
||||
fun applyTheme() {
|
||||
if(context.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean("use_material_you", false)){
|
||||
return
|
||||
}
|
||||
when (context.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getString("theme", "PURPLE")!!) {
|
||||
"PURPLE" -> {
|
||||
context.setTheme(R.style.Theme_Dantotsu_Purple)
|
||||
}
|
||||
//"MONOCHROME" -> {
|
||||
// context.setTheme(R.style.Theme_Dantotsu_Monochrome)
|
||||
//}
|
||||
"BLUE" -> {
|
||||
context.setTheme(R.style.Theme_Dantotsu_Blue)
|
||||
}
|
||||
"GREEN" -> {
|
||||
context.setTheme(R.style.Theme_Dantotsu_Green)
|
||||
}
|
||||
"PINK" -> {
|
||||
context.setTheme(R.style.Theme_Dantotsu_Pink)
|
||||
}
|
||||
else -> {
|
||||
context.setTheme(R.style.Theme_Dantotsu_Purple)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object{
|
||||
enum class Theme(val theme: String) {
|
||||
PURPLE("PURPLE"),
|
||||
BLUE("BLUE"),
|
||||
GREEN("GREEN"),
|
||||
PINK("PINK");
|
||||
//MONOCHROME("MONOCHROME");
|
||||
|
||||
companion object {
|
||||
fun fromString(value: String): Theme {
|
||||
return values().find { it.theme == value } ?: PURPLE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue