mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 15:11:49 +01:00
Show MIUI warning more prominently in CreateBackupScreen
This commit is contained in:
parent
83a67feb48
commit
565317d99c
@ -4,10 +4,8 @@ import android.content.ActivityNotFoundException
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
@ -28,6 +26,7 @@ import cafe.adriel.voyager.core.model.rememberScreenModel
|
|||||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||||
import eu.kanade.presentation.components.AppBar
|
import eu.kanade.presentation.components.AppBar
|
||||||
|
import eu.kanade.presentation.components.WarningBanner
|
||||||
import eu.kanade.presentation.util.Screen
|
import eu.kanade.presentation.util.Screen
|
||||||
import eu.kanade.tachiyomi.data.backup.create.BackupCreateFlags
|
import eu.kanade.tachiyomi.data.backup.create.BackupCreateFlags
|
||||||
import eu.kanade.tachiyomi.data.backup.create.BackupCreateJob
|
import eu.kanade.tachiyomi.data.backup.create.BackupCreateJob
|
||||||
@ -77,63 +76,61 @@ class CreateBackupScreen : Screen() {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
) { contentPadding ->
|
) { contentPadding ->
|
||||||
Column(
|
LazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(contentPadding)
|
.padding(contentPadding)
|
||||||
.fillMaxSize(),
|
.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
LazyColumn(
|
if (DeviceUtil.isMiui && DeviceUtil.isMiuiOptimizationDisabled()) {
|
||||||
modifier = Modifier
|
|
||||||
.weight(1f)
|
|
||||||
.padding(horizontal = MaterialTheme.padding.medium),
|
|
||||||
) {
|
|
||||||
item {
|
item {
|
||||||
LabeledCheckbox(
|
WarningBanner(MR.strings.restore_miui_warning)
|
||||||
label = stringResource(MR.strings.manga),
|
|
||||||
checked = true,
|
|
||||||
onCheckedChange = {},
|
|
||||||
enabled = false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
BackupChoices.forEach { (k, v) ->
|
|
||||||
item {
|
|
||||||
LabeledCheckbox(
|
|
||||||
label = stringResource(v),
|
|
||||||
checked = state.flags.contains(k),
|
|
||||||
onCheckedChange = {
|
|
||||||
model.toggleFlag(k)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
item {
|
||||||
HorizontalDivider()
|
LabeledCheckbox(
|
||||||
|
label = stringResource(MR.strings.manga),
|
||||||
Button(
|
checked = true,
|
||||||
modifier = Modifier
|
onCheckedChange = {},
|
||||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
enabled = false,
|
||||||
.fillMaxWidth(),
|
modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium),
|
||||||
onClick = {
|
|
||||||
if (!BackupCreateJob.isManualJobRunning(context)) {
|
|
||||||
if (DeviceUtil.isMiui && DeviceUtil.isMiuiOptimizationDisabled()) {
|
|
||||||
context.toast(MR.strings.restore_miui_warning, Toast.LENGTH_LONG)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
chooseBackupDir.launch(Backup.getFilename())
|
|
||||||
} catch (e: ActivityNotFoundException) {
|
|
||||||
context.toast(MR.strings.file_picker_error)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
context.toast(MR.strings.backup_in_progress)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = stringResource(MR.strings.action_create),
|
|
||||||
color = MaterialTheme.colorScheme.onPrimary,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
BackupChoices.forEach { (k, v) ->
|
||||||
|
item {
|
||||||
|
LabeledCheckbox(
|
||||||
|
label = stringResource(v),
|
||||||
|
checked = state.flags.contains(k),
|
||||||
|
onCheckedChange = {
|
||||||
|
model.toggleFlag(k)
|
||||||
|
},
|
||||||
|
modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HorizontalDivider()
|
||||||
|
|
||||||
|
Button(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
onClick = {
|
||||||
|
if (!BackupCreateJob.isManualJobRunning(context)) {
|
||||||
|
try {
|
||||||
|
chooseBackupDir.launch(Backup.getFilename())
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
context.toast(MR.strings.file_picker_error)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.toast(MR.strings.backup_in_progress)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(MR.strings.action_create),
|
||||||
|
color = MaterialTheme.colorScheme.onPrimary,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -521,7 +521,7 @@
|
|||||||
<string name="pref_storage_usage">Storage usage</string>
|
<string name="pref_storage_usage">Storage usage</string>
|
||||||
<string name="pref_clear_chapter_cache">Clear chapter cache</string>
|
<string name="pref_clear_chapter_cache">Clear chapter cache</string>
|
||||||
<string name="used_cache">Used: %1$s</string>
|
<string name="used_cache">Used: %1$s</string>
|
||||||
<string name="cache_deleted">Cache cleared. %1$d files have been deleted</string>
|
<string name="cache_deleted">Cache cleared, %1$d files deleted</string>
|
||||||
<string name="cache_delete_error">Error occurred while clearing</string>
|
<string name="cache_delete_error">Error occurred while clearing</string>
|
||||||
<string name="pref_auto_clear_chapter_cache">Clear chapter cache on app launch</string>
|
<string name="pref_auto_clear_chapter_cache">Clear chapter cache on app launch</string>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user