mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-16 13:48:09 -07:00
@@ -45,4 +45,9 @@ class BasePreferences(
|
||||
Preference.appStateKey("donation_campaign_shown"),
|
||||
false,
|
||||
)
|
||||
|
||||
val skippedAppUpdate: Preference<String> = preferenceStore.getString(
|
||||
Preference.appStateKey("skipped_app_update"),
|
||||
"",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,12 +5,17 @@ import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
||||
import eu.kanade.presentation.manga.components.MarkdownRender
|
||||
@@ -18,6 +23,7 @@ import eu.kanade.presentation.theme.TachiyomiPreviewTheme
|
||||
import eu.kanade.tachiyomi.ui.more.NewUpdateScreenModel
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.automirroredrounded.OpenInNew
|
||||
import mihon.icons.materialsymbols.rounded.UpdateDisabled
|
||||
import mihon.icons.materialsymbols.rounded.Verified
|
||||
import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor
|
||||
import tachiyomi.i18n.MR
|
||||
@@ -34,7 +40,33 @@ fun NewUpdateScreen(
|
||||
onOpenInBrowser: () -> Unit,
|
||||
onAcceptUpdate: () -> Unit,
|
||||
onRejectUpdate: () -> Unit,
|
||||
onSkipUpdate: () -> Unit,
|
||||
) {
|
||||
var showSkipDialog by remember { mutableStateOf(false) }
|
||||
if (showSkipDialog) {
|
||||
val dismiss = { showSkipDialog = false }
|
||||
AlertDialog(
|
||||
onDismissRequest = dismiss,
|
||||
title = { Text(text = stringResource(MR.strings.update_check_skip_title, versionName)) },
|
||||
text = { Text(text = stringResource(MR.strings.update_check_skip_message)) },
|
||||
dismissButton = {
|
||||
TextButton(onClick = dismiss) {
|
||||
Text(text = stringResource(MR.strings.action_cancel))
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
dismiss()
|
||||
onSkipUpdate()
|
||||
},
|
||||
) {
|
||||
Text(text = stringResource(MR.strings.action_ok))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
InfoScreen(
|
||||
icon = MaterialSymbols.Rounded.Verified,
|
||||
headingText = stringResource(MR.strings.update_check_notification_update_available),
|
||||
@@ -52,6 +84,14 @@ fun NewUpdateScreen(
|
||||
canAccept = stage != NewUpdateScreenModel.Stage.Downloading,
|
||||
rejectText = stringResource(MR.strings.action_not_now),
|
||||
onRejectClick = onRejectUpdate,
|
||||
rejectAction = {
|
||||
OutlinedButton(onClick = { showSkipDialog = true }) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.UpdateDisabled,
|
||||
contentDescription = stringResource(MR.strings.update_check_skip),
|
||||
)
|
||||
}
|
||||
},
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -94,6 +134,7 @@ private fun NewUpdateScreenPreview() {
|
||||
onOpenInBrowser = {},
|
||||
onAcceptUpdate = {},
|
||||
onRejectUpdate = {},
|
||||
onSkipUpdate = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,10 @@ class MainActivity : BaseActivity() {
|
||||
if (updaterEnabled) {
|
||||
try {
|
||||
val result = context.appGraph.updateChecker.checkForUpdate()
|
||||
if (result is GetApplicationRelease.Result.NewUpdate) {
|
||||
if (
|
||||
result is GetApplicationRelease.Result.NewUpdate &&
|
||||
result.release.version != preferences.skippedAppUpdate.get()
|
||||
) {
|
||||
val updateScreen = NewUpdateScreen(
|
||||
versionName = result.release.version,
|
||||
changelogInfo = result.release.info,
|
||||
|
||||
@@ -43,6 +43,10 @@ class NewUpdateScreen(
|
||||
}
|
||||
},
|
||||
onRejectUpdate = navigator::pop,
|
||||
onSkipUpdate = {
|
||||
viewModel.skipUpdate(versionName)
|
||||
navigator.pop()
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import dev.zacsweers.metro.AssistedInject
|
||||
import dev.zacsweers.metro.ContributesIntoMap
|
||||
import dev.zacsweers.metrox.viewmodel.ManualViewModelAssistedFactory
|
||||
import dev.zacsweers.metrox.viewmodel.ManualViewModelAssistedFactoryKey
|
||||
import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionInstaller
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
@@ -38,6 +39,7 @@ class NewUpdateScreenModel(
|
||||
@Assisted private val downloadLink: String,
|
||||
private val context: Context,
|
||||
private val network: NetworkHelper,
|
||||
private val preferences: BasePreferences,
|
||||
) : ViewModel() {
|
||||
|
||||
val state: StateFlow<NewUpdateScreenModel.State>
|
||||
@@ -96,6 +98,11 @@ class NewUpdateScreenModel(
|
||||
response.body.source().saveTo(apkFile)
|
||||
}
|
||||
|
||||
fun skipUpdate(versionName: String) {
|
||||
downloadJob?.cancel()
|
||||
preferences.skippedAppUpdate.set(versionName)
|
||||
}
|
||||
|
||||
fun installUpdate() {
|
||||
val intent = Intent(Intent.ACTION_VIEW).apply {
|
||||
setDataAndType(apkFile.getUriCompat(context), ExtensionInstaller.APK_MIME)
|
||||
|
||||
@@ -53,6 +53,7 @@ class CrashLogUtil(
|
||||
App ID: ${BuildConfig.APPLICATION_ID}
|
||||
App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE}, ${BuildConfig.BUILD_TIME})
|
||||
Installation ID: ${preferences.installationId.get()}
|
||||
Skipped app update: ${preferences.skippedAppUpdate.get().ifEmpty { "None" }}
|
||||
Android version: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT}; build ${Build.DISPLAY})
|
||||
Device brand: ${Build.BRAND}
|
||||
Device manufacturer: ${Build.MANUFACTURER}
|
||||
|
||||
Reference in New Issue
Block a user