diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankAccountSettingsDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankAccountSettingsDialog.kt index b090ebed..94332f01 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankAccountSettingsDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/settings/BankAccountSettingsDialog.kt @@ -1,5 +1,6 @@ package net.dankito.banking.ui.android.dialogs.settings +import android.content.Intent import android.os.Bundle import android.view.* import androidx.appcompat.app.AppCompatActivity @@ -31,41 +32,63 @@ open class BankAccountSettingsDialog : SettingsDialogBase() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - val rootView = inflater.inflate(R.layout.dialog_bank_account_settings, container, false) - - setupUI(rootView) - - return rootView + return inflater.inflate(R.layout.dialog_bank_account_settings, container, false) } - protected open fun setupUI(rootView: View) { - rootView.apply { - toolbar.apply { - setupToolbar(this, account.displayName) - } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) - edtxtBankAccountName.text = account.displayName - - swtchHideAccount.setOnCheckedChangeListener { _, hideAccount -> swtchUpdateAccountAutomatically.isEnabled = hideAccount == false } - - swtchHideAccount.isChecked = account.hideAccount - swtchUpdateAccountAutomatically.isChecked = account.updateAccountAutomatically - - lvlAccountHolderName.value = account.accountHolderName - lvlAccountIdentifier.value = account.identifier - lvlSubAccountNumber.setValueAndVisibilityIfValueIsSet(account.subAccountNumber) - lvlIban.setValueAndVisibilityIfValueIsSet(account.iban) - lvlAccountType.value = account.type.toString() // TODO: translate - - val context = rootView.context - val accountFeaturesItems = listOf( - CheckableValueAdapterItem(account.supportsRetrievingBalance, context, R.string.dialog_bank_account_settings_account_features_supports_retrieving_balance), - CheckableValueAdapterItem(account.supportsRetrievingAccountTransactions, context, R.string.dialog_bank_account_settings_account_features_supports_retrieving_account_transactions), - CheckableValueAdapterItem(account.supportsTransferringMoney, context, R.string.dialog_bank_account_settings_account_features_supports_money_transfer), - CheckableValueAdapterItem(account.supportsRealTimeTransfer, context, R.string.dialog_bank_account_settings_account_features_supports_real_time_transfer) - ) - FastAdapterRecyclerView(rootView.rcyAccountFeatures, accountFeaturesItems) + toolbar.apply { + setupToolbar(this, account.displayName) } + + edtxtBankAccountName.text = account.displayName + + swtchHideAccount.setOnCheckedChangeListener { _, hideAccount -> swtchUpdateAccountAutomatically.isEnabled = hideAccount == false } + + swtchHideAccount.isChecked = account.hideAccount + swtchUpdateAccountAutomatically.isChecked = account.updateAccountAutomatically + + btnShareAccountData.setOnClickListener { shareAccountData() } + + lvlAccountHolderName.value = account.accountHolderName + lvlAccountIdentifier.value = account.identifier + lvlSubAccountNumber.setValueAndVisibilityIfValueIsSet(account.subAccountNumber) + lvlIban.setValueAndVisibilityIfValueIsSet(account.iban) + lvlAccountType.value = account.type.toString() // TODO: translate + + val context = view.context + val accountFeaturesItems = listOf( + CheckableValueAdapterItem(account.supportsRetrievingBalance, context, R.string.dialog_bank_account_settings_account_features_supports_retrieving_balance), + CheckableValueAdapterItem(account.supportsRetrievingAccountTransactions, context, R.string.dialog_bank_account_settings_account_features_supports_retrieving_account_transactions), + CheckableValueAdapterItem(account.supportsTransferringMoney, context, R.string.dialog_bank_account_settings_account_features_supports_money_transfer), + CheckableValueAdapterItem(account.supportsRealTimeTransfer, context, R.string.dialog_bank_account_settings_account_features_supports_real_time_transfer) + ) + FastAdapterRecyclerView(view.rcyAccountFeatures, accountFeaturesItems) + } + + + protected open fun shareAccountData() { + val accountData = StringBuilder(account.accountHolderName + "\n" + account.bank.bankName) + + account.iban?.let { iban -> + accountData.append("\n" + getString(R.string.share_account_data_iban, iban)) + } + + accountData.append("\n" + getString(R.string.share_account_data_bic, account.bank.bic)) + accountData.append("\n" + getString(R.string.share_account_data_bank_code, account.bank.bankCode)) + accountData.append("\n" + getString(R.string.share_account_data_account_number, account.identifier)) + + + val sendIntent: Intent = Intent().apply { + action = Intent.ACTION_SEND + putExtra(Intent.EXTRA_TEXT, accountData.toString()) + type = "text/plain" + } + + val shareIntent = Intent.createChooser(sendIntent, null) + startActivity(shareIntent) + } diff --git a/ui/BankingAndroidApp/src/main/res/drawable/ic_baseline_share_24.xml b/ui/BankingAndroidApp/src/main/res/drawable/ic_baseline_share_24.xml new file mode 100644 index 00000000..2f13bb3e --- /dev/null +++ b/ui/BankingAndroidApp/src/main/res/drawable/ic_baseline_share_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/ui/BankingAndroidApp/src/main/res/layout/dialog_bank_account_settings.xml b/ui/BankingAndroidApp/src/main/res/layout/dialog_bank_account_settings.xml index 44bccbe0..7698d993 100644 --- a/ui/BankingAndroidApp/src/main/res/layout/dialog_bank_account_settings.xml +++ b/ui/BankingAndroidApp/src/main/res/layout/dialog_bank_account_settings.xml @@ -92,11 +92,35 @@ android:layout_marginTop="@dimen/form_section_extra_margin_top" > - + android:layout_marginTop="@dimen/form_section_extra_margin_top" + > + + + + + + Überweisen Echtzeitüberweisung + IBAN %S + BIC %S + Bankleitzahl %S + Kontonumber %S + Nicht gespeicherte Änderungen Es wurden nicht alle Änderungen gespeichert. Sind Sie sich sicher, dass Sie sie verwerfen möchten?\n\n(TODO: Oder einfach: Änderungen verwerfen?) diff --git a/ui/BankingAndroidApp/src/main/res/values/dimens.xml b/ui/BankingAndroidApp/src/main/res/values/dimens.xml index 04a05c0e..ab9c7010 100644 --- a/ui/BankingAndroidApp/src/main/res/values/dimens.xml +++ b/ui/BankingAndroidApp/src/main/res/values/dimens.xml @@ -202,6 +202,7 @@ 2dp 16sp + 30dp 120dp diff --git a/ui/BankingAndroidApp/src/main/res/values/strings.xml b/ui/BankingAndroidApp/src/main/res/values/strings.xml index 110f8aed..3600bd08 100644 --- a/ui/BankingAndroidApp/src/main/res/values/strings.xml +++ b/ui/BankingAndroidApp/src/main/res/values/strings.xml @@ -151,6 +151,11 @@ Money transfer Real-time transfer + IBAN %S + BIC %S + Bank code %S + Account number %S + Unsaved changed Changed data hasn\'t been saved. Are you sure you want to discard them?\n\n(TODO: Oder einfach: Discard changes?) diff --git a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings index d1c3d581..591d8417 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings @@ -195,6 +195,11 @@ Unfortunately, Bankmeister cannot know whether a bank charges for real-time tran "Supports Transferring Money" = "Money transfer"; "Supports Real-time transfer" = "Real-time transfer"; +"IBAN %@" = "IBAN %@"; +"BIC %@" = "BIC %@"; +"Bank code %@" = "Bank code %@"; +"Account number %@" = "Account number %@"; + /* ProtectAppSettingsDialog */ diff --git a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings index 10ae0c8c..1ffccfa6 100644 --- a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings @@ -196,6 +196,11 @@ Ob eine Bank Gebühren für Echtzeitüberweisungen erhebt, kann Bankmeister leid "Supports Transferring Money" = "Überweisen"; "Supports Real-time transfer" = "Echtzeitüberweisung"; +"IBAN %@" = "IBAN %@"; +"BIC %@" = "BIC %@"; +"Bank code %@" = "Bankleitzahl %@"; +"Account number %@" = "Kontonummer %@"; + /* ProtectAppSettingsDialog */ diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/BankAccountSettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/BankAccountSettingsDialog.swift index 19176542..1901359d 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/BankAccountSettingsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/BankAccountSettingsDialog.swift @@ -47,7 +47,7 @@ struct BankAccountSettingsDialog: View { .disabled(hideAccount) } - Section { + Section(header: shareButton.alignHorizontally(.trailing)) { LabelledValue("Account holder name", account.accountHolderName) // TODO: senseful? LabelledValue("Bank account identifier", account.identifier) @@ -80,6 +80,42 @@ struct BankAccountSettingsDialog: View { } + private var shareButton: some View { + Button(action: self.shareAccountData) { + Image(systemName: "square.and.arrow.up") + .resizable() + .scaledToFill() + .frame(width: 20, height: 20) + .linkForegroundColor() + } + .padding(.trailing, -6) + .padding(.bottom, 4) + } + + + private func shareAccountData() { + var accountData = account.accountHolderName + "\n" + account.bank.bankName + + if let iban = account.iban { + accountData.append("\n" + "IBAN \(iban)".localize()) + } + + accountData.append("\n" + "BIC \(account.bank.bic)".localize()) + accountData.append("\n" + "Bank code \(account.bank.bankCode)".localize()) + accountData.append("\n" + "Account number \(account.identifier)".localize()) + + + let activityViewController = UIActivityViewController(activityItems: [accountData], applicationActivities: nil) + + let viewController = SceneDelegate.rootViewController + + // needed for iPad + activityViewController.popoverPresentationController?.sourceView = viewController?.view + + viewController?.present(activityViewController, animated: true, completion: nil) + } + + private func cancelPressed() { if hasUnsavedData { self.unsavedChangesMessage = Message.createUnsavedChangesMessage(self.closeDialog)