Implemented sharing account data
This commit is contained in:
parent
99866e02be
commit
746591597e
|
@ -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)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
|
||||
</vector>
|
|
@ -92,11 +92,35 @@
|
|||
android:layout_marginTop="@dimen/form_section_extra_margin_top"
|
||||
>
|
||||
|
||||
<net.dankito.banking.ui.android.views.FormSectionTitle
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dialog_bank_account_settings_account_data_section_title"
|
||||
/>
|
||||
android:layout_marginTop="@dimen/form_section_extra_margin_top"
|
||||
>
|
||||
|
||||
<net.dankito.banking.ui.android.views.FormSectionTitle
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toLeftOf="@+id/btnShareAccountData"
|
||||
android:layout_toStartOf="@+id/btnShareAccountData"
|
||||
android:text="@string/dialog_bank_account_settings_account_data_section_title"
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnShareAccountData"
|
||||
android:layout_width="@dimen/dialog_bank_accounts_settings_share_account_data_button_size"
|
||||
android:layout_height="@dimen/dialog_bank_accounts_settings_share_account_data_button_size"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@null"
|
||||
app:srcCompat="@drawable/ic_baseline_share_24"
|
||||
android:scaleType="fitCenter"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<net.dankito.banking.ui.android.views.FormLabelledValue
|
||||
android:id="@+id/lvlAccountHolderName"
|
||||
|
|
|
@ -151,6 +151,11 @@
|
|||
<string name="dialog_bank_account_settings_account_features_supports_money_transfer">Überweisen</string>
|
||||
<string name="dialog_bank_account_settings_account_features_supports_real_time_transfer">Echtzeitüberweisung</string>
|
||||
|
||||
<string name="share_account_data_iban">IBAN %S</string>
|
||||
<string name="share_account_data_bic">BIC %S</string>
|
||||
<string name="share_account_data_bank_code">Bankleitzahl %S</string>
|
||||
<string name="share_account_data_account_number">Kontonumber %S</string>
|
||||
|
||||
|
||||
<string name="alert_ask_discard_changes_title">Nicht gespeicherte Änderungen</string>
|
||||
<string name="alert_ask_discard_changes_message">Es wurden nicht alle Änderungen gespeichert. Sind Sie sich sicher, dass Sie sie verwerfen möchten?\n\n(TODO: Oder einfach: Änderungen verwerfen?)</string>
|
||||
|
|
|
@ -202,6 +202,7 @@
|
|||
<dimen name="list_item_draggable_bank_account_padding">2dp</dimen>
|
||||
<dimen name="list_item_draggable_bank_account_account_name_text_size">16sp</dimen>
|
||||
|
||||
<dimen name="dialog_bank_accounts_settings_share_account_data_button_size">30dp</dimen>
|
||||
<!-- = 4 x list_item_checkable_value_height -->
|
||||
<dimen name="dialog_bank_accounts_settings_list_account_features_height">120dp</dimen>
|
||||
|
||||
|
|
|
@ -151,6 +151,11 @@
|
|||
<string name="dialog_bank_account_settings_account_features_supports_money_transfer">Money transfer</string>
|
||||
<string name="dialog_bank_account_settings_account_features_supports_real_time_transfer">Real-time transfer</string>
|
||||
|
||||
<string name="share_account_data_iban">IBAN %S</string>
|
||||
<string name="share_account_data_bic">BIC %S</string>
|
||||
<string name="share_account_data_bank_code">Bank code %S</string>
|
||||
<string name="share_account_data_account_number">Account number %S</string>
|
||||
|
||||
|
||||
<string name="alert_ask_discard_changes_title">Unsaved changed</string>
|
||||
<string name="alert_ask_discard_changes_message">Changed data hasn\'t been saved. Are you sure you want to discard them?\n\n(TODO: Oder einfach: Discard changes?)</string>
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue