android: Different style for voice button when no permissions granted (#1555)

* android: Different style for voice button when no permissions granted

* linebreaks

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
Stanislav Dmitrenko
2022-12-12 13:25:49 +03:00
committed by GitHub
parent 741b3e8848
commit e347f5329c
@@ -71,16 +71,19 @@ fun SendMsgView(
when {
showProgress -> ProgressIndicator()
showVoiceButton -> when {
needToAllowVoiceToContact || !allowedVoiceByPrefs || !permissionsState.allPermissionsGranted -> {
needToAllowVoiceToContact || !allowedVoiceByPrefs -> {
DisallowedVoiceButton {
when {
needToAllowVoiceToContact -> showNeedToAllowVoiceAlert(allowVoiceToContact)
!allowedVoiceByPrefs -> showDisabledVoiceAlert(isDirectChat)
else -> permissionsState.launchMultiplePermissionRequest()
if (needToAllowVoiceToContact) {
showNeedToAllowVoiceAlert(allowVoiceToContact)
} else {
showDisabledVoiceAlert(isDirectChat)
}
}
}
else -> RecordVoiceView(recState)
!permissionsState.allPermissionsGranted ->
VoiceButtonWithoutPermission { permissionsState.launchMultiplePermissionRequest() }
else ->
RecordVoiceView(recState)
}
else -> {
val icon = if (cs.editing) Icons.Filled.Check else Icons.Outlined.ArrowUpward
@@ -248,6 +251,20 @@ private fun DisallowedVoiceButton(onClick: () -> Unit) {
}
}
@Composable
private fun VoiceButtonWithoutPermission(onClick: () -> Unit) {
IconButton(onClick, Modifier.size(36.dp)) {
Icon(
Icons.Filled.KeyboardVoice,
stringResource(R.string.icon_descr_record_voice_message),
tint = MaterialTheme.colors.primary,
modifier = Modifier
.size(36.dp)
.padding(4.dp)
)
}
}
@Composable
private fun LockToCurrentOrientationUntilDispose() {
val context = LocalContext.current