Skip to content

Commit

Permalink
Fix: #300 - Delete data wallet implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lijogeorgep authored and josmilan committed Apr 22, 2024
1 parent 0be603f commit f93c1b2
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 24 deletions.
31 changes: 28 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "io.igrant.data4diabetes"
minSdkVersion 21
minSdkVersion 24
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down Expand Up @@ -130,8 +130,9 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.google.android.gms:play-services-mlkit-barcode-scanning:18.0.0"

implementation 'com.github.decentralised-dataexchange:ama-android-sdk:2.5.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "com.github.L3-iGrant:data_wallet:2024.4.1"

implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-dynamic-links-ktx'
Expand All @@ -142,4 +143,28 @@ dependencies {
implementation 'com.github.markomilos:paginate:1.0.0'
implementation 'com.github.marlonlom:timeago:4.0.3'

implementation 'org.hyperledger:indy:1.16.0'
implementation 'net.java.dev.jna:jna:5.6.0'
implementation 'org.apache.commons:commons-lang3:3.7'
implementation 'commons-io:commons-io:2.8.0'
//retrofit
//retrofit and services
implementation('com.squareup.retrofit2:retrofit:2.7.1') {
exclude module: 'okhttp'
}
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.okhttp3:okhttp:4.3.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.3.1'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.airbnb.android:lottie:3.5.0'
implementation 'org.greenrobot:eventbus:3.1.1'
annotationProcessor "org.greenrobot:eventbus-annotation-processor:3.1.1"
implementation 'com.github.koushikcse:LoadingButton:1.7'
implementation 'com.github.mediapark-pk:Base58-android:0.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
implementation 'com.tbuonomo:dotsindicator:4.2'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
}
63 changes: 43 additions & 20 deletions android/app/src/main/kotlin/io/igrant/data4diabetes/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.igrant.data4diabetes

import android.util.Log
import com.github.privacyDashboard.PrivacyDashboard
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import io.igrant.data_wallet.indy.LedgerNetworkType
import io.igrant.data_wallet.utils.DataWallet
import io.igrant.data_wallet.utils.DataWalletConfigurations
import io.igrant.data_wallet.utils.DeleteWalletResult
import io.igrant.data_wallet.utils.InitializeWalletCallback
import io.igrant.data_wallet.utils.InitializeWalletState
import io.igrant.data_wallet.utils.dataAgreement.DataAgreementUtils
Expand All @@ -20,27 +22,7 @@ class MainActivity : FlutterActivity() {

override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
DataWallet.initializeSdk(
this,
object : InitializeWalletCallback {
override fun progressUpdate(progress: Int) {
when (progress) {
InitializeWalletState.INITIALIZE_WALLET_STARTED -> {

}
InitializeWalletState.INITIALIZE_WALLET_EXTERNAL_FILES_LOADED -> {

}
InitializeWalletState.POOL_CREATED -> {

}
InitializeWalletState.WALLET_OPENED -> {
DataWalletConfigurations.registerForSubscription(this@MainActivity)
}
}
}
}, LedgerNetworkType.getSelectedNetwork(this)
)


methodChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
Expand Down Expand Up @@ -194,9 +176,50 @@ class MainActivity : FlutterActivity() {

}
}
"InitWallet"->{
initializeWallet()
}
"DeleteWallet"->{
val response = DataWallet.deleteWallet()
when (response) {
is DeleteWalletResult.Success -> {
// Show success message or perform any other action
DataWallet.releaseSdk()
Log.d("Success","${response.message}")
}
is DeleteWalletResult.Error -> {
// error message
Log.d("Error","${response.errorMessage}")
}
}
}
}
}


}

private fun initializeWallet() {
DataWallet.initializeSdk(
this,
object : InitializeWalletCallback {
override fun progressUpdate(progress: Int) {
when (progress) {
InitializeWalletState.INITIALIZE_WALLET_STARTED -> {

}
InitializeWalletState.INITIALIZE_WALLET_EXTERNAL_FILES_LOADED -> {

}
InitializeWalletState.POOL_CREATED -> {

}
InitializeWalletState.WALLET_OPENED -> {
DataWalletConfigurations.registerForSubscription(this@MainActivity)
}
}
}
}, LedgerNetworkType.getSelectedNetwork(this)
)
}
}
8 changes: 8 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ allprojects {
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://repo.sovrin.org/repository/maven-public'}
maven {
name = "GitHubPackages"
url "https://maven.pkg.github.com/L3-iGrant/ama-android-sdk"
credentials {
username = "L3-iGrant"
password = "xxxxxxxxxxxxxxxxx"
}
}

}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/app/modules/otp/controllers/otp_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:Data4Diabetes/app/modules/Register/controllers/register_controll
import 'package:Data4Diabetes/app/modules/login/controllers/login_controller.dart';
import 'package:Data4Diabetes/app/network/exceptions/api_exception.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';

Expand Down Expand Up @@ -43,7 +44,9 @@ class OtpController extends BaseController {

hideLoading();
verifyOtpController.clear();

var platform = const MethodChannel('io.igrant.data4diabetes.channel');
// initialize wallet
platform.invokeMethod('InitWallet');
Get.offAll(MainView());
}
} catch (e) {
Expand Down
4 changes: 4 additions & 0 deletions lib/app/modules/settings/controllers/settings_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class SettingsController extends BaseController {
await _prefs.remove(key);
}
}
//delete wallet
platform.invokeMethod('DeleteWallet');
Get.offAll(const LauncherView());
}

Expand All @@ -70,6 +72,8 @@ class SettingsController extends BaseController {
color: Colors.green);
SharedPreferences _prefs = await SharedPreferences.getInstance();
_prefs.clear();
// delete wallet
platform.invokeMethod('DeleteWallet');
Get.offAll(const LauncherView());
} else {
GetSnackToast(message: appLocalization.settingsDeleteAccountFail);
Expand Down
3 changes: 3 additions & 0 deletions lib/app/my_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class _MyAppState extends State<MyApp> {
super.initState();
_initLocale();
_initPrivacyDashboard();
var platform = const MethodChannel('io.igrant.data4diabetes.channel');
// initialize wallet
platform.invokeMethod('InitWallet');
}

Future<void> _initLocale() async {
Expand Down

0 comments on commit f93c1b2

Please sign in to comment.