Ask for user confirmation before deleting Widget

This commit is contained in:
Benoit Marty 2022-01-04 14:32:03 +01:00
parent 5340d16e1f
commit d52e61413d

View file

@ -160,7 +160,7 @@ class WidgetFragment @Inject constructor() :
return@withState true return@withState true
} }
R.id.action_delete -> { R.id.action_delete -> {
viewModel.handle(WidgetAction.DeleteWidget) deleteWidget()
return@withState true return@withState true
} }
R.id.action_refresh -> if (state.formattedURL.complete) { R.id.action_refresh -> if (state.formattedURL.complete) {
@ -172,7 +172,7 @@ class WidgetFragment @Inject constructor() :
return@withState true return@withState true
} }
R.id.action_revoke -> if (state.status == WidgetStatus.WIDGET_ALLOWED) { R.id.action_revoke -> if (state.status == WidgetStatus.WIDGET_ALLOWED) {
viewModel.handle(WidgetAction.RevokeWidget) revokeWidget()
return@withState true return@withState true
} }
} }
@ -306,7 +306,7 @@ class WidgetFragment @Inject constructor() :
) )
} }
fun deleteWidget() { private fun deleteWidget() {
MaterialAlertDialogBuilder(requireContext()) MaterialAlertDialogBuilder(requireContext())
.setMessage(R.string.widget_delete_message_confirmation) .setMessage(R.string.widget_delete_message_confirmation)
.setPositiveButton(R.string.remove) { _, _ -> .setPositiveButton(R.string.remove) { _, _ ->
@ -316,7 +316,7 @@ class WidgetFragment @Inject constructor() :
.show() .show()
} }
fun revokeWidget() { private fun revokeWidget() {
viewModel.handle(WidgetAction.RevokeWidget) viewModel.handle(WidgetAction.RevokeWidget)
} }
} }