Skip to content

Colota - Android GPS Location tracker

Add F-Droid support with GMS and FOSS build flavors

Max Dietrich77a803b905f3
diff --git a/.github/workflows/build-latest-release.yml b/.github/workflows/build-latest-release.yml
index c68bb25f..6d29e8be 100644
--- a/.github/workflows/build-latest-release.yml
+++ b/.github/workflows/build-latest-release.yml
@@ -1,6 +1,16 @@
name: Build Latest Release
on:
+ push:
+ branches:
+ - main
+ paths-ignore:
+ - '**.md'
+ - 'apps/docs/**'
+ - 'screenshots/**'
+ - 'LICENSE'
+ - '.github/workflows/docs-*'
+ - '.github/workflows/build-release.yml'
workflow_dispatch:
concurrency:
@@ -81,11 +91,19 @@ jobs:
test -n "${{ secrets.KEY_ALIAS }}" || exit 1
test -n "${{ secrets.KEY_PASSWORD }}" || exit 1
- - name: Build Release APK
+ - name: Build GMS Release APK
run: |
cd apps/mobile/android
chmod +x gradlew
- ./gradlew assembleRelease --no-daemon \
+ ./gradlew assembleGmsRelease --no-daemon \
+ -PhermesEnabled=true \
+ -Pandroid.useAndroidX=true \
+ -Dorg.gradle.jvmargs="-Xmx4096m -XX:MaxMetaspaceSize=512m"
+
+ - name: Build FOSS Release APK
+ run: |
+ cd apps/mobile/android
+ ./gradlew assembleFossRelease --no-daemon \
-PhermesEnabled=true \
-Pandroid.useAndroidX=true \
-Dorg.gradle.jvmargs="-Xmx4096m -XX:MaxMetaspaceSize=512m"
@@ -103,12 +121,16 @@ jobs:
tag_name: latest
name: "Latest Development Build"
body: |
- ## πŸš€ Automated Build (Tests Passed βœ…)
+ ## Automated Build (Tests Passed)
Built from commit: `${{ github.sha }}`
+
+ **app-gms-release.apk** β€” Google Play Services variant
+ **app-foss-release.apk** β€” F-Droid / FOSS variant (no Google Play Services)
draft: false
prerelease: true
files: |
- apps/mobile/android/app/build/outputs/apk/release/app-release.apk
+ apps/mobile/android/app/build/outputs/apk/gms/release/app-gms-release.apk
+ apps/mobile/android/app/build/outputs/apk/foss/release/app-foss-release.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml
index 1f213e35..42778c00 100644
--- a/.github/workflows/build-release.yml
+++ b/.github/workflows/build-release.yml
@@ -86,15 +86,32 @@ jobs:
test -n "${{ secrets.KEY_ALIAS }}" || exit 1
test -n "${{ secrets.KEY_PASSWORD }}" || exit 1
- - name: Build Release APK
+ - name: Build GMS Release APK
run: |
cd apps/mobile/android
chmod +x gradlew
- ./gradlew assembleRelease --no-daemon \
+ ./gradlew assembleGmsRelease --no-daemon \
-PhermesEnabled=true \
-Pandroid.useAndroidX=true \
-Dorg.gradle.jvmargs="-Xmx4096m -XX:MaxMetaspaceSize=512m"
+ - name: Build FOSS Release APK
+ run: |
+ cd apps/mobile/android
+ ./gradlew assembleFossRelease --no-daemon \
+ -PhermesEnabled=true \
+ -Pandroid.useAndroidX=true \
+ -Dorg.gradle.jvmargs="-Xmx4096m -XX:MaxMetaspaceSize=512m"
+
+ - name: Publish to GitHub Release
+ uses: softprops/action-gh-release@v2
+ with:
+ files: |
+ apps/mobile/android/app/build/outputs/apk/gms/release/app-gms-release.apk
+ apps/mobile/android/app/build/outputs/apk/foss/release/app-foss-release.apk
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
- name: Secure Cleanup
if: always()
run: |
diff --git a/README.md b/README.md
index ee86cb14..e92150fc 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
Colota sends your location to your own server over HTTP(S). It works offline, supports geofencing, and doesn't share any data except with your backends.
-[Documentation](https://colota.app/docs/introduction) | [Google Play](https://play.google.com/store/apps/details?id=com.Colota&hl=en-US) | [Privacy Policy](https://colota.app/privacy-policy)
+[Google Play](https://play.google.com/store/apps/details?id=com.Colota&hl=en-US) | [F-Droid](https://f-droid.org/packages/com.Colota/) | [Documentation](https://colota.app/docs/introduction) | [Privacy Policy](https://colota.app/privacy-policy)
## Features
@@ -38,7 +38,7 @@ Colota sends your location to your own server over HTTP(S). It works offline, su
## Quick Start
```bash
-# Install from Google Play or download APK from Releases
+# Install from Google Play, F-Droid, or download APK from Releases
# Then:
1. Grant location permissions (precise, all the time)
2. Disable battery optimization for Colota
@@ -60,7 +60,8 @@ git clone https://github.com/dietrichmax/colota.git
cd colota
npm install
cd apps/mobile/android
-gradlew assembleRelease # or ./gradlew on Linux/macOS
+./gradlew assembleGmsRelease # Google Play variant
+./gradlew assembleFossRelease # F-Droid variant (no Google Play Services)
```
## Contributing
diff --git a/apps/docs/docs/contributing.md b/apps/docs/docs/contributing.md
index f7abfd2f..4ec07480 100644
--- a/apps/docs/docs/contributing.md
+++ b/apps/docs/docs/contributing.md
@@ -28,6 +28,11 @@ See the [Development Guide](/docs/development/architecture) for architecture det
- **Kotlin** for native Android modules
- Follow existing patterns in the codebase
- Use `logger` instead of `console.log` β€” import from `src/utils/logger`
+- Test both build flavors if your changes touch native code:
+ ```bash
+ cd apps/mobile/android
+ ./gradlew assembleGmsDebug assembleFossDebug
+ ```
- Run before submitting:
```bash
npm run lint -w @colota/mobile
diff --git a/apps/docs/docs/development/architecture.md b/apps/docs/docs/development/architecture.md
index 9958d8cb..ea20eff8 100644
--- a/apps/docs/docs/development/architecture.md
+++ b/apps/docs/docs/development/architecture.md
@@ -46,7 +46,11 @@ The mobile app has a **React Native** UI layer and **native Kotlin** modules for
## Native Kotlin Modules
-All native code lives in `apps/mobile/android/app/src/main/java/com/colota/`, organized into sub-packages: `bridge/`, `service/`, `data/`, `sync/`, and `util/`.
+All native code lives in `apps/mobile/android/app/src/`, organized by build flavor:
+
+- `src/main/java/com/colota/` β€” Shared code: `bridge/`, `service/`, `data/`, `sync/`, `util/`, `location/` (interface)
+- `src/gms/java/com/colota/location/` β€” Google Play Services location provider
+- `src/foss/java/com/colota/location/` β€” Native Android location provider
### LocationServiceModule
@@ -65,11 +69,20 @@ Emits events back to JavaScript:
- `onSyncError` β€” 3+ consecutive sync failures
- `onPauseZoneChange` β€” entered or exited a geofence pause zone
+### LocationProvider Abstraction
+
+Location services are abstracted behind a `LocationProvider` interface (`location/LocationProvider.kt`), with flavor-specific implementations:
+
+- **GMS** (`src/gms/`) β€” `GmsLocationProvider` wraps Google Play Services `FusedLocationProviderClient`
+- **FOSS** (`src/foss/`) β€” `NativeLocationProvider` wraps Android's native `LocationManager` with `GPS_PROVIDER`
+
+Each flavor provides a `LocationProviderFactory` that returns the correct implementation. The service and bridge code in `src/main/` uses only the interface.
+
### LocationForegroundService
An Android foreground service that runs continuously for GPS tracking. Manages:
-- GPS location capture via Google Play Services
+- GPS location capture via the `LocationProvider` abstraction
- Foreground notification (required by Android)
- Pause zone detection (geofencing)
- Location accuracy filtering
diff --git a/apps/docs/docs/development/local-setup.md b/apps/docs/docs/development/local-setup.md
index f26994c4..73117447 100644
--- a/apps/docs/docs/development/local-setup.md
+++ b/apps/docs/docs/development/local-setup.md
@@ -55,6 +55,25 @@ npx react-native run-android
Or open `apps/mobile/android/` in Android Studio and run from there.
+### Build Flavors
+
+The app has two product flavors:
+
+| Flavor | Description | Location Provider |
+| ------ | ------------------- | -------------------------------------------------- |
+| `gms` | Google Play variant | FusedLocationProviderClient (Google Play Services) |
+| `foss` | F-Droid variant | Native LocationManager (no Google dependencies) |
+
+Build commands:
+
+```bash
+npm run android:debug # GMS debug (default)
+npm run android:debug:foss # FOSS debug
+npm run android:release # GMS release
+npm run android:release:foss # FOSS release
+npm run android:release:all # Both release APKs
+```
+
### Environment Variables
The app reads build configuration from `apps/mobile/android/app/build.gradle`. Key settings:
@@ -62,7 +81,7 @@ The app reads build configuration from `apps/mobile/android/app/build.gradle`. K
| Property | Default | Description |
| ------------------- | ------------ | -------------------------- |
| `applicationId` | `com.Colota` | Android package identifier |
-| `minSdkVersion` | 24 | Minimum Android 7.0 |
+| `minSdkVersion` | 26 | Minimum Android 8.0 |
| `targetSdkVersion` | 36 | Target Android 16 |
| `compileSdkVersion` | 36 | Compile against Android 16 |
@@ -89,14 +108,16 @@ colota/
β”œβ”€β”€ apps/
β”‚ β”œβ”€β”€ mobile/
β”‚ β”‚ β”œβ”€β”€ android/ # Android native project
-β”‚ β”‚ β”‚ └── app/src/main/java/com/colota/
-β”‚ β”‚ β”‚ β”œβ”€β”€ bridge/ # React Native bridge
-β”‚ β”‚ β”‚ β”œβ”€β”€ service/ # Foreground service & config
-β”‚ β”‚ β”‚ β”œβ”€β”€ data/ # SQLite & geofencing
-β”‚ β”‚ β”‚ β”œβ”€β”€ sync/ # Network sync & payloads
-β”‚ β”‚ β”‚ β”œβ”€β”€ util/ # Helpers & encryption
-β”‚ β”‚ β”‚ β”œβ”€β”€ MainActivity.kt
-β”‚ β”‚ β”‚ └── MainApplication.kt
+β”‚ β”‚ β”‚ └── app/src/
+β”‚ β”‚ β”‚ β”œβ”€β”€ main/java/com/colota/
+β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ bridge/ # React Native bridge
+β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ service/ # Foreground service & config
+β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ data/ # SQLite & geofencing
+β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ sync/ # Network sync & payloads
+β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ util/ # Helpers & encryption
+β”‚ β”‚ β”‚ β”‚ └── location/ # LocationProvider interface
+β”‚ β”‚ β”‚ β”œβ”€β”€ gms/java/com/colota/location/ # GMS implementation
+β”‚ β”‚ β”‚ └── foss/java/com/colota/location/ # Native implementation
β”‚ β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”‚ β”œβ”€β”€ screens/ # 9 app screens
β”‚ β”‚ β”‚ β”œβ”€β”€ components/ # UI and feature components
diff --git a/apps/docs/docs/faq.md b/apps/docs/docs/faq.md
index 77769e20..d5b1d3db 100644
--- a/apps/docs/docs/faq.md
+++ b/apps/docs/docs/faq.md
@@ -18,7 +18,9 @@ No, but you can use [Dawarich](/docs/integrations/dawarich) or a custom backend
### Does this work without Google Play Services?
-Not currently. Colota uses Android's `FusedLocationProvider` which requires Google Play Services.
+Yes. The **FOSS variant** (available on F-Droid and GitHub Releases) uses Android's native `LocationManager` and has no Google Play Services dependency. It works on LineageOS, GrapheneOS, CalyxOS, and any ROM without Google services.
+
+The Google Play variant uses `FusedLocationProvider` for potentially better location accuracy through Wi-Fi and cell tower fusion.
### Why AGPL-3.0?
diff --git a/apps/docs/docs/getting-started/build-from-source.md b/apps/docs/docs/getting-started/build-from-source.md
index e94b6fe0..f2a1fa27 100644
--- a/apps/docs/docs/getting-started/build-from-source.md
+++ b/apps/docs/docs/getting-started/build-from-source.md
@@ -17,14 +17,33 @@ git clone https://github.com/dietrichmax/colota.git
cd colota
npm install
cd apps/mobile/android
-gradlew assembleRelease # or ./gradlew on Linux/macOS
```
-The APK will be at `apps/mobile/android/app/build/outputs/apk/release/`.
+### GMS variant (Google Play Services)
+
+```bash
+./gradlew assembleGmsRelease
+```
+
+Output: `app/build/outputs/apk/gms/release/app-gms-release.apk`
+
+### FOSS variant (no Google Play Services)
+
+```bash
+./gradlew assembleFossRelease
+```
+
+Output: `app/build/outputs/apk/foss/release/app-foss-release.apk`
+
+### Build both
+
+```bash
+./gradlew assembleGmsRelease assembleFossRelease
+```
## Development
-To run the app in development mode:
+To run the app in development mode (GMS variant by default):
```bash
cd colota
@@ -33,3 +52,5 @@ cd apps/mobile
npm start # Start Metro bundler
npm run android # Build and install on connected device
```
+
+Use `npm run android:debug:foss` to build and run the FOSS variant instead.
diff --git a/apps/docs/docs/getting-started/installation.md b/apps/docs/docs/getting-started/installation.md
index 156e5a53..e44016d6 100644
--- a/apps/docs/docs/getting-started/installation.md
+++ b/apps/docs/docs/getting-started/installation.md
@@ -6,12 +6,24 @@ sidebar_position: 1
## From Google Play
-The easiest way to install Colota:
-
[Get it on Google Play](https://play.google.com/store/apps/details?id=com.Colota&hl=en-US)
-## From Releases
+The Google Play version uses Google Play Services for location (FusedLocationProvider).
+
+## From F-Droid
+
+[Get it on F-Droid](https://f-droid.org/packages/com.Colota/)
+
+The F-Droid version uses Android's native LocationManager and has **no Google Play Services dependency**. This is the recommended option for devices running LineageOS, GrapheneOS, CalyxOS, or any ROM without Google services.
+
+## From GitHub Releases
1. Download the latest APK from [GitHub Releases](https://github.com/dietrichmax/colota/releases)
+ - **app-gms-release.apk** β€” Google Play Services variant
+ - **app-foss-release.apk** β€” FOSS variant (no Google Play Services)
2. Enable **Install from Unknown Sources** in Android settings
3. Install the APK
+
+## Build from Source
+
+See [Build from Source](/docs/getting-started/build-from-source) for instructions on building both variants locally.
diff --git a/apps/docs/docs/getting-started/quick-start.md b/apps/docs/docs/getting-started/quick-start.md
index 599fdce9..50c7fe3c 100644
--- a/apps/docs/docs/getting-started/quick-start.md
+++ b/apps/docs/docs/getting-started/quick-start.md
@@ -6,7 +6,7 @@ sidebar_position: 2
Minimal setup to start tracking:
-1. Install the app ([Google Play](https://play.google.com/store/apps/details?id=com.Colota&hl=en-US) or [APK](https://github.com/dietrichmax/colota/releases))
+1. Install the app ([Google Play](https://play.google.com/store/apps/details?id=com.Colota&hl=en-US), [F-Droid](https://f-droid.org/packages/com.Colota/), or [APK](https://github.com/dietrichmax/colota/releases))
2. Grant location permissions β€” select **Precise location** and **Allow all the time**
3. Disable battery optimization for Colota in Android settings
4. Press **Start Tracking**
diff --git a/apps/mobile/android/app/build.gradle b/apps/mobile/android/app/build.gradle
index 18dfb66d..4869b82a 100644
--- a/apps/mobile/android/app/build.gradle
+++ b/apps/mobile/android/app/build.gradle
@@ -21,7 +21,7 @@ react {
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
- // debuggableVariants = ["liteDebug", "prodDebug"]
+ debuggableVariants = ["gmsDebug", "fossDebug"]
/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
@@ -137,12 +137,25 @@ android {
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
+
+ flavorDimensions "distribution"
+
+ productFlavors {
+ gms {
+ dimension "distribution"
+ // Google Play Services variant
+ }
+ foss {
+ dimension "distribution"
+ // F-Droid / open-source variant β€” no Google Play Services
+ }
+ }
}
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
- implementation 'com.google.android.gms:play-services-location:21.0.1'
+ gmsImplementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
implementation 'androidx.security:security-crypto:1.1.0'
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/changelogs/14.txt b/apps/mobile/android/app/fastlane/metadata/android/en-US/changelogs/14.txt
new file mode 100644
index 00000000..5f2be6ae
--- /dev/null
+++ b/apps/mobile/android/app/fastlane/metadata/android/en-US/changelogs/14.txt
@@ -0,0 +1,4 @@
+- Added F-Droid support with FOSS variant (no Google Play Services)
+- Location tracking uses native Android LocationManager APIs
+- Added HTTP GET request support for Traccar and similar backends
+- Added Traccar and PhoneTrack API templates
\ No newline at end of file
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/full_description.txt b/apps/mobile/android/app/fastlane/metadata/android/en-US/full_description.txt
new file mode 100644
index 00000000..2608de1e
--- /dev/null
+++ b/apps/mobile/android/app/fastlane/metadata/android/en-US/full_description.txt
@@ -0,0 +1,16 @@
+Colota is an open-source GPS tracking application that sends your location to your own server over HTTP(S). It works offline, supports geofencing, and doesn't share any data except with your configured backends.
+
+<b>Features</b>
+
+<ul>
+<li><b>Self-Hosted</b> β€” Works with Dawarich, OwnTracks, PhoneTrack, Reitti, Traccar, or any custom backend that accepts JSON over HTTP</li>
+<li><b>Privacy First</b> β€” No analytics, no telemetry, no third-party SDKs. Licensed under AGPL-3.0</li>
+<li><b>Works Offline</b> β€” Locations are queued locally and synced when connectivity returns. Export as CSV, GeoJSON, GPX, or KML</li>
+<li><b>Reliable Tracking</b> β€” Foreground service with auto-start on boot, exponential backoff for failed syncs</li>
+<li><b>Geofencing</b> β€” Define pause zones to automatically stop tracking in specific areas</li>
+<li><b>Flexible Sync</b> β€” Instant send, periodic batch sync, or fully offline mode</li>
+<li><b>Authentication</b> β€” Basic Auth, Bearer Token, or custom headers with AES-256-GCM encryption</li>
+<li><b>Configurable</b> β€” Custom field mapping, update intervals, distance filters, and accuracy thresholds</li>
+</ul>
+
+The FOSS variant uses Android's native LocationManager and has no Google Play Services dependency.
\ No newline at end of file
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/images/icon.png b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/icon.png
new file mode 100644
index 00000000..4778902d
Binary files /dev/null and b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/icon.png differ
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png
new file mode 100644
index 00000000..2b16680c
Binary files /dev/null and b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png differ
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png
new file mode 100644
index 00000000..40a47145
Binary files /dev/null and b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png differ
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png
new file mode 100644
index 00000000..689f19b9
Binary files /dev/null and b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png differ
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png
new file mode 100644
index 00000000..23a867ad
Binary files /dev/null and b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png differ
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/5.png b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/5.png
new file mode 100644
index 00000000..6f8a6b85
Binary files /dev/null and b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/5.png differ
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/6.png b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/6.png
new file mode 100644
index 00000000..29d51576
Binary files /dev/null and b/apps/mobile/android/app/fastlane/metadata/android/en-US/images/phoneScreenshots/6.png differ
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/short_description.txt b/apps/mobile/android/app/fastlane/metadata/android/en-US/short_description.txt
new file mode 100644
index 00000000..ca496a86
--- /dev/null
+++ b/apps/mobile/android/app/fastlane/metadata/android/en-US/short_description.txt
@@ -0,0 +1 @@
+Self-hosted GPS tracking app with offline support and geofencing
\ No newline at end of file
diff --git a/apps/mobile/android/app/fastlane/metadata/android/en-US/title.txt b/apps/mobile/android/app/fastlane/metadata/android/en-US/title.txt
new file mode 100644
index 00000000..261ab21d
--- /dev/null
+++ b/apps/mobile/android/app/fastlane/metadata/android/en-US/title.txt
@@ -0,0 +1 @@
+Colota
\ No newline at end of file
diff --git a/apps/mobile/android/app/proguard-rules.pro b/apps/mobile/android/app/proguard-rules.pro
index d469b858..9180409b 100644
--- a/apps/mobile/android/app/proguard-rules.pro
+++ b/apps/mobile/android/app/proguard-rules.pro
@@ -13,8 +13,12 @@
-keep class com.Colota.** { *; }
-# Keep Google Play Services Location
+# Keep Google Play Services Location (only present in gms flavor)
-keep class com.google.android.gms.location.** { *; }
+-dontwarn com.google.android.gms.**
+
+# Keep location provider abstraction
+-keep class com.Colota.location.** { *; }
# Standard optimization settings
-dontwarn com.facebook.react.**
diff --git a/apps/mobile/android/app/src/foss/java/com/Colota/location/LocationProviderFactory.kt b/apps/mobile/android/app/src/foss/java/com/Colota/location/LocationProviderFactory.kt
new file mode 100644
index 00000000..52ff73f3
--- /dev/null
+++ b/apps/mobile/android/app/src/foss/java/com/Colota/location/LocationProviderFactory.kt
@@ -0,0 +1,16 @@
+/**
+ * Copyright (C) 2026 Max Dietrich
+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
+ */
+
+package com.Colota.location
+
+import android.content.Context
+
+/**
+ * Factory for the FOSS product flavor.
+ * Returns a LocationProvider backed by Android's native LocationManager.
+ */
+object LocationProviderFactory {
+ fun create(context: Context): LocationProvider = NativeLocationProvider(context)
+}
diff --git a/apps/mobile/android/app/src/foss/java/com/Colota/location/NativeLocationProvider.kt b/apps/mobile/android/app/src/foss/java/com/Colota/location/NativeLocationProvider.kt
new file mode 100644
index 00000000..cf97f084
--- /dev/null
+++ b/apps/mobile/android/app/src/foss/java/com/Colota/location/NativeLocationProvider.kt
@@ -0,0 +1,73 @@
+/**
+ * Copyright (C) 2026 Max Dietrich
+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
+ */
+
+package com.Colota.location
+
+import android.content.Context
+import android.location.Location
+import android.location.LocationListener
+import android.location.LocationManager
+import android.os.Bundle
+import android.os.Looper
+
+/**
+ * Location provider backed by Android's native LocationManager.
+ * Used in the FOSS product flavor (F-Droid distribution, no Google Play Services).
+ * Uses GPS_PROVIDER as primary (equivalent to PRIORITY_HIGH_ACCURACY).
+ */
+class NativeLocationProvider(context: Context) : LocationProvider {
+
+ private val locationManager: LocationManager =
+ context.getSystemService(Context.LOCATION_SERVICE) as LocationManager
+
+ private val listenerMap = mutableMapOf<LocationUpdateCallback, LocationListener>()
+
+ override fun requestLocationUpdates(
+ intervalMs: Long,
+ minDistanceMeters: Float,
+ looper: Looper,
+ callback: LocationUpdateCallback
+ ) {
+ val listener = object : LocationListener {
+ override fun onLocationChanged(location: Location) {
+ callback.onLocationUpdate(location)
+ }
+ override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {}
+ override fun onProviderEnabled(provider: String) {}
+ override fun onProviderDisabled(provider: String) {}
+ }
+ listenerMap[callback] = listener
+
+ try {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ intervalMs,
+ minDistanceMeters,
+ listener,
+ looper
+ )
+ } catch (e: SecurityException) {
+ listenerMap.remove(callback)
+ throw e
+ }
+ }
+
+ override fun removeLocationUpdates(callback: LocationUpdateCallback) {
+ listenerMap.remove(callback)?.let { locationManager.removeUpdates(it) }
+ }
+
+ override fun getLastLocation(
+ onSuccess: (Location?) -> Unit,
+ onFailure: (Exception) -> Unit
+ ) {
+ try {
+ val location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER)
+ ?: locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)
+ onSuccess(location)
+ } catch (e: SecurityException) {
+ onFailure(e)
+ }
+ }
+}
diff --git a/apps/mobile/android/app/src/gms/java/com/Colota/location/GmsLocationProvider.kt b/apps/mobile/android/app/src/gms/java/com/Colota/location/GmsLocationProvider.kt
new file mode 100644
index 00000000..6a130f09
--- /dev/null
+++ b/apps/mobile/android/app/src/gms/java/com/Colota/location/GmsLocationProvider.kt
@@ -0,0 +1,67 @@
+/**
+ * Copyright (C) 2026 Max Dietrich
+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
+ */
+
+package com.Colota.location
+
+import android.content.Context
+import android.location.Location
+import android.os.Looper
+import com.google.android.gms.location.*
+
+/**
+ * Location provider backed by Google Play Services FusedLocationProviderClient.
+ * Used in the GMS product flavor (Google Play distribution).
+ */
+class GmsLocationProvider(context: Context) : LocationProvider {
+
+ private val fusedClient: FusedLocationProviderClient =
+ LocationServices.getFusedLocationProviderClient(context)
+
+ private val callbackMap = mutableMapOf<LocationUpdateCallback, LocationCallback>()
+
+ override fun requestLocationUpdates(
+ intervalMs: Long,
+ minDistanceMeters: Float,
+ looper: Looper,
+ callback: LocationUpdateCallback
+ ) {
+ val gmsCallback = object : LocationCallback() {
+ override fun onLocationResult(result: LocationResult) {
+ result.locations.forEach { callback.onLocationUpdate(it) }
+ }
+ }
+ callbackMap[callback] = gmsCallback
+
+ val request = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, intervalMs * 2)
+ .setMinUpdateIntervalMillis(intervalMs)
+ .setMinUpdateDistanceMeters(minDistanceMeters)
+ .setMaxUpdateDelayMillis(intervalMs * 2)
+ .build()
+
+ try {
+ fusedClient.requestLocationUpdates(request, gmsCallback, looper)
+ } catch (e: SecurityException) {
+ callbackMap.remove(callback)
+ throw e
+ }
+ }
+
+ override fun removeLocationUpdates(callback: LocationUpdateCallback) {
+ callbackMap.remove(callback)?.let { fusedClient.removeLocationUpdates(it) }
+ }
+
+ override fun getLastLocation(
+ onSuccess: (Location?) -> Unit,
+ onFailure: (Exception) -> Unit
+ ) {
+ try {
+ fusedClient.lastLocation
+ .addOnSuccessListener { onSuccess(it) }
+ .addOnFailureListener { onFailure(it) }
+ } catch (e: SecurityException) {
+ onFailure(e)
+ }
+ }
+}
diff --git a/apps/mobile/android/app/src/gms/java/com/Colota/location/LocationProviderFactory.kt b/apps/mobile/android/app/src/gms/java/com/Colota/location/LocationProviderFactory.kt
new file mode 100644
index 00000000..7e093359
--- /dev/null
+++ b/apps/mobile/android/app/src/gms/java/com/Colota/location/LocationProviderFactory.kt
@@ -0,0 +1,16 @@
+/**
+ * Copyright (C) 2026 Max Dietrich
+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
+ */
+
+package com.Colota.location
+
+import android.content.Context
+
+/**
+ * Factory for the GMS product flavor.
+ * Returns a LocationProvider backed by Google Play Services.
+ */
+object LocationProviderFactory {
+ fun create(context: Context): LocationProvider = GmsLocationProvider(context)
+}
diff --git a/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt b/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt
index 372cf2ae..c096684e 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt
@@ -20,7 +20,7 @@ import android.os.Build
import android.util.Log
import com.facebook.react.bridge.*
import com.facebook.react.modules.core.DeviceEventManagerModule
-import com.google.android.gms.location.LocationServices
+import com.Colota.location.LocationProviderFactory
import org.json.JSONObject
import kotlinx.coroutines.*
@@ -367,21 +367,24 @@ class LocationServiceModule(reactContext: ReactApplicationContext) :
@ReactMethod
fun checkCurrentPauseZone(promise: Promise) {
- val fusedClient = LocationServices.getFusedLocationProviderClient(reactApplicationContext)
-
+ val provider = LocationProviderFactory.create(reactApplicationContext)
+
try {
- fusedClient.lastLocation.addOnSuccessListener { loc ->
- if (loc == null) {
- promise.resolve(null)
- } else {
- executeAsync(promise) {
- geofenceHelper.getPauseZone(loc)
+ provider.getLastLocation(
+ onSuccess = { loc ->
+ if (loc == null) {
+ promise.resolve(null)
+ } else {
+ executeAsync(promise) {
+ geofenceHelper.getPauseZone(loc)
+ }
}
+ },
+ onFailure = { e ->
+ Log.e(TAG, "Failed to get location for pause zone check", e)
+ promise.resolve(null)
}
- }.addOnFailureListener { e ->
- Log.e(TAG, "Failed to get location for pause zone check", e)
- promise.resolve(null)
- }
+ )
} catch (e: SecurityException) {
Log.e(TAG, "Location permission not granted", e)
promise.resolve(null)
diff --git a/apps/mobile/android/app/src/main/java/com/colota/location/LocationProvider.kt b/apps/mobile/android/app/src/main/java/com/colota/location/LocationProvider.kt
new file mode 100644
index 00000000..1ffe64ff
--- /dev/null
+++ b/apps/mobile/android/app/src/main/java/com/colota/location/LocationProvider.kt
@@ -0,0 +1,55 @@
+/**
+ * Copyright (C) 2026 Max Dietrich
+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
+ */
+
+package com.Colota.location
+
+import android.location.Location
+import android.os.Looper
+
+/**
+ * Abstraction over platform location services.
+ * Implementations: GmsLocationProvider (Google Play), NativeLocationProvider (FOSS).
+ */
+interface LocationProvider {
+
+ /**
+ * Request continuous location updates.
+ *
+ * @param intervalMs Desired update interval in milliseconds.
+ * @param minDistanceMeters Minimum distance between updates in meters.
+ * @param looper Looper on which callbacks are dispatched.
+ * @param callback Receives each location update.
+ */
+ fun requestLocationUpdates(
+ intervalMs: Long,
+ minDistanceMeters: Float,
+ looper: Looper,
+ callback: LocationUpdateCallback
+ )
+
+ /**
+ * Stop receiving location updates for the given callback.
+ */
+ fun removeLocationUpdates(callback: LocationUpdateCallback)
+
+ /**
+ * Asynchronously retrieve the last known location.
+ *
+ * @param onSuccess Called with the location, or null if unavailable.
+ * @param onFailure Called if the request fails entirely.
+ */
+ fun getLastLocation(
+ onSuccess: (Location?) -> Unit,
+ onFailure: (Exception) -> Unit
+ )
+}
+
+/**
+ * Callback interface for location updates.
+ * Each implementation wraps this into its platform-specific listener.
+ */
+interface LocationUpdateCallback {
+ fun onLocationUpdate(location: Location)
+}
diff --git a/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.kt b/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.kt
index 1604940f..5d3c614e 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/service/LocationForegroundService.kt
@@ -21,7 +21,9 @@ import android.content.Intent
import android.os.*
import android.util.Log
import androidx.core.app.NotificationCompat
-import com.google.android.gms.location.*
+import com.Colota.location.LocationProvider
+import com.Colota.location.LocationProviderFactory
+import com.Colota.location.LocationUpdateCallback
import kotlinx.coroutines.*
import org.json.JSONObject
@@ -30,7 +32,7 @@ import org.json.JSONObject
*/
class LocationForegroundService : Service() {
- private lateinit var fusedLocationClient: FusedLocationProviderClient
+ private lateinit var locationProvider: LocationProvider
private lateinit var notificationManager: NotificationManager
private lateinit var dbHelper: DatabaseHelper
private lateinit var payloadBuilder: PayloadBuilder
@@ -41,7 +43,7 @@ class LocationForegroundService : Service() {
private lateinit var syncManager: SyncManager
@Volatile private var serviceScope: CoroutineScope? = null
- @Volatile private var locationCallback: LocationCallback? = null
+ @Volatile private var locationUpdateCallback: LocationUpdateCallback? = null
private var insidePauseZone = false
private var currentZoneName: String? = null
private var lastNotificationText: String? = null
@@ -70,7 +72,7 @@ class LocationForegroundService : Service() {
serviceScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
- fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
+ locationProvider = LocationProviderFactory.create(this)
notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
dbHelper = DatabaseHelper.getInstance(this)
payloadBuilder = PayloadBuilder()
@@ -169,11 +171,12 @@ class LocationForegroundService : Service() {
override fun onBind(intent: Intent?): IBinder? = null
private fun setupLocationUpdates() {
- locationCallback = object : LocationCallback() {
- override fun onLocationResult(result: LocationResult) {
- result.locations.forEach { handleLocationUpdate(it) }
+ val callback = object : LocationUpdateCallback {
+ override fun onLocationUpdate(location: android.location.Location) {
+ handleLocationUpdate(location)
}
}
+ locationUpdateCallback = callback
if (deviceInfoHelper.isBatteryCritical(threshold = 5)) {
val (level, _) = deviceInfoHelper.getCachedBatteryStatus()
@@ -184,32 +187,30 @@ class LocationForegroundService : Service() {
return
}
- val locationRequest = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, config.interval * 2)
- .setMinUpdateIntervalMillis(config.interval)
- .setMinUpdateDistanceMeters(config.minUpdateDistance)
- .setMaxUpdateDelayMillis(config.interval * 2)
- .build()
-
try {
- fusedLocationClient.requestLocationUpdates(
- locationRequest,
- locationCallback!!,
- Looper.getMainLooper()
+ locationProvider.requestLocationUpdates(
+ intervalMs = config.interval,
+ minDistanceMeters = config.minUpdateDistance,
+ looper = Looper.getMainLooper(),
+ callback = callback
)
-
- fusedLocationClient.lastLocation.addOnSuccessListener { location ->
- location?.let {
- lastKnownLocation = it
-
- // Check if starting in a pause zone
- geofenceHelper.getPauseZone(it)?.let { zoneName ->
- enterPauseZone(zoneName)
- } ?: run {
- // Not in zone - show coordinates immediately
- updateNotification(it.latitude, it.longitude, forceUpdate = true)
+
+ locationProvider.getLastLocation(
+ onSuccess = { location ->
+ location?.let {
+ lastKnownLocation = it
+
+ // Check if starting in a pause zone
+ geofenceHelper.getPauseZone(it)?.let { zoneName ->
+ enterPauseZone(zoneName)
+ } ?: run {
+ // Not in zone - show coordinates immediately
+ updateNotification(it.latitude, it.longitude, forceUpdate = true)
+ }
}
- }
- }
+ },
+ onFailure = { /* initial location unavailable, updates will arrive */ }
+ )
} catch (e: SecurityException) {
Log.e(TAG, "Location permission missing", e)
stopSelf()
@@ -217,8 +218,8 @@ class LocationForegroundService : Service() {
}
private fun stopLocationUpdates() {
- locationCallback?.let { fusedLocationClient.removeLocationUpdates(it) }
- locationCallback = null
+ locationUpdateCallback?.let { locationProvider.removeLocationUpdates(it) }
+ locationUpdateCallback = null
}
private fun handleZoneRecheckAction() {
@@ -232,26 +233,29 @@ class LocationForegroundService : Service() {
recheckZoneWithLocation(cachedLoc)
} else {
// Otherwise, request the last known location from the provider
- fusedLocationClient.lastLocation.addOnSuccessListener { location ->
- location?.let {
- lastKnownLocation = it
- recheckZoneWithLocation(it)
- } ?: run {
- // No location available - if in zone, exit it
- if (insidePauseZone) {
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "No location for recheck, forcing exit from zone")
+ locationProvider.getLastLocation(
+ onSuccess = { location ->
+ if (location != null) {
+ lastKnownLocation = location
+ recheckZoneWithLocation(location)
+ } else {
+ // No location available - if in zone, exit it
+ if (insidePauseZone) {
+ if (BuildConfig.DEBUG) {
+ Log.d(TAG, "No location for recheck, forcing exit from zone")
+ }
+ exitPauseZone()
}
+ }
+ },
+ onFailure = { e ->
+ Log.e(TAG, "Recheck error", e)
+ // On error, also exit zone if in one
+ if (insidePauseZone) {
exitPauseZone()
}
}
- }.addOnFailureListener { e ->
- Log.e(TAG, "Recheck error", e)
- // On error, also exit zone if in one
- if (insidePauseZone) {
- exitPauseZone()
- }
- }
+ )
}
}
@@ -551,7 +555,7 @@ class LocationForegroundService : Service() {
notificationManager.notify(NOTIFICATION_ID, finalNotification)
- locationCallback?.let { fusedLocationClient.removeLocationUpdates(it) }
+ locationUpdateCallback?.let { locationProvider.removeLocationUpdates(it) }
stopSelf()
}
diff --git a/apps/mobile/android/build.gradle b/apps/mobile/android/build.gradle
index 4586beb8..8e5363e0 100644
--- a/apps/mobile/android/build.gradle
+++ b/apps/mobile/android/build.gradle
@@ -1,7 +1,7 @@
buildscript {
ext {
buildToolsVersion = "36.0.0"
- minSdkVersion = 24
+ minSdkVersion = 26
compileSdkVersion = 36
targetSdkVersion = 36
ndkVersion = "29.0.14206865"
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index 6884149f..b514ac82 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -4,15 +4,18 @@
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
- "android:debug": "cd android && gradlew assembleDebug",
- "android:release": "cd android && gradlew assembleRelease",
- "android:bundle": "cd android && gradlew bundleRelease",
+ "android:debug": "cd android && gradlew assembleGmsDebug",
+ "android:debug:foss": "cd android && gradlew assembleFossDebug",
+ "android:release": "cd android && gradlew assembleGmsRelease",
+ "android:release:foss": "cd android && gradlew assembleFossRelease",
+ "android:release:all": "cd android && gradlew assembleGmsRelease assembleFossRelease",
+ "android:bundle": "cd android && gradlew bundleGmsRelease",
"clean": "cd android && gradlew clean",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"test": "jest --passWithNoTests",
"test:coverage": "jest --coverage",
- "deploy-release": "adb install android/app/build/outputs/apk/release/app-release.apk",
- "deploy-bundle": "adb install android/app/build/outputs/bundle/release/app-release.aab"
+ "deploy-release": "adb install android/app/build/outputs/apk/gms/release/app-gms-release.apk",
+ "deploy-release:foss": "adb install android/app/build/outputs/apk/foss/release/app-foss-release.apk"
},
"dependencies": {
"@colota/shared": "*",