bug fix that took user to default card from dashboard instead of the card user selected

This commit is contained in:
2026-05-29 16:45:19 +05:00
parent 3db077cf9a
commit f5f52829c7
2 changed files with 23 additions and 8 deletions
@@ -393,9 +393,10 @@ class DashboardFragment : Fragment() {
if (isMib) { if (isMib) {
Toast.makeText(requireContext(), R.string.mib_qr_nfc_not_supported, Toast.LENGTH_SHORT).show() Toast.makeText(requireContext(), R.string.mib_qr_nfc_not_supported, Toast.LENGTH_SHORT).show()
} else { } else {
val accountNumber = (item as CardItem.Bml).account.accountNumber
(requireActivity() as HomeActivity).navigateTo( (requireActivity() as HomeActivity).navigateTo(
R.id.nav_pay_with_card, R.id.nav_pay_with_card,
CardsFragment.newInstanceWithAutoTapMode() CardsFragment.newInstanceWithAutoTapMode(accountNumber)
) )
} }
} }
@@ -684,16 +684,26 @@ ViewCompat.setOnApplyWindowInsetsListener(binding.contentLayout) { v, insets ->
updateCardInfo(currentCardPosition) updateCardInfo(currentCardPosition)
} }
// Auto-enter tap mode when launched from shortcut or NFC prompt // Auto-enter tap mode when launched from shortcut, NFC prompt, or dashboard
if (!autoTapModeTriggered && arguments?.getBoolean(ARG_AUTO_TAP_MODE) == true) { if (!autoTapModeTriggered && arguments?.getBoolean(ARG_AUTO_TAP_MODE) == true) {
val defaultCard = cards.filterIsInstance<CardItem.Bml>().firstOrNull() val targetAccount = arguments?.getString(ARG_AUTO_TAP_ACCOUNT)
if (defaultCard != null) { val targetCard = if (targetAccount != null)
cards.filterIsInstance<CardItem.Bml>().firstOrNull { it.account.accountNumber == targetAccount }
else
cards.filterIsInstance<CardItem.Bml>().firstOrNull()
if (targetCard != null) {
autoTapModeTriggered = true autoTapModeTriggered = true
// Scroll to the target card first
val pos = cards.indexOf(targetCard)
if (pos >= 0) {
currentCardPosition = pos
binding.rvCards.scrollToPosition(pos)
}
val prefs = requireContext().getSharedPreferences("prefs", Context.MODE_PRIVATE) val prefs = requireContext().getSharedPreferences("prefs", Context.MODE_PRIVATE)
if (prefs.getBoolean("biometrics_transfer_confirm", false)) { if (prefs.getBoolean("biometrics_transfer_confirm", false)) {
showBiometricPromptForTap(defaultCard) showBiometricPromptForTap(targetCard)
} else { } else {
setTapMode(true, defaultCard) setTapMode(true, targetCard)
} }
} }
} }
@@ -944,8 +954,12 @@ ViewCompat.setOnApplyWindowInsetsListener(binding.contentLayout) { v, insets ->
companion object { companion object {
private const val ARG_AUTO_TAP_MODE = "auto_tap_mode" private const val ARG_AUTO_TAP_MODE = "auto_tap_mode"
fun newInstanceWithAutoTapMode() = CardsFragment().apply { private const val ARG_AUTO_TAP_ACCOUNT = "auto_tap_account"
arguments = Bundle().apply { putBoolean(ARG_AUTO_TAP_MODE, true) } fun newInstanceWithAutoTapMode(accountNumber: String? = null) = CardsFragment().apply {
arguments = Bundle().apply {
putBoolean(ARG_AUTO_TAP_MODE, true)
if (accountNumber != null) putString(ARG_AUTO_TAP_ACCOUNT, accountNumber)
}
} }
fun cardImageAsset(card: MibCard): String? = when (card.cardType) { fun cardImageAsset(card: MibCard): String? = when (card.cardType) {