This commit is contained in:
Andrew 2024-04-10 12:38:02 +09:30
parent d044a4090d
commit 85c7a23235
2 changed files with 11 additions and 6 deletions

View File

@ -1,6 +1,8 @@
package org.thoughtcrime.securesms package org.thoughtcrime.securesms
import android.content.Context import android.content.Context
import android.content.Intent
import android.net.Uri
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.MATCH_PARENT
@ -147,6 +149,14 @@ fun Context.showOpenUrlDialog(build: SessionDialogBuilder.() -> Unit): AlertDial
build() build()
}.show() }.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 = fun Fragment.showSessionDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog =
SessionDialogBuilder(requireContext()).apply { build() }.show() SessionDialogBuilder(requireContext()).apply { build() }.show()
fun Fragment.createSessionDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog = fun Fragment.createSessionDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog =

View File

@ -81,12 +81,7 @@ class NewMessageFragment : Fragment() {
viewModel, viewModel,
onClose = { delegate.onDialogClosePressed() }, onClose = { delegate.onDialogClosePressed() },
onBack = { delegate.onDialogBackPressed() }, onBack = { delegate.onDialogBackPressed() },
onHelp = { onHelp = { requireContext().showOpenUrlDialog("https://sessionapp.zendesk.com/hc/en-us/articles/4439132747033-How-do-Session-ID-usernames-work") }
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()
}
}
) )
} }
} }