From 73be639397bb56331bb71b406f74ffe1ff2f12db Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:00:00 +0000 Subject: [PATCH] cleanup --- .../main/java/ani/dantotsu/MainActivity.kt | 4 --- .../ani/dantotsu/download/DownloadsManager.kt | 9 +++++- .../download/manga/OfflineMangaFragment.kt | 6 ---- .../ani/dantotsu/home/AnimePageAdapter.kt | 5 ++-- .../java/ani/dantotsu/media/SearchAdapter.kt | 3 +- .../ani/dantotsu/media/anime/ExoplayerView.kt | 5 ++-- .../manga/mangareader/MangaReaderActivity.kt | 5 +++- .../main/java/ani/dantotsu/others/Kitsu.kt | 1 + .../dantotsu/parsers/OfflineAnimeParser.kt | 2 +- .../ani/dantotsu/settings/SettingsActivity.kt | 28 ++++++++++++------- 10 files changed, 40 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/MainActivity.kt b/app/src/main/java/ani/dantotsu/MainActivity.kt index c375add684..303861cf01 100644 --- a/app/src/main/java/ani/dantotsu/MainActivity.kt +++ b/app/src/main/java/ani/dantotsu/MainActivity.kt @@ -47,13 +47,10 @@ import ani.dantotsu.media.MediaDetailsActivity import ani.dantotsu.others.CustomBottomDialog import ani.dantotsu.others.LangSet import ani.dantotsu.others.SharedPreferenceBooleanLiveData -import ani.dantotsu.parsers.novel.NovelExtensionManager import ani.dantotsu.settings.UserInterfaceSettings import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription import ani.dantotsu.themes.ThemeManager 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.SoftBreakAddsNewLinePlugin import kotlinx.coroutines.Dispatchers @@ -65,7 +62,6 @@ import nl.joery.animatedbottombar.AnimatedBottomBar import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.io.Serializable -import kotlin.random.Random class MainActivity : AppCompatActivity() { diff --git a/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt b/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt index ef7765628c..c5a965464e 100644 --- a/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt +++ b/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt @@ -75,9 +75,11 @@ class DownloadsManager(private val context: Context) { DownloadedType.Type.MANGA -> { downloadsList.removeAll { it.title == title && it.type == DownloadedType.Type.MANGA } } + DownloadedType.Type.ANIME -> { downloadsList.removeAll { it.title == title && it.type == DownloadedType.Type.ANIME } } + 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 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) { if (chapter != null) { File( diff --git a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt index 0134d3d1c6..985869328c 100644 --- a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt +++ b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt @@ -1,10 +1,8 @@ package ani.dantotsu.download.manga -import android.animation.ObjectAnimator import android.content.Context import android.content.Intent import android.net.Uri -import android.os.Build import android.os.Bundle import android.os.Environment import android.text.Editable @@ -15,7 +13,6 @@ import android.view.View import android.view.ViewGroup import android.view.animation.AlphaAnimation import android.view.animation.LayoutAnimationController -import android.view.animation.OvershootInterpolator import android.widget.AbsListView import android.widget.AutoCompleteTextView import android.widget.GridView @@ -45,7 +42,6 @@ import ani.dantotsu.setSafeOnClickListener import ani.dantotsu.settings.SettingsDialogFragment import ani.dantotsu.settings.UserInterfaceSettings import ani.dantotsu.snackString -import ani.dantotsu.statusBarHeight import com.google.android.material.card.MaterialCardView import com.google.android.material.imageview.ShapeableImageView 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.api.get import java.io.File -import kotlin.math.max -import kotlin.math.min class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener { diff --git a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt index 69f02ab041..5ee0527676 100644 --- a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt @@ -133,8 +133,9 @@ class AnimePageAdapter : RecyclerView.Adapter onIncludeListClick.invoke(isChecked) diff --git a/app/src/main/java/ani/dantotsu/media/SearchAdapter.kt b/app/src/main/java/ani/dantotsu/media/SearchAdapter.kt index 18fe0a4c2c..43c8f34438 100644 --- a/app/src/main/java/ani/dantotsu/media/SearchAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/SearchAdapter.kt @@ -61,7 +61,8 @@ class SearchAdapter(private val activity: SearchActivity) : binding.searchBar.hint = activity.result.type if (currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE) - ?.getBoolean("incognito", false ) == true){ + ?.getBoolean("incognito", false) == true + ) { val startIconDrawableRes = R.drawable.ic_incognito_24 val startIconDrawable: Drawable? = context?.let { AppCompatResources.getDrawable(it, startIconDrawableRes) } diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index a907eee891..8bdd4242ea 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -1323,7 +1323,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL } 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 { setCache(Helper.getSimpleCache(this@ExoplayerView)) if (ext.server.offline) { @@ -1745,7 +1746,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL private fun updateAniProgress() { 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 (loadData("${media.id}_save_progress") != false && if (media.isAdult) settings.updateForH else true) { media.anime!!.selectedEpisode?.apply { diff --git a/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt b/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt index 23f8260e5d..8ec077c3bb 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt @@ -219,7 +219,10 @@ class MangaReaderActivity : AppCompatActivity() { val mangaSources = MangaSources val scope = lifecycleScope scope.launch(Dispatchers.IO) { - mangaSources.init(Injekt.get().installedExtensionsFlow, this@MangaReaderActivity) + mangaSources.init( + Injekt.get().installedExtensionsFlow, + this@MangaReaderActivity + ) } model.mangaReadSources = mangaSources } else { diff --git a/app/src/main/java/ani/dantotsu/others/Kitsu.kt b/app/src/main/java/ani/dantotsu/others/Kitsu.kt index bee4beeea7..374f0dd0eb 100644 --- a/app/src/main/java/ani/dantotsu/others/Kitsu.kt +++ b/app/src/main/java/ani/dantotsu/others/Kitsu.kt @@ -96,6 +96,7 @@ query { } } } + else -> { res?.body?.string() } diff --git a/app/src/main/java/ani/dantotsu/parsers/OfflineAnimeParser.kt b/app/src/main/java/ani/dantotsu/parsers/OfflineAnimeParser.kt index f66de95e85..1c9c3b6c7a 100644 --- a/app/src/main/java/ani/dantotsu/parsers/OfflineAnimeParser.kt +++ b/app/src/main/java/ani/dantotsu/parsers/OfflineAnimeParser.kt @@ -118,7 +118,7 @@ class OfflineVideoExtractor(val videoServer: VideoServer) : VideoExtractor() { val sublist = getSubtitle( videoServer.extraData?.get("title") ?: "", videoServer.extraData?.get("episode") ?: "" - )?: emptyList() + ) ?: emptyList() //we need to return a "fake" video so that the app doesn't crash val video = Video( null, diff --git a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt index d602b857cd..2a9a25d9bf 100644 --- a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt @@ -215,10 +215,12 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene } 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 pinnedSourcesBoolean = animeSourcesWithoutDownloadsSource.map { it.name in AnimeSources.pinnedAnimeSources } - val pinnedSourcesOriginal = getSharedPreferences( + val pinnedSourcesBoolean = + animeSourcesWithoutDownloadsSource.map { it.name in AnimeSources.pinnedAnimeSources } + val pinnedSourcesOriginal = getSharedPreferences( "Dantotsu", Context.MODE_PRIVATE ).getStringSet("pinned_anime_sources", null) @@ -240,12 +242,14 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene "Dantotsu", Context.MODE_PRIVATE ).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() .putStringSet("pinned_anime_sources", pinnedSources).apply() AnimeSources.pinnedAnimeSources = pinnedSources 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() .putInt("settings_def_anime_source_s_r", newDefaultSourceIndex).apply() dialog.dismiss() @@ -468,10 +472,12 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene } 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 pinnedSourcesBoolean = mangaSourcesWithoutDownloadsSource.map { it.name in MangaSources.pinnedMangaSources } - val pinnedSourcesOriginal = getSharedPreferences( + val pinnedSourcesBoolean = + mangaSourcesWithoutDownloadsSource.map { it.name in MangaSources.pinnedMangaSources } + val pinnedSourcesOriginal = getSharedPreferences( "Dantotsu", Context.MODE_PRIVATE ).getStringSet("pinned_manga_sources", null) @@ -493,12 +499,14 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene "Dantotsu", Context.MODE_PRIVATE ).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() .putStringSet("pinned_manga_sources", pinnedSources).apply() MangaSources.pinnedMangaSources = pinnedSources 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() .putInt("settings_def_manga_source_s_r", newDefaultSourceIndex).apply() dialog.dismiss()