Add a confirmation dialog when deleting a feed group

This commit is contained in:
Mauricio Colli 2020-03-05 20:27:00 -03:00
parent 98c65d8ddb
commit d8b9d353aa
No known key found for this signature in database
GPG key ID: F200BFD6F29DDD85
3 changed files with 37 additions and 1 deletions

View file

@ -45,6 +45,7 @@ class FeedGroupDialog : DialogFragment() {
object InitialScreen : ScreenState()
object SubscriptionsPicker : ScreenState()
object IconPickerList : ScreenState()
object DeleteScreen : ScreenState()
}
@State @JvmField var selectedIcon: FeedGroupIcon? = null
@ -104,7 +105,7 @@ class FeedGroupDialog : DialogFragment() {
setupIconPicker()
delete_button.setOnClickListener { viewModel.deleteGroup() }
delete_button.setOnClickListener { showDeleteScreen() }
cancel_button.setOnClickListener {
if (currentScreen !is ScreenState.InitialScreen) {
@ -149,6 +150,8 @@ class FeedGroupDialog : DialogFragment() {
NO_GROUP_SELECTED -> viewModel.createGroup(name, icon, selectedSubscriptions)
else -> viewModel.updateGroup(name, icon, selectedSubscriptions, groupSortOrder)
}
} else if (currentScreen is ScreenState.DeleteScreen) {
viewModel.deleteGroup()
} else {
showInitialScreen()
}
@ -158,6 +161,7 @@ class FeedGroupDialog : DialogFragment() {
is ScreenState.InitialScreen -> showInitialScreen()
is ScreenState.IconPickerList -> showIconPicker()
is ScreenState.SubscriptionsPicker -> showSubscriptionsPicker()
is ScreenState.DeleteScreen -> showDeleteScreen()
}
}
@ -287,6 +291,7 @@ class FeedGroupDialog : DialogFragment() {
animateView(icon_selector, false, 0)
animateView(subscriptions_selector, false, 0)
animateView(options_root, true, 250)
animateView(delete_screen_message, false, 0)
separator.visibility = View.GONE
confirm_button.setText(if (groupId == NO_GROUP_SELECTED) R.string.create else android.R.string.ok)
@ -299,6 +304,7 @@ class FeedGroupDialog : DialogFragment() {
animateView(icon_selector, true, 250)
animateView(subscriptions_selector, false, 0)
animateView(options_root, false, 0)
animateView(delete_screen_message, false, 0)
separator.visibility = View.VISIBLE
confirm_button.setText(android.R.string.ok)
@ -313,6 +319,7 @@ class FeedGroupDialog : DialogFragment() {
animateView(icon_selector, false, 0)
animateView(subscriptions_selector, true, 250)
animateView(options_root, false, 0)
animateView(delete_screen_message, false, 0)
separator.visibility = View.VISIBLE
confirm_button.setText(android.R.string.ok)
@ -322,6 +329,21 @@ class FeedGroupDialog : DialogFragment() {
hideKeyboard()
}
private fun showDeleteScreen() {
currentScreen = ScreenState.DeleteScreen
animateView(icon_selector, false, 0)
animateView(subscriptions_selector, false, 0)
animateView(options_root, false, 0)
animateView(delete_screen_message, true, 250)
separator.visibility = View.GONE
confirm_button.setText(android.R.string.ok)
delete_button.visibility = View.GONE
cancel_button.visibility = View.VISIBLE
hideKeyboard()
}
///////////////////////////////////////////////////////////////////////////
// Utils
///////////////////////////////////////////////////////////////////////////

View file

@ -143,6 +143,19 @@
tools:listitem="@layout/picker_subscription_item"
tools:spanCount="4" />
</LinearLayout>
<TextView
android:id="@+id/delete_screen_message"
style="@style/TextAppearance.AppCompat.Subhead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:paddingLeft="?dialogPreferredPadding"
android:paddingTop="16dp"
android:paddingRight="?dialogPreferredPadding"
android:paddingBottom="16dp"
android:text="@string/feed_group_dialog_delete_message"
android:visibility="visible" />
</FrameLayout>
<View

View file

@ -610,6 +610,7 @@
<string name="feed_group_dialog_empty_selection">No subscription selected</string>
<string name="feed_group_dialog_empty_name">Empty group name</string>
<string name="feed_group_dialog_name_input">Name</string>
<string name="feed_group_dialog_delete_message">Do you want to delete this group?</string>
<string name="feed_create_new_group_button_title">New</string>
<string name="settings_category_feed_title">Feed</string>