Don't show copied to clipboard toast on A13+ when copying backup restore error

This commit is contained in:
arkon 2022-11-05 11:56:31 -04:00
parent 54471a014f
commit 3733871d2f

View File

@ -33,10 +33,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.runtime.toMutableStateList import androidx.compose.runtime.toMutableStateList
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.core.net.toUri import androidx.core.net.toUri
import com.google.accompanist.permissions.rememberPermissionState import com.google.accompanist.permissions.rememberPermissionState
@ -55,6 +53,7 @@ import eu.kanade.tachiyomi.data.backup.BackupFileValidator
import eu.kanade.tachiyomi.data.backup.BackupRestoreService import eu.kanade.tachiyomi.data.backup.BackupRestoreService
import eu.kanade.tachiyomi.data.backup.models.Backup import eu.kanade.tachiyomi.data.backup.models.Backup
import eu.kanade.tachiyomi.util.system.DeviceUtil import eu.kanade.tachiyomi.util.system.DeviceUtil
import eu.kanade.tachiyomi.util.system.copyToClipboard
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
@ -239,7 +238,6 @@ class SettingsBackupScreen : SearchableSettings {
val onDismissRequest = { error = null } val onDismissRequest = { error = null }
when (val err = error) { when (val err = error) {
is InvalidRestore -> { is InvalidRestore -> {
val clipboard = LocalClipboardManager.current
AlertDialog( AlertDialog(
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,
title = { Text(text = stringResource(R.string.invalid_backup_file)) }, title = { Text(text = stringResource(R.string.invalid_backup_file)) },
@ -247,8 +245,7 @@ class SettingsBackupScreen : SearchableSettings {
dismissButton = { dismissButton = {
TextButton( TextButton(
onClick = { onClick = {
clipboard.setText(AnnotatedString(err.message)) context.copyToClipboard(err.message, err.message)
context.toast(R.string.copied_to_clipboard)
onDismissRequest() onDismissRequest()
}, },
) { ) {