Decentralized utility management made simple. Manage customers, revenues and assets with this all-in one open source platform.
MicroPowerManager (MPM) is a decentralized utility and customer management tool. Manage customers, revenues and assets with this all-in one Open Source platform.
This repository contains the source code for the MicroPowerManager Customer Registration App.
- Install Android Studio
- Git clone the repository
To build the app
-
Open the project in Android Studio
-
Configure
temurin-11as Gradle JDK.-
Open Setting (Android Studio > Settings > Build, Execution, Deployment > Build Tools > Gradle)
-
If not installed yet, select Download JDK... from the Gradle JDK dropdown and select
Field Value Version 11Vendor Eclipse Temurin AdoptOpenJDK HotSpotLocation <default>NOTE: For ideal performance be sure to select the correct architecture. For example for users of Mac's with M-chips select
aarch64. -
If already installed, select temurin-11 from the Gradle JDK dropdown
-
-
Click Sync Project with Gradle files
Run on a Device or Emulator:
- Minimum
minSdkVersionis 21 (Android 5.0). - The app uses location permissions, so ensure the emulator or device has Google Play Services and location set up.
To create a release APK locally
-
Open a terminal and confirm
$JAVE_HOMEis set correctly. -
Run
./gradlew assembleRelease
-
The output APK will be located at
app/build/outputs/apk/release
If you plan to develop and contribute a few additional steps are recommended
- Install Intellij ktlint Plugin
- Enable Intellij ktlint Plugin plugin.
- Open Setting (Android Studio > Settings > Tools > KtLint)
- Select
Mode > Distract free (recommended) - Select
Ruleset version > 1.5.0
- Install direnv
- Copy
.envrc.sampleto.envrcand adjustJAVA_HOME=to match the Gradle JDK path from above.
The app uses a single-activity, MVVM-based architecture with
- Koin for Dependency Injection
- Room for local persistence
- RxJava for reactive data flows.
- View Fragments/Activities handling UI interactions (e.g.,
AddCustomerFragment). - ViewModel Classes like
AddCustomerViewModelexpose data to the UI and orchestrate calls to repositories. - Repository / Model Data retrieval and business logic (e.g.,
AddCustomerRepository) using both Room (for local DB) and Retrofit (for network).
All dependencies (ViewModels, Repositories, Retrofit clients, etc.) are declared in Koin modules.
- Retrofit with qualifiers for Auth (
AuthNetworkModule) and No-Auth (NoAuthNetworkModule). - OkHttp interceptors handle logging, authorization headers, content-type, etc.
- Base URL can be changed dynamically using
SharedPreferenceWrapper.
- Local offline storage using Room (class:
InensusDatabase) with a single table for customers (CustomerDao). - Simple DAO operations (insert, update, delete, getCustomerList) in
CustomerDao.
MainActivityhosts all screens and toggles them with fragment transactions (show/hide).SplashActivityandLoginActivityare additional specialized activities (e.g., for onboarding/login).- Bottom Navigation is used to switch between major features in
MainActivity.
ConnectivityBroadcastReceivermonitors network changes and updatesConnectionChecker.SessionExpireBroadcastReceivertriggers forced logout if the user's session is invalid.
Below are the app's main features and their responsibilities:
- Purpose: Allows user to authenticate.
- Activity:
LoginActivity. - Data: Credentials stored via
SharedPreferenceWrapper.
- Purpose: Lets user create a new customer entry.
- Fragment:
AddCustomerFragment. - Implementation:
- Fetches additional data (manufacturer, meter types, etc.) if online.
- Stores the new customer in the local DB using
CustomerDao.
- Purpose: Displays customers stored locally.
- Fragment:
CustomerListFragment. - Implementation:
- Queries
CustomerDaofor all entries. - (Optionally) syncs local data with a remote server (if implemented).
- Queries
- Purpose: Works without internet.
- Tech: Room Database.
- Location:
InensusDatabase,CustomerDao.
- RxJava:
- Observed in
AddCustomerFragment,CustomerListFragment, etc. - Uses
CompositeDisposableinBaseViewModelfor cleanup.
- Observed in
- Deprecated APIs:
AsyncTaskfor DB inserts,GoogleApiClientfor location.- Migrate to coroutines and
FusedLocationProviderClientif maintaining long term.
- Permissions: Location permission is handled manually in
AddCustomerFragment.
- User opens Add Customer tab.
- App fetches needed reference data if online (meter types, tariffs, etc.).
- Location is requested and stored.
- User enters data; valid inputs are saved locally (in
CustomerDao).
- User taps Customer List tab.
- Locally stored customers are loaded and displayed.
- If desired, user can sync to a remote server (if connectivity is detected).
- If user's token is invalid, a broadcast triggers session logout.
- App shows alert and navigates to
LoginActivity.
