mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 13:50:30 +05:30
feat: add option to also clear watch positions when clearing history in the watch history screen
This commit is contained in:
parent
9fc80a2877
commit
8287e87785
@ -15,6 +15,7 @@ import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.room.withTransaction
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.api.obj.StreamItem
|
||||
import com.github.libretube.constants.PreferenceKeys
|
||||
@ -91,15 +92,23 @@ class WatchHistoryFragment : DynamicLayoutManagerFragment() {
|
||||
binding.filterTypeTV.text = resources.getStringArray(R.array.filterOptions)[selectedTypeFilter]
|
||||
binding.filterStatusTV.text = resources.getStringArray(R.array.filterStatusOptions)[selectedStatusFilter]
|
||||
|
||||
val watchPositionItem = arrayOf("Also clear watch positions")
|
||||
val selected = booleanArrayOf(false)
|
||||
|
||||
binding.clear.setOnClickListener {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.clear_history)
|
||||
.setMessage(R.string.irreversible)
|
||||
.setMultiChoiceItems(watchPositionItem, selected) { _, index, newValue ->
|
||||
selected[index] = newValue
|
||||
}
|
||||
.setPositiveButton(R.string.okay) { _, _ ->
|
||||
binding.historyScrollView.isGone = true
|
||||
binding.historyEmpty.isVisible = true
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
Database.watchHistoryDao().deleteAll()
|
||||
Database.withTransaction {
|
||||
Database.watchHistoryDao().deleteAll()
|
||||
if (selected[0]) Database.watchPositionDao().deleteAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
|
Loading…
Reference in New Issue
Block a user