hide/show memo section if Taddress
This commit is contained in:
parent
93ed588073
commit
69a4092cd6
|
@ -26,6 +26,7 @@ import cash.z.ecc.android.sdk.block.CompactBlockProcessor.WalletBalance
|
||||||
import cash.z.ecc.android.sdk.ext.*
|
import cash.z.ecc.android.sdk.ext.*
|
||||||
import cash.z.ecc.android.sdk.validate.AddressType
|
import cash.z.ecc.android.sdk.validate.AddressType
|
||||||
import cash.z.ecc.android.ui.base.BaseFragment
|
import cash.z.ecc.android.ui.base.BaseFragment
|
||||||
|
import kotlinx.android.synthetic.main.fragment_send.*
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -136,13 +137,23 @@ class SendFragment : BaseFragment<FragmentSendBinding>(),
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onAddressChanged(address: String) {
|
private fun onAddressChanged(address: String) {
|
||||||
|
var isTaddress = false
|
||||||
lifecycleScope.launchWhenResumed {
|
lifecycleScope.launchWhenResumed {
|
||||||
val validation = sendViewModel.validateAddress(address)
|
val validation = sendViewModel.validateAddress(address)
|
||||||
binding.buttonSend.isActivated = !validation.isNotValid
|
binding.buttonSend.isActivated = !validation.isNotValid
|
||||||
var type = when (validation) {
|
var type = when (validation) {
|
||||||
is AddressType.Transparent -> R.string.send_validation_address_valid_taddr to R.color.zcashGreen
|
is AddressType.Transparent -> {
|
||||||
is AddressType.Shielded -> R.string.send_validation_address_valid_zaddr to R.color.zcashGreen
|
isTaddress = true
|
||||||
is AddressType.Invalid -> R.string.send_validation_address_invalid to R.color.zcashRed
|
R.string.send_validation_address_valid_taddr to R.color.zcashGreen
|
||||||
|
}
|
||||||
|
is AddressType.Shielded -> {
|
||||||
|
isTaddress = false
|
||||||
|
R.string.send_validation_address_valid_zaddr to R.color.zcashGreen
|
||||||
|
}
|
||||||
|
is AddressType.Invalid -> {
|
||||||
|
isTaddress = false
|
||||||
|
R.string.send_validation_address_invalid to R.color.zcashRed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (address == sendViewModel.synchronizer.getAddress()) type =
|
if (address == sendViewModel.synchronizer.getAddress()) type =
|
||||||
R.string.send_validation_address_self to R.color.zcashRed
|
R.string.send_validation_address_self to R.color.zcashRed
|
||||||
|
@ -157,6 +168,19 @@ class SendFragment : BaseFragment<FragmentSendBinding>(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if Taddress, no memo can be included in TX
|
||||||
|
if(isTaddress) {
|
||||||
|
text_layout_memo.visibility = View.INVISIBLE
|
||||||
|
check_include_address.visibility = View.INVISIBLE
|
||||||
|
text_no_memo.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
}else{
|
||||||
|
text_layout_memo.visibility = View.VISIBLE
|
||||||
|
check_include_address.visibility = View.VISIBLE
|
||||||
|
text_no_memo.visibility = View.INVISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
// if we have the last used address but we're changing it, then clear the selection
|
// if we have the last used address but we're changing it, then clear the selection
|
||||||
if (binding.imageLastUsedAddressSelected.isVisible) {
|
if (binding.imageLastUsedAddressSelected.isVisible) {
|
||||||
loadLastUsedAddress().let { lastAddress ->
|
loadLastUsedAddress().let { lastAddress ->
|
||||||
|
|
|
@ -196,13 +196,13 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/send_address_hint"
|
android:hint="@string/send_address_hint"
|
||||||
android:theme="@style/Zcash.Overlay.TextInputLayout"
|
android:theme="@style/Zcash.Overlay.TextInputLayout"
|
||||||
|
android:visibility="visible"
|
||||||
app:endIconDrawable="@drawable/ic_qr_scan"
|
app:endIconDrawable="@drawable/ic_qr_scan"
|
||||||
app:endIconMode="custom"
|
app:endIconMode="custom"
|
||||||
app:helperText="Enter a valid Zcash address"
|
app:helperText="Enter a valid Zcash address"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_bias="0.08"
|
|
||||||
app:layout_constraintWidth_percent="0.84">
|
app:layout_constraintWidth_percent="0.84">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
@ -225,6 +225,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/send_memo_hint"
|
android:hint="@string/send_memo_hint"
|
||||||
android:theme="@style/Zcash.Overlay.TextInputLayout"
|
android:theme="@style/Zcash.Overlay.TextInputLayout"
|
||||||
|
android:visibility="visible"
|
||||||
app:endIconMode="clear_text"
|
app:endIconMode="clear_text"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -244,9 +245,23 @@
|
||||||
android:maxLines="3"
|
android:maxLines="3"
|
||||||
android:textColor="@color/text_light"
|
android:textColor="@color/text_light"
|
||||||
android:textColorHint="@color/text_light_dimmed"
|
android:textColorHint="@color/text_light_dimmed"
|
||||||
|
android:visibility="visible"
|
||||||
tools:text="WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" />
|
tools:text="WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_no_memo"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="To add a memo, enter a shielded address!"
|
||||||
|
android:visibility="invisible"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/space_checkbox"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/text_layout_address"
|
||||||
|
app:layout_constraintVertical_bias="1.0"
|
||||||
|
app:layout_constraintWidth_percent="0.84" />
|
||||||
|
|
||||||
<!-- <ImageView-->
|
<!-- <ImageView-->
|
||||||
<!-- android:id="@+id/clear_memo"-->
|
<!-- android:id="@+id/clear_memo"-->
|
||||||
<!-- android:layout_width="24dp"-->
|
<!-- android:layout_width="24dp"-->
|
||||||
|
|
Loading…
Reference in New Issue