mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Add option to clear history
This commit is contained in:
parent
fb81c0eb95
commit
789692c906
4 changed files with 36 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
package eu.kanade.tachiyomi.ui.recents
|
||||
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
import eu.kanade.tachiyomi.data.database.models.History
|
||||
|
@ -21,6 +22,8 @@ import eu.kanade.tachiyomi.util.chapter.ChapterSort
|
|||
import eu.kanade.tachiyomi.util.system.executeOnIO
|
||||
import eu.kanade.tachiyomi.util.system.launchIO
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.system.withUIContext
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancel
|
||||
|
@ -501,6 +504,16 @@ class RecentsPresenter(
|
|||
}
|
||||
}
|
||||
|
||||
fun deleteAllHistory() {
|
||||
presenterScope.launchIO {
|
||||
db.deleteHistory().executeAsBlocking()
|
||||
withUIContext {
|
||||
controller?.activity?.toast(R.string.clear_history_completed)
|
||||
getRecents()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var lastRecents: List<RecentMangaItem>? = null
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@ package eu.kanade.tachiyomi.ui.recents.options
|
|||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.RecentsHistoryViewBinding
|
||||
import eu.kanade.tachiyomi.util.bindToPreference
|
||||
import eu.kanade.tachiyomi.util.system.materialAlertDialog
|
||||
import eu.kanade.tachiyomi.widget.BaseRecentsDisplayView
|
||||
|
||||
class RecentsHistoryView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
|
@ -12,5 +14,15 @@ class RecentsHistoryView @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
override fun inflateBinding() = RecentsHistoryViewBinding.bind(this)
|
||||
override fun initGeneralPreferences() {
|
||||
binding.groupChapters.bindToPreference(preferences.groupChaptersHistory())
|
||||
binding.clearHistory.setOnClickListener {
|
||||
val activity = controller?.activity ?: return@setOnClickListener
|
||||
activity.materialAlertDialog()
|
||||
.setMessage(R.string.clear_history_confirmation)
|
||||
.setPositiveButton(R.string.clear) { _, _ ->
|
||||
controller?.presenter?.deleteAllHistory()
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,5 +20,13 @@
|
|||
android:layout_marginTop="8dp"
|
||||
android:text="@string/group_chapters_together"
|
||||
android:textColor="?attr/colorOnBackground" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/clear_history"
|
||||
style="@style/Theme.Widget.Button.TextButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/clear_history" />
|
||||
|
||||
</LinearLayout>
|
||||
</eu.kanade.tachiyomi.ui.recents.options.RecentsHistoryView>
|
|
@ -271,6 +271,9 @@
|
|||
<string name="only_unread">Only unread</string>
|
||||
<string name="only_downloaded">Only downloaded</string>
|
||||
<string name="unread_or_downloaded">Unread or downloaded</string>
|
||||
<string name="clear_history">Clear history</string>
|
||||
<string name="clear_history_completed">History deleted</string>
|
||||
<string name="clear_history_confirmation">Are you sure? All history will be lost.</string>
|
||||
|
||||
<!-- Recents Settings -->
|
||||
<string name="show_reset_history_button">Show reset history button</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue