diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt index b9d09435..dbc5b546 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt @@ -33,6 +33,8 @@ import net.dankito.banking.ui.model.responses.BankingClientResponse import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.util.InputValidator import net.dankito.banking.bankfinder.BankInfo +import net.dankito.banking.ui.android.extensions.hideKeyboard +import net.dankito.banking.ui.android.extensions.isEllipsized import net.dankito.banking.util.ValidationResult import net.dankito.utils.multiplatform.toBigDecimal import net.dankito.utils.android.extensions.asActivity @@ -40,7 +42,9 @@ import net.dankito.utils.android.extensions.getDimension import java.math.BigDecimal import java.text.DecimalFormatSymbols import java.text.NumberFormat +import java.util.* import javax.inject.Inject +import kotlin.concurrent.schedule open class TransferMoneyDialog : DialogFragment() { @@ -154,8 +158,6 @@ open class TransferMoneyDialog : DialogFragment() { val decimalSeparator = DecimalFormatSymbols.getInstance().getDecimalSeparator() rootView.edtxtAmount.keyListener = DigitsKeyListener.getInstance("0123456789$decimalSeparator") - rootView.txtvwInstantPaymentLabel.setOnClickListener { rootView.swtchInstantPayment.toggle() } - rootView.txtvwInstantPaymentMayWithConstsLabel.setOnClickListener { rootView.swtchInstantPayment.toggle() } rootView.btnShowInstantPaymentInfo.setOnClickListener { showInstantPaymentInfo(rootView.btnShowInstantPaymentInfo, rootView) } setInstantPaymentControlsVisibility(rootView) @@ -163,9 +165,27 @@ open class TransferMoneyDialog : DialogFragment() { rootView.btnCancel.setOnClickListener { dismiss() } rootView.btnTransferMoney.setOnClickListener { transferMoney() } + + adjustCheckBoxInstantPaymentWidth() } - private fun setInstantPaymentControlsVisibility(rootView: View) { + + protected open fun adjustCheckBoxInstantPaymentWidth() { + // wait some time till CheckBox is layout and lineCount is set + val timer = Timer() + timer.schedule(10) { requireActivity().runOnUiThread { adjustCheckBoxInstantPaymentWidthOnUiThread() }} + timer.schedule(2500) { requireActivity().runOnUiThread { adjustCheckBoxInstantPaymentWidthOnUiThread() }} + } + + protected open fun adjustCheckBoxInstantPaymentWidthOnUiThread() { + if (chkbxInstantPayment.isEllipsized == false) { + // by default chkbxInstantPayment uses full width, even though if its text doesn't need this space -> there + chkbxInstantPayment.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0f) + chkbxInstantPayment.requestLayout() + } + } + + protected open fun setInstantPaymentControlsVisibility(rootView: View) { rootView.lytInstantPayment.visibility = if (bankAccount.supportsInstantPaymentMoneyTransfer) { View.VISIBLE @@ -282,7 +302,7 @@ open class TransferMoneyDialog : DialogFragment() { remitteeBic?.replace(" ", "") ?: "", // should always be != null at this point amount.toBigDecimal(), inputValidator.convertToAllowedSepaCharacters(edtxtUsage.text.toString()), - swtchInstantPayment.isChecked + chkbxInstantPayment.isChecked ) presenter.transferMoneyAsync(data) { diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/extensions/TextViewExtensions.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/extensions/TextViewExtensions.kt index 729de163..430b4da3 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/extensions/TextViewExtensions.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/extensions/TextViewExtensions.kt @@ -14,4 +14,17 @@ fun TextView.showAmount(presenter: BankingPresenter, amount: BigDecimal) { fun TextView.setTextColorForAmount(amount: BigDecimal) { setTextColorToColorResource(if (amount >= java.math.BigDecimal.ZERO) R.color.positiveAmount else R.color.negativeAmount) -} \ No newline at end of file +} + +val TextView.isEllipsized: Boolean + get() { + this.layout?.let { layout -> + for (i in 0..layout.lineCount) { + if (layout.getEllipsisCount(i) > 0) { + return true + } + } + } + + return false + } \ No newline at end of file diff --git a/ui/BankingAndroidApp/src/main/res/layout/dialog_transfer_money.xml b/ui/BankingAndroidApp/src/main/res/layout/dialog_transfer_money.xml index bafbea6e..a1bf0f68 100644 --- a/ui/BankingAndroidApp/src/main/res/layout/dialog_transfer_money.xml +++ b/ui/BankingAndroidApp/src/main/res/layout/dialog_transfer_money.xml @@ -125,100 +125,47 @@ - - - - - - - - - - - + Keine BIC gefunden für BLZ %1$s Betrag: Verwendungszweck: - Echtzeitüberweisung - (evtl. kostenpflichtig) + Echtzeitüberweisung (evtl. kostenpflichtig) Normale Überweisungen werden in der Regel innerhalb eines Werktages gutgeschrieben. Dies gilt jedoch nur zu Geschäftszeiten der Banken, also schon mal nicht am Wochenende und an Feiertagen. Zudem unterscheiden sich die Geschäftszeiten von Bank zu Bank. Meistens gehen diese von 10 - 18 Uhr, manchmal auch bis 22 Uhr, manchmal (Freitags) aber auch nur bis 14 Uhr. \n\nEchtzeitüberweisungen werden hingegen innerhalb von maximal 10 Sekunden überwiesen, egal an welchem Tag und zu welcher Uhrzeit. \n\nHäufig sind Echtzeitüberweisungen jedoch kostenpflichtig. diff --git a/ui/BankingAndroidApp/src/main/res/values/dimens.xml b/ui/BankingAndroidApp/src/main/res/values/dimens.xml index bf43257d..0d5b0a27 100644 --- a/ui/BankingAndroidApp/src/main/res/values/dimens.xml +++ b/ui/BankingAndroidApp/src/main/res/values/dimens.xml @@ -69,7 +69,6 @@ 40dp 8dp 14sp - 4dp 6dp 6dp 20dp diff --git a/ui/BankingAndroidApp/src/main/res/values/strings.xml b/ui/BankingAndroidApp/src/main/res/values/strings.xml index 5643ca3b..f13ba5f0 100644 --- a/ui/BankingAndroidApp/src/main/res/values/strings.xml +++ b/ui/BankingAndroidApp/src/main/res/values/strings.xml @@ -62,8 +62,7 @@ No BIC found for bank code %1$s Amount: Usage: - Instant payment - (may with costs) + Instant payment (may with costs) Bank transfers are usually credited within one business day. However, this only applies during bank business hours, and therefore not at weekends and on public holidays. In addition, business hours vary from bank to bank. Mostly they are from 10 - 18 o\'clock, sometimes also until 22 o\'clock, but sometimes (e. g. Fridays) only until 14 o\'clock. \n\nInstant payment transfers on the other hand are transferred within a maximum of 10 seconds, regardless of the day and time of day. \n\nHowever, real-time transfers are often subject to a fee.