From 326b848e576f5be527fe2619a568f3edba5a84c9 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Mon, 8 Jan 2024 23:23:17 -0600 Subject: [PATCH] manga extensions fix --- app/build.gradle | 2 +- .../settings/InstalledAnimeExtensionsFragment.kt | 13 +++++++++---- .../settings/InstalledMangaExtensionsFragment.kt | 14 ++++++++++---- .../settings/InstalledNovelExtensionsFragment.kt | 13 +++++++++---- .../extension/manga/api/MangaExtensionGithubApi.kt | 6 +++--- .../extension/manga/util/MangaExtensionLoader.kt | 2 ++ app/src/main/res/layout/item_extension.xml | 1 + app/src/main/res/layout/item_extension_all.xml | 1 + 8 files changed, 36 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 59735059b8..5cc751b663 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,7 +29,7 @@ android { debug { applicationIdSuffix ".beta" manifestPlaceholders = [icon_placeholder: "@mipmap/ic_launcher_beta", icon_placeholder_round: "@mipmap/ic_launcher_beta_round"] - debuggable false + debuggable true } release { manifestPlaceholders = [icon_placeholder: "@mipmap/ic_launcher", icon_placeholder_round: "@mipmap/ic_launcher_round"] diff --git a/app/src/main/java/ani/dantotsu/settings/InstalledAnimeExtensionsFragment.kt b/app/src/main/java/ani/dantotsu/settings/InstalledAnimeExtensionsFragment.kt index d921b6879a..07a239cfd5 100644 --- a/app/src/main/java/ani/dantotsu/settings/InstalledAnimeExtensionsFragment.kt +++ b/app/src/main/java/ani/dantotsu/settings/InstalledAnimeExtensionsFragment.kt @@ -115,13 +115,13 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler { .show() } }, - { pkg -> + { pkg, forceDelete -> if (isAdded) { // Check if the fragment is currently added to its activity val context = requireContext() // Store context in a variable val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once - if (pkg.hasUpdate) { + if (pkg.hasUpdate && !forceDelete) { animeExtensionManager.updateExtension(pkg) .observeOn(AndroidSchedulers.mainThread()) // Observe on main thread .subscribe( @@ -202,7 +202,7 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler { private class AnimeExtensionsAdapter( private val onSettingsClicked: (AnimeExtension.Installed) -> Unit, - private val onUninstallClicked: (AnimeExtension.Installed) -> Unit, + private val onUninstallClicked: (AnimeExtension.Installed, Boolean) -> Unit, val skipIcons: Boolean ) : ListAdapter( DIFF_CALLBACK_INSTALLED @@ -234,11 +234,15 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler { holder.closeTextView.setImageResource(R.drawable.ic_round_delete_24) } holder.closeTextView.setOnClickListener { - onUninstallClicked(extension) + onUninstallClicked(extension, false) } holder.settingsImageView.setOnClickListener { onSettingsClicked(extension) } + holder.card.setOnLongClickListener { + onUninstallClicked(extension, true) + true + } } fun filter(query: String, currentList: List) { @@ -258,6 +262,7 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler { val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView) val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView) val closeTextView: ImageView = view.findViewById(R.id.closeTextView) + val card = view.findViewById(R.id.extensionCardView) } companion object { diff --git a/app/src/main/java/ani/dantotsu/settings/InstalledMangaExtensionsFragment.kt b/app/src/main/java/ani/dantotsu/settings/InstalledMangaExtensionsFragment.kt index 79db119787..e791b30470 100644 --- a/app/src/main/java/ani/dantotsu/settings/InstalledMangaExtensionsFragment.kt +++ b/app/src/main/java/ani/dantotsu/settings/InstalledMangaExtensionsFragment.kt @@ -111,13 +111,13 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler { .show() } }, - { pkg -> + { pkg: MangaExtension.Installed , forceDelete: Boolean -> if (isAdded) { // Check if the fragment is currently added to its activity val context = requireContext() // Store context in a variable val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once - if (pkg.hasUpdate) { + if (pkg.hasUpdate && !forceDelete) { mangaExtensionManager.updateExtension(pkg) .observeOn(AndroidSchedulers.mainThread()) // Observe on main thread .subscribe( @@ -198,7 +198,7 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler { private class MangaExtensionsAdapter( private val onSettingsClicked: (MangaExtension.Installed) -> Unit, - private val onUninstallClicked: (MangaExtension.Installed) -> Unit, + private val onUninstallClicked: (MangaExtension.Installed, Boolean) -> Unit, skipIcons: Boolean ) : ListAdapter( DIFF_CALLBACK_INSTALLED @@ -231,11 +231,16 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler { holder.closeTextView.setImageResource(R.drawable.ic_round_delete_24) } holder.closeTextView.setOnClickListener { - onUninstallClicked(extension) + onUninstallClicked(extension, false) } holder.settingsImageView.setOnClickListener { onSettingsClicked(extension) } + + holder.card.setOnLongClickListener { + onUninstallClicked(extension, true) + true + } } fun filter(query: String, currentList: List) { @@ -255,6 +260,7 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler { val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView) val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView) val closeTextView: ImageView = view.findViewById(R.id.closeTextView) + val card: View = view.findViewById(R.id.extensionCardView) } companion object { diff --git a/app/src/main/java/ani/dantotsu/settings/InstalledNovelExtensionsFragment.kt b/app/src/main/java/ani/dantotsu/settings/InstalledNovelExtensionsFragment.kt index c0a61dd5aa..51959b1d21 100644 --- a/app/src/main/java/ani/dantotsu/settings/InstalledNovelExtensionsFragment.kt +++ b/app/src/main/java/ani/dantotsu/settings/InstalledNovelExtensionsFragment.kt @@ -43,13 +43,13 @@ class InstalledNovelExtensionsFragment : Fragment(), SearchQueryHandler { Toast.makeText(requireContext(), "Source is not configurable", Toast.LENGTH_SHORT) .show() }, - { pkg -> + { pkg, forceDelete -> if (isAdded) { // Check if the fragment is currently added to its activity val context = requireContext() // Store context in a variable val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once - if (pkg.hasUpdate) { + if (pkg.hasUpdate && !forceDelete) { novelExtensionManager.updateExtension(pkg) .observeOn(AndroidSchedulers.mainThread()) // Observe on main thread .subscribe( @@ -130,7 +130,7 @@ class InstalledNovelExtensionsFragment : Fragment(), SearchQueryHandler { private class NovelExtensionsAdapter( private val onSettingsClicked: (NovelExtension.Installed) -> Unit, - private val onUninstallClicked: (NovelExtension.Installed) -> Unit, + private val onUninstallClicked: (NovelExtension.Installed, Boolean) -> Unit, skipIcons: Boolean ) : ListAdapter( DIFF_CALLBACK_INSTALLED @@ -165,11 +165,15 @@ class InstalledNovelExtensionsFragment : Fragment(), SearchQueryHandler { holder.closeTextView.setImageResource(R.drawable.ic_round_delete_24) } holder.closeTextView.setOnClickListener { - onUninstallClicked(extension) + onUninstallClicked(extension, false) } holder.settingsImageView.setOnClickListener { onSettingsClicked(extension) } + holder.card.setOnLongClickListener { + onUninstallClicked(extension, true) + true + } } fun filter(query: String, currentList: List) { @@ -189,6 +193,7 @@ class InstalledNovelExtensionsFragment : Fragment(), SearchQueryHandler { val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView) val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView) val closeTextView: ImageView = view.findViewById(R.id.closeTextView) + val card = view.findViewById(R.id.extensionCardView) } companion object { diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionGithubApi.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionGithubApi.kt index dd4540c210..440a86f15a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionGithubApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/api/MangaExtensionGithubApi.kt @@ -127,7 +127,7 @@ internal class MangaExtensionGithubApi { hasChangelog = it.hasChangelog == 1, sources = it.sources?.toExtensionSources().orEmpty(), apkName = it.apk, - iconUrl = "${getUrlPrefix()}icon/${it.apk.replace(".apk", ".png")}", + iconUrl = "${getUrlPrefix()}icon/${it.pkg}.png", ) } } @@ -160,8 +160,8 @@ internal class MangaExtensionGithubApi { } } -private const val REPO_URL_PREFIX = "https://raw.githubusercontent.com/tachiyomiorg/tachiyomi-extensions/repo/" -private const val FALLBACK_REPO_URL_PREFIX = "https://gcore.jsdelivr.net/gh/tachiyomiorg/tachiyomi-extensions@repo/" +private const val REPO_URL_PREFIX = "https://raw.githubusercontent.com/keiyoushi/extensions/main/" +private const val FALLBACK_REPO_URL_PREFIX = "https://gcore.jsdelivr.net/gh/keiyoushi/extensions@main/" @Serializable private data class ExtensionJsonObject( diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionLoader.kt index e5f1e5a0d5..b2eed54318 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/manga/util/MangaExtensionLoader.kt @@ -137,6 +137,7 @@ internal object MangaExtensionLoader { val signatureHash = getSignatureHash(pkgInfo) + /* temporarily disabling signature check TODO: remove? if (signatureHash == null) { logcat(LogPriority.WARN) { "Package $pkgName isn't signed" } return MangaLoadResult.Error @@ -145,6 +146,7 @@ internal object MangaExtensionLoader { logcat(LogPriority.WARN) { "Extension $pkgName isn't trusted" } return MangaLoadResult.Untrusted(extension) } + */ val isNsfw = appInfo.metaData.getInt(METADATA_NSFW) == 1 if (!loadNsfwSource && isNsfw) { diff --git a/app/src/main/res/layout/item_extension.xml b/app/src/main/res/layout/item_extension.xml index 5cbe47648b..dbf4dffbc8 100644 --- a/app/src/main/res/layout/item_extension.xml +++ b/app/src/main/res/layout/item_extension.xml @@ -1,5 +1,6 @@