Skip to content

Commit

Permalink
UI Updates to Document Data Screen
Browse files Browse the repository at this point in the history
- Added warning message text, box, and icon
- Showing document data fields according to a specified order defined in the code that matches the slides. Shows remaining fields in an unordered fashion.

Tested by:
- Manual testing by adding Test eID-Karte Personalausweis
- ./gradlew check
- ./gradlew connectedCheck

Signed-off-by: dritan-x <[email protected]>
  • Loading branch information
dritan-x committed Nov 23, 2024
1 parent 981f6dd commit fb6d29e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.android.identity_credential.wallet.ui.destination.document

import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -9,6 +10,8 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -23,12 +26,13 @@ import androidx.compose.ui.draw.rotate
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shadow
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
Expand All @@ -48,6 +52,7 @@ import com.android.identity_credential.wallet.ui.KeyValuePairHtml
import com.android.identity_credential.wallet.ui.KeyValuePairText
import com.android.identity_credential.wallet.ui.ScreenWithAppBarAndBackButton
import com.android.identity_credential.wallet.ui.prompt.biometric.showBiometricPrompt
import com.android.identity_credential.wallet.util.inverse
import kotlinx.coroutines.launch


Expand Down Expand Up @@ -156,14 +161,34 @@ private fun DocumentAuthenticationRequired(
private fun DocumentDetails(
documentInfo: DocumentInfo,
) {
Column() {
Text(
text = stringResource(R.string.document_details_screen_flash_pass_lecture),
textAlign = TextAlign.Center,
fontStyle = FontStyle.Italic,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.padding(8.dp)
)
Column(
modifier = Modifier.padding(top = 20.dp)
) {
Row(
modifier = Modifier
.padding(horizontal = 30.dp)
.padding(bottom = 20.dp)
.border(1.dp, SolidColor(MaterialTheme.colorScheme.outline), RoundedCornerShape(30.dp))
){
Icon(
modifier = Modifier
.size(40.dp)
.padding(top = 20.dp, start = 10.dp, end = 10.dp)
,
painter = painterResource(id = R.drawable.warning),
tint = MaterialTheme.colorScheme.background.inverse(),
contentDescription = stringResource(
R.string.accessibility_artwork_for,
stringResource(id = R.string.document_details_screen_title)
)
)
Text(
modifier = Modifier.padding(top = 20.dp, bottom = 20.dp, end=5.dp),
text = stringResource(R.string.document_details_screen_flash_pass_lecture),
textAlign = TextAlign.Left,
style = MaterialTheme.typography.bodyLarge
)
}

val topImages = listOf("portrait")
val bottomImages = listOf("signature_usual_mark")
Expand All @@ -189,16 +214,32 @@ private fun DocumentDetails(
val centerAttributes = documentInfo.attributes.filter {
!topImages.contains(it.key) && !bottomImages.contains(it.key)
}
for ((attributeId, displayInfo) in centerAttributes) {
when (displayInfo) {

val orderedEntries = listOf(
"issuing_country",
"birth_date",
"expiry_date",
"given_name",
"family_name",
)

val sortedKeys = centerAttributes.keys.sortedBy {keyValue->
if (keyValue in orderedEntries){
orderedEntries.indexOfFirst { it == keyValue }
} else {
Int.MAX_VALUE
}
}
for (sortedKey in sortedKeys) {
when (val displayInfo = centerAttributes[sortedKey]) {
is AttributeDisplayInfoPlainText -> {
KeyValuePairText(displayInfo.name, displayInfo.value)
}
is AttributeDisplayInfoHtml -> {
KeyValuePairHtml(displayInfo.name, displayInfo.value)
}
else -> {
throw IllegalArgumentException("Unsupported attribute display info for $attributeId: $displayInfo")
throw IllegalArgumentException("Unsupported attribute display info for $sortedKey: $displayInfo")
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions wallet/src/main/res/drawable/warning.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="m40,840 l440,-760 440,760L40,840ZM178,760h604L480,240 178,760ZM480,720q17,0 28.5,-11.5T520,680q0,-17 -11.5,-28.5T480,640q-17,0 -28.5,11.5T440,680q0,17 11.5,28.5T480,720ZM440,600h80v-200h-80v200ZM480,500Z"
android:fillColor="#5f6368"/>
</vector>
6 changes: 1 addition & 5 deletions wallet/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,7 @@
<!-- DocumentDetailsScreen -->
<string name="document_details_screen_title">Document Data</string>
<string name="document_details_screen_disclaimer">UNVERIFIED DATA\nDO NOT USE</string>
<string name="document_details_screen_flash_pass_lecture">
Showing this screen is not a secure way of sharing identity data because the verifier
has no way to confirm the authenticity of the data. Use NFC or QR to share identity
data in a secure and privacy-preserving manner.
</string>
<string name="document_details_screen_flash_pass_lecture">Do not share this screen. It is not secure for presenting info directly as authenticity cannot be verified.</string>
<string name="document_details_boolean_true_value">True</string>
<string name="document_details_boolean_false_value">False</string>

Expand Down

0 comments on commit fb6d29e

Please sign in to comment.