Skip to content

Commit

Permalink
Fix #1 - Issuance and Verification
Browse files Browse the repository at this point in the history
  • Loading branch information
josmilan committed Mar 18, 2024
1 parent d18dde6 commit 4f78055
Show file tree
Hide file tree
Showing 43 changed files with 1,964 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
16 changes: 16 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}

buildFeatures {
dataBinding = true
}
}

dependencies {

implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation("androidx.appcompat:appcompat:1.4.2")
implementation("com.google.android.material:material:1.6.1")
implementation("androidx.activity:activity-compose:1.7.0")
implementation(platform("androidx.compose:compose-bom:2023.08.00"))
implementation("androidx.compose.ui:ui")
Expand All @@ -67,4 +73,14 @@ dependencies {
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")

implementation("com.nimbusds:nimbus-jose-jwt:9.21")

implementation("com.github.L3-iGrant:qrcode_scanner_android:3.1.1")
implementation("com.google.zxing:core:3.4.1")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")

implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1")

}
8 changes: 5 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -11,12 +12,13 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.EudiWalletOIDCAndroid"
tools:targetApi="31">
tools:targetApi="31"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.EudiWalletOIDCAndroid">
android:theme="@style/Theme.AppCompat.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
123 changes: 86 additions & 37 deletions app/src/main/java/com/ewc/eudiwalletoidcandroid/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,47 +1,96 @@
package com.ewc.eudiwalletoidcandroid

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.ewc.eudi_wallet_oidc_android.EudiWallet
import com.ewc.eudiwalletoidcandroid.ui.theme.EudiWalletOIDCAndroidTheme

class MainActivity : ComponentActivity() {
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import com.ewc.eudi_wallet_oidc_android.services.did.DIDService
import com.ewc.eudiwalletoidcandroid.databinding.ActivityMainBinding
import io.igrant.qrcode_scanner_android.qrcode.utils.QRScanner

class MainActivity : AppCompatActivity() {

companion object {
const val REQUEST_CODE_SCAN_ISSUE = 101
const val REQUEST_CODE_SCAN_VERIFY = 102
}

private var viewModel: MainViewModel? = null
private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
EudiWalletOIDCAndroidTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Greeting("Android")
}
binding =
DataBindingUtil.setContentView(this, R.layout.activity_main)

viewModel = ViewModelProvider(this)[MainViewModel::class.java]
binding.viewModel = viewModel
binding.lifecycleOwner = this
viewModel?.subJwk = DIDService().createJWK()
viewModel?.did = DIDService().createDID(viewModel?.subJwk!!)

initClicks()
}

private fun initClicks() {
binding.addCredential.setOnClickListener {
binding.tvCredential.text = ""
QRScanner().withLocale("en").start(
this,
REQUEST_CODE_SCAN_ISSUE
)
}

binding.verifyCredential.setOnClickListener {
QRScanner().withLocale("en").start(
this,
REQUEST_CODE_SCAN_VERIFY
)
}

binding.verifyPin.setOnClickListener {
if (binding.etPin.text.length == 4) {
viewModel?.verifyPin(binding.etPin.text.toString())

binding.etPin.visibility = View.GONE
binding.verifyPin.visibility = View.GONE
binding.etPin.text.clear()
}
}
}
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello ${EudiWallet.sayHello()}!",
modifier = modifier
)
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
EudiWalletOIDCAndroidTheme {
Greeting("Android")

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK) {
when (requestCode) {
REQUEST_CODE_SCAN_ISSUE -> {
if (data == null) return

val url = try {
data.getStringExtra("com.blikoon.qrcodescanner.got_qr_scan_relult")
} catch (e: Exception) {
""
}

viewModel?.issueCredential(url ?: "")
}

REQUEST_CODE_SCAN_VERIFY -> {
if (data == null) return

val url = try {
data.getStringExtra("com.blikoon.qrcodescanner.got_qr_scan_relult")
} catch (e: Exception) {
""
}

viewModel?.verifyCredential(url ?: "")
}
}
}
}

}
Loading

0 comments on commit 4f78055

Please sign in to comment.