Skip to content

Commit

Permalink
Merge pull request #300 from Concordium/android-example-account
Browse files Browse the repository at this point in the history
Android example account
  • Loading branch information
shjortConcordium authored Jan 24, 2024
2 parents 81816dc + 414b7de commit 245d6ba
Show file tree
Hide file tree
Showing 52 changed files with 2,275 additions and 0 deletions.
25 changes: 25 additions & 0 deletions concordium-android-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,31 @@
</dependencies>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-aar-after-build</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/../concordium-android-sdk-examples/app/libs</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target</directory>
<includes>
<include>concordium-android-sdk.aar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
11 changes: 11 additions & 0 deletions concordium-android-wallet-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
app/libs
7 changes: 7 additions & 0 deletions concordium-android-wallet-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Wallet example for Android applications

This folder contains a small project for an Android app that uses the Concordium Android SDK.

For the app to build, one must add the Android library (AAR file), to the `app/libs` folder. This can either be done by downloading it from the repository's releases, or building the [concordium-android-sdk](../concordium-android-sdk/) with `mvn install`. (This command will copy the library on `app/libs`)

The app is able to take a BIP39 seed phrase, and use that to create/recover an identity, create an account and send transfers using the created account.
1 change: 1 addition & 0 deletions concordium-android-wallet-example/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
88 changes: 88 additions & 0 deletions concordium-android-wallet-example/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}

val bundleId = "com.concordium.example.wallet"

android {
namespace = bundleId
compileSdk = 34

defaultConfig {
applicationId = bundleId
minSdk = 26
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_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
pickFirsts += "com/google/protobuf/*"
}
}
}

dependencies {
implementation("io.grpc:grpc-okhttp:1.60.0")
implementation("io.grpc:grpc-protobuf:1.60.0")
implementation("io.grpc:grpc-stub:1.60.0")
implementation("androidx.browser:browser:1.7.0")
implementation(files("libs/concordium-android-sdk.aar"))
compileOnly("org.apache.tomcat:annotations-api:6.0.53") // necessary for Java 9+
implementation ("com.fasterxml.jackson.core:jackson-core:2.16.1")
implementation ("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.1")
implementation ("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.16.1")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.16.1")

implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-jackson:2.9.0")

implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation("androidx.activity:activity-compose:1.8.2")
implementation(platform("androidx.compose:compose-bom:2023.08.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")

implementation("cash.z.ecc.android:kotlin-bip39:1.0.7")
implementation("commons-codec:commons-codec:1.16.0")
implementation("org.bitcoinj:bitcoinj-core:0.16.2") {
exclude(group="com.google.protobuf")
}
}
21 changes: 21 additions & 0 deletions concordium-android-wallet-example/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions concordium-android-wallet-example/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" /> <!-- Protection level: normal -->

<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.Androidsdkexample"
tools:targetApi="34">
<activity android:name="com.concordium.example.wallet.activities.SeedPhraseActivity" />
<activity android:name="com.concordium.example.wallet.activities.NewIdentityActivity" />
<activity
android:name="com.concordium.example.wallet.activities.IssueIdentityActivity"
android:exported="true">
<intent-filter android:label="schemefilter">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="identity-issuer"
android:scheme="concordiumwallet-example" />
</intent-filter>
</activity>
<activity android:name="com.concordium.example.wallet.activities.IdentityConfirmationActivity" />
<activity android:name="com.concordium.example.wallet.activities.RecoverIdentityActivity" />
<activity android:name="com.concordium.example.wallet.activities.IdentityActivity" />
<activity android:name="com.concordium.example.wallet.activities.AccountActivity" />
<activity
android:name="com.concordium.example.wallet.activities.RouterActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.concordium.example.wallet

import com.concordium.sdk.crypto.wallet.Network

object Constants {
// These indices are set to 0, because this wallet only does 1 identity/account, but in a
// proper wallet with multiple identities/account, these would be actual variables.
const val IDENTITY_INDEX = 0
const val CREDENTIAL_COUNTER = 0

const val AR_THRESHOLD = 2L

val NETWORK = Network.TESTNET
const val GRPC_URL = "grpc.testnet.concordium.com"
const val GRPC_PORT = 20000
const val CALLBACK_URL = "concordiumwallet-example://identity-issuer/callback"
const val WALLET_PROXY_URL = "https://wallet-proxy.testnet.concordium.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.concordium.example.wallet

import android.content.Intent
import androidx.activity.ComponentActivity
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import com.concordium.example.wallet.activities.AccountActivity
import com.concordium.example.wallet.activities.IdentityActivity
import com.concordium.example.wallet.activities.IssueIdentityActivity
import com.concordium.example.wallet.activities.RecoverIdentityActivity
import com.concordium.example.wallet.activities.SeedPhraseActivity
import com.concordium.example.wallet.ui.Container

/**
* Preview that an overview menu, where each activity can be accessed directly.
* Mostly useful for testing purposes.
*/
@Preview(showBackground = true)
@Composable
fun Overview() {
val context = LocalContext.current

fun gotoActivity(activity: Class<out ComponentActivity>) {
val myIntent = Intent(context, activity)
context.startActivity(myIntent)
}

Container {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = "Example Wallet")
Button(onClick = { gotoActivity(SeedPhraseActivity::class.java) }) {
Text(text = "Go to SeedPhrase view")
}
Button(onClick = { gotoActivity(IssueIdentityActivity::class.java) }) {
Text(text = "Go to Identity issuance view")
}
Button(onClick = { gotoActivity(RecoverIdentityActivity::class.java) }) {
Text(text = "Go to Identity recovery view")
}
Button(onClick = { gotoActivity(IdentityActivity::class.java) }) {
Text(text = "Go to Identity view")
}
Button(onClick = { gotoActivity(AccountActivity::class.java) }) {
Text(text = "Go to Account view")
}
}
}
}
Loading

0 comments on commit 245d6ba

Please sign in to comment.