mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-26 01:37:43 +00:00
Refactor
This commit is contained in:
parent
d044a4090d
commit
85c7a23235
@ -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 =
|
||||||
|
@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user