Skip to content

Commit

Permalink
manga extensions fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelonion committed Jan 9, 2024
1 parent 01f9e86 commit 326b848
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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<AnimeExtension.Installed, AnimeExtensionsAdapter.ViewHolder>(
DIFF_CALLBACK_INSTALLED
Expand Down Expand Up @@ -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<AnimeExtension.Installed>) {
Expand All @@ -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<View>(R.id.extensionCardView)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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<MangaExtension.Installed, MangaExtensionsAdapter.ViewHolder>(
DIFF_CALLBACK_INSTALLED
Expand Down Expand Up @@ -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<MangaExtension.Installed>) {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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<NovelExtension.Installed, NovelExtensionsAdapter.ViewHolder>(
DIFF_CALLBACK_INSTALLED
Expand Down Expand Up @@ -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<NovelExtension.Installed>) {
Expand All @@ -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<View>(R.id.extensionCardView)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
}
}
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_extension.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/extensionCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_extension_all.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/extensionCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
Expand Down

0 comments on commit 326b848

Please sign in to comment.