Implemented `UserRepository` and `ExpenseShareRepository` to handle data fetching with a caching strategy (local DAO + remote API).
Specific changes include:
- Added `getUserById` to `UserDao` and updated `getShareById` in `ExpenseShareDao` to support nullable returns.
- Updated `APIService` and `ComDataTypes` to include endpoints and data models for User info, Expense Shares, and pluralized Expense responses.
- Refactored `ExpenseRepository` to use the updated API naming conventions and removed debug print statements.
The `ExpenseRepository` was introduced to handle data fetching with a caching strategy, utilizing a new `Resource` sealed class to represent Loading, Success, and Error states.
Key changes include:
- Added `ExpenseRepository` to manage data flow between the local database and remote API.
- Updated `MainViewModel` to use the repository and expose expenses via a `StateFlow<Resource<List<Expense>>>`.
- Enhanced Room entities (`Expense`, `ExpenseShare`, `User`) with `@PrimaryKey` annotations and added a `Converters` class to handle `List<String>` types.
- Expanded `AppDatabase` to include DAOs for `Expense`, `ExpenseShare`, and `User`.
- Updated `DashboardScreen` to reactively display loading indicators, error messages, and cached/remote expense data.
The login screen now labels the server input as "Server-Domain", and the network provider has been updated to automatically prepend the HTTPS protocol. The database version has been incremented, and a network security configuration has been added to allow user certificates for debugging. Additionally, the encrypted shared preferences storage name was updated.
The `Expense` entity and its associated API endpoints have been updated, and a new `ExpenseShare` entity with a corresponding DAO has been added.
The `MainViewModel` now includes logic to fetch expenses from the server upon successful session validation. The `DashboardScreen` has been updated to display a list of expenses using a `LazyColumn` and a new `ExpenseItem` component. Additionally, the `APIService` has been expanded to include CRUD operations for expenses and user information.
The `RefreshResponse` data class has been updated to use `access_token` and `refresh_token` to match the API response. Consequently, `MainViewModel` now uses these updated field names when saving new tokens to storage. Debug print statements for access and refresh tokens have also been removed.
The manifest has been simplified by removing unused namespace declarations and redundant activity labels. Extraneous whitespace and empty lines were also removed for better readability.
The UI logic from `MainActivity.kt` has been moved into a new `AppContent` composable, and individual screens (`LoginScreen`, `DashboardScreen`, `AccountSelectionScreen`) have been extracted to their own files within the `ui.screens` package.
Additional changes:
- Updated `MainActivity` to use the new `AppContent` structure and handled back navigation for new account logins.
- Fixed a field name mismatch in `RefreshRequest` within `APIService.kt`, changing `refreshToken` to `refresh_token`.
- Minor formatting update in `README.md`.
The `.gitignore` file has been reorganized and expanded to include standard exclusions for build artifacts, Kotlin/Java project files, Android Studio metadata, keys/secrets, and OS-generated files.
The `LoginViewModel` now trims whitespace from usernames during the login request and account creation process.
The `.gitignore` file has been updated to exclude `.jks` files and the `/app/release` directory.
Added a `SessionState` sealed class to track the connection status and integrated it into the `DashboardScreen`. The dashboard now triggers a session validation on launch, showing a loading indicator during the check.
The `MainViewModel` has been updated with a `validateSession` function that:
- Pings the server using the stored access token.
- Attempts to refresh the token if a 401 Unauthorized response is received.
- Updates the `TokenStorage` with new tokens upon successful refresh.
- Redirects to logout if both tokens are invalid.
Additionally, the `APIService` was expanded with `ping` and `refresh` endpoints, and the `AppDatabase` version was incremented.
MainViewModel now accepts a `TokenStorage` instance. When an account is deleted, its associated tokens are now cleared from storage. MainActivity has been updated to initialize and provide the `TokenStorage` to the view model.
The Dashboard now includes a "Löschen" (Delete) button that allows users to remove the currently selected account via the `MainViewModel`.
The login process has been updated to convert usernames to lowercase before authentication to ensure consistency. Additionally, spacing adjustments were made to the Dashboard UI layout.
The app now supports adding a new account without logging out of the current session. A `BackHandler` has been implemented in the `LoginScreen` and `DashboardScreen` to improve navigation flow, and the `LoginScreen` now accepts an optional `onBack` callback.
The CC0 1.0 Universal license has been added to the project. The `.gitignore` configuration was consolidated by moving the `/app/build` exclusion to the root `.gitignore` and removing the redundant `app/.gitignore` file.
- Replaced mock login logic in `LoginViewModel` with actual API calls using Retrofit.
- Integrated `EncryptedSharedPreferences` via a new `TokenStorage` class to securely persist access and refresh tokens.
- Added `RetrofitProvider` and `APIService` to handle network requests and JSON serialization.
- Updated `Account` entity and database schema (version 2) to include user roles, enabling destructive migration for development.
- Added necessary internet permissions and allowed cleartext traffic in `AndroidManifest.xml`.
- Included dependencies for Retrofit, OkHttp logging, and AndroidX Security.
This commit introduces the `User` and `Expense` data classes as Room entities. Each entity is accompanied by its corresponding Data Access Object (DAO) with methods for `getAll`, `insert`, and `delete` operations.
Additionally, unused comments were removed from `MainViewModel` and an unnecessary preview was removed from `MainActivity`.
The login process has been expanded to include fields for Server URL, Username, and Password, replacing the previous User ID-only login.
The UI now utilizes `navigationBarsPadding` to prevent overlap with system navigation elements on the Login, Account Selection, and generic screens. The `Account` entity has been updated to include a `serverUrl`.