Add help shortcut for source migration (closes #3951)

This commit is contained in:
arkon 2020-11-22 16:27:42 -05:00
parent d548c690d6
commit 56c19e57a9
3 changed files with 36 additions and 0 deletions

View file

@ -1,14 +1,19 @@
package eu.kanade.tachiyomi.ui.browse.migration.sources package eu.kanade.tachiyomi.ui.browse.migration.sources
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.MigrationSourcesControllerBinding import eu.kanade.tachiyomi.databinding.MigrationSourcesControllerBinding
import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrationMangaController import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrationMangaController
import eu.kanade.tachiyomi.util.system.openInBrowser
class MigrationSourcesController : class MigrationSourcesController :
NucleusController<MigrationSourcesControllerBinding, MigrationSourcesPresenter>(), NucleusController<MigrationSourcesControllerBinding, MigrationSourcesPresenter>(),
@ -16,6 +21,10 @@ class MigrationSourcesController :
private var adapter: SourceAdapter? = null private var adapter: SourceAdapter? = null
init {
setHasOptionsMenu(true)
}
override fun createPresenter(): MigrationSourcesPresenter { override fun createPresenter(): MigrationSourcesPresenter {
return MigrationSourcesPresenter() return MigrationSourcesPresenter()
} }
@ -39,6 +48,17 @@ class MigrationSourcesController :
super.onDestroyView(view) 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<SourceItem>) { fun setSources(sourcesWithManga: List<SourceItem>) {
adapter?.updateDataSet(sourcesWithManga) adapter?.updateDataSet(sourcesWithManga)
} }
@ -49,4 +69,8 @@ class MigrationSourcesController :
parentController!!.router.pushController(controller.withFadeTransaction()) parentController!!.router.pushController(controller.withFadeTransaction())
return false return false
} }
companion object {
const val HELP_URL = "https://tachiyomi.org/help/guides/source-migration/"
}
} }

View file

@ -0,0 +1,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_source_migration_help"
android:icon="@drawable/ic_help_24dp"
android:title="@string/migration_help_guide"
app:iconTint="?attr/colorOnPrimary"
app:showAsAction="ifRoom" />
</menu>

View file

@ -621,6 +621,7 @@
<string name="recent_manga_time">Ch. %1$s - %2$s</string> <string name="recent_manga_time">Ch. %1$s - %2$s</string>
<!-- Source migration screen --> <!-- Source migration screen -->
<string name="migration_help_guide">Source migration guide</string>
<string name="migration_info">Tap to select the source to migrate from</string> <string name="migration_info">Tap to select the source to migrate from</string>
<string name="migration_dialog_what_to_include">Select data to include</string> <string name="migration_dialog_what_to_include">Select data to include</string>
<string name="migration_selection_prompt">Select a source to migrate from</string> <string name="migration_selection_prompt">Select a source to migrate from</string>