Skip to content

Commit

Permalink
Classic receive
Browse files Browse the repository at this point in the history
  • Loading branch information
SeniorZhai committed Mar 8, 2025
1 parent d7c5007 commit a6e5186
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class ClassicWalletFragment : BaseFragment(R.layout.fragment_privacy_wallet), He
getSolanaAddressForWallet()
}
if (address != null) {
WalletActivity.showWithAddress(this@ClassicWalletFragment.requireActivity(), address, WalletActivity.Destination.Address)
this@ClassicWalletFragment.navTo(Web3ReceiveSelectionFragment.newInstance(address, token.chainId), Web3ReceiveSelectionFragment.TAG)
}
}
dismissNow()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package one.mixin.android.ui.wallet

import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import one.mixin.android.Constants
import one.mixin.android.Constants.Web3ChainIds
import one.mixin.android.R
import one.mixin.android.databinding.FragmentWeb3ReceiveSelectionBinding
import one.mixin.android.extension.navTo
import one.mixin.android.session.Session
import one.mixin.android.ui.common.BaseFragment
import one.mixin.android.ui.home.web3.Web3ViewModel
import one.mixin.android.ui.wallet.InputFragment
import one.mixin.android.web3.send.TokenListBottomSheetDialogFragment

@AndroidEntryPoint
class Web3ReceiveSelectionFragment : BaseFragment() {
companion object {
const val TAG = "Web3ReceiveSelectionFragment"
private const val ARGS_ADDRESS = "args_address"
private const val ARGS_CHAIN_ID = "args_chain_id"

fun newInstance(address: String, chainId: String) = Web3ReceiveSelectionFragment().apply {
arguments = Bundle().apply {
putString(ARGS_ADDRESS, address)
putString(ARGS_CHAIN_ID, chainId)
}
}
}

private var _binding: FragmentWeb3ReceiveSelectionBinding? = null
private val binding get() = requireNotNull(_binding)
private val web3ViewModel by viewModels<Web3ViewModel>()

private val address by lazy { requireArguments().getString(ARGS_ADDRESS, "") }
private val chainId by lazy { requireArguments().getString(ARGS_CHAIN_ID, "") }

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
_binding = FragmentWeb3ReceiveSelectionBinding.inflate(inflater, container, false).apply { this.root.setOnClickListener { } }
binding.root.setOnClickListener { }
binding.title.setOnClickListener { }
binding.title.leftIb.setOnClickListener { activity?.onBackPressedDispatcher?.onBackPressed() }
binding.walletTv.text = getString(R.string.contact_mixin_id, Session.getAccount()?.identityNumber)
binding.walletRl.setOnClickListener {
lifecycleScope.launch {
if (address.isEmpty()) {
return@launch
}
val chainIds = if (chainId.isNotEmpty()) {
listOf(chainId)
} else {
Web3ChainIds
}
val list = web3ViewModel.web3TokenItems(chainIds)
TokenListBottomSheetDialogFragment.newInstance(ArrayList(list)).apply {
setOnClickListener { token ->
navTo(InputFragment.newInstance(token, address, null, true), InputFragment.TAG)
dismissNow()
}
}.show(parentFragmentManager, TokenListBottomSheetDialogFragment.TAG)
}
}
binding.addressRl.setOnClickListener {
WalletActivity.showWithAddress(this.requireActivity(), address, WalletActivity.Destination.Address)
}
return binding.root
}

@SuppressLint("SetTextI18n")
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,13 @@ class Web3AddressFragment : BaseFragment() {
binding.avatar2.isVisible = false
binding.avatar3.isVisible = false
binding.avatar4.isVisible = false
binding.avatar5.isVisible = false
binding.avatar6.isVisible = false
binding.avatar7.isVisible = false
binding.bottomHintTv.setText(R.string.web3_deposit_description_solana)
} else {
qrAvatar.bg.setImageResource(R.drawable.ic_web3_logo_eth)
binding.avatar1.setImageResource(R.drawable.ic_web3_chain_eth)
binding.avatar2.isVisible = true
binding.avatar3.isVisible = true
binding.avatar4.isVisible = true
binding.avatar5.isVisible = true
binding.avatar6.isVisible = true
binding.avatar7.isVisible = true
binding.bottomHintTv.setText(R.string.web3_deposit_description_evm)
}
qr.post {
Expand Down
141 changes: 141 additions & 0 deletions app/src/main/res/layout/fragment_web3_receive_selection.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/bg_white"
android:orientation="vertical">

<one.mixin.android.widget.TitleView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:need_divider="false"
app:titleText="@string/Receive" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/wallet_rl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="10dp"
android:background="@drawable/ripple_round_window">

<ImageView
android:id="@+id/avatar"
android:src="@drawable/ic_web3_deposit_wallet"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>

<ImageView
android:src="@drawable/ic_web3_arrow"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<TextView
android:id="@+id/wallet_title_tv"
android:text="@string/My_Wallet"
android:textColor="?attr/text_primary"
android:textSize="16sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="2dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/wallet_tv"
app:layout_constraintStart_toEndOf="@id/avatar"
/>

<TextView
android:id="@+id/wallet_tv"
android:text="@string/My_Wallet_desc"
android:textColor="?attr/text_subtitle"
android:textSize="13sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginStart="12dp"
android:layout_marginBottom="12dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/wallet_title_tv"
app:layout_constraintStart_toEndOf="@id/avatar" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/address_rl"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="10dp"
android:background="@drawable/ripple_round_window">

<ImageView
android:id="@+id/avatar_address"
android:src="@drawable/ic_web3_deposit_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>

<ImageView
android:src="@drawable/ic_web3_arrow"
android:layout_marginEnd="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<TextView
android:id="@+id/wallet_address_tv"
android:text="@string/Exchanges_or_Wallets"
android:textColor="?attr/text_primary"
android:textSize="16sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginBottom="2dp"
android:layout_marginStart="12dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/address_tv"
app:layout_constraintStart_toEndOf="@id/avatar_address"/>

<TextView
android:id="@+id/address_tv"
android:text="@string/Exchanges_or_Wallets_desc"
android:textColor="?attr/text_subtitle"
android:textSize="13sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginStart="12dp"
android:layout_marginBottom="12dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/wallet_address_tv"
app:layout_constraintStart_toEndOf="@id/avatar_address"/>

</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

4 changes: 4 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1859,4 +1859,8 @@
<string name="Address_Book">地址簿</string>
<string name="insufficient_fee_description">需要 %1$s 以支付 %2$s 网络费用</string>
<string name="Send_To_Title">转给</string>
<string name="My_Wallet">我的钱包</string>
<string name="My_Wallet_desc">使用加密货币网络从我的其他钱包提现</string>
<string name="Exchanges_or_Wallets">交易所或钱包</string>
<string name="Exchanges_or_Wallets_desc">使用加密货币网络从其他交易所或链上钱包提现</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1906,4 +1906,8 @@
<string name="Privacy_Wallet">Privacy Wallet</string>
<string name="Classic_Wallet">Classic Wallet</string>
<string name="Other">Other</string>
<string name="My_Wallet">My Wallet</string>
<string name="My_Wallet_desc">Withdraw from my other wallet using a crypto network</string>
<string name="Exchanges_or_Wallets">Exchanges or Wallets</string>
<string name="Exchanges_or_Wallets_desc">Withdraw from other exchanges or on-chain wallets using a crypto network</string>
</resources>

0 comments on commit a6e5186

Please sign in to comment.