diff --git a/.idea/misc.xml b/.idea/misc.xml index 2289330..5d1e5db 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -33,6 +33,8 @@ + + diff --git a/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/MainPage.kt b/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/MainPage.kt index 93564c1..2f90216 100644 --- a/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/MainPage.kt +++ b/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/MainPage.kt @@ -7,6 +7,7 @@ import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.dp @@ -27,20 +28,20 @@ import ch.mathieubroillet.jarvis.android.utils.MessageFromUser @Composable fun Base(navController: NavController) { - Column(Modifier.padding(bottom = 25.dp)) { + Column(Modifier.padding(bottom = 25.dp).fillMaxWidth()) { Row(Modifier.align(Alignment.End)) { IconAlertDialogTextField( R.drawable.ic_baseline_keyboard_24, - "Demandez-moi quelque chose", - "Entrez une phrase" + stringResource(id = R.string.main_page_dialog_ask_me_anything), + stringResource(id = R.string.main_page_dialog_type_a_sentence) ) DropDownSettingsMenu(navController) } Text( - text = "Bonjour, comment puis-je vous aider ?", + text = stringResource(id = R.string.main_page_how_may_i_help_you), fontFamily = productSansFont, fontSize = 30.sp, modifier = Modifier.padding(top = 30.dp) @@ -65,15 +66,15 @@ fun DropDownSettingsMenu(navController: NavController) { onDismissRequest = { expanded = false }, offset = DpOffset((-500).dp, 0.dp) ) { - DropdownMenuItem(onClick = { /* Handle refresh! */ }) { - Text("Effacer la conversation") + DropdownMenuItem(onClick = { navController.navigate(Screen.PermissionsScreen.route) }) { + Text(stringResource(id = R.string.main_page_delete_conversation)) } DropdownMenuItem(onClick = { navController.navigate(Screen.SettingsScreen.route) }) { - Text("Paramètres") + Text(stringResource(id = R.string.settings)) } Divider() DropdownMenuItem(onClick = { /* Handle send feedback! */ }) { - Text("Signaler un problème") + Text(stringResource(id = R.string.report_an_issue)) } } } @@ -110,9 +111,9 @@ fun DisplayMainPage(navController: NavController) { LazyColumn(content = { item { // Basic interaction stuff for demo - MessageFromJarvis(text = "Salut, je suis Jarvis! \nPose moi une question et je ferais de mon mieux pour te renseigner.") - MessageFromUser(text = "Quel temps fait-il à Paris en ce moment ?") - MessageFromJarvis(text = "A Paris, il fait actuellement 10 degrés et le ciel est nuageux.") + MessageFromJarvis(text = stringResource(id = R.string.demo_message_1)) + MessageFromUser(text = stringResource(id = R.string.demo_message_2)) + MessageFromJarvis(text = stringResource(id = R.string.demo_message_3)) } }) } diff --git a/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/PermissionsPage.kt b/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/PermissionsPage.kt index 24fc964..acdef74 100644 --- a/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/PermissionsPage.kt +++ b/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/PermissionsPage.kt @@ -1,13 +1,14 @@ package ch.mathieubroillet.jarvis.android.pages +import android.Manifest import androidx.compose.foundation.layout.* -import androidx.compose.material.Button import androidx.compose.material.Icon import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -17,6 +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 @Composable @@ -37,19 +39,23 @@ fun PermissionsBase(navController: NavController) { ) } Text( - text = "Avant de commencer", + text = stringResource(id = R.string.permissions_page_permissions_page_before_starting), fontFamily = productSansFont, fontSize = 30.sp, modifier = Modifier.padding(top = 15.dp) ) Text( - text = "Cette application a besoin des autorisations suivantes pour fonctionner :", + text = stringResource(id = R.string.permissions_page_this_app_need_the_following_permissions), fontFamily = productSansFont, fontSize = 20.sp, modifier = Modifier.padding(top = 10.dp) ) - PermissionRow(R.drawable.ic_baseline_mic_24, "Microphone", "Nécessaire pour vous entendre.") + PermissionRow( + R.drawable.ic_baseline_mic_24, + stringResource(id = R.string.permissions_microphone), + stringResource(id = R.string.permissions_microphone_description) + ) } } @@ -83,9 +89,7 @@ fun PermissionRow( fontSize = 14.sp ) } - Button(onClick = { /*TODO*/ }) { - Text(text = "Autoriser") - } + requestPermission(permission = Manifest.permission.RECORD_AUDIO) } } diff --git a/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/SettingsPage.kt b/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/SettingsPage.kt index a2b76b9..e041c39 100644 --- a/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/SettingsPage.kt +++ b/app/src/main/java/ch/mathieubroillet/jarvis/android/pages/SettingsPage.kt @@ -9,6 +9,7 @@ import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -40,7 +41,7 @@ fun SettingsBase(navController: NavController) { } } Text( - text = "Paramètres", + text = stringResource(id = R.string.settings), fontFamily = productSansFont, fontSize = 30.sp, modifier = Modifier.padding(top = 30.dp) diff --git a/app/src/main/java/ch/mathieubroillet/jarvis/android/utils/Dialogs.kt b/app/src/main/java/ch/mathieubroillet/jarvis/android/utils/Dialogs.kt index bdcc952..fe65cbf 100644 --- a/app/src/main/java/ch/mathieubroillet/jarvis/android/utils/Dialogs.kt +++ b/app/src/main/java/ch/mathieubroillet/jarvis/android/utils/Dialogs.kt @@ -9,10 +9,12 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import ch.mathieubroillet.jarvis.android.R +import ch.mathieubroillet.jarvis.android.ui.theme.JarvisComposeTheme import ch.mathieubroillet.jarvis.android.ui.theme.productSansFont @Composable @@ -21,7 +23,7 @@ fun IconAlertDialogTextField( title: String = "Title", label: String = "Label" ) { - MaterialTheme { + JarvisComposeTheme { Column { val openDialog = remember { mutableStateOf(false) } @@ -43,12 +45,13 @@ fun IconAlertDialogTextField( title = null, text = null, buttons = { - Column(Modifier.fillMaxWidth()) { + Column { Box( modifier = Modifier .clip(RectangleShape) .background(color = MaterialTheme.colors.secondaryVariant) .padding(horizontal = 20.dp, vertical = 15.dp) + .fillMaxWidth() ) { Text( text = title, @@ -62,6 +65,7 @@ fun IconAlertDialogTextField( .background(color = MaterialTheme.colors.background) .padding(horizontal = 20.dp) .padding(top = 15.dp, bottom = 10.dp) + .fillMaxWidth() ) { Column { var text by remember { mutableStateOf(TextFieldValue("")) } @@ -85,13 +89,13 @@ fun IconAlertDialogTextField( ) { TextButton(onClick = { openDialog.value = false }) { Text( - text = "Annuler", + text = stringResource(id = R.string.cancel), color = MaterialTheme.colors.secondary ) } TextButton(onClick = { /*TODO*/ }) { Text( - text = "OK", + text = stringResource(id = R.string.ok), color = MaterialTheme.colors.secondary ) } diff --git a/app/src/main/res/drawable/ic_outline_settings_24.xml b/app/src/main/res/drawable/ic_outline_settings_24.xml new file mode 100644 index 0000000..0d7a0a6 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_settings_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml new file mode 100644 index 0000000..4d850a6 --- /dev/null +++ b/app/src/main/res/values-fr/strings.xml @@ -0,0 +1,21 @@ + + + Autoriser + Refusée + Autorisé + Avant de commencer + Demandez-moi quelque chose + Entrez une phrase + Effacer la conversation + Bonjour, comment puis-je vous aider ? + Paramètres + Signaler un problème + Salut, je suis Jarvis! \nPose moi une question et je ferais de mon mieux pour te renseigner. + Quel temps fait-il à Paris en ce moment ? + A Paris, il fait actuellement 10 degrés et le ciel est nuageux. + Cette application a besoin des autorisations suivantes pour fonctionner: + Microphone + Nécessaire pour vous entendre + Annuler + OK + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d61f292..9e361bd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,22 @@ + - Jarvis Compose + Jarvis + Grant + Denied + Granted + Before you begin + Ask me anything + Type something here + Hi, how can I help ? + Delete conversation + Settings + Report an issue + Hi, I\'m Jarvis! \nAsk me anything and I\'ll do my best to help you. + What\'s the weather like in Paris ? + In Paris it\'s cloudy and the temperature is 10 degrees celsuis + The following permissions are required for this application to run: + Microphone + Necessary to hear you + Cancel + OK \ No newline at end of file