mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Fix ItemButton contentDescriptions
This commit is contained in:
parent
253fe9136d
commit
8fd653c9d4
@ -111,7 +111,7 @@ fun ColumnScope.Items(
|
||||
Divider(startIndent = LocalDimensions.current.dividerIndent)
|
||||
ItemButton(textId = R.string.dialog_join_community_title, icon = R.drawable.ic_globe, onClick = delegate::onJoinCommunitySelected)
|
||||
Divider(startIndent = LocalDimensions.current.dividerIndent)
|
||||
ItemButton(textId = R.string.activity_settings_invite_button_title, icon = R.drawable.ic_invite_friend, contentDescription = R.string.AccessibilityId_invite_friend_button, onClick = delegate::onInviteFriend)
|
||||
ItemButton(textId = R.string.activity_settings_invite_button_title, icon = R.drawable.ic_invite_friend, Modifier.contentDescription(R.string.AccessibilityId_invite_friend_button), onClick = delegate::onInviteFriend)
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = LocalDimensions.current.marginMedium)
|
||||
|
@ -218,7 +218,7 @@ fun CellButtons(
|
||||
Column {
|
||||
onReply?.let {
|
||||
ItemButton(
|
||||
stringResource(R.string.reply),
|
||||
R.string.reply,
|
||||
R.drawable.ic_message_details__reply,
|
||||
onClick = it
|
||||
)
|
||||
@ -226,14 +226,14 @@ fun CellButtons(
|
||||
}
|
||||
onResend?.let {
|
||||
ItemButton(
|
||||
stringResource(R.string.resend),
|
||||
R.string.resend,
|
||||
R.drawable.ic_message_details__refresh,
|
||||
onClick = it
|
||||
)
|
||||
Divider()
|
||||
}
|
||||
ItemButton(
|
||||
stringResource(R.string.delete),
|
||||
R.string.delete,
|
||||
R.drawable.ic_message_details__trash,
|
||||
colors = destructiveButtonColors(),
|
||||
onClick = onDelete
|
||||
|
@ -117,7 +117,7 @@ class LandingActivity: BaseActionBarActivity() {
|
||||
}
|
||||
|
||||
Column {
|
||||
/*Column(modifier = Modifier
|
||||
Column(modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = LocalDimensions.current.marginMedium)) {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
@ -149,7 +149,7 @@ class LandingActivity: BaseActionBarActivity() {
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
}*/
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.padding(horizontal = LocalDimensions.current.marginLarge)) {
|
||||
PrimaryFillButton(
|
||||
|
@ -81,6 +81,7 @@ import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||
import org.thoughtcrime.securesms.ui.components.OutlineCopyButton
|
||||
import org.thoughtcrime.securesms.ui.color.destructiveButtonColors
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.setThemedContent
|
||||
import org.thoughtcrime.securesms.util.BitmapDecodingException
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil
|
||||
@ -412,27 +413,27 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
|
||||
Cell {
|
||||
Column {
|
||||
ItemButtonWithDrawable(R.string.activity_path_title, icon = if (hasPaths) R.drawable.ic_status else R.drawable.ic_path_yellow) { show<PathActivity>() }
|
||||
ItemButtonWithDrawable(R.string.activity_path_title, if (hasPaths) R.drawable.ic_status else R.drawable.ic_path_yellow) { show<PathActivity>() }
|
||||
Divider()
|
||||
ItemButton(R.string.activity_settings_privacy_button_title, icon = R.drawable.ic_privacy_icon) { show<PrivacySettingsActivity>() }
|
||||
ItemButton(R.string.activity_settings_privacy_button_title, R.drawable.ic_privacy_icon) { show<PrivacySettingsActivity>() }
|
||||
Divider()
|
||||
ItemButton(R.string.activity_settings_notifications_button_title, icon = R.drawable.ic_speaker, contentDescription = R.string.AccessibilityId_notifications) { show<NotificationSettingsActivity>() }
|
||||
ItemButton(R.string.activity_settings_notifications_button_title, R.drawable.ic_speaker, Modifier.contentDescription(R.string.AccessibilityId_notifications)) { show<NotificationSettingsActivity>() }
|
||||
Divider()
|
||||
ItemButton(R.string.activity_settings_conversations_button_title, icon = R.drawable.ic_conversations, contentDescription = R.string.AccessibilityId_conversations) { show<ChatSettingsActivity>() }
|
||||
ItemButton(R.string.activity_settings_conversations_button_title, R.drawable.ic_conversations, Modifier.contentDescription(R.string.AccessibilityId_conversations)) { show<ChatSettingsActivity>() }
|
||||
Divider()
|
||||
ItemButton(R.string.activity_settings_message_requests_button_title, icon = R.drawable.ic_message_requests, contentDescription = R.string.AccessibilityId_message_requests) { show<MessageRequestsActivity>() }
|
||||
ItemButton(R.string.activity_settings_message_requests_button_title, R.drawable.ic_message_requests, Modifier.contentDescription(R.string.AccessibilityId_message_requests)) { show<MessageRequestsActivity>() }
|
||||
Divider()
|
||||
ItemButton(R.string.activity_settings_message_appearance_button_title, icon = R.drawable.ic_appearance, contentDescription = R.string.AccessibilityId_appearance) { show<AppearanceSettingsActivity>() }
|
||||
ItemButton(R.string.activity_settings_message_appearance_button_title, R.drawable.ic_appearance, Modifier.contentDescription(R.string.AccessibilityId_appearance)) { show<AppearanceSettingsActivity>() }
|
||||
Divider()
|
||||
ItemButton(R.string.activity_settings_invite_button_title, icon = R.drawable.ic_invite_friend, contentDescription = R.string.AccessibilityId_invite_friend) { sendInvitationToUseSession() }
|
||||
ItemButton(R.string.activity_settings_invite_button_title, R.drawable.ic_invite_friend, Modifier.contentDescription(R.string.AccessibilityId_invite_friend)) { sendInvitationToUseSession() }
|
||||
Divider()
|
||||
if (!prefs.getHidePassword()) {
|
||||
ItemButton(R.string.sessionRecoveryPassword, icon = R.drawable.ic_recovery_phrase, contentDescription = R.string.AccessibilityId_recovery_password_menu_item) { show<RecoveryPasswordActivity>() }
|
||||
ItemButton(R.string.sessionRecoveryPassword, R.drawable.ic_recovery_phrase, Modifier.contentDescription(R.string.AccessibilityId_recovery_password_menu_item)) { show<RecoveryPasswordActivity>() }
|
||||
Divider()
|
||||
}
|
||||
ItemButton(R.string.activity_settings_help_button, icon = R.drawable.ic_help, contentDescription = R.string.AccessibilityId_help) { show<HelpSettingsActivity>() }
|
||||
ItemButton(R.string.activity_settings_help_button, R.drawable.ic_help, Modifier.contentDescription(R.string.AccessibilityId_help)) { show<HelpSettingsActivity>() }
|
||||
Divider()
|
||||
ItemButton(R.string.activity_settings_clear_all_data_button_title, colors = destructiveButtonColors(), icon = R.drawable.ic_clear_data, contentDescription = R.string.AccessibilityId_clear_data) { ClearAllDataDialog().show(supportFragmentManager, "Clear All Data Dialog") }
|
||||
ItemButton(R.string.activity_settings_clear_all_data_button_title, R.drawable.ic_clear_data, Modifier.contentDescription(R.string.AccessibilityId_clear_data), destructiveButtonColors()) { ClearAllDataDialog().show(supportFragmentManager, "Clear All Data Dialog") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,21 +109,11 @@ fun <T> OptionsCard(card: OptionsCard<T>, callbacks: Callbacks<T>) {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ItemButton(
|
||||
@StringRes textId: Int,
|
||||
@DrawableRes icon: Int,
|
||||
colors: ButtonColors = transparentButtonColors(),
|
||||
@StringRes contentDescription: Int = textId,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
ItemButton(stringResource(textId), icon, colors, stringResource(contentDescription), onClick)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ItemButtonWithDrawable(
|
||||
@StringRes textId: Int,
|
||||
@DrawableRes icon: Int,
|
||||
modifier: Modifier = Modifier,
|
||||
colors: ButtonColors = transparentButtonColors(),
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
@ -131,6 +121,7 @@ fun ItemButtonWithDrawable(
|
||||
|
||||
ItemButton(
|
||||
text = stringResource(textId),
|
||||
modifier = modifier,
|
||||
icon = {
|
||||
Image(
|
||||
painter = rememberDrawablePainter(drawable = AppCompatResources.getDrawable(context, icon)),
|
||||
@ -143,20 +134,24 @@ fun ItemButtonWithDrawable(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Courtesy [ItemButton] implementation that takes a [DrawableRes] for the [icon]
|
||||
*/
|
||||
@Composable
|
||||
fun ItemButton(
|
||||
text: String,
|
||||
@StringRes textId: Int,
|
||||
@DrawableRes icon: Int,
|
||||
modifier: Modifier = Modifier,
|
||||
colors: ButtonColors = transparentButtonColors(),
|
||||
contentDescription: String = text,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
ItemButton(
|
||||
text = text,
|
||||
text = stringResource(textId),
|
||||
modifier = modifier,
|
||||
icon = {
|
||||
Icon(
|
||||
painter = painterResource(id = icon),
|
||||
contentDescription = contentDescription,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.align(Alignment.Center)
|
||||
)
|
||||
},
|
||||
@ -165,15 +160,21 @@ fun ItemButton(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Base [ItemButton] implementation.
|
||||
*
|
||||
* A button to be used in a list of buttons, usually in a [Cell] or [Card]
|
||||
*/
|
||||
@Composable
|
||||
fun ItemButton(
|
||||
text: String,
|
||||
icon: @Composable() (BoxScope.() -> Unit),
|
||||
icon: @Composable (BoxScope.() -> Unit),
|
||||
modifier: Modifier = Modifier,
|
||||
colors: ButtonColors = transparentButtonColors(),
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
TextButton(
|
||||
modifier = Modifier
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.height(60.dp),
|
||||
colors = colors,
|
||||
|
@ -38,7 +38,6 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.filter
|
||||
@ -47,9 +46,9 @@ import org.thoughtcrime.securesms.ui.GetString
|
||||
import org.thoughtcrime.securesms.ui.LaunchedEffectAsync
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.baseBold
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.color.radioButtonColors
|
||||
import org.thoughtcrime.securesms.ui.color.slimOutlineButton
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
|
@ -7,6 +7,7 @@ import androidx.compose.material.LocalTextStyle
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.thoughtcrime.securesms.ui.baseBold
|
||||
@ -34,12 +35,12 @@ interface ButtonSize {
|
||||
val minHeight: Dp
|
||||
|
||||
object Large: ButtonSize {
|
||||
override val textStyle = baseBold
|
||||
override val textStyle = baseBold.copy(textAlign = TextAlign.Center)
|
||||
override val minHeight = 41.dp
|
||||
}
|
||||
|
||||
object Slim: ButtonSize {
|
||||
override val textStyle = extraSmallBold
|
||||
override val textStyle = extraSmallBold.copy(textAlign = TextAlign.Center)
|
||||
override val minHeight = 29.dp
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user