mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-26 20:55:10 +00:00
Add clear all menu action to calls tab.
This commit is contained in:
committed by
Cody Henthorne
parent
c08e108fc3
commit
f8434bede5
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user