Implemented selecting bank account in BankTransferDialog
This commit is contained in:
parent
6e712316ab
commit
dc5e405833
|
@ -0,0 +1,34 @@
|
|||
package net.dankito.banking.fints4java.android.ui.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import kotlinx.android.synthetic.main.list_item_bank_account.view.*
|
||||
import net.dankito.banking.fints4java.android.R
|
||||
import net.dankito.banking.ui.model.BankAccount
|
||||
import net.dankito.utils.android.ui.adapter.ListAdapter
|
||||
|
||||
|
||||
open class BankAccountsAdapter(bankAccounts: List<BankAccount>) : ListAdapter<BankAccount>(bankAccounts) {
|
||||
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View? {
|
||||
|
||||
val item = getItem(position)
|
||||
|
||||
val inflater = parent?.context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater
|
||||
val view = convertView ?: inflater?.inflate(R.layout.list_item_bank_account, parent, false)
|
||||
|
||||
view?.let {
|
||||
var displayName = "${item.account.bank.name} ${item.identifier}"
|
||||
item.subAccountNumber?.let {
|
||||
displayName += " ($it)"
|
||||
}
|
||||
|
||||
view.txtBankAccountDisplayName.text = displayName
|
||||
}
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,8 @@ import kotlinx.android.synthetic.main.dialog_bank_transfer.*
|
|||
import kotlinx.android.synthetic.main.dialog_bank_transfer.view.*
|
||||
import net.dankito.banking.fints4java.android.R
|
||||
import net.dankito.banking.fints4java.android.ui.MainWindowPresenter
|
||||
import net.dankito.banking.fints4java.android.ui.adapter.BankAccountsAdapter
|
||||
import net.dankito.banking.fints4java.android.ui.listener.ListItemSelectedListener
|
||||
import net.dankito.banking.ui.model.BankAccount
|
||||
import net.dankito.banking.ui.model.parameters.TransferMoneyData
|
||||
import net.dankito.banking.ui.model.responses.BankingClientResponse
|
||||
|
@ -31,6 +33,8 @@ open class BankTransferDialog : DialogFragment() {
|
|||
|
||||
protected lateinit var presenter: MainWindowPresenter
|
||||
|
||||
protected var preselectedBankAccount: BankAccount? = null
|
||||
|
||||
protected lateinit var bankAccount: BankAccount
|
||||
|
||||
protected var preselectedValues: TransferMoneyData? = null
|
||||
|
@ -38,13 +42,13 @@ open class BankTransferDialog : DialogFragment() {
|
|||
protected val sepaMessageCreator: ISepaMessageCreator = SepaMessageCreator()
|
||||
|
||||
|
||||
open fun show(activity: AppCompatActivity, presenter: MainWindowPresenter, bankAccount: BankAccount, fullscreen: Boolean = false) {
|
||||
show(activity, presenter, bankAccount, null, fullscreen)
|
||||
open fun show(activity: AppCompatActivity, presenter: MainWindowPresenter, preselectedBankAccount: BankAccount?, fullscreen: Boolean = false) {
|
||||
show(activity, presenter, preselectedBankAccount, null, fullscreen)
|
||||
}
|
||||
|
||||
open fun show(activity: AppCompatActivity, presenter: MainWindowPresenter, bankAccount: BankAccount, preselectedValues: TransferMoneyData?, fullscreen: Boolean = false) {
|
||||
open fun show(activity: AppCompatActivity, presenter: MainWindowPresenter, preselectedBankAccount: BankAccount?, preselectedValues: TransferMoneyData?, fullscreen: Boolean = false) {
|
||||
this.presenter = presenter
|
||||
this.bankAccount = bankAccount
|
||||
this.preselectedBankAccount = preselectedBankAccount
|
||||
this.preselectedValues = preselectedValues
|
||||
|
||||
val style = if(fullscreen) R.style.FullscreenDialogWithStatusBar else R.style.Dialog
|
||||
|
@ -65,6 +69,19 @@ open class BankTransferDialog : DialogFragment() {
|
|||
protected open fun setupUI(rootView: View) {
|
||||
setPreselectedValues(rootView)
|
||||
|
||||
val allBankAccounts = presenter.accounts.flatMap { it.bankAccounts }
|
||||
bankAccount = preselectedBankAccount ?: allBankAccounts.first()
|
||||
|
||||
if (allBankAccounts.size > 1) {
|
||||
rootView.lytSelectBankAccount.visibility = View.VISIBLE
|
||||
|
||||
val adapter = BankAccountsAdapter(allBankAccounts)
|
||||
rootView.spnBankAccounts.adapter = adapter
|
||||
rootView.spnBankAccounts.onItemSelectedListener = ListItemSelectedListener(adapter) { selectedBankAccount ->
|
||||
this.bankAccount = selectedBankAccount
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add autocompletion by searching for name in account entries
|
||||
rootView.edtxtRemitteeName.addTextChangedListener(otherEditTextChangedWatcher)
|
||||
|
||||
|
|
|
@ -6,6 +6,35 @@
|
|||
android:padding="@dimen/dialog_bank_transfer_padding"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/lytSelectBankAccount"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dialog_bank_transfer_input_fields_height"
|
||||
android:layout_marginBottom="@dimen/dialog_bank_transfer_bank_accounts_margin_bottom"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="gone"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/dialog_bank_transfer_account"
|
||||
android:layout_marginRight="@dimen/dialog_bank_transfer_label_margin_right"
|
||||
android:layout_marginEnd="@dimen/dialog_bank_transfer_label_margin_right"
|
||||
android:gravity="center_vertical"
|
||||
/>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spnBankAccounts"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/txtBankAccountDisplayName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
style="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textSize="@dimen/list_item_bank_account_text_size"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:padding="@dimen/list_item_bank_account_padding"
|
||||
/>
|
|
@ -36,9 +36,14 @@
|
|||
|
||||
<dimen name="dialog_bank_transfer_padding">4dp</dimen>
|
||||
<dimen name="dialog_bank_transfer_input_fields_height">40dp</dimen>
|
||||
<dimen name="dialog_bank_transfer_label_margin_right">4dp</dimen>
|
||||
<dimen name="dialog_bank_transfer_bank_accounts_margin_bottom">12dp</dimen>
|
||||
<dimen name="dialog_bank_transfer_autocomplete_fields_height">50dp</dimen>
|
||||
<dimen name="dialog_bank_transfer_buttons_width">120dp</dimen>
|
||||
|
||||
<dimen name="list_item_bank_account_padding">4dp</dimen>
|
||||
<dimen name="list_item_bank_account_text_size">13sp</dimen>
|
||||
|
||||
<dimen name="view_tan_image_controls_buttons_height">40dp</dimen>
|
||||
<dimen name="view_tan_image_controls_buttons_width">40dp</dimen>
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
\n\nWould you like to fetch all account transactions now? If so entering a TAN is required.
|
||||
</string>
|
||||
|
||||
<string name="dialog_bank_transfer_account">Account:</string>
|
||||
<string name="dialog_bank_transfer_remittee_name">Name:</string>
|
||||
<string name="dialog_bank_transfer_remittee_iban">IBAN:</string>
|
||||
<string name="dialog_bank_transfer_remittee_bic">BIC:</string>
|
||||
|
|
Loading…
Reference in New Issue