diff --git a/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt b/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt index d5db6ae041..4cecbbf67a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/SessionDialogBuilder.kt @@ -140,6 +140,12 @@ class SessionDialogBuilder(val context: Context) { fun Context.showSessionDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog = SessionDialogBuilder(this).apply { build() }.show() +fun Context.showOpenUrlDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog = + SessionDialogBuilder(this).apply { + title(R.string.urlOpen) + text(R.string.urlOpenBrowser) + build() + }.show() fun Fragment.showSessionDialog(build: SessionDialogBuilder.() -> Unit): AlertDialog = SessionDialogBuilder(requireContext()).apply { build() }.show() 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 18ff88a46e..df02a8f736 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/dms/NewMessageFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/dms/NewMessageFragment.kt @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms.dms import android.content.Intent +import android.net.Uri import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -22,6 +23,7 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter @@ -37,6 +39,7 @@ import org.session.libsession.utilities.recipients.Recipient import org.thoughtcrime.securesms.conversation.start.NewConversationDelegate import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2 import org.thoughtcrime.securesms.dependencies.DatabaseComponent +import org.thoughtcrime.securesms.showOpenUrlDialog import org.thoughtcrime.securesms.ui.AppTheme import org.thoughtcrime.securesms.ui.BorderlessButtonSecondary import org.thoughtcrime.securesms.ui.OutlineButton @@ -78,7 +81,12 @@ class NewMessageFragment : Fragment() { viewModel, onClose = { delegate.onDialogClosePressed() }, onBack = { delegate.onDialogBackPressed() }, - onHelp = { Toast.makeText(requireContext(), "todo, not implemented.", Toast.LENGTH_LONG).show() } + 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() + } + } ) } } @@ -147,9 +155,10 @@ fun EnterAccountId( placeholder = stringResource(R.string.accountIdOrOnsEnter), onChange = callbacks::onChange, onContinue = callbacks::onContinue, - error = state.error?.string() + error = state.error?.string(), ) - BorderlessButtonSecondary(text = stringResource(R.string.messageNewDescription)) { onHelp() } + if (state.error == null) BorderlessButtonSecondary(text = stringResource(R.string.messageNewDescription)) { onHelp() } + Spacer(modifier = Modifier.weight(1f)) OutlineButton( diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/LandingActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/LandingActivity.kt index 8ce485a9b5..c173eb9d42 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/LandingActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/LandingActivity.kt @@ -31,6 +31,7 @@ import org.thoughtcrime.securesms.BaseActionBarActivity import org.thoughtcrime.securesms.crypto.IdentityKeyUtil import org.thoughtcrime.securesms.onboarding.pickname.startPickDisplayNameActivity import org.thoughtcrime.securesms.service.KeyCachingService +import org.thoughtcrime.securesms.showOpenUrlDialog import org.thoughtcrime.securesms.showSessionDialog import org.thoughtcrime.securesms.ui.AppTheme import org.thoughtcrime.securesms.ui.BorderlessButton @@ -120,9 +121,7 @@ class LandingActivity : BaseActionBarActivity() { } private fun openDialog() { - showSessionDialog { - title(R.string.urlOpen) - text(R.string.urlOpenBrowser) + showOpenUrlDialog { button( R.string.activity_landing_terms_of_service, contentDescriptionRes = R.string.AccessibilityId_terms_of_service_link diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt index 86bf5153ea..0a2fe09eea 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt @@ -9,6 +9,7 @@ import androidx.compose.material.OutlinedTextField import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import org.thoughtcrime.securesms.ui.baseBold import org.thoughtcrime.securesms.ui.outlinedTextFieldColors @@ -17,10 +18,10 @@ import org.thoughtcrime.securesms.ui.outlinedTextFieldColors fun SessionOutlinedTextField( text: String, placeholder: String, + modifier: Modifier = Modifier, onChange: (String) -> Unit, onContinue: () -> Unit, - error: String? = null, - modifier: Modifier + error: String? = null ) { Column(modifier = modifier) { OutlinedTextField( @@ -42,6 +43,7 @@ fun SessionOutlinedTextField( Text( it, modifier = Modifier.padding(top = 12.dp), + textAlign = TextAlign.Center, style = MaterialTheme.typography.baseBold, color = MaterialTheme.colors.error )