From b0f3ac99a4f34910ebed3f84a3da12b0411cb7f4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 4 Dec 2016 10:27:53 +0100 Subject: [PATCH] make sure dialogs are cancellable by clicking outside --- .../gallery/dialogs/ChangeSortingDialog.kt | 6 ++++-- .../com/simplemobiletools/gallery/dialogs/CopyDialog.kt | 1 + .../simplemobiletools/gallery/dialogs/PickAlbumDialog.kt | 1 + .../gallery/dialogs/RenameDirectoryDialog.kt | 1 + .../simplemobiletools/gallery/dialogs/RenameFileDialog.kt | 1 + .../com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt | 1 + 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt index f3a8011b4..357c430cd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ChangeSortingDialog.kt @@ -20,13 +20,15 @@ class ChangeSortingDialog(val activity: Activity, val isDirectorySorting: Boolea config = Config.newInstance(activity) view = LayoutInflater.from(activity).inflate(R.layout.dialog_change_sorting, null) - AlertDialog.Builder(activity) + val dialog = AlertDialog.Builder(activity) .setTitle(activity.resources.getString(R.string.sort_by)) .setView(view) .setPositiveButton(R.string.ok, this) .setNegativeButton(R.string.cancel, null) .create() - .show() + + dialog.setCanceledOnTouchOutside(true) + dialog.show() currSorting = if (isDirectorySorting) config.directorySorting else config.sorting setupSortRadio() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt index cba853a19..2598b7b8f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt @@ -39,6 +39,7 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList, val c .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) + setCanceledOnTouchOutside(true) show() getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ if (destinationPath == context.resources.getString(R.string.select_destination) || destinationPath.isEmpty()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt index 1272ea837..fb023fa4c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt @@ -25,6 +25,7 @@ class PickAlbumDialog(val activity: SimpleActivity, val callback: (path: String) .setNegativeButton(R.string.cancel, null) .create() + dialog.setCanceledOnTouchOutside(true) dialog.show() GetDirectoriesAsynctask(activity, false, false, ArrayList()) { val adapter = DirectoryAdapter(activity, it, null) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt index 101b9fc55..7e09aebf6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt @@ -25,6 +25,7 @@ class RenameDirectoryDialog(val activity: SimpleActivity, val dir: File, val cal .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) + setCanceledOnTouchOutside(true) show() getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ val newDirName = view.directory_name.value diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt index ebb7470f4..9c0dacb13 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt @@ -34,6 +34,7 @@ class RenameFileDialog(val activity: SimpleActivity, val file: File, val callbac .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) + setCanceledOnTouchOutside(true) show() getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ val fileName = view.file_name.value diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt index 627ae71f6..abbe56a34 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt @@ -24,6 +24,7 @@ class SaveAsDialog(val activity: Activity, val path: String, val callback: (file .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) + setCanceledOnTouchOutside(true) show() getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ val filename = view.file_name.value