Added english and french languages and permission "asking system" is working good :)

This commit is contained in:
Mathieu 2022-01-04 16:58:44 +01:00
parent 43e1489dd4
commit d11f58b716
8 changed files with 86 additions and 24 deletions

View File

@ -33,6 +33,8 @@
<entry key="../../../../../layout/compose-model-1641294663527.xml" value="0.38796296296296295" />
<entry key="../../../../../layout/compose-model-1641294734010.xml" value="0.38796296296296295" />
<entry key="../../../../../layout/compose-model-1641294737726.xml" value="0.38796296296296295" />
<entry key="../../../../../layout/compose-model-1641305520689.xml" value="0.38796296296296295" />
<entry key="../../../../../layout/compose-model-1641310759461.xml" value="0.38796296296296295" />
<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" />

View File

@ -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))
}
})
}

View File

@ -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)
}
}

View File

@ -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)

View File

@ -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
)
}

View 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="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98 0,-0.34 -0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.09,-0.16 -0.26,-0.25 -0.44,-0.25 -0.06,0 -0.12,0.01 -0.17,0.03l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.06,-0.02 -0.12,-0.03 -0.18,-0.03 -0.17,0 -0.34,0.09 -0.43,0.25l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98 0,0.33 0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.09,0.16 0.26,0.25 0.44,0.25 0.06,0 0.12,-0.01 0.17,-0.03l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.06,0.02 0.12,0.03 0.18,0.03 0.17,0 0.34,-0.09 0.43,-0.25l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM17.45,11.27c0.04,0.31 0.05,0.52 0.05,0.73 0,0.21 -0.02,0.43 -0.05,0.73l-0.14,1.13 0.89,0.7 1.08,0.84 -0.7,1.21 -1.27,-0.51 -1.04,-0.42 -0.9,0.68c-0.43,0.32 -0.84,0.56 -1.25,0.73l-1.06,0.43 -0.16,1.13 -0.2,1.35h-1.4l-0.19,-1.35 -0.16,-1.13 -1.06,-0.43c-0.43,-0.18 -0.83,-0.41 -1.23,-0.71l-0.91,-0.7 -1.06,0.43 -1.27,0.51 -0.7,-1.21 1.08,-0.84 0.89,-0.7 -0.14,-1.13c-0.03,-0.31 -0.05,-0.54 -0.05,-0.74s0.02,-0.43 0.05,-0.73l0.14,-1.13 -0.89,-0.7 -1.08,-0.84 0.7,-1.21 1.27,0.51 1.04,0.42 0.9,-0.68c0.43,-0.32 0.84,-0.56 1.25,-0.73l1.06,-0.43 0.16,-1.13 0.2,-1.35h1.39l0.19,1.35 0.16,1.13 1.06,0.43c0.43,0.18 0.83,0.41 1.23,0.71l0.91,0.7 1.06,-0.43 1.27,-0.51 0.7,1.21 -1.07,0.85 -0.89,0.7 0.14,1.13zM12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM12,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</vector>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="permissions_page_grant_permission">Autoriser</string>
<string name="permissions_page_permission_denied">Refusée</string>
<string name="permission_granted">Autorisé</string>
<string name="permissions_page_permissions_page_before_starting">Avant de commencer</string>
<string name="main_page_dialog_ask_me_anything">Demandez-moi quelque chose</string>
<string name="main_page_dialog_type_a_sentence">Entrez une phrase</string>
<string name="main_page_delete_conversation">Effacer la conversation</string>
<string name="main_page_how_may_i_help_you">Bonjour, comment puis-je vous aider ?</string>
<string name="settings">Paramètres</string>
<string name="report_an_issue">Signaler un problème</string>
<string name="demo_message_1">Salut, je suis Jarvis! \nPose moi une question et je ferais de mon mieux pour te renseigner.</string>
<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="cancel">Annuler</string>
<string name="ok">OK</string>
</resources>

View File

@ -1,3 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Jarvis Compose</string>
<string name="app_name" translatable="false">Jarvis</string>
<string name="permissions_page_grant_permission">Grant</string>
<string name="permissions_page_permission_denied">Denied</string>
<string name="permission_granted">Granted</string>
<string name="permissions_page_permissions_page_before_starting">Before you begin</string>
<string name="main_page_dialog_ask_me_anything">Ask me anything</string>
<string name="main_page_dialog_type_a_sentence">Type something here</string>
<string name="main_page_how_may_i_help_you">Hi, how can I help ?</string>
<string name="main_page_delete_conversation">Delete conversation</string>
<string name="settings">Settings</string>
<string name="report_an_issue">Report an issue</string>
<string name="demo_message_1">Hi, I\'m Jarvis! \nAsk me anything and I\'ll do my best to help you.</string>
<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="cancel">Cancel</string>
<string name="ok">OK</string>
</resources>