Add links to local source guide

Also added empty view in browse sources to retry or open in webview
This commit is contained in:
Jay 2020-04-25 20:29:00 -04:00
parent 40ae78c0a3
commit 7b7222428c
41 changed files with 117 additions and 50 deletions

View File

@ -31,12 +31,14 @@ import java.util.zip.ZipFile
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()
@ -63,11 +65,11 @@ class LocalSource(private val context: Context) : CatalogueSource {
}
override val id = ID
override val name = context.getString(R.string.local_library)
override val name = context.getString(R.string.local_source)
override val lang = ""
override val supportsLatest = true
override fun toString() = context.getString(R.string.local_library)
override fun toString() = context.getString(R.string.local_source)
override fun fetchPopularManga(page: Int) = fetchSearchManga(page, "", POPULAR_FILTERS)

View File

@ -22,6 +22,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.online.HttpSource
@ -33,6 +34,7 @@ import eu.kanade.tachiyomi.ui.source.SourceController
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.system.connectivityManager
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.openInBrowser
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.inflate
import eu.kanade.tachiyomi.util.view.scrollViewWith
@ -42,6 +44,7 @@ import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.util.view.visibleIf
import eu.kanade.tachiyomi.util.view.withFadeTransaction
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
import eu.kanade.tachiyomi.widget.EmptyView
import kotlinx.android.synthetic.main.browse_source_controller.*
import rx.Observable
import rx.Subscription
@ -258,6 +261,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 {
@ -265,6 +271,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()
else -> return super.onOptionsItemSelected(item)
}
return true
@ -329,6 +336,10 @@ open class BrowseSourceController(bundle: Bundle) :
startActivity(intent)
}
private fun openLocalSourceHelpGuide() {
activity?.openInBrowser(LocalSource.HELP_URL)
}
/**
* Restarts the request with a new query.
*
@ -373,18 +384,49 @@ open class BrowseSourceController(bundle: Bundle) :
hideProgressBar()
snack?.dismiss()
val message = if (error is NoResultsException) catalogue_view.context.getString(R.string.no_results_found) else (error.message ?: "")
snack = source_layout?.snack(message, Snackbar.LENGTH_INDEFINITE) {
setAction(R.string.retry) {
// If not the first page, show bottom progress bar.
if (adapter.mainItemCount > 0) {
val item = progressItem ?: return@setAction
adapter.addScrollableFooterWithDelay(item, 0, true)
} else {
showProgressBar()
presenter.requestNext()
}
val message = getErrorMessage(error)
val retryAction = View.OnClickListener {
// If not the first page, show bottom progress bar.
if (adapter.mainItemCount > 0 && progressItem != null) {
adapter.addScrollableFooterWithDelay(progressItem!!, 0, true)
} else {
showProgressBar()
}
presenter.requestNext()
}
if (adapter.isEmpty) {
val actions = emptyList<EmptyView.Action>().toMutableList()
actions += if (presenter.source is LocalSource) {
EmptyView.Action(R.string.local_source_help_guide, View.OnClickListener { openLocalSourceHelpGuide() })
} else {
EmptyView.Action(R.string.retry, retryAction)
}
if (presenter.source is HttpSource) {
actions += EmptyView.Action(R.string.open_in_webview, View.OnClickListener { openInWebView() })
}
empty_view.show(R.drawable.ic_local_library_24dp, message, actions)
} else {
snack = source_layout?.snack(message, Snackbar.LENGTH_INDEFINITE) {
setAction(R.string.retry, retryAction)
}
}
}
private fun getErrorMessage(error: Throwable): String {
if (error is NoResultsException) {
return activity!!.getString(R.string.no_results_found)
}
return when {
error.message == null -> ""
error.message!!.startsWith("HTTP error") -> "${error.message}: ${activity!!.getString(R.string.check_site_in_web)}"
else -> error.message!!
}
}

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,11.55C9.64,9.35 6.48,8 3,8v11c3.48,0 6.64,1.35 9,3.55 2.36,-2.19 5.52,-3.55 9,-3.55V8c-3.48,0 -6.64,1.35 -9,3.55zM12,8c1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3 1.34,3 3,3z"/>
</vector>

View File

@ -30,4 +30,15 @@
android:text="@string/filter"
app:icon="@drawable/ic_filter_list_white_24dp"/>
<eu.kanade.tachiyomi.widget.EmptyView
android:id="@+id/empty_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/extension_uninstall_button"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -60,7 +60,6 @@
android:id="@+id/search_btn"
style="@style/Theme.Widget.Button.TextButton"
android:textSize="16sp"
android:letterSpacing="0.0"
android:layout_width="wrap_content"
android:textColor="?attr/tabBarIconColor"
android:layout_height="match_parent"

View File

@ -21,4 +21,10 @@
android:title="@string/open_in_webview"
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:showAsAction="ifRoom" />
</menu>

View File

@ -11,6 +11,6 @@
<item
android:id="@+id/action_help"
android:title="@string/help"
android:icon="@drawable/ic_help_black_24dp"
android:icon="@drawable/ic_help_24dp"
app:showAsAction="always"/>
</menu>

View File

@ -192,7 +192,7 @@
<string name="could_not_log_in">حدث خطأ في تسجيل الدخول</string>
<string name="unknown_error">خطأ غير معروف</string>
<string name="no_more_results">لا يوجد نتائج أخرى</string>
<string name="local_library">المانجا المحلية</string>
<string name="local_source">المانجا المحلية</string>
<string name="other">أخرى</string>
<string name="global_search">البحث الشامل…</string>
<string name="latest">اﻷخيرة</string>

View File

@ -282,7 +282,7 @@
<string name="restoring_backup">Възстановяване на копие</string>
<string name="refresh_tracking_metadata">Обнови метаданните на проследяването</string>
<string name="updates_tracking_details">Обновява статус, оценка и последно прочетена глава от услугите за проследяване</string>
<string name="local_library">Локална манга</string>
<string name="local_source">Локална манга</string>
<string name="paused">На пауза</string>
<string name="download_paused">Изтеглянето спряно</string>
<string name="restore_message">За възстановяването се изтеглят данни от източника, за които може да бъде отчетен разход на данни. Също проверете дали сте влезли коректно в източниците, които го изискват, преди възстановяването.</string>

View File

@ -191,7 +191,7 @@
<string name="unknown_error">অজানা ত্রুটি</string>
<string name="local">স্থানীয়</string>
<string name="no_more_results">আর কিছু নেই</string>
<string name="local_library">স্থানীয় মাংগা</string>
<string name="local_source">স্থানীয় মাংগা</string>
<string name="other">অন্যসব</string>
<string name="global_search">সার্বজনীন খোঁজ…</string>
<string name="latest">সর্বশেষ</string>

View File

@ -218,7 +218,7 @@
<string name="local">Local</string>
<string name="search_filters">Filtres de cerca</string>
<string name="no_more_results">No hi ha més resultats</string>
<string name="local_library">Manga en local</string>
<string name="local_source">Manga en local</string>
<string name="other">Altres</string>
<string name="global_search">Cerca global…</string>
<string name="latest">Recents</string>

View File

@ -249,7 +249,7 @@
<string name="helps_fix_bugs">Pomáhá opravit chyby. Nebudou odeslány žádné citlivé údaje</string>
<string name="local">Lokální</string>
<string name="search_filters">Filtry vyhledávání</string>
<string name="local_library">Lokální manga</string>
<string name="local_source">Lokální manga</string>
<string name="other">Ostatní</string>
<string name="latest">Nejnovější</string>
<string name="browse">Procházet</string>

View File

@ -186,7 +186,7 @@
<string name="could_not_log_in">Anmeldungsfehler</string>
<string name="unknown_error">Unbekannter Fehler</string>
<string name="no_more_results">Keine weiteren Ergebnisse</string>
<string name="local_library">Lokale Manga</string>
<string name="local_source">Lokale Manga</string>
<string name="description">Beschreibung</string>
<string name="ongoing">Fortlaufend</string>
<string name="unknown">Unbekannt</string>

View File

@ -216,7 +216,7 @@
<string name="local">Τοπικό</string>
<string name="search_filters">Φίλτρα αναζήτησης</string>
<string name="no_more_results">Δεν υπάρχουν άλλα αποτελέσματα</string>
<string name="local_library">Τοπικά manga</string>
<string name="local_source">Τοπικά manga</string>
<string name="other">Άλλα</string>
<string name="global_search">Καθολική αναζήτηση…</string>
<string name="latest">Τελευταίο</string>

View File

@ -266,7 +266,7 @@ También asegúrese de haber iniciado sesión en las fuentes que lo requieren an
<string name="refresh_tracking_metadata">Actualizar metadatos de seguimiento</string>
<string name="updates_tracking_details">Actualización de estado, puntuación y último capítulo leído en los servicios de seguimiento</string>
<string name="no_more_results">No hay más resultados</string>
<string name="local_library">Manga local</string>
<string name="local_source">Manga local</string>
<string name="circular">Icono circular</string>
<string name="rounded">Icono redondeado</string>
<string name="square">Icono cuadrado</string>

View File

@ -286,7 +286,7 @@
<string name="restore_backup">Palauta varmuuskopio</string>
<string name="backup_location">Varmuuskopio kansio</string>
<string name="search_filters">Hakusuodattimet</string>
<string name="local_library">Paikalliset sarjat</string>
<string name="local_source">Paikalliset sarjat</string>
<string name="other">Muut</string>
<string name="latest">Viimeisimmät</string>
<string name="browse">Selaa</string>

View File

@ -255,7 +255,7 @@
<string name="amoled_black">Thème AMOLED</string>
<string name="default_category">Catégorie par défaut</string>
<string name="download_paused">Téléchargement en pause</string>
<string name="local_library">Manga locaux</string>
<string name="local_source">Manga locaux</string>
<string name="paused">En pause</string>
<string name="restore">Restaurer</string>
<string name="backup_location">Dossier de sauvegarde</string>

View File

@ -190,7 +190,7 @@
<string name="unknown_error">अज्ञात त्रुटि</string>
<string name="local">लोकल</string>
<string name="no_more_results">कोई और परिणाम नहीं है</string>
<string name="local_library">लोकल मंगा</string>
<string name="local_source">लोकल मंगा</string>
<string name="other">अन्य</string>
<string name="global_search">वैश्विक खोज …</string>
<string name="latest">नवीनतम</string>

View File

@ -188,7 +188,7 @@
<string name="could_not_log_in">Login gagal</string>
<string name="unknown_error">Terdapat suatu kesalahan</string>
<string name="no_more_results">Tidak ada hasil lainnya</string>
<string name="local_library">Manga lokal</string>
<string name="local_source">Manga lokal</string>
<string name="description">Deskripsi</string>
<string name="ongoing">Berlanjut</string>
<string name="unknown">Tidak diketahui</string>

View File

@ -279,7 +279,7 @@
<string name="refresh_tracking_metadata">Ricarica metadati progresso</string>
<string name="updates_tracking_details">Aggiorna stato, voto e ultimo capitolo letto dalla funzione segna progresso</string>
<string name="no_more_results">Non ci sono altri risultati</string>
<string name="local_library">Manga locale</string>
<string name="local_source">Manga locale</string>
<string name="paused">In pausa</string>
<string name="download_paused">Download in pausa</string>
<string name="source_migration">Migrazione fonti</string>

View File

@ -275,7 +275,7 @@
<string name="what_should_backup">어떤 항목들을 백업하겠습니까\?</string>
<string name="clear_database_completed">항목 삭제됨</string>
<string name="local">로컬</string>
<string name="local_library">로컬 만화</string>
<string name="local_source">로컬 만화</string>
<string name="other">기타</string>
<string name="browse">찾아보기</string>
<string name="licensed">판권작</string>

View File

@ -189,7 +189,7 @@
<string name="unknown_error">Ralat tidak diketahui</string>
<string name="local">Setempat</string>
<string name="no_more_results">Tiada lagi hasil</string>
<string name="local_library">Manga setempat</string>
<string name="local_source">Manga setempat</string>
<string name="other">Lain</string>
<string name="global_search">Carian keseluruhan…</string>
<string name="latest">Terkini</string>

View File

@ -209,7 +209,7 @@
<string name="local">Lokal</string>
<string name="search_filters">Søkefilter</string>
<string name="no_more_results">Ingen flere resultater</string>
<string name="local_library">Lokal manga</string>
<string name="local_source">Lokal manga</string>
<string name="other">Andre</string>
<string name="global_search">Globalt søk…</string>
<string name="latest">Seneste</string>

View File

@ -144,7 +144,7 @@
<string name="login">Log in</string>
<string name="unknown_error">Onbekende fout</string>
<string name="no_more_results">Geen verdere resultaten</string>
<string name="local_library">Lokale manga</string>
<string name="local_source">Lokale manga</string>
<string name="description">Beschrijving</string>
<string name="unknown">Onbekend</string>
<string name="author">Auteur</string>

View File

@ -352,7 +352,7 @@
<string name="search_filters">Filtry wyszukiwania</string>
<string name="no_more_results">Nie ma więcej wyników</string>
<string name="no_results_found">Nie znaleziono wyników</string>
<string name="local_library">Lokalne mangi</string>
<string name="local_source">Lokalne mangi</string>
<string name="other">Inne</string>
<string name="global_search">Wyszukiwanie globalne…</string>
<string name="latest">Najnowsze</string>

View File

@ -188,7 +188,7 @@ Além disso, verifique se as fontes que requerem uma conta foram configuradas co
<string name="could_not_log_in">Erro ao fazer login</string>
<string name="unknown_error">Erro desconhecido</string>
<string name="no_more_results">Não há mais resultados</string>
<string name="local_library">Mangá local</string>
<string name="local_source">Mangá local</string>
<string name="description">Descrição</string>
<string name="ongoing">Em andamento</string>
<string name="unknown">Desconhecido</string>

View File

@ -293,7 +293,7 @@
<string name="local">Local</string>
<string name="search_filters">Filtros de busca</string>
<string name="no_more_results">Não há mais resultados</string>
<string name="local_library">Mangá local</string>
<string name="local_source">Mangá local</string>
<string name="other">Outras</string>
<string name="global_search">Pesquisa global…</string>
<string name="latest">Mais recente</string>

View File

@ -215,7 +215,7 @@
<string name="local">Local</string>
<string name="search_filters">Filtre de căutare</string>
<string name="no_more_results">Nu mai sunt rezultate</string>
<string name="local_library">Manga local</string>
<string name="local_source">Manga local</string>
<string name="other">Altele</string>
<string name="global_search">Căutare globală…</string>
<string name="latest">Cel mai recent</string>

View File

@ -254,7 +254,7 @@
<string name="loading">Загрузка…</string>
<string name="local_library">Локальная манга</string>
<string name="local_source">Локальная манга</string>
<string name="local">Локальная</string>
<plurals name="after_minutes">

View File

@ -217,7 +217,7 @@
<string name="local">Locale</string>
<string name="search_filters">Filtros de chirca</string>
<string name="no_more_results">Non bi sunt àteros risultados</string>
<string name="local_library">Manga locale</string>
<string name="local_source">Manga locale</string>
<string name="other">Àteru</string>
<string name="global_search">Chirca globale…</string>
<string name="latest">Ùrtimos</string>

View File

@ -217,7 +217,7 @@
<string name="local">Lokalno</string>
<string name="search_filters">Filteri pretrage</string>
<string name="no_more_results">Nema više rezultata</string>
<string name="local_library">Lokalna manga</string>
<string name="local_source">Lokalna manga</string>
<string name="other">Ostalo</string>
<string name="global_search">Globalno pretraživanje…</string>
<string name="latest">Poslednje</string>

View File

@ -216,7 +216,7 @@
<string name="local">Lokal</string>
<string name="search_filters">Sök filter</string>
<string name="no_more_results">Inga mer resultat</string>
<string name="local_library">Lokal manga</string>
<string name="local_source">Lokal manga</string>
<string name="other">Andra</string>
<string name="global_search">Global sökning…</string>
<string name="latest">Senaste</string>

View File

@ -215,7 +215,7 @@
<string name="local">ท้องถิ่น</string>
<string name="search_filters">ตัวกรองค้นหา</string>
<string name="no_more_results">ไม่มีผลลัพธ์เพิ่มเติม</string>
<string name="local_library">มังงะภายในเครื่อง</string>
<string name="local_source">มังงะภายในเครื่อง</string>
<string name="other">อื่น ๆ</string>
<string name="global_search">ค้นหาทั้งหมด…</string>
<string name="latest">ล่าสุด</string>

View File

@ -229,7 +229,7 @@
<string name="local">Lokal</string>
<string name="search_filters">Pagsasala sa Paghahanap</string>
<string name="no_more_results">Wala nang mga resulta</string>
<string name="local_library">Lokal na manga</string>
<string name="local_source">Lokal na manga</string>
<string name="other">Iba pa</string>
<string name="global_search">Pangkalahatang paghahanap…</string>
<string name="latest">Pinakabago</string>

View File

@ -215,7 +215,7 @@
<string name="local">Yerel</string>
<string name="search_filters">Arama süzgeçleri</string>
<string name="no_more_results">Başka sonuç yok</string>
<string name="local_library">Yerel manga</string>
<string name="local_source">Yerel manga</string>
<string name="other">Diğer</string>
<string name="global_search">Genel arama…</string>
<string name="latest">En son</string>

View File

@ -216,7 +216,7 @@
<string name="local">Локальна</string>
<string name="search_filters">Пошукові фільтри</string>
<string name="no_more_results">Більше немає результатів</string>
<string name="local_library">Локальна манга</string>
<string name="local_source">Локальна манга</string>
<string name="other">Інші</string>
<string name="global_search">Глобальний пошук…</string>
<string name="latest">Остання</string>

View File

@ -311,7 +311,7 @@
<string name="updates_tracking_details">Cập nhật trạng thái, điểm số và chương cuối đã đọc từ dịch vụ theo dõi</string>
<string name="local">Địa phương</string>
<string name="search_filters">Bộ lọc tìm kiếm</string>
<string name="local_library">Truyện tranh địa phương</string>
<string name="local_source">Truyện tranh địa phương</string>
<string name="other">Khác</string>
<string name="global_search">Tìm kiếm toàn cầu…</string>
<string name="latest">Mới nhất</string>

View File

@ -215,7 +215,7 @@
<string name="local">本地</string>
<string name="search_filters">按分类搜索</string>
<string name="no_more_results">找不到更多结果</string>
<string name="local_library">本地漫画</string>
<string name="local_source">本地漫画</string>
<string name="other">其它</string>
<string name="global_search">全局搜索…</string>
<string name="latest">最近更新</string>

View File

@ -225,7 +225,7 @@
<string name="unknown_error">不明的錯誤</string>
<string name="local">本機</string>
<string name="no_more_results">沒有更多結果</string>
<string name="local_library">本機漫畫</string>
<string name="local_source">本機漫畫</string>
<string name="other">其他</string>
<string name="browse">瀏覽</string>
<string name="description">介紹</string>

View File

@ -204,7 +204,7 @@
<string name="search_filters">Search filters</string>
<string name="no_more_results">No more results</string>
<string name="no_results_found">No results found</string>
<string name="local_library">Local library</string>
<string name="local_source">Local source</string>
<string name="other">Other</string>
<string name="global_search">Global search…</string>
<string name="view_latest">View latest</string>
@ -216,6 +216,8 @@
<string name="sources">Sources</string>
<string name="source_hidden">Source hidden</string>
<string name="last_used">Last Used</string>
<string name="local_source_help_guide">Local source guide</string>
<string name="check_site_in_web">Check website in WebView</string>
<!-- Other Screens -->