Added permission page

This commit is contained in:
Mathieu 2022-01-03 21:42:42 +01:00
parent 4de9e66d0e
commit 7996a94ad3
9 changed files with 140 additions and 10 deletions

View File

@ -25,10 +25,17 @@
<entry key="../../../../../layout/compose-model-1641220668413.xml" value="0.38981481481481484" />
<entry key="../../../../../layout/compose-model-1641224457648.xml" value="0.38981481481481484" />
<entry key="../../../../../layout/compose-model-1641224617165.xml" value="0.38981481481481484" />
<entry key="../../../../../layout/compose-model-1641224827876.xml" value="0.38981481481481484" />
<entry key="../../../../../layout/compose-model-1641238823591.xml" value="1.0" />
<entry key="../../../../../layout/compose-model-1641238895316.xml" value="0.38981481481481484" />
<entry key="../../../../../layout/compose-model-1641242466678.xml" value="0.38981481481481484" />
<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" />
<entry key="app/src/main/res/drawable/ic_baseline_mic_24.xml" value="0.38981481481481484" />
<entry key="app/src/main/res/drawable/ic_baseline_more_vert_24.xml" value="0.38981481481481484" />
<entry key="app/src/main/res/drawable/ic_baseline_person_24.xml" value="0.5307291666666667" />
<entry key="app/src/main/res/drawable/ic_baseline_shield_24.xml" value="0.38981481481481484" />
<entry key="app/src/main/res/drawable/ic_launcher_background.xml" value="0.5307291666666667" />
<entry key="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" value="0.5307291666666667" />
</map>

View File

@ -56,6 +56,8 @@ dependencies {
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.navigation:navigation-compose:2.4.0-rc01"
implementation 'com.google.accompanist:accompanist-permissions:0.22.0-rc'
implementation 'com.google.accompanist:accompanist-insets:0.22.0-rc'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
implementation 'androidx.activity:activity-compose:1.4.0'
testImplementation 'junit:junit:4.13.2'

View File

@ -2,6 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.mathieubroillet.jarvis.android">
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"

View File

@ -22,7 +22,6 @@ import ch.mathieubroillet.jarvis.android.ui.theme.JarvisComposeTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

View File

@ -6,6 +6,7 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import ch.mathieubroillet.jarvis.android.pages.DisplayMainPage
import ch.mathieubroillet.jarvis.android.pages.DisplayPermissionsPage
import ch.mathieubroillet.jarvis.android.pages.DisplaySettingsPage
@Composable
@ -18,6 +19,9 @@ fun Navigation() {
composable(route = Screen.SettingsScreen.route) {
SettingsScreen(navController = navController)
}
composable(route = Screen.PermissionsScreen.route) {
PermissionsScreen(navController = navController)
}
}
}
@ -30,4 +34,9 @@ fun MainScreen(navController: NavController) {
@Composable
fun SettingsScreen(navController: NavController) {
DisplaySettingsPage(navController)
}
@Composable
fun PermissionsScreen(navController: NavController) {
DisplayPermissionsPage(navController)
}

View File

@ -3,4 +3,5 @@ package ch.mathieubroillet.jarvis.android.nav
sealed class Screen(val route: String){
object MainScreen : Screen("main_screen")
object SettingsScreen : Screen("settings_screen")
object PermissionsScreen : Screen("permissions_screen")
}

View File

@ -0,0 +1,98 @@
package ch.mathieubroillet.jarvis.android.pages
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.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
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
@Composable
fun DisplayPermissionsPage(navController: NavController) {
DefaultBox {
PermissionsBase(navController)
}
}
@Composable
fun PermissionsBase(navController: NavController) {
Column(Modifier.padding(bottom = 25.dp)) {
Row {
Icon(
painter = painterResource(id = R.drawable.ic_baseline_shield_24),
contentDescription = "shield icon",
modifier = Modifier.size(50.dp)
)
}
Text(
text = "Avant de commencer",
fontFamily = productSansFont,
fontSize = 30.sp,
modifier = Modifier.padding(top = 15.dp)
)
Text(
text = "Cette application a besoin des autorisations suivantes pour fonctionner :",
fontFamily = productSansFont,
fontSize = 20.sp,
modifier = Modifier.padding(top = 10.dp)
)
PermissionRow(R.drawable.ic_baseline_mic_24, "Microphone", "Nécessaire pour vous entendre.")
}
}
@Composable
fun PermissionRow(
icon: Int = R.drawable.ic_baseline_error_24,
title: String = "Name",
description: String = "Description of the permission"
) {
Row(
Modifier
.padding(top = 20.dp)
.fillMaxWidth(),
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
)
}
Button(onClick = { /*TODO*/ }) {
Text(text = "Autoriser")
}
}
}
@Preview(showBackground = true)
@Composable
fun PermissionsPagePreview() {
JarvisComposeTheme {
DisplayPermissionsPage(rememberNavController())
}
}

View File

@ -1,10 +1,9 @@
<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="M12,14c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6c0,1.66 1.34,3 3,3zM17.3,11c0,3 -2.54,5.1 -5.3,5.1S6.7,14 6.7,11L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c3.28,-0.48 6,-3.3 6,-6.72h-1.7z"/>
</vector>
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path android:fillColor="@android:color/white" android:pathData="M17.3,11C17.3,14 14.76,16.1 12,16.1C9.24,16.1 6.7,14 6.7,11H5C5,14.41 7.72,17.23 11,17.72V21H13V17.72C16.28,17.23 19,14.41 19,11M10.8,4.9C10.8,4.24 11.34,3.7 12,3.7C12.66,3.7 13.2,4.24 13.2,4.9L13.19,11.1C13.19,11.76 12.66,12.3 12,12.3C11.34,12.3 10.8,11.76 10.8,11.1M12,14A3,3 0 0,0 15,11V5A3,3 0 0,0 12,2A3,3 0 0,0 9,5V11A3,3 0 0,0 12,14Z" />
</vector>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M10,17L6,13L7.41,11.59L10,14.17L16.59,7.58L18,9M12,1L3,5V11C3,16.55 6.84,21.74 12,23C17.16,21.74 21,16.55 21,11V5L12,1Z" />
</vector>