-
Notifications
You must be signed in to change notification settings - Fork 0
Mobile
- Android - OS
- Kotlin - Language
- Jetpack Compose - UI Building Framework
- Material - UI Design Framework
- Hilt - DI Framework
- Retrofit/OkHttp3 - Network communication
Mobile application (BLP Mini) is supposed to be a mini web version for employees. It has a core part of features which web application provides.
BLP Mini uses Data-UI-Domain architecture described in Android App Architecture guide. In short:
- The role of the UI layer (or presentation layer) is to display the application data on the screen.
- The data layer of an app contains the business logic
- The domain layer is an optional layer that sits between the UI and data layers. The domain layer is responsible for encapsulating complex business logic, or simple business logic that is reused by multiple ViewModels BLP Mini Data Layer BLP Mini Domain Layer BLP Mini Presentation Layer
BLP Mini uses Model-View-ViewModel pattern.
- Its principal advantage is that it caches state and persists it through configuration changes. This means that your UI doesn’t have to fetch data again when navigating between activities, or following configuration changes, such as when rotating the screen.
When users opens the application for the first time, a login screen will appear with a prompt to enter email and password. When pressing "login" button, a request is sent to the backend to acquire a JWT token which will be saved locally on phone. After this authentication process, authorization starts which sends another request to the backend to check whether user has Employee role or not.
If application is closed and then reopened, login screen will automatically start with authorization process and proceed to the main screen in case of success.
User's data is requested from the backend in order to fill and display Profile Data. The UI for Profile displaying is done. UI and business logic for changing data is yet to be developed.
UI for displaying available suppliers and filtering them is partially done. More UI and business logic to go.
It should be possible to check order history and confirm/decline an order from Orders screen. UI and business logic to go.
It should be possible to search for suppliers, categories and options.
It should be possible to receive important notifications.
Token is cached via SharedPreferences class which allows to use it on the next startup instead of logging once again. In case of an http unauthorized 401 exception, user is navigated to login screen and token gets removed.
AuthInterceptor.kt is responsible to attach Bearer to HTTP Authorization Header.
NetworkViewModel.kt may notify Views that user is not authorized
Application requires Internet connectivity. It automatically detects whether Internet is provided or not and blocks current screen with an alert. The following endpoints are being used for now (by Retrofit):
- /api/login
- /api/profile/details
- /api/profile
These are requested by Data Layer Sources
The only data that is cached is JWT token after succeccful authorization. In order to save any model in cache, SharedPreferencesSource.kt is used. TokenDiskSource.kt extends it and uses set(value) method to cache a token. To retrieve a token get() is used.
All other models are requested on demand and are not cached but saved in memory (until restart).
![](https://user-images.githubusercontent.com/46071888/230788210-c23c167b-8fab-40cf-ab44-ad003178d92b.png)
![](https://user-images.githubusercontent.com/46071888/230787905-4c3b0637-8f86-4660-92b7-0ecaa94a0bd9.png)
![](https://user-images.githubusercontent.com/46071888/230787894-e3f35120-df29-457a-b225-f9e67d59f2cb.png)
![](https://user-images.githubusercontent.com/46071888/230787901-baf7c024-9ac4-4a0d-82b2-b99e26fa1c7f.png)
![](https://user-images.githubusercontent.com/46071888/230787903-ccb43bd3-9bb1-465c-aaa1-146134dccfe0.png)
![](https://user-images.githubusercontent.com/46071888/230787909-cfbb7b72-a154-426d-bd2e-705b568896fd.png)
![](https://user-images.githubusercontent.com/46071888/230787918-c0f4b0f5-28d6-4bdb-a504-0b2f3429bed3.png)
![](https://user-images.githubusercontent.com/46071888/230787907-82ca67c4-4b1a-45ee-a28a-843ed6155831.png)
![](https://user-images.githubusercontent.com/46071888/230788215-30bd30af-ccc1-4978-ba4e-c95afa5cb804.png)
![](https://user-images.githubusercontent.com/46071888/230787916-62e9024b-a2bf-4762-9757-8fcf30b841b4.png)