Skip to content

Commit

Permalink
Addressing PR comments
Browse files Browse the repository at this point in the history
- Made contactless animation more prominent in Dark theme by setting it
  to the inverse colors of Light theme (except the error case).
- Hard-code text in defaultGraph instead of referencing String resources
  of downstream client from upstream.
- Add EvidenceRequestDetailedMessage to handle showing custom UI for
  specific message types, such as after completing the the
  Provision PID flow.
- Show the transitional success screen after successful NFC scanning
  only when Developer Mode is enabled.
- Updated NFC status text to be even more user friendly.

Signed-off-by: dritan-x <[email protected]>
  • Loading branch information
dritan-x committed Nov 6, 2024
1 parent 5d62fd1 commit e70efb5
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.android.identity.issuance.evidence

import kotlinx.io.bytestring.ByteString

/**
* Detailed rich-text message building on top of [EvidenceRequestMessage] that additionally contains
* a [messageTitle] and a [messageType] that is used to identify the classification of the detailed
* message (such as "completed", "info", "confirmation_XYZ") that allows showing tailored UI
* pertaining to the message.
*
* [messageType] identifier used for classifying message types (success, error, info, ..) to show
* the appropriate UI pertaining to the detailed message.
* [messageTitle] title to show above the message
* [message] message formatted as markdown
* [assets] images that can be referenced in markdown, type (PNG, JPEG, or SVG) determined by the extension
* [acceptButtonText] button label to continue to the next screen
* [rejectButtonText] optional button label to continue without accepting
*/
data class EvidenceRequestDetailedMessage(
val messageType: String,
val messageTitle: String,
val message: String,
val assets: Map<String, ByteString>,
val acceptButtonText: String,
val rejectButtonText: String?,
) : EvidenceRequest()
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@ import kotlinx.io.bytestring.ByteString
* [assets] images that can be referenced in markdown, type (PNG, JPEG, or SVG) determined by the extension
* [acceptButtonText] button label to continue to the next screen
* [rejectButtonText] optional button label to continue without accepting
* [messageType] optional identifier used for classifying message types (success, error, info, ..)
* for showing a more appropriate UI than a standard basic message
* [messageTitle] optional title to show above the message for a non-standard or non-basic message
* that is filtered/classified via the [messageType]
*/
data class EvidenceRequestMessage(
val message: String,
val assets: Map<String, ByteString>,
val acceptButtonText: String,
val rejectButtonText: String?,
val messageType: String? = null,
val messageTitle: String? = null
) : EvidenceRequest()
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.android.identity.issuance.proofing

import com.android.identity.issuance.evidence.EvidenceRequestCreatePassphrase
import com.android.identity.issuance.evidence.EvidenceRequestDetailedMessage
import com.android.identity.issuance.evidence.EvidenceRequestGermanEid
import com.android.identity.issuance.evidence.EvidenceRequestIcaoPassiveAuthentication
import com.android.identity.issuance.evidence.EvidenceRequestMessage
Expand All @@ -27,23 +28,31 @@ class ProofingGraphBuilder {
private val chain = mutableListOf<(Node?) -> Node>()

/** Sends [EvidenceRequestMessage]. */
fun message(
fun message(id: String, message: String, assets: Map<String, ByteString>,
acceptButtonText: String, rejectButtonText: String?) {
val evidenceRequest = EvidenceRequestMessage(message, assets, acceptButtonText, rejectButtonText)
chain.add { followUp -> ProofingGraph.SimpleNode(id, followUp, evidenceRequest) }
}

/** Sends [EvidenceRequestMessage]. */
fun detailedMessage(
id: String,
messageType: String,
messageTitle: String,
message: String,
assets: Map<String, ByteString>,
acceptButtonText: String,
rejectButtonText: String?,
messageType: String? = null,
messageTitle: String? = null

) {
val evidenceRequest =
EvidenceRequestMessage(
EvidenceRequestDetailedMessage(
messageType,
messageTitle,
message,
assets,
acceptButtonText,
rejectButtonText,
messageType,
messageTitle,
)
chain.add { followUp -> ProofingGraph.SimpleNode(id, followUp, evidenceRequest) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,13 @@ fun defaultGraph(
}
}
}
message(
id = "message",
message = resources.getStringResource("R.string.evidence_request_complete_info") ?: """
Your application is about to be sent the ID issuer for verification. You will
get notified when the application is approved.
""".trimIndent(),
detailedMessage(
id = "detailedMessage",
messageType = "evidence_request_complete",
messageTitle = resources.getStringResource("R.string.evidence_request_complete_title")
?: "Submitted for Verification",
messageTitle = "Document Scanning Complete",
message = "Your application is now under ID issuer verification. This process might take a few hours.",
assets = mapOf(),
acceptButtonText = resources.getStringResource("R.string.evidence_request_complete_done_button")
?: "Continue",
acceptButtonText = "Done",
rejectButtonText = null
)
requestNotificationPermission(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.Handler
import androidx.annotation.RawRes
import com.android.identity.flow.handler.FlowNotifications
import com.android.identity.flow.server.Configuration
import com.android.identity.flow.server.FlowEnvironment
import com.android.identity.flow.server.Resources
import com.android.identity.flow.server.Storage
import com.android.identity.flow.server.FlowEnvironment
import com.android.identity.flow.handler.FlowNotifications
import com.android.identity.issuance.ApplicationSupport
import com.android.identity.securearea.SecureArea
import com.android.identity_credential.wallet.R
Expand Down Expand Up @@ -199,28 +199,7 @@ internal class LocalDevelopmentEnvironment(
context.resources.getString(R.string.utopia_local_issuing_authority_photoid_tos)
"funke/tos.html" ->
context.resources.getString(R.string.funke_issuing_authority_tos)
else -> {
// String passthrough allowing upstream code to reference downstream Strings
// there's no need to hard-code/define every possible String in here
if (name.startsWith("R.string.")){
val stringName = name.split("R.string.")[1]
/**
* Localized function resolving a String resource ID from a String's name.
* Note: This approach uses reflection under the hood and is less efficient
* than retrieving a String directly by its identifier. If this ends
* up being a bottleneck we can change the approach of how downstream
* Strings/resources are shared upstream.
*/
fun getStringResId(stringName: String): Int {
return context.resources.getIdentifier(stringName, "string", context.packageName)
}
// return the requested String's value
context.resources.getString(getStringResId(stringName))
} else {
// unknown raw file name or String resource, return null
null
}
}
else -> null
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ fun WalletNavigation(
onNavigate = onNavigate,
permissionTracker = permissionTracker,
walletServerProvider = application.walletServerProvider,
documentStore = application.documentStore
documentStore = application.documentStore,
developerMode = application.settingsModel.developerModeEnabled.value ?: false
)
}

Expand Down
Loading

0 comments on commit e70efb5

Please sign in to comment.