mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Put shortcut to backup menu in More
This commit is contained in:
		@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user