Revert removal of last chapter/updated from manga info
Cette révision appartient à :
Parent
0c988d95ee
révision
0601bedb0b
7 fichiers modifiés avec 122 ajouts et 3 suppressions
|
@ -28,6 +28,7 @@ import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersController
|
||||||
import eu.kanade.tachiyomi.ui.manga.info.MangaInfoController
|
import eu.kanade.tachiyomi.ui.manga.info.MangaInfoController
|
||||||
import eu.kanade.tachiyomi.ui.manga.track.TrackController
|
import eu.kanade.tachiyomi.ui.manga.track.TrackController
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
import java.util.Date
|
||||||
import kotlinx.android.synthetic.main.main_activity.tabs
|
import kotlinx.android.synthetic.main.main_activity.tabs
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
|
@ -64,6 +65,10 @@ class MangaController : RxController<PagerControllerBinding>, TabbedController {
|
||||||
|
|
||||||
val fromSource = args.getBoolean(FROM_SOURCE_EXTRA, false)
|
val fromSource = args.getBoolean(FROM_SOURCE_EXTRA, false)
|
||||||
|
|
||||||
|
val lastUpdateRelay: BehaviorRelay<Date> = BehaviorRelay.create()
|
||||||
|
|
||||||
|
val chapterCountRelay: BehaviorRelay<Float> = BehaviorRelay.create()
|
||||||
|
|
||||||
val mangaFavoriteRelay: PublishRelay<Boolean> = PublishRelay.create()
|
val mangaFavoriteRelay: PublishRelay<Boolean> = PublishRelay.create()
|
||||||
|
|
||||||
private val trackingIconRelay: BehaviorRelay<Boolean> = BehaviorRelay.create()
|
private val trackingIconRelay: BehaviorRelay<Boolean> = BehaviorRelay.create()
|
||||||
|
|
|
@ -71,7 +71,10 @@ class ChaptersController :
|
||||||
|
|
||||||
override fun createPresenter(): ChaptersPresenter {
|
override fun createPresenter(): ChaptersPresenter {
|
||||||
val ctrl = parentController as MangaController
|
val ctrl = parentController as MangaController
|
||||||
return ChaptersPresenter(ctrl.manga!!, ctrl.source!!, ctrl.mangaFavoriteRelay)
|
return ChaptersPresenter(
|
||||||
|
ctrl.manga!!, ctrl.source!!,
|
||||||
|
ctrl.chapterCountRelay, ctrl.lastUpdateRelay, ctrl.mangaFavoriteRelay
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.ui.manga.chapter
|
package eu.kanade.tachiyomi.ui.manga.chapter
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import com.jakewharton.rxrelay.BehaviorRelay
|
||||||
import com.jakewharton.rxrelay.PublishRelay
|
import com.jakewharton.rxrelay.PublishRelay
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
|
@ -13,6 +14,7 @@ import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||||
import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed
|
import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed
|
||||||
|
import java.util.Date
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import rx.android.schedulers.AndroidSchedulers
|
import rx.android.schedulers.AndroidSchedulers
|
||||||
|
@ -27,6 +29,8 @@ import uy.kohesive.injekt.api.get
|
||||||
class ChaptersPresenter(
|
class ChaptersPresenter(
|
||||||
val manga: Manga,
|
val manga: Manga,
|
||||||
val source: Source,
|
val source: Source,
|
||||||
|
private val chapterCountRelay: BehaviorRelay<Float>,
|
||||||
|
private val lastUpdateRelay: BehaviorRelay<Date>,
|
||||||
private val mangaFavoriteRelay: PublishRelay<Boolean>,
|
private val mangaFavoriteRelay: PublishRelay<Boolean>,
|
||||||
val preferences: PreferencesHelper = Injekt.get(),
|
val preferences: PreferencesHelper = Injekt.get(),
|
||||||
private val db: DatabaseHelper = Injekt.get(),
|
private val db: DatabaseHelper = Injekt.get(),
|
||||||
|
@ -86,6 +90,20 @@ class ChaptersPresenter(
|
||||||
|
|
||||||
// Listen for download status changes
|
// Listen for download status changes
|
||||||
observeDownloads()
|
observeDownloads()
|
||||||
|
|
||||||
|
// Emit the number of chapters to the info tab.
|
||||||
|
chapterCountRelay.call(
|
||||||
|
chapters.maxBy { it.chapter_number }?.chapter_number
|
||||||
|
?: 0f
|
||||||
|
)
|
||||||
|
|
||||||
|
// Emit the upload date of the most recent chapter
|
||||||
|
lastUpdateRelay.call(
|
||||||
|
Date(
|
||||||
|
chapters.maxBy { it.date_upload }?.date_upload
|
||||||
|
?: 0
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.subscribe { chaptersRelay.call(it) }
|
.subscribe { chaptersRelay.call(it) }
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
|
import eu.kanade.tachiyomi.data.glide.toMangaThumbnail
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.databinding.MangaInfoControllerBinding
|
import eu.kanade.tachiyomi.databinding.MangaInfoControllerBinding
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
|
@ -37,6 +38,9 @@ import eu.kanade.tachiyomi.util.view.setChips
|
||||||
import eu.kanade.tachiyomi.util.view.snack
|
import eu.kanade.tachiyomi.util.view.snack
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
|
import java.text.DateFormat
|
||||||
|
import java.text.DecimalFormat
|
||||||
|
import java.util.Date
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.android.view.clicks
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
|
@ -57,13 +61,20 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||||
|
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
|
private val dateFormat: DateFormat by lazy {
|
||||||
|
preferences.dateFormat().getOrDefault()
|
||||||
|
}
|
||||||
|
|
||||||
private var initialLoad: Boolean = true
|
private var initialLoad: Boolean = true
|
||||||
|
|
||||||
private var thumbnailUrl: String? = null
|
private var thumbnailUrl: String? = null
|
||||||
|
|
||||||
override fun createPresenter(): MangaInfoPresenter {
|
override fun createPresenter(): MangaInfoPresenter {
|
||||||
val ctrl = parentController as MangaController
|
val ctrl = parentController as MangaController
|
||||||
return MangaInfoPresenter(ctrl.manga!!, ctrl.source!!, ctrl.mangaFavoriteRelay)
|
return MangaInfoPresenter(
|
||||||
|
ctrl.manga!!, ctrl.source!!,
|
||||||
|
ctrl.chapterCountRelay, ctrl.lastUpdateRelay, ctrl.mangaFavoriteRelay
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||||
|
@ -316,6 +327,27 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||||
binding.mangaGenresTagsFullChips.visibleIf { !isExpanded }
|
binding.mangaGenresTagsFullChips.visibleIf { !isExpanded }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update chapter count TextView.
|
||||||
|
*
|
||||||
|
* @param count number of chapters.
|
||||||
|
*/
|
||||||
|
fun setChapterCount(count: Float) {
|
||||||
|
if (count > 0f) {
|
||||||
|
binding.mangaChapters.text = DecimalFormat("#.#").format(count)
|
||||||
|
} else {
|
||||||
|
binding.mangaChapters.text = resources?.getString(R.string.unknown)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setLastUpdateDate(date: Date) {
|
||||||
|
if (date.time != 0L) {
|
||||||
|
binding.mangaLastUpdate.text = dateFormat.format(date)
|
||||||
|
} else {
|
||||||
|
binding.mangaLastUpdate.text = resources?.getString(R.string.unknown)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles the favorite status and asks for confirmation to delete downloaded chapters.
|
* Toggles the favorite status and asks for confirmation to delete downloaded chapters.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.ui.manga.info
|
package eu.kanade.tachiyomi.ui.manga.info
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import com.jakewharton.rxrelay.BehaviorRelay
|
||||||
import com.jakewharton.rxrelay.PublishRelay
|
import com.jakewharton.rxrelay.PublishRelay
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
|
@ -11,6 +12,7 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed
|
import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed
|
||||||
|
import java.util.Date
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import rx.android.schedulers.AndroidSchedulers
|
import rx.android.schedulers.AndroidSchedulers
|
||||||
|
@ -26,6 +28,8 @@ import uy.kohesive.injekt.api.get
|
||||||
class MangaInfoPresenter(
|
class MangaInfoPresenter(
|
||||||
val manga: Manga,
|
val manga: Manga,
|
||||||
val source: Source,
|
val source: Source,
|
||||||
|
private val chapterCountRelay: BehaviorRelay<Float>,
|
||||||
|
private val lastUpdateRelay: BehaviorRelay<Date>,
|
||||||
private val mangaFavoriteRelay: PublishRelay<Boolean>,
|
private val mangaFavoriteRelay: PublishRelay<Boolean>,
|
||||||
private val db: DatabaseHelper = Injekt.get(),
|
private val db: DatabaseHelper = Injekt.get(),
|
||||||
private val downloadManager: DownloadManager = Injekt.get(),
|
private val downloadManager: DownloadManager = Injekt.get(),
|
||||||
|
@ -46,10 +50,18 @@ class MangaInfoPresenter(
|
||||||
super.onCreate(savedState)
|
super.onCreate(savedState)
|
||||||
sendMangaToView()
|
sendMangaToView()
|
||||||
|
|
||||||
|
// Update chapter count
|
||||||
|
chapterCountRelay.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribeLatestCache(MangaInfoController::setChapterCount)
|
||||||
|
|
||||||
// Update favorite status
|
// Update favorite status
|
||||||
mangaFavoriteRelay.observeOn(AndroidSchedulers.mainThread())
|
mangaFavoriteRelay.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe { setFavorite(it) }
|
.subscribe { setFavorite(it) }
|
||||||
.apply { add(this) }
|
.apply { add(this) }
|
||||||
|
|
||||||
|
// update last update date
|
||||||
|
lastUpdateRelay.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribeLatestCache(MangaInfoController::setLastUpdateDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -98,6 +98,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/manga_info_author_label"
|
android:text="@string/manga_info_author_label"
|
||||||
android:textIsSelectable="false"
|
android:textIsSelectable="false"
|
||||||
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/manga_full_title" />
|
app:layout_constraintTop_toBottomOf="@+id/manga_full_title" />
|
||||||
|
|
||||||
|
@ -137,6 +138,52 @@
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/manga_artist_label" />
|
app:layout_constraintStart_toEndOf="@+id/manga_artist_label" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/manga_chapters_label"
|
||||||
|
style="@style/TextAppearance.Medium.Body2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/manga_info_last_chapter_label"
|
||||||
|
android:textIsSelectable="false"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/manga_artist_label" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/manga_chapters"
|
||||||
|
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textIsSelectable="false"
|
||||||
|
app:layout_constraintBaseline_toBaselineOf="@+id/manga_chapters_label"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/manga_chapters_label" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/manga_last_update_label"
|
||||||
|
style="@style/TextAppearance.Medium.Body2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/manga_info_latest_data_label"
|
||||||
|
android:textIsSelectable="false"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/manga_chapters_label" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/manga_last_update"
|
||||||
|
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textIsSelectable="false"
|
||||||
|
app:layout_constraintBaseline_toBaselineOf="@+id/manga_last_update_label"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/manga_last_update_label" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/manga_status_label"
|
android:id="@+id/manga_status_label"
|
||||||
style="@style/TextAppearance.Medium.Body2"
|
style="@style/TextAppearance.Medium.Body2"
|
||||||
|
@ -145,7 +192,7 @@
|
||||||
android:text="@string/manga_info_status_label"
|
android:text="@string/manga_info_status_label"
|
||||||
android:textIsSelectable="false"
|
android:textIsSelectable="false"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/manga_artist_label" />
|
app:layout_constraintTop_toBottomOf="@+id/manga_last_update_label" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/manga_status"
|
android:id="@+id/manga_status"
|
||||||
|
|
|
@ -421,6 +421,8 @@
|
||||||
<string name="manga_info_author_label">Author</string>
|
<string name="manga_info_author_label">Author</string>
|
||||||
<string name="manga_info_artist_label">Artist</string>
|
<string name="manga_info_artist_label">Artist</string>
|
||||||
<string name="manga_info_chapters_label">Chapters</string>
|
<string name="manga_info_chapters_label">Chapters</string>
|
||||||
|
<string name="manga_info_last_chapter_label">Last chapter</string>
|
||||||
|
<string name="manga_info_latest_data_label">Updated</string>
|
||||||
<string name="manga_info_status_label">Status</string>
|
<string name="manga_info_status_label">Status</string>
|
||||||
<string name="manga_info_source_label">Source</string>
|
<string name="manga_info_source_label">Source</string>
|
||||||
<string name="manga_info_genres_label">Genres</string>
|
<string name="manga_info_genres_label">Genres</string>
|
||||||
|
|
Référencer dans un nouveau ticket