diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/adapter/BankAccountsAdapter.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/adapter/BankAccountsAdapter.kt new file mode 100644 index 00000000..cce7abc2 --- /dev/null +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/adapter/BankAccountsAdapter.kt @@ -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) : ListAdapter(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 + } + +} \ No newline at end of file diff --git a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/BankTransferDialog.kt b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/BankTransferDialog.kt index 6308261d..c4532b96 100644 --- a/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/BankTransferDialog.kt +++ b/fints4javaAndroidApp/src/main/java/net/dankito/banking/fints4java/android/ui/dialogs/BankTransferDialog.kt @@ -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) diff --git a/fints4javaAndroidApp/src/main/res/layout/dialog_bank_transfer.xml b/fints4javaAndroidApp/src/main/res/layout/dialog_bank_transfer.xml index 42559810..a0f0cf36 100644 --- a/fints4javaAndroidApp/src/main/res/layout/dialog_bank_transfer.xml +++ b/fints4javaAndroidApp/src/main/res/layout/dialog_bank_transfer.xml @@ -6,6 +6,35 @@ android:padding="@dimen/dialog_bank_transfer_padding" > + + + + + + + + + \ No newline at end of file diff --git a/fints4javaAndroidApp/src/main/res/values/dimens.xml b/fints4javaAndroidApp/src/main/res/values/dimens.xml index 70c78f56..9499593e 100644 --- a/fints4javaAndroidApp/src/main/res/values/dimens.xml +++ b/fints4javaAndroidApp/src/main/res/values/dimens.xml @@ -36,9 +36,14 @@ 4dp 40dp + 4dp + 12dp 50dp 120dp + 4dp + 13sp + 40dp 40dp diff --git a/fints4javaAndroidApp/src/main/res/values/strings.xml b/fints4javaAndroidApp/src/main/res/values/strings.xml index 09c93272..66ec35da 100644 --- a/fints4javaAndroidApp/src/main/res/values/strings.xml +++ b/fints4javaAndroidApp/src/main/res/values/strings.xml @@ -41,6 +41,7 @@ \n\nWould you like to fetch all account transactions now? If so entering a TAN is required. + Account: Name: IBAN: BIC: