From a9cf7f9d8cc56de631df51e00190501113cb94ff Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 26 May 2019 20:37:35 +0200 Subject: [PATCH] show the warning at deleting a folder in red --- .../gallery/pro/adapters/DirectoryAdapter.kt | 6 ++-- .../pro/dialogs/ConfirmDeleteFolderDialog.kt | 31 +++++++++++++++++++ .../layout/dialog_confirm_delete_folder.xml | 29 +++++++++++++++++ 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ConfirmDeleteFolderDialog.kt create mode 100644 app/src/main/res/layout/dialog_confirm_delete_folder.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index f4d1e1da5..965250340 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -23,6 +23,7 @@ import com.simplemobiletools.commons.views.FastScroller import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.MediaActivity +import com.simplemobiletools.gallery.pro.dialogs.ConfirmDeleteFolderDialog import com.simplemobiletools.gallery.pro.dialogs.ExcludeFolderDialog import com.simplemobiletools.gallery.pro.dialogs.PickMediumDialog import com.simplemobiletools.gallery.pro.extensions.* @@ -399,10 +400,9 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList Unit) { + var dialog: AlertDialog + + init { + val view = activity.layoutInflater.inflate(R.layout.dialog_confirm_delete_folder, null) + view.message.text = message + view.message_warning.text = warningMessage + + val builder = AlertDialog.Builder(activity) + .setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed() } + + builder.setNegativeButton(R.string.no, null) + + dialog = builder.create().apply { + activity.setupDialogStuff(view, this) + } + } + + private fun dialogConfirmed() { + dialog.dismiss() + callback() + } +} diff --git a/app/src/main/res/layout/dialog_confirm_delete_folder.xml b/app/src/main/res/layout/dialog_confirm_delete_folder.xml new file mode 100644 index 000000000..220c36f09 --- /dev/null +++ b/app/src/main/res/layout/dialog_confirm_delete_folder.xml @@ -0,0 +1,29 @@ + + + + + + + +