Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the androidx-credentials dependencies to version 1.7.0-alpha02 and introduces the DigitalCredentialIssuer class to facilitate digital credential issuance using the CredentialManager API. It also adds a JSON snippet for OpenID4VCI issuance requests. Review feedback includes correcting a spacing issue in the class declaration, changing a parameter type from Context to Activity to ensure proper UI execution, replacing an unsafe cast with a type check to avoid potential crashes, and addressing unused variables within the exception handler.
| import androidx.credentials.exceptions.CreateCredentialUnknownException | ||
| import androidx.credentials.exceptions.CreateCredentialUnsupportedException | ||
|
|
||
| class DigitalCredentialIssuer : Activity() { |
There was a problem hiding this comment.
There is an extra space before the colon in the class declaration. Additionally, consider if this class needs to inherit from Activity. If it is intended as a utility class for snippets, the inheritance may be unnecessary. This follows the Kotlin Style Guide regarding whitespace.
| class DigitalCredentialIssuer : Activity() { | |
| class DigitalCredentialIssuer : Activity() { |
References
- The Kotlin Style Guide recommends standard spacing around colons in class declarations. (link)
|
|
||
| class DigitalCredentialIssuer : Activity() { | ||
| @OptIn(ExperimentalDigitalCredentialApi::class) | ||
| suspend fun issueToWallet(context: Context) { |
There was a problem hiding this comment.
The CredentialManager.createCredential method requires an Activity context to properly launch the selector UI. It is recommended to change the parameter type from Context to Activity to ensure the caller provides a valid context for UI operations.
| suspend fun issueToWallet(context: Context) { | |
| suspend fun issueToWallet(context: Activity) { |
There was a problem hiding this comment.
What do you think about this Gemini suggestion?
| context = context, | ||
| request = createRequest | ||
| ) | ||
| handleSuccess(response as CreateDigitalCredentialResponse) |
There was a problem hiding this comment.
There was a problem hiding this comment.
I think this is fine as a sample since there's only one flow being illustrated
| val errorType = e.type | ||
| val errorMessage = e.message |
kkuan2011
left a comment
There was a problem hiding this comment.
minor comments for you to consider, otherwise feel free to submit
| context = context, | ||
| request = createRequest | ||
| ) | ||
| handleSuccess(response as CreateDigitalCredentialResponse) |
|
|
||
| class DigitalCredentialIssuer : Activity() { | ||
| @OptIn(ExperimentalDigitalCredentialApi::class) | ||
| suspend fun issueToWallet(context: Context) { |
There was a problem hiding this comment.
What do you think about this Gemini suggestion?
| import androidx.credentials.exceptions.CreateCredentialUnknownException | ||
| import androidx.credentials.exceptions.CreateCredentialUnsupportedException | ||
|
|
||
| class DigitalCredentialIssuer : Activity() { |
There was a problem hiding this comment.
nit: even though it's not in the visible code snippet, should we make this a ComponentActivity to be more compose-first?
There was a problem hiding this comment.
Sure, I don't think this hurts
No description provided.