From a612ecbae11815f1433da0b01cadc274fc0399d2 Mon Sep 17 00:00:00 2001 From: Uwe Trottmann Date: Wed, 11 Dec 2024 15:52:43 +0100 Subject: [PATCH] Lists: move delete list button to the edge, use save action string --- .../lists/ListManageDialogFragment.kt | 43 +++++++++++-------- .../main/res/layout/dialog_list_manage.xml | 12 +++--- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/battlelancer/seriesguide/lists/ListManageDialogFragment.kt b/app/src/main/java/com/battlelancer/seriesguide/lists/ListManageDialogFragment.kt index 6dad887dfd..5b940e47b1 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/lists/ListManageDialogFragment.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/lists/ListManageDialogFragment.kt @@ -39,24 +39,29 @@ class ListManageDialogFragment : AppCompatDialogFragment() { this.binding = binding // buttons - binding.buttonNegative.isEnabled = false - binding.buttonNegative.setText(R.string.list_remove) - binding.buttonNegative.setOnClickListener { - // ask about removing list - DeleteListDialogFragment.create(listId) - .safeShow(parentFragmentManager, "confirm-delete-list") - dismiss() + binding.buttonListManageDelete.apply { + isEnabled = false + setText(R.string.list_remove) + setOnClickListener { + // ask about removing list + DeleteListDialogFragment.create(listId) + .safeShow(parentFragmentManager, "confirm-delete-list") + dismiss() + } } - binding.buttonPositive.setText(android.R.string.ok) - binding.buttonPositive.setOnClickListener { - val editText = this.binding?.textInputLayoutListManageListName?.editText - ?: return@setOnClickListener - - // update title - val listName = editText.text.toString().trim() - ListsTools.renameList(requireContext(), listId, listName) - - dismiss() + binding.buttonListManageConfirm.apply { + setText(R.string.action_save) + setOnClickListener { + val editText = + this@ListManageDialogFragment.binding?.textInputLayoutListManageListName?.editText + ?: return@setOnClickListener + + // update title + val listName = editText.text.toString().trim() + ListsTools.renameList(requireContext(), listId, listName) + + dismiss() + } } // Delay loading data for views to after this function @@ -95,14 +100,14 @@ class ListManageDialogFragment : AppCompatDialogFragment() { editTextName.addTextChangedListener( AddListDialogFragment.ListNameTextWatcher( requireContext(), textInputLayoutName, - binding.buttonPositive, listName + binding.buttonListManageConfirm, listName ) ) // do only allow removing if this is NOT the last list val listsCount = listHelper.getListsCount() if (listsCount > 1) { - binding.buttonNegative.isEnabled = true + binding.buttonListManageDelete.isEnabled = true } } diff --git a/app/src/main/res/layout/dialog_list_manage.xml b/app/src/main/res/layout/dialog_list_manage.xml index 368a0daad9..652eb287be 100644 --- a/app/src/main/res/layout/dialog_list_manage.xml +++ b/app/src/main/res/layout/dialog_list_manage.xml @@ -15,7 +15,8 @@ + android:layout_height="wrap_content" + app:endIconMode="clear_text"> @@ -38,12 +39,13 @@ android:paddingRight="@dimen/large_padding" android:paddingBottom="@dimen/inline_padding"> +