Fixed instant payment layout (show info button is now right after label and label ellipsizes if there's not enough space
This commit is contained in:
parent
6467964305
commit
b33964a76b
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
val TextView.isEllipsized: Boolean
|
||||
get() {
|
||||
this.layout?.let { layout ->
|
||||
for (i in 0..layout.lineCount) {
|
||||
if (layout.getEllipsisCount(i) > 0) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
|
@ -125,100 +125,47 @@
|
|||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/lytInstantPayment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginTop="@dimen/dialog_transfer_money_instant_payment_margin_top"
|
||||
android:layout_marginBottom="@dimen/dialog_transfer_money_instant_payment_margin_bottom"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:visibility="gone"
|
||||
>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/lytInstantPaymentInfo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toLeftOf="@+id/swtchInstantPayment"
|
||||
android:layout_toStartOf="@+id/swtchInstantPayment"
|
||||
android:layout_alignParentBottom="true"
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/lytInstantPayment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginTop="@dimen/dialog_transfer_money_instant_payment_margin_top"
|
||||
android:layout_marginBottom="@dimen/dialog_transfer_money_instant_payment_margin_bottom"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:visibility="gone"
|
||||
android:layout_marginRight="@dimen/dialog_transfer_money_instant_payment_show_info_button_margin_end"
|
||||
android:layout_marginEnd="@dimen/dialog_transfer_money_instant_payment_show_info_button_margin_end"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvwInstantPaymentLabel"
|
||||
android:layout_width="wrap_content"
|
||||
<androidx.appcompat.widget.AppCompatCheckBox
|
||||
android:id="@+id/chkbxInstantPayment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
style="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textSize="@dimen/dialog_transfer_money_instant_payment_text_size"
|
||||
android:layout_weight="1"
|
||||
android:lines="1"
|
||||
android:ellipsize="end"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:textAlignment="gravity"
|
||||
android:textSize="@dimen/view_instant_payment_info_text_size"
|
||||
android:text="@string/dialog_transfer_money_instant_payment"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvwInstantPaymentMayWithConstsLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toRightOf="@+id/txtvwInstantPaymentLabel"
|
||||
android:layout_toEndOf="@+id/txtvwInstantPaymentLabel"
|
||||
android:layout_toLeftOf="@+id/btnShowInstantPaymentInfo"
|
||||
android:layout_toStartOf="@+id/btnShowInstantPaymentInfo"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginLeft="@dimen/dialog_transfer_money_instant_payment_may_with_costs_margin_start"
|
||||
android:layout_marginStart="@dimen/dialog_transfer_money_instant_payment_may_with_costs_margin_start"
|
||||
style="@style/TextAppearance.AppCompat.Small"
|
||||
android:lines="1"
|
||||
android:ellipsize="end"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:textAlignment="gravity"
|
||||
android:text="@string/dialog_transfer_money_instant_payment_may_with_costs"
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnShowInstantPaymentInfo"
|
||||
android:layout_width="@dimen/dialog_transfer_money_instant_payment_show_info_button_size"
|
||||
android:layout_height="@dimen/dialog_transfer_money_instant_payment_show_info_button_size"
|
||||
android:layout_weight="0"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:layout_marginLeft="@dimen/dialog_transfer_money_instant_payment_show_info_button_margin_start"
|
||||
android:layout_marginStart="@dimen/dialog_transfer_money_instant_payment_show_info_button_margin_start"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@null"
|
||||
app:srcCompat="@drawable/ic_baseline_info_24"
|
||||
android:tint="@color/infoIconColor"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swtchInstantPayment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
|
|
|
@ -62,8 +62,7 @@
|
|||
<string name="dialog_transfer_money_could_not_determine_bic_from_iban">Keine BIC gefunden für BLZ %1$s</string>
|
||||
<string name="dialog_transfer_money_amount">Betrag:</string>
|
||||
<string name="dialog_transfer_money_usage">Verwendungszweck:</string>
|
||||
<string name="dialog_transfer_money_instant_payment">Echtzeitüberweisung</string>
|
||||
<string name="dialog_transfer_money_instant_payment_may_with_costs">(evtl. kostenpflichtig)</string>
|
||||
<string name="dialog_transfer_money_instant_payment">Echtzeitüberweisung (evtl. kostenpflichtig)</string>
|
||||
<string name="dialog_transfer_money_instant_payment_info">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.
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
<dimen name="dialog_transfer_money_input_fields_height">40dp</dimen>
|
||||
<dimen name="dialog_transfer_money_input_fields_bottom_margin_when_displaying_validation_label">8dp</dimen>
|
||||
<dimen name="dialog_transfer_money_instant_payment_text_size">14sp</dimen>
|
||||
<dimen name="dialog_transfer_money_instant_payment_may_with_costs_margin_start">4dp</dimen>
|
||||
<dimen name="dialog_transfer_money_instant_payment_margin_top">6dp</dimen>
|
||||
<dimen name="dialog_transfer_money_instant_payment_margin_bottom">6dp</dimen>
|
||||
<dimen name="dialog_transfer_money_instant_payment_show_info_button_size">20dp</dimen>
|
||||
|
|
|
@ -62,8 +62,7 @@
|
|||
<string name="dialog_transfer_money_could_not_determine_bic_from_iban">No BIC found for bank code %1$s</string>
|
||||
<string name="dialog_transfer_money_amount">Amount:</string>
|
||||
<string name="dialog_transfer_money_usage">Usage:</string>
|
||||
<string name="dialog_transfer_money_instant_payment">Instant payment</string>
|
||||
<string name="dialog_transfer_money_instant_payment_may_with_costs">(may with costs)</string>
|
||||
<string name="dialog_transfer_money_instant_payment">Instant payment (may with costs)</string>
|
||||
<string name="dialog_transfer_money_instant_payment_info">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.
|
||||
|
|
Loading…
Reference in New Issue