Add clear all menu action to calls tab.
This commit is contained in:
parent
c08e108fc3
commit
f8434bede5
4 changed files with 47 additions and 0 deletions
|
@ -88,6 +88,7 @@ class CallLogFragment : Fragment(R.layout.call_log_fragment), CallLogAdapter.Cal
|
|||
|
||||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||
when (menuItem.itemId) {
|
||||
R.id.action_clear_call_history -> clearCallHistory()
|
||||
R.id.action_settings -> startActivity(AppSettingsActivity.home(requireContext()))
|
||||
R.id.action_notification_profile -> NotificationProfileSelectionFragment.show(parentFragmentManager)
|
||||
R.id.action_filter_missed_calls -> filterMissedCalls()
|
||||
|
@ -386,6 +387,29 @@ class CallLogFragment : Fragment(R.layout.call_log_fragment), CallLogAdapter.Cal
|
|||
binding.recyclerCoordinatorAppBar.setExpanded(false, true)
|
||||
}
|
||||
|
||||
private fun clearCallHistory() {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.CallLogFragment__clear_call_history_question)
|
||||
.setMessage(R.string.CallLogFragment__this_will_permanently_delete_all_call_history)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
callLogActionMode.end()
|
||||
viewModel.stageDeleteAll()
|
||||
Snackbar
|
||||
.make(
|
||||
binding.root,
|
||||
R.string.CallLogFragment__cleared_call_history,
|
||||
Snackbar.LENGTH_SHORT
|
||||
)
|
||||
.addCallback(SnackbarDeletionCallback())
|
||||
.setAction(R.string.CallLogFragment__undo) {
|
||||
viewModel.cancelStagedDeletion()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun isSearchOpen(): Boolean {
|
||||
return isSearchVisible() || viewModel.hasSearchQuery
|
||||
}
|
||||
|
|
|
@ -123,6 +123,20 @@ class CallLogViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun stageDeleteAll() {
|
||||
callLogStore.state.stagedDeletion?.cancel()
|
||||
callLogStore.update {
|
||||
it.copy(
|
||||
selectionState = CallLogSelectionState.empty(),
|
||||
stagedDeletion = CallLogStagedDeletion(
|
||||
it.filter,
|
||||
CallLogSelectionState.selectAll(),
|
||||
callLogRepository
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun commitStagedDeletion() {
|
||||
callLogStore.state.stagedDeletion?.commit()
|
||||
callLogStore.update {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/action_clear_call_history" android:title="@string/CallLogFragment__clear_call_history" />
|
||||
<item android:id="@+id/action_filter_missed_calls" android:title="@string/CallLogFragment__filter_missed_calls" />
|
||||
<item android:id="@+id/action_clear_missed_call_filter" android:title="@string/CallLogFragment__clear_filter" />
|
||||
<item android:id="@+id/action_settings" android:title="@string/CallLogFragment__settings" />
|
||||
|
|
|
@ -5959,6 +5959,14 @@
|
|||
<string name="CallContextMenu__delete">Delete</string>
|
||||
|
||||
<!-- Call Log Fragment -->
|
||||
<!-- Snackbar text after clearing the call history -->
|
||||
<string name="CallLogFragment__cleared_call_history">Cleared call history</string>
|
||||
<!-- Dialog title to clear all call events -->
|
||||
<string name="CallLogFragment__clear_call_history_question">Clear call history?</string>
|
||||
<!-- Dialog body to clear all call events -->
|
||||
<string name="CallLogFragment__this_will_permanently_delete_all_call_history">This will permanently delete all call history</string>
|
||||
<!-- Action bar menu item to delete all call events -->
|
||||
<string name="CallLogFragment__clear_call_history">Clear call history</string>
|
||||
<!-- Action bar menu item to only display missed calls -->
|
||||
<string name="CallLogFragment__filter_missed_calls">Filter missed calls</string>
|
||||
<!-- Action bar menu item to clear missed call filter -->
|
||||
|
|
Loading…
Add table
Reference in a new issue