From 067cb2452efcb428f14a5f911f7bd51ccbf0ef0f Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 5 Feb 2022 17:44:54 -0500 Subject: [PATCH] Add shortcut to backups guide --- .../ui/setting/SettingsBackupController.kt | 17 +++++++++++++++++ app/src/main/res/menu/settings_backup.xml | 11 +++++++++++ 2 files changed, 28 insertions(+) create mode 100644 app/src/main/res/menu/settings_backup.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt index 76eee3a8f..a6d135360 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt @@ -7,6 +7,9 @@ import android.content.ActivityNotFoundException import android.content.Intent import android.net.Uri import android.os.Bundle +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem import android.view.View import android.widget.Toast import androidx.appcompat.app.AlertDialog @@ -37,6 +40,7 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.summaryRes import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.DeviceUtil +import eu.kanade.tachiyomi.util.system.openInBrowser import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -158,6 +162,17 @@ class SettingsBackupController : SettingsController() { infoPreference(R.string.backup_info) } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + inflater.inflate(R.menu.settings_backup, menu) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.action_backup_help -> activity?.openInBrowser(HELP_URL) + } + return super.onOptionsItemSelected(item) + } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { if (data != null && resultCode == Activity.RESULT_OK) { val activity = activity ?: return @@ -305,3 +320,5 @@ private const val KEY_URI = "RestoreBackupDialog.uri" private const val CODE_BACKUP_DIR = 503 private const val CODE_BACKUP_CREATE = 504 private const val CODE_BACKUP_RESTORE = 505 + +private const val HELP_URL = "https://tachiyomi.org/help/guides/backups/" diff --git a/app/src/main/res/menu/settings_backup.xml b/app/src/main/res/menu/settings_backup.xml new file mode 100644 index 000000000..28ff24c5f --- /dev/null +++ b/app/src/main/res/menu/settings_backup.xml @@ -0,0 +1,11 @@ + + + + +