From 50dcba61a6dbbd82f870eb338a2b34431019b7f9 Mon Sep 17 00:00:00 2001 From: Joel-Haeberli Date: Sat, 13 Apr 2024 17:05:26 +0200 Subject: code: basic setup for wallee app --- cli/cli.go | 1 + docs/content/appendix/meeting_notes.tex | 53 ++++++ docs/content/implementation/c2ec.tex | 2 +- docs/thesis.pdf | Bin 1667073 -> 1668345 bytes wallee-c2ec/.gitignore | 15 ++ wallee-c2ec/.idea/.gitignore | 3 + wallee-c2ec/.idea/compiler.xml | 6 + wallee-c2ec/.idea/deploymentTargetDropDown.xml | 10 ++ wallee-c2ec/.idea/gradle.xml | 19 +++ .../.idea/inspectionProfiles/Project_Default.xml | 41 +++++ wallee-c2ec/.idea/kotlinc.xml | 6 + wallee-c2ec/.idea/migrations.xml | 10 ++ wallee-c2ec/.idea/misc.xml | 10 ++ wallee-c2ec/app/.gitignore | 1 + wallee-c2ec/app/build.gradle.kts | 70 ++++++++ wallee-c2ec/app/proguard-rules.pro | 21 +++ .../habej2/wallee_c2ec/ExampleInstrumentedTest.kt | 24 +++ wallee-c2ec/app/src/main/AndroidManifest.xml | 43 +++++ .../ch/bfh/habej2/wallee_c2ec/ExchangeActivity.kt | 45 +++++ .../java/ch/bfh/habej2/wallee_c2ec/MainActivity.kt | 40 +++++ .../ch/bfh/habej2/wallee_c2ec/PaymentActivity.kt | 27 +++ .../wallee_c2ec/WithdrawalCreationActivity.kt | 66 ++++++++ .../habej2/wallee_c2ec/client/c2ec/C2ECClient.kt | 26 +++ .../client/c2ec/C2ECPaymentNotification.kt | 4 + .../client/c2ec/C2ECWithdrawalOperationStatus.kt | 4 + .../habej2/wallee_c2ec/config/ExchangeConfig.kt | 21 +++ .../habej2/wallee_c2ec/config/TerminalConfig.kt | 13 ++ .../ch/bfh/habej2/wallee_c2ec/ui/theme/Color.kt | 11 ++ .../ch/bfh/habej2/wallee_c2ec/ui/theme/Theme.kt | 70 ++++++++ .../ch/bfh/habej2/wallee_c2ec/ui/theme/Type.kt | 34 ++++ .../main/res/drawable/ic_launcher_background.xml | 170 +++++++++++++++++++ .../main/res/drawable/ic_launcher_foreground.xml | 30 ++++ .../app/src/main/res/mipmap-anydpi/ic_launcher.xml | 6 + .../main/res/mipmap-anydpi/ic_launcher_round.xml | 6 + .../app/src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../main/res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes .../app/src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../main/res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../app/src/main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../main/res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../src/main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../main/res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../src/main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../main/res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes wallee-c2ec/app/src/main/res/values/colors.xml | 10 ++ wallee-c2ec/app/src/main/res/values/strings.xml | 6 + wallee-c2ec/app/src/main/res/values/themes.xml | 5 + wallee-c2ec/app/src/main/res/xml/backup_rules.xml | 13 ++ .../app/src/main/res/xml/data_extraction_rules.xml | 19 +++ .../ch/bfh/habej2/wallee_c2ec/ExampleUnitTest.kt | 17 ++ wallee-c2ec/build.gradle.kts | 5 + wallee-c2ec/gradle.properties | 23 +++ wallee-c2ec/gradle/libs.versions.toml | 35 ++++ wallee-c2ec/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + wallee-c2ec/gradlew | 185 +++++++++++++++++++++ wallee-c2ec/gradlew.bat | 89 ++++++++++ wallee-c2ec/settings.gradle.kts | 29 ++++ 58 files changed, 1349 insertions(+), 1 deletion(-) create mode 100644 wallee-c2ec/.gitignore create mode 100644 wallee-c2ec/.idea/.gitignore create mode 100644 wallee-c2ec/.idea/compiler.xml create mode 100644 wallee-c2ec/.idea/deploymentTargetDropDown.xml create mode 100644 wallee-c2ec/.idea/gradle.xml create mode 100644 wallee-c2ec/.idea/inspectionProfiles/Project_Default.xml create mode 100644 wallee-c2ec/.idea/kotlinc.xml create mode 100644 wallee-c2ec/.idea/migrations.xml create mode 100644 wallee-c2ec/.idea/misc.xml create mode 100644 wallee-c2ec/app/.gitignore create mode 100644 wallee-c2ec/app/build.gradle.kts create mode 100644 wallee-c2ec/app/proguard-rules.pro create mode 100644 wallee-c2ec/app/src/androidTest/java/ch/bfh/habej2/wallee_c2ec/ExampleInstrumentedTest.kt create mode 100644 wallee-c2ec/app/src/main/AndroidManifest.xml create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ExchangeActivity.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/MainActivity.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/PaymentActivity.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/WithdrawalCreationActivity.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECClient.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECPaymentNotification.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECWithdrawalOperationStatus.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/config/ExchangeConfig.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/config/TerminalConfig.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Color.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Theme.kt create mode 100644 wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Type.kt create mode 100644 wallee-c2ec/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 wallee-c2ec/app/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 wallee-c2ec/app/src/main/res/mipmap-anydpi/ic_launcher.xml create mode 100644 wallee-c2ec/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml create mode 100644 wallee-c2ec/app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 wallee-c2ec/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 wallee-c2ec/app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 wallee-c2ec/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 wallee-c2ec/app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 wallee-c2ec/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 wallee-c2ec/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 wallee-c2ec/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 wallee-c2ec/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 wallee-c2ec/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 wallee-c2ec/app/src/main/res/values/colors.xml create mode 100644 wallee-c2ec/app/src/main/res/values/strings.xml create mode 100644 wallee-c2ec/app/src/main/res/values/themes.xml create mode 100644 wallee-c2ec/app/src/main/res/xml/backup_rules.xml create mode 100644 wallee-c2ec/app/src/main/res/xml/data_extraction_rules.xml create mode 100644 wallee-c2ec/app/src/test/java/ch/bfh/habej2/wallee_c2ec/ExampleUnitTest.kt create mode 100644 wallee-c2ec/build.gradle.kts create mode 100644 wallee-c2ec/gradle.properties create mode 100644 wallee-c2ec/gradle/libs.versions.toml create mode 100644 wallee-c2ec/gradle/wrapper/gradle-wrapper.jar create mode 100644 wallee-c2ec/gradle/wrapper/gradle-wrapper.properties create mode 100755 wallee-c2ec/gradlew create mode 100644 wallee-c2ec/gradlew.bat create mode 100644 wallee-c2ec/settings.gradle.kts diff --git a/cli/cli.go b/cli/cli.go index 35b8573..ea36f23 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -225,6 +225,7 @@ func connectDbUsingString(connString string) error { if err != nil { return err } + fmt.Println("connected to database") return nil } diff --git a/docs/content/appendix/meeting_notes.tex b/docs/content/appendix/meeting_notes.tex index 61bfdea..2b901f7 100644 --- a/docs/content/appendix/meeting_notes.tex +++ b/docs/content/appendix/meeting_notes.tex @@ -189,6 +189,59 @@ \item Look at Wire Gateway and Bank Integration API as specification of an API and not as individual components of Taler. C2EC must implement those specification in order to integrate into the Taler ecosystem. \end{itemize} +\subsection*{27.03.2024} + +\textbf{Participants} + +\begin{itemize} + \item Fehrensen Benjamin + \item Grothoff Christian + \item H\"aberli Joel +\end{itemize} + +\textbf{Topics} +\begin{itemize} + \item Discussion of the Architecture documentation + \item Feedback of Ben and Christian +\end{itemize} + +\textbf{Action points} +\begin{itemize} + \item Integrate Feedback into documentation + \item Use official docs repo to specify the API (e.g. Bank-Integration API and Wire Gateway API specification) + \item No meeting next week. +\end{itemize} + +\subsection*{10.04.2024} + +\textbf{Participants} + +\begin{itemize} + \item Fehrensen Benjamin + \item Grothoff Christian + \item H\"aberli Joel +\end{itemize} + +\textbf{Topics} +\begin{itemize} + \item Discussion of the C2EC code. +\end{itemize} + +\textbf{Action points} +\begin{itemize} + \item Use ini-format to parse config + \item Add support for PGHOST environment variable + \item Rename config properties to be compliant with other Taler repositories. + \begin{itemize} + \item serve + \item bind + \item unix-path-mode + \item etc. + \end{itemize} + \item For the attestation there is the additional case that neither confirm nor abort is an option and instead retries are required. + \item Remove doubled abstractions (Abstracting attestation is not necessary) +\end{itemize} + % TEMPLATE % \subsection*{TEMPLATE} diff --git a/docs/content/implementation/c2ec.tex b/docs/content/implementation/c2ec.tex index 89e645f..a62993f 100644 --- a/docs/content/implementation/c2ec.tex +++ b/docs/content/implementation/c2ec.tex @@ -32,7 +32,7 @@ The Wire-Gateway specification requires the implementor of the API to keep track \subsection{Payment Attestation} -The attestation of a transaction is crucial, since this is the action which allows the exchange to create a reserve and can proof to the provider and customer, that the transaction was successful and therefore can put the liability for the withdrawal on the provider. The attestation process is implemented using a provider client interface and a provider transaction interface. This allows the process to be the same for each individual provider and new providers can be added easily by providing a specific implementation of the interfaces. +The attestation of a transaction is crucial, since this is the action which allows the exchange to create a reserve and can proof to the provider and customer, that the transaction was successful and therefore can put the liability for the money on the provider. The attestation process is implemented using a provider client interface and a provider transaction interface. This allows the process to be the same for each individual provider and new providers can be added easily by providing a specific implementation of the interfaces. \subsubsection{Provider Client} diff --git a/docs/thesis.pdf b/docs/thesis.pdf index 71efce5..ca2b5a5 100644 Binary files a/docs/thesis.pdf and b/docs/thesis.pdf differ diff --git a/wallee-c2ec/.gitignore b/wallee-c2ec/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/wallee-c2ec/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/wallee-c2ec/.idea/.gitignore b/wallee-c2ec/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/wallee-c2ec/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/wallee-c2ec/.idea/compiler.xml b/wallee-c2ec/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/wallee-c2ec/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/wallee-c2ec/.idea/deploymentTargetDropDown.xml b/wallee-c2ec/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..0c0c338 --- /dev/null +++ b/wallee-c2ec/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/wallee-c2ec/.idea/gradle.xml b/wallee-c2ec/.idea/gradle.xml new file mode 100644 index 0000000..0897082 --- /dev/null +++ b/wallee-c2ec/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/wallee-c2ec/.idea/inspectionProfiles/Project_Default.xml b/wallee-c2ec/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..44ca2d9 --- /dev/null +++ b/wallee-c2ec/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,41 @@ + + + + \ No newline at end of file diff --git a/wallee-c2ec/.idea/kotlinc.xml b/wallee-c2ec/.idea/kotlinc.xml new file mode 100644 index 0000000..fdf8d99 --- /dev/null +++ b/wallee-c2ec/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/wallee-c2ec/.idea/migrations.xml b/wallee-c2ec/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/wallee-c2ec/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/wallee-c2ec/.idea/misc.xml b/wallee-c2ec/.idea/misc.xml new file mode 100644 index 0000000..0ad17cb --- /dev/null +++ b/wallee-c2ec/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/wallee-c2ec/app/.gitignore b/wallee-c2ec/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/wallee-c2ec/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/wallee-c2ec/app/build.gradle.kts b/wallee-c2ec/app/build.gradle.kts new file mode 100644 index 0000000..1696be2 --- /dev/null +++ b/wallee-c2ec/app/build.gradle.kts @@ -0,0 +1,70 @@ +plugins { + alias(libs.plugins.androidApplication) + alias(libs.plugins.jetbrainsKotlinAndroid) +} + +android { + namespace = "ch.bfh.habej2.wallee_c2ec" + compileSdk = 34 + + defaultConfig { + applicationId = "ch.bfh.habej2.wallee_c2ec" + minSdk = 27 + 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}" + } + } +} + +dependencies { + implementation(libs.okhttp) + implementation(libs.wallee.sdk) + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.material3) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) +} \ No newline at end of file diff --git a/wallee-c2ec/app/proguard-rules.pro b/wallee-c2ec/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/wallee-c2ec/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/wallee-c2ec/app/src/androidTest/java/ch/bfh/habej2/wallee_c2ec/ExampleInstrumentedTest.kt b/wallee-c2ec/app/src/androidTest/java/ch/bfh/habej2/wallee_c2ec/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..9d51602 --- /dev/null +++ b/wallee-c2ec/app/src/androidTest/java/ch/bfh/habej2/wallee_c2ec/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package ch.bfh.habej2.wallee_c2ec + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("ch.bfh.habej2.wallee_c2ec", appContext.packageName) + } +} \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/AndroidManifest.xml b/wallee-c2ec/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..86771a7 --- /dev/null +++ b/wallee-c2ec/app/src/main/AndroidManifest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ExchangeActivity.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ExchangeActivity.kt new file mode 100644 index 0000000..6aebf8b --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ExchangeActivity.kt @@ -0,0 +1,45 @@ +package ch.bfh.habej2.wallee_c2ec + +import android.content.Intent +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.ui.Modifier +import ch.bfh.habej2.wallee_c2ec.config.EXCHANGES +import ch.bfh.habej2.wallee_c2ec.ui.theme.Walleec2ecTheme + +class ExchangeActivity : ComponentActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + Walleec2ecTheme { + // A surface container using the 'background' color from the theme + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + Text(text = "Choose the exchange to withdraw from") + + // TODO let user select exchanges from config here + // config must contain display name, credentials (generated by cli) + // and the base url of the c2ec bank-integration api + EXCHANGES.forEach { Text(text = it.displayName) } + + Button(onClick = { Intent(this.parent, WithdrawalCreationActivity::class.java) }) { + title = "withdraw" + } + + Button(onClick = { finish() }) { + title = "back" + } + } + } + } + } +} \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/MainActivity.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/MainActivity.kt new file mode 100644 index 0000000..f91c419 --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/MainActivity.kt @@ -0,0 +1,40 @@ +package ch.bfh.habej2.wallee_c2ec + +import android.content.Intent +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import ch.bfh.habej2.wallee_c2ec.config.loadConfiguredExchanges +import ch.bfh.habej2.wallee_c2ec.ui.theme.Walleec2ecTheme + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + loadConfiguredExchanges() + setContent { + Walleec2ecTheme { + // A surface container using the 'background' color from the theme + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + Text(text = "Withdraw Taler using Wallee") + Button(onClick = { Intent(this, WithdrawalCreationActivity::class.java) }) { + title = "Start Withdrawal" + } + Button(onClick = { Intent(this, ExchangeActivity::class.java) }) { + title = "Choose Exchange" + } + } + } + } + } +} diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/PaymentActivity.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/PaymentActivity.kt new file mode 100644 index 0000000..06f1908 --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/PaymentActivity.kt @@ -0,0 +1,27 @@ +package ch.bfh.habej2.wallee_c2ec + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.ui.Modifier +import ch.bfh.habej2.wallee_c2ec.ui.theme.Walleec2ecTheme + +class PaymentActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + Walleec2ecTheme { + // A surface container using the 'background' color from the theme + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + // TODO use wallee sdk here for payment. + } + } + } + } +} diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/WithdrawalCreationActivity.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/WithdrawalCreationActivity.kt new file mode 100644 index 0000000..f789907 --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/WithdrawalCreationActivity.kt @@ -0,0 +1,66 @@ +package ch.bfh.habej2.wallee_c2ec + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.ui.Modifier +import ch.bfh.habej2.wallee_c2ec.config.TERMINAL_CONFIG +import ch.bfh.habej2.wallee_c2ec.ui.theme.Walleec2ecTheme +import java.security.SecureRandom +import java.util.Base64 + +class WithdrawalCreationActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + val encodedWopid = encodeWopid(createWopid()) + + // TODO Start long polling here somehow in the background. + // when response arrives, send intent to start PaymentActivity for the withdrawal + + setContent { + Walleec2ecTheme { + // A surface container using the 'background' color from the theme + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + + Text(text = "Generated Random WOPID=$encodedWopid") + + Text(text = "QR-Code content: ${formatTalerUri(encodedWopid)}") + + Button(onClick = { finish() }) { + // TODO: abort payment here + title = "back" + } + } + } + } + } + + fun formatTalerUri(encodedWopid: String): String { + + return "taler://withdraw/$encodedWopid?terminal_id=${TERMINAL_CONFIG.terminalId}" + } + + fun encodeWopid(wopid: ByteArray): String { + + return Base64.getUrlEncoder() + .encode(wopid) + .toString() + } + + fun createWopid(): ByteArray { + + val wopid = ByteArray(32) + val rand = SecureRandom() + rand.nextBytes(wopid) // will seed automatically + return wopid + } +} diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECClient.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECClient.kt new file mode 100644 index 0000000..5868899 --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECClient.kt @@ -0,0 +1,26 @@ +package ch.bfh.habej2.wallee_c2ec.client.c2ec + +import okhttp3.OkHttpClient + +class C2ECClient { + + companion object { + const val WITHDRAWAL_OP = "/c2ec/withdrawal-operation" + const val WITHDRAWAL_STATUS = "$WITHDRAWAL_OP/:wopid" + const val WITHDRAWAL_PAYMENT = "$WITHDRAWAL_OP/:wopid/payment" + } + + init { + var client = OkHttpClient.Builder().build(); + } + + fun retrieveWithdrawalStatus(wopid: String, longPollMs: Int): C2ECWithdrawalOperationStatus { + + println("retrieving withdrawal operation status...") + return C2ECWithdrawalOperationStatus() + } + + fun sendPaymentNotification(payment: C2ECPaymentNotification) { + println("sending payment notification...") + } +} \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECPaymentNotification.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECPaymentNotification.kt new file mode 100644 index 0000000..d4b292e --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECPaymentNotification.kt @@ -0,0 +1,4 @@ +package ch.bfh.habej2.wallee_c2ec.client.c2ec + +class C2ECPaymentNotification { +} \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECWithdrawalOperationStatus.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECWithdrawalOperationStatus.kt new file mode 100644 index 0000000..6aab68c --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/client/c2ec/C2ECWithdrawalOperationStatus.kt @@ -0,0 +1,4 @@ +package ch.bfh.habej2.wallee_c2ec.client.c2ec + +class C2ECWithdrawalOperationStatus { +} \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/config/ExchangeConfig.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/config/ExchangeConfig.kt new file mode 100644 index 0000000..5226699 --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/config/ExchangeConfig.kt @@ -0,0 +1,21 @@ +package ch.bfh.habej2.wallee_c2ec.config + +val EXCHANGES: List = mutableListOf() + +var CURRENT_EXCHANGE : ExchangeConfig? = null + +data class ExchangeConfig( + val displayName: String, + val c2ecBaseUrl: String, + val terminalId: String, + val accessToken: String +) + +fun loadConfiguredExchanges() { + + // TODO load from config file here + EXCHANGES.plus(listOf( + ExchangeConfig("localhost", "http://localhost:8082/c2ec", "Wallee-1", "secret") + )) + CURRENT_EXCHANGE = EXCHANGES[0] +} \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/config/TerminalConfig.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/config/TerminalConfig.kt new file mode 100644 index 0000000..5ebe54d --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/config/TerminalConfig.kt @@ -0,0 +1,13 @@ +package ch.bfh.habej2.wallee_c2ec.config + +val TERMINAL_CONFIG: TerminalConfig = TerminalConfig("Wallee-1", "secret") + +data class TerminalConfig( + val terminalId: String, + val accessToken: String +) + +fun loadTerminalConfig() { + + // TODO load from config file +} \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Color.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Color.kt new file mode 100644 index 0000000..548232a --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package ch.bfh.habej2.wallee_c2ec.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/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Theme.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Theme.kt new file mode 100644 index 0000000..1180b5e --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Theme.kt @@ -0,0 +1,70 @@ +package ch.bfh.habej2.wallee_c2ec.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.runtime.SideEffect +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalView +import androidx.core.view.WindowCompat + +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 Walleec2ecTheme( + 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 + } + val view = LocalView.current + if (!view.isInEditMode) { + SideEffect { + val window = (view.context as Activity).window + window.statusBarColor = colorScheme.primary.toArgb() + WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme + } + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Type.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Type.kt new file mode 100644 index 0000000..16cfb54 --- /dev/null +++ b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package ch.bfh.habej2.wallee_c2ec.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/wallee-c2ec/app/src/main/res/drawable/ic_launcher_background.xml b/wallee-c2ec/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/wallee-c2ec/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wallee-c2ec/app/src/main/res/drawable/ic_launcher_foreground.xml b/wallee-c2ec/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/wallee-c2ec/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/wallee-c2ec/app/src/main/res/mipmap-anydpi/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/wallee-c2ec/app/src/main/res/mipmap-anydpi/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/wallee-c2ec/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/wallee-c2ec/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/wallee-c2ec/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/wallee-c2ec/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/wallee-c2ec/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/wallee-c2ec/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/wallee-c2ec/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/wallee-c2ec/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/wallee-c2ec/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/wallee-c2ec/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/wallee-c2ec/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/wallee-c2ec/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/wallee-c2ec/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/wallee-c2ec/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/wallee-c2ec/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/wallee-c2ec/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/wallee-c2ec/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/wallee-c2ec/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/wallee-c2ec/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/wallee-c2ec/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/wallee-c2ec/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/wallee-c2ec/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/wallee-c2ec/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/wallee-c2ec/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/wallee-c2ec/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/wallee-c2ec/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/wallee-c2ec/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/wallee-c2ec/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/wallee-c2ec/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/wallee-c2ec/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/wallee-c2ec/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/wallee-c2ec/app/src/main/res/values/colors.xml b/wallee-c2ec/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/wallee-c2ec/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/res/values/strings.xml b/wallee-c2ec/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..2e91ab3 --- /dev/null +++ b/wallee-c2ec/app/src/main/res/values/strings.xml @@ -0,0 +1,6 @@ + + wallee-c2ec + ExchangeActivity + WithdrawalCreationActivity + PaymentActivity + \ No newline at end of file diff --git a/wallee-c2ec/app/src/main/res/values/themes.xml b/wallee-c2ec/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..d399614 --- /dev/null +++ b/wallee-c2ec/app/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +