Commit b642c886 authored by dimitrisCBR's avatar dimitrisCBR
Browse files

Add account_status demo functionality

parent 8eb57128
package com.futurae.futuraedemo;
import android.app.Application;
import com.futurae.sdk.FuturaeClient;
import com.futurae.sdk.Kit;
......@@ -8,14 +9,15 @@ import timber.log.Timber;
public class AppMain extends Application {
// overrides
@Override
public final void onCreate() {
// overrides
@Override
public final void onCreate() {
super.onCreate();
super.onCreate();
Timber.plant(new Timber.DebugTree());
boolean adaptiveEnabled = false;
FuturaeClient.launch(this, adaptiveEnabled, (Kit)null);
}
Timber.plant(new Timber.DebugTree());
//adaptive is optional. If you want to use it, make sure you read up our documentation
boolean adaptiveEnabled = true;
FuturaeClient.launch(this, adaptiveEnabled, (Kit) null);
}
}
......@@ -18,6 +18,7 @@ import com.futurae.futuraedemo.databinding.ActivityHomeBinding
import com.futurae.sdk.*
import com.futurae.sdk.approve.ApproveSession
import com.futurae.sdk.model.AccountsMigrationResource
import com.futurae.sdk.model.AccountsStatus
import com.futurae.sdk.model.SessionInfo
import com.google.android.gms.vision.barcode.Barcode
import timber.log.Timber
......@@ -129,6 +130,34 @@ class HomeActivity : AppCompatActivity() {
)
}
binding.performAccStatusButton.setOnClickListener {
val accounts = FuturaeClient.sharedClient().accounts
if (accounts == null || accounts.size == 0) {
showAlert("Error", "No account enrolled")
return@setOnClickListener
}
FuturaeClient.sharedClient()
.getAccountsStatus(accounts.map { it.userId }, object : FuturaeResultCallback<AccountsStatus> {
override fun success(accountsStatus: AccountsStatus) {
accountsStatus.statuses.forEach { accountStatus ->
Timber.d("ScaDebug: Found SCA Account for futurae user id ${accountStatus.userId}")
accountStatus.sessionInfos.forEach { sessionInfo ->
Timber.d("ScaDebug: Found SCA Session ${sessionInfo.sessionId}")
if (sessionInfo.factor == FuturaeClient.APPROVE) {
Timber.d("ScaDebug: SCA Session ${sessionInfo.sessionId} is APPROVE")
}
}
}
}
override fun failure(t: Throwable) {
Timber.e(t)
}
})
}
checkRuntimePermissions()
}
......@@ -235,12 +264,12 @@ class HomeActivity : AppCompatActivity() {
}
override fun failure(t: Throwable) {
Timber.e(t)
showAlert("Error", "Error: ${t.message}")
}
})
} catch (e: MalformedQRCodeException) {
Timber.e(e)
return
}
} ?: showAlert("Error", "QR code not found from result")
}
......@@ -271,6 +300,7 @@ class HomeActivity : AppCompatActivity() {
}
override fun failure(throwable: Throwable) {
Timber.e(throwable)
showAlert("Error", throwable.message ?: "")
}
})
......
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
xmlns:tools="http://schemas.android.com/tools">
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
......@@ -99,42 +99,53 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkMigrationButton" />
<com.google.android.material.button.MaterialButton
android:id="@+id/performAccStatusButton"
style="@style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main_btn_accounts_status"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/performMigrationButton" />
<androidx.cardview.widget.CardView
android:id="@+id/migrationCard"
android:visibility="gone"
tools:visibility="visible"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="50dp"
app:layout_constraintStart_toStartOf="parent"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
tools:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:orientation="vertical">
android:orientation="vertical"
android:padding="20dp">
<TextView
style="@style/TextAppearance.MaterialComponents.Headline5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Migration Progress"/>
android:text="Migration Progress" />
<TextView
style="@style/TextAppearance.MaterialComponents.Subtitle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Fetching fresh observations"/>
android:text="Fetching fresh observations" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_marginTop="20dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
android:layout_marginTop="20dp" />
</LinearLayout>
......
......@@ -10,6 +10,7 @@
<string name="main_btn_qr_code_generic">Scan QR Code</string>
<string name="main_btn_accounts_migration_check">Check account migration</string>
<string name="main_btn_accounts_migration_execute">Execute account migration</string>
<string name="main_btn_accounts_status">Account status</string>
<!--QR CODE-->
<string name="qrcode_title">QR Code</string>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment