mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +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)
|
Divider(startIndent = LocalDimensions.current.dividerIndent)
|
||||||
ItemButton(textId = R.string.dialog_join_community_title, icon = R.drawable.ic_globe, onClick = delegate::onJoinCommunitySelected)
|
ItemButton(textId = R.string.dialog_join_community_title, icon = R.drawable.ic_globe, onClick = delegate::onJoinCommunitySelected)
|
||||||
Divider(startIndent = LocalDimensions.current.dividerIndent)
|
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(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(horizontal = LocalDimensions.current.marginMedium)
|
.padding(horizontal = LocalDimensions.current.marginMedium)
|
||||||
|
@ -218,7 +218,7 @@ fun CellButtons(
|
|||||||
Column {
|
Column {
|
||||||
onReply?.let {
|
onReply?.let {
|
||||||
ItemButton(
|
ItemButton(
|
||||||
stringResource(R.string.reply),
|
R.string.reply,
|
||||||
R.drawable.ic_message_details__reply,
|
R.drawable.ic_message_details__reply,
|
||||||
onClick = it
|
onClick = it
|
||||||
)
|
)
|
||||||
@ -226,14 +226,14 @@ fun CellButtons(
|
|||||||
}
|
}
|
||||||
onResend?.let {
|
onResend?.let {
|
||||||
ItemButton(
|
ItemButton(
|
||||||
stringResource(R.string.resend),
|
R.string.resend,
|
||||||
R.drawable.ic_message_details__refresh,
|
R.drawable.ic_message_details__refresh,
|
||||||
onClick = it
|
onClick = it
|
||||||
)
|
)
|
||||||
Divider()
|
Divider()
|
||||||
}
|
}
|
||||||
ItemButton(
|
ItemButton(
|
||||||
stringResource(R.string.delete),
|
R.string.delete,
|
||||||
R.drawable.ic_message_details__trash,
|
R.drawable.ic_message_details__trash,
|
||||||
colors = destructiveButtonColors(),
|
colors = destructiveButtonColors(),
|
||||||
onClick = onDelete
|
onClick = onDelete
|
||||||
|
@ -117,7 +117,7 @@ class LandingActivity: BaseActionBarActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
/*Column(modifier = Modifier
|
Column(modifier = Modifier
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
.padding(horizontal = LocalDimensions.current.marginMedium)) {
|
.padding(horizontal = LocalDimensions.current.marginMedium)) {
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
@ -149,7 +149,7 @@ class LandingActivity: BaseActionBarActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
}*/
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.padding(horizontal = LocalDimensions.current.marginLarge)) {
|
Column(modifier = Modifier.padding(horizontal = LocalDimensions.current.marginLarge)) {
|
||||||
PrimaryFillButton(
|
PrimaryFillButton(
|
||||||
|
@ -81,6 +81,7 @@ import org.thoughtcrime.securesms.ui.LocalDimensions
|
|||||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||||
import org.thoughtcrime.securesms.ui.components.OutlineCopyButton
|
import org.thoughtcrime.securesms.ui.components.OutlineCopyButton
|
||||||
import org.thoughtcrime.securesms.ui.color.destructiveButtonColors
|
import org.thoughtcrime.securesms.ui.color.destructiveButtonColors
|
||||||
|
import org.thoughtcrime.securesms.ui.contentDescription
|
||||||
import org.thoughtcrime.securesms.ui.setThemedContent
|
import org.thoughtcrime.securesms.ui.setThemedContent
|
||||||
import org.thoughtcrime.securesms.util.BitmapDecodingException
|
import org.thoughtcrime.securesms.util.BitmapDecodingException
|
||||||
import org.thoughtcrime.securesms.util.BitmapUtil
|
import org.thoughtcrime.securesms.util.BitmapUtil
|
||||||
@ -412,27 +413,27 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
|
|
||||||
Cell {
|
Cell {
|
||||||
Column {
|
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()
|
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()
|
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()
|
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()
|
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()
|
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()
|
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()
|
Divider()
|
||||||
if (!prefs.getHidePassword()) {
|
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()
|
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()
|
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
|
@Composable
|
||||||
fun ItemButtonWithDrawable(
|
fun ItemButtonWithDrawable(
|
||||||
@StringRes textId: Int,
|
@StringRes textId: Int,
|
||||||
@DrawableRes icon: Int,
|
@DrawableRes icon: Int,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
colors: ButtonColors = transparentButtonColors(),
|
colors: ButtonColors = transparentButtonColors(),
|
||||||
onClick: () -> Unit
|
onClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
@ -131,6 +121,7 @@ fun ItemButtonWithDrawable(
|
|||||||
|
|
||||||
ItemButton(
|
ItemButton(
|
||||||
text = stringResource(textId),
|
text = stringResource(textId),
|
||||||
|
modifier = modifier,
|
||||||
icon = {
|
icon = {
|
||||||
Image(
|
Image(
|
||||||
painter = rememberDrawablePainter(drawable = AppCompatResources.getDrawable(context, icon)),
|
painter = rememberDrawablePainter(drawable = AppCompatResources.getDrawable(context, icon)),
|
||||||
@ -143,20 +134,24 @@ fun ItemButtonWithDrawable(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Courtesy [ItemButton] implementation that takes a [DrawableRes] for the [icon]
|
||||||
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun ItemButton(
|
fun ItemButton(
|
||||||
text: String,
|
@StringRes textId: Int,
|
||||||
@DrawableRes icon: Int,
|
@DrawableRes icon: Int,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
colors: ButtonColors = transparentButtonColors(),
|
colors: ButtonColors = transparentButtonColors(),
|
||||||
contentDescription: String = text,
|
|
||||||
onClick: () -> Unit
|
onClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
ItemButton(
|
ItemButton(
|
||||||
text = text,
|
text = stringResource(textId),
|
||||||
|
modifier = modifier,
|
||||||
icon = {
|
icon = {
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(id = icon),
|
painter = painterResource(id = icon),
|
||||||
contentDescription = contentDescription,
|
contentDescription = null,
|
||||||
modifier = Modifier.align(Alignment.Center)
|
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
|
@Composable
|
||||||
fun ItemButton(
|
fun ItemButton(
|
||||||
text: String,
|
text: String,
|
||||||
icon: @Composable() (BoxScope.() -> Unit),
|
icon: @Composable (BoxScope.() -> Unit),
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
colors: ButtonColors = transparentButtonColors(),
|
colors: ButtonColors = transparentButtonColors(),
|
||||||
onClick: () -> Unit
|
onClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
TextButton(
|
TextButton(
|
||||||
modifier = Modifier
|
modifier = modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(60.dp),
|
.height(60.dp),
|
||||||
colors = colors,
|
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.Preview
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.flow.filter
|
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.LaunchedEffectAsync
|
||||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
|
||||||
import org.thoughtcrime.securesms.ui.baseBold
|
import org.thoughtcrime.securesms.ui.baseBold
|
||||||
import org.thoughtcrime.securesms.ui.color.Colors
|
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.radioButtonColors
|
||||||
import org.thoughtcrime.securesms.ui.color.slimOutlineButton
|
import org.thoughtcrime.securesms.ui.color.slimOutlineButton
|
||||||
import org.thoughtcrime.securesms.ui.contentDescription
|
import org.thoughtcrime.securesms.ui.contentDescription
|
||||||
|
@ -7,6 +7,7 @@ import androidx.compose.material.LocalTextStyle
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.ui.text.TextStyle
|
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 androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import org.thoughtcrime.securesms.ui.baseBold
|
import org.thoughtcrime.securesms.ui.baseBold
|
||||||
@ -34,12 +35,12 @@ interface ButtonSize {
|
|||||||
val minHeight: Dp
|
val minHeight: Dp
|
||||||
|
|
||||||
object Large: ButtonSize {
|
object Large: ButtonSize {
|
||||||
override val textStyle = baseBold
|
override val textStyle = baseBold.copy(textAlign = TextAlign.Center)
|
||||||
override val minHeight = 41.dp
|
override val minHeight = 41.dp
|
||||||
}
|
}
|
||||||
|
|
||||||
object Slim: ButtonSize {
|
object Slim: ButtonSize {
|
||||||
override val textStyle = extraSmallBold
|
override val textStyle = extraSmallBold.copy(textAlign = TextAlign.Center)
|
||||||
override val minHeight = 29.dp
|
override val minHeight = 29.dp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user