-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add domain for user profile * Add Supplier to AndroidApplicationService. Remove demo code from MainNodePresenter and inti code to AndroidApplicationService. Add generateKeyPairInProgress and createAndPublishInProgress properties. Add createSimulatedDelay method to ClientUserProfileServiceFacade Supplier is then used in DI and provides the services from the AndroidApplicationService when used by a lazy getter. This hack is needed as AndroidApplicationService requires some constructor argumewnts which are not present as application startup but only after the mainActiviy is created. We startup KOIN in the MainApplication.onCreate method. We use the MainNodePresenter which gets called its onViewAttached once the mainActiviy is ready and then we can set the applicationService inside the supplier. I don't like that unsafe lateinit setter strategy and have proposed an alterantive solution in my POC which would work with constructor injection. Maybe there are some hacks in KOIN to get the done in a different manner, but the main problem is that KOIN gets started at the MainApplication.onCreate and not on the MainActivity.onCreate. Only at that moment we have all the basic dependencies from the Android UI framework. But even if we would move that to the MainActivity.onCreate, we would need to pass the properties to the module in some way. * Rename AndroidModule to AndroidClientModule Add DI config to AndroidClientModule Remove ICreateProfilePresenter as there is only one instance and not expected a use case for multiple instances. Add UserProfileRepository holding model and serviceFacade Adjust Screen and Presenter. Discussion: To me the usage of the repository does not make much sense here. The 2 relevant methods do not map into the CRUD pattern which seems to be the design philosophy for repositories. I would suggest to use it only when teh CRUD pattern and persistence is used and appropriate. And to inject the model and the service facade to the presenter in the other cases. Otherwise we just create a useless wrapper. @rodvar: If you would implement the usage here in a different way, can you provide with the given use case an implementation example? * Add "android.permission.INTERNET" entry to manifest for Android client * Fix parameter in ApiRequestService. We pass the host instead of baseUrl. On iOS simulator we need to use localhost, not 10.0.2.2 * Add IosClientModule Use Dispatchers.Main instead of Dispatchers.IO as it seems iOS does not support that. * Add equals and hashCode * Remove redundant config for UserProfileRepository * Remove unused model * Add pruneAllBackups and readAllPersisted calls in AndroidApplicationService * Add applySelectedUserProfile, getSelectedUserProfile and getUserIdentityIds methods. In the CreateProfilePresenter at onLaunched there are commented out some different dev test modes; - Use hasUserProfile to check if create user profile screen should be shown - onGenerateKeyPair if no profile is present - applySelectedUserProfile if one is present and we apply the data to the screen. This is only for dev testing. We have to display the selected user profile in the app in a TBD way. Tested with all 3 apps and working. Requires latest Bisq 2 main version and a running rest api. * Move gradle dependencies to toml file * Fix merge issue * Fix merge issue Go to next screen on onCreateAndPublishNewUserProfile completed. * Move bisq2 compatible models to client.replicated_model * Add clientModule, use DI for HttpClient * Use class name for Logger.withTag Remove unneeded coroutineScope.launch blocks * Add ignoreUnknownKeys to json deserializer Make Json configs fields * Add serviceFacade and model for bootstrap * Refactor: Rename MainNodePresenter to NodeMainPresenter * Add serviceFacade and model for application bootstrap. This only provides the domain part. It is not yet connected to the UI as its still unclear to me what patter to use for that. When using the Client version one need to instantiate th ClientApplicationBootstrapFacade and call initialize(). Could be done in the presenter... * Remove domain models and use return values instead * Nits contribution - fix double call on view attached for the special case of the MainPresenter - remove double static configuration of bisq core jars (left in MainApplication override only) - provide single instance of android memory report service and adjust usages - cleanup/comment dead code - cleanup unused imports * Apply code review suggestions * Adjust to API changes --------- Co-authored-by: Rodrigo Varela <[email protected]>
- Loading branch information
1 parent
6e8839b
commit 83cc9bc
Showing
49 changed files
with
1,030 additions
and
681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...androidClient/src/androidMain/kotlin/network/bisq/mobile/client/di/AndroidClientModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package network.bisq.mobile.client.di | ||
|
||
import network.bisq.mobile.android.node.main.bootstrap.ClientApplicationBootstrapFacade | ||
import network.bisq.mobile.client.presentation.AndroidClientMainPresenter | ||
import network.bisq.mobile.client.service.ApiRequestService | ||
import network.bisq.mobile.domain.client.main.user_profile.ClientUserProfileServiceFacade | ||
import network.bisq.mobile.domain.client.main.user_profile.UserProfileApiGateway | ||
import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade | ||
import network.bisq.mobile.domain.user_profile.UserProfileServiceFacade | ||
import network.bisq.mobile.presentation.MainPresenter | ||
import network.bisq.mobile.presentation.ui.AppPresenter | ||
import org.koin.dsl.bind | ||
import org.koin.dsl.module | ||
|
||
val androidClientModule = module { | ||
single<ApplicationBootstrapFacade> { ClientApplicationBootstrapFacade() } | ||
|
||
single { ApiRequestService(get(), "10.0.2.2") } | ||
single { UserProfileApiGateway(get()) } | ||
single<UserProfileServiceFacade> { ClientUserProfileServiceFacade(get()) } | ||
single<MainPresenter> { AndroidClientMainPresenter(get()) } bind AppPresenter::class | ||
} |
8 changes: 0 additions & 8 deletions
8
bisqapps/androidClient/src/androidMain/kotlin/network/bisq/mobile/client/di/AndroidModule.kt
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
.../androidMain/kotlin/network/bisq/mobile/client/presentation/AndroidClientMainPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package network.bisq.mobile.client.presentation | ||
|
||
import network.bisq.mobile.domain.data.repository.GreetingRepository | ||
import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade | ||
import network.bisq.mobile.presentation.MainPresenter | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
class AndroidClientMainPresenter( | ||
private val applicationBootstrapFacade: ApplicationBootstrapFacade | ||
) : MainPresenter(GreetingRepository()) { | ||
var applicationServiceInited = false | ||
override fun onViewAttached() { | ||
super.onViewAttached() | ||
|
||
if (!applicationServiceInited) { | ||
applicationServiceInited = true | ||
applicationBootstrapFacade.initialize() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...otlin/network/bisq/mobile/android/node/domain/bootstrap/NodeApplicationBootstrapFacade.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package network.bisq.mobile.android.node.domain.bootstrap | ||
|
||
import bisq.application.State | ||
import network.bisq.mobile.android.node.AndroidApplicationService | ||
import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade | ||
|
||
class NodeApplicationBootstrapFacade( | ||
private val supplier: AndroidApplicationService.Supplier | ||
) : | ||
ApplicationBootstrapFacade() { | ||
|
||
override fun initialize() { | ||
supplier.stateSupplier.get().addObserver { state: State -> | ||
when (state) { | ||
State.INITIALIZE_APP -> { | ||
setState("Starting Bisq") | ||
setProgress(0f) | ||
} | ||
|
||
State.INITIALIZE_NETWORK -> { | ||
setState("Initialize P2P network") | ||
setProgress(0.5f) | ||
} | ||
|
||
// not used | ||
State.INITIALIZE_WALLET -> { | ||
} | ||
|
||
State.INITIALIZE_SERVICES -> { | ||
setState("Initialize services") | ||
setProgress(0.75f) | ||
} | ||
|
||
State.APP_INITIALIZED -> { | ||
setState("Bisq started") | ||
setProgress(1f) | ||
} | ||
|
||
State.FAILED -> { | ||
setState("Startup failed") | ||
setProgress(0f) | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.