Skip to content

Commit

Permalink
Added XML implemenetation example
Browse files Browse the repository at this point in the history
  • Loading branch information
gau4sar committed Aug 11, 2022
1 parent 01833be commit cf59f2b
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 4 deletions.
4 changes: 3 additions & 1 deletion androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ dependencies {
implementation("com.github.ballerine-io:ballerine-android-sdk:1.0.4")

implementation("androidx.appcompat:appcompat:1.5.0")
implementation("com.google.android.material:material:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

val compose_version = "1.1.1"
val compose_version = "1.2.1"

implementation ("androidx.core:core-ktx:1.8.0")
implementation ("androidx.activity:activity-compose:1.5.1")
Expand Down
11 changes: 8 additions & 3 deletions androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.ballerine.kmp.example.android">
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.CAMERA" />

<application
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name=".MainActivityXML"
android:exported="true" />

<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
</manifest>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package io.ballerine.kmp.example.android

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.compose.ui.platform.ComposeView
import io.ballerine.android_sdk.BallerineKYCFlowWebView
import java.io.File
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors

class MainActivityXML : AppCompatActivity() {

private lateinit var outputFileDirectory: File
private lateinit var cameraExecutorService: ExecutorService

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main_xml)

outputFileDirectory = getOutputDirectory()
cameraExecutorService = Executors.newSingleThreadExecutor()

findViewById<ComposeView>(R.id.ballerine_kyc_flow).setContent {
BallerineKYCFlowWebView(
outputFileDirectory = outputFileDirectory,
cameraExecutorService = cameraExecutorService,
url = "${MainActivity.BALLERINE_WEB_URL}?b_t=${MainActivity.BALLERINE_API_TOKEN}",
onVerificationComplete = { verificationResult ->

//TODO :: Use the verification result returned

// Here we are just displaying the verification result as Text on the screen
Log.e(localClassName, "Idv result : ${verificationResult.idvResult} \n" +
"Status : ${verificationResult.status} \n" +
"Code : ${verificationResult.code}"
)
})
}
}

// Helper functions

private fun getOutputDirectory(): File {
val mediaDir = externalMediaDirs.firstOrNull()?.let {
File(it, "Document").apply { mkdirs() }
}
return if (mediaDir != null && mediaDir.exists()) mediaDir else filesDir
}

override fun onDestroy() {
super.onDestroy()
cameraExecutorService.shutdown()
}
}
14 changes: 14 additions & 0 deletions androidApp/src/main/res/layout/activity_main_xml.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivityXML">

<androidx.compose.ui.platform.ComposeView
android:id="@+id/ballerine_kyc_flow"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit cf59f2b

Please sign in to comment.