Minor cleanup

- Add pending intent immutable flags to satisfy lint warnings
- Change AddDuplicateMangaDialog arg to a function instead to avoid leaking controller-specific logic into it
- Require WebView 99+
This commit is contained in:
arkon
2022-05-10 17:39:45 -04:00
parent 9f655e0d41
commit d3f9232a3f
8 changed files with 36 additions and 26 deletions
@@ -47,6 +47,7 @@ class AppUpdateChecker {
when (result) {
is AppUpdateResult.NewUpdate -> AppUpdateNotifier(context).promptUpdate(result.release)
is AppUpdateResult.NewUpdateFdroidInstallation -> AppUpdateNotifier(context).promptFdroidUpdate()
else -> {}
}
result
@@ -56,7 +57,6 @@ class AppUpdateChecker {
private fun isNewVersion(versionTag: String): Boolean {
// Removes prefixes like "r" or "v"
val newVersion = versionTag.replace("[^\\d.]".toRegex(), "")
val oldVersion = BuildConfig.VERSION_NAME.replace("[^\\d.]".toRegex(), "")
return if (BuildConfig.PREVIEW) {
// Preview builds: based on releases in "tachiyomiorg/tachiyomi-preview" repo
@@ -65,6 +65,8 @@ class AppUpdateChecker {
} else {
// Release builds: based on releases in "tachiyomiorg/tachiyomi" repo
// tagged as something like "v0.1.2"
val oldVersion = BuildConfig.VERSION_NAME.replace("[^\\d.]".toRegex(), "")
val newSemVer = newVersion.split(".").map { it.toInt() }
val oldSemVer = oldVersion.split(".").map { it.toInt() }
@@ -73,6 +75,7 @@ class AppUpdateChecker {
return true
}
}
false
}
}
@@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.data.updater
import android.annotation.SuppressLint
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
@@ -26,12 +27,13 @@ internal class AppUpdateNotifier(private val context: Context) {
context.notificationManager.notify(id, build())
}
@SuppressLint("LaunchActivityFromNotification")
fun promptUpdate(release: GithubRelease) {
val intent = Intent(context, AppUpdateService::class.java).apply {
putExtra(AppUpdateService.EXTRA_DOWNLOAD_URL, release.getDownloadLink())
putExtra(AppUpdateService.EXTRA_DOWNLOAD_TITLE, release.version)
}
val updateIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
val updateIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
val releaseIntent = Intent(Intent.ACTION_VIEW, release.releaseLink.toUri()).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP