Remove F-droid warnings

(cherry picked from commit 181dbbb638686a284fa24c4e43d7c022a4f8e4bb)
This commit is contained in:
AntsyLich 2025-02-26 02:13:14 +06:00 committed by Cuong-Tran
parent 73719f2f1b
commit 35310c70fe
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
8 changed files with 1 additions and 116 deletions

View file

@ -1,12 +1,5 @@
package eu.kanade.presentation.more package eu.kanade.presentation.more
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.HelpOutline import androidx.compose.material.icons.automirrored.outlined.HelpOutline
import androidx.compose.material.icons.automirrored.outlined.Label import androidx.compose.material.icons.automirrored.outlined.Label
@ -22,11 +15,9 @@ import androidx.compose.material.icons.outlined.Storage
import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.HorizontalDivider
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.vectorResource import androidx.compose.ui.res.vectorResource
import eu.kanade.presentation.components.WarningBanner
import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
@ -51,7 +42,6 @@ fun MoreScreen(
onDownloadedOnlyChange: (Boolean) -> Unit, onDownloadedOnlyChange: (Boolean) -> Unit,
incognitoMode: Boolean, incognitoMode: Boolean,
onIncognitoModeChange: (Boolean) -> Unit, onIncognitoModeChange: (Boolean) -> Unit,
isFDroid: Boolean,
// SY --> // SY -->
showNavUpdates: Boolean, showNavUpdates: Boolean,
showNavHistory: Boolean, showNavHistory: Boolean,
@ -75,26 +65,7 @@ fun MoreScreen(
val delegateSourcePreferences = remember { Injekt.get<DelegateSourcePreferences>() } val delegateSourcePreferences = remember { Injekt.get<DelegateSourcePreferences>() }
// SY <-- // SY <--
Scaffold( Scaffold { contentPadding ->
topBar = {
Column(
modifier = Modifier.windowInsetsPadding(
WindowInsets.systemBars.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
),
) {
if (isFDroid) {
WarningBanner(
textRes = MR.strings.fdroid_warning,
modifier = Modifier.clickable {
uriHandler.openUri(
"https://komikku-app.github.io/docs/faq/general#how-do-i-update-from-the-f-droid-builds",
)
},
)
}
}
},
) { contentPadding ->
ScrollbarLazyColumn( ScrollbarLazyColumn(
// KMK: use contentPadding as preferable padding for ScrollbarLazyColumn when not using stickyHeader // KMK: use contentPadding as preferable padding for ScrollbarLazyColumn when not using stickyHeader
contentPadding = contentPadding, contentPadding = contentPadding,

View file

@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.data.updater
import android.content.Context import android.content.Context
import android.os.Build import android.os.Build
import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.util.system.isInstalledFromFDroid
import tachiyomi.core.common.util.lang.withIOContext import tachiyomi.core.common.util.lang.withIOContext
import tachiyomi.domain.UnsortedPreferences import tachiyomi.domain.UnsortedPreferences
import tachiyomi.domain.release.interactor.GetApplicationRelease import tachiyomi.domain.release.interactor.GetApplicationRelease
@ -35,7 +34,6 @@ class AppUpdateChecker(
val result = getApplicationRelease.await( val result = getApplicationRelease.await(
GetApplicationRelease.Arguments( GetApplicationRelease.Arguments(
isPreview = BuildConfig.PREVIEW || peekIntoPreview, isPreview = BuildConfig.PREVIEW || peekIntoPreview,
isThirdParty = context.isInstalledFromFDroid(),
commitCount = BuildConfig.COMMIT_COUNT.toInt(), commitCount = BuildConfig.COMMIT_COUNT.toInt(),
versionName = BuildConfig.VERSION_NAME, versionName = BuildConfig.VERSION_NAME,
repository = getGithubRepo(peekIntoPreview), repository = getGithubRepo(peekIntoPreview),
@ -54,10 +52,6 @@ class AppUpdateChecker(
AppUpdateNotifier(context).promptUpdate(result.release) AppUpdateNotifier(context).promptUpdate(result.release)
} }
is GetApplicationRelease.Result.ThirdPartyInstallation -> AppUpdateNotifier(
context,
).promptFdroidUpdate()
else -> {} else -> {}
} }
@ -85,7 +79,6 @@ class AppUpdateChecker(
getApplicationRelease.awaitReleaseNotes( getApplicationRelease.awaitReleaseNotes(
GetApplicationRelease.Arguments( GetApplicationRelease.Arguments(
isPreview = BuildConfig.PREVIEW || peekIntoPreview, isPreview = BuildConfig.PREVIEW || peekIntoPreview,
isThirdParty = context.isInstalledFromFDroid(),
commitCount = BuildConfig.COMMIT_COUNT.toInt(), commitCount = BuildConfig.COMMIT_COUNT.toInt(),
versionName = BuildConfig.VERSION_NAME, versionName = BuildConfig.VERSION_NAME,
repository = getGithubRepo(peekIntoPreview), repository = getGithubRepo(peekIntoPreview),

View file

@ -152,27 +152,6 @@ internal class AppUpdateNotifier(private val context: Context) {
notificationBuilder.show(Notifications.ID_APP_UPDATE_PROMPT) notificationBuilder.show(Notifications.ID_APP_UPDATE_PROMPT)
} }
/**
* 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.stringResource(MR.strings.update_check_notification_update_available))
setContentText(context.stringResource(MR.strings.update_check_fdroid_migration_info))
setSmallIcon(R.drawable.ic_komikku)
setContentIntent(
NotificationHandler.openUrl(
context,
"https://komikku-app.github.io/docs/faq/general#how-do-i-update-from-the-f-droid-builds",
),
)
}
notificationBuilder.show(Notifications.ID_APP_UPDATE_PROMPT)
}
/** /**
* Call when apk download throws a error * Call when apk download throws a error
* *

View file

@ -30,7 +30,6 @@ import eu.kanade.tachiyomi.ui.libraryUpdateError.LibraryUpdateErrorScreen
import eu.kanade.tachiyomi.ui.setting.SettingsScreen import eu.kanade.tachiyomi.ui.setting.SettingsScreen
import eu.kanade.tachiyomi.ui.stats.StatsScreen import eu.kanade.tachiyomi.ui.stats.StatsScreen
import eu.kanade.tachiyomi.ui.updates.UpdatesTab import eu.kanade.tachiyomi.ui.updates.UpdatesTab
import eu.kanade.tachiyomi.util.system.isInstalledFromFDroid
import exh.ui.batchadd.BatchAddScreen import exh.ui.batchadd.BatchAddScreen
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
@ -74,7 +73,6 @@ data object MoreTab : Tab {
onDownloadedOnlyChange = { screenModel.downloadedOnly = it }, onDownloadedOnlyChange = { screenModel.downloadedOnly = it },
incognitoMode = screenModel.incognitoMode, incognitoMode = screenModel.incognitoMode,
onIncognitoModeChange = { screenModel.incognitoMode = it }, onIncognitoModeChange = { screenModel.incognitoMode = it },
isFDroid = context.isInstalledFromFDroid(),
// SY --> // SY -->
showNavUpdates = screenModel.showNavUpdates, showNavUpdates = screenModel.showNavUpdates,
showNavHistory = screenModel.showNavHistory, showNavHistory = screenModel.showNavHistory,

View file

@ -16,7 +16,6 @@ import androidx.core.net.toUri
import com.hippo.unifile.UniFile import com.hippo.unifile.UniFile
import eu.kanade.domain.ui.UiPreferences import eu.kanade.domain.ui.UiPreferences
import eu.kanade.domain.ui.model.ThemeMode import eu.kanade.domain.ui.model.ThemeMode
import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.delegate.ThemingDelegate import eu.kanade.tachiyomi.ui.base.delegate.ThemingDelegate
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
@ -157,23 +156,6 @@ val Context.hasMiuiPackageInstaller get() = isPackageInstalled("com.miui.package
val Context.isShizukuInstalled get() = isPackageInstalled("moe.shizuku.privileged.api") || Sui.isSui() val Context.isShizukuInstalled get() = isPackageInstalled("moe.shizuku.privileged.api") || Sui.isSui()
fun Context.isInstalledFromFDroid(): Boolean {
val installerPackageName = try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
packageManager.getInstallSourceInfo(packageName).installingPackageName
} else {
@Suppress("DEPRECATION")
packageManager.getInstallerPackageName(packageName)
}
} catch (e: Exception) {
null
}
return installerPackageName == "org.fdroid.fdroid" ||
// F-Droid builds typically disable the updater
(!BuildConfig.INCLUDE_UPDATER && !isDebugBuildType)
}
fun Context.launchRequestPackageInstallsPermission() { fun Context.launchRequestPackageInstallsPermission() {
Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES).apply { Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES).apply {
data = "package:$packageName".toUri() data = "package:$packageName".toUri()

View file

@ -50,7 +50,6 @@ class GetApplicationRelease(
versionTag = latest.version, versionTag = latest.version,
) )
return when { return when {
isNewVersion && arguments.isThirdParty -> Result.ThirdPartyInstallation
isNewVersion -> Result.NewUpdate(latest) isNewVersion -> Result.NewUpdate(latest)
else -> Result.NoNewUpdate else -> Result.NoNewUpdate
} }
@ -117,8 +116,6 @@ class GetApplicationRelease(
data class Arguments( data class Arguments(
/** If current version is Preview (beta) build */ /** If current version is Preview (beta) build */
val isPreview: Boolean, val isPreview: Boolean,
/** If current version is from third party */
val isThirdParty: Boolean,
/** Commit count of current version */ /** Commit count of current version */
val commitCount: Int, val commitCount: Int,
/** Current version name, could be version tag (v0.1.2) or commit count (r1234) */ /** Current version name, could be version tag (v0.1.2) or commit count (r1234) */
@ -133,7 +130,6 @@ class GetApplicationRelease(
data class NewUpdate(val release: Release) : Result data class NewUpdate(val release: Release) : Result
data object NoNewUpdate : Result data object NoNewUpdate : Result
data object OsTooOld : Result data object OsTooOld : Result
data object ThirdPartyInstallation : Result
} }
} }

View file

@ -30,35 +30,6 @@ class GetApplicationReleaseTest {
getApplicationRelease = GetApplicationRelease(releaseService, preferenceStore) getApplicationRelease = GetApplicationRelease(releaseService, preferenceStore)
} }
@Test
fun `When has update but is third party expect third party installation`() = runTest {
every { preference.get() } returns 0
every { preference.set(any()) }.answers { }
val releases = listOf(
Release(
"v2.0.0",
"info",
"http://example.com/release_link",
listOf("http://example.com/assets"),
),
)
coEvery { releaseService.releaseNotes(any()) } returns releases
val result = getApplicationRelease.await(
GetApplicationRelease.Arguments(
isPreview = false,
isThirdParty = true,
commitCount = 0,
versionName = "v1.0.0",
repository = "test",
),
)
result shouldBe GetApplicationRelease.Result.ThirdPartyInstallation
}
@Test @Test
fun `When has update but is preview expect new update`() = runTest { fun `When has update but is preview expect new update`() = runTest {
every { preference.get() } returns 0 every { preference.get() } returns 0
@ -78,7 +49,6 @@ class GetApplicationReleaseTest {
val result = getApplicationRelease.await( val result = getApplicationRelease.await(
GetApplicationRelease.Arguments( GetApplicationRelease.Arguments(
isPreview = true, isPreview = true,
isThirdParty = false,
commitCount = 1000, commitCount = 1000,
versionName = "", versionName = "",
repository = "test", repository = "test",
@ -109,7 +79,6 @@ class GetApplicationReleaseTest {
val result = getApplicationRelease.await( val result = getApplicationRelease.await(
GetApplicationRelease.Arguments( GetApplicationRelease.Arguments(
isPreview = false, isPreview = false,
isThirdParty = false,
commitCount = 0, commitCount = 0,
versionName = "v1.0.0", versionName = "v1.0.0",
repository = "test", repository = "test",
@ -139,7 +108,6 @@ class GetApplicationReleaseTest {
val result = getApplicationRelease.await( val result = getApplicationRelease.await(
GetApplicationRelease.Arguments( GetApplicationRelease.Arguments(
isPreview = false, isPreview = false,
isThirdParty = false,
commitCount = 0, commitCount = 0,
versionName = "v2.0.0", versionName = "v2.0.0",
repository = "test", repository = "test",
@ -168,7 +136,6 @@ class GetApplicationReleaseTest {
val result = getApplicationRelease.await( val result = getApplicationRelease.await(
GetApplicationRelease.Arguments( GetApplicationRelease.Arguments(
isPreview = false, isPreview = false,
isThirdParty = false,
commitCount = 0, commitCount = 0,
versionName = "v1.0.0", versionName = "v1.0.0",
repository = "test", repository = "test",

View file

@ -931,7 +931,6 @@
<string name="update_check_notification_download_complete">Tap to install update</string> <string name="update_check_notification_download_complete">Tap to install update</string>
<string name="update_check_notification_download_error">Download error</string> <string name="update_check_notification_download_error">Download error</string>
<string name="update_check_notification_update_available">New version available!</string> <string name="update_check_notification_update_available">New version available!</string>
<string name="update_check_fdroid_migration_info">A new version is available from the official releases. Tap to learn how to migrate from unofficial F-Droid releases.</string>
<!-- Information Text --> <!-- Information Text -->
<string name="information_no_downloads">No downloads</string> <string name="information_no_downloads">No downloads</string>