Merge pull request #175 from CrystalPony/master

Fix the cursor position resetting to 0 when there's a space on either side of the address field
This commit is contained in:
Kevin Gorham 2020-06-28 04:14:17 -04:00 committed by GitHub
commit e9c166a47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -69,10 +69,13 @@ class SendAddressFragment : BaseFragment<FragmentSendAddressBinding>(),
binding.inputZcashAddress.apply {
doAfterTextChanged {
val trim = text.toString().trim()
val textStr = text.toString()
val trim = textStr.trim()
if (text.toString() != trim) {
binding.inputZcashAddress
.findViewById<EditText>(R.id.input_zcash_address).setText(trim)
val textView = binding.inputZcashAddress.findViewById<EditText>(R.id.input_zcash_address)
val cursorPosition = textView.selectionEnd;
textView.setText(trim)
textView.setSelection(cursorPosition-(textStr.length-trim.length))
}
onAddressChanged(trim)
}