From 427db22ef18035054213bb2f1122507351f9fd61 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 19 Nov 2020 21:24:25 +0100 Subject: [PATCH] Implemented AccountTransactionDetailsDialog --- .../adapter/AccountTransactionAdapter.kt | 6 + .../AccountTransactionDetailsDialog.kt | 80 +++++++++ .../ui/android/views/FormLabelledValue.kt | 8 + .../ui/android/views/FormSectionTitle.kt | 10 ++ .../dialog_account_transaction_details.xml | 156 ++++++++++++++++++ .../src/main/res/values-de/strings.xml | 26 ++- .../src/main/res/values/strings.xml | 27 ++- .../de.lproj/Localizable.strings | 2 +- 8 files changed, 306 insertions(+), 9 deletions(-) create mode 100644 ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AccountTransactionDetailsDialog.kt create mode 100644 ui/BankingAndroidApp/src/main/res/layout/dialog_account_transaction_details.xml diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/AccountTransactionAdapter.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/AccountTransactionAdapter.kt index e8c61bef..fcf92c2c 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/AccountTransactionAdapter.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/AccountTransactionAdapter.kt @@ -2,8 +2,10 @@ package net.dankito.banking.ui.android.adapter import android.view.ContextMenu import android.view.View +import androidx.appcompat.app.AppCompatActivity import net.dankito.banking.ui.android.R import net.dankito.banking.ui.android.adapter.viewholder.AccountTransactionViewHolder +import net.dankito.banking.ui.android.dialogs.AccountTransactionDetailsDialog import net.dankito.banking.ui.android.extensions.setIcon import net.dankito.banking.ui.android.extensions.showAmount import net.dankito.banking.ui.model.IAccountTransaction @@ -49,6 +51,10 @@ open class AccountTransactionAdapter(protected val presenter: BankingPresenter) // TODO: if bank icon isn't set: Show default icon? show at least an empty space to that amount and date don't shift up causing an inconsistent view? viewHolder.imgvwBankIcon.hide() } + + viewHolder.itemView.setOnClickListener { + AccountTransactionDetailsDialog().show(item, viewHolder.itemView.context as AppCompatActivity) + } } diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AccountTransactionDetailsDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AccountTransactionDetailsDialog.kt new file mode 100644 index 00000000..4edff1b1 --- /dev/null +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AccountTransactionDetailsDialog.kt @@ -0,0 +1,80 @@ +package net.dankito.banking.ui.android.dialogs + +import android.os.Bundle +import android.view.* +import androidx.fragment.app.FragmentActivity +import kotlinx.android.synthetic.main.dialog_account_transaction_details.view.* +import net.dankito.banking.ui.android.R +import net.dankito.banking.ui.android.dialogs.settings.SettingsDialogBase +import net.dankito.banking.ui.android.views.FormLabelledValue +import net.dankito.banking.ui.model.IAccountTransaction +import net.dankito.utils.multiplatform.BigDecimal + + +open class AccountTransactionDetailsDialog : SettingsDialogBase() { + + companion object { + const val DialogTag = "AccountTransactionDetailsDialog" + } + + + protected lateinit var transaction: IAccountTransaction + + + + fun show(transaction: IAccountTransaction, activity: FragmentActivity) { + this.transaction = transaction + + show(activity, DialogTag) + } + + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + val rootView = inflater.inflate(R.layout.dialog_account_transaction_details, container, false) + + setupUI(rootView) + + return rootView + } + + protected open fun setupUI(rootView: View) { + rootView.apply { + toolbar.apply { + setupToolbar(this, context.getString(R.string.dialog_account_transaction_details_title), false) + } + + sender_or_recipient_section_title.setTitle(if (transaction.amount.isPositive) R.string.dialog_account_transaction_details_sender else R.string.dialog_account_transaction_details_recipient) + lvlOtherPartyName.value = transaction.otherPartyName ?: "" + lvlOtherPartyAccountId.value = transaction.otherPartyAccountId ?: "" + lvlOtherPartyBankCode.value = transaction.otherPartyBankCode ?: "" + + lvlAmount.showAmount(presenter, transaction.amount, transaction.currency) + lvlReference.value = transaction.reference + + lvlBookingText.value = transaction.bookingText ?: "" + lvlBookingDate.value = presenter.formatToMediumDate(transaction.bookingDate) + lvlValueDate.value = presenter.formatToMediumDate(transaction.valueDate) + + showAmountIfSet(lvlOpeningBalance, transaction.openingBalance, transaction.account.currency) + showAmountIfSet(lvlClosingBalance, transaction.closingBalance, transaction.account.currency) + } + } + + protected open fun showAmountIfSet(labelledValue: FormLabelledValue, amount: BigDecimal?, currencyCode: String) { + if (amount != null) { + labelledValue.showAmount(presenter, amount, currencyCode) + } + else { + labelledValue.visibility = View.GONE + } + } + + + override val hasUnsavedChanges: Boolean + get() = false + + override fun saveChanges() { + + } + +} \ No newline at end of file diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt index 4ca2543f..c50568e5 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormLabelledValue.kt @@ -8,7 +8,10 @@ import android.widget.LinearLayout import android.widget.TextView import kotlinx.android.synthetic.main.view_form_labelled_value.view.* import net.dankito.banking.ui.android.R +import net.dankito.banking.ui.android.extensions.setTextColorForAmount import net.dankito.utils.android.extensions.setVisibility +import net.dankito.banking.ui.presenter.BankingPresenter +import net.dankito.utils.multiplatform.BigDecimal open class FormLabelledValue @JvmOverloads constructor( @@ -65,4 +68,9 @@ open class FormLabelledValue @JvmOverloads constructor( this.value = value ?: "" } + open fun showAmount(presenter: BankingPresenter, amount: BigDecimal, currencyIsoCode: String? = null) { + value = presenter.formatAmount(amount, currencyIsoCode) + txtValue.setTextColorForAmount(amount) + } + } \ No newline at end of file diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormSectionTitle.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormSectionTitle.kt index 1dcf1a2b..6cc0eb3d 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormSectionTitle.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/views/FormSectionTitle.kt @@ -4,6 +4,7 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.widget.LinearLayout +import androidx.annotation.StringRes import kotlinx.android.synthetic.main.view_form_section_title.view.* import net.dankito.banking.ui.android.R @@ -37,4 +38,13 @@ open class FormSectionTitle @JvmOverloads constructor( } } + + open var title: CharSequence + get() = txtvwSectionTitle.text + set(value) = txtvwSectionTitle.setText(value) + + open fun setTitle(@StringRes titleResId: Int) { + this.title = context.getString(titleResId) + } + } \ No newline at end of file diff --git a/ui/BankingAndroidApp/src/main/res/layout/dialog_account_transaction_details.xml b/ui/BankingAndroidApp/src/main/res/layout/dialog_account_transaction_details.xml new file mode 100644 index 00000000..7f8ae8ed --- /dev/null +++ b/ui/BankingAndroidApp/src/main/res/layout/dialog_account_transaction_details.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ui/BankingAndroidApp/src/main/res/values-de/strings.xml b/ui/BankingAndroidApp/src/main/res/values-de/strings.xml index c25d337a..3acc2662 100644 --- a/ui/BankingAndroidApp/src/main/res/values-de/strings.xml +++ b/ui/BankingAndroidApp/src/main/res/values-de/strings.xml @@ -25,12 +25,24 @@ Login Name Passwort + Konto Konten Bankzugänge + Name + Bankleitzahl BIC IBAN + Betrag + Verwendungszweck + + Buchungstext + Buchungsdatum + Wertstellungsdatum + Taganfangssaldo + Tagendsaldo + Kontoinhaber FinTS Server @@ -67,6 +79,12 @@ Um QR-Codes scannen zu können wird der Zugriff auf die Kamera benötigt. + + Bank (Suche mit Name, Bankleitzahl oder Ort): + Hinzufügen + %s untersützt FinTS 3.0 nicht und kann deshalb leider mit dieser App nicht verwendet werden. + Konto konnte nicht hinzugefügt werden.\n\nFehlermeldung Ihrer Bank:\n\n%s + Umsätze Umsätze aktualisieren @@ -88,10 +106,10 @@ \n\nMöchten Sie hingegen den Button für dieses Konto nicht mehr angezeigt bekommen, klicken Sie auf das \'x\' rechts. Der Button wird dann immer noch am Ende der Umsatzlist angezeigt, falls Sie die älteren Umsätze später doch noch abrufen möchten. - Bank (Suche mit Name, Bankleitzahl oder Ort): - Hinzufügen - %s untersützt FinTS 3.0 nicht und kann deshalb leider mit dieser App nicht verwendet werden. - Konto konnte nicht hinzugefügt werden.\n\nFehlermeldung Ihrer Bank:\n\n%s + Umsatzdetails + Zahlender + Empfänger + Konto: Name: diff --git a/ui/BankingAndroidApp/src/main/res/values/strings.xml b/ui/BankingAndroidApp/src/main/res/values/strings.xml index f16a5e01..cc7a3b3d 100644 --- a/ui/BankingAndroidApp/src/main/res/values/strings.xml +++ b/ui/BankingAndroidApp/src/main/res/values/strings.xml @@ -25,12 +25,24 @@ Login name Password + Account Accounts Bank credentials + Name + Bank code BIC IBAN + Amount + Reference + + Booking text + Booking date + Value date + Day opening balance + Day closing balance + Customer name FinTS server @@ -67,6 +79,13 @@ To scan QR-Codes permission to access camera is required. + + Bank (search by name, bank code or city): + Add + %s does not support FinTS 3.0 and can therefore unfortunately not be used with this app. + Could not add account.\n\nError message from your bank:\n\n%s + + Home Update transactions @@ -88,10 +107,10 @@ \n\nIf you no longer wish to see this button for this account, click on the \'x\' on the right. The button will still be displayed at the end of the list of transactions, in case you want to retrieve the earlier transactions later. - Bank (search by name, bank code or city): - Add - %s does not support FinTS 3.0 and can therefore unfortunately not be used with this app. - Could not add account.\n\nError message from your bank:\n\n%s + Transaction details + Sender + Recipient + Account: Name: diff --git a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings index f858d7e1..4f5d7442 100644 --- a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings @@ -124,7 +124,7 @@ "Booking date" = "Buchungsdatum"; "Value date" = "Wertstellungsdatum"; "Account day opening balance" = "Taganfangssaldo"; -"Account day closing balance" = "Tagschlusssaldo"; +"Account day closing balance" = "Tagendsaldo";