From e347f5329c47f2307d63360b66743aefdaaa99d7 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Mon, 12 Dec 2022 13:25:49 +0300 Subject: [PATCH] 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> --- .../simplex/app/views/chat/SendMsgView.kt | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/SendMsgView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/SendMsgView.kt index 942593cfa3..c6e40f9a41 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/SendMsgView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/SendMsgView.kt @@ -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