Files
fksar/docs/thijooree/08-contacts.md
T
2026-06-13 21:30:12 +05:00

81 lines
2.8 KiB
Markdown

# Contacts
The contacts screen stores and manages frequently used transfer recipients. Contacts are local to the app and never synced externally.
---
## Fragment — `ContactsFragment`
Displays the full contact list as a `RecyclerView`. Observes `HomeViewModel.contacts` and `HomeViewModel.contactCategories`.
---
## Contact List
Each contact row shows:
- Circular avatar (profile image if set, otherwise initials placeholder)
- Display name
- Account number(s)
- Category chip (if assigned)
Tapping a contact row opens `AddContactSheetFragment` in edit mode.
Tapping the **Transfer** button on a contact row opens `TransferFragment` with the recipient pre-filled.
---
## Categories
Contacts can be assigned to user-defined categories (e.g., "Family", "Business"). Categories appear as filter chips at the top of the list. Tapping a chip filters the list to that category. Tapping again clears the filter.
---
## Add Contact — `AddContactSheetFragment`
A bottom sheet for creating or editing a contact. The companion exposes a single `newInstance(bmlProfileId?, accountNumber?, recipientName?, currency?)` factory (`AddContactSheetFragment.kt:572-585`) used by the BML USD → MIB auto-add flow on the [Transfer screen](20-transfer-flows.md#bml-usd--mib-no-saved-contact).
### Fields
| Field | Notes |
|---|---|
| Name | Display name |
| Account number | Primary transfer account number |
| Bank | Optional — for display only |
| Category | Optional; selectable from existing categories or create new |
| Profile image | Optional; select from gallery or camera |
### Profile Image
The pencil icon next to the avatar opens a chooser:
- **Gallery** — pick from device gallery
- **Camera** — capture a new photo (temp file in `cacheDir`)
The selected image is held in memory as a base64 string (`selectedImageBase64` in `AddContactSheetFragment`) and uploaded inline with the contact on save. A local copy is also kept in `util/ContactImageCache` (cache directory, PNG, keyed by the image hash) so the avatar can be rendered without a round-trip on next open.
### Save
On save, the contact is persisted to the local database and `HomeViewModel.contacts` is refreshed.
### Delete
A delete button (with confirmation dialog) removes the contact and its profile image.
---
## Contact Picker — `ContactPickerSheetFragment`
A compact bottom sheet version of the contact list, used by `TransferFragment` when the user taps **Choose Contact**.
- Shows all contacts with avatar and name
- Search bar filters by name or account number
- Tapping a contact returns the selection to `TransferFragment` and dismisses the sheet
- Profile images use a `"local:{key}"` synthetic hash prefix to identify locally stored images
---
 
---
[← Transfer](07-transfer.md)     **Next →** [Activities](09-activities.md)