mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 03:55:06 +01:00
Revert removal of tracker start/end date
This commit is contained in:
parent
f85194ec46
commit
0cd551d4fd
@ -22,9 +22,9 @@ data class BackupTracking(
|
||||
@ProtoNumber(8) var score: Float = 0F,
|
||||
@ProtoNumber(9) var status: Int = 0,
|
||||
// startedReadingDate is called startReadTime in 1.x
|
||||
// @ProtoNumber(10) var startedReadingDate: Long = 0,
|
||||
@ProtoNumber(10) var startedReadingDate: Long = 0,
|
||||
// finishedReadingDate is called endReadTime in 1.x
|
||||
// @ProtoNumber(11) var finishedReadingDate: Long = 0,
|
||||
@ProtoNumber(11) var finishedReadingDate: Long = 0,
|
||||
) {
|
||||
fun getTrackingImpl(): TrackImpl {
|
||||
return TrackImpl().apply {
|
||||
@ -37,6 +37,8 @@ data class BackupTracking(
|
||||
total_chapters = this@BackupTracking.totalChapters
|
||||
score = this@BackupTracking.score
|
||||
status = this@BackupTracking.status
|
||||
started_reading_date = this@BackupTracking.startedReadingDate
|
||||
finished_reading_date = this@BackupTracking.finishedReadingDate
|
||||
tracking_url = this@BackupTracking.trackingUrl
|
||||
}
|
||||
}
|
||||
@ -54,6 +56,8 @@ data class BackupTracking(
|
||||
totalChapters = track.total_chapters,
|
||||
score = track.score,
|
||||
status = track.status,
|
||||
startedReadingDate = track.started_reading_date,
|
||||
finishedReadingDate = track.finished_reading_date,
|
||||
trackingUrl = track.tracking_url
|
||||
)
|
||||
}
|
||||
|
@ -56,10 +56,8 @@ class TrackPutResolver : DefaultPutResolver<Track>() {
|
||||
put(COL_STATUS, obj.status)
|
||||
put(COL_TRACKING_URL, obj.tracking_url)
|
||||
put(COL_SCORE, obj.score)
|
||||
|
||||
// These aren't used anymore
|
||||
put(COL_START_DATE, 0)
|
||||
put(COL_FINISH_DATE, 0)
|
||||
put(COL_START_DATE, obj.started_reading_date)
|
||||
put(COL_FINISH_DATE, obj.finished_reading_date)
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,6 +75,8 @@ class TrackGetResolver : DefaultGetResolver<Track>() {
|
||||
status = cursor.getInt(cursor.getColumnIndex(COL_STATUS))
|
||||
score = cursor.getFloat(cursor.getColumnIndex(COL_SCORE))
|
||||
tracking_url = cursor.getString(cursor.getColumnIndex(COL_TRACKING_URL))
|
||||
started_reading_date = cursor.getLong(cursor.getColumnIndex(COL_START_DATE))
|
||||
finished_reading_date = cursor.getLong(cursor.getColumnIndex(COL_FINISH_DATE))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,18 @@ interface Track : Serializable {
|
||||
|
||||
var status: Int
|
||||
|
||||
var started_reading_date: Long
|
||||
|
||||
var finished_reading_date: Long
|
||||
|
||||
var tracking_url: String
|
||||
|
||||
fun copyPersonalFrom(other: Track) {
|
||||
last_chapter_read = other.last_chapter_read
|
||||
score = other.score
|
||||
status = other.status
|
||||
started_reading_date = other.started_reading_date
|
||||
finished_reading_date = other.finished_reading_date
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -22,6 +22,10 @@ class TrackImpl : Track {
|
||||
|
||||
override var status: Int = 0
|
||||
|
||||
override var started_reading_date: Long = 0
|
||||
|
||||
override var finished_reading_date: Long = 0
|
||||
|
||||
override var tracking_url: String = ""
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
@ -21,6 +21,9 @@ abstract class TrackService(val id: Int) {
|
||||
// Name of the manga sync service to display
|
||||
abstract val name: String
|
||||
|
||||
// Application and remote support for reading dates
|
||||
open val supportsReadingDates: Boolean = false
|
||||
|
||||
@DrawableRes
|
||||
abstract fun getLogo(): Int
|
||||
|
||||
|
@ -24,6 +24,10 @@ class TrackSearch : Track {
|
||||
|
||||
override var status: Int = 0
|
||||
|
||||
override var started_reading_date: Long = 0
|
||||
|
||||
override var finished_reading_date: Long = 0
|
||||
|
||||
override lateinit var tracking_url: String
|
||||
|
||||
var cover_url: String = ""
|
||||
|
@ -0,0 +1,85 @@
|
||||
package eu.kanade.tachiyomi.ui.manga.track
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.datetime.datePicker
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Track
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.util.Calendar
|
||||
|
||||
class SetTrackReadingDatesDialog<T> : DialogController
|
||||
where T : Controller, T : SetTrackReadingDatesDialog.Listener {
|
||||
|
||||
private val item: TrackItem
|
||||
|
||||
private val dateToUpdate: ReadingDate
|
||||
|
||||
constructor(target: T, dateToUpdate: ReadingDate, item: TrackItem) : super(
|
||||
bundleOf(KEY_ITEM_TRACK to item.track)
|
||||
) {
|
||||
targetController = target
|
||||
this.item = item
|
||||
this.dateToUpdate = dateToUpdate
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
constructor(bundle: Bundle) : super(bundle) {
|
||||
val track = bundle.getSerializable(KEY_ITEM_TRACK) as Track
|
||||
val service = Injekt.get<TrackManager>().getService(track.sync_id)!!
|
||||
item = TrackItem(track, service)
|
||||
dateToUpdate = ReadingDate.Start
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val listener = (targetController as? Listener)
|
||||
|
||||
return MaterialDialog(activity!!)
|
||||
.title(
|
||||
when (dateToUpdate) {
|
||||
ReadingDate.Start -> R.string.track_started_reading_date
|
||||
ReadingDate.Finish -> R.string.track_finished_reading_date
|
||||
}
|
||||
)
|
||||
.datePicker(currentDate = getCurrentDate()) { _, date ->
|
||||
listener?.setReadingDate(item, dateToUpdate, date.timeInMillis)
|
||||
}
|
||||
.neutralButton(R.string.action_remove) {
|
||||
listener?.setReadingDate(item, dateToUpdate, 0L)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCurrentDate(): Calendar {
|
||||
// Today if no date is set, otherwise the already set date
|
||||
return Calendar.getInstance().apply {
|
||||
item.track?.let {
|
||||
val date = when (dateToUpdate) {
|
||||
ReadingDate.Start -> it.started_reading_date
|
||||
ReadingDate.Finish -> it.finished_reading_date
|
||||
}
|
||||
if (date != 0L) {
|
||||
timeInMillis = date
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun setReadingDate(item: TrackItem, type: ReadingDate, date: Long)
|
||||
}
|
||||
|
||||
enum class ReadingDate {
|
||||
Start,
|
||||
Finish
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val KEY_ITEM_TRACK = "SetTrackReadingDatesDialog.item.track"
|
||||
}
|
||||
}
|
@ -43,5 +43,7 @@ class TrackAdapter(controller: TrackController) : RecyclerView.Adapter<TrackHold
|
||||
fun onStatusClick(position: Int)
|
||||
fun onChaptersClick(position: Int)
|
||||
fun onScoreClick(position: Int)
|
||||
fun onStartDateClick(position: Int)
|
||||
fun onFinishDateClick(position: Int)
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ class TrackController :
|
||||
TrackAdapter.OnClickListener,
|
||||
SetTrackStatusDialog.Listener,
|
||||
SetTrackChaptersDialog.Listener,
|
||||
SetTrackScoreDialog.Listener {
|
||||
SetTrackScoreDialog.Listener,
|
||||
SetTrackReadingDatesDialog.Listener {
|
||||
|
||||
constructor(manga: Manga?) : super(
|
||||
bundleOf(MANGA_EXTRA to (manga?.id ?: 0))
|
||||
@ -154,6 +155,20 @@ class TrackController :
|
||||
SetTrackScoreDialog(this, item).showDialog(router)
|
||||
}
|
||||
|
||||
override fun onStartDateClick(position: Int) {
|
||||
val item = adapter?.getItem(position) ?: return
|
||||
if (item.track == null) return
|
||||
|
||||
SetTrackReadingDatesDialog(this, SetTrackReadingDatesDialog.ReadingDate.Start, item).showDialog(router)
|
||||
}
|
||||
|
||||
override fun onFinishDateClick(position: Int) {
|
||||
val item = adapter?.getItem(position) ?: return
|
||||
if (item.track == null) return
|
||||
|
||||
SetTrackReadingDatesDialog(this, SetTrackReadingDatesDialog.ReadingDate.Finish, item).showDialog(router)
|
||||
}
|
||||
|
||||
override fun setStatus(item: TrackItem, selection: Int) {
|
||||
presenter.setStatus(item, selection)
|
||||
binding.swipeRefresh.isRefreshing = true
|
||||
@ -169,6 +184,14 @@ class TrackController :
|
||||
binding.swipeRefresh.isRefreshing = true
|
||||
}
|
||||
|
||||
override fun setReadingDate(item: TrackItem, type: SetTrackReadingDatesDialog.ReadingDate, date: Long) {
|
||||
when (type) {
|
||||
SetTrackReadingDatesDialog.ReadingDate.Start -> presenter.setStartDate(item, date)
|
||||
SetTrackReadingDatesDialog.ReadingDate.Finish -> presenter.setFinishDate(item, date)
|
||||
}
|
||||
binding.swipeRefresh.isRefreshing = true
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val MANGA_EXTRA = "manga"
|
||||
const val TAG_SEARCH_CONTROLLER = "track_search_controller"
|
||||
|
@ -6,11 +6,16 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.databinding.TrackItemBinding
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.DateFormat
|
||||
|
||||
class TrackHolder(private val binding: TrackItemBinding, adapter: TrackAdapter) : BaseViewHolder(binding.root) {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
private val dateFormat: DateFormat by lazy {
|
||||
preferences.dateFormat()
|
||||
}
|
||||
|
||||
init {
|
||||
val listener = adapter.rowClickListener
|
||||
|
||||
@ -24,6 +29,8 @@ class TrackHolder(private val binding: TrackItemBinding, adapter: TrackAdapter)
|
||||
binding.trackStatus.setOnClickListener { listener.onStatusClick(bindingAdapterPosition) }
|
||||
binding.trackChapters.setOnClickListener { listener.onChaptersClick(bindingAdapterPosition) }
|
||||
binding.trackScore.setOnClickListener { listener.onScoreClick(bindingAdapterPosition) }
|
||||
binding.trackStartDate.setOnClickListener { listener.onStartDateClick(bindingAdapterPosition) }
|
||||
binding.trackFinishDate.setOnClickListener { listener.onFinishDateClick(bindingAdapterPosition) }
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@ -42,6 +49,18 @@ class TrackHolder(private val binding: TrackItemBinding, adapter: TrackAdapter)
|
||||
if (track.total_chapters > 0) track.total_chapters else "-"
|
||||
binding.trackStatus.text = item.service.getStatus(track.status)
|
||||
binding.trackScore.text = if (track.score == 0f) "-" else item.service.displayScore(track)
|
||||
|
||||
if (item.service.supportsReadingDates) {
|
||||
binding.trackStartDate.text =
|
||||
if (track.started_reading_date != 0L) dateFormat.format(track.started_reading_date) else "-"
|
||||
binding.trackFinishDate.text =
|
||||
if (track.finished_reading_date != 0L) dateFormat.format(track.finished_reading_date) else "-"
|
||||
} else {
|
||||
binding.bottomDivider.isVisible = false
|
||||
binding.vertDivider3.isVisible = false
|
||||
binding.trackStartDate.isVisible = false
|
||||
binding.trackFinishDate.isVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,4 +149,16 @@ class TrackPresenter(
|
||||
}
|
||||
updateRemote(track, item.service)
|
||||
}
|
||||
|
||||
fun setStartDate(item: TrackItem, date: Long) {
|
||||
val track = item.track!!
|
||||
track.started_reading_date = date
|
||||
updateRemote(track, item.service)
|
||||
}
|
||||
|
||||
fun setFinishDate(item: TrackItem, date: Long) {
|
||||
val track = item.track!!
|
||||
track.finished_reading_date = date
|
||||
updateRemote(track, item.service)
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@
|
||||
android:layout_marginBottom="8dp"
|
||||
android:alpha="0.25"
|
||||
android:background="?android:attr/textColorHint"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bottom_divider"
|
||||
app:layout_constraintEnd_toStartOf="@+id/track_chapters"
|
||||
app:layout_constraintStart_toEndOf="@+id/track_status"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
@ -133,7 +133,7 @@
|
||||
android:layout_marginBottom="8dp"
|
||||
android:alpha="0.25"
|
||||
android:background="?android:attr/textColorHint"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bottom_divider"
|
||||
app:layout_constraintEnd_toStartOf="@+id/track_score"
|
||||
app:layout_constraintStart_toEndOf="@+id/track_chapters"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
@ -153,6 +153,59 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/top_divider"
|
||||
tools:text="10" />
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_divider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:alpha="0.25"
|
||||
android:background="?android:attr/textColorHint"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/track_score" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/track_start_date"
|
||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/list_item_selector"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:padding="16dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/vert_divider_3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bottom_divider"
|
||||
tools:text="4/16/2020" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vert_divider_3"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:alpha="0.25"
|
||||
android:background="?android:attr/textColorHint"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/track_start_date"
|
||||
app:layout_constraintEnd_toStartOf="@+id/track_finish_date"
|
||||
app:layout_constraintTop_toTopOf="@+id/bottom_divider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/track_finish_date"
|
||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/list_item_selector"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:padding="16dp"
|
||||
app:layout_constraintStart_toEndOf="@+id/vert_divider_3"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bottom_divider"
|
||||
tools:text="4/16/2020" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -569,6 +569,8 @@
|
||||
<string name="status">Status</string>
|
||||
<string name="track_status">Status</string>
|
||||
<string name="track_start_date">Started</string>
|
||||
<string name="track_started_reading_date">Started reading date</string>
|
||||
<string name="track_finished_reading_date">Finished reading date</string>
|
||||
<string name="track_type">Type</string>
|
||||
<string name="track_author">Author</string>
|
||||
<string name="error_invalid_date_supplied">Invalid date supplied</string>
|
||||
|
Loading…
Reference in New Issue
Block a user