diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt
index ccd9be10c..9b1b317c9 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt
@@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.network.await
import eu.kanade.tachiyomi.network.parseAs
import eu.kanade.tachiyomi.util.lang.withIOContext
+import eu.kanade.tachiyomi.util.system.getInstallerPackageName
import uy.kohesive.injekt.injectLazy
import java.util.Date
import java.util.concurrent.TimeUnit
@@ -33,14 +34,19 @@ class AppUpdateChecker {
// Check if latest version is different from current version
if (isNewVersion(it.version)) {
- AppUpdateResult.NewUpdate(it)
+ if (context.getInstallerPackageName() == "org.fdroid.fdroid") {
+ AppUpdateResult.NewUpdateFdroidInstallation
+ } else {
+ AppUpdateResult.NewUpdate(it)
+ }
} else {
AppUpdateResult.NoNewUpdate
}
}
- if (result is AppUpdateResult.NewUpdate) {
- AppUpdateNotifier(context).promptUpdate(result.release)
+ when (result) {
+ is AppUpdateResult.NewUpdate -> AppUpdateNotifier(context).promptUpdate(result.release)
+ is AppUpdateResult.NewUpdateFdroidInstallation -> AppUpdateNotifier(context).promptFdroidUpdate()
}
result
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt
index f6bcce4b7..a1bb160f7 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateNotifier.kt
@@ -58,6 +58,22 @@ internal class AppUpdateNotifier(private val context: Context) {
notificationBuilder.show()
}
+ /**
+ * Some people are still installing the app from F-Droid, so we avoid prompting GitHub-based
+ * updates.
+ *
+ * We can prompt them to migrate to the GitHub version though.
+ */
+ fun promptFdroidUpdate() {
+ with(notificationBuilder) {
+ setContentTitle(context.getString(R.string.update_check_notification_update_available))
+ setContentText(context.getString(R.string.update_check_fdroid_migration_info))
+ setSmallIcon(R.drawable.ic_tachi)
+ setContentIntent(NotificationHandler.openUrl(context, "https://tachiyomi.org/help/guides/troubleshooting/#unable-to-install-the-app-or-extensions"))
+ }
+ notificationBuilder.show()
+ }
+
/**
* Call when apk download starts.
*
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateResult.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateResult.kt
index 7a40a3d3d..695d13492 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateResult.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateResult.kt
@@ -2,5 +2,6 @@ package eu.kanade.tachiyomi.data.updater
sealed class AppUpdateResult {
class NewUpdate(val release: GithubRelease) : AppUpdateResult()
+ object NewUpdateFdroidInstallation : AppUpdateResult()
object NoNewUpdate : AppUpdateResult()
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt
index 2894f7ab2..134d8470d 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt
@@ -382,6 +382,19 @@ fun Context.isPackageInstalled(packageName: String): Boolean {
}
}
+fun Context.getInstallerPackageName(): String? {
+ return try {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ packageManager.getInstallSourceInfo(packageName).installingPackageName
+ } else {
+ @Suppress("DEPRECATION")
+ packageManager.getInstallerPackageName(packageName)
+ }
+ } catch (e: Exception) {
+ null
+ }
+}
+
fun Context.getApplicationIcon(pkgName: String): Drawable? {
return try {
packageManager.getApplicationIcon(pkgName)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7a499d201..ecf15854e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -765,6 +765,7 @@
Download complete
Download error
New version available!
+ A new version is available from the official releases. Tap to learn how to migrate from unofficial F-Droid releases.