Skip to content

Commit e3ac691

Browse files
author
Thomas Leing
committed
Liveness screenshots
1 parent d455339 commit e3ac691

File tree

30 files changed

+521
-14
lines changed

30 files changed

+521
-14
lines changed

gradle/libs.versions.toml

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ plugin-ktlint = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref =
6262
camera = ["androidx-camera-core", "androidx-camera-camera2", "androidx-camera-lifecycle"]
6363
compose = ["androidx-compose-material", "androidx-compose-tooling"]
6464
test = ["test-androidx-junit", "test-junit", "test-mockk", "test-robolectric", "test-compose-junit", "test-compose-manifest", "test-espresso"]
65+
#test-liveness = ["test-androidx-junit", "test-junit", "test-mockk", "test-compose-junit", "test-compose-manifest", "test-espresso"]
6566

6667
[plugins]
6768
android-application = { id = "com.android.application", version.ref = "agp" }

liveness-screenshots/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

liveness-screenshots/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Authenticator Screenshots
2+
3+
Generates screenshots for the [Authenticator](../authenticator) project.
4+
5+
```shell
6+
# Record screenshots
7+
./gradlew authenticator-screenshots:recordPaparazziDebug
8+
9+
# Verify screenshots
10+
./gradlew authenticator-screenshots:verifyPaparazziDebug
11+
```
12+
13+
## Why a separate module?
14+
15+
`authenticator-screenshots` has a different rationale, but for this module the `paparazzi` plugin is incompatible with changing `externalNativeBuild` and `packagingOptions` in the `build.gradle.kts`.

liveness-screenshots/build.gradle.kts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
@Suppress("DSL_SCOPE_VIOLATION")
17+
plugins {
18+
id("amplify.android.library")
19+
alias(libs.plugins.paparazzi)
20+
}
21+
22+
android {
23+
namespace = "com.amplifyframework.ui.liveness.screenshots"
24+
25+
androidResources {
26+
noCompress += "tflite"
27+
}
28+
}
29+
30+
dependencies {
31+
implementation(libs.bundles.camera)
32+
implementation(libs.bundles.compose)
33+
implementation(libs.tensorflow)
34+
implementation(libs.test.mockk)
35+
implementation(projects.liveness)
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License").
6+
~ You may not use this file except in compliance with the License.
7+
~ A copy of the License is located at
8+
~
9+
~ http://aws.amazon.com/apache2.0
10+
~
11+
~ or in the "license" file accompanying this file. This file is distributed
12+
~ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
~ express or implied. See the License for the specific language governing
14+
~ permissions and limitations under the License.
15+
-->
16+
17+
<manifest />
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package com.amplifyframework.ui.liveness
17+
18+
val sessionId = "sessionId"
19+
val region = "us-east-1"
20+
21+
//import com.amplifyframework.ui.authenticator.forms.FieldConfig
22+
//import com.amplifyframework.ui.authenticator.forms.FieldError
23+
//import com.amplifyframework.ui.authenticator.forms.FieldValidator
24+
//import com.amplifyframework.ui.authenticator.forms.MutableFieldData
25+
//import com.amplifyframework.ui.authenticator.forms.MutableFieldState
26+
//import com.amplifyframework.ui.authenticator.forms.MutableFormState
27+
//import com.amplifyframework.ui.authenticator.forms.MutablePasswordFieldState
28+
//
29+
//fun mockForm(
30+
// vararg fields: MutableFieldData,
31+
// enabled: Boolean = true
32+
//) = object : MutableFormState {
33+
// override val fields = fields.associateBy { it.config.key }
34+
// override var enabled = enabled
35+
//}
36+
//
37+
//fun mockFieldData(
38+
// config: FieldConfig,
39+
// state: MutableFieldState = mockFieldState(),
40+
// validator: FieldValidator = { null }
41+
//) = object : MutableFieldData {
42+
// override val state = state
43+
// override val config = config
44+
// override val validator = validator
45+
//}
46+
//
47+
//fun mockFieldState(
48+
// content: String = "",
49+
// error: FieldError? = null
50+
//) = object : MutableFieldState {
51+
// override var content = content
52+
// override var error = error
53+
//}
54+
//
55+
//fun mockPasswordFieldState(
56+
// content: String = "",
57+
// error: FieldError? = null,
58+
// visible: Boolean = false
59+
//) = object : MutablePasswordFieldState {
60+
// override var fieldContentVisible = visible
61+
// override var content = content
62+
// override var error: FieldError? = error
63+
//}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package com.amplifyframework.ui.liveness
17+
18+
import androidx.compose.foundation.layout.Box
19+
import androidx.compose.foundation.layout.padding
20+
import androidx.compose.material3.Surface
21+
import androidx.compose.runtime.Composable
22+
import androidx.compose.ui.Modifier
23+
import androidx.compose.ui.unit.dp
24+
import app.cash.paparazzi.DeviceConfig
25+
import app.cash.paparazzi.Paparazzi
26+
import com.amplifyframework.ui.authenticator.theme.AmplifyTheme
27+
import org.junit.Rule
28+
29+
abstract class ScreenshotTestBase {
30+
31+
@get:Rule
32+
val screenshotRule = Paparazzi(
33+
deviceConfig = DeviceConfig.PIXEL_6,
34+
showSystemUi = false
35+
)
36+
37+
protected open fun screenshot(name: String? = null, content: @Composable () -> Unit) =
38+
screenshotRule.snapshot(name) {
39+
AmplifyTheme {
40+
Surface {
41+
Box(modifier = Modifier.padding(top = 56.dp)) {
42+
content()
43+
}
44+
}
45+
}
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package com.amplifyframework.ui.authenticator.theme
17+
18+
import androidx.compose.ui.graphics.Color
19+
20+
val md_theme_light_primary = Color(0xFF006876)
21+
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
22+
val md_theme_light_primaryContainer = Color(0xFF9EEFFF)
23+
val md_theme_light_onPrimaryContainer = Color(0xFF001F24)
24+
val md_theme_light_secondary = Color(0xFF96339B)
25+
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
26+
val md_theme_light_secondaryContainer = Color(0xFFFFD6F9)
27+
val md_theme_light_onSecondaryContainer = Color(0xFF37003B)
28+
val md_theme_light_tertiary = Color(0xFF895100)
29+
val md_theme_light_onTertiary = Color(0xFFFFFFFF)
30+
val md_theme_light_tertiaryContainer = Color(0xFFFFDCBC)
31+
val md_theme_light_onTertiaryContainer = Color(0xFF2C1700)
32+
val md_theme_light_error = Color(0xFFBA1A1A)
33+
val md_theme_light_errorContainer = Color(0xFFFFDAD6)
34+
val md_theme_light_onError = Color(0xFFFFFFFF)
35+
val md_theme_light_onErrorContainer = Color(0xFF410002)
36+
val md_theme_light_background = Color(0xFFFBFCFD)
37+
val md_theme_light_onBackground = Color(0xFF191C1D)
38+
val md_theme_light_surface = Color(0xFFFBFCFD)
39+
val md_theme_light_onSurface = Color(0xFF191C1D)
40+
val md_theme_light_surfaceVariant = Color(0xFFDBE4E6)
41+
val md_theme_light_onSurfaceVariant = Color(0xFF3F484A)
42+
val md_theme_light_outline = Color(0xFF6F797B)
43+
val md_theme_light_inverseOnSurface = Color(0xFFEFF1F2)
44+
val md_theme_light_inverseSurface = Color(0xFF2E3132)
45+
val md_theme_light_inversePrimary = Color(0xFF51D7EE)
46+
val md_theme_light_shadow = Color(0xFF000000)
47+
val md_theme_light_surfaceTint = Color(0xFF006876)
48+
val md_theme_light_outlineVariant = Color(0xFFBFC8CA)
49+
val md_theme_light_scrim = Color(0xFF000000)
50+
51+
val md_theme_dark_primary = Color(0xFF51D7EE)
52+
val md_theme_dark_onPrimary = Color(0xFF00363E)
53+
val md_theme_dark_primaryContainer = Color(0xFF004E59)
54+
val md_theme_dark_onPrimaryContainer = Color(0xFF9EEFFF)
55+
val md_theme_dark_secondary = Color(0xFFFFA9FB)
56+
val md_theme_dark_onSecondary = Color(0xFF590060)
57+
val md_theme_dark_secondaryContainer = Color(0xFF7A1580)
58+
val md_theme_dark_onSecondaryContainer = Color(0xFFFFD6F9)
59+
val md_theme_dark_tertiary = Color(0xFFFFB86C)
60+
val md_theme_dark_onTertiary = Color(0xFF492900)
61+
val md_theme_dark_tertiaryContainer = Color(0xFF683D00)
62+
val md_theme_dark_onTertiaryContainer = Color(0xFFFFDCBC)
63+
val md_theme_dark_error = Color(0xFFFFB4AB)
64+
val md_theme_dark_errorContainer = Color(0xFF93000A)
65+
val md_theme_dark_onError = Color(0xFF690005)
66+
val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6)
67+
val md_theme_dark_background = Color(0xFF191C1D)
68+
val md_theme_dark_onBackground = Color(0xFFE1E3E3)
69+
val md_theme_dark_surface = Color(0xFF191C1D)
70+
val md_theme_dark_onSurface = Color(0xFFE1E3E3)
71+
val md_theme_dark_surfaceVariant = Color(0xFF3F484A)
72+
val md_theme_dark_onSurfaceVariant = Color(0xFFBFC8CA)
73+
val md_theme_dark_outline = Color(0xFF899294)
74+
val md_theme_dark_inverseOnSurface = Color(0xFF191C1D)
75+
val md_theme_dark_inverseSurface = Color(0xFFE1E3E3)
76+
val md_theme_dark_inversePrimary = Color(0xFF006876)
77+
val md_theme_dark_shadow = Color(0xFF000000)
78+
val md_theme_dark_surfaceTint = Color(0xFF51D7EE)
79+
val md_theme_dark_outlineVariant = Color(0xFF3F484A)
80+
val md_theme_dark_scrim = Color(0xFF000000)
81+
82+
val seed = Color(0xFF7CD6E7)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package com.amplifyframework.ui.authenticator.theme
17+
18+
import androidx.compose.foundation.isSystemInDarkTheme
19+
import androidx.compose.material3.MaterialTheme
20+
import androidx.compose.material3.darkColorScheme
21+
import androidx.compose.material3.lightColorScheme
22+
import androidx.compose.runtime.Composable
23+
24+
private val LightColors = lightColorScheme(
25+
primary = md_theme_light_primary,
26+
onPrimary = md_theme_light_onPrimary,
27+
primaryContainer = md_theme_light_primaryContainer,
28+
onPrimaryContainer = md_theme_light_onPrimaryContainer,
29+
secondary = md_theme_light_secondary,
30+
onSecondary = md_theme_light_onSecondary,
31+
secondaryContainer = md_theme_light_secondaryContainer,
32+
onSecondaryContainer = md_theme_light_onSecondaryContainer,
33+
tertiary = md_theme_light_tertiary,
34+
onTertiary = md_theme_light_onTertiary,
35+
tertiaryContainer = md_theme_light_tertiaryContainer,
36+
onTertiaryContainer = md_theme_light_onTertiaryContainer,
37+
error = md_theme_light_error,
38+
errorContainer = md_theme_light_errorContainer,
39+
onError = md_theme_light_onError,
40+
onErrorContainer = md_theme_light_onErrorContainer,
41+
background = md_theme_light_background,
42+
onBackground = md_theme_light_onBackground,
43+
surface = md_theme_light_surface,
44+
onSurface = md_theme_light_onSurface,
45+
surfaceVariant = md_theme_light_surfaceVariant,
46+
onSurfaceVariant = md_theme_light_onSurfaceVariant,
47+
outline = md_theme_light_outline,
48+
inverseOnSurface = md_theme_light_inverseOnSurface,
49+
inverseSurface = md_theme_light_inverseSurface,
50+
inversePrimary = md_theme_light_inversePrimary,
51+
surfaceTint = md_theme_light_surfaceTint
52+
)
53+
54+
private val DarkColors = darkColorScheme(
55+
primary = md_theme_dark_primary,
56+
onPrimary = md_theme_dark_onPrimary,
57+
primaryContainer = md_theme_dark_primaryContainer,
58+
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
59+
secondary = md_theme_dark_secondary,
60+
onSecondary = md_theme_dark_onSecondary,
61+
secondaryContainer = md_theme_dark_secondaryContainer,
62+
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
63+
tertiary = md_theme_dark_tertiary,
64+
onTertiary = md_theme_dark_onTertiary,
65+
tertiaryContainer = md_theme_dark_tertiaryContainer,
66+
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
67+
error = md_theme_dark_error,
68+
errorContainer = md_theme_dark_errorContainer,
69+
onError = md_theme_dark_onError,
70+
onErrorContainer = md_theme_dark_onErrorContainer,
71+
background = md_theme_dark_background,
72+
onBackground = md_theme_dark_onBackground,
73+
surface = md_theme_dark_surface,
74+
onSurface = md_theme_dark_onSurface,
75+
surfaceVariant = md_theme_dark_surfaceVariant,
76+
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
77+
outline = md_theme_dark_outline,
78+
inverseOnSurface = md_theme_dark_inverseOnSurface,
79+
inverseSurface = md_theme_dark_inverseSurface,
80+
inversePrimary = md_theme_dark_inversePrimary,
81+
surfaceTint = md_theme_dark_surfaceTint
82+
)
83+
84+
@Composable
85+
fun AmplifyTheme(
86+
useDarkTheme: Boolean = isSystemInDarkTheme(),
87+
content: @Composable () -> Unit
88+
) {
89+
val colors = if (!useDarkTheme) {
90+
LightColors
91+
} else {
92+
DarkColors
93+
}
94+
95+
MaterialTheme(
96+
colorScheme = colors,
97+
content = content
98+
)
99+
}

0 commit comments

Comments
 (0)