From d8b9d353aa0a69d1055183e87c4ba0fac0207e70 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Thu, 5 Mar 2020 20:27:00 -0300 Subject: [PATCH] Add a confirmation dialog when deleting a feed group --- .../subscription/dialog/FeedGroupDialog.kt | 24 ++++++++++++++++++- .../res/layout/dialog_feed_group_create.xml | 13 ++++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt index 3307c2078..aa6576d90 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt @@ -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 /////////////////////////////////////////////////////////////////////////// diff --git a/app/src/main/res/layout/dialog_feed_group_create.xml b/app/src/main/res/layout/dialog_feed_group_create.xml index 03a152434..364a6c891 100644 --- a/app/src/main/res/layout/dialog_feed_group_create.xml +++ b/app/src/main/res/layout/dialog_feed_group_create.xml @@ -143,6 +143,19 @@ tools:listitem="@layout/picker_subscription_item" tools:spanCount="4" /> + + No subscription selected Empty group name Name + Do you want to delete this group? New Feed