taler-code-examples

Reference examples (sample code)
Log | Files | Refs | README | LICENSE

commit 1356af6ca4a8b9b8c0b77b8744b702474a6c006a
parent 4cd15738e030ac1bce359e5bda7dcd1fa7d4d77d
Author: Iván Ávalos <avalos@disroot.org>
Date:   Thu, 19 Sep 2024 23:02:42 +0200

add wallet/Anastasis code examples

Diffstat:
AAndroid/anastasis-integration-demo-app/anastasis-lib/.gitignore | 2++
AAndroid/anastasis-integration-demo-app/anastasis-lib/build.gradle.kts | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-lib/consumer-rules.pro | 0
AAndroid/anastasis-integration-demo-app/anastasis-lib/proguard-rules.pro | 22++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-lib/src/main/AndroidManifest.xml | 32++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/contract/ActivityResultContracts.kt | 222+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/model/AnastasisResults.kt | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/provider/BackupFileProvider.kt | 22++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/utils/AnastasisFileUtils.kt | 44++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/utils/SecretCodec.kt | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-lib/src/main/res/xml/provider_paths.xml | 22++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/.gitignore | 2++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/build.gradle.kts | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/proguard-rules.pro | 22++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/AndroidManifest.xml | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/MainActivity.kt | 107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/components/LibraryUsageExamples.kt | 183+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/components/UsageExamples.kt | 552+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/ui/theme/Color.kt | 28++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/ui/theme/Theme.kt | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/ui/theme/Type.kt | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/utils/Utils.kt | 49+++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/drawable/ic_launcher_background.xml | 170+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/drawable/ic_launcher_foreground.xml | 30++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 6++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml | 6++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher.webp | 0
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher_round.webp | 0
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher.webp | 0
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher_round.webp | 0
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher.webp | 0
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp | 0
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher.webp | 0
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp | 0
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp | 0
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp | 0
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/values/colors.xml | 10++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/values/strings.xml | 4++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/values/themes.xml | 5+++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/xml/backup_rules.xml | 13+++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/xml/data_extraction_rules.xml | 19+++++++++++++++++++
AAndroid/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/xml/provider_paths.xml | 6++++++
AAndroid/anastasis-integration-demo-app/build.gradle.kts | 4++++
AAndroid/anastasis-integration-demo-app/gradle.properties | 24++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/gradle/libs.versions.toml | 22++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/gradle/wrapper/gradle-wrapper.jar | 0
AAndroid/anastasis-integration-demo-app/gradle/wrapper/gradle-wrapper.properties | 6++++++
AAndroid/anastasis-integration-demo-app/gradlew | 185+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/gradlew.bat | 89+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/anastasis-integration-demo-app/settings.gradle.kts | 24++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/build.gradle.kts | 6++++++
AAndroid/wallet-integration-demo-app/gradle.properties | 24++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/gradle/libs.versions.toml | 22++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/gradle/wrapper/gradle-wrapper.jar | 0
AAndroid/wallet-integration-demo-app/gradle/wrapper/gradle-wrapper.properties | 6++++++
AAndroid/wallet-integration-demo-app/gradlew | 185+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/gradlew.bat | 89+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/settings.gradle.kts | 25+++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/.gitignore | 2++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/build.gradle.kts | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/proguard-rules.pro | 22++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/AndroidManifest.xml | 42++++++++++++++++++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/MainActivity.kt | 289++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/ui/theme/Color.kt | 28++++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/ui/theme/Theme.kt | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/ui/theme/Type.kt | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/drawable/ic_launcher_background.xml | 186+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/drawable/ic_launcher_foreground.xml | 47+++++++++++++++++++++++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 23+++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml | 23+++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher.webp | 0
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher_round.webp | 0
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher.webp | 0
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher_round.webp | 0
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher.webp | 0
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp | 0
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher.webp | 0
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp | 0
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp | 0
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp | 0
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/values/colors.xml | 27+++++++++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/values/strings.xml | 20++++++++++++++++++++
AAndroid/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/values/themes.xml | 22++++++++++++++++++++++
83 files changed, 3742 insertions(+), 0 deletions(-)

diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/.gitignore b/Android/anastasis-integration-demo-app/anastasis-lib/.gitignore @@ -0,0 +1 @@ +/build +\ No newline at end of file diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/build.gradle.kts b/Android/anastasis-integration-demo-app/anastasis-lib/build.gradle.kts @@ -0,0 +1,59 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +plugins { + id("com.android.library") + id("kotlin-android") +} + +android { + namespace = "net.taler.anastasislib" + compileSdk = 34 + + defaultConfig { + minSdk = 24 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } +} + +dependencies { + + implementation("androidx.core:core-ktx:1.13.1") + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("com.google.android.material:material:1.12.0") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.2.0") + androidTestImplementation("androidx.test.espresso:espresso-core:3.6.0") +} +\ No newline at end of file diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/consumer-rules.pro b/Android/anastasis-integration-demo-app/anastasis-lib/consumer-rules.pro diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/proguard-rules.pro b/Android/anastasis-integration-demo-app/anastasis-lib/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile +\ No newline at end of file diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/src/main/AndroidManifest.xml b/Android/anastasis-integration-demo-app/anastasis-lib/src/main/AndroidManifest.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + + <application> + <provider + android:name="net.taler.anastasislib.provider.BackupFileProvider" + android:authorities="${applicationId}.fileprovider" + android:exported="false" + android:grantUriPermissions="true"> + <meta-data + android:name="android.support.FILE_PROVIDER_PATHS" + android:resource="@xml/provider_paths" /> + </provider> + </application> + +</manifest> diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/contract/ActivityResultContracts.kt b/Android/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/contract/ActivityResultContracts.kt @@ -0,0 +1,222 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasislib.contract + +import android.app.PendingIntent +import android.content.ClipData +import android.content.Context +import android.content.Intent +import android.net.Uri +import androidx.activity.result.contract.ActivityResultContract +import net.taler.anastasislib.model.AnastasisBackupResult +import net.taler.anastasislib.model.AnastasisRecoveryResult +import net.taler.anastasislib.model.AnastasisResultCode +import net.taler.anastasislib.utils.SecretCodec + +class AnastasisActivityResultContracts { + + /** + * Contract for launching Anastasis for backup. + */ + class BackupSecret private constructor( + private val appId: String?, + private val appName: String?, + private val secretName: String, + private val secretText: String?, + private val secretFileContentUri: Uri?, + private val expirationDateTime: String?, + ) : ActivityResultContract<Unit, AnastasisBackupResult>() { + + constructor( + appId: String? = null, + appName: String? = null, + secretName: String, + secretText: String, + expirationDateTime: String? = null + ) : this(appId, appName, secretName, secretText, null, expirationDateTime) + + constructor( + appId: String? = null, + appName: String? = null, + secretName: String, + secretFileUri: Uri, + expirationDateTime: String? = null + ) : this(appId, appName, secretName, null, secretFileUri, expirationDateTime) + + override fun createIntent(context: Context, input: Unit): Intent { + val uriBuilder = Uri.Builder() + .scheme("anastasis") + .authority("backup") + .appendEncodedPath(appId) + .appendPath(secretName) + + if (!secretText.isNullOrBlank()) { + uriBuilder.appendQueryParameter( + "secret", + SecretCodec.encode(secretText.toByteArray()) + ) + } + if (!appName.isNullOrBlank()) { + uriBuilder.appendQueryParameter("app_name", appName) + } + if (!expirationDateTime.isNullOrEmpty()) { + uriBuilder.appendQueryParameter("expiration_datetime", expirationDateTime) + } + + val intent = Intent("anastasis.intent.action.backup").run { + data = uriBuilder.build() + if (secretFileContentUri != null) { + clipData = ClipData.newRawUri("", secretFileContentUri) + flags = Intent.FLAG_GRANT_READ_URI_PERMISSION + } + val pendingIntent = PendingIntent.getActivity( + context, + 0, + Intent(), + PendingIntent.FLAG_IMMUTABLE + ) + putExtra("pending_intent", pendingIntent) + Intent.createChooser(this, "") + } + + return intent + } + + override fun parseResult(resultCode: Int, intent: Intent?): AnastasisBackupResult { + var resultData: AnastasisBackupResult + try { + val data = intent?.data?.pathSegments + when (resultCode) { + AnastasisResultCode.BACKUP_SUCCESS -> { + resultData = AnastasisBackupResult.Success( + resultCode = resultCode, + secretName = data!![1], + expirationDateTime = data[2], + message = data[3], + ) + } + + else -> { + resultData = AnastasisBackupResult.Error( + resultCode = resultCode, + message = data!![1], + ) + } + } + } catch (e: Exception) { + resultData = AnastasisBackupResult.Error( + resultCode = AnastasisResultCode.ERROR_INTERNAL, + message = "Internal error occurred while handling the result." + ) + } + + return resultData + } + } + + /** + * Contract for launching Anastasis for recovery. + */ + class RecoverSecret( + private val _appId: String? = null, + private val _appName: String? = null, + private val _secretName: String? = null, + private val _isPrimaryConstructor: Boolean, /* Just to resolve JVM constructors clash */ + ) : ActivityResultContract<Unit, AnastasisRecoveryResult>() { + + constructor( + appId: String, + appName: String? = null, + secretName: String, + ) : this( + _appId = appId, + _appName = appName, + _secretName = secretName, + _isPrimaryConstructor = false + ) + + constructor( + appId: String? = null, + appName: String? = null + ) : this( + _appId = appId, + _appName = appName, + _isPrimaryConstructor = false + ) + + override fun createIntent(context: Context, input: Unit): Intent { + val uriBuilder = Uri.Builder() + .scheme("anastasis") + .authority("recovery") + + if (!_appId.isNullOrBlank()) { + uriBuilder.appendEncodedPath(_appId) + // Secret name can only be provided if an app id is provided + if (!_secretName.isNullOrBlank()) { + uriBuilder.appendPath(_secretName) + } + } + if (!_appName.isNullOrBlank()) { + uriBuilder.appendQueryParameter("app_name", _appName) + } + + val intent = Intent("anastasis.intent.action.recovery").run { + data = uriBuilder.build() + val pendingIntent = PendingIntent.getActivity( + context, + 0, + Intent(), + PendingIntent.FLAG_IMMUTABLE + ) + putExtra("pending_intent", pendingIntent) + Intent.createChooser(this, "") + } + + return intent + } + + override fun parseResult(resultCode: Int, intent: Intent?): AnastasisRecoveryResult { + var resultData: AnastasisRecoveryResult + try { + val data = intent?.data?.pathSegments + when (resultCode) { + AnastasisResultCode.RECOVERY_SUCCESS -> { + resultData = AnastasisRecoveryResult.Success( + resultCode = resultCode, + secretFileContentUri = intent?.clipData?.getItemAt(0)!!.uri, + message = data!![1], + ) + } + + else -> { + resultData = AnastasisRecoveryResult.Error( + resultCode = resultCode, + message = data!![1], + ) + } + } + } catch (e: Exception) { + resultData = AnastasisRecoveryResult.Error( + resultCode = AnastasisResultCode.ERROR_INTERNAL, + message = "Internal error occurred while handling the result." + ) + } + + return resultData + } + } +} diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/model/AnastasisResults.kt b/Android/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/model/AnastasisResults.kt @@ -0,0 +1,84 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasislib.model + +import android.net.Uri + +sealed class AnastasisBackupResult( + open val resultCode: Int, + open val message: String?, +) { + data class Success( + override val resultCode: Int, + override val message: String? = null, + val secretName: String, + val expirationDateTime: String, + ) : AnastasisBackupResult(resultCode, message) + + data class Error( + override val resultCode: Int, + override val message: String? = null, + ) : AnastasisBackupResult(resultCode, message) +} + +sealed class AnastasisRecoveryResult( + open val resultCode: Int, + open val message: String?, +) { + data class Success( + override val resultCode: Int, + override val message: String? = null, + val secretFileContentUri: Uri, + ) : AnastasisRecoveryResult(resultCode, message) + + data class Error( + override val resultCode: Int, + override val message: String? = null, + ) : AnastasisRecoveryResult(resultCode, message) +} + +object AnastasisResultCode { + /** + * Similar to Activity.CANCELED. + */ + const val ERROR_USER_ABORTED = 0 + + /** + * Invalid or missing data received from the caller app. + */ + const val ERROR_INVALID_DATA = 1 + + /** + * Internal error in Anastasis. + */ + const val ERROR_INTERNAL = 2 + + /** + * Secret not found. + */ + const val SECRET_NOT_FOUND = 3 + + /** + * Backup success. + */ + const val BACKUP_SUCCESS = 100 + + /** + * Recovery success. + */ + const val RECOVERY_SUCCESS = 101 +} +\ No newline at end of file diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/provider/BackupFileProvider.kt b/Android/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/provider/BackupFileProvider.kt @@ -0,0 +1,22 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasislib.provider + +import androidx.core.content.FileProvider +import net.taler.anastasislib.R + +class BackupFileProvider : FileProvider(R.xml.provider_paths) diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/utils/AnastasisFileUtils.kt b/Android/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/utils/AnastasisFileUtils.kt @@ -0,0 +1,44 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasislib.utils + +import android.content.Context +import android.net.Uri +import java.io.File + +object AnastasisFileUtils { + /** + * Returns the directory in which caller apps can use to create their own files to be backed up. + */ + fun getBackupFilesDir(context: Context): File = context.cacheDir + + /** + * Returns file name of a file content URI. + */ + fun getFilename(uri: Uri): String? = uri.lastPathSegment + + /** + * Returns the MIME type of a file content URI. + */ + fun getFileMimeType(context: Context, uri: Uri): String? = context.contentResolver.getType(uri) + + /** + * Returns the plain text content of a text file content URI. + */ + fun getFileContent(context: Context, uri: Uri): String? = + context.contentResolver.openInputStream(uri).use { it?.readBytes()?.decodeToString() } +} diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/utils/SecretCodec.kt b/Android/anastasis-integration-demo-app/anastasis-lib/src/main/java/net/taler/anastasislib/utils/SecretCodec.kt @@ -0,0 +1,105 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasislib.utils + +import kotlin.math.floor + +/** + * Contains helper functions to encode/decode text secrets. + */ +internal object SecretCodec { + private const val encTableCrock = "0123456789ABCDEFGHJKMNPQRSTVWXYZ" + + /** + * Encodes a ByteArray to Crock Base32. + */ + fun encode(bytes: ByteArray): String { + var sb = "" + val size = bytes.size + var bitBuf = 0 + var numBits = 0 + var pos = 0 + while (pos < size || numBits > 0) { + if (pos < size && numBits < 5) { + val d = bytes[pos++] + bitBuf = bitBuf.shl(8).or(d.toInt()) + numBits += 8 + } + if (numBits < 5) { + // zero-padding + bitBuf = bitBuf.shl(5 - numBits) + numBits = 5 + } + val v = bitBuf.ushr(numBits - 5).and(31) + sb += encTableCrock[v] + numBits -= 5 + } + return sb + } + + /** + * Decodes a string from Crock Base32. + */ + fun decode(e: String): ByteArray { + val size = e.length + var bitpos = 0 + var bitbuf = 0 + var readPosition = 0 + val outLen = floor((size * 5f) / 8).toInt() + val out = ByteArray(outLen) + var outPos = 0 + while (readPosition < size || bitpos > 0) { + if (readPosition < size) { + val v = getValue(e[readPosition++]) + bitbuf = bitbuf.shl(5).or(v) + bitpos += 5 + } + while (bitpos >= 8) { + val d = bitbuf.shr(bitpos - 8).and(0xff).toByte() + out[outPos++] = d + bitpos -= 8 + } + if (readPosition == size && bitpos > 0) { + bitbuf = bitbuf.shl(8 - bitpos).and(0xff) + bitpos = if (bitbuf == 0) 0 else 8 + } + } + return out + } + + private fun getValue(c: Char): Int { + val a = when (c) { + 'o', 'O' -> '0' + 'i', 'I', 'l', 'L' -> '1' + 'u', 'U' -> 'V' + else -> c + } + if (a in '0'..'9') { + return a - '0' + } + val A = if (a in 'a'..'z') a.uppercaseChar() else a + var dec = 0 + if (A in 'A'..'Z') { + if ('I' < A) dec++ + if ('L' < A) dec++ + if ('O' < A) dec++ + if ('U' < A) dec++ + return A - 'A' + 10 - dec + } + throw Error("encoding error") + } +} diff --git a/Android/anastasis-integration-demo-app/anastasis-lib/src/main/res/xml/provider_paths.xml b/Android/anastasis-integration-demo-app/anastasis-lib/src/main/res/xml/provider_paths.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<paths> + <cache-path + name="backup-files" + path="/" /> +</paths> diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/.gitignore b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/.gitignore @@ -0,0 +1 @@ +/app/build +\ No newline at end of file diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/build.gradle.kts b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/build.gradle.kts @@ -0,0 +1,83 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "net.taler.anastasistestdriverapp" + compileSdk = 34 + + defaultConfig { + applicationId = "net.taler.anastasistestdriverapp" + minSdk = 24 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } + buildFeatures { + compose = true + buildConfig = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.14" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + implementation(project(":anastasis-lib")) + // Android + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2") + // Compose + implementation("androidx.activity:activity-compose:1.8.0") + implementation(platform("androidx.compose:compose-bom:2023.10.01")) + implementation("androidx.compose.ui:ui") + implementation("androidx.compose.ui:ui-graphics") + implementation("androidx.compose.ui:ui-tooling-preview") + debugImplementation("androidx.compose.ui:ui-tooling") + debugImplementation("androidx.compose.ui:ui-test-manifest") + implementation("androidx.compose.material3:material3") +} diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/proguard-rules.pro b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile +\ No newline at end of file diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/AndroidManifest.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/AndroidManifest.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools"> + + <application + android:allowBackup="true" + android:dataExtractionRules="@xml/data_extraction_rules" + android:fullBackupContent="@xml/backup_rules" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:roundIcon="@mipmap/ic_launcher_round" + android:supportsRtl="true" + android:theme="@style/Theme.AnastasisTestDriverApp" + tools:targetApi="31"> + <activity + android:name="net.taler.anastasistestdriverapp.MainActivity" + android:exported="true" + android:label="@string/app_name" + android:theme="@style/Theme.AnastasisTestDriverApp"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + <provider + android:name="androidx.core.content.FileProvider" + android:authorities="net.taler.anastasistestdriverapp.fileprovider" + android:exported="false" + android:grantUriPermissions="true" + tools:replace="android:authorities"> + <meta-data + android:name="android.support.FILE_PROVIDER_PATHS" + android:resource="@xml/provider_paths" /> + </provider> + </application> + +</manifest> diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/MainActivity.kt b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/MainActivity.kt @@ -0,0 +1,107 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasistestdriverapp + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Divider +import androidx.compose.material3.Scaffold +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import net.taler.anastasistestdriverapp.components.ExternalFileExample +import net.taler.anastasistestdriverapp.components.LibraryUsageBackupExample +import net.taler.anastasistestdriverapp.components.LibraryUsageRecoveryExample +import net.taler.anastasistestdriverapp.components.OwnFileExample +import net.taler.anastasistestdriverapp.components.RecoveryExample +import net.taler.anastasistestdriverapp.components.TextExample +import net.taler.anastasistestdriverapp.ui.theme.AnastasisTestDriverAppTheme + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + AnastasisTestDriverAppTheme { + Scaffold(Modifier.fillMaxSize()) { innerPadding -> + HomeScreen(Modifier.padding(innerPadding)) + } + } + } + } +} + +@Composable +fun HomeScreen(modifier: Modifier = Modifier) { + Column( + verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.Top), + modifier = modifier + .fillMaxSize() + .verticalScroll(rememberScrollState()), + ) { + TextExample() + Divider( + Modifier + .padding(top = 12.dp) + .fillMaxWidth() + ) + ExternalFileExample() + Divider( + Modifier + .padding(top = 12.dp) + .fillMaxWidth() + ) + OwnFileExample() + Divider( + Modifier + .padding(top = 12.dp) + .fillMaxWidth() + ) + RecoveryExample() + Divider( + Modifier + .padding(top = 12.dp) + .fillMaxWidth() + ) + LibraryUsageBackupExample() + Divider( + Modifier + .padding(top = 12.dp) + .fillMaxWidth() + ) + LibraryUsageRecoveryExample() + } +} + +@Preview(showBackground = true, showSystemUi = true) +@Composable +fun HomeScreenPreview() { + AnastasisTestDriverAppTheme { + HomeScreen() + } +} diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/components/LibraryUsageExamples.kt b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/components/LibraryUsageExamples.kt @@ -0,0 +1,183 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasistestdriverapp.components + +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.launch +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.core.content.FileProvider +import net.taler.anastasislib.contract.AnastasisActivityResultContracts +import net.taler.anastasislib.model.AnastasisBackupResult +import net.taler.anastasislib.model.AnastasisRecoveryResult +import net.taler.anastasislib.utils.AnastasisFileUtils +import net.taler.anastasistestdriverapp.BuildConfig +import java.io.File + +@Composable +fun LibraryUsageBackupExample(modifier: Modifier = Modifier) { + val appId = "net.taler.anastasistestdriverapp" + val appName = "Gmail App" + val secretName = "Account password" + val expirationDateTime = "2030-01-01T08:30:15" + + val context = LocalContext.current + val file = File( + AnastasisFileUtils.getBackupFilesDir(context), + "example-lib-secret-file.txt" + ) + file.writeText( + "Long secret data included in the file.\n" + + "Email: TestAcc@gmail.com\n" + + "Password: 123456789" + ) + val secretFileContentUri = FileProvider.getUriForFile( + context, + "${BuildConfig.APPLICATION_ID}.fileprovider", + file, + ) + + var backupResult by remember { mutableStateOf("") } + val anastasisLauncher = rememberLauncherForActivityResult( + contract = AnastasisActivityResultContracts.BackupSecret( + appId = appId, + appName = appName, + secretName = secretName, + secretFileUri = secretFileContentUri, + expirationDateTime = expirationDateTime, + ) + ) { result -> + backupResult = when (result) { + is AnastasisBackupResult.Success -> { + "${result.message}\n" + + "Secret name: ${result.secretName}\n" + + "Expiration: ${result.expirationDateTime}" + } + + is AnastasisBackupResult.Error -> { + "${result.message}" + } + } + } + + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(16.dp), + modifier = modifier.fillMaxSize() + ) { + Text( + "Library Usage Example (Backup)", + style = MaterialTheme.typography.headlineMedium, + fontWeight = FontWeight.Bold, + color = Color.Blue, + textAlign = TextAlign.Center, + modifier = Modifier.padding(16.dp), + ) + Button( + onClick = { + anastasisLauncher.launch() + }, + ) { + Text("Back up using Anastasis") + } + } + + Text( + text = backupResult, + fontSize = 16.sp, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth() + ) +} + +@Composable +fun LibraryUsageRecoveryExample(modifier: Modifier = Modifier) { + val appId = "net.taler.anastasistestdriverapp" + val appName = "Gmail App" + val secretName = "Account password" + + var recoveryResult by remember { mutableStateOf("") } + val anastasisLauncher = rememberLauncherForActivityResult( + contract = AnastasisActivityResultContracts.RecoverSecret( + appId = appId, + appName = appName, + secretName = secretName, + ) + ) { result -> + recoveryResult = when (result) { + is AnastasisRecoveryResult.Success -> { + "${result.message}\n Secret file content URI: ${result.secretFileContentUri}" + } + + is AnastasisRecoveryResult.Error -> { + "${result.message}" + } + } + } + + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(16.dp), + modifier = modifier.fillMaxSize() + ) { + Text( + "Library Usage Example (Recovery)", + style = MaterialTheme.typography.headlineMedium, + fontWeight = FontWeight.Bold, + color = Color.Blue, + textAlign = TextAlign.Center, + modifier = Modifier.padding(16.dp), + ) + Button( + onClick = { + anastasisLauncher.launch() + }, + ) { + Text("Recover using Anastasis") + } + } + + Text( + text = recoveryResult, + fontSize = 16.sp, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth() + ) +} diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/components/UsageExamples.kt b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/components/UsageExamples.kt @@ -0,0 +1,552 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasistestdriverapp.components + +import android.app.PendingIntent +import android.content.ClipData +import android.content.Intent +import android.net.Uri +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.text.selection.SelectionContainer +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.core.content.FileProvider +import net.taler.anastasistestdriverapp.utils.Utils +import java.io.File + +@Composable +fun TextExample(modifier: Modifier = Modifier) { + var appId by remember { + mutableStateOf("net.taler.anastasistestdriverapp") + } + + var appName by remember { + mutableStateOf("Gmail App") + } + + var secretName by remember { + mutableStateOf("Account password") + } + + var secret by remember { + mutableStateOf("123456") + } + + var expirationDateTime by remember { + mutableStateOf("2030-01-01T08:30:15") + } + + val uri by remember { + derivedStateOf { + val uriBuilder = Uri.Builder() + .scheme("anastasis") + .authority("backup") + .appendEncodedPath(appId) // appId is actually not encoded and we don't want to. + .appendPath(secretName) + .appendQueryParameter( + "secret", + Utils.encodeSecretToBase32(secret.toByteArray()) + ) + if (appName.isNotBlank()) { + uriBuilder.appendQueryParameter("app_name", appName) + } + if (expirationDateTime.isNotBlank()) { + uriBuilder.appendQueryParameter("expiration_datetime", expirationDateTime) + } + uriBuilder.build() + } + } + + var backupResult by remember { mutableStateOf("") } + val anastasisLauncher = rememberLauncherForActivityResult( + contract = ActivityResultContracts.StartActivityForResult() + ) { activityResult -> + val data = activityResult.data?.data?.pathSegments + when (activityResult.resultCode) { + 0 -> backupResult = "User aborted the process" + 1 -> backupResult = "Invalid input: ${data!![1]}" + 2 -> backupResult = "Internal error occurred" + 100 -> backupResult = "Backup succeeded: \n" + + "(secret name: ${data!![1]}) \n" + + "(expiration date: ${data[2]})" + } + } + + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(16.dp), + modifier = modifier.fillMaxSize() + ) { + Text( + "Text Example", + style = MaterialTheme.typography.headlineMedium, + fontWeight = FontWeight.Bold, + color = Color.Blue, + modifier = Modifier.padding(16.dp), + ) + + TextField( + label = { + Text(text = "App ID") + }, + value = appId, + onValueChange = { appId = it }, + textStyle = TextStyle(fontSize = 16.sp), + modifier = Modifier.fillMaxWidth(), + ) + + TextField( + label = { + Text(text = "App Name (Optional)") + }, + value = appName, + onValueChange = { appName = it }, + textStyle = TextStyle(fontSize = 16.sp), + modifier = Modifier.fillMaxWidth(), + ) + + TextField( + label = { + Text(text = "Secret Name") + }, + value = secretName, + onValueChange = { secretName = it }, + textStyle = TextStyle(fontSize = 16.sp), + modifier = Modifier.fillMaxWidth(), + ) + + TextField( + label = { + Text(text = "Secret") + }, + value = secret, + onValueChange = { secret = it }, + textStyle = TextStyle(fontSize = 16.sp), + modifier = Modifier.fillMaxWidth(), + ) + + TextField( + label = { + Text(text = "Expiration date-time (Optional)") + }, + value = expirationDateTime, + onValueChange = { expirationDateTime = it }, + textStyle = TextStyle(fontSize = 16.sp), + modifier = Modifier.fillMaxWidth(), + ) + + Text( + "URI:", + textAlign = TextAlign.Center, + fontWeight = FontWeight.Bold, + modifier = Modifier.padding(horizontal = 8.dp) + ) + Text( + "$uri", + textAlign = TextAlign.Center, + modifier = Modifier.padding(horizontal = 8.dp) + ) + + val context = LocalContext.current + Button( + onClick = { + val intent = Intent("anastasis.intent.action.backup").run { + data = uri + val pendingIntent = PendingIntent.getActivity( + context, + 0, + Intent(), + PendingIntent.FLAG_IMMUTABLE + ) + putExtra("pending_intent", pendingIntent) + Intent.createChooser(this, "") + } + anastasisLauncher.launch(intent) + }, + ) { + Text("Back up using Anastasis") + } + + Text( + text = backupResult, + fontSize = 16.sp, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth() + ) + } +} + +@Composable +fun ExternalFileExample(modifier: Modifier = Modifier) { + var secretFileContentUri by remember { mutableStateOf<Uri?>(null) } + val uri by remember { + derivedStateOf { + Uri.Builder() + .scheme("anastasis") + .authority("backup") + .appendEncodedPath("net.taler.anastasistestdriverapp") // appId is actually not encoded and we don't want to. + .appendPath("Account Credentials") + .build() + } + } + + var backupResult by remember { mutableStateOf("") } + val anastasisLauncher = rememberLauncherForActivityResult( + contract = ActivityResultContracts.StartActivityForResult() + ) { activityResult -> + val data = activityResult.data?.data?.pathSegments + when (activityResult.resultCode) { + 0 -> backupResult = "User aborted the process" + 1 -> backupResult = "Invalid input: ${data!![1]}" + 2 -> backupResult = "Internal error occurred" + 100 -> backupResult = "Backup succeeded: \n" + + "(secret name: ${data!![1]}) \n" + + "(expiration date: ${data[2]})" + } + } + val filePickerLauncher = rememberLauncherForActivityResult( + contract = ActivityResultContracts.GetContent(), + onResult = { + it?.let { uri -> secretFileContentUri = uri } + } + ) + + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(16.dp), + modifier = modifier.fillMaxWidth() + ) { + + Text( + "External File Example", + style = MaterialTheme.typography.headlineMedium, + fontWeight = FontWeight.Bold, + color = Color.Blue, + modifier = Modifier.padding(horizontal = 16.dp), + ) + + OutlinedButton( + onClick = { filePickerLauncher.launch("*/*") }, + shape = MaterialTheme.shapes.small, + modifier = Modifier.padding(top = 16.dp) + ) { + Text("Pick a file") + } + + SelectionContainer { + Text( + text = secretFileContentUri?.toString() ?: "No selected file", + fontSize = 16.sp, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth() + ) + } + + val context = LocalContext.current + Button( + onClick = { + val intent = Intent("anastasis.intent.action.backup").run { + data = uri + clipData = ClipData.newRawUri("", secretFileContentUri) + addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + val pendingIntent = PendingIntent.getActivity( + context, + 0, + Intent(), + PendingIntent.FLAG_IMMUTABLE + ) + putExtra("pending_intent", pendingIntent) + Intent.createChooser(this, "") + } + anastasisLauncher.launch(intent) + }, + ) { + Text("Back up using Anastasis") + } + + Text( + text = backupResult, + fontSize = 16.sp, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth() + ) + } +} + +@Composable +fun OwnFileExample(modifier: Modifier = Modifier) { + val context = LocalContext.current + val uri by remember { + derivedStateOf { + Uri.Builder() + .scheme("anastasis") + .authority("backup") + .appendEncodedPath("net.taler.anastasistestdriverapp") // appId is actually not encoded and we don't want to. + .appendPath("Account password") + .build() + } + } + + var backupResult by remember { mutableStateOf("") } + val anastasisLauncher = rememberLauncherForActivityResult( + contract = ActivityResultContracts.StartActivityForResult() + ) { activityResult -> + val data = activityResult.data?.data?.pathSegments + when (activityResult.resultCode) { + 0 -> backupResult = "User aborted the process" + 1 -> backupResult = "Invalid input: ${data!![1]}" + 2 -> backupResult = "Internal error occurred" + 100 -> backupResult = "Backup succeeded: \n" + + "(secret name: ${data!![1]}) \n" + + "(expiration date: ${data!![2]})" + } + } + + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(16.dp), + modifier = modifier.fillMaxWidth() + ) { + Text( + "Own File Example", + style = MaterialTheme.typography.headlineMedium, + fontWeight = FontWeight.Bold, + color = Color.Blue, + modifier = Modifier.padding(horizontal = 16.dp), + ) + + val file = File(context.cacheDir, "example-secret-file.txt") + file.writeText( + "Long secret data included in the file.\n" + + "Email: TestAcc@gmail.com\n" + + "Password: 123456789" + ) + + val secretFileContentUri = FileProvider.getUriForFile( + context, + "net.taler.anastasistestdriverapp.fileprovider", + file, + ) + + SelectionContainer { + Text( + text = secretFileContentUri!!.toString(), + fontSize = 16.sp, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(16.dp) + .fillMaxWidth() + ) + } + + Button( + onClick = { + val intent = Intent("anastasis.intent.action.backup").run { + data = uri + clipData = ClipData.newRawUri("", secretFileContentUri) + addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + val pendingIntent = PendingIntent.getActivity( + context, + 0, + Intent(), + PendingIntent.FLAG_IMMUTABLE + ) + putExtra("pending_intent", pendingIntent) + Intent.createChooser(this, "") + } + anastasisLauncher.launch(intent) + }, + ) { + Text("Back up using Anastasis") + } + + Text( + text = backupResult, + fontSize = 16.sp, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth() + ) + } +} + +@Composable +fun RecoveryExample(modifier: Modifier = Modifier) { + var appId by remember { + mutableStateOf("net.taler.anastasistestdriverapp") + } + + var appName by remember { + mutableStateOf("Gmail App") + } + + var secretName by remember { + mutableStateOf("Account password") + } + + val uri by remember { + derivedStateOf { + val uriBuilder = Uri.Builder() + .scheme("anastasis") + .authority("recovery") + if (appId.isNotBlank()) { + uriBuilder.appendEncodedPath(appId) // appId is actually not encoded and we don't want to. + } + if (appId.isNotBlank() && secretName.isNotBlank()) { + uriBuilder.appendPath(secretName) + } + if (appName.isNotBlank()) { + uriBuilder.appendQueryParameter("app_name", appName) + } + uriBuilder.build() + } + } + + var recoveryResult by remember { mutableStateOf("") } + val anastasisLauncher = rememberLauncherForActivityResult( + contract = ActivityResultContracts.StartActivityForResult() + ) { activityResult -> + val data = activityResult.data?.data?.pathSegments + when (activityResult.resultCode) { + 0 -> recoveryResult = "User aborted the process" + 1 -> recoveryResult = "Invalid input: ${data!![1]}" + 2 -> recoveryResult = "Internal error occurred" + 3 -> recoveryResult = "Secret not found." + 101 -> { + val secretUri = activityResult.data?.clipData?.getItemAt(0)?.uri + recoveryResult = "Recovered secret Content URI: $secretUri\n" + + "File name: ${Utils.resolveDocFilename(secretUri!!)}\n" + } + } + } + + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(16.dp), + modifier = modifier.fillMaxSize() + ) { + Text( + "Recovery Example", + style = MaterialTheme.typography.headlineMedium, + fontWeight = FontWeight.Bold, + color = Color.Blue, + modifier = Modifier.padding(16.dp), + ) + + TextField( + label = { + Text(text = "App ID") + }, + value = appId, + onValueChange = { appId = it }, + textStyle = TextStyle(fontSize = 16.sp), + modifier = Modifier.fillMaxWidth(), + ) + + TextField( + label = { + Text(text = "App Name (Optional)") + }, + value = appName, + onValueChange = { appName = it }, + textStyle = TextStyle(fontSize = 16.sp), + modifier = Modifier.fillMaxWidth(), + ) + + TextField( + label = { + Text(text = "Secret Name") + }, + value = secretName, + onValueChange = { secretName = it }, + textStyle = TextStyle(fontSize = 16.sp), + modifier = Modifier.fillMaxWidth(), + ) + + Text( + "URI:", + textAlign = TextAlign.Center, + fontWeight = FontWeight.Bold, + modifier = Modifier.padding(horizontal = 8.dp) + ) + Text( + "$uri", + textAlign = TextAlign.Center, + modifier = Modifier.padding(horizontal = 8.dp) + ) + + val context = LocalContext.current + Button( + onClick = { + val intent = Intent("anastasis.intent.action.recovery").run { + data = uri + val pendingIntent = PendingIntent.getActivity( + context, + 0, + Intent(), + PendingIntent.FLAG_IMMUTABLE + ) + putExtra("pending_intent", pendingIntent) + Intent.createChooser(this, "") + } + anastasisLauncher.launch(intent) + }, + ) { + Text("Recover using Anastasis") + } + + Text( + text = recoveryResult, + fontSize = 16.sp, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(horizontal = 16.dp) + .fillMaxWidth() + ) + } +} diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/ui/theme/Color.kt b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/ui/theme/Color.kt @@ -0,0 +1,27 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasistestdriverapp.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) +\ No newline at end of file diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/ui/theme/Theme.kt b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/ui/theme/Theme.kt @@ -0,0 +1,73 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasistestdriverapp.ui.theme + +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun AnastasisTestDriverAppTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/ui/theme/Type.kt b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/ui/theme/Type.kt @@ -0,0 +1,50 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasistestdriverapp.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) +\ No newline at end of file diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/utils/Utils.kt b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/java/net/taler/anastasistestdriverapp/utils/Utils.kt @@ -0,0 +1,49 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.anastasistestdriverapp.utils + +import android.net.Uri + +object Utils { + private const val encTableCrock = "0123456789ABCDEFGHJKMNPQRSTVWXYZ" + + fun encodeSecretToBase32(bytes: ByteArray): String { + var sb = "" + val size = bytes.size + var bitBuf = 0 + var numBits = 0 + var pos = 0 + while (pos < size || numBits > 0) { + if (pos < size && numBits < 5) { + val d = bytes[pos++] + bitBuf = bitBuf.shl(8).or(d.toInt()) + numBits += 8 + } + if (numBits < 5) { + // zero-padding + bitBuf = bitBuf.shl(5 - numBits) + numBits = 5 + } + val v = bitBuf.ushr(numBits - 5).and(31) + sb += encTableCrock[v] + numBits -= 5 + } + return sb + } + + fun resolveDocFilename(uri: Uri): String? = uri.lastPathSegment +} diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/drawable/ic_launcher_background.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="108dp" + android:height="108dp" + android:viewportWidth="108" + android:viewportHeight="108"> + <path + android:fillColor="#3DDC84" + android:pathData="M0,0h108v108h-108z" /> + <path + android:fillColor="#00000000" + android:pathData="M9,0L9,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,0L19,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M29,0L29,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M39,0L39,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M49,0L49,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M59,0L59,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M69,0L69,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M79,0L79,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M89,0L89,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M99,0L99,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,9L108,9" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,19L108,19" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,29L108,29" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,39L108,39" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,49L108,49" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,59L108,59" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,69L108,69" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,79L108,79" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,89L108,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,99L108,99" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,29L89,29" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,39L89,39" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,49L89,49" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,59L89,59" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,69L89,69" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,79L89,79" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M29,19L29,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M39,19L39,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M49,19L49,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M59,19L59,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M69,19L69,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M79,19L79,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> +</vector> diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/drawable/ic_launcher_foreground.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:aapt="http://schemas.android.com/aapt" + android:width="108dp" + android:height="108dp" + android:viewportWidth="108" + android:viewportHeight="108"> + <path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z"> + <aapt:attr name="android:fillColor"> + <gradient + android:endX="85.84757" + android:endY="92.4963" + android:startX="42.9492" + android:startY="49.59793" + android:type="linear"> + <item + android:color="#44000000" + android:offset="0.0" /> + <item + android:color="#00000000" + android:offset="1.0" /> + </gradient> + </aapt:attr> + </path> + <path + android:fillColor="#FFFFFF" + android:fillType="nonZero" + android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z" + android:strokeWidth="1" + android:strokeColor="#00000000" /> +</vector> diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background" /> + <foreground android:drawable="@drawable/ic_launcher_foreground" /> + <monochrome android:drawable="@drawable/ic_launcher_foreground" /> +</adaptive-icon> diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background" /> + <foreground android:drawable="@drawable/ic_launcher_foreground" /> + <monochrome android:drawable="@drawable/ic_launcher_foreground" /> +</adaptive-icon> diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher.webp b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differ. diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differ. diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher.webp b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differ. diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differ. diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differ. diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differ. diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differ. diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differ. diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differ. diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp Binary files differ. diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/values/colors.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="purple_200">#FFBB86FC</color> + <color name="purple_500">#FF6200EE</color> + <color name="purple_700">#FF3700B3</color> + <color name="teal_200">#FF03DAC5</color> + <color name="teal_700">#FF018786</color> + <color name="black">#FF000000</color> + <color name="white">#FFFFFFFF</color> +</resources> diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/values/strings.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ +<resources> + <string name="app_name">AnastasisTestDriverApp</string> +</resources> +\ No newline at end of file diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/values/themes.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <style name="Theme.AnastasisTestDriverApp" parent="android:Theme.Material.Light.NoActionBar" /> +</resources> diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/xml/backup_rules.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/xml/backup_rules.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + Sample backup rules file; uncomment and customize as necessary. + See https://developer.android.com/guide/topics/data/autobackup + for details. + Note: This file is ignored for devices older that API 31 + See https://developer.android.com/about/versions/12/backup-restore +--> +<full-backup-content> + <!-- + <include domain="sharedpref" path="."/> + <exclude domain="sharedpref" path="device.xml"/> +--> +</full-backup-content> diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/xml/data_extraction_rules.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + Sample data extraction rules file; uncomment and customize as necessary. + See https://developer.android.com/about/versions/12/backup-restore#xml-changes + for details. +--> +<data-extraction-rules> + <cloud-backup> + <!-- TODO: Use <include> and <exclude> to control what is backed up. + <include .../> + <exclude .../> + --> + </cloud-backup> + <!-- + <device-transfer> + <include .../> + <exclude .../> + </device-transfer> + --> +</data-extraction-rules> diff --git a/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/xml/provider_paths.xml b/Android/anastasis-integration-demo-app/anastasis-test-driver-app/src/main/res/xml/provider_paths.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<paths> + <cache-path + name="backup-files" + path="/" /> +</paths> diff --git a/Android/anastasis-integration-demo-app/build.gradle.kts b/Android/anastasis-integration-demo-app/build.gradle.kts @@ -0,0 +1,4 @@ +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.jetbrains.kotlin.android) apply false +} diff --git a/Android/anastasis-integration-demo-app/gradle.properties b/Android/anastasis-integration-demo-app/gradle.properties @@ -0,0 +1,23 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true +\ No newline at end of file diff --git a/Android/anastasis-integration-demo-app/gradle/libs.versions.toml b/Android/anastasis-integration-demo-app/gradle/libs.versions.toml @@ -0,0 +1,22 @@ +[versions] +agp = "8.4.1" +kotlin = "1.9.24" +coreKtx = "1.13.1" +junit = "4.13.2" +junitVersion = "1.2.1" +espressoCore = "3.6.1" +appcompat = "1.7.0" +material = "1.12.0" + +[libraries] +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } +androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } +material = { group = "com.google.android.material", name = "material", version.ref = "material" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } + diff --git a/Android/anastasis-integration-demo-app/gradle/wrapper/gradle-wrapper.jar b/Android/anastasis-integration-demo-app/gradle/wrapper/gradle-wrapper.jar Binary files differ. diff --git a/Android/anastasis-integration-demo-app/gradle/wrapper/gradle-wrapper.properties b/Android/anastasis-integration-demo-app/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Aug 26 21:23:22 EEST 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Android/anastasis-integration-demo-app/gradlew b/Android/anastasis-integration-demo-app/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/Android/anastasis-integration-demo-app/gradlew.bat b/Android/anastasis-integration-demo-app/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Android/anastasis-integration-demo-app/settings.gradle.kts b/Android/anastasis-integration-demo-app/settings.gradle.kts @@ -0,0 +1,24 @@ +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "AnastasisIntegrationDemoApp" +include(":anastasis-lib") +include(":anastasis-test-driver-app") diff --git a/Android/wallet-integration-demo-app/build.gradle.kts b/Android/wallet-integration-demo-app/build.gradle.kts @@ -0,0 +1,5 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.jetbrains.kotlin.android) apply false +} +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/gradle.properties b/Android/wallet-integration-demo-app/gradle.properties @@ -0,0 +1,23 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/gradle/libs.versions.toml b/Android/wallet-integration-demo-app/gradle/libs.versions.toml @@ -0,0 +1,22 @@ +[versions] +agp = "8.4.1" +kotlin = "1.9.24" +coreKtx = "1.13.1" +junit = "4.13.2" +junitVersion = "1.2.1" +espressoCore = "3.6.1" +appcompat = "1.7.0" +material = "1.12.0" + +[libraries] +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } +androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } +material = { group = "com.google.android.material", name = "material", version.ref = "material" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } + diff --git a/Android/wallet-integration-demo-app/gradle/wrapper/gradle-wrapper.jar b/Android/wallet-integration-demo-app/gradle/wrapper/gradle-wrapper.jar Binary files differ. diff --git a/Android/wallet-integration-demo-app/gradle/wrapper/gradle-wrapper.properties b/Android/wallet-integration-demo-app/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Aug 26 21:40:54 EEST 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Android/wallet-integration-demo-app/gradlew b/Android/wallet-integration-demo-app/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/Android/wallet-integration-demo-app/gradlew.bat b/Android/wallet-integration-demo-app/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Android/wallet-integration-demo-app/settings.gradle.kts b/Android/wallet-integration-demo-app/settings.gradle.kts @@ -0,0 +1,24 @@ +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "WalletIntegrationDemoApp" +include(":wallet-test-driver-app") + +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/.gitignore b/Android/wallet-integration-demo-app/wallet-test-driver-app/.gitignore @@ -0,0 +1 @@ +/build +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/build.gradle.kts b/Android/wallet-integration-demo-app/wallet-test-driver-app/build.gradle.kts @@ -0,0 +1,83 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "net.taler.wallettestdriverapp" + compileSdk = 34 + + defaultConfig { + applicationId = "net.taler.wallettestdriverapp" + minSdk = 24 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.14" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + // Android + implementation("androidx.core:core-ktx:1.13.1") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4") + // Compose + implementation("androidx.activity:activity-compose:1.9.1") + implementation(platform("androidx.compose:compose-bom:2024.06.00")) + implementation("androidx.compose.ui:ui") + implementation("androidx.compose.ui:ui-graphics") + implementation("androidx.compose.ui:ui-tooling-preview") + debugImplementation("androidx.compose.ui:ui-tooling") + debugImplementation("androidx.compose.ui:ui-test-manifest") + implementation("androidx.compose.material3:material3") + // Networking + implementation("com.squareup.okhttp3:okhttp:4.12.0") +} +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/proguard-rules.pro b/Android/wallet-integration-demo-app/wallet-test-driver-app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/AndroidManifest.xml b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + + <uses-permission android:name="android.permission.INTERNET" /> + <application + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:roundIcon="@mipmap/ic_launcher_round" + android:supportsRtl="true" + android:theme="@style/Theme.Talerandroid"> + <activity + android:name=".MainActivity" + android:exported="true" + android:label="@string/app_name" + android:theme="@style/Theme.Talerandroid"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest> +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/MainActivity.kt b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/MainActivity.kt @@ -0,0 +1,288 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.wallettestdriverapp + +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.util.Log +import androidx.activity.ComponentActivity +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material3.Button +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.Divider +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import net.taler.wallettestdriverapp.ui.theme.TalerandroidTheme +import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.RequestBody +import okhttp3.RequestBody.Companion.toRequestBody +import org.json.JSONObject + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + TalerandroidTheme { + Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> + HomeScreen( + modifier = Modifier.padding(innerPadding) + ) + } + } + } + } +} + +@Composable +fun HomeScreen(modifier: Modifier = Modifier) { + Column( + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + modifier = modifier.fillMaxSize() + ) { + SinglePaymentExample() + Divider(Modifier.padding(vertical = 8.dp)) + MultiPaymentExample() + } +} + +@Composable +private fun SinglePaymentExample() { + val coroutineScope = rememberCoroutineScope(); + var price by remember { mutableStateOf("0") } + var isCreatingOrder by remember { mutableStateOf(false) } + var paymentResult by remember { mutableStateOf("") } + val walletLauncher = rememberLauncherForActivityResult( + contract = ActivityResultContracts.StartActivityForResult() + ) { activityResult -> + when (activityResult.resultCode) { + -1 -> paymentResult = "No status yet" + 0 -> paymentResult = "User aborted the payment" + 1 -> paymentResult = "Insufficient balance" + 2 -> paymentResult = "Payment was still pending" + 3 -> paymentResult = "Payment failed" + 4 -> paymentResult = "Already paid" + 100 -> paymentResult = "Payment succeeded" + } + } + + Column( + verticalArrangement = Arrangement.spacedBy(4.dp, alignment = Alignment.CenterVertically), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text(text = "Single-Payment Example") + TextField( + value = price, + onValueChange = { price = it }, + label = { Text(text = "Order price (KUDOS)") }, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), + modifier = Modifier.padding(8.dp) + ) + Button(onClick = { + coroutineScope.launch(Dispatchers.IO) { + isCreatingOrder = true + val orderID = createOrder( + merchantUrl = "https://backend.demo.taler.net/private/orders", + price = price.toDouble(), + currency = "KUDOS", + summary = "Donate to make the wallet works", + ) + isCreatingOrder = false + val orderTalerUri = "taler://pay/backend.demo.taler.net/$orderID/" + Uri.parse(orderTalerUri).let { uri -> + val intent = Intent().apply { + action = "android.intent.action.VIEW" + data = uri + } + Log.d("wallet-test-driver-app", intent.toString()) + walletLauncher.launch(Intent.createChooser(intent, "Choose App")) + } + } + }) { + Text("Create the order") + } + if (isCreatingOrder) { + CircularProgressIndicator() + } + Text(text = paymentResult, modifier = Modifier.padding(8.dp)) + } +} + +@Composable +private fun MultiPaymentExample() { + val coroutineScope = rememberCoroutineScope(); + var order1Price by remember { mutableStateOf("0") } + var order2Price by remember { mutableStateOf("0") } + var order3Price by remember { mutableStateOf("0") } + var isCreatingOrders by remember { mutableStateOf(false) } + var paymentResult by remember { mutableStateOf("") } + val walletLauncher = rememberLauncherForActivityResult( + contract = ActivityResultContracts.StartActivityForResult() + ) { activityResult -> + when (activityResult.resultCode) { + 0 -> paymentResult = "User aborted the payments." + 5 -> paymentResult = "Missing Data: Empty list of Taler pay URIs." + 3 -> { + val payUrisToStatus = + activityResult.data?.getSerializableExtra("results") as HashMap<String, Int> + paymentResult = "Failure: \n$payUrisToStatus" + } + + 100 -> paymentResult = "All payments succeeded" + } + } + + Column( + verticalArrangement = Arrangement.spacedBy(4.dp, alignment = Alignment.CenterVertically), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text(text = "Multi-Payment Example") + TextField( + value = order1Price, + onValueChange = { order1Price = it }, + label = { Text(text = "Order 1 price (KUDOS)") }, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), + modifier = Modifier.padding(8.dp) + ) + TextField( + value = order2Price, + onValueChange = { order2Price = it }, + label = { Text(text = "Order 2 price (TESTKUDOS)") }, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), + modifier = Modifier.padding(8.dp) + ) + TextField( + value = order3Price, + onValueChange = { order3Price = it }, + label = { Text(text = "Order 3 price (TESTKUDOS)") }, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), + modifier = Modifier.padding(8.dp) + ) + Button(onClick = { + coroutineScope.launch(Dispatchers.IO) { + isCreatingOrders = true + val order1ID = createOrder( + merchantUrl = "https://backend.demo.taler.net/private/orders", + price = order1Price.toDouble(), + currency = "KUDOS", + summary = "Payment A" + ) + val order2ID = createOrder( + merchantUrl = "https://backend.test.taler.net/private/orders", + price = order2Price.toDouble(), + currency = "TESTKUDOS", + summary = "Payment B" + ) + val order3ID = createOrder( + merchantUrl = "https://backend.test.taler.net/private/orders", + price = order3Price.toDouble(), + currency = "TESTKUDOS", + summary = "Payment C" + ) + isCreatingOrders = false + val orderTalerUri1 = "taler://pay/backend.demo.taler.net/$order1ID/" + val orderTalerUri2 = "taler://pay/backend.test.taler.net/$order2ID/" + val orderTalerUri3 = "taler://pay/backend.test.taler.net/$order3ID/" + val intent = Intent().apply { + action = "net.taler.wallet.MULTI_PAYMENT" + putStringArrayListExtra( + "talerUris", + arrayListOf(orderTalerUri1, orderTalerUri2, orderTalerUri3) + ) + } + Log.d("wallet-test-driver-app", "$intent") + walletLauncher.launch(Intent.createChooser(intent, "Choose App")) + } + }) { + Text("Create the orders") + } + if (isCreatingOrders) { + CircularProgressIndicator() + } + Text(text = paymentResult, modifier = Modifier.padding(8.dp)) + } +} + +fun createOrder( + merchantUrl: String, + price: Double, + currency: String, + summary: String, +): String { + val jsonMediaType = "application/json; charset=utf-8".toMediaTypeOrNull() + val bodyContent = JSONObject().apply { + put("order", JSONObject().apply { + put("amount", "$currency:$price") + put("summary", summary) + }) + put("create_token", false) + }.toString() + + val body: RequestBody = bodyContent.toRequestBody(jsonMediaType) + + val request = Request.Builder() + .url(merchantUrl) + .addHeader("Authorization", "Bearer secret-token:sandbox") + .post(body) + .build() + + val response = OkHttpClient().newCall(request).execute() + if (response.isSuccessful) { + val orderID = JSONObject(response.body!!.string()).getString("order_id") + response.close() + Log.d("wallet-test-driver-app", orderID) + return orderID + } else { + Log.d("wallet-test-driver-app", "Request failed: $response") + throw Exception() + } +} + + +@Preview(showBackground = true) +@Composable +fun HomeScreenPreview() { + TalerandroidTheme { + HomeScreen() + } +} +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/ui/theme/Color.kt b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/ui/theme/Color.kt @@ -0,0 +1,27 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.wallettestdriverapp.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/ui/theme/Theme.kt b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/ui/theme/Theme.kt @@ -0,0 +1,74 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.wallettestdriverapp.ui.theme + +import android.app.Activity +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun TalerandroidTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit, +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/ui/theme/Type.kt b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/java/net/taler/wallettestdriverapp/ui/theme/Type.kt @@ -0,0 +1,50 @@ +/* + * This file is part of GNU Taler + * (C) 2024 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +package net.taler.wallettestdriverapp.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/drawable/ic_launcher_background.xml b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="108dp" + android:height="108dp" + android:viewportWidth="108" + android:viewportHeight="108"> + <path + android:fillColor="#3DDC84" + android:pathData="M0,0h108v108h-108z" /> + <path + android:fillColor="#00000000" + android:pathData="M9,0L9,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,0L19,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M29,0L29,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M39,0L39,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M49,0L49,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M59,0L59,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M69,0L69,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M79,0L79,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M89,0L89,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M99,0L99,108" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,9L108,9" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,19L108,19" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,29L108,29" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,39L108,39" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,49L108,49" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,59L108,59" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,69L108,69" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,79L108,79" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,89L108,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M0,99L108,99" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,29L89,29" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,39L89,39" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,49L89,49" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,59L89,59" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,69L89,69" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M19,79L89,79" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M29,19L29,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M39,19L39,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M49,19L49,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M59,19L59,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M69,19L69,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + <path + android:fillColor="#00000000" + android:pathData="M79,19L79,89" + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> +</vector> diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/drawable/ic_launcher_foreground.xml b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,46 @@ +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<vector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:aapt="http://schemas.android.com/aapt" + android:width="108dp" + android:height="108dp" + android:viewportWidth="108" + android:viewportHeight="108"> + <path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z"> + <aapt:attr name="android:fillColor"> + <gradient + android:endX="85.84757" + android:endY="92.4963" + android:startX="42.9492" + android:startY="49.59793" + android:type="linear"> + <item + android:color="#44000000" + android:offset="0.0" /> + <item + android:color="#00000000" + android:offset="1.0" /> + </gradient> + </aapt:attr> + </path> + <path + android:fillColor="#FFFFFF" + android:fillType="nonZero" + android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z" + android:strokeWidth="1" + android:strokeColor="#00000000" /> +</vector> +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background" /> + <foreground android:drawable="@drawable/ic_launcher_foreground" /> + <monochrome android:drawable="@drawable/ic_launcher_foreground" /> +</adaptive-icon> +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background" /> + <foreground android:drawable="@drawable/ic_launcher_foreground" /> + <monochrome android:drawable="@drawable/ic_launcher_foreground" /> +</adaptive-icon> +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher.webp b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-hdpi/ic_launcher_round.webp diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher.webp b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-mdpi/ic_launcher_round.webp diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/values/colors.xml b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/values/colors.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<resources> + <color name="purple_200">#FFBB86FC</color> + <color name="purple_500">#FF6200EE</color> + <color name="purple_700">#FF3700B3</color> + <color name="teal_200">#FF03DAC5</color> + <color name="teal_700">#FF018786</color> + <color name="black">#FF000000</color> + <color name="white">#FFFFFFFF</color> +</resources> +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/values/strings.xml b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/values/strings.xml @@ -0,0 +1,19 @@ +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<resources> + <string name="app_name">wallet-test-driver-app</string> +</resources> +\ No newline at end of file diff --git a/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/values/themes.xml b/Android/wallet-integration-demo-app/wallet-test-driver-app/src/main/res/values/themes.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ This file is part of GNU Taler + ~ (C) 2024 Taler Systems S.A. + ~ + ~ GNU Taler is free software; you can redistribute it and/or modify it under the + ~ terms of the GNU General Public License as published by the Free Software + ~ Foundation; either version 3, or (at your option) any later version. + ~ + ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along with + ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + --> + +<resources> + + <style name="Theme.Talerandroid" parent="android:Theme.Material.Light.NoActionBar" /> +</resources> +\ No newline at end of file