diff --git a/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt b/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt index 4cecbbf67a..dba5a254ce 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt @@ -1,6 +1,8 @@ package org.thoughtcrime.securesms import android.content.Context +import android.content.Intent +import android.net.Uri import android.view.LayoutInflater import android.view.View import android.view.ViewGroup.LayoutParams.MATCH_PARENT @@ -147,6 +149,14 @@ fun Context.showOpenUrlDialog(build: SessionDialogBuilder.() -> Unit): AlertDial build() }.show() +fun Context.showOpenUrlDialog(url: String): AlertDialog = + showOpenUrlDialog { + okButton { openUrl(url) } + cancelButton() + } + +fun Context.openUrl(url: String) = Intent(Intent.ACTION_VIEW, Uri.parse(url)).let(::startActivity) + fun Fragment.showSessionDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog = SessionDialogBuilder(requireContext()).apply { build() }.show() fun Fragment.createSessionDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog = diff --git a/app/src/main/java/org/thoughtcrime/securesms/dms/NewMessageFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/dms/NewMessageFragment.kt index df02a8f736..8e9cd2673c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/dms/NewMessageFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/dms/NewMessageFragment.kt @@ -81,12 +81,7 @@ class NewMessageFragment : Fragment() { viewModel, onClose = { delegate.onDialogClosePressed() }, onBack = { delegate.onDialogBackPressed() }, - onHelp = { - requireContext().showOpenUrlDialog { - okButton { Intent(Intent.ACTION_VIEW, Uri.parse("https://sessionapp.zendesk.com/hc/en-us/articles/4439132747033-How-do-Session-ID-usernames-work")).let(::startActivity) } - cancelButton() - } - } + onHelp = { requireContext().showOpenUrlDialog("https://sessionapp.zendesk.com/hc/en-us/articles/4439132747033-How-do-Session-ID-usernames-work") } ) } }