From 56c19e57a9c062341c848975a150ca21d151006e Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 22 Nov 2020 16:27:42 -0500 Subject: [PATCH] Add help shortcut for source migration (closes #3951) --- .../sources/MigrationSourcesController.kt | 24 +++++++++++++++++++ app/src/main/res/menu/source_migration.xml | 11 +++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 36 insertions(+) create mode 100644 app/src/main/res/menu/source_migration.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt index 862e6b9411..cb969b5b8d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt @@ -1,14 +1,19 @@ package eu.kanade.tachiyomi.ui.browse.migration.sources import android.view.LayoutInflater +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.LinearLayoutManager import eu.davidea.flexibleadapter.FlexibleAdapter +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.MigrationSourcesControllerBinding import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrationMangaController +import eu.kanade.tachiyomi.util.system.openInBrowser class MigrationSourcesController : NucleusController(), @@ -16,6 +21,10 @@ class MigrationSourcesController : private var adapter: SourceAdapter? = null + init { + setHasOptionsMenu(true) + } + override fun createPresenter(): MigrationSourcesPresenter { return MigrationSourcesPresenter() } @@ -39,6 +48,17 @@ class MigrationSourcesController : super.onDestroyView(view) } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + inflater.inflate(R.menu.source_migration, menu) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.action_source_migration_help -> activity?.openInBrowser(HELP_URL) + } + return super.onOptionsItemSelected(item) + } + fun setSources(sourcesWithManga: List) { adapter?.updateDataSet(sourcesWithManga) } @@ -49,4 +69,8 @@ class MigrationSourcesController : parentController!!.router.pushController(controller.withFadeTransaction()) return false } + + companion object { + const val HELP_URL = "https://tachiyomi.org/help/guides/source-migration/" + } } diff --git a/app/src/main/res/menu/source_migration.xml b/app/src/main/res/menu/source_migration.xml new file mode 100644 index 0000000000..000574fd01 --- /dev/null +++ b/app/src/main/res/menu/source_migration.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c8a8656ccb..7c1ddfad27 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -621,6 +621,7 @@ Ch. %1$s - %2$s + Source migration guide Tap to select the source to migrate from Select data to include Select a source to migrate from