diff --git a/app/build.gradle b/app/build.gradle index ed0055f..7989de5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,7 +65,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:7df0d79980' + implementation 'com.github.SimpleMobileTools:Simple-Commons:c070dff787' kapt 'androidx.room:room-compiler:2.4.2' implementation 'androidx.room:room-runtime:2.4.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/AddOrEditClipDialog.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/AddOrEditClipDialog.kt index 03e51c1..ab8dc89 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/AddOrEditClipDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/AddOrEditClipDialog.kt @@ -2,13 +2,9 @@ package com.simplemobiletools.keyboard.dialogs import androidx.appcompat.app.AlertDialog import com.simplemobiletools.commons.activities.BaseSimpleActivity -import com.simplemobiletools.commons.extensions.setupDialogStuff -import com.simplemobiletools.commons.extensions.showKeyboard -import com.simplemobiletools.commons.extensions.toast -import com.simplemobiletools.commons.extensions.value +import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.keyboard.R -import com.simplemobiletools.keyboard.extensions.clipsDB import com.simplemobiletools.keyboard.helpers.ClipsHelper import com.simplemobiletools.keyboard.models.Clip import kotlinx.android.synthetic.main.dialog_add_or_edit_clip.view.* @@ -21,13 +17,13 @@ class AddOrEditClipDialog(val activity: BaseSimpleActivity, val originalClip: Cl } } - AlertDialog.Builder(activity) + activity.getAlertDialogBuilder() .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) - .create().apply { - activity.setupDialogStuff(view, this) { - showKeyboard(view.add_clip_value) - getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { + .apply { + activity.setupDialogStuff(view, this) { alertDialog -> + alertDialog.showKeyboard(view.add_clip_value) + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { val clipValue = view.add_clip_value.value if (clipValue.isEmpty()) { activity.toast(R.string.value_cannot_be_empty) @@ -43,7 +39,7 @@ class AddOrEditClipDialog(val activity: BaseSimpleActivity, val originalClip: Cl ClipsHelper(activity).insertClip(clip) activity.runOnUiThread { callback() - dismiss() + alertDialog.dismiss() } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/ExportClipsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/ExportClipsDialog.kt index 83c4c3e..f4c80d2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/ExportClipsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/ExportClipsDialog.kt @@ -37,12 +37,12 @@ class ExportClipsDialog( } } - AlertDialog.Builder(activity) + activity.getAlertDialogBuilder() .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) - .create().apply { - activity.setupDialogStuff(view, this, R.string.export_clipboard_items) { - getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { + .apply { + activity.setupDialogStuff(view, this, R.string.export_clipboard_items) { alertDialog -> + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { val filename = view.export_clips_filename.value if (filename.isEmpty()) { activity.toast(R.string.filename_cannot_be_empty) @@ -60,11 +60,11 @@ class ExportClipsDialog( val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newPath.getFilenameFromPath()) ConfirmationDialog(activity, title) { callback(newPath, filename) - dismiss() + alertDialog.dismiss() } } else { callback(newPath, filename) - dismiss() + alertDialog.dismiss() } } }