diff --git a/example/src/main/java/org/xmtp/android/example/connect/ConnectWalletFragment.kt b/example/src/main/java/org/xmtp/android/example/connect/ConnectWalletFragment.kt
index 711736eae..b542a63cf 100644
--- a/example/src/main/java/org/xmtp/android/example/connect/ConnectWalletFragment.kt
+++ b/example/src/main/java/org/xmtp/android/example/connect/ConnectWalletFragment.kt
@@ -60,6 +60,10 @@ class ConnectWalletFragment : Fragment() {
viewModel.generateWallet()
}
+ binding.savedWalletButton.setOnClickListener {
+ viewModel.savedWallet()
+ }
+
val isConnectWalletAvailable = isConnectAvailable()
binding.connectButton.isEnabled = isConnectWalletAvailable
binding.connectError.isVisible = !isConnectWalletAvailable
@@ -115,6 +119,7 @@ class ConnectWalletFragment : Fragment() {
private fun showError(message: String) {
binding.progress.visibility = View.GONE
binding.generateButton.visibility = View.VISIBLE
+ binding.savedWalletButton.visibility = View.VISIBLE
binding.connectButton.visibility = View.VISIBLE
binding.connectError.isVisible = !isConnectAvailable()
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
@@ -125,6 +130,8 @@ class ConnectWalletFragment : Fragment() {
binding.generateButton.visibility = View.GONE
binding.connectButton.visibility = View.GONE
binding.connectError.visibility = View.GONE
+ binding.savedWalletButton.visibility = View.GONE
+
}
override fun onDestroyView() {
diff --git a/example/src/main/java/org/xmtp/android/example/connect/ConnectWalletViewModel.kt b/example/src/main/java/org/xmtp/android/example/connect/ConnectWalletViewModel.kt
index 4d37b3eb6..fdb10450c 100644
--- a/example/src/main/java/org/xmtp/android/example/connect/ConnectWalletViewModel.kt
+++ b/example/src/main/java/org/xmtp/android/example/connect/ConnectWalletViewModel.kt
@@ -17,6 +17,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
+import org.web3j.utils.Numeric
import org.xmtp.android.example.ClientManager
import org.xmtp.android.example.account.WalletConnectV2Account
import org.xmtp.android.library.Client
@@ -98,6 +99,26 @@ class ConnectWalletViewModel(application: Application) : AndroidViewModel(applic
}
}
+ @UiThread
+ fun savedWallet() {
+ viewModelScope.launch(Dispatchers.IO) {
+ _uiState.value = ConnectUiState.Loading
+ try {
+ val privateKeyData = Numeric.hexStringToByteArray("0x2429cd5b39334e854cb26dfe2037293cd1ccc980e366a35fa6a09cdbef070bda")
+ // Use hardcoded privateKey
+ val privateKey = PrivateKeyBuilder.buildFromPrivateKeyData(privateKeyData)
+ val wallet = PrivateKeyBuilder(privateKey)
+ val client = Client().create(wallet, ClientManager.clientOptions(getApplication()))
+ _uiState.value = ConnectUiState.Success(
+ wallet.getAddress(),
+ PrivateKeyBundleV1Builder.encodeData(client.privateKeyBundleV1)
+ )
+ } catch (e: XMTPException) {
+ _uiState.value = ConnectUiState.Error(e.message.orEmpty())
+ }
+ }
+ }
+
@UiThread
fun connectWallet(approvedSession: Modal.Model.ApprovedSession) {
viewModelScope.launch(Dispatchers.IO) {
diff --git a/example/src/main/java/org/xmtp/android/example/conversation/ConversationDetailActivity.kt b/example/src/main/java/org/xmtp/android/example/conversation/ConversationDetailActivity.kt
index 7432651ae..f52ecab8c 100644
--- a/example/src/main/java/org/xmtp/android/example/conversation/ConversationDetailActivity.kt
+++ b/example/src/main/java/org/xmtp/android/example/conversation/ConversationDetailActivity.kt
@@ -55,8 +55,8 @@ class ConversationDetailActivity : AppCompatActivity() {
setSupportActionBar(binding.toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.subtitle = if (peerAddress != null && peerAddress!!.contains(",")) {
- val addresses = peerAddress?.split(",")?.toMutableList()
- addresses?.joinToString(" -- ") {
+ val addresses = peerAddress?.split(",")?.toMutableList()?.drop(1)
+ addresses?.joinToString(" & ") {
it.truncatedAddress()
}
} else {
diff --git a/example/src/main/java/org/xmtp/android/example/conversation/ConversationViewHolder.kt b/example/src/main/java/org/xmtp/android/example/conversation/ConversationViewHolder.kt
index 7c79211a7..9b2de94c2 100644
--- a/example/src/main/java/org/xmtp/android/example/conversation/ConversationViewHolder.kt
+++ b/example/src/main/java/org/xmtp/android/example/conversation/ConversationViewHolder.kt
@@ -26,8 +26,8 @@ class ConversationViewHolder(
fun bind(item: MainViewModel.MainListItem.ConversationItem) {
conversation = item.conversation
binding.peerAddress.text = if (item.conversation.peerAddress.contains(",")) {
- val addresses = item.conversation.peerAddress.split(",")
- addresses.joinToString(" -- ") {
+ val addresses = item.conversation.peerAddress.split(",").drop(1)
+ addresses.joinToString(" & ") {
it.truncatedAddress()
}
} else {
diff --git a/example/src/main/java/org/xmtp/android/example/message/MessageViewHolder.kt b/example/src/main/java/org/xmtp/android/example/message/MessageViewHolder.kt
index 41cfb8912..e4d98dbeb 100644
--- a/example/src/main/java/org/xmtp/android/example/message/MessageViewHolder.kt
+++ b/example/src/main/java/org/xmtp/android/example/message/MessageViewHolder.kt
@@ -22,7 +22,7 @@ class MessageViewHolder(
binding.root.resources.getColor(R.color.teal_700, binding.root.context.theme)
fun bind(item: ConversationDetailViewModel.MessageListItem.Message) {
- val isFromMe = ClientManager.client.address == item.message.senderAddress
+ val isFromMe = ClientManager.client.address.lowercase() == item.message.senderAddress.lowercase()
val params = binding.messageContainer.layoutParams as ConstraintLayout.LayoutParams
if (isFromMe) {
params.rightToRight = PARENT_ID
diff --git a/example/src/main/res/layout/fragment_connect_wallet.xml b/example/src/main/res/layout/fragment_connect_wallet.xml
index 8d93ca824..75d7098eb 100644
--- a/example/src/main/res/layout/fragment_connect_wallet.xml
+++ b/example/src/main/res/layout/fragment_connect_wallet.xml
@@ -28,6 +28,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
+
+
+ app:layout_constraintTop_toBottomOf="@id/savedWalletButton" />