Added Tracking status to manga details buttons

all's thats left is the tracking button action
This commit is contained in:
Jay 2020-03-04 23:27:39 -08:00
parent 87ed315ad5
commit 96d322afbe
44 changed files with 92 additions and 58 deletions

View File

@ -179,7 +179,6 @@ class LibraryPresenter(
return@f false
if (filterTracked != STATE_IGNORE) {
val db = Injekt.get<DatabaseHelper>()
val tracks = db.getTracks(item.manga).executeAsBlocking()
val trackCount = loggedServices.count { service ->

View File

@ -12,12 +12,14 @@ import eu.kanade.tachiyomi.data.database.models.LibraryManga
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.database.models.MangaCategory
import eu.kanade.tachiyomi.data.database.models.MangaImpl
import eu.kanade.tachiyomi.data.database.models.Track
import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
import eu.kanade.tachiyomi.data.library.LibraryServiceListener
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.model.SChapter
@ -58,6 +60,10 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
var hasRequested = false
var isLoading = false
private val loggedServices by lazy { Injekt.get<TrackManager>().services.filter { it.isLogged } }
var tracks = emptyList<Track>()
var chapters:List<ChapterItem> = emptyList()
private set
@ -77,6 +83,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
}
else {
updateChapters()
tracks = db.getTracks(manga).executeAsBlocking()
controller.updateChapters(this.chapters)
}
}
@ -449,9 +456,10 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
asyncUpdateMangaAndChapters()
}
private fun asyncUpdateMangaAndChapters() {
private fun asyncUpdateMangaAndChapters(justChapters:Boolean = false) {
launch {
withContext(Dispatchers.IO) { db.updateFlags(manga).executeAsBlocking() }
if (!justChapters)
withContext(Dispatchers.IO) { db.updateFlags(manga).executeAsBlocking() }
updateChapters()
withContext(Dispatchers.Main) { controller.updateChapters(chapters) }
}
@ -518,6 +526,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
coverCache.deleteFromCache(manga.thumbnail_url)
db.resetMangaInfo(manga).executeAsBlocking()
downloadManager.deleteManga(manga, source)
asyncUpdateMangaAndChapters(true)
}
fun setFavorite(favorite: Boolean) {
@ -650,4 +659,8 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
}
return false
}
fun isTracked(): Boolean {
return loggedServices.any { service -> tracks.any { it.sync_id == service.id } }
}
}

View File

@ -9,6 +9,7 @@ import androidx.core.graphics.ColorUtils
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.signature.ObjectKey
import com.google.android.material.button.MaterialButton
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.database.models.MangaImpl
@ -47,6 +48,7 @@ class MangaHeaderHolder(
}
filter_button.setOnClickListener { adapter.coverListener?.showChapterFilter() }
filters_text.setOnClickListener { adapter.coverListener?.showChapterFilter() }
chapters_title.setOnClickListener { adapter.coverListener?.showChapterFilter() }
share_button.setOnClickListener { adapter.coverListener?.prepareToShareManga() }
favorite_button.setOnClickListener {
adapter.coverListener?.favoriteManga(false)
@ -116,23 +118,22 @@ class MangaHeaderHolder(
else -> R.string.add_to_library
}
)
backgroundTintList =
ContextCompat.getColorStateList(context, android.R.color.transparent)
if (!item.isLocked && manga.favorite) {
backgroundTintList =
ColorStateList.valueOf(
ColorUtils.setAlphaComponent(
context.getResourceColor(R.attr.colorAccent), 75))
strokeColor = ColorStateList.valueOf(Color.TRANSPARENT)
}
else strokeColor = ColorStateList.valueOf(
ColorUtils.setAlphaComponent(
itemView.context.getResourceColor(R.attr
.colorOnSurface), 31))
checked(!item.isLocked && manga.favorite)
}
true_backdrop.setBackgroundColor(adapter.coverListener.coverColor() ?:
itemView.context.getResourceColor(android.R.attr.colorBackground))
val tracked = presenter.isTracked() && !item.isLocked
with(track_button) {
text = itemView.context.getString(if (tracked) R.string.action_filter_tracked
else R.string.tracking)
icon = ContextCompat.getDrawable(itemView.context, if (tracked) R.drawable
.ic_check_white_24dp else R.drawable.ic_sync_black_24dp)
checked(tracked)
}
with(start_reading_button) {
val nextChapter = presenter.getNextUnreadChapter()
visibleIf(nextChapter != null && !item.isLocked)
@ -180,6 +181,27 @@ class MangaHeaderHolder(
.into(backdrop)
}
private fun MaterialButton.checked(checked: Boolean) {
if (checked) {
backgroundTintList = ColorStateList.valueOf(
ColorUtils.setAlphaComponent(
context.getResourceColor(R.attr.colorAccent), 75
)
)
strokeColor = ColorStateList.valueOf(Color.TRANSPARENT)
} else {
strokeColor = ColorStateList.valueOf(
ColorUtils.setAlphaComponent(
itemView.context.getResourceColor(
R.attr.colorOnSurface
), 31
)
)
backgroundTintList =
ContextCompat.getColorStateList(context, android.R.color.transparent)
}
}
fun setTopHeight(newHeight: Int) {
top_view.updateLayoutParams<ConstraintLayout.LayoutParams> {
height = newHeight

View File

@ -12,7 +12,7 @@ object MigrationFlags {
private const val CATEGORIES2 = 0x2
private const val TRACK2 = 0x4
val titles get() = arrayOf(R.string.chapters, R.string.categories, R.string.track)
val titles get() = arrayOf(R.string.chapters, R.string.categories, R.string.tracking)
val flags get() = arrayOf(CHAPTERS, CATEGORIES, TRACK)

View File

@ -203,7 +203,7 @@ class SettingsBackupController : SettingsController() {
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val activity = activity!!
val options = arrayOf(R.string.manga, R.string.categories, R.string.chapters,
R.string.track, R.string.history)
R.string.tracking, R.string.history)
.map { activity.getString(it) }
return MaterialDialog(activity)

View File

@ -214,7 +214,7 @@
<View
android:id="@+id/more_bg_gradient"
android:layout_width="50dp"
android:layout_height="20dp"
android:layout_height="20sp"
android:layout_marginEnd="30dp"
android:background="@drawable/full_gradient"
android:backgroundTint="?android:attr/colorBackground"
@ -224,7 +224,7 @@
<View
android:id="@+id/more_bg_solid"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_height="20sp"
android:layout_marginStart="45dp"
android:background="?android:attr/colorBackground"
app:layout_constraintBottom_toBottomOf="@id/manga_summary"

View File

@ -62,7 +62,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:checked="true"
android:text="@string/track"
android:text="@string/tracking"
app:layout_constraintBottom_toBottomOf="@+id/mig_categories"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"

View File

@ -4,7 +4,7 @@
<string name="categories">اﻷقسام</string>
<string name="manga">المانجا</string>
<string name="chapters">الفصول</string>
<string name="track">التتبع</string>
<string name="tracking">التتبع</string>
<string name="history">السجل</string>
<string name="label_settings">اﻹعدادات</string>
<string name="label_download_queue">طابور التنزيل</string>

View File

@ -298,7 +298,7 @@
<string name="download_notifier_no_network">Няма налична мрежова връзка</string>
<string name="categories">Категории</string>
<string name="manga">Манга</string>
<string name="track">Следене</string>
<string name="tracking">Следене</string>
<string name="history">История</string>
<string name="action_sort_total">Общ брой глави</string>
<string name="action_close">Затвори</string>

View File

@ -4,7 +4,7 @@
<string name="categories">ধরণ</string>
<string name="manga">মাংগা</string>
<string name="chapters">অধ্যায়গুলো</string>
<string name="track">অনুসরণকরণ</string>
<string name="tracking">অনুসরণকরণ</string>
<string name="history">ইতিহাস</string>
<string name="label_settings">সেটিংস</string>
<string name="label_download_queue">ডাউনলোড</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Categories</string>
<string name="manga">Manga</string>
<string name="chapters">Capítols</string>
<string name="track">En seguiment</string>
<string name="tracking">En seguiment</string>
<string name="history">Historial</string>
<string name="label_settings">Configuració</string>
<string name="label_download_queue">Cua de descàrregues</string>

View File

@ -194,7 +194,7 @@
<string name="download_notifier_download_paused">Stahování pozastaveno</string>
<string name="label_download_queue">Stahovací fronta</string>
<string name="name">Název</string>
<string name="track">Sledování</string>
<string name="tracking">Sledování</string>
<string name="label_catalogues">Katalogy</string>
<string name="label_recent_updates">Aktualizace knihovny</string>
<string name="action_filter_bookmarked">Založeno</string>

View File

@ -296,7 +296,7 @@
<string name="download_notifier_text_only_wifi">Keine WLAN-Verbindung verfügbar</string>
<string name="download_notifier_no_network">Kein Netzwerk verfügbar</string>
<string name="download_notifier_download_paused">Herunterladen pausiert</string>
<string name="track">Synchronisation</string>
<string name="tracking">Synchronisation</string>
<string name="label_recent_updates">Neu verfügbare Kapitel</string>
<string name="other_source">Andere</string>
<string name="action_global_search_hint">Globale Suche…</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Κατηγορίες</string>
<string name="manga">Manga</string>
<string name="chapters">Κεφάλαια</string>
<string name="track">Παρακολούθηση</string>
<string name="tracking">Παρακολούθηση</string>
<string name="history">Ιστορία</string>
<string name="label_settings">Ρυθμίσεις</string>
<string name="label_download_queue">Ουρά λήψεων</string>

View File

@ -233,7 +233,7 @@
<string name="download_notifier_text_only_wifi">Conexión Wi-Fi no disponible</string>
<string name="categories">Categorías</string>
<string name="manga">Manga</string>
<string name="track">Seguimiento</string>
<string name="tracking">Seguimiento</string>
<string name="history">Historial</string>
<string name="action_filter_bookmarked">Marcado</string>
<string name="action_filter_read">Leído</string>

View File

@ -3,7 +3,7 @@
<string name="name">Nimi</string>
<string name="categories">Kategoriat</string>
<string name="manga">Manga</string>
<string name="track">Seuranta</string>
<string name="tracking">Seuranta</string>
<string name="history">Historia</string>
<string name="label_settings">Asetukset</string>
<string name="label_download_queue">Latausjono</string>

View File

@ -311,7 +311,7 @@
<string name="restore_completed">Restauration terminée</string>
<string name="file_saved">Fichier enregistré dans %1$s</string>
<string name="backup_choice">Que voulez-vous sauvegarder ?</string>
<string name="track">Suivi</string>
<string name="tracking">Suivi</string>
<string name="action_sort_total">Nombre de chapitres</string>
<string name="short_recent_updates">Mises à jour</string>
<string name="pref_download_new_categories">Catégories à inclure dans le téléchargement</string>

View File

@ -4,7 +4,7 @@
<string name="categories">श्रेणियाँ</string>
<string name="manga">मांगा</string>
<string name="chapters">अध्याय</string>
<string name="track">पदचिह्न</string>
<string name="tracking">पदचिह्न</string>
<string name="history">इतिहास</string>
<string name="label_settings">सेटिंग्स</string>
<string name="label_download_queue">डाउनलोड कतार</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Kategóriák</string>
<string name="manga">Manga</string>
<string name="chapters">Fejezetek</string>
<string name="track">Nyilvántartás</string>
<string name="tracking">Nyilvántartás</string>
<string name="history">Előzmények</string>
<string name="label_settings">Beállítások</string>
<string name="label_recent_manga">Legutóbb olvasott</string>

View File

@ -3,7 +3,7 @@
<string name="categories">Kategori</string>
<string name="manga">Manga</string>
<string name="chapters">Bab</string>
<string name="track">Pelacakan</string>
<string name="tracking">Pelacakan</string>
<string name="history">Riwayat</string>
<string name="label_settings">Pengaturan</string>
<string name="label_download_queue">Sedang diunduh</string>

View File

@ -297,7 +297,7 @@
<string name="update_weekly">Settimanalmente</string>
<string name="amoled_theme">Tema AMOLED</string>
<string name="default_category">Categoria predefinita</string>
<string name="track">Monitoraggio</string>
<string name="tracking">Monitoraggio</string>
<string name="pref_category_tracking">Monitoraggio</string>
<string name="default_category_summary">Chiedi sempre</string>
<string name="pref_crop_borders">Ritaglia bordi</string>

View File

@ -30,7 +30,7 @@
<string name="action_display_grid">グリッド</string>
<string name="action_display_list">リスト</string>
<string name="action_sort">ソート</string>
<string name="track">追跡</string>
<string name="tracking">追跡</string>
<string name="label_extensions">拡張機能</string>
<string name="label_extension_info">拡張機能の情報</string>
<string name="label_migration">ソース移行</string>

View File

@ -4,7 +4,7 @@
<string name="categories">카테고리</string>
<string name="manga">만화</string>
<string name="chapters">챕터</string>
<string name="track">동기화</string>
<string name="tracking">동기화</string>
<string name="label_selected">%1$d 선택됨</string>
<string name="action_filter">필터</string>
<string name="action_filter_downloaded">다운로드됨</string>

View File

@ -3,7 +3,7 @@
<string name="categories">Kategorijas</string>
<string name="manga">Manga</string>
<string name="chapters">Nodaļas</string>
<string name="track">Sekošana</string>
<string name="tracking">Sekošana</string>
<string name="history">Vēsture</string>
<string name="label_settings">Iestatījumi</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Kategori</string>
<string name="manga">Manga</string>
<string name="chapters">Bab-bab</string>
<string name="track">Penjejakan</string>
<string name="tracking">Penjejakan</string>
<string name="history">Sejarah</string>
<string name="label_settings">Tetapan</string>
<string name="label_download_queue">Giliran muat turun</string>

View File

@ -118,7 +118,7 @@
<string name="pref_show_page_number">Vis sidenummer</string>
<string name="pref_keep_screen_on">Behold skjerm på</string>
<string name="pref_reader_navigation">Navigasjon</string>
<string name="track">Sporing</string>
<string name="tracking">Sporing</string>
<string name="action_open_in_web_view">Nettvisning</string>
<string name="pref_category_tracking">Sporing</string>
<string name="portrait">Stående</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Categorieën</string>
<string name="manga">Manga</string>
<string name="chapters">Hoofdstukken</string>
<string name="track">Tracking</string>
<string name="tracking">Tracking</string>
<string name="history">Geschiedenis</string>
<string name="label_settings">Instellingen</string>
<string name="label_library">Mijn bibliotheek</string>

View File

@ -117,7 +117,7 @@
<string name="download_notifier_download_paused">Pobieranie wstrzymane</string>
<string name="label_selected">Zaznaczono: %1$d</string>
<string name="action_sort_alpha">Alfabetycznie</string>
<string name="track">Śledzenie</string>
<string name="tracking">Śledzenie</string>
<string name="action_reset">Reset</string>
<string name="services">Usługi śledzenia</string>
<string name="version">Wersja</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Categorias</string>
<string name="manga">Mangá</string>
<string name="chapters">Capítulos</string>
<string name="track">Monitoramento</string>
<string name="tracking">Monitoramento</string>
<string name="history">Histórico</string>
<string name="label_settings">Configurações</string>
<string name="label_download_queue">Fila de download</string>

View File

@ -241,7 +241,7 @@
<string name="download_notifier_text_only_wifi">Sem ligação de Wi-Fi disponível</string>
<string name="categories">Categorias</string>
<string name="manga">Mangá</string>
<string name="track">Manutenção</string>
<string name="tracking">Manutenção</string>
<string name="history">Histórico</string>
<string name="label_extensions">Extensões</string>
<string name="label_extension_info">Info. da extensão</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Categorii</string>
<string name="manga">Manga</string>
<string name="chapters">Capitole</string>
<string name="track">Urmărind</string>
<string name="tracking">Urmărind</string>
<string name="history">Istoric</string>
<string name="label_settings">Setări</string>
<string name="label_download_queue">Descărcări în așteptare</string>

View File

@ -583,7 +583,7 @@
<string name="title">Название</string>
<string name="track">Отслеживание</string>
<string name="tracking">Отслеживание</string>
<string name="track_start_date">Начато</string>
<string name="track_status">Статус</string>
<string name="track_type">Тип</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Categorias</string>
<string name="manga">Manga</string>
<string name="chapters">Capìtulos</string>
<string name="track">Arrastamentu</string>
<string name="tracking">Arrastamentu</string>
<string name="history">Cronologia</string>
<string name="label_settings">Impostatziones</string>
<string name="label_download_queue">Fila de sos iscarrigamentos</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Kategórie</string>
<string name="manga">Manga</string>
<string name="chapters">Kapitoly</string>
<string name="track">Sledovanie</string>
<string name="tracking">Sledovanie</string>
<string name="history">História</string>
<string name="label_settings">Nastavenia</string>
<string name="label_download_queue">Sťahujúce sa</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Kategorije</string>
<string name="manga">Manga</string>
<string name="chapters">Poglavlje</string>
<string name="track">Praćenje</string>
<string name="tracking">Praćenje</string>
<string name="history">Istorija</string>
<string name="label_settings">Podešavanja</string>
<string name="label_download_queue">Redosled preuzimanja</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Kategorier</string>
<string name="manga">Manga</string>
<string name="chapters">Kapitel</string>
<string name="track">Spårning</string>
<string name="tracking">Spårning</string>
<string name="history">Historik</string>
<string name="label_settings">Inställningar</string>
<string name="label_download_queue">Nedladdningskö</string>

View File

@ -4,7 +4,7 @@
<string name="categories">หมวดหมู่</string>
<string name="manga">มังงะ</string>
<string name="chapters">ตอน</string>
<string name="track">ดังต่อไปนี้</string>
<string name="tracking">ดังต่อไปนี้</string>
<string name="history">ประวัติศาสตร์</string>
<string name="label_settings">ตั้งค่า</string>
<string name="label_download_queue">คิวดาวน์โหลด</string>

View File

@ -3,7 +3,7 @@
<string name="categories">Mga Kategorya</string>
<string name="manga">Mga Manga</string>
<string name="chapters">Mga Kabanata</string>
<string name="track">Sinusundan</string>
<string name="tracking">Sinusundan</string>
<string name="history">Kasaysayan</string>
<string name="label_settings">Pagsasaayos</string>
<string name="label_download_queue">Toka sa Download</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Kategoriler</string>
<string name="manga">Manga</string>
<string name="chapters">Bölümler</string>
<string name="track">İzleme</string>
<string name="tracking">İzleme</string>
<string name="history">Geçmiş</string>
<string name="label_settings">Ayarlar</string>
<string name="label_download_queue">İndirme kuyruğu</string>

View File

@ -4,7 +4,7 @@
<string name="categories">Категорії</string>
<string name="manga">Манга</string>
<string name="chapters">Глави</string>
<string name="track">Відстеження</string>
<string name="tracking">Відстеження</string>
<string name="history">Історія</string>
<string name="label_settings">Налаштування</string>
<string name="label_download_queue">Черга завантаження</string>

View File

@ -295,7 +295,7 @@
<string name="download_notifier_download_paused">Tải xuống đã tạm dừng</string>
<string name="categories">Hạng mục</string>
<string name="manga">Truyện</string>
<string name="track">Theo dõi</string>
<string name="tracking">Theo dõi</string>
<string name="history">Lịch sử</string>
<string name="label_migration">Di chuyển nguồn</string>
<string name="label_extensions">Tiện ích mở rộng</string>

View File

@ -64,7 +64,7 @@
<string name="action_save">保存</string>
<string name="action_reset">重置</string>
<string name="action_undo">撤销</string>
<string name="track">同步</string>
<string name="tracking">同步</string>
<string name="label_migration">来源迁移</string>
<string name="action_mark_previous_as_read">标记之前章节已读</string>
<string name="action_create">创建</string>

View File

@ -338,7 +338,7 @@
<string name="transition_pages_error">第 %1$s 頁載入失敗</string>
<string name="information_no_recent">沒有新章節</string>
<string name="name">名稱</string>
<string name="track">追隨中</string>
<string name="tracking">追隨中</string>
<string name="pref_category_tracking">跟隨中</string>
<string name="pref_auto_update_manga_sync">閱讀完後同步章節</string>
<string name="ext_trust">信任</string>

View File

@ -10,7 +10,7 @@
<string name="manhua">Manhua</string>
<string name="comic">Comic</string>
<string name="chapters">Chapters</string>
<string name="track">Tracking</string>
<string name="tracking">Tracking</string>
<string name="history">History</string>
<!-- Activities and fragments labels (toolbar title) -->