From 9cf99480d6019e7400909424f8b85424b3b41db8 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 7 Aug 2023 23:01:03 +0930 Subject: [PATCH] Fix shareLogs() canceled by early dismiss() (#1295) --- .../org/thoughtcrime/securesms/SessionDialogBuilder.kt | 10 +++++----- .../securesms/preferences/ShareLogsDialog.kt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt b/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt index 141a98e4ac..3fb5e2787c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt @@ -111,16 +111,16 @@ class SessionDialogBuilder(val context: Context) { text, contentDescription, R.style.Widget_Session_Button_Dialog_DestructiveText, - listener - ) + ) { listener() } - fun okButton(listener: (() -> Unit) = {}) = button(android.R.string.ok, listener = listener) - fun cancelButton(listener: (() -> Unit) = {}) = button(android.R.string.cancel, R.string.AccessibilityId_cancel_button, listener = listener) + fun okButton(listener: (() -> Unit) = {}) = button(android.R.string.ok) { listener() } + fun cancelButton(listener: (() -> Unit) = {}) = button(android.R.string.cancel, R.string.AccessibilityId_cancel_button) { listener() } fun button( @StringRes text: Int, @StringRes contentDescriptionRes: Int = text, @StyleRes style: Int = R.style.Widget_Session_Button_Dialog_UnimportantText, + dismiss: Boolean = false, listener: (() -> Unit) = {} ) = Button(context, null, 0, style).apply { setText(text) @@ -129,7 +129,7 @@ class SessionDialogBuilder(val context: Context) { .apply { setMargins(toPx(20, resources)) } setOnClickListener { listener.invoke() - dismiss() + if (dismiss) dismiss() } }.let(buttonLayout::addView) diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt index e3be429e3a..2dc5e75d98 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/ShareLogsDialog.kt @@ -40,7 +40,7 @@ class ShareLogsDialog : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog = createSessionDialog { title(R.string.dialog_share_logs_title) text(R.string.dialog_share_logs_explanation) - button(R.string.share) { shareLogs() } + button(R.string.share, dismiss = false) { shareLogs() } cancelButton { dismiss() } }