# Android Changelog ## 2026-03-08 ### Step 1 - Build and app wiring - Added Android project plugin configuration for Hilt and Kotlin serialization. - Added dependency repositories and explicit app module include in settings. - Added app dependencies for Retrofit/OkHttp, DataStore, coroutines, Hilt, and unit testing. - Enabled INTERNET permission and registered MessengerApplication in manifest. - Added MessengerApplication with HiltAndroidApp. ### Step 2 - Network/data core + DI - Fixed DTO/Auth API serialization annotations and endpoint declarations for `/api/v1/auth/login`, `/api/v1/auth/refresh`, `/api/v1/auth/me`. - Implemented DataStore-based token persistence with a corrected `getTokens()` read path. - Added auth network stack: bearer interceptor, 401 authenticator with refresh flow and retry guard. - Added clean-layer contracts and implementations: `domain/common`, `domain/auth`, `data/auth/repository`. - Wired dependencies with Hilt modules for DataStore, OkHttp/Retrofit, and repository bindings. ### Step 3 - Minimal auth UI and navigation - Replaced Phase 0 placeholder UI with Compose auth flow (`AuthViewModel` + login screen). - Added loading/error states for login and startup session restore. - Added navigation graph: `AuthGraph (login)` to placeholder `Chats` screen after successful auth. - Implemented automatic session restore on app start using stored tokens. ### Step 4 - Unit tests - Added `DataStoreTokenRepositoryTest` for token save/read and clear behavior. - Added `NetworkAuthRepositoryTest` for login success path and 401 -> `InvalidCredentials` error mapping. ### Step 5 - Chat Room models and persistence core - Added domain chat model (`ChatItem`) for chat list rendering concerns. - Added Room entities: `chats`, `users_short` with sort-friendly indices. - Added `ChatDao` with `observeChats()`, `upsertChats()`, and transactional `clearAndReplaceChats()`. - Added `MessengerDatabase` and Hilt database wiring (`DatabaseModule`). ### Step 6 - Chat API and repository sync - Added chat REST API client for `/api/v1/chats` and `/api/v1/chats/{chat_id}`. - Added chat DTOs and remote/local mappers (`ChatReadDto -> ChatEntity/UserShortEntity -> ChatItem`). - Implemented `NetworkChatRepository` with cache-first flow strategy (Room first, then server sync). - Added chat domain contracts/use-cases (`ChatRepository`, observe/refresh use-cases). - Wired chat API/repository via Hilt modules. ### Step 7 - Realtime manager and chat list updates - Added a unified realtime manager abstraction and WebSocket implementation for `/api/v1/realtime/ws?token=...`. - Implemented auto-reconnect with exponential backoff and max cap. - Added realtime event parser for `receive_message`, `message_updated`, `message_deleted`, `chat_updated`, `chat_deleted`, `user_online`, `user_offline`. - Added use-case level realtime event handling that updates Room and triggers repository refreshes when needed. - Wired realtime manager into DI. ### Step 8 - Chat list UI and navigation - Added Chat List screen with tabs (`All` / `Archived`), local search filter, pull-to-refresh, and state handling (loading/empty/error). - Added chat row rendering for unread badge, mention badge (`@`), pinned/muted marks, and message preview by media type. - Added private chat presence display (`online` / `last seen recently` fallback). - Connected Chat List to ViewModel/use-cases with no business logic inside composables. - Added chat click navigation to placeholder `ChatScreen(chatId)`. ### Step 9 - Tests and checklist updates - Added unit test for chat cache-first sync strategy (`NetworkChatRepositoryTest`). - Added unit test for realtime event parsing (`RealtimeEventParserTest`). - Added DAO test (`ChatDaoTest`) using in-memory Room + Robolectric. - Updated Android checklist status in `docs/android-checklist.md`. ### Step 10 - Build stabilization fixes - Switched Android API base URL to `https://chat.daemonlord.ru/`. - Added cleartext traffic flag in manifest for local/dev compatibility. - Fixed Hilt dependency cycle by separating refresh `AuthApiService` with a dedicated qualifier. - Added `CoroutineDispatcher` DI provider and qualifier for repositories. - Fixed Material3 experimental API opt-in and removed deprecated `StateFlow.distinctUntilChanged()` usage. ### Step 11 - Sprint A / 1) Message Room + models - Added message domain model (`MessageItem`) for chat screen rendering. - Added Room entities `messages` and `message_attachments` with chat-history indexes. - Added `MessageDao` with observe/pagination/upsert/delete APIs. - Updated `MessengerDatabase` schema to include message tables and DAO. - Added Hilt DI provider for `MessageDao`. ### Step 12 - Sprint A / 2) Message API + repository - Added message REST API client for history/send/edit/delete endpoints. - Added message DTOs and mappers (`MessageReadDto -> MessageEntity -> MessageItem`). - Added `MessageRepository` contracts/use-cases for observe/sync/pagination/send/edit/delete. - Implemented `NetworkMessageRepository` with cache-first observation and optimistic text send. - Wired message API and repository into Hilt modules. ### Step 13 - Sprint A / 3) Message realtime integration - Extended realtime event model/parser with message-focused events (`message_delivered`, `message_read`, `typing_start`, `typing_stop`) and richer message payload mapping. - Updated unified realtime handler to write `receive_message`, `message_updated`, `message_deleted` into `messages` Room state. - Added delivery/read status updates in Room for message status events. - Kept chat list sync updates in the same manager/use-case pipeline for consistency. ### Step 14 - Sprint A / 4) Message UI core - Replaced chat placeholder with a real message screen route + ViewModel. - Added message list rendering with Telegram-like bubble alignment and status hints. - Added input composer with send flow, reply/edit modes, and inline action cancellation. - Added long-press actions (`reply`, `edit`, `delete`) for baseline message operations. - Added manual "load older" pagination trigger and chat back navigation integration. ### Step 15 - Sprint A / 5) Message tests and docs - Added unit tests for `NetworkMessageRepository` sync/send flows. - Added DAO test for message scoped replace behavior in Room. - Expanded realtime parser tests with rich `receive_message` mapping coverage. - Updated `docs/android-checklist.md` for completed message-core items. ### Step 16 - Sprint B / 1-2) Media data layer + chat integration - Added media API/DTO layer for upload URL and attachment creation. - Added `MediaRepository` + `UploadAndAttachMediaUseCase` and network implementation with presigned PUT upload. - Extended `MessageRepository` with media send flow (`sendMediaMessage`) and optimistic local update behavior. - Wired media API/repository through Hilt modules. - Integrated file picking and media sending into Android `ChatScreen`/`ChatViewModel` with upload state handling. ### Step 17 - Sprint B / media tests - Added `NetworkMediaRepositoryTest` for successful upload+attach flow. - Added error-path coverage for failed presigned upload handling. ## 2026-03-09 ### Step 18 - Sprint P0 / 1) Message core completion - Extended message API/data contracts with `messages/status`, `forward`, and reaction endpoints. - Added message domain support for forwarded message metadata and attachment waveform payload. - Implemented repository operations for delivery/read acknowledgements, forward, and reactions. - Updated Chat ViewModel/UI with forward flow, reaction toggle, and edit/delete-for-all edge-case guards. - Added automatic delivered/read acknowledgement for latest incoming message in active chat. - Fixed outgoing message detection by resolving current user id from JWT `sub` claim. ### Step 19 - Sprint P0 / 2) Media UX after send - Added media endpoint mapping for chat attachments (`GET /api/v1/media/chats/{chat_id}/attachments`). - Extended Room message observation to include attachment relations via `MessageLocalModel`. - Synced and persisted message attachments during message refresh/pagination and after media send. - Extended message domain model with attachment list payload. - Added message attachment rendering in Chat UI: inline image preview, minimal image viewer overlay, and basic audio play/pause control. ### Step 20 - Sprint P0 / 3) Roles/permissions baseline - Extended chat data/domain models with `my_role` and added `observeChatById` stream in Room/repository. - Added `ObserveChatUseCase` to expose per-chat permission state to message screen. - Implemented channel send restrictions in `ChatViewModel`: sending/attach disabled for `member` role in `channel` chats. - Added composer-level restriction hint in Chat UI to explain blocked actions. ### Step 21 - Sprint P0 / 4) Invite join flow (minimum) - Added chat API contracts for invite actions: `POST /api/v1/chats/{chat_id}/invite-link` and `POST /api/v1/chats/join-by-invite`. - Added domain model/use-cases for invite-link creation and join-by-invite. - Extended chat repository with invite operations and local chat upsert on successful join. - Added minimal Chat List UI flow for join-by-invite token input with loading/error handling and auto-open of joined chat. ### Step 22 - Sprint P0 / 5) Realtime stability and reconcile - Added heartbeat in WebSocket manager (`ping` interval + `pong` timeout detection) with forced reconnect on stale link. - Improved socket lifecycle hygiene by cancelling heartbeat on close/failure/disconnect paths. - Added `connect` event mapping and centralized reconcile trigger in realtime handler. - On realtime reconnect, chat repository now refreshes `all` and `archived` snapshots to reduce stale state after transient disconnects. ### Step 23 - Sprint P0 / 6) Auth hardening foundation - Extended auth API/repository contracts with sessions management endpoints: - `GET /api/v1/auth/sessions` - `DELETE /api/v1/auth/sessions/{jti}` - `DELETE /api/v1/auth/sessions` - Added domain model and use-cases for listing/revoking sessions. - Added unit coverage for session DTO -> domain mapping in `NetworkAuthRepositoryTest`. ### Step 24 - Sprint P0 / 7) Quality pass - Added realtime parser unit coverage for `connect` event mapping. - Extended message DAO tests with attachment relation verification. - Added Android smoke and baseline document (`docs/android-smoke.md`) with test matrix and performance targets. - Updated Android checklist quality section with initial performance baseline completion. ### Step 25 - UI safe insets fix - Enabled edge-to-edge mode in `MainActivity` via `enableEdgeToEdge()`. - Added safe area insets handling (`WindowInsets.safeDrawing`) for login, chat list, session-check and chat screens. - Added bottom composer protection in chat screen with `navigationBarsPadding()` and `imePadding()`. - Fixed UI overlap with status bar and navigation bar on modern Android devices. ### Step 26 - Core base / bulk forward foundation - Added message API/data contracts for bulk forward (`POST /api/v1/messages/{message_id}/forward-bulk`). - Extended `MessageRepository` with `forwardMessageBulk(...)`. - Implemented bulk-forward flow in `NetworkMessageRepository` with Room/chat last-message updates. - Added `ForwardMessageBulkUseCase` for future multi-select message actions. - Updated message repository unit test fakes to cover new API surface. ### Step 27 - Core base / message action state machine - Added reusable `MessageActionState` reducer with explicit selection modes (`NONE`, `SINGLE`, `MULTI`). - Added action-intent contract for message operations (reply/edit/forward/delete/reaction/clear). - Integrated `ChatViewModel` with reducer-backed selection logic while preserving current UI behavior. - Added base ViewModel handlers for entering/toggling multi-select mode (`onEnterMultiSelect`, `onToggleMessageMultiSelection`, `onClearSelection`). - Added unit tests for reducer transitions and available intents (`MessageActionStateTest`). ### Step 28 - Core base / Android multi-forward execution - Switched chat forward state from single-message payload to `forwardingMessageIds` set. - Extended `ChatViewModel` forward flow: multi-select now forwards multiple source messages in one action. - Wired `ForwardMessageBulkUseCase` for multi-message forwarding (sequential safe execution with error short-circuit). - Updated chat action bar and forward sheet labels for multi-selection count. ### Step 29 - Core base / multi-select delete execution - Fixed multi-select delete behavior in `ChatViewModel`: `Delete` now applies to all selected messages, not only focused one. - Added explicit guard for `Delete for all` in multi-select mode (single-message only). ### Step 30 - Core base / reply-forward preview data foundation - Extended message DTO/Room/domain models with optional preview metadata: - `replyPreviewText`, `replyPreviewSenderName` - `forwardedFromDisplayName` - sender profile fields from API payload (`senderDisplayName`, `senderUsername`, `senderAvatarUrl`) - Added Room self-relation in `MessageLocalModel` to resolve reply preview fallback from referenced message. - Updated message mappers and repository/realtime temporary entity creation for new model fields. - Bumped Room schema version to `7`. ### Step 31 - Chat UI / reply-forward bubble blocks - Added inline forwarded header rendering in message bubbles with display-name fallback. - Added inline reply preview block in message bubbles (author + snippet) based on new preview fields/fallbacks. - Updated Telegram UI batch-2 checklist items for reply-preview and forwarded header. ### Step 32 - Chat UI / pinned message bar - Added `pinned_message_id` support in chat DTO/local/domain models and DAO selects. - Extended `ChatViewModel` state with pinned message id + resolved pinned message object. - Rendered pinned message bar under chat app bar with hide action. - Updated Telegram UI batch-2 checklist item for pinned message block. ### Step 33 - Chat UI / top app bar restructuring - Extended chat UI state with resolved chat header fields (`chatTitle`, `chatSubtitle`, `chatAvatarUrl`). - Updated chat top app bar layout to Telegram-like structure: back, avatar, title, status, call action, menu action. - Kept load-more behavior accessible via menu placeholder action button. - Updated Telegram UI batch-2 checklist item for chat top app bar. ### Step 34 - Chat UI / composer restyling - Reworked chat composer into rounded Telegram-like container with emoji slot, text input, attach button, and send/voice state button. - Preserved send/upload state guards and existing insets handling (`navigationBarsPadding` + `imePadding`). - Updated Telegram UI batch-2 checklist composer-related items. ### Step 35 - Chat UI / multi-select bars and overlays - Split message selection UX into dedicated top selection bar (count/close/delete/edit/reactions) and bottom action bar (reply/forward). - Enhanced selected bubble visual state with explicit selected marker text. - Updated Telegram UI batch-2 checklist items for multi-select mode. ### Step 36 - Chat list / advanced states baseline - Added chat-list local type filters (`All`, `People`, `Groups`, `Channels`) with new `ChatListFilter` UI state. - Added archive statistics stream in `ChatListViewModel` and special archive top-row entry in `All` tab. - Extended list preview formatting with media-type markers and retained unread/mention/pinned indicators. - Updated Telegram UI checklists for chat-list advanced states (batch 2 and batch 3). ### Step 37 - Chat UI / wallpaper-aware readability - Added gradient wallpaper-like chat background layer in `ChatScreen`. - Kept pinned/composer/action surfaces on semi-transparent containers to preserve readability over wallpaper. - Updated Telegram UI checklist items for wallpaper and overlay readability. ### Step 38 - Quality/docs / mapper fallback coverage - Added `MessageMappersTest` to verify reply preview fallback resolution from Room self-relation (`reply_to_message_id`). - Updated Android master checklist for completed chat list tabs/filters coverage. ### Step 39 - Android scope / remove calls UI - Removed chat top-bar `Call` action from Android `ChatScreen`. - Updated Android UI checklist wording to reflect chat header without calls support. ### Step 40 - Invite deep link flow (app links) - Added Android App Links intent filter for `https://chat.daemonlord.ru/join...`. - Added invite token extraction from incoming intents (`query token` and `/join/{token}` path formats). - Wired deep link token into `MessengerNavHost -> ChatListRoute -> ChatListViewModel` auto-join flow. - Removed manual `Invite token` input row from chat list screen. ### Step 41 - Chat UI / long-press action menu - Added long-press message action card in `ChatScreen` with quick reactions. - Added context actions from long-press: reply, edit, forward, delete, select, close. - Added placeholder disabled pin action in the menu to keep action set consistent with Telegram-like flow. - Updated Telegram UI batch-2 checklist items for long-press reactions and context menu. ### Step 42 - Chat list / row and FAB parity pass - Updated chat list rows with avatar rendering, trailing message time, and richer right-side metadata layout. - Kept unread/mention/pinned/muted indicators while aligning row structure closer to Telegram list pattern. - Added floating compose FAB placeholder at bottom-right in chat list screen. - Updated Telegram UI batch-2 checklist chat-list parity items. ### Step 43 - Chat list / floating bottom navigation shell - Added floating rounded bottom navigation container on chat list screen. - Added active tab visual state (Chats selected) with pill styling. - Updated Telegram UI checklists for bottom-nav shell parity (batch 1 and batch 2). ### Step 44 - Chat UI / bubble density pass - Updated message bubble shapes for incoming/outgoing messages to denser rounded Telegram-like contours. - Kept bottom-right time + delivery state rendering in bubble footer after time formatting update. - Updated Telegram UI batch-2 checklist item for message bubble parity. ### Step 45 - Chat UI / media bubble improvements - Added richer video attachment card rendering in message bubbles. - Added file-list style attachment rows (icon + filename + type/size metadata). - Upgraded non-voice audio attachment player with play/pause, progress bar, and current/total duration labels. - Updated Telegram UI batch-2 checklist media-bubble items. ### Step 46 - Media viewer / header and gallery navigation - Upgraded chat image viewer to use global image gallery state (`index / total`) instead of a single URL. - Added fullscreen viewer header with close, index, share placeholder, and delete placeholder actions. - Added image navigation controls (`Prev`/`Next`) for gallery traversal. - Updated Telegram UI batch-2 checklist for fullscreen media header support. ### Step 47 - Notifications foundation (FCM + channels + deep links) - Added Firebase Messaging dependency and Android manifest wiring for `POST_NOTIFICATIONS`. - Added notification channels (`messages`, `mentions`, `system`) with startup initialization in `MessengerApplication`. - Added push service (`MessengerFirebaseMessagingService`) + payload parser + notification dispatcher. - Added notification tap deep-link handling to open target chat from `MainActivity` via nav host. - Added runtime notification permission request flow (Android 13+) in `MessengerNavHost`. - Added parser unit test (`PushPayloadParserTest`). ### Step 48 - Foreground local notifications from realtime - Added `ActiveChatTracker` to suppress local notifications for currently opened chat. - Wired realtime receive-message handling to trigger local notification via `NotificationDispatcher` when chat is not active. - Added chat title lookup helper in `ChatDao` for notification titles. - Added explicit realtime stop in `ChatViewModel.onCleared()` to avoid stale collectors. ### Step 49 - Mention override for muted chats - Extended realtime receive-message model/parsing with `isMention` flag support. - Added muted-chat guard in realtime notification flow: muted chats stay silent unless message is a mention. - Routed mention notifications to mentions channel/priority via `NotificationDispatcher`. - Added parser unit test for mention-flag mapping. ### Step 50 - Notification settings storage (DataStore) - Added domain notification settings models/repository contracts (global + per-chat override). - Added `DataStoreNotificationSettingsRepository` with persistence for global flags and per-chat override mode. - Added `ShouldShowMessageNotificationUseCase` and wired realtime notifications through it. - Added unit tests for DataStore notification settings repository and notification visibility use case. ### Step 51 - Logout with full local cleanup - Added `LogoutUseCase` with centralized sign-out flow: disconnect realtime, clear active chat, clear auth session, and clear local cached data. - Added `SessionCleanupRepository` + `DefaultSessionCleanupRepository` to wipe Room tables and clear per-chat notification overrides. - Added logout action in chat list UI and wired it to `AuthViewModel`, with automatic navigation back to login via auth state. - Added unit tests for logout use case orchestration and notification override cleanup. ### Step 52 - Settings/Profile shell and logout relocation - Added dedicated `Settings` and `Profile` routes/screens with mobile-safe insets and placeholder content. - Removed direct logout action from chat list and moved logout action to `Settings`. - Wired bottom navigation pills in chats to open `Settings` and `Profile`. ### Step 53 - Secure token storage (Keystore-backed) - Added `EncryptedPrefsTokenRepository` backed by `EncryptedSharedPreferences` and Android `MasterKey` (Keystore). - Switched DI token binding from DataStore token repository to encrypted shared preferences repository. - Kept DataStore for non-token app settings and renamed preferences file to `messenger_preferences.preferences_pb`. ### Step 54 - Message interactions: tap menu vs long-press select - Updated chat message gesture behavior to match Telegram pattern: - tap opens contextual message menu with reactions/actions, - long-press enters multi-select mode directly. - Hid single-selection action bars while contextual menu is visible to avoid mixed UX states. - Improved multi-select visual affordance with per-message selection indicator circles. ### Step 55 - Chat multi-select action cleanup - Removed duplicate forward action in multi-select mode (`Forward selected`), leaving a single clear forward action button. ### Step 56 - Unified API error handling - Added shared API error mapper (`ApiErrorMapper`) with mode-aware mapping (`DEFAULT`, `LOGIN`). - Switched auth/chat/message/media repositories to a single `Throwable -> AppError` mapping source. - Kept login-specific invalid-credentials mapping while standardizing unauthorized/server/network handling for other API calls. ### Step 57 - Offline-first message history reading - Added paged local history reading path by introducing configurable message observe limit (`observeMessages(chatId, limit)`). - Updated chat screen loading strategy to expand local Room-backed history first when loading older messages. - Added network-failure fallback in message sync/load-more: if network is unavailable but local cache exists, chat remains readable without blocking error. ### Step 58 - Keep authenticated session when offline at app start - Updated auth restore flow in `AuthViewModel`: network errors during session restore no longer force logout when local tokens exist. - App now opens authenticated flow in offline mode instead of redirecting to login. ### Step 59 - Deferred message action queue (send/edit/delete) - Added Room-backed pending action queue (`pending_message_actions`) for message operations that fail due to network issues. - Implemented enqueue + optimistic behavior for `sendText`, `editMessage`, and `deleteMessage` on network failures. - Added automatic pending-action flush on chat sync/load-more and before new message operations. - Kept non-network server failures as immediate errors (no queueing), while allowing offline continuation. ### Step 60 - Media cache foundation (Coil + Exo cache) - Added global Coil image loader cache policy in `MessengerApplication` (memory + disk cache). - Added Media3 `SimpleCache` singleton module for media stream/file caching foundation. - Added Media3/Coil core dependencies and configured cache sizes for mobile usage. ### Step 61 - Compose UI tests baseline - Added instrumented Compose UI tests for login and chat list states. - Added Android test dependencies for Compose test runner (`ui-test-junit4`) and test infra. - Covered key visual states: auth error rendering, chat list loading state, and empty state. ### Step 62 - Android CI pipeline - Added dedicated Android CI workflow for `main` branch and PRs. - CI now runs Android build, unit tests, lint, and androidTest assemble. - Added optional detekt execution step (auto-skipped when detekt task is not configured). ### Step 63 - Integration tests for auth/chat/realtime - Kept repository-level integration coverage for auth/chat data flows (MockWebServer + in-memory storage). - Added `RealtimePipelineIntegrationTest` to validate realtime event handling pipeline (`receive_message` -> Room state update). - Consolidated quality checklist integration test coverage for auth/chat/realtime. ### Step 64 - Android release workflow - Added dedicated release workflow (`.github/workflows/android-release.yml`) for `main` branch pushes. - Adapted version extraction for Kotlin DSL (`android/app/build.gradle.kts`) and guarded release by existing git tag. - Wired release build, git tag push, and Gitea release publication with APK artifact upload.