diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index 32a1e6876..573806e6a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -30,11 +30,13 @@ import timber.log.Timber class LocalSource(private val context: Context) : CatalogueSource { companion object { - private val COVER_NAME = "cover.jpg" + const val HELP_URL = "https://tachiyomi.org/help/guides/reading-local-manga/" + + private const val COVER_NAME = "cover.jpg" private val POPULAR_FILTERS = FilterList(OrderBy()) private val LATEST_FILTERS = FilterList(OrderBy().apply { state = Filter.Sort.Selection(1, false) }) private val LATEST_THRESHOLD = TimeUnit.MILLISECONDS.convert(7, TimeUnit.DAYS) - val ID = 0L + const val ID = 0L fun updateCover(context: Context, manga: SManga, input: InputStream): File? { val dir = getBaseDirectories(context).firstOrNull() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt index 452bfcfd2..94b346aa6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt @@ -25,6 +25,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.databinding.SourceControllerBinding import eu.kanade.tachiyomi.source.CatalogueSource +import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.base.controller.NucleusController @@ -33,6 +34,7 @@ import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.system.connectivityManager +import eu.kanade.tachiyomi.util.system.openInBrowser import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.inflate @@ -266,6 +268,9 @@ open class BrowseSourceController(bundle: Bundle) : val isHttpSource = presenter.source is HttpSource menu.findItem(R.id.action_open_in_web_view).isVisible = isHttpSource + + val isLocalSource = presenter.source is LocalSource + menu.findItem(R.id.action_local_source_help).isVisible = isLocalSource } override fun onOptionsItemSelected(item: MenuItem): Boolean { @@ -273,6 +278,7 @@ open class BrowseSourceController(bundle: Bundle) : R.id.action_search -> expandActionViewFromInteraction = true R.id.action_display_mode -> swapDisplayMode() R.id.action_open_in_web_view -> openInWebView() + R.id.action_local_source_help -> openLocalSourceHelpGuide() } return super.onOptionsItemSelected(item) } @@ -285,6 +291,10 @@ open class BrowseSourceController(bundle: Bundle) : startActivity(intent) } + private fun openLocalSourceHelpGuide() { + activity?.openInBrowser(LocalSource.HELP_URL) + } + /** * Restarts the request with a new query. * @@ -343,12 +353,16 @@ open class BrowseSourceController(bundle: Bundle) : } if (adapter.isEmpty) { - val actions = mutableListOf(EmptyView.Action(R.string.action_retry, retryAction)) + val actions = emptyList().toMutableList() + + if (presenter.source is LocalSource) { + actions += EmptyView.Action(R.string.local_source_help_guide, View.OnClickListener { openLocalSourceHelpGuide() }) + } else { + actions += EmptyView.Action(R.string.action_retry, retryAction) + } + if (presenter.source is HttpSource) { - val openInWebViewAction = View.OnClickListener { - openInWebView() - } - actions += EmptyView.Action(R.string.action_open_in_web_view, openInWebViewAction) + actions += EmptyView.Action(R.string.action_open_in_web_view, View.OnClickListener { openInWebView() }) } binding.emptyView.show(message, actions) diff --git a/app/src/main/res/menu/source_browse.xml b/app/src/main/res/menu/source_browse.xml index 9239fd7f9..94e3a80ce 100644 --- a/app/src/main/res/menu/source_browse.xml +++ b/app/src/main/res/menu/source_browse.xml @@ -23,4 +23,11 @@ app:iconTint="?attr/colorOnPrimary" app:showAsAction="ifRoom" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cf3ce8eb0..78ba5768c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -402,6 +402,7 @@ Global search… Latest Browse + Local source guide This manga has been removed from the database.