manga extensions fix

This commit is contained in:
Finnley Somdahl 2024-01-08 23:23:17 -06:00
parent 01f9e86475
commit 326b848e57
8 changed files with 36 additions and 16 deletions

View file

@ -29,7 +29,7 @@ android {
debug { debug {
applicationIdSuffix ".beta" applicationIdSuffix ".beta"
manifestPlaceholders = [icon_placeholder: "@mipmap/ic_launcher_beta", icon_placeholder_round: "@mipmap/ic_launcher_beta_round"] manifestPlaceholders = [icon_placeholder: "@mipmap/ic_launcher_beta", icon_placeholder_round: "@mipmap/ic_launcher_beta_round"]
debuggable false debuggable true
} }
release { release {
manifestPlaceholders = [icon_placeholder: "@mipmap/ic_launcher", icon_placeholder_round: "@mipmap/ic_launcher_round"] manifestPlaceholders = [icon_placeholder: "@mipmap/ic_launcher", icon_placeholder_round: "@mipmap/ic_launcher_round"]

View file

@ -115,13 +115,13 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler {
.show() .show()
} }
}, },
{ pkg -> { pkg, forceDelete ->
if (isAdded) { // Check if the fragment is currently added to its activity if (isAdded) { // Check if the fragment is currently added to its activity
val context = requireContext() // Store context in a variable val context = requireContext() // Store context in a variable
val notificationManager = val notificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once
if (pkg.hasUpdate) { if (pkg.hasUpdate && !forceDelete) {
animeExtensionManager.updateExtension(pkg) animeExtensionManager.updateExtension(pkg)
.observeOn(AndroidSchedulers.mainThread()) // Observe on main thread .observeOn(AndroidSchedulers.mainThread()) // Observe on main thread
.subscribe( .subscribe(
@ -202,7 +202,7 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler {
private class AnimeExtensionsAdapter( private class AnimeExtensionsAdapter(
private val onSettingsClicked: (AnimeExtension.Installed) -> Unit, private val onSettingsClicked: (AnimeExtension.Installed) -> Unit,
private val onUninstallClicked: (AnimeExtension.Installed) -> Unit, private val onUninstallClicked: (AnimeExtension.Installed, Boolean) -> Unit,
val skipIcons: Boolean val skipIcons: Boolean
) : ListAdapter<AnimeExtension.Installed, AnimeExtensionsAdapter.ViewHolder>( ) : ListAdapter<AnimeExtension.Installed, AnimeExtensionsAdapter.ViewHolder>(
DIFF_CALLBACK_INSTALLED DIFF_CALLBACK_INSTALLED
@ -234,11 +234,15 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler {
holder.closeTextView.setImageResource(R.drawable.ic_round_delete_24) holder.closeTextView.setImageResource(R.drawable.ic_round_delete_24)
} }
holder.closeTextView.setOnClickListener { holder.closeTextView.setOnClickListener {
onUninstallClicked(extension) onUninstallClicked(extension, false)
} }
holder.settingsImageView.setOnClickListener { holder.settingsImageView.setOnClickListener {
onSettingsClicked(extension) onSettingsClicked(extension)
} }
holder.card.setOnLongClickListener {
onUninstallClicked(extension, true)
true
}
} }
fun filter(query: String, currentList: List<AnimeExtension.Installed>) { fun filter(query: String, currentList: List<AnimeExtension.Installed>) {
@ -258,6 +262,7 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler {
val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView) val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView)
val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView) val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView)
val closeTextView: ImageView = view.findViewById(R.id.closeTextView) val closeTextView: ImageView = view.findViewById(R.id.closeTextView)
val card = view.findViewById<View>(R.id.extensionCardView)
} }
companion object { companion object {

View file

@ -111,13 +111,13 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler {
.show() .show()
} }
}, },
{ pkg -> { pkg: MangaExtension.Installed , forceDelete: Boolean ->
if (isAdded) { // Check if the fragment is currently added to its activity if (isAdded) { // Check if the fragment is currently added to its activity
val context = requireContext() // Store context in a variable val context = requireContext() // Store context in a variable
val notificationManager = val notificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once
if (pkg.hasUpdate) { if (pkg.hasUpdate && !forceDelete) {
mangaExtensionManager.updateExtension(pkg) mangaExtensionManager.updateExtension(pkg)
.observeOn(AndroidSchedulers.mainThread()) // Observe on main thread .observeOn(AndroidSchedulers.mainThread()) // Observe on main thread
.subscribe( .subscribe(
@ -198,7 +198,7 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler {
private class MangaExtensionsAdapter( private class MangaExtensionsAdapter(
private val onSettingsClicked: (MangaExtension.Installed) -> Unit, private val onSettingsClicked: (MangaExtension.Installed) -> Unit,
private val onUninstallClicked: (MangaExtension.Installed) -> Unit, private val onUninstallClicked: (MangaExtension.Installed, Boolean) -> Unit,
skipIcons: Boolean skipIcons: Boolean
) : ListAdapter<MangaExtension.Installed, MangaExtensionsAdapter.ViewHolder>( ) : ListAdapter<MangaExtension.Installed, MangaExtensionsAdapter.ViewHolder>(
DIFF_CALLBACK_INSTALLED DIFF_CALLBACK_INSTALLED
@ -231,11 +231,16 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler {
holder.closeTextView.setImageResource(R.drawable.ic_round_delete_24) holder.closeTextView.setImageResource(R.drawable.ic_round_delete_24)
} }
holder.closeTextView.setOnClickListener { holder.closeTextView.setOnClickListener {
onUninstallClicked(extension) onUninstallClicked(extension, false)
} }
holder.settingsImageView.setOnClickListener { holder.settingsImageView.setOnClickListener {
onSettingsClicked(extension) onSettingsClicked(extension)
} }
holder.card.setOnLongClickListener {
onUninstallClicked(extension, true)
true
}
} }
fun filter(query: String, currentList: List<MangaExtension.Installed>) { fun filter(query: String, currentList: List<MangaExtension.Installed>) {
@ -255,6 +260,7 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler {
val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView) val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView)
val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView) val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView)
val closeTextView: ImageView = view.findViewById(R.id.closeTextView) val closeTextView: ImageView = view.findViewById(R.id.closeTextView)
val card: View = view.findViewById(R.id.extensionCardView)
} }
companion object { companion object {

View file

@ -43,13 +43,13 @@ class InstalledNovelExtensionsFragment : Fragment(), SearchQueryHandler {
Toast.makeText(requireContext(), "Source is not configurable", Toast.LENGTH_SHORT) Toast.makeText(requireContext(), "Source is not configurable", Toast.LENGTH_SHORT)
.show() .show()
}, },
{ pkg -> { pkg, forceDelete ->
if (isAdded) { // Check if the fragment is currently added to its activity if (isAdded) { // Check if the fragment is currently added to its activity
val context = requireContext() // Store context in a variable val context = requireContext() // Store context in a variable
val notificationManager = val notificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Initialize NotificationManager once
if (pkg.hasUpdate) { if (pkg.hasUpdate && !forceDelete) {
novelExtensionManager.updateExtension(pkg) novelExtensionManager.updateExtension(pkg)
.observeOn(AndroidSchedulers.mainThread()) // Observe on main thread .observeOn(AndroidSchedulers.mainThread()) // Observe on main thread
.subscribe( .subscribe(
@ -130,7 +130,7 @@ class InstalledNovelExtensionsFragment : Fragment(), SearchQueryHandler {
private class NovelExtensionsAdapter( private class NovelExtensionsAdapter(
private val onSettingsClicked: (NovelExtension.Installed) -> Unit, private val onSettingsClicked: (NovelExtension.Installed) -> Unit,
private val onUninstallClicked: (NovelExtension.Installed) -> Unit, private val onUninstallClicked: (NovelExtension.Installed, Boolean) -> Unit,
skipIcons: Boolean skipIcons: Boolean
) : ListAdapter<NovelExtension.Installed, NovelExtensionsAdapter.ViewHolder>( ) : ListAdapter<NovelExtension.Installed, NovelExtensionsAdapter.ViewHolder>(
DIFF_CALLBACK_INSTALLED DIFF_CALLBACK_INSTALLED
@ -165,11 +165,15 @@ class InstalledNovelExtensionsFragment : Fragment(), SearchQueryHandler {
holder.closeTextView.setImageResource(R.drawable.ic_round_delete_24) holder.closeTextView.setImageResource(R.drawable.ic_round_delete_24)
} }
holder.closeTextView.setOnClickListener { holder.closeTextView.setOnClickListener {
onUninstallClicked(extension) onUninstallClicked(extension, false)
} }
holder.settingsImageView.setOnClickListener { holder.settingsImageView.setOnClickListener {
onSettingsClicked(extension) onSettingsClicked(extension)
} }
holder.card.setOnLongClickListener {
onUninstallClicked(extension, true)
true
}
} }
fun filter(query: String, currentList: List<NovelExtension.Installed>) { fun filter(query: String, currentList: List<NovelExtension.Installed>) {
@ -189,6 +193,7 @@ class InstalledNovelExtensionsFragment : Fragment(), SearchQueryHandler {
val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView) val settingsImageView: ImageView = view.findViewById(R.id.settingsImageView)
val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView) val extensionIconImageView: ImageView = view.findViewById(R.id.extensionIconImageView)
val closeTextView: ImageView = view.findViewById(R.id.closeTextView) val closeTextView: ImageView = view.findViewById(R.id.closeTextView)
val card = view.findViewById<View>(R.id.extensionCardView)
} }
companion object { companion object {

View file

@ -127,7 +127,7 @@ internal class MangaExtensionGithubApi {
hasChangelog = it.hasChangelog == 1, hasChangelog = it.hasChangelog == 1,
sources = it.sources?.toExtensionSources().orEmpty(), sources = it.sources?.toExtensionSources().orEmpty(),
apkName = it.apk, 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 REPO_URL_PREFIX = "https://raw.githubusercontent.com/keiyoushi/extensions/main/"
private const val FALLBACK_REPO_URL_PREFIX = "https://gcore.jsdelivr.net/gh/tachiyomiorg/tachiyomi-extensions@repo/" private const val FALLBACK_REPO_URL_PREFIX = "https://gcore.jsdelivr.net/gh/keiyoushi/extensions@main/"
@Serializable @Serializable
private data class ExtensionJsonObject( private data class ExtensionJsonObject(

View file

@ -137,6 +137,7 @@ internal object MangaExtensionLoader {
val signatureHash = getSignatureHash(pkgInfo) val signatureHash = getSignatureHash(pkgInfo)
/* temporarily disabling signature check TODO: remove?
if (signatureHash == null) { if (signatureHash == null) {
logcat(LogPriority.WARN) { "Package $pkgName isn't signed" } logcat(LogPriority.WARN) { "Package $pkgName isn't signed" }
return MangaLoadResult.Error return MangaLoadResult.Error
@ -145,6 +146,7 @@ internal object MangaExtensionLoader {
logcat(LogPriority.WARN) { "Extension $pkgName isn't trusted" } logcat(LogPriority.WARN) { "Extension $pkgName isn't trusted" }
return MangaLoadResult.Untrusted(extension) return MangaLoadResult.Untrusted(extension)
} }
*/
val isNsfw = appInfo.metaData.getInt(METADATA_NSFW) == 1 val isNsfw = appInfo.metaData.getInt(METADATA_NSFW) == 1
if (!loadNsfwSource && isNsfw) { if (!loadNsfwSource && isNsfw) {

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/extensionCardView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/extensionCardView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"