diff --git a/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/MainApplication.kt b/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/MainApplication.kt
index cdc0d6f3..6e3599a2 100644
--- a/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/MainApplication.kt
+++ b/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/MainApplication.kt
@@ -1,6 +1,7 @@
package network.bisq.mobile.client
import android.app.Application
+import network.bisq.mobile.client.di.androidClientModule
import network.bisq.mobile.client.di.clientModule
import network.bisq.mobile.domain.di.domainModule
import network.bisq.mobile.presentation.di.presentationModule
@@ -14,7 +15,7 @@ class MainApplication: Application() {
startKoin {
androidContext(this@MainApplication)
- modules(listOf(domainModule, presentationModule, clientModule))
+ modules(listOf(domainModule, presentationModule, clientModule, androidClientModule))
}
}
}
diff --git a/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/di/AndroidClientModule.kt b/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/di/AndroidClientModule.kt
new file mode 100644
index 00000000..2c529fe3
--- /dev/null
+++ b/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/di/AndroidClientModule.kt
@@ -0,0 +1,16 @@
+package network.bisq.mobile.client.di
+
+import network.bisq.mobile.client.cathash.ClientCatHashService
+import network.bisq.mobile.service.AndroidClientCatHashService
+import org.koin.android.ext.koin.androidContext
+import org.koin.dsl.bind
+import org.koin.dsl.module
+
+
+val androidClientModule = module {
+ single {
+ val context = androidContext()
+ val filesDir = context.filesDir.absolutePath
+ AndroidClientCatHashService(context, filesDir)
+ } bind ClientCatHashService::class
+}
\ No newline at end of file
diff --git a/androidClient/src/androidMain/kotlin/network/bisq/mobile/service/AndroidClientCatHashService.kt b/androidClient/src/androidMain/kotlin/network/bisq/mobile/service/AndroidClientCatHashService.kt
new file mode 100644
index 00000000..83d3fc5b
--- /dev/null
+++ b/androidClient/src/androidMain/kotlin/network/bisq/mobile/service/AndroidClientCatHashService.kt
@@ -0,0 +1,49 @@
+/*
+ * This iconFilePath is part of Bisq.
+ *
+ * Bisq is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Bisq 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 Affero General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Bisq. If not, see .
+ */
+package network.bisq.mobile.service
+
+import android.content.Context
+import androidx.compose.ui.graphics.ImageBitmap
+import androidx.compose.ui.graphics.asAndroidBitmap
+import androidx.compose.ui.graphics.asImageBitmap
+import network.bisq.mobile.client.cathash.ClientCatHashService
+import network.bisq.mobile.utils.ImageUtil
+import network.bisq.mobile.utils.ImageUtil.PATH_TO_DRAWABLE
+import java.io.File
+
+const val CAT_HASH_PATH = PATH_TO_DRAWABLE + "cathash/"
+
+class AndroidClientCatHashService(private val context: Context, filesDir: String) :
+ ClientCatHashService("$filesDir/Bisq2_mobile") {
+ override fun composeImage(paths: Array, size: Int): ImageBitmap {
+ return ImageUtil.composeImage(
+ context,
+ CAT_HASH_PATH,
+ paths,
+ size,
+ size
+ ).asImageBitmap()
+ }
+
+ override fun writeRawImage(image: ImageBitmap, iconFilePath: String) {
+ ImageUtil.writeRawImage(image.asAndroidBitmap(), File(iconFilePath))
+ }
+
+ override fun readRawImage(iconFilePath: String): ImageBitmap? {
+ return ImageUtil.readRawImage(File((iconFilePath)))?.asImageBitmap()
+ }
+}
diff --git a/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/di/ClientModule.kt b/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/di/ClientModule.kt
index 147eb33a..45aac1a1 100644
--- a/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/di/ClientModule.kt
+++ b/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/di/ClientModule.kt
@@ -50,7 +50,7 @@ val clientModule = module {
single { ClientMarketPriceServiceFacade(get()) }
single { UserProfileApiGateway(get()) }
- single { ClientUserProfileServiceFacade(get()) }
+ single { ClientUserProfileServiceFacade(get(), get()) }
single { OfferbookApiGateway(get()) }
single { ClientOfferbookServiceFacade(get(), get()) }
diff --git a/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/offerbook/ClientOfferbookServiceFacade.kt b/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/offerbook/ClientOfferbookServiceFacade.kt
index dc6a976f..eccfe1ad 100644
--- a/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/offerbook/ClientOfferbookServiceFacade.kt
+++ b/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/offerbook/ClientOfferbookServiceFacade.kt
@@ -5,11 +5,11 @@ import network.bisq.mobile.client.offerbook.market.ClientMarketListItemService
import network.bisq.mobile.client.offerbook.market.ClientSelectedOfferbookMarketService
import network.bisq.mobile.client.offerbook.offer.ClientOfferbookListItemService
import network.bisq.mobile.client.offerbook.offer.OfferbookApiGateway
-import network.bisq.mobile.domain.service.market_price.MarketPriceServiceFacade
-import network.bisq.mobile.domain.data.model.OfferListItem
-import network.bisq.mobile.domain.service.offerbook.OfferbookServiceFacade
import network.bisq.mobile.domain.data.model.MarketListItem
+import network.bisq.mobile.domain.data.model.OfferListItem
import network.bisq.mobile.domain.data.model.OfferbookMarket
+import network.bisq.mobile.domain.service.market_price.MarketPriceServiceFacade
+import network.bisq.mobile.domain.service.offerbook.OfferbookServiceFacade
import network.bisq.mobile.utils.Logging
class ClientOfferbookServiceFacade(
@@ -24,8 +24,10 @@ class ClientOfferbookServiceFacade(
override val selectedOfferbookMarket: StateFlow get() = selectedOfferbookMarketService.selectedOfferbookMarket
// Misc
- private val offerbookListItemService: ClientOfferbookListItemService = ClientOfferbookListItemService(apiGateway)
- private val marketListItemService: ClientMarketListItemService = ClientMarketListItemService(apiGateway)
+ private val offerbookListItemService: ClientOfferbookListItemService =
+ ClientOfferbookListItemService(apiGateway)
+ private val marketListItemService: ClientMarketListItemService =
+ ClientMarketListItemService(apiGateway)
private val selectedOfferbookMarketService: ClientSelectedOfferbookMarketService =
ClientSelectedOfferbookMarketService(marketPriceServiceFacade)
diff --git a/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/user_profile/ClientUserProfileServiceFacade.kt b/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/user_profile/ClientUserProfileServiceFacade.kt
index ada9e672..1ad5ebf1 100644
--- a/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/user_profile/ClientUserProfileServiceFacade.kt
+++ b/shared/domain/src/commonMain/kotlin/network/bisq/mobile/client/user_profile/ClientUserProfileServiceFacade.kt
@@ -2,15 +2,20 @@ package network.bisq.mobile.client.user_profile
import kotlinx.coroutines.delay
import kotlinx.datetime.Clock
+import network.bisq.mobile.client.cathash.ClientCatHashService
import network.bisq.mobile.client.replicated_model.user.identity.PreparedData
import network.bisq.mobile.client.replicated_model.user.profile.UserProfile
import network.bisq.mobile.domain.service.user_profile.UserProfileServiceFacade
import network.bisq.mobile.utils.Logging
+import network.bisq.mobile.utils.hexToByteArray
import kotlin.math.max
import kotlin.math.min
import kotlin.random.Random
-class ClientUserProfileServiceFacade(private val apiGateway: UserProfileApiGateway) :
+class ClientUserProfileServiceFacade(
+ private val apiGateway: UserProfileApiGateway,
+ private val clientCatHashService: ClientCatHashService
+) :
UserProfileServiceFacade, Logging {
// Misc
@@ -26,8 +31,15 @@ class ClientUserProfileServiceFacade(private val apiGateway: UserProfileApiGatew
val ts = Clock.System.now().toEpochMilliseconds()
val preparedData = apiGateway.requestPreparedData()
createSimulatedDelay(Clock.System.now().toEpochMilliseconds() - ts)
- //todo not impl yet
- result(preparedData.id, preparedData.nym, null)
+ val pubKeyHash: ByteArray = preparedData.id.hexToByteArray()
+ val powSolution = preparedData.proofOfWork.solution
+ val image = clientCatHashService.getImage(
+ pubKeyHash,
+ powSolution,
+ 0,
+ 120
+ )
+ result(preparedData.id, preparedData.nym, image)
this.preparedData = preparedData
} catch (e: Exception) {
log.e { e.toString() }