Fixed permission (ui) button issue and added write_external_storage to the required permissions
This commit is contained in:
parent
39f95ec800
commit
cbcf615e57
@ -40,6 +40,9 @@
|
||||
<entry key="../../../../../layout/compose-model-1641313346209.xml" value="0.3861111111111111" />
|
||||
<entry key="../../../../../layout/compose-model-1641371559019.xml" value="0.33" />
|
||||
<entry key="../../../../../layout/compose-model-1641372970000.xml" value="0.3861111111111111" />
|
||||
<entry key="../../../../../layout/compose-model-1641393136708.xml" value="0.3861111111111111" />
|
||||
<entry key="../../../../../layout/compose-model-1641396021148.xml" value="0.2690033783783784" />
|
||||
<entry key="../../../../../layout/compose-model-1641396094843.xml" value="0.33" />
|
||||
<entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.5307291666666667" />
|
||||
<entry key="app/src/main/res/drawable/ic_baseline_arrow_back_24.xml" value="0.38981481481481484" />
|
||||
<entry key="app/src/main/res/drawable/ic_baseline_keyboard_24.xml" value="0.38981481481481484" />
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
|
@ -20,7 +20,7 @@ import com.google.accompanist.permissions.rememberMultiplePermissionsState
|
||||
fun Navigation() {
|
||||
val navController = rememberNavController()
|
||||
|
||||
val permissions = listOf(android.Manifest.permission.RECORD_AUDIO)
|
||||
val permissions = listOf(android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
val permissionState = rememberMultiplePermissionsState(permissions)
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ import ch.mathieubroillet.jarvis.android.R
|
||||
import ch.mathieubroillet.jarvis.android.ui.theme.JarvisComposeTheme
|
||||
import ch.mathieubroillet.jarvis.android.ui.theme.productSansFont
|
||||
import ch.mathieubroillet.jarvis.android.utils.DefaultBox
|
||||
import ch.mathieubroillet.jarvis.android.utils.requestPermission
|
||||
import ch.mathieubroillet.jarvis.android.utils.requestPermissionButton
|
||||
|
||||
|
||||
@Composable
|
||||
@ -57,8 +57,16 @@ fun PermissionsBase(navController: NavController) {
|
||||
|
||||
PermissionRow(
|
||||
R.drawable.ic_baseline_mic_24,
|
||||
stringResource(id = R.string.permissions_microphone),
|
||||
stringResource(id = R.string.permissions_microphone_description)
|
||||
stringResource(id = R.string.permission_microphone),
|
||||
stringResource(id = R.string.permission_microphone_description),
|
||||
Manifest.permission.RECORD_AUDIO
|
||||
)
|
||||
|
||||
PermissionRow(
|
||||
R.drawable.ic_baseline_folder_open_24,
|
||||
stringResource(id = R.string.permission_files),
|
||||
stringResource(id = R.string.permission_files_description),
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -67,7 +75,8 @@ fun PermissionsBase(navController: NavController) {
|
||||
fun PermissionRow(
|
||||
icon: Int = R.drawable.ic_baseline_error_24,
|
||||
title: String = "Name",
|
||||
description: String = "Description of the permission"
|
||||
description: String = "Description of the permission",
|
||||
permission: String
|
||||
) {
|
||||
Row(
|
||||
Modifier
|
||||
@ -76,24 +85,27 @@ fun PermissionRow(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = icon),
|
||||
contentDescription = "permission icon",
|
||||
modifier = Modifier.size(40.dp)
|
||||
)
|
||||
Column {
|
||||
Text(
|
||||
text = title,
|
||||
fontFamily = productSansFont,
|
||||
fontSize = 18.sp
|
||||
)
|
||||
Text(
|
||||
text = description,
|
||||
fontFamily = productSansFont,
|
||||
fontSize = 14.sp
|
||||
Row(modifier = Modifier.fillMaxWidth(0.75F)) {
|
||||
Icon(
|
||||
painter = painterResource(id = icon),
|
||||
contentDescription = "permission icon",
|
||||
modifier = Modifier.size(40.dp).padding(end = 10.dp)
|
||||
)
|
||||
Column {
|
||||
Text(
|
||||
text = title,
|
||||
fontFamily = productSansFont,
|
||||
fontSize = 18.sp
|
||||
)
|
||||
Text(
|
||||
text = description,
|
||||
fontFamily = productSansFont,
|
||||
fontSize = 14.sp,
|
||||
)
|
||||
}
|
||||
}
|
||||
requestPermission(permission = Manifest.permission.RECORD_AUDIO)
|
||||
|
||||
requestPermissionButton(permission = permission)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import com.google.accompanist.permissions.rememberPermissionState
|
||||
|
||||
@OptIn(ExperimentalPermissionsApi::class)
|
||||
@Composable
|
||||
fun requestPermission(permission: String) {
|
||||
fun requestPermissionButton(permission: String) {
|
||||
val permissionState = rememberPermissionState(permission = permission)
|
||||
val context = LocalContext.current
|
||||
|
||||
|
10
app/src/main/res/drawable/ic_baseline_folder_open_24.xml
Normal file
10
app/src/main/res/drawable/ic_baseline_folder_open_24.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,6h-8l-2,-2L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,8c0,-1.1 -0.9,-2 -2,-2zM20,18L4,18L4,8h16v10z"/>
|
||||
</vector>
|
@ -14,8 +14,10 @@
|
||||
<string name="demo_message_2">Quel temps fait-il à Paris en ce moment ?</string>
|
||||
<string name="demo_message_3">A Paris, il fait actuellement 10 degrés et le ciel est nuageux.</string>
|
||||
<string name="permissions_page_this_app_need_the_following_permissions">Cette application a besoin des autorisations suivantes pour fonctionner:</string>
|
||||
<string name="permissions_microphone">Microphone</string>
|
||||
<string name="permissions_microphone_description">Nécessaire pour vous entendre</string>
|
||||
<string name="permission_microphone">Microphone</string>
|
||||
<string name="permission_microphone_description">Nécessaire pour vous entendre</string>
|
||||
<string name="cancel">Annuler</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="permission_files">Fichiers</string>
|
||||
<string name="permission_files_description">Nécessaire pour stocker temporairement les enregistrements audios</string>
|
||||
</resources>
|
@ -15,8 +15,10 @@
|
||||
<string name="demo_message_2">What\'s the weather like in Paris ?</string>
|
||||
<string name="demo_message_3">In Paris it\'s cloudy and the temperature is 10 degrees celsuis</string>
|
||||
<string name="permissions_page_this_app_need_the_following_permissions">The following permissions are required for this application to run:</string>
|
||||
<string name="permissions_microphone">Microphone</string>
|
||||
<string name="permissions_microphone_description">Necessary to hear you</string>
|
||||
<string name="permission_microphone">Microphone</string>
|
||||
<string name="permission_microphone_description">Necessary to hear you</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="permission_files">Files</string>
|
||||
<string name="permission_files_description">Necessary to temporarily save audio recordings</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user