Finish contentDescriptions

This commit is contained in:
Andrew 2024-06-06 12:21:25 +09:30
parent 6ffb71e6a1
commit f40a0a8a48
10 changed files with 83 additions and 63 deletions

View File

@ -163,7 +163,7 @@ fun EnterAccountId(
if (state.error == null) {
BorderlessButtonSecondary(
text = stringResource(R.string.messageNewDescription),
contentDescription = GetString(R.string.AccessibilityId_help_desk_link),
modifier = Modifier.contentDescription(R.string.AccessibilityId_help_desk_link)
) { onHelp() }
}

View File

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement.Absolute.spacedBy
@ -25,6 +24,7 @@ import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.fragment.app.Fragment
import dagger.hilt.android.AndroidEntryPoint
@ -39,7 +39,6 @@ import org.thoughtcrime.securesms.ui.components.OnPrimaryButtons
import org.thoughtcrime.securesms.ui.components.OutlineButton
import org.thoughtcrime.securesms.ui.components.OutlineTemporaryStateButton
import org.thoughtcrime.securesms.ui.components.SmallButtons
import org.thoughtcrime.securesms.ui.components.TemporaryStateButton
import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.small
@ -53,66 +52,82 @@ class InviteFriendFragment : Fragment() {
): View = ComposeView(requireContext()).apply {
setContent {
AppTheme {
InviteFriend()
InviteFriend(
onBack = { delegate.onDialogBackPressed() },
onClose = { delegate.onDialogClosePressed() },
copyPublicKey = requireContext()::copyPublicKey,
sendInvitation = requireContext()::sendInvitation,
)
}
}
}
}
@Composable
private fun InviteFriend() {
Column(modifier = Modifier.background(MaterialTheme.colors.primarySurface)) {
AppBar(stringResource(R.string.invite_a_friend), onBack = { delegate.onDialogBackPressed() }, onClose = { delegate.onDialogClosePressed() })
Column(
modifier = Modifier.padding(horizontal = 24.dp),
verticalArrangement = spacedBy(10.dp)
) {
Box(
modifier = Modifier
.border(
width = 1.dp,
color = classicDarkColors[5],
shape = RoundedCornerShape(size = 13.dp)
)
.fillMaxWidth()
.wrapContentHeight()
) {
Text(
TextSecurePreferences.getLocalNumber(LocalContext.current)!!,
textAlign = TextAlign.Center,
modifier = Modifier
.contentDescription("Your account ID")
.align(Alignment.Center)
.padding(22.dp)
@Preview
@Composable
private fun PreviewInviteFriend() {
InviteFriend()
}
@Composable
private fun InviteFriend(
onBack: () -> Unit = {},
onClose: () -> Unit = {},
copyPublicKey: () -> Unit = {},
sendInvitation: () -> Unit = {},
) {
Column(modifier = Modifier.background(MaterialTheme.colors.primarySurface)) {
AppBar(stringResource(R.string.invite_a_friend), onBack = onBack, onClose = onClose)
Column(
modifier = Modifier.padding(horizontal = 24.dp),
verticalArrangement = spacedBy(10.dp)
) {
Box(
modifier = Modifier
.border(
width = 1.dp,
color = classicDarkColors[5],
shape = RoundedCornerShape(size = 13.dp)
)
}
.fillMaxWidth()
.wrapContentHeight()
) {
Text(
stringResource(R.string.invite_your_friend_to_chat_with_you_on_session_by_sharing_your_account_id_with_them),
TextSecurePreferences.getLocalNumber(LocalContext.current)!!,
textAlign = TextAlign.Center,
style = MaterialTheme.typography.small,
color = classicDarkColors[5],
modifier = Modifier.padding(horizontal = 8.dp)
modifier = Modifier
.contentDescription("Your account ID")
.align(Alignment.Center)
.padding(22.dp)
)
OnPrimaryButtons {
SmallButtons {
Row(horizontalArrangement = spacedBy(20.dp)) {
OutlineButton(
modifier = Modifier
.weight(1f)
.contentDescription("Share button"),
onClick = { requireContext().sendInvitation() }
) {
Text(stringResource(R.string.share))
}
}
OutlineTemporaryStateButton(
Modifier
.weight(1f)
.contentDescription("Copy button"),
onClick = { requireContext().copyPublicKey() }
) { isTemporary ->
Text(stringResource(if (isTemporary) R.string.copied else R.string.copy))
}
Text(
stringResource(R.string.invite_your_friend_to_chat_with_you_on_session_by_sharing_your_account_id_with_them),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.small,
color = classicDarkColors[5],
modifier = Modifier.padding(horizontal = 8.dp)
)
OnPrimaryButtons {
SmallButtons {
Row(horizontalArrangement = spacedBy(20.dp)) {
OutlineButton(
modifier = Modifier
.weight(1f)
.contentDescription("Share button"),
onClick = sendInvitation
) {
Text(stringResource(R.string.share))
}
OutlineTemporaryStateButton(
Modifier
.weight(1f)
.contentDescription(R.string.AccessibilityId_copy_button),
onClick = copyPublicKey
) { isTemporary ->
Text(stringResource(if (isTemporary) R.string.copied else R.string.copy))
}
}
}

View File

@ -70,7 +70,7 @@ class NewConversationHomeFragment : Fragment() {
Spacer(modifier = Modifier.height(4.dp))
Text(text = stringResource(R.string.qrYoursDescription), color = classicDarkColors[5], style = MaterialTheme.typography.small)
Spacer(modifier = Modifier.height(20.dp))
QrImage(string = TextSecurePreferences.getLocalNumber(requireContext())!!, contentDescription = "Your session id")
QrImage(string = TextSecurePreferences.getLocalNumber(requireContext())!!, contentDescription = stringResource(R.string.AccessibilityId_qr_code))
}
}
}

View File

@ -143,7 +143,7 @@ fun RecoveryPasswordCell(seed: String, copySeed:() -> Unit = {}) {
Text(
seed,
modifier = Modifier
.contentDescription(R.string.AccessibilityId_hide_recovery_password_button)
.contentDescription(R.string.AccessibilityId_recovery_password_container)
.padding(vertical = 24.dp)
.border(
width = 1.dp,
@ -164,7 +164,7 @@ fun RecoveryPasswordCell(seed: String, copySeed:() -> Unit = {}) {
QrImage(
seed,
modifier = Modifier.padding(vertical = 24.dp),
contentDescription = "QR code of your recovery password",
contentDescription = stringResource(R.string.AccessibilityId_qr_code),
icon = R.drawable.session_shield
)
}

View File

@ -91,7 +91,7 @@ fun QrPage(string: String) {
) {
QrImage(
string = string,
contentDescription = "Your session id",
contentDescription = stringResource(R.string.AccessibilityId_qr_code),
modifier = Modifier.padding(top = 32.dp, bottom = 12.dp),
icon = R.drawable.session
)

View File

@ -83,6 +83,7 @@ import org.thoughtcrime.securesms.ui.ItemButtonWithDrawable
import org.thoughtcrime.securesms.ui.components.OutlineButton
import org.thoughtcrime.securesms.ui.components.OutlineTemporaryStateButton
import org.thoughtcrime.securesms.ui.components.TemporaryStateButton
import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.destructiveButtonColors
import org.thoughtcrime.securesms.util.BitmapDecodingException
import org.thoughtcrime.securesms.util.BitmapUtil
@ -402,7 +403,8 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
}
OutlineTemporaryStateButton(
modifier = Modifier.weight(1f),
modifier = Modifier.weight(1f)
.contentDescription(R.string.AccessibilityId_copy_button),
onClick = { copyPublicKey() },
) { isTemporary ->
Text(stringResource(if (isTemporary) R.string.copied else R.string.copy))

View File

@ -148,12 +148,12 @@ fun FilledButton(
@Composable
fun BorderlessButtonSecondary(
text: String,
contentDescription: GetString = GetString(text),
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
BorderlessButton(
text,
contentDescription = contentDescription,
modifier = modifier,
contentColor = MaterialTheme.colors.onSurface.copy(ContentAlpha.medium),
onClick = onClick
)

View File

@ -43,7 +43,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="@string/AccessibilityId_account_id"
android:contentDescription="@string/AccessibilityId_enter_display_name"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:visibility="invisible"

View File

@ -6,7 +6,7 @@
<item
android:id="@+id/action_qr_code"
android:title=""
android:contentDescription="View QR code"
android:contentDescription="@string/AccessibilityId_view_qr_code"
android:icon="@drawable/ic_qr_code_24"
app:showAsAction="always" />

View File

@ -1118,6 +1118,7 @@
<string name="AccessibilityId_recovery_phrase_input">Recovery phrase input</string>
<string name="AccessibilityId_error_message">Error message</string>
<string name="AccessibilityId_hide_recovery_password_button">Hide recovery password button</string>
<string name="AccessibilityId_recovery_password_container">Recovery password container</string>
<string name="AccessibilityId_confirm_button">Confirm button</string>
<string name="AccessibilityId_open_url">Open URL</string>
<string name="accountIdErrorInvalid">This Account ID is invalid. Please check and try again.</string>
@ -1139,4 +1140,6 @@
<string name="AccessibilityId_invite_friend_button">Invite friend button</string>
<string name="AccessibilityId_help_desk_link">Help desk link</string>
<string name="AccessibilityId_copy_button">Copy button</string>
<string name="AccessibilityId_view_qr_code">View QR code</string>
<string name="AccessibilityId_qr_code">QR code</string>
</resources>