From f6d3c38d03b87f9db52eb2a615cd449f5710a856 Mon Sep 17 00:00:00 2001 From: Andreas E Date: Sat, 3 Oct 2020 16:54:42 +0200 Subject: [PATCH] Ability to delete reading history (#3871) * Added ability to delete history for all manga * Fix review comments (cherry picked from commit 812368e332b56a3b8964e7c1247c9fbc18804516) --- .../ui/setting/SettingsAdvancedController.kt | 26 +++++++++++++++++++ app/src/main/res/values/strings.xml | 4 +++ 2 files changed, 30 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index edab951ac..7838b718b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -114,6 +114,16 @@ class SettingsAdvancedController : SettingsController() { ctrl.showDialog(router) } } + preference { + titleRes = R.string.pref_clear_history + summaryRes = R.string.pref_clear_history_summary + + onClick { + val ctrl = ClearHistoryDialogController() + ctrl.targetController = this@SettingsAdvancedController + ctrl.showDialog(router) + } + } } preferenceCategory { @@ -402,6 +412,22 @@ class SettingsAdvancedController : SettingsController() { } } + class ClearHistoryDialogController : DialogController() { + override fun onCreateDialog(savedViewState: Bundle?): Dialog { + return MaterialDialog(activity!!) + .message(R.string.clear_history_confirmation) + .positiveButton(android.R.string.ok) { + (targetController as? SettingsAdvancedController)?.clearHistory() + } + .negativeButton(android.R.string.cancel) + } + } + + private fun clearHistory() { + db.deleteHistory().executeAsBlocking() + activity?.toast(R.string.clear_history_completed) + } + private fun clearDatabase() { db.deleteMangasNotInLibrary().executeAsBlocking() db.deleteHistoryNoLastRead().executeAsBlocking() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f1774c807..fef57fd49 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -403,6 +403,10 @@ Helps with background library updates and backups Battery optimization is already disabled Couldn\'t open device settings + History deleted + Are you sure? All history will be lost. + Clear history + Delete reading history for all manga Website