Skip to content

Commit

Permalink
Feature/android node networking POC integration (#38)
Browse files Browse the repository at this point in the history
* Remove protobuf files and i18n resources

* Remove mobile package (was first dev app with showing version number)

* Add multidex dependency, add protobuf source path

* - small adaptations on android native POC whilst understanding it

* - convert android native POC code to Kotlin for easier transition

* - replace completable future with coroutines job

* - protobuf fixes on POC merged from boilingfrog, fully communicates with seednode now (thanks Henrik!)

* - integration of last commit into the androidNode

* - integrated services from POC with all their dependencies, ready to be used

* - initialize services, added typesafe conf where its expecting it

* - integration of print default sec key and language, printing on system.out

* Added Koin Dependency (#31)

* Added Koin Dependency

At this stage, have only added in build.gradle.kts file under comman
code.

* Added sample code on android side

* Added di under shared package

* Added Koin under ios

* Fix - Renaming files

* Added Koin to Android Node

* Fix - Reformat the code

* Fix - fomatting again

* - integrated services from POC with all their dependencies, ready to be used

* - hardcode presenter dependency till issues with DI Koin and androidNode gets fixed

* - remove protobuf lite dep causing trouble with protobuf in bisq2 jars on runtime

* - capable of creating profile if non existent and gets persisted

* - observe network changes and log, fetch and print btc market price

* - private messaging (trading) integration

* - public messaging integration

* - Implementation for android node memory report integrated with main service + junit setup and test for the new code

* - android node ci config to use its own presenter as main

* - integration of app state

* - add cleanup on presenter destruction

* - fix userProfile mode package name

---------

Co-authored-by: HenrikJannsen <[email protected]>
Co-authored-by: nis-ship-it <[email protected]>
  • Loading branch information
3 people authored Nov 13, 2024
1 parent c53884b commit 66605d1
Show file tree
Hide file tree
Showing 173 changed files with 2,229 additions and 42,968 deletions.
60 changes: 35 additions & 25 deletions bisqapps/androidNode/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import com.google.protobuf.gradle.*
import org.apache.tools.ant.taskdefs.condition.Os
import com.google.protobuf.gradle.proto

plugins {
alias(libs.plugins.kotlinMultiplatform)
Expand Down Expand Up @@ -32,6 +32,11 @@ kotlin {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
}
androidUnitTest.dependencies {
implementation(libs.mock.io)
implementation(libs.kotlin.test.junit.v180)
implementation(libs.junit)
}
kotlin.srcDirs(
"src/androidMain/kotlin",
"${layout.buildDirectory}/generated/source/proto/debug/java",
Expand All @@ -47,32 +52,28 @@ android {

sourceSets {
getByName("main") {
proto {
srcDir("src/androidMain/proto")
java {
srcDir("src/main/resources")
srcDir("${layout.buildDirectory}/generated/source/proto/debug/java")
srcDir("${layout.buildDirectory}/generated/source/proto/release/java")
proto {
srcDir("${layout.buildDirectory}/extracted-include-protos/debug")
}
}
java.srcDirs(
"src/layout.buildDirectory/kotlin",
"${layout.buildDirectory}/generated/source/proto/debug/java",
"${layout.buildDirectory}/generated/source/proto/release/java"
)
}
}

defaultConfig {
applicationId = "network.bisq.mobile.node"
minSdk = libs.versions.android.node.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
multiDexEnabled = true
versionCode = 1
versionName = project.version.toString()
buildConfigField("String", "APP_VERSION", "\"${version}\"")
buildConfigField("String", "SHARED_VERSION", "\"${sharedVersion}\"")
}

// We don't want to use the protobuf coming in bisq2 core dependencies as we use protobuf-lite for mobile
configurations.all {
exclude(group = "com.google.protobuf", module = "protobuf-java")
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
Expand Down Expand Up @@ -104,17 +105,11 @@ protobuf {
protoc {
artifact = "com.google.protobuf:protoc:4.28.2$archSuffix"
}
plugins {
create("javalite") {
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0$archSuffix"
}
}
generateProtoTasks {
all().forEach { task ->
task.inputs.dir("${layout.buildDirectory.get()}/extracted-include-protos/debug")
task.builtins {
create("java") {
option("lite")
}
create("java")
}
}
}
Expand All @@ -125,9 +120,16 @@ dependencies {
debugImplementation(compose.uiTooling)

// bisq2 core dependencies
implementation(libs.bisq.core.common) {
exclude(group = "com.google.protobuf", module = "protobuf-java")
}
implementation(libs.androidx.multidex)
implementation(libs.google.guava)
compileOnly(libs.lombok)
annotationProcessor(libs.lombok)
implementation(libs.typesafe.config)

implementation(libs.bouncycastle)
implementation(libs.bouncycastle.pg)

implementation(libs.bisq.core.common)
implementation(libs.bisq.core.i18n)
implementation(libs.bisq.core.persistence)
implementation(libs.bisq.core.security)
Expand All @@ -154,10 +156,18 @@ dependencies {
implementation(libs.bisq.core.presentation)

// protobuf
implementation(libs.protobuf.lite)
implementation(libs.protobuf.gradle.plugin)
implementation(libs.protoc)

implementation(libs.koin.core)
implementation(libs.koin.android)
}

// ensure tests run on J17
tasks.withType<Test> {
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(17))
}
)
}
2 changes: 2 additions & 0 deletions bisqapps/androidNode/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name="network.bisq.mobile.android.node.MainApplication"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.koin.android.ext.android.inject

class MainActivity : ComponentActivity() {
private val presenter : MainPresenter by inject()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
presenter.attachView(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import network.bisq.mobile.presentation.di.presentationModule
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin


class MainApplication : Application() {
override fun onCreate() {
super.onCreate()

startKoin {
androidContext(this@MainApplication)
modules(listOf(androidNodeModule, domainModule, presentationModule))
// order is important, last one is picked for each interface/class key
modules(listOf(domainModule, presentationModule, androidNodeModule))
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package network.bisq.mobile.android.node.di

import network.bisq.mobile.android.node.AndroidNodeGreetingFactory
import network.bisq.mobile.android.node.presentation.MainNodePresenter
import network.bisq.mobile.domain.GreetingFactory
import network.bisq.mobile.presentation.MainPresenter
import org.koin.dsl.module

val androidNodeModule = module {
single<GreetingFactory> { AndroidNodeGreetingFactory() }
single<MainPresenter> { MainNodePresenter(get()) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package network.bisq.mobile.android.node.domain.model

import bisq.common.observable.Observable
import bisq.security.pow.ProofOfWork
import lombok.Getter
import lombok.Setter
import java.security.KeyPair

/**
* TODO do we need to make this shared? If so it involves getting rid of the bisq.* deps, lombok and include java.security in shared..
* Most probably we don't and this can be just part of androidNode (we'll know when the bisq-apis gets defined)
*/
@Getter
class UserProfileModel {
@Setter
var keyPair: KeyPair? = null

@Setter
lateinit var pubKeyHash: ByteArray

@Setter
var proofOfWork: ProofOfWork? = null

private val userName = Observable<String>()
val terms = Observable("")
val statement = Observable("")
val nym = Observable<String>()
private val nickName = Observable<String>()
private val profileId = Observable<String>()

val isBusy = Observable<Boolean>()
}
Loading

0 comments on commit 66605d1

Please sign in to comment.