Implemented accepting TAN or transferring money if enter key is pressed
This commit is contained in:
parent
95ce20b5bb
commit
4d551197f9
|
@ -5,6 +5,7 @@ import android.graphics.BitmapFactory
|
|||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.text.InputType
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -163,6 +164,14 @@ open class EnterTanDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
rootView.edtxtEnteredTan.inputType = InputType.TYPE_CLASS_NUMBER
|
||||
|
||||
rootView.edtxtEnteredTan.setOnKeyListener { _, keyCode, _ ->
|
||||
if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||
enteringTanDone(rootView.edtxtEnteredTan.text.toString())
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.dankito.banking.fints4java.android.R
|
|||
import net.dankito.banking.fints4java.android.di.BankingComponent
|
||||
import net.dankito.banking.fints4java.android.ui.adapter.BankAccountsAdapter
|
||||
import net.dankito.banking.fints4java.android.ui.adapter.presenter.RemitteePresenter
|
||||
import net.dankito.banking.fints4java.android.ui.extensions.addEnterPressedListener
|
||||
import net.dankito.banking.fints4java.android.ui.listener.ListItemSelectedListener
|
||||
import net.dankito.banking.fints4java.android.util.StandardAutocompleteCallback
|
||||
import net.dankito.banking.fints4java.android.util.StandardTextWatcher
|
||||
|
@ -127,6 +128,12 @@ open class TransferMoneyDialog : DialogFragment() {
|
|||
rootView.edtxtAmount.setOnFocusChangeListener { _, hasFocus -> if (hasFocus == false) checkIfEnteredAmountIsValid() }
|
||||
rootView.edtxtUsage.setOnFocusChangeListener { _, hasFocus -> if (hasFocus == false) checkIfEnteredUsageTextIsValid() }
|
||||
|
||||
transferMoneyIfEnterPressed(rootView.edtxtRemitteeName)
|
||||
transferMoneyIfEnterPressed(rootView.edtxtRemitteeIban)
|
||||
transferMoneyIfEnterPressed(rootView.edtxtRemitteeBic)
|
||||
transferMoneyIfEnterPressed(rootView.edtxtAmount)
|
||||
transferMoneyIfEnterPressed(rootView.edtxtUsage)
|
||||
|
||||
// fix that even in Locales using ',' as decimal separator entering ',' is not allowed (thanks dstibbe! https://stackoverflow.com/a/34256139)
|
||||
val decimalSeparator = DecimalFormatSymbols.getInstance().getDecimalSeparator()
|
||||
rootView.edtxtAmount.keyListener = DigitsKeyListener.getInstance("0123456789$decimalSeparator")
|
||||
|
@ -136,6 +143,20 @@ open class TransferMoneyDialog : DialogFragment() {
|
|||
rootView.btnTransferMoney.setOnClickListener { transferMoney() }
|
||||
}
|
||||
|
||||
private fun transferMoneyIfEnterPressed(editText: EditText) {
|
||||
editText.addEnterPressedListener {
|
||||
if (isRequiredDataEntered()) {
|
||||
transferMoney()
|
||||
|
||||
return@addEnterPressedListener true
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun isRequiredDataEntered() = btnTransferMoney.isEnabled
|
||||
|
||||
private fun initRemitteeAutocompletion(edtxtRemitteeName: EditText) {
|
||||
val autocompleteCallback = StandardAutocompleteCallback<Remittee> { _, item ->
|
||||
remitteeSelected(item)
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package net.dankito.banking.fints4java.android.ui.extensions
|
||||
|
||||
import android.view.KeyEvent
|
||||
import android.widget.EditText
|
||||
|
||||
|
||||
fun EditText.addEnterPressedListener(enterPressed: () -> Boolean) {
|
||||
this.setOnKeyListener { _, keyCode, _ ->
|
||||
if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||
return@setOnKeyListener enterPressed()
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue