Add links to local source guide (closes #2896)
This commit is contained in:
parent
f841d3d259
commit
a95ac8ad83
@ -30,11 +30,13 @@ import timber.log.Timber
|
|||||||
|
|
||||||
class LocalSource(private val context: Context) : CatalogueSource {
|
class LocalSource(private val context: Context) : CatalogueSource {
|
||||||
companion object {
|
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 POPULAR_FILTERS = FilterList(OrderBy())
|
||||||
private val LATEST_FILTERS = FilterList(OrderBy().apply { state = Filter.Sort.Selection(1, false) })
|
private val LATEST_FILTERS = FilterList(OrderBy().apply { state = Filter.Sort.Selection(1, false) })
|
||||||
private val LATEST_THRESHOLD = TimeUnit.MILLISECONDS.convert(7, TimeUnit.DAYS)
|
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? {
|
fun updateCover(context: Context, manga: SManga, input: InputStream): File? {
|
||||||
val dir = getBaseDirectories(context).firstOrNull()
|
val dir = getBaseDirectories(context).firstOrNull()
|
||||||
|
@ -25,6 +25,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.databinding.SourceControllerBinding
|
import eu.kanade.tachiyomi.databinding.SourceControllerBinding
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
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.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||||
import eu.kanade.tachiyomi.util.system.connectivityManager
|
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.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.inflate
|
import eu.kanade.tachiyomi.util.view.inflate
|
||||||
@ -266,6 +268,9 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
|
|
||||||
val isHttpSource = presenter.source is HttpSource
|
val isHttpSource = presenter.source is HttpSource
|
||||||
menu.findItem(R.id.action_open_in_web_view).isVisible = isHttpSource
|
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 {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
@ -273,6 +278,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
R.id.action_search -> expandActionViewFromInteraction = true
|
R.id.action_search -> expandActionViewFromInteraction = true
|
||||||
R.id.action_display_mode -> swapDisplayMode()
|
R.id.action_display_mode -> swapDisplayMode()
|
||||||
R.id.action_open_in_web_view -> openInWebView()
|
R.id.action_open_in_web_view -> openInWebView()
|
||||||
|
R.id.action_local_source_help -> openLocalSourceHelpGuide()
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item)
|
return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
@ -285,6 +291,10 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openLocalSourceHelpGuide() {
|
||||||
|
activity?.openInBrowser(LocalSource.HELP_URL)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restarts the request with a new query.
|
* Restarts the request with a new query.
|
||||||
*
|
*
|
||||||
@ -343,12 +353,16 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (adapter.isEmpty) {
|
if (adapter.isEmpty) {
|
||||||
val actions = mutableListOf(EmptyView.Action(R.string.action_retry, retryAction))
|
val actions = emptyList<EmptyView.Action>().toMutableList()
|
||||||
if (presenter.source is HttpSource) {
|
|
||||||
val openInWebViewAction = View.OnClickListener {
|
if (presenter.source is LocalSource) {
|
||||||
openInWebView()
|
actions += EmptyView.Action(R.string.local_source_help_guide, View.OnClickListener { openLocalSourceHelpGuide() })
|
||||||
|
} else {
|
||||||
|
actions += EmptyView.Action(R.string.action_retry, retryAction)
|
||||||
}
|
}
|
||||||
actions += EmptyView.Action(R.string.action_open_in_web_view, openInWebViewAction)
|
|
||||||
|
if (presenter.source is HttpSource) {
|
||||||
|
actions += EmptyView.Action(R.string.action_open_in_web_view, View.OnClickListener { openInWebView() })
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.emptyView.show(message, actions)
|
binding.emptyView.show(message, actions)
|
||||||
|
@ -23,4 +23,11 @@
|
|||||||
app:iconTint="?attr/colorOnPrimary"
|
app:iconTint="?attr/colorOnPrimary"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_local_source_help"
|
||||||
|
android:icon="@drawable/ic_help_24dp"
|
||||||
|
android:title="@string/local_source_help_guide"
|
||||||
|
app:iconTint="?attr/colorOnPrimary"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -402,6 +402,7 @@
|
|||||||
<string name="action_global_search_hint">Global search…</string>
|
<string name="action_global_search_hint">Global search…</string>
|
||||||
<string name="latest">Latest</string>
|
<string name="latest">Latest</string>
|
||||||
<string name="browse">Browse</string>
|
<string name="browse">Browse</string>
|
||||||
|
<string name="local_source_help_guide">Local source guide</string>
|
||||||
|
|
||||||
<!-- Manga activity -->
|
<!-- Manga activity -->
|
||||||
<string name="manga_not_in_db">This manga has been removed from the database.</string>
|
<string name="manga_not_in_db">This manga has been removed from the database.</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user