mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Add warning about F-Droid build support in More screen
This commit is contained in:
parent
bdeb209d43
commit
725fcbba0e
7 changed files with 45 additions and 20 deletions
|
@ -4,8 +4,6 @@ import android.content.Intent
|
|||
import android.net.Uri
|
||||
import android.provider.Settings
|
||||
import android.util.DisplayMetrics
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
|
@ -56,6 +54,7 @@ import eu.kanade.presentation.components.EmptyScreen
|
|||
import eu.kanade.presentation.components.LoadingScreen
|
||||
import eu.kanade.presentation.components.Scaffold
|
||||
import eu.kanade.presentation.components.ScrollbarLazyColumn
|
||||
import eu.kanade.presentation.components.WarningBanner
|
||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.TrailingWidgetBuffer
|
||||
import eu.kanade.presentation.util.horizontalPadding
|
||||
|
@ -195,20 +194,6 @@ private fun ExtensionDetails(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun WarningBanner(@StringRes textRes: Int) {
|
||||
Text(
|
||||
text = stringResource(textRes),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(MaterialTheme.colorScheme.error)
|
||||
.padding(16.dp),
|
||||
color = MaterialTheme.colorScheme.onError,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun DetailsHeader(
|
||||
extension: Extension,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.kanade.presentation.components
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
|
@ -13,6 +14,23 @@ import androidx.compose.ui.text.style.TextAlign
|
|||
import androidx.compose.ui.unit.dp
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
||||
@Composable
|
||||
fun WarningBanner(
|
||||
@StringRes textRes: Int,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(textRes),
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.background(MaterialTheme.colorScheme.error)
|
||||
.padding(16.dp),
|
||||
color = MaterialTheme.colorScheme.onError,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AppStateBanners(
|
||||
downloadedOnlyMode: Boolean,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.kanade.presentation.more
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.asPaddingValues
|
||||
import androidx.compose.foundation.layout.navigationBars
|
||||
|
@ -24,6 +25,7 @@ import androidx.compose.ui.res.vectorResource
|
|||
import eu.kanade.presentation.components.AppStateBanners
|
||||
import eu.kanade.presentation.components.Divider
|
||||
import eu.kanade.presentation.components.ScrollbarLazyColumn
|
||||
import eu.kanade.presentation.components.WarningBanner
|
||||
import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -35,6 +37,7 @@ import eu.kanade.tachiyomi.widget.TachiyomiBottomNavigationView
|
|||
@Composable
|
||||
fun MoreScreen(
|
||||
presenter: MorePresenter,
|
||||
isFDroid: Boolean,
|
||||
onClickDownloadQueue: () -> Unit,
|
||||
onClickCategories: () -> Unit,
|
||||
onClickBackupAndRestore: () -> Unit,
|
||||
|
@ -50,6 +53,17 @@ fun MoreScreen(
|
|||
WindowInsets.navigationBars.asPaddingValues(),
|
||||
),
|
||||
) {
|
||||
if (isFDroid) {
|
||||
item {
|
||||
WarningBanner(
|
||||
textRes = R.string.fdroid_warning,
|
||||
modifier = Modifier.clickable {
|
||||
uriHandler.openUri("https://tachiyomi.org/help/faq/#how-do-i-migrate-from-the-f-droid-version")
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
LogoHeader()
|
||||
}
|
||||
|
|
|
@ -9,7 +9,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 eu.kanade.tachiyomi.util.system.isInstalledFromFDroid
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
@ -38,7 +38,7 @@ class AppUpdateChecker {
|
|||
|
||||
// Check if latest version is different from current version
|
||||
if (isNewVersion(it.version)) {
|
||||
if (context.getInstallerPackageName() == "org.fdroid.fdroid") {
|
||||
if (context.isInstalledFromFDroid()) {
|
||||
AppUpdateResult.NewUpdateFdroidInstallation
|
||||
} else {
|
||||
AppUpdateResult.NewUpdate(it)
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.ui.base.controller.pushController
|
|||
import eu.kanade.tachiyomi.ui.category.CategoryController
|
||||
import eu.kanade.tachiyomi.ui.download.DownloadController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
||||
import eu.kanade.tachiyomi.util.system.isInstalledFromFDroid
|
||||
|
||||
class MoreController :
|
||||
FullComposeController<MorePresenter>(),
|
||||
|
@ -19,6 +20,7 @@ class MoreController :
|
|||
override fun ComposeContent() {
|
||||
MoreScreen(
|
||||
presenter = presenter,
|
||||
isFDroid = activity?.isInstalledFromFDroid() ?: false,
|
||||
onClickDownloadQueue = { router.pushController(DownloadController()) },
|
||||
onClickCategories = { router.pushController(CategoryController()) },
|
||||
onClickBackupAndRestore = { router.pushController(SettingsMainController.toBackupScreen()) },
|
||||
|
|
|
@ -39,6 +39,7 @@ import androidx.core.net.toUri
|
|||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.domain.ui.UiPreferences
|
||||
import eu.kanade.domain.ui.model.TabletUiMode
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.base.delegate.ThemingDelegate
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
|
@ -393,8 +394,8 @@ fun Context.isPackageInstalled(packageName: String): Boolean {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.getInstallerPackageName(): String? {
|
||||
return try {
|
||||
fun Context.isInstalledFromFDroid(): Boolean {
|
||||
val installerPackageName = try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
packageManager.getInstallSourceInfo(packageName).installingPackageName
|
||||
} else {
|
||||
|
@ -404,6 +405,10 @@ fun Context.getInstallerPackageName(): String? {
|
|||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
return installerPackageName == "org.fdroid.fdroid" ||
|
||||
// F-Droid builds typically disable the updater
|
||||
(!BuildConfig.INCLUDE_UPDATER && !isDevFlavor)
|
||||
}
|
||||
|
||||
fun Context.getApplicationIcon(pkgName: String): Drawable? {
|
||||
|
|
|
@ -548,6 +548,7 @@
|
|||
|
||||
|
||||
<!-- More -->
|
||||
<string name="fdroid_warning">F-Droid builds are not officially supported.\nTap to learn more.</string>
|
||||
<string name="label_downloaded_only">Downloaded only</string>
|
||||
<string name="pref_incognito_mode">Incognito mode</string>
|
||||
<string name="pref_incognito_mode_summary">Pauses reading history</string>
|
||||
|
|
Loading…
Reference in a new issue