cleanup
This commit is contained in:
parent
0ebd067bc2
commit
73be639397
10 changed files with 40 additions and 28 deletions
|
@ -47,13 +47,10 @@ import ani.dantotsu.media.MediaDetailsActivity
|
||||||
import ani.dantotsu.others.CustomBottomDialog
|
import ani.dantotsu.others.CustomBottomDialog
|
||||||
import ani.dantotsu.others.LangSet
|
import ani.dantotsu.others.LangSet
|
||||||
import ani.dantotsu.others.SharedPreferenceBooleanLiveData
|
import ani.dantotsu.others.SharedPreferenceBooleanLiveData
|
||||||
import ani.dantotsu.parsers.novel.NovelExtensionManager
|
|
||||||
import ani.dantotsu.settings.UserInterfaceSettings
|
import ani.dantotsu.settings.UserInterfaceSettings
|
||||||
import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription
|
import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription
|
||||||
import ani.dantotsu.themes.ThemeManager
|
import ani.dantotsu.themes.ThemeManager
|
||||||
import eu.kanade.domain.source.service.SourcePreferences
|
import eu.kanade.domain.source.service.SourcePreferences
|
||||||
import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager
|
|
||||||
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
|
|
||||||
import io.noties.markwon.Markwon
|
import io.noties.markwon.Markwon
|
||||||
import io.noties.markwon.SoftBreakAddsNewLinePlugin
|
import io.noties.markwon.SoftBreakAddsNewLinePlugin
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -65,7 +62,6 @@ import nl.joery.animatedbottombar.AnimatedBottomBar
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
import kotlin.random.Random
|
|
||||||
|
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
|
@ -75,9 +75,11 @@ class DownloadsManager(private val context: Context) {
|
||||||
DownloadedType.Type.MANGA -> {
|
DownloadedType.Type.MANGA -> {
|
||||||
downloadsList.removeAll { it.title == title && it.type == DownloadedType.Type.MANGA }
|
downloadsList.removeAll { it.title == title && it.type == DownloadedType.Type.MANGA }
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadedType.Type.ANIME -> {
|
DownloadedType.Type.ANIME -> {
|
||||||
downloadsList.removeAll { it.title == title && it.type == DownloadedType.Type.ANIME }
|
downloadsList.removeAll { it.title == title && it.type == DownloadedType.Type.ANIME }
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadedType.Type.NOVEL -> {
|
DownloadedType.Type.NOVEL -> {
|
||||||
downloadsList.removeAll { it.title == title && it.type == DownloadedType.Type.NOVEL }
|
downloadsList.removeAll { it.title == title && it.type == DownloadedType.Type.NOVEL }
|
||||||
}
|
}
|
||||||
|
@ -252,7 +254,12 @@ class DownloadsManager(private val context: Context) {
|
||||||
const val mangaLocation = "Dantotsu/Manga"
|
const val mangaLocation = "Dantotsu/Manga"
|
||||||
const val animeLocation = "Dantotsu/Anime"
|
const val animeLocation = "Dantotsu/Anime"
|
||||||
|
|
||||||
fun getDirectory(context: Context, type: DownloadedType.Type, title: String, chapter: String? = null): File {
|
fun getDirectory(
|
||||||
|
context: Context,
|
||||||
|
type: DownloadedType.Type,
|
||||||
|
title: String,
|
||||||
|
chapter: String? = null
|
||||||
|
): File {
|
||||||
return if (type == DownloadedType.Type.MANGA) {
|
return if (type == DownloadedType.Type.MANGA) {
|
||||||
if (chapter != null) {
|
if (chapter != null) {
|
||||||
File(
|
File(
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package ani.dantotsu.download.manga
|
package ani.dantotsu.download.manga
|
||||||
|
|
||||||
import android.animation.ObjectAnimator
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
|
@ -15,7 +13,6 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.animation.AlphaAnimation
|
import android.view.animation.AlphaAnimation
|
||||||
import android.view.animation.LayoutAnimationController
|
import android.view.animation.LayoutAnimationController
|
||||||
import android.view.animation.OvershootInterpolator
|
|
||||||
import android.widget.AbsListView
|
import android.widget.AbsListView
|
||||||
import android.widget.AutoCompleteTextView
|
import android.widget.AutoCompleteTextView
|
||||||
import android.widget.GridView
|
import android.widget.GridView
|
||||||
|
@ -45,7 +42,6 @@ import ani.dantotsu.setSafeOnClickListener
|
||||||
import ani.dantotsu.settings.SettingsDialogFragment
|
import ani.dantotsu.settings.SettingsDialogFragment
|
||||||
import ani.dantotsu.settings.UserInterfaceSettings
|
import ani.dantotsu.settings.UserInterfaceSettings
|
||||||
import ani.dantotsu.snackString
|
import ani.dantotsu.snackString
|
||||||
import ani.dantotsu.statusBarHeight
|
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
import com.google.android.material.imageview.ShapeableImageView
|
import com.google.android.material.imageview.ShapeableImageView
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
|
@ -57,8 +53,6 @@ import eu.kanade.tachiyomi.source.model.SChapterImpl
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.math.max
|
|
||||||
import kotlin.math.min
|
|
||||||
|
|
||||||
class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
|
class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
|
||||||
|
|
||||||
|
|
|
@ -133,8 +133,9 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
|
||||||
binding.animeIncludeList.visibility =
|
binding.animeIncludeList.visibility =
|
||||||
if (Anilist.userid != null) View.VISIBLE else View.GONE
|
if (Anilist.userid != null) View.VISIBLE else View.GONE
|
||||||
|
|
||||||
binding.animeIncludeList.isChecked = currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
binding.animeIncludeList.isChecked =
|
||||||
?.getBoolean("popular_list", true) ?: true
|
currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||||
|
?.getBoolean("popular_list", true) ?: true
|
||||||
|
|
||||||
binding.animeIncludeList.setOnCheckedChangeListener { _, isChecked ->
|
binding.animeIncludeList.setOnCheckedChangeListener { _, isChecked ->
|
||||||
onIncludeListClick.invoke(isChecked)
|
onIncludeListClick.invoke(isChecked)
|
||||||
|
|
|
@ -61,7 +61,8 @@ class SearchAdapter(private val activity: SearchActivity) :
|
||||||
|
|
||||||
binding.searchBar.hint = activity.result.type
|
binding.searchBar.hint = activity.result.type
|
||||||
if (currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
if (currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||||
?.getBoolean("incognito", false ) == true){
|
?.getBoolean("incognito", false) == true
|
||||||
|
) {
|
||||||
val startIconDrawableRes = R.drawable.ic_incognito_24
|
val startIconDrawableRes = R.drawable.ic_incognito_24
|
||||||
val startIconDrawable: Drawable? =
|
val startIconDrawable: Drawable? =
|
||||||
context?.let { AppCompatResources.getDrawable(it, startIconDrawableRes) }
|
context?.let { AppCompatResources.getDrawable(it, startIconDrawableRes) }
|
||||||
|
|
|
@ -1323,7 +1323,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
||||||
}
|
}
|
||||||
dataSource
|
dataSource
|
||||||
}
|
}
|
||||||
val dafuckDataSourceFactory = DefaultDataSourceFactory(this, Util.getUserAgent(this, R.string.app_name.toString()))
|
val dafuckDataSourceFactory =
|
||||||
|
DefaultDataSourceFactory(this, Util.getUserAgent(this, R.string.app_name.toString()))
|
||||||
cacheFactory = CacheDataSource.Factory().apply {
|
cacheFactory = CacheDataSource.Factory().apply {
|
||||||
setCache(Helper.getSimpleCache(this@ExoplayerView))
|
setCache(Helper.getSimpleCache(this@ExoplayerView))
|
||||||
if (ext.server.offline) {
|
if (ext.server.offline) {
|
||||||
|
@ -1745,7 +1746,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
||||||
|
|
||||||
private fun updateAniProgress() {
|
private fun updateAniProgress() {
|
||||||
val incognito = currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
val incognito = currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)
|
||||||
?.getBoolean("incognito", false) ?: false
|
?.getBoolean("incognito", false) ?: false
|
||||||
if (!incognito && exoPlayer.currentPosition / episodeLength > settings.watchPercentage && Anilist.userid != null)
|
if (!incognito && exoPlayer.currentPosition / episodeLength > settings.watchPercentage && Anilist.userid != null)
|
||||||
if (loadData<Boolean>("${media.id}_save_progress") != false && if (media.isAdult) settings.updateForH else true) {
|
if (loadData<Boolean>("${media.id}_save_progress") != false && if (media.isAdult) settings.updateForH else true) {
|
||||||
media.anime!!.selectedEpisode?.apply {
|
media.anime!!.selectedEpisode?.apply {
|
||||||
|
|
|
@ -219,7 +219,10 @@ class MangaReaderActivity : AppCompatActivity() {
|
||||||
val mangaSources = MangaSources
|
val mangaSources = MangaSources
|
||||||
val scope = lifecycleScope
|
val scope = lifecycleScope
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
mangaSources.init(Injekt.get<MangaExtensionManager>().installedExtensionsFlow, this@MangaReaderActivity)
|
mangaSources.init(
|
||||||
|
Injekt.get<MangaExtensionManager>().installedExtensionsFlow,
|
||||||
|
this@MangaReaderActivity
|
||||||
|
)
|
||||||
}
|
}
|
||||||
model.mangaReadSources = mangaSources
|
model.mangaReadSources = mangaSources
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -96,6 +96,7 @@ query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
res?.body?.string()
|
res?.body?.string()
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ class OfflineVideoExtractor(val videoServer: VideoServer) : VideoExtractor() {
|
||||||
val sublist = getSubtitle(
|
val sublist = getSubtitle(
|
||||||
videoServer.extraData?.get("title") ?: "",
|
videoServer.extraData?.get("title") ?: "",
|
||||||
videoServer.extraData?.get("episode") ?: ""
|
videoServer.extraData?.get("episode") ?: ""
|
||||||
)?: emptyList()
|
) ?: emptyList()
|
||||||
//we need to return a "fake" video so that the app doesn't crash
|
//we need to return a "fake" video so that the app doesn't crash
|
||||||
val video = Video(
|
val video = Video(
|
||||||
null,
|
null,
|
||||||
|
|
|
@ -215,10 +215,12 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.settingsPinnedAnimeSources.setOnClickListener {
|
binding.settingsPinnedAnimeSources.setOnClickListener {
|
||||||
val animeSourcesWithoutDownloadsSource = AnimeSources.list.filter { it.name != "Downloaded" }
|
val animeSourcesWithoutDownloadsSource =
|
||||||
|
AnimeSources.list.filter { it.name != "Downloaded" }
|
||||||
val names = animeSourcesWithoutDownloadsSource.map { it.name }
|
val names = animeSourcesWithoutDownloadsSource.map { it.name }
|
||||||
val pinnedSourcesBoolean = animeSourcesWithoutDownloadsSource.map { it.name in AnimeSources.pinnedAnimeSources }
|
val pinnedSourcesBoolean =
|
||||||
val pinnedSourcesOriginal = getSharedPreferences(
|
animeSourcesWithoutDownloadsSource.map { it.name in AnimeSources.pinnedAnimeSources }
|
||||||
|
val pinnedSourcesOriginal = getSharedPreferences(
|
||||||
"Dantotsu",
|
"Dantotsu",
|
||||||
Context.MODE_PRIVATE
|
Context.MODE_PRIVATE
|
||||||
).getStringSet("pinned_anime_sources", null)
|
).getStringSet("pinned_anime_sources", null)
|
||||||
|
@ -240,12 +242,14 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
"Dantotsu",
|
"Dantotsu",
|
||||||
Context.MODE_PRIVATE
|
Context.MODE_PRIVATE
|
||||||
).getInt("settings_def_anime_source_s_r", 0)
|
).getInt("settings_def_anime_source_s_r", 0)
|
||||||
val oldName = if (oldDefaultSourceIndex >= AnimeSources.names.size) "" else AnimeSources.names[oldDefaultSourceIndex]
|
val oldName =
|
||||||
|
if (oldDefaultSourceIndex >= AnimeSources.names.size) "" else AnimeSources.names[oldDefaultSourceIndex]
|
||||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||||
.putStringSet("pinned_anime_sources", pinnedSources).apply()
|
.putStringSet("pinned_anime_sources", pinnedSources).apply()
|
||||||
AnimeSources.pinnedAnimeSources = pinnedSources
|
AnimeSources.pinnedAnimeSources = pinnedSources
|
||||||
AnimeSources.performReorderAnimeSources()
|
AnimeSources.performReorderAnimeSources()
|
||||||
val newDefaultSourceIndex = if (oldName == "") 0 else AnimeSources.names.indexOf(oldName)
|
val newDefaultSourceIndex =
|
||||||
|
if (oldName == "") 0 else AnimeSources.names.indexOf(oldName)
|
||||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||||
.putInt("settings_def_anime_source_s_r", newDefaultSourceIndex).apply()
|
.putInt("settings_def_anime_source_s_r", newDefaultSourceIndex).apply()
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
|
@ -468,10 +472,12 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.settingsPinnedMangaSources.setOnClickListener {
|
binding.settingsPinnedMangaSources.setOnClickListener {
|
||||||
val mangaSourcesWithoutDownloadsSource = MangaSources.list.filter { it.name != "Downloaded" }
|
val mangaSourcesWithoutDownloadsSource =
|
||||||
|
MangaSources.list.filter { it.name != "Downloaded" }
|
||||||
val names = mangaSourcesWithoutDownloadsSource.map { it.name }
|
val names = mangaSourcesWithoutDownloadsSource.map { it.name }
|
||||||
val pinnedSourcesBoolean = mangaSourcesWithoutDownloadsSource.map { it.name in MangaSources.pinnedMangaSources }
|
val pinnedSourcesBoolean =
|
||||||
val pinnedSourcesOriginal = getSharedPreferences(
|
mangaSourcesWithoutDownloadsSource.map { it.name in MangaSources.pinnedMangaSources }
|
||||||
|
val pinnedSourcesOriginal = getSharedPreferences(
|
||||||
"Dantotsu",
|
"Dantotsu",
|
||||||
Context.MODE_PRIVATE
|
Context.MODE_PRIVATE
|
||||||
).getStringSet("pinned_manga_sources", null)
|
).getStringSet("pinned_manga_sources", null)
|
||||||
|
@ -493,12 +499,14 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
"Dantotsu",
|
"Dantotsu",
|
||||||
Context.MODE_PRIVATE
|
Context.MODE_PRIVATE
|
||||||
).getInt("settings_def_manga_source_s_r", 0)
|
).getInt("settings_def_manga_source_s_r", 0)
|
||||||
val oldName = if (oldDefaultSourceIndex >= MangaSources.names.size) "" else MangaSources.names[oldDefaultSourceIndex]
|
val oldName =
|
||||||
|
if (oldDefaultSourceIndex >= MangaSources.names.size) "" else MangaSources.names[oldDefaultSourceIndex]
|
||||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||||
.putStringSet("pinned_manga_sources", pinnedSources).apply()
|
.putStringSet("pinned_manga_sources", pinnedSources).apply()
|
||||||
MangaSources.pinnedMangaSources = pinnedSources
|
MangaSources.pinnedMangaSources = pinnedSources
|
||||||
MangaSources.performReorderMangaSources()
|
MangaSources.performReorderMangaSources()
|
||||||
val newDefaultSourceIndex = if (oldName == "") 0 else MangaSources.names.indexOf(oldName)
|
val newDefaultSourceIndex =
|
||||||
|
if (oldName == "") 0 else MangaSources.names.indexOf(oldName)
|
||||||
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
|
||||||
.putInt("settings_def_manga_source_s_r", newDefaultSourceIndex).apply()
|
.putInt("settings_def_manga_source_s_r", newDefaultSourceIndex).apply()
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue