Add Chats: transfers grouped per person as a chat #57

Open
azuwlaa wants to merge 2 commits from azuwlaa/android:feat/chats into main
Member

Adds a Chats page: BML transfers grouped per person and shown like a messaging app, with sending from inside the chat.

What it does

  • Chats takes the Contacts slot in the default bottom nav; Contacts moves to More and opens from a toolbar button on Chats. Users who customised their slots keep their setup.
  • Telegram-style list (avatar, name, last transfer, time) with search by name, real name, account number and note.
  • Only transfers from the first time Chats is opened are recorded — no old history is loaded.

Where transfers come from

  • BML notifications ("Funds Received" / "Funds Transferred") — instant. Read from the existing notification cache plus a fresh first page; the cache is not written to, so the notification poller is unaffected.
  • BML account history — booked later (often next day); includes Favara Credit/Debit (date-only).
  • In-app receipts (ReceiptStore) — add the note, recipient account and slip.
  • The three are merged so each transfer shows once. Transfers between the user's own accounts are skipped.

One chat per person

  • Chats are keyed by the account holder's real name, looked up via BML /validate/account (cached, 20 lookups per refresh, refreshed every 30 days). A contact saved as "Ali" joins the "MOHAMED ALI" chat.
  • A chat can hold several accounts (MVR / USD / MIB); a To bar shows the selected account and currency and switches between them. BML never reveals the sender's account, so received money is grouped by name only.
  • Header shows photo, contact name and real name; tapping opens the contact sheet, or Add Contact if not saved.

Sending

  • From-account card + "Send from" sheet (full number and balance); defaults to a source account in the recipient's currency.
  • Send opens the existing TransferFragment in a bottom sheet over the chat (same checks, confirm and OTP). On success it returns to the chat instead of opening the receipt; sent bubbles get a receipt button.

Second commit: business payments, new bubbles, pinning, Scan to Pay

Business chats

  • Card and Scan to Pay payments become chats named after the business, from BML "Payment Completed" alerts (instant) and "Purchase" history entries, merged into one bubble. Shortened alert names ("FAMILY ROOM") are filed under the full name ("FAMILY ROOM COFFEE"). Kept apart from people: shop icon, "Spent here this month" summary. ATM withdrawals and cash deposits are ignored.
  • Static merchant QRs (no preset amount) that the app already keeps in its recents are copied into Chats' own store, so a business can be paid again from its chat ("Pay [business]") with a card picker. Card-machine QRs are not saved.

Scan to Pay button

  • QR button on the chat list opens the scanner: BML QRs (static or card machine) open the payment, PayMV QRs a transfer. Success returns to Chats, which refreshes now and again after 10 s (the alert usually lands a few seconds after paying). Tested with a live card-machine QR.

Bubbles and chat screen

  • Compact bubbles: amount first, note, account, time and ticks inside; a tick shows the transfer was seen in a BML alert, two ticks that it is booked in history. Receipt button in the corner of sent bubbles. Plain-text day separators with day totals. Monthly sent / received / net summary.
  • From chip with account number and balance (masked by the hide-amounts toggle); tinted To bar when a person has several accounts; Note field passed as remarks.
  • Long-press a bubble: Send again, View receipt, Copy reference.
  • Currency rules: MVR into a USD account can't be selected (BML doesn't allow it); USD into an MVR account is allowed with a conversion warning.

Sending

  • Personal profiles: tapping Send shows only the confirm dialog over the chat (the Transfer page runs hidden). Business profiles keep the sheet, since their OTP is typed on the Transfer page.

Chat list

  • Long-press a chat to pin or unpin it (with Undo); pinned chats stay on top.

Storage

  • chats.json, account_names.json, chat_pins.json and chat_merchant_qr.json in filesDir, encrypted with CacheEncryption.

Changes to existing code (kept small)

  • TransferFragment: optional returnOnSuccess flag on newInstanceFromQr and newInstanceFromBmlQr, an optional autoConfirm flag (opens the confirm dialog on load), and a small returnToCallerIfRequested() helper used by the success paths. All default off; behaviour elsewhere unchanged.
  • BmlTransferHandler: one line so QR payments also return to the caller when asked.
  • ContactDetailsSheetFragment / ContactsFragment: small ContactSheetHost interface so the contact sheet also works from a chat.
  • HomeActivity, NavCustomization, nav menus, strings.xml: register nav_chats.

Everything else is in new files (ChatStore, AccountNameStore, Chats*/Chat* fragments and adapters, TransferSheetFragment, layouts).

Not included / known limits

  • BML current & savings accounts only (no MIB / Fahipay / M-Faisa sources yet).
  • Chat data isn't cleared on logout or Settings → Storage.
  • No Dhivehi strings yet.

Tested on a physical device (debug build): notifications, history merge, sending from chats (personal and business profiles), static and card-machine Scan to Pay, receipts, pinning, light and dark mode.

Generated with Claude Code

https://claude.ai/code/session_01FQUrmJjrypeoPsubpzuezC

Adds a **Chats** page: BML transfers grouped per person and shown like a messaging app, with sending from inside the chat. ## What it does - **Chats** takes the Contacts slot in the default bottom nav; Contacts moves to More and opens from a toolbar button on Chats. Users who customised their slots keep their setup. - Telegram-style list (avatar, name, last transfer, time) with search by name, real name, account number and note. - Only transfers from the first time Chats is opened are recorded — no old history is loaded. ## Where transfers come from - **BML notifications** ("Funds Received" / "Funds Transferred") — instant. Read from the existing notification cache plus a fresh first page; the cache is not written to, so the notification poller is unaffected. - **BML account history** — booked later (often next day); includes `Favara Credit/Debit` (date-only). - **In-app receipts** (`ReceiptStore`) — add the note, recipient account and slip. - The three are merged so each transfer shows once. Transfers between the user's own accounts are skipped. ## One chat per person - Chats are keyed by the account holder's **real name**, looked up via BML `/validate/account` (cached, 20 lookups per refresh, refreshed every 30 days). A contact saved as "Ali" joins the "MOHAMED ALI" chat. - A chat can hold several accounts (MVR / USD / MIB); a **To** bar shows the selected account and currency and switches between them. BML never reveals the sender's account, so received money is grouped by name only. - Header shows photo, contact name and real name; tapping opens the contact sheet, or Add Contact if not saved. ## Sending - From-account card + "Send from" sheet (full number and balance); defaults to a source account in the recipient's currency. - **Send** opens the existing `TransferFragment` in a bottom sheet over the chat (same checks, confirm and OTP). On success it returns to the chat instead of opening the receipt; sent bubbles get a receipt button. ## Second commit: business payments, new bubbles, pinning, Scan to Pay **Business chats** - Card and Scan to Pay payments become chats named after the business, from BML "Payment Completed" alerts (instant) and "Purchase" history entries, merged into one bubble. Shortened alert names ("FAMILY ROOM") are filed under the full name ("FAMILY ROOM COFFEE"). Kept apart from people: shop icon, "Spent here this month" summary. ATM withdrawals and cash deposits are ignored. - Static merchant QRs (no preset amount) that the app already keeps in its recents are copied into Chats' own store, so a business can be paid again from its chat ("Pay [business]") with a card picker. Card-machine QRs are not saved. **Scan to Pay button** - QR button on the chat list opens the scanner: BML QRs (static or card machine) open the payment, PayMV QRs a transfer. Success returns to Chats, which refreshes now and again after 10 s (the alert usually lands a few seconds after paying). Tested with a live card-machine QR. **Bubbles and chat screen** - Compact bubbles: amount first, note, account, time and ticks inside; a tick shows the transfer was seen in a BML alert, two ticks that it is booked in history. Receipt button in the corner of sent bubbles. Plain-text day separators with day totals. Monthly sent / received / net summary. - From chip with account number and balance (masked by the hide-amounts toggle); tinted To bar when a person has several accounts; Note field passed as remarks. - Long-press a bubble: Send again, View receipt, Copy reference. - Currency rules: MVR into a USD account can't be selected (BML doesn't allow it); USD into an MVR account is allowed with a conversion warning. **Sending** - Personal profiles: tapping Send shows only the confirm dialog over the chat (the Transfer page runs hidden). Business profiles keep the sheet, since their OTP is typed on the Transfer page. **Chat list** - Long-press a chat to pin or unpin it (with Undo); pinned chats stay on top. ## Storage - `chats.json`, `account_names.json`, `chat_pins.json` and `chat_merchant_qr.json` in `filesDir`, encrypted with `CacheEncryption`. ## Changes to existing code (kept small) - `TransferFragment`: optional `returnOnSuccess` flag on `newInstanceFromQr` and `newInstanceFromBmlQr`, an optional `autoConfirm` flag (opens the confirm dialog on load), and a small `returnToCallerIfRequested()` helper used by the success paths. All default off; behaviour elsewhere unchanged. - `BmlTransferHandler`: one line so QR payments also return to the caller when asked. - `ContactDetailsSheetFragment` / `ContactsFragment`: small `ContactSheetHost` interface so the contact sheet also works from a chat. - `HomeActivity`, `NavCustomization`, nav menus, `strings.xml`: register `nav_chats`. Everything else is in new files (`ChatStore`, `AccountNameStore`, `Chats*`/`Chat*` fragments and adapters, `TransferSheetFragment`, layouts). ## Not included / known limits - BML current & savings accounts only (no MIB / Fahipay / M-Faisa sources yet). - Chat data isn't cleared on logout or Settings → Storage. - No Dhivehi strings yet. Tested on a physical device (debug build): notifications, history merge, sending from chats (personal and business profiles), static and card-machine Scan to Pay, receipts, pinning, light and dark mode. Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FQUrmJjrypeoPsubpzuezC
azuwlaa added 1 commit 2026-09-25 12:29:11 +00:00
Replaces Contacts in the default bottom nav slot with a Chats page
(Contacts moves to More and opens from the Chats toolbar).

- Chats start when the page is first opened; no old history is loaded
- Transfers come from BML notifications (instant), account history
  (booked later) and in-app receipts, merged into one bubble each
- Chats are keyed by the account holder's real name, looked up via
  BML account validation, so nickname contacts and their MVR/USD
  accounts share one chat; the To bar picks the account to send to
- Sending opens the Transfer page in a bottom sheet over the chat and
  returns to it on success; sent bubbles link to their receipt
- Chat and name data are stored encrypted with CacheEncryption

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FQUrmJjrypeoPsubpzuezC
azuwlaa force-pushed feat/chats from 9bb7c2ce72 to da5cca79c6 2026-09-25 12:29:11 +00:00 Compare
azuwlaa added 1 commit 2026-09-25 23:13:15 +00:00
- Card / Scan to Pay payments show as business chats (from BML
  "Payment Completed" alerts and "Purchase" history), kept apart from
  people; static merchant QRs are kept so a business can be paid again
  from its chat, with a card picker
- Scan to Pay button on the chat list; returns and re-checks after paying
- Compact bubbles with ticks (alert seen / booked in history), receipt
  button, day totals, monthly summary, long-press actions
- Personal accounts confirm with just the dialog over the chat; business
  profiles keep the sheet for the OTP step
- From chip shows account number and balance; MVR -> USD account is
  blocked, USD -> MVR warns about conversion
- Long-press a chat to pin it to the top

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FQUrmJjrypeoPsubpzuezC
This pull request has changes conflicting with the target branch.
  • app/src/main/java/sh/sar/basedbank/ui/home/TransferFragment.kt
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u https://git.shihaam.dev/azuwlaa/android feat/chats:azuwlaa-feat/chats
git checkout azuwlaa-feat/chats
Sign in to join this conversation.