Put shortcut to backup menu in More

This commit is contained in:
arkon 2021-05-24 16:55:42 -04:00
parent 948cb31d1a
commit a498f940c6
4 changed files with 43 additions and 38 deletions

View File

@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.ui.base.controller.RootController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.category.CategoryController
import eu.kanade.tachiyomi.ui.download.DownloadController
import eu.kanade.tachiyomi.ui.setting.SettingsBackupController
import eu.kanade.tachiyomi.ui.setting.SettingsController
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
import eu.kanade.tachiyomi.util.preference.add
@ -93,6 +94,14 @@ class MoreController :
router.pushController(CategoryController().withFadeTransaction())
}
}
preference {
titleRes = R.string.label_backup
iconRes = R.drawable.ic_backup_24dp
iconTint = tintColor
onClick {
router.pushController(SettingsBackupController().withFadeTransaction())
}
}
}
preferenceCategory {

View File

@ -53,46 +53,43 @@ class SettingsBackupController : SettingsController() {
}
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
titleRes = R.string.backup
titleRes = R.string.label_backup
preferenceCategory {
titleRes = R.string.backup
preference {
key = "pref_create_backup"
titleRes = R.string.pref_create_backup
summaryRes = R.string.pref_create_backup_summ
preference {
key = "pref_create_backup"
titleRes = R.string.pref_create_backup
summaryRes = R.string.pref_create_backup_summ
onClick {
if (!BackupCreateService.isRunning(context)) {
val ctrl = CreateBackupDialog()
ctrl.targetController = this@SettingsBackupController
ctrl.showDialog(router)
} else {
context.toast(R.string.backup_in_progress)
}
}
}
preference {
key = "pref_restore_backup"
titleRes = R.string.pref_restore_backup
summaryRes = R.string.pref_restore_backup_summ
onClick {
if (!BackupRestoreService.isRunning(context)) {
val intent = Intent(Intent.ACTION_GET_CONTENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "*/*"
}
val title = resources?.getString(R.string.file_select_backup)
val chooser = Intent.createChooser(intent, title)
startActivityForResult(chooser, CODE_BACKUP_RESTORE)
} else {
context.toast(R.string.restore_in_progress)
}
onClick {
if (!BackupCreateService.isRunning(context)) {
val ctrl = CreateBackupDialog()
ctrl.targetController = this@SettingsBackupController
ctrl.showDialog(router)
} else {
context.toast(R.string.backup_in_progress)
}
}
}
preference {
key = "pref_restore_backup"
titleRes = R.string.pref_restore_backup
summaryRes = R.string.pref_restore_backup_summ
onClick {
if (!BackupRestoreService.isRunning(context)) {
val intent = Intent(Intent.ACTION_GET_CONTENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "*/*"
}
val title = resources?.getString(R.string.file_select_backup)
val chooser = Intent.createChooser(intent, title)
startActivityForResult(chooser, CODE_BACKUP_RESTORE)
} else {
context.toast(R.string.restore_in_progress)
}
}
}
preferenceCategory {
titleRes = R.string.pref_backup_service_category

View File

@ -61,7 +61,7 @@ class SettingsMainController : SettingsController() {
preference {
iconRes = R.drawable.ic_backup_24dp
iconTint = tintColor
titleRes = R.string.backup
titleRes = R.string.label_backup
onClick { navigateTo(SettingsBackupController()) }
}
preference {

View File

@ -18,7 +18,7 @@
<string name="label_recent_updates">Updates</string>
<string name="label_recent_manga">History</string>
<string name="label_sources">Sources</string>
<string name="label_backup">Backup</string>
<string name="label_backup">Backup and restore</string>
<string name="label_migration">Migrate</string>
<string name="label_extensions">Extensions</string>
<string name="label_extension_info">Extension info</string>
@ -389,7 +389,6 @@
<string name="pref_search_pinned_sources_only">Only include pinned sources</string>
<!-- Backup section -->
<string name="backup">Backup</string>
<string name="pref_create_backup">Create backup</string>
<string name="pref_create_backup_summ">Can be used to restore current library</string>
<string name="pref_restore_backup">Restore backup</string>