diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PrismAgent.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PrismAgent.kt index 990bfe99a..bcfffc7e4 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PrismAgent.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PrismAgent.kt @@ -446,6 +446,7 @@ class PrismAgent { store = BasicMediatorHandler.PlutoMediatorRepositoryImpl(pluto) ) setupMediatorHandler(tmpMediatorHandler) + start() } /** diff --git a/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/Sdk.kt b/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/Sdk.kt index e156e6aa8..cda3a57b2 100644 --- a/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/Sdk.kt +++ b/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/Sdk.kt @@ -80,6 +80,10 @@ class Sdk() { } } + suspend fun updateMediatorDID(mediatorDID: String) { + agent?.setupMediatorDID(DID(mediatorDID)) + } + fun stopAgent() { agent?.let { it.stopFetchingMessages() diff --git a/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/ui/agent/AgentFragment.kt b/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/ui/agent/AgentFragment.kt index a47a668fb..c4e2e2374 100644 --- a/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/ui/agent/AgentFragment.kt +++ b/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/ui/agent/AgentFragment.kt @@ -32,7 +32,8 @@ class AgentFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding.startAgent.setOnClickListener { - viewModel.startAgent() + val mediatorDID = binding.mediatorDid.text.toString() + viewModel.startAgent(mediatorDID) } } diff --git a/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/ui/agent/AgentViewModel.kt b/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/ui/agent/AgentViewModel.kt index a4e485430..7dbc5f51c 100644 --- a/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/ui/agent/AgentViewModel.kt +++ b/sampleapp/src/main/java/io/iohk/atala/prism/sampleapp/ui/agent/AgentViewModel.kt @@ -8,10 +8,11 @@ import kotlinx.coroutines.launch class AgentViewModel(application: Application) : AndroidViewModel(application) { - fun startAgent() { + fun startAgent(mediatorDID: String) { val sdk = Sdk.getInstance(getApplication()) viewModelScope.launch { sdk.startAgent() + sdk.updateMediatorDID(mediatorDID) } } } diff --git a/sampleapp/src/main/res/layout/fragment_agent.xml b/sampleapp/src/main/res/layout/fragment_agent.xml index 09b9cf107..6f8d5ad1d 100644 --- a/sampleapp/src/main/res/layout/fragment_agent.xml +++ b/sampleapp/src/main/res/layout/fragment_agent.xml @@ -1,44 +1,66 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".ui.agent.AgentFragment"> + android:id="@+id/agent_status_title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:text="Agent status:" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"/> + android:id="@+id/agent_status" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/agent_status_title" + tools:text="RUNNING"/> + + + +