Memo improvements.

- Added ability to clear the memo field
- Fixed the memo UI so the wording makes more sense and responds to checkbox
- Changed 'Send without memo' to 'Omit memo'
This commit is contained in:
Kevin Gorham 2020-01-31 11:28:55 -05:00
parent cccfbe2271
commit 61ec3bed66
No known key found for this signature in database
GPG Key ID: CCA55602DF49FC38
3 changed files with 90 additions and 53 deletions

View File

@ -4,13 +4,11 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.inputmethod.EditorInfo
import androidx.core.widget.doAfterTextChanged
import cash.z.ecc.android.R
import cash.z.ecc.android.databinding.FragmentSendMemoBinding
import cash.z.ecc.android.di.viewmodel.activityViewModel
import cash.z.ecc.android.ext.gone
import cash.z.ecc.android.ext.goneIf
import cash.z.ecc.android.ext.onClickNavTo
import cash.z.ecc.android.ext.toColoredSpan
import cash.z.ecc.android.ext.*
import cash.z.ecc.android.ui.base.BaseFragment
class SendMemoFragment : BaseFragment<FragmentSendMemoBinding>() {
@ -28,6 +26,10 @@ class SendMemoFragment : BaseFragment<FragmentSendMemoBinding>() {
binding.buttonSkip.setOnClickListener {
onBottomButton()
}
binding.clearMemo.setOnClickListener {
onClearMemo()
}
R.id.action_nav_send_memo_to_nav_send_address.let {
binding.backButtonHitArea.onClickNavTo(it)
onBackPressNavTo(it)
@ -37,14 +39,15 @@ class SendMemoFragment : BaseFragment<FragmentSendMemoBinding>() {
onIncludeMemo(binding.checkIncludeAddress.isChecked)
}
binding.inputMemo.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
binding.inputMemo.let { memo ->
memo.onEditorActionDone {
onTopButton()
true
} else {
false
}
memo.doAfterTextChanged {
binding.clearMemo.goneIf(memo.text.isEmpty())
}
}
sendViewModel.afterInitFromAddress {
binding.textIncludedAddress.text = "sent from ${sendViewModel.fromAddress}"
}
@ -54,15 +57,20 @@ class SendMemoFragment : BaseFragment<FragmentSendMemoBinding>() {
applyModel()
}
private fun onClearMemo() {
binding.inputMemo.setText("")
}
private fun applyModel() {
sendViewModel.isShielded.let { isShielded ->
binding.groupShielded.goneIf(!isShielded)
binding.groupTransparent.goneIf(isShielded)
binding.textIncludedAddress.goneIf(!sendViewModel.includeFromAddress)
if (isShielded) {
binding.inputMemo.setText(sendViewModel.memo)
binding.checkIncludeAddress.isChecked = sendViewModel.includeFromAddress
binding.buttonNext.text = "ADD MEMO"
binding.buttonSkip.text = "SEND WITHOUT MEMO"
binding.buttonSkip.text = "OMIT MEMO"
} else {
binding.buttonNext.text = "WAIT, GO BACK"
binding.buttonSkip.text = "PROCEED"
@ -74,7 +82,11 @@ class SendMemoFragment : BaseFragment<FragmentSendMemoBinding>() {
private fun onIncludeMemo(checked: Boolean) {
binding.textIncludedAddress.goneIf(!checked)
sendViewModel.includeFromAddress = checked
if (checked) binding.inputMemo.setHint("") else binding.inputMemo.setHint("Add a memo here")
binding.textInfoShielded.text = if (checked) {
getString(R.string.send_memo_included_message)
} else {
getString(R.string.send_memo_excluded_message)
}
}
private fun onTopButton() {

View File

@ -33,33 +33,57 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.045" />
<EditText
android:id="@+id/input_memo"
<View
android:id="@+id/background_memo"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/background_banner"
android:elevation="6dp"
android:gravity="top"
android:hint="Add a memo here"
android:maxLines="3"
android:imeActionLabel="add memo"
android:imeOptions="actionDone"
android:inputType="textImeMultiLine"
android:paddingBottom="8dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
android:textColor="@color/text_light"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.24"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.185"
app:layout_constraintWidth_percent="0.8"
tools:text="This is my memo" />
app:layout_constraintWidth_percent="0.8" />
<EditText
android:id="@+id/input_memo"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:elevation="6dp"
android:gravity="top"
android:scrollbars="vertical"
android:scrollbarStyle="outsideOverlay"
tools:text="this\nis\nsome\ntext\nthat\nspans\nmany\nlines"
android:hint="Add a memo here"
android:imeActionLabel="add memo"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:maxLength="512"
android:paddingBottom="8dp"
android:paddingEnd="32dp"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
android:textColor="@color/text_light"
app:layout_constraintBottom_toTopOf="@id/text_included_address"
app:layout_constraintEnd_toEndOf="@id/background_memo"
app:layout_constraintStart_toStartOf="@id/background_memo"
app:layout_constraintTop_toTopOf="@id/background_memo" />
<ImageView
android:id="@+id/clear_memo"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:elevation="6dp"
android:src="@drawable/ic_close_black_24dp"
android:tint="@color/text_light"
app:layout_constraintEnd_toEndOf="@id/background_memo"
app:layout_constraintTop_toTopOf="@id/background_memo" />
<TextView
android:id="@+id/text_included_address"
@ -70,9 +94,9 @@
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:textColor="@color/text_light_dimmed"
app:layout_constraintBottom_toBottomOf="@id/input_memo"
app:layout_constraintEnd_toEndOf="@id/input_memo"
app:layout_constraintStart_toStartOf="@id/input_memo"
app:layout_constraintBottom_toBottomOf="@id/background_memo"
app:layout_constraintEnd_toEndOf="@id/background_memo"
app:layout_constraintStart_toStartOf="@id/background_memo"
tools:text="sent from z23lk4jjl2k3jl43kkj542l3kl4hj2l3k1j41l2kjk423lkj423lklhk2jrhiuhrh2j4hh2hkj23hkj4" />
<View
@ -94,20 +118,18 @@
android:layout_marginTop="16dp"
android:padding="0dp"
android:text="Include your sending address in memo"
app:layout_constraintStart_toStartOf="@+id/input_memo"
app:layout_constraintTop_toBottomOf="@+id/input_memo" />
app:layout_constraintStart_toStartOf="@+id/background_memo"
app:layout_constraintTop_toBottomOf="@+id/background_memo" />
<TextView
android:id="@+id/text_info_shielded"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="Your transaction is shielded and your address is unavailable to recipient"
app:layout_constraintEnd_toEndOf="@id/input_memo"
app:layout_constraintStart_toStartOf="@id/input_memo"
android:text="Your transaction is shielded and your address is not available to recipient"
app:layout_constraintEnd_toEndOf="@id/background_memo"
app:layout_constraintStart_toStartOf="@id/background_memo"
app:layout_constraintTop_toBottomOf="@id/check_include_address" />
<ImageView
@ -128,48 +150,48 @@
android:id="@+id/sad_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="16dp"
android:layout_marginTop="16dp"
android:drawablePadding="16dp"
android:drawableTint="@color/text_light_dimmed"
android:gravity="center"
android:text="You are going to make the zebra sad."
android:textColor="@color/text_light"
android:textSize="18dp"
android:gravity="center"
app:layout_constraintBottom_toTopOf="@id/sad_description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sad_icon"
app:layout_constraintBottom_toTopOf="@id/sad_description"
app:layout_constraintVertical_chainStyle="packed"/>
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/sad_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:drawablePadding="16dp"
android:drawableTint="@color/text_light_dimmed"
android:gravity="center"
android:text="Heads up! You are sending to a transparent address, which reduces your privacy and does not support memos."
android:textColor="@color/text_light"
android:textSize="18dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="@id/sad_checkbox"
app:layout_constraintEnd_toEndOf="@id/sad_title"
app:layout_constraintHeight_percent="0.2"
app:layout_constraintStart_toStartOf="@id/sad_title"
app:layout_constraintTop_toBottomOf="@id/sad_title"
app:layout_constraintBottom_toTopOf="@id/sad_checkbox"
app:layout_constraintVertical_bias="0.5263" />
<CheckBox
android:id="@+id/sad_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Don't show this again"
android:checked="true"
app:layout_constraintStart_toStartOf="parent"
android:text="Don't show this again"
app:layout_constraintBottom_toTopOf="@id/button_next"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/sad_description"
app:layout_constraintBottom_toTopOf="@id/button_next"/>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sad_description" />
<com.google.android.material.button.MaterialButton
android:id="@+id/button_next"
@ -177,14 +199,14 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:padding="12dp"
android:text="Add Memo"
android:textColor="@color/text_dark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.8"
app:layout_constraintWidth_percent="0.68" />
app:layout_constraintWidth_percent="0.68"
tools:text="Add Memo" />
<com.google.android.material.button.MaterialButton
android:id="@+id/button_skip"
@ -192,11 +214,11 @@
android:layout_height="wrap_content"
style="@style/Zcash.Button.OutlinedButton"
android:padding="12dp"
android:text="Send without memo"
android:textColor="@color/text_light"
app:layout_constraintEnd_toEndOf="@id/button_next"
app:layout_constraintStart_toStartOf="@id/button_next"
app:layout_constraintTop_toBottomOf="@id/button_next" />
app:layout_constraintTop_toBottomOf="@id/button_next"
tools:text="Omit memo" />
<androidx.constraintlayout.widget.Group
android:id="@+id/group_transparent"
@ -208,6 +230,6 @@
android:id="@+id/group_shielded"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="input_memo, check_include_address, text_included_address, text_info_shielded"
app:constraint_referenced_ids="background_memo, input_memo, check_include_address, text_info_shielded"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -8,4 +8,7 @@
<!-- Send Flow -->
<string name="send_hint_input_zcash_address">Enter a shielded Zcash address</string>
<string name="send_hint_input_zcash_amount">Enter an amount to send</string>
<string name="send_memo_excluded_message">Your transaction is shielded and your address is not available to the recipient</string>
<string name="send_memo_included_message">Your transaction is shielded but your address will be sent to the recipient via the memo</string>
</resources>