瀏覽代碼

Put shortcut to backup menu in More

arkon 3 年之前
父節點
當前提交
a498f940c6

+ 9 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt

@@ -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 {

+ 31 - 34
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt

@@ -53,46 +53,43 @@ class SettingsBackupController : SettingsController() {
     }
 
     override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
-        titleRes = R.string.backup
-
-        preferenceCategory {
-            titleRes = R.string.backup
-
-            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)
-                    }
+        titleRes = R.string.label_backup
+
+        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)
+        }
+        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
 

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt

@@ -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 {

+ 1 - 2
app/src/main/res/values/strings.xml

@@ -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>