Skip to content

Colota - Android GPS Location tracker

feat: native-file-sharing

Max Dietrich7a433a89ab7c
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 2bad1557..7cb40f8d 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -80,5 +80,14 @@
</intent-filter>
</receiver>
+ <provider
+ android:name="androidx.core.content.FileProvider"
+ android:authorities="${applicationId}.fileprovider"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="android.support.FILE_PROVIDER_PATHS"
+ android:resource="@xml/file_paths" />
+ </provider>
</application>
</manifest>
diff --git a/android/app/src/main/java/com/locata/LocationBootReceiver.kt b/android/app/src/main/java/com/locata/BootReceiver.kt
similarity index 100%
rename from android/app/src/main/java/com/locata/LocationBootReceiver.kt
rename to android/app/src/main/java/com/locata/BootReceiver.kt
diff --git a/android/app/src/main/java/com/locata/BuildConfigModule.kt b/android/app/src/main/java/com/locata/BuildConfigModule.kt
index d8050889..04fde540 100644
--- a/android/app/src/main/java/com/locata/BuildConfigModule.kt
+++ b/android/app/src/main/java/com/locata/BuildConfigModule.kt
@@ -2,6 +2,7 @@
* Copyright (C) 2026 Max Dietrich
* Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
*/
+
package com.Colota
import com.facebook.react.bridge.ReactApplicationContext
diff --git a/android/app/src/main/java/com/locata/DeviceInfoHelper.kt b/android/app/src/main/java/com/locata/DeviceInfoHelper.kt
new file mode 100644
index 00000000..65b90982
--- /dev/null
+++ b/android/app/src/main/java/com/locata/DeviceInfoHelper.kt
@@ -0,0 +1,105 @@
+/**
+ * Copyright (C) 2026 Max Dietrich
+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
+ */
+
+package com.Colota
+
+import android.content.Context
+import android.content.Intent
+import android.net.Uri
+import android.os.Build
+import android.os.PowerManager
+import android.provider.Settings
+import android.util.Log
+import com.facebook.react.bridge.Arguments
+import com.facebook.react.bridge.WritableMap
+
+/**
+ * Helper class for device information, battery optimization, and permissions.
+ */
+class DeviceInfoHelper(private val context: Context) {
+
+ private val powerManager by lazy {
+ context.getSystemService(Context.POWER_SERVICE) as PowerManager
+ }
+
+ companion object {
+ private const val TAG = "DeviceInfoHelper"
+ }
+
+ // ============================================================================
+ // DEVICE INFORMATION
+ // ============================================================================
+
+ fun getDeviceInfo(): WritableMap {
+ return Arguments.createMap().apply {
+ putString("model", Build.MODEL)
+ putString("brand", Build.BRAND)
+ putString("manufacturer", Build.MANUFACTURER)
+ putString("device", Build.DEVICE)
+ putString("deviceId", Build.DEVICE)
+ putString("systemVersion", Build.VERSION.RELEASE)
+ putInt("apiLevel", Build.VERSION.SDK_INT)
+ }
+ }
+
+ fun getSystemVersion(): String = Build.VERSION.RELEASE
+
+ fun getApiLevel(): Int = Build.VERSION.SDK_INT
+
+ fun getModel(): String = Build.MODEL
+
+ fun getBrand(): String = Build.BRAND
+
+ fun getDeviceId(): String = Build.DEVICE
+
+ // ============================================================================
+ // BATTERY OPTIMIZATION
+ // ============================================================================
+
+ /**
+ * Checks if the app is exempt from battery optimization.
+ * @return true if exempt, false otherwise (or true on Android < M)
+ */
+ fun isIgnoringBatteryOptimizations(): Boolean {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ powerManager.isIgnoringBatteryOptimizations(context.packageName)
+ } else {
+ true // Battery optimization doesn't exist on older versions
+ }
+ }
+
+ /**
+ * Requests battery optimization exemption.
+ * Opens system settings dialog.
+ * @return true if dialog opened successfully, false if fallback used
+ */
+ fun requestIgnoreBatteryOptimizations(): Boolean {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
+ return true // Not applicable on older versions
+ }
+
+ return try {
+ val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).apply {
+ data = Uri.parse("package:${context.packageName}")
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ }
+ context.startActivity(intent)
+ true
+ } catch (e: Exception) {
+ Log.e(TAG, "Failed to open battery optimization settings", e)
+ // Fallback to general settings
+ try {
+ val fallbackIntent = Intent(Settings.ACTION_SETTINGS).apply {
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ }
+ context.startActivity(fallbackIntent)
+ false // Indicate fallback was used
+ } catch (e2: Exception) {
+ Log.e(TAG, "Failed to open general settings", e2)
+ throw e2 // Let caller handle this
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/android/app/src/main/java/com/locata/FileOperations.kt b/android/app/src/main/java/com/locata/FileOperations.kt
new file mode 100644
index 00000000..f5d90d0c
--- /dev/null
+++ b/android/app/src/main/java/com/locata/FileOperations.kt
@@ -0,0 +1,93 @@
+/**
+ * Copyright (C) 2026 Max Dietrich
+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.
+ */
+
+package com.Colota
+
+import android.content.Intent
+import android.net.Uri
+import androidx.core.content.FileProvider
+import com.facebook.react.bridge.*
+import java.io.File
+
+class FileOperations(private val context: ReactApplicationContext) {
+
+ /**
+ * Writes content to a file in the app's cache directory
+ * @param fileName Name of the file to create
+ * @param content Text content to write
+ * @return Full file path
+ */
+ fun writeFile(fileName: String, content: String): String {
+ val cacheDir = context.cacheDir
+ val file = File(cacheDir, fileName)
+ file.writeText(content)
+ return file.absolutePath
+ }
+
+ /**
+ * Shares a file using Android's native share sheet
+ * @param filePath Absolute path to the file
+ * @param mimeType MIME type of the file
+ * @param title Share dialog title
+ */
+ fun shareFile(filePath: String, mimeType: String, title: String) {
+ val file = File(filePath)
+ if (!file.exists()) {
+ throw IllegalArgumentException("File does not exist: $filePath")
+ }
+
+ val uri = FileProvider.getUriForFile(
+ context,
+ "${context.packageName}.fileprovider",
+ file
+ )
+
+ val intent = Intent(Intent.ACTION_SEND).apply {
+ type = mimeType
+ putExtra(Intent.EXTRA_STREAM, uri)
+ putExtra(Intent.EXTRA_SUBJECT, title)
+ addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ }
+
+ val chooser = Intent.createChooser(intent, title).apply {
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ }
+
+ context.startActivity(chooser)
+
+ // Schedule deletion after 30 seconds
+ android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
+ try {
+ if (file.exists()) {
+ file.delete()
+ if (BuildConfig.DEBUG) {
+ Log.d("FileOperations", "Cleaned up export file: ${file.name}")
+ }
+ }
+ } catch (e: Exception) {
+ Log.w("FileOperations", "Failed to cleanup file", e)
+ }
+ }, 30000)
+
+ return true
+ }
+
+ /**
+ * Deletes a file
+ * @param filePath Absolute path to the file
+ */
+ fun deleteFile(filePath: String) {
+ val file = File(filePath)
+ if (file.exists()) {
+ file.delete()
+ }
+ }
+
+ /**
+ * Gets the cache directory path
+ */
+ fun getCacheDirectory(): String = context.cacheDir.absolutePath
+}
\ No newline at end of file
diff --git a/android/app/src/main/java/com/locata/LocationServiceModule.kt b/android/app/src/main/java/com/locata/LocationServiceModule.kt
index 078153f5..520f4ae7 100644
--- a/android/app/src/main/java/com/locata/LocationServiceModule.kt
+++ b/android/app/src/main/java/com/locata/LocationServiceModule.kt
@@ -30,6 +30,8 @@ class LocationServiceModule(reactContext: ReactApplicationContext) :
private val locationUtils = LocationUtils(reactContext)
private val dbHelper = LocationDatabaseHelper.getInstance(reactContext)
+ private val fileOps = FileOperations(reactContext)
+ private val deviceInfo = DeviceInfoHelper(reactContext)
// Use a fixed thread pool instead of unlimited threads
private val dbExecutor: ExecutorService = if (Config.DB_THREAD_POOL_SIZE == 1) {
@@ -512,41 +514,22 @@ class LocationServiceModule(reactContext: ReactApplicationContext) :
reactApplicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager
}
+ // ==============================================================
+ // BATTERY OPTIMIZATION (Delegated to DeviceInfoHelper)
+ // ==============================================================
+
@ReactMethod
fun isIgnoringBatteryOptimizations(promise: Promise) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- promise.resolve(powerManager.isIgnoringBatteryOptimizations(reactApplicationContext.packageName))
- } else {
- promise.resolve(true)
- }
+ promise.resolve(deviceInfo.isIgnoringBatteryOptimizations())
}
@ReactMethod
fun requestIgnoreBatteryOptimizations(promise: Promise) {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
- promise.resolve(true)
- return
- }
-
try {
- val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).apply {
- data = Uri.parse("package:${reactApplicationContext.packageName}")
- flags = Intent.FLAG_ACTIVITY_NEW_TASK
- }
- reactApplicationContext.startActivity(intent)
- promise.resolve(true)
+ val result = deviceInfo.requestIgnoreBatteryOptimizations()
+ promise.resolve(result)
} catch (e: Exception) {
- Log.e(TAG, "Failed to open battery optimization settings", e)
- // Fallback to general settings
- try {
- val fallbackIntent = Intent(Settings.ACTION_SETTINGS).apply {
- flags = Intent.FLAG_ACTIVITY_NEW_TASK
- }
- reactApplicationContext.startActivity(fallbackIntent)
- promise.resolve(false)
- } catch (e2: Exception) {
- promise.reject("ERROR", e2.message, e2)
- }
+ promise.reject("ERROR", e.message, e)
}
}
@@ -567,6 +550,72 @@ class LocationServiceModule(reactContext: ReactApplicationContext) :
throw e
}
}
+
+ // ==============================================================
+ // DEVICE INFORMATION (Delegated to DeviceInfoHelper)
+ // ==============================================================
+
+ /**
+ * Returns device information as a map
+ */
+ @ReactMethod
+ fun getDeviceInfo(promise: Promise) {
+ try {
+ promise.resolve(deviceInfo.getDeviceInfo())
+ } catch (e: Exception) {
+ promise.reject("DEVICE_INFO_ERROR", e.message)
+ }
+ }
+
+ /**
+ * Individual getters for compatibility
+ */
+ @ReactMethod
+ fun getSystemVersion(promise: Promise) {
+ promise.resolve(deviceInfo.getSystemVersion())
+ }
+
+ @ReactMethod
+ fun getApiLevel(promise: Promise) {
+ promise.resolve(deviceInfo.getApiLevel())
+ }
+
+ @ReactMethod
+ fun getModel(promise: Promise) {
+ promise.resolve(deviceInfo.getModel())
+ }
+
+ @ReactMethod
+ fun getBrand(promise: Promise) {
+ promise.resolve(deviceInfo.getBrand())
+ }
+
+ @ReactMethod
+ fun getDeviceId(promise: Promise) {
+ promise.resolve(deviceInfo.getDeviceId())
+ }
+
+ // ==============================================================
+ // File Operations (Delegated to FileOperations)
+ // ==============================================================
+
+ @ReactMethod
+ fun writeFile(fileName: String, content: String, promise: Promise) =
+ executeAsync(promise) { fileOps.writeFile(fileName, content) }
+
+
+ @ReactMethod
+ fun shareFile(filePath: String, mimeType: String, title: String, promise: Promise) =
+ executeAsync(promise) { fileOps.shareFile(filePath, mimeType, title) }
+
+
+ @ReactMethod
+ fun deleteFile(filePath: String, promise: Promise) =
+ executeAsync(promise) { fileOps.deleteFile(filePath) }
+
+ @ReactMethod
+ fun getCacheDirectory(promise: Promise) =
+ executeAsync(promise) { fileOps.getCacheDirectory() }
}
// Extension functions for safer ReadableMap access
diff --git a/android/app/src/main/res/xml/file_paths.xml b/android/app/src/main/res/xml/file_paths.xml
new file mode 100644
index 00000000..46786416
--- /dev/null
+++ b/android/app/src/main/res/xml/file_paths.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths>
+ <cache-path name="shared_files" path="." />
+</paths>
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 5bc7b360..ef328e28 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,27 +1,20 @@
{
"name": "Colota",
- "version": "1.0.1",
+ "version": "1.3.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "Colota",
- "version": "1.0.1",
+ "version": "1.3.1",
"dependencies": {
- "@react-native/new-app-screen": "0.83.1",
"@react-navigation/native": "^7.1.26",
"@react-navigation/native-stack": "^7.9.0",
- "@types/react-native-sqlite-storage": "^6.0.5",
"react": "19.2.0",
"react-native": "0.83.1",
- "react-native-device-info": "^15.0.1",
- "react-native-fs": "^2.20.0",
"react-native-permissions": "^5.4.4",
"react-native-safe-area-context": "^5.6.2",
"react-native-screens": "^4.19.0",
- "react-native-share": "^12.2.2",
- "react-native-sqlite-storage": "^6.0.1",
- "react-native-svg": "^15.15.1",
"react-native-webview": "^13.16.0"
},
"devDependencies": {
@@ -3281,25 +3274,6 @@
"node": ">= 20.19.4"
}
},
- "node_modules/@react-native/new-app-screen": {
- "version": "0.83.1",
- "resolved": "https://registry.npmjs.org/@react-native/new-app-screen/-/new-app-screen-0.83.1.tgz",
- "integrity": "sha512-xnozxb1NjjpbTYZWHPVHHFVHdmUQ3yQfO9wK29e0JKNg/uIUq4rJ7oXYwIWPsUFFxMlKsesu2lG2+VagbGwQsg==",
- "license": "MIT",
- "engines": {
- "node": ">= 20.19.4"
- },
- "peerDependencies": {
- "@types/react": "^19.1.0",
- "react": "*",
- "react-native": "*"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- }
- }
- },
"node_modules/@react-native/normalize-colors": {
"version": "0.83.1",
"resolved": "https://registry.npmjs.org/@react-native/normalize-colors/-/normalize-colors-0.83.1.tgz",
@@ -3583,12 +3557,6 @@
"csstype": "^3.2.2"
}
},
- "node_modules/@types/react-native-sqlite-storage": {
- "version": "6.0.5",
- "resolved": "https://registry.npmjs.org/@types/react-native-sqlite-storage/-/react-native-sqlite-storage-6.0.5.tgz",
- "integrity": "sha512-1gPwgYil6pHV/EDF816M8KmVsQC5nGMTAm8OMC25GbyuBaXFn7sdguMq6A2owtXB8c4qsH2tOEIQNetbOquawA==",
- "license": "MIT"
- },
"node_modules/@types/react-test-renderer": {
"version": "19.1.0",
"resolved": "https://registry.npmjs.org/@types/react-test-renderer/-/react-test-renderer-19.1.0.tgz",
@@ -4450,11 +4418,6 @@
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"license": "MIT"
},
- "node_modules/base-64": {
- "version": "0.1.0",
- "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz",
- "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA=="
- },
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@@ -4538,12 +4501,6 @@
"devOptional": true,
"license": "MIT"
},
- "node_modules/boolbase": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
- "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==",
- "license": "ISC"
- },
"node_modules/brace-expansion": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
@@ -5154,47 +5111,6 @@
"node": ">= 8"
}
},
- "node_modules/css-select": {
- "version": "5.2.2",
- "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz",
- "integrity": "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==",
- "license": "BSD-2-Clause",
- "dependencies": {
- "boolbase": "^1.0.0",
- "css-what": "^6.1.0",
- "domhandler": "^5.0.2",
- "domutils": "^3.0.1",
- "nth-check": "^2.0.1"
- },
- "funding": {
- "url": "https://github.com/sponsors/fb55"
- }
- },
- "node_modules/css-tree": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.1.3.tgz",
- "integrity": "sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==",
- "license": "MIT",
- "dependencies": {
- "mdn-data": "2.0.14",
- "source-map": "^0.6.1"
- },
- "engines": {
- "node": ">=8.0.0"
- }
- },
- "node_modules/css-what": {
- "version": "6.2.2",
- "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.2.2.tgz",
- "integrity": "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==",
- "license": "BSD-2-Clause",
- "engines": {
- "node": ">= 6"
- },
- "funding": {
- "url": "https://github.com/sponsors/fb55"
- }
- },
"node_modules/csstype": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
@@ -5432,61 +5348,6 @@
"node": ">=6.0.0"
}
},
- "node_modules/dom-serializer": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
- "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
- "license": "MIT",
- "dependencies": {
- "domelementtype": "^2.3.0",
- "domhandler": "^5.0.2",
- "entities": "^4.2.0"
- },
- "funding": {
- "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
- }
- },
- "node_modules/domelementtype": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
- "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/fb55"
- }
- ],
- "license": "BSD-2-Clause"
- },
- "node_modules/domhandler": {
- "version": "5.0.3",
- "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
- "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
- "license": "BSD-2-Clause",
- "dependencies": {
- "domelementtype": "^2.3.0"
- },
- "engines": {
- "node": ">= 4"
- },
- "funding": {
- "url": "https://github.com/fb55/domhandler?sponsor=1"
- }
- },
- "node_modules/domutils": {
- "version": "3.2.2",
- "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz",
- "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==",
- "license": "BSD-2-Clause",
- "dependencies": {
- "dom-serializer": "^2.0.0",
- "domelementtype": "^2.3.0",
- "domhandler": "^5.0.3"
- },
- "funding": {
- "url": "https://github.com/fb55/domutils?sponsor=1"
- }
- },
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
@@ -5542,18 +5403,6 @@
"node": ">= 0.8"
}
},
- "node_modules/entities": {
- "version": "4.5.0",
- "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
- "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
- "license": "BSD-2-Clause",
- "engines": {
- "node": ">=0.12"
- },
- "funding": {
- "url": "https://github.com/fb55/entities?sponsor=1"
- }
- },
"node_modules/env-paths": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
@@ -8914,12 +8763,6 @@
"node": ">= 0.4"
}
},
- "node_modules/mdn-data": {
- "version": "2.0.14",
- "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz",
- "integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==",
- "license": "CC0-1.0"
- },
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -9469,18 +9312,6 @@
"node": ">=8"
}
},
- "node_modules/nth-check": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
- "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==",
- "license": "BSD-2-Clause",
- "dependencies": {
- "boolbase": "^1.0.0"
- },
- "funding": {
- "url": "https://github.com/fb55/nth-check?sponsor=1"
- }
- },
"node_modules/nullthrows": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/nullthrows/-/nullthrows-1.1.1.tgz",
@@ -10278,34 +10109,6 @@
}
}
},
- "node_modules/react-native-device-info": {
- "version": "15.0.1",
- "resolved": "https://registry.npmjs.org/react-native-device-info/-/react-native-device-info-15.0.1.tgz",
- "integrity": "sha512-U5waZRXtT3l1SgZpZMlIvMKPTkFZPH8W7Ks6GrJhdH723aUIPxjVer7cRSij1mvQdOAAYFJV/9BDzlC8apG89A==",
- "license": "MIT",
- "peerDependencies": {
- "react-native": "*"
- }
- },
- "node_modules/react-native-fs": {
- "version": "2.20.0",
- "resolved": "https://registry.npmjs.org/react-native-fs/-/react-native-fs-2.20.0.tgz",
- "integrity": "sha512-VkTBzs7fIDUiy/XajOSNk0XazFE9l+QlMAce7lGuebZcag5CnjszB+u4BdqzwaQOdcYb5wsJIsqq4kxInIRpJQ==",
- "license": "MIT",
- "dependencies": {
- "base-64": "^0.1.0",
- "utf8": "^3.0.0"
- },
- "peerDependencies": {
- "react-native": "*",
- "react-native-windows": "*"
- },
- "peerDependenciesMeta": {
- "react-native-windows": {
- "optional": true
- }
- }
- },
"node_modules/react-native-permissions": {
"version": "5.4.4",
"resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-5.4.4.tgz",
@@ -10348,39 +10151,6 @@
"react-native": "*"
}
},
- "node_modules/react-native-share": {
- "version": "12.2.2",
- "resolved": "https://registry.npmjs.org/react-native-share/-/react-native-share-12.2.2.tgz",
- "integrity": "sha512-YlGx4uILBXcBsOAwZ7ilK1QXzaA5H1LNgEKZIiwpWdw3Fz02s4yCel1mQJmjbPbwg5uHn+0uiWrSPBrNjDs/+A==",
- "license": "MIT",
- "engines": {
- "node": ">=16"
- }
- },
- "node_modules/react-native-sqlite-storage": {
- "version": "6.0.1",
- "resolved": "https://registry.npmjs.org/react-native-sqlite-storage/-/react-native-sqlite-storage-6.0.1.tgz",
- "integrity": "sha512-1tDFjrint6X6qSYKf3gDyz+XB+X79jfiL6xTugKHPRtF0WvqMtVgdLuNqZunIXjNEvNtNVEbXaeZ6MsguFu00A==",
- "license": "MIT",
- "peerDependencies": {
- "react-native": ">=0.14.0"
- }
- },
- "node_modules/react-native-svg": {
- "version": "15.15.1",
- "resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-15.15.1.tgz",
- "integrity": "sha512-ZUD1xwc3Hwo4cOmOLumjJVoc7lEf9oQFlHnLmgccLC19fNm6LVEdtB+Cnip6gEi0PG3wfvVzskViEtrySQP8Fw==",
- "license": "MIT",
- "dependencies": {
- "css-select": "^5.1.0",
- "css-tree": "^1.1.3",
- "warn-once": "0.1.1"
- },
- "peerDependencies": {
- "react": "*",
- "react-native": "*"
- }
- },
"node_modules/react-native-webview": {
"version": "13.16.0",
"resolved": "https://registry.npmjs.org/react-native-webview/-/react-native-webview-13.16.0.tgz",
@@ -12007,12 +11777,6 @@
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}
},
- "node_modules/utf8": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz",
- "integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==",
- "license": "MIT"
- },
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
diff --git a/package.json b/package.json
index 606135cc..e08127a3 100644
--- a/package.json
+++ b/package.json
@@ -20,20 +20,13 @@
"deploy-bundle": "adb install android/app/build/outputs/apk/bundle/app-release.aab"
},
"dependencies": {
- "@react-native/new-app-screen": "0.83.1",
"@react-navigation/native": "^7.1.26",
"@react-navigation/native-stack": "^7.9.0",
- "@types/react-native-sqlite-storage": "^6.0.5",
"react": "19.2.0",
"react-native": "0.83.1",
- "react-native-device-info": "^15.0.1",
- "react-native-fs": "^2.20.0",
"react-native-permissions": "^5.4.4",
"react-native-safe-area-context": "^5.6.2",
"react-native-screens": "^4.19.0",
- "react-native-share": "^12.2.2",
- "react-native-sqlite-storage": "^6.0.1",
- "react-native-svg": "^15.15.1",
"react-native-webview": "^13.16.0"
},
"devDependencies": {
diff --git a/assets/icon.png b/src/assets/icons/center.png
similarity index 100%
rename from assets/icon.png
rename to src/assets/icons/center.png
diff --git a/src/assets/icons/icon.png b/src/assets/icons/icon.png
new file mode 100644
index 00000000..3cb56b4d
Binary files /dev/null and b/src/assets/icons/icon.png differ
diff --git a/src/components/features/dashboard/DashboardMap.tsx b/src/components/features/dashboard/DashboardMap.tsx
index e373c227..4bd548eb 100644
--- a/src/components/features/dashboard/DashboardMap.tsx
+++ b/src/components/features/dashboard/DashboardMap.tsx
@@ -17,15 +17,14 @@ import {
ActivityIndicator,
TouchableOpacity,
DeviceEventEmitter,
- Platform,
+ Image,
} from "react-native";
import { WebView } from "react-native-webview";
import { LocationCoords } from "../../../types/global";
import { useTheme } from "../../../hooks/useTheme";
import NativeLocationService from "../../../services/NativeLocationService";
-import { SvgXml } from "react-native-svg";
-import RNFS from "react-native-fs";
-import { loadOpenLayersAssets } from "../../../helpers/openlayersLoader"
+import centerIcon from "../../../assets/icons/center.png";
+import icon from "../../../assets/icons/icon.png"
type Props = {
coords: LocationCoords | null;
@@ -38,8 +37,6 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {
const webviewRef = useRef<WebView>(null);
const { colors, mode } = useTheme();
const isDark = mode === "dark";
- const [olCss, setOlCss] = useState("");
- const [olJs, setOlJs] = useState("");
const [geofences, setGeofences] = useState<any[]>([]);
const [isCentered, setIsCentered] = useState(true);
const [mapReady, setMapReady] = useState(false);
@@ -61,14 +58,6 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {
}
}, [coords]);
- const centerIconXml = `
- <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 72 72">
- <g transform="translate(0,72) scale(0.1,-0.1)" fill="${colors.text}">
- <path d="M340 622 c0 -25 -5 -29 -47 -40 -64 -18 -137 -91 -155 -155 -11 -42 -15 -47 -40 -47 -21 0 -28 -5 -28 -20 0 -15 7 -20 28 -20 25 0 29 -5 40 -47 18 -64 91 -137 155 -155 42 -11 47 -15 47 -40 0 -21 5 -28 20 -28 15 0 20 7 20 28 0 25 5 29 47 40 64 18 137 91 155 155 11 42 15 47 40 47 21 0 28 5 28 20 0 15 -7 20 -28 20 -25 0 -29 5 -40 47 -18 65 -91 137 -155 154 -42 10 -47 14 -47 40 0 22 -5 29 -20 29 -15 0 -20 -7 -20 -28z m88 -87 c77 -33 115 -90 116 -177 1 -47 -4 -64 -29 -100 -34 -49 -102 -87 -155 -88 -52 0 -120 38 -155 88 -50 72 -38 179 27 239 54 50 130 65 196 38z"/>
- </g>
- </svg>
- `;
-
const loadGeofences = useCallback(async () => {
try {
const data = await NativeLocationService.getGeofences();
@@ -113,18 +102,8 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {
})
);
}
- console.log("Map is ready, sending coords", coords);
}, [coords, mapReady, tracking, currentSilentZone]);
- /*const onMessage = useCallback(async (event: any) => {
- try {
- const data = JSON.parse(event.nativeEvent.data);
-
- if (data.type === "MAP_READY") setMapReady(true);
- if (data.type === "CENTERED") setIsCentered(data.value);
-
- }, [loadGeofences]);*/
-
// Update geofences
useEffect(() => {
if (webviewRef.current && mapReady) {
@@ -144,16 +123,8 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {
);
}
}, [coords]);
-
- useEffect(() => {
- loadOpenLayersAssets().then(({ css, js }) => {
- setOlCss(css);
- setOlJs(js);
- });
-}, []);
-
const html = useMemo(() => {
- if (!hasInitialCoords || !initialCoords.current || !olCss || !olJs)
+ if (!hasInitialCoords || !initialCoords.current)
return "";
const lon = initialCoords.current.longitude;
@@ -164,7 +135,9 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
- <link rel="stylesheet" href="openlayers/ol.css">
+
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/ol.css">
+ <!-- <link rel="stylesheet" href="openlayers/ol.css"> -->
<style>
html, body, #map {
margin: 0;
@@ -274,7 +247,8 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {
</head>
<body>
<div id="map"></div>
- <script src="openlayers/ol.js"></script>
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ol.js"></script>
+ <!-- <script src="openlayers/ol.js"></script> -->
<script>
const vectorSource = new ol.source.Vector();
@@ -447,7 +421,7 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {
</body>
</html>
`;
- }, [olCss, olJs, colors, isDark, hasInitialCoords]);
+ }, [colors, isDark, hasInitialCoords]);
if (!tracking) {
return (
@@ -458,13 +432,10 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {
]}
>
<View style={[styles.iconCircle, { backgroundColor: colors.border }]}>
- <SvgXml
- xml={centerIconXml}
- width="52"
- height="52"
- color={colors.primary}
- fill={colors.primary}
- />
+ <Image
+ source={icon}
+ style={{ width: 52, height: 52, }}
+ />
</View>
<Text style={[styles.stateTitle, { color: colors.text }]}>
Tracking Disabled
@@ -509,10 +480,7 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {
originWhitelist={["*"]}
source={{
html: html,
- baseUrl:
- Platform.OS === "android"
- ? "file:///android_asset/"
- : RNFS.MainBundlePath + "/",
+ //baseUrl: "file:///android_asset/",
}}
style={styles.webview}
scrollEnabled={false}
@@ -578,7 +546,10 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {
]}
onPress={handleCenterMe}
>
- <SvgXml xml={centerIconXml} width="28" height="28" />
+ <Image
+ source={centerIcon}
+ style={{ width: 28, height: 28, tintColor: colors.text }}
+ />
</TouchableOpacity>
)}
diff --git a/src/helpers/openlayersLoader.ts b/src/helpers/openlayersLoader.ts
deleted file mode 100644
index cf03005d..00000000
--- a/src/helpers/openlayersLoader.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Platform } from "react-native";
-import RNFS from "react-native-fs";
-
-let cachedOlCss: string | null = null;
-let cachedOlJs: string | null = null;
-let loadingPromise: Promise<{css: string, js: string}> | null = null;
-
-export async function loadOpenLayersAssets() {
- // Return cached if available
- if (cachedOlCss && cachedOlJs) {
- return { css: cachedOlCss, js: cachedOlJs };
- }
-
- // Return existing promise if already loading
- if (loadingPromise) {
- return loadingPromise;
- }
-
- // Start loading
- loadingPromise = (async () => {
- try {
- if (Platform.OS === "android") {
- cachedOlCss = await RNFS.readFileAssets("openlayers/ol.css", "utf8");
- cachedOlJs = await RNFS.readFileAssets("openlayers/ol.js", "utf8");
- } else {
- const cssPath = `${RNFS.MainBundlePath}/openlayers/ol.css`;
- const jsPath = `${RNFS.MainBundlePath}/openlayers/ol.js`;
- cachedOlCss = await RNFS.readFile(cssPath, "utf8");
- cachedOlJs = await RNFS.readFile(jsPath, "utf8");
- }
- return { css: cachedOlCss, js: cachedOlJs };
- } catch (err) {
- console.error("Failed to load OpenLayers assets:", err);
- loadingPromise = null; // Reset to allow retry
- throw err;
- }
- })();
-
- return loadingPromise;
-}
\ No newline at end of file
diff --git a/src/screens/AboutScreen.tsx b/src/screens/AboutScreen.tsx
index 74ceaf95..e7e68898 100644
--- a/src/screens/AboutScreen.tsx
+++ b/src/screens/AboutScreen.tsx
@@ -13,11 +13,11 @@ import {
TouchableOpacity,
Image,
} from "react-native";
-import DeviceInfo from "react-native-device-info";
import { ScreenProps, ThemeColors } from "../types/global";
import { useTheme } from "../hooks/useTheme";
import { SectionTitle, Card, Container, Divider, Footer } from "../components";
import NativeLocationService from "../services/NativeLocationService";
+import icon from "../assets/icons/icon.png";
const REPO_URL = "https://github.com/dietrichmax/colota";
const PRIVACY_POLICY_URL = "https://mxd.codes/colota/privacy-policy";
@@ -103,6 +103,9 @@ export function AboutScreen({}: ScreenProps) {
const [showDebugInfo, setShowDebugInfo] = useState(false);
const [tapCount, setTapCount] = useState(0);
const [deviceInfo, setDeviceInfo] = useState({
+ model: "...",
+ brand: "...",
+ deviceId: "...",
systemVersion: "...",
apiLevel: "...",
});
@@ -130,12 +133,18 @@ export function AboutScreen({}: ScreenProps) {
useEffect(() => {
const loadDeviceInfo = async () => {
- const apiLevel = await DeviceInfo.getApiLevel();
-
- setDeviceInfo({
- systemVersion: DeviceInfo.getSystemVersion(),
- apiLevel: apiLevel.toString(),
- });
+ try {
+ const info = await NativeLocationService.getDeviceInfo();
+ setDeviceInfo({
+ model: info.model,
+ brand: info.brand,
+ deviceId: info.deviceId,
+ systemVersion: info.systemVersion,
+ apiLevel: info.apiLevel.toString(),
+ });
+ } catch (err) {
+ console.error("Failed to load device info:", err);
+ }
};
loadDeviceInfo();
@@ -174,7 +183,7 @@ export function AboutScreen({}: ScreenProps) {
activeOpacity={0.8}
>
<Image
- source={require("../../assets/icon.png")}
+ source={icon}
style={styles.appIcon}
resizeMode="contain"
/>
@@ -363,12 +372,12 @@ export function AboutScreen({}: ScreenProps) {
/>
<TechRow
label="Device Model"
- value={DeviceInfo.getModel()}
+ value={deviceInfo.model}
colors={colors}
/>
<TechRow
label="Device Brand"
- value={DeviceInfo.getBrand()}
+ value={deviceInfo.brand}
colors={colors}
/>
<View style={styles.techRow}>
@@ -378,7 +387,7 @@ export function AboutScreen({}: ScreenProps) {
Device ID
</Text>
<Text style={[styles.techValue, { color: colors.text }]}>
- {DeviceInfo.getDeviceId()}
+ {deviceInfo.deviceId}
</Text>
</View>
</Card>
diff --git a/src/screens/ExportDataScreen.tsx b/src/screens/ExportDataScreen.tsx
index 9b9428c3..ab4770df 100644
--- a/src/screens/ExportDataScreen.tsx
+++ b/src/screens/ExportDataScreen.tsx
@@ -18,8 +18,6 @@ import { Container, Card, SectionTitle, Divider } from "../components";
import { useTheme } from "../hooks/useTheme";
import { ThemeColors, LocationCoords } from "../types/global";
import NativeLocationService from "../services/NativeLocationService";
-import RNFS from "react-native-fs";
-import Share from "react-native-share"; // Use react-native-share instead
type ExportFormat = "csv" | "geojson" | "gpx" | "kml";
@@ -176,8 +174,7 @@ export function ExportDataScreen() {
setExportProgress("Saving file...");
- const filePath = `${RNFS.CachesDirectoryPath}/${fileName}`;
- await RNFS.writeFile(filePath, content, "utf8");
+ const filePath = await NativeLocationService.writeFile(fileName, content);
// File is ready, close loading overlay
setExporting(false);
@@ -186,36 +183,24 @@ export function ExportDataScreen() {
// Wait for overlay to close before showing share dialog
await new Promise<void>((resolve) => setTimeout(resolve, 300));
- // Now show share dialog using react-native-share
- const shareOptions = {
- title: "Export Location Data",
- message: `Colota location export: ${stats.totalLocations} locations`,
- url: Platform.OS === "android" ? `file://${filePath}` : filePath,
- type: mimeType,
- filename: fileName,
- subject: fileName, // For email
- };
-
try {
- await Share.open(shareOptions);
+ await NativeLocationService.shareFile(
+ filePath,
+ mimeType,
+ `Colota Export - ${stats.totalLocations} locations`
+ );
} catch (shareError: any) {
- // User cancelled or share failed
- if (
- shareError?.message &&
- !shareError.message.includes("User did not share")
- ) {
- console.warn("[ExportDataScreen] Share error:", shareError);
- }
+ console.warn("[ExportDataScreen] Share error:", shareError);
}
// Clean up temp file after sharing
setTimeout(async () => {
try {
- await RNFS.unlink(filePath);
+ await NativeLocationService.deleteFile(filePath);
} catch (err) {
console.warn("[ExportDataScreen] Failed to cleanup temp file:", err);
}
- }, 1000);
+ }, 2000);
} catch (error) {
console.error("[ExportDataScreen] Export failed:", error);
Alert.alert(
diff --git a/src/screens/GeofenceScreen.tsx b/src/screens/GeofenceScreen.tsx
index ed18a9d3..1cdc8e9d 100644
--- a/src/screens/GeofenceScreen.tsx
+++ b/src/screens/GeofenceScreen.tsx
@@ -20,24 +20,20 @@ import {
Alert,
Switch,
DeviceEventEmitter,
- Platform,
+ Image,
} from "react-native";
import { WebView } from "react-native-webview";
-import { SvgXml } from "react-native-svg";
+import centerIcon from "../assets/icons/center.png";
import { useTheme } from "../hooks/useTheme";
import NativeLocationService from "../services/NativeLocationService";
import { Geofence, ScreenProps, LocationCoords } from "../types/global";
import { useTracking } from "../contexts/TrackingProvider";
import { Container, SectionTitle, Card } from "../components";
-import RNFS from "react-native-fs";
-import { loadOpenLayersAssets } from "../helpers/openlayersLoader";
export function GeofenceScreen({}: ScreenProps) {
const { coords, tracking } = useTracking();
const { colors, mode } = useTheme();
const isDark = mode === "dark";
- const [olCss, setOlCss] = useState("");
- const [olJs, setOlJs] = useState("");
const [geofences, setGeofences] = useState<Geofence[]>([]);
const [newName, setNewName] = useState("");
@@ -61,17 +57,6 @@ export function GeofenceScreen({}: ScreenProps) {
}
}, [coords]);
- const centerIconXml = useMemo(
- () => `
- <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 72 72">
- <g transform="translate(0,72) scale(0.1,-0.1)" fill="${colors.text}">
- <path d="M340 622 c0 -25 -5 -29 -47 -40 -64 -18 -137 -91 -155 -155 -11 -42 -15 -47 -40 -47 -21 0 -28 -5 -28 -20 0 -15 7 -20 28 -20 25 0 29 -5 40 -47 18 -64 91 -137 155 -155 42 -11 47 -15 47 -40 0 -21 5 -28 20 -28 15 0 20 7 20 28 0 25 5 29 47 40 64 18 137 91 155 155 11 42 15 47 40 47 21 0 28 5 28 20 0 15 -7 20 -28 20 -25 0 -29 5 -40 47 -18 65 -91 137 -155 154 -42 10 -47 14 -47 40 0 22 -5 29 -20 29 -15 0 -20 -7 -20 -28z m88 -87 c77 -33 115 -90 116 -177 1 -47 -4 -64 -29 -100 -34 -49 -102 -87 -155 -88 -52 0 -120 38 -155 88 -50 72 -38 179 27 239 54 50 130 65 196 38z"/>
- </g>
- </svg>
- `,
- [colors.text]
- );
-
// Load geofences
const loadGeofences = useCallback(async () => {
try {
@@ -244,15 +229,8 @@ export function GeofenceScreen({}: ScreenProps) {
[loadGeofences]
);
- useEffect(() => {
- loadOpenLayersAssets().then(({ css, js }) => {
- setOlCss(css);
- setOlJs(js);
- });
- }, [])
-
const html = useMemo(() => {
- if (!hasInitialCoords || !initialCoords.current || !olCss || !olJs)
+ if (!hasInitialCoords || !initialCoords.current)
return "";
const lon = initialCoords.current.longitude;
@@ -554,7 +532,7 @@ export function GeofenceScreen({}: ScreenProps) {
</body>
</html>
`;
- }, [olCss, olJs, colors, isDark, hasInitialCoords]);
+ }, [colors, isDark, hasInitialCoords]);
const renderItem = useCallback(
({ item }: { item: Geofence }) => (
@@ -618,10 +596,7 @@ export function GeofenceScreen({}: ScreenProps) {
originWhitelist={["*"]}
source={{
html: html,
- baseUrl:
- Platform.OS === "android"
- ? "file:///android_asset/"
- : RNFS.MainBundlePath + "/",
+ baseUrl: "file:///android_asset/"
}}
style={styles.webview}
scrollEnabled={false}
@@ -637,7 +612,10 @@ export function GeofenceScreen({}: ScreenProps) {
onPress={handleCenterMe}
activeOpacity={0.7}
>
- <SvgXml xml={centerIconXml} width="28" height="28" />
+ <Image
+ source={centerIcon}
+ style={{ width: 28, height: 28, tintColor: colors.text }}
+ />
</TouchableOpacity>
)}
</View>
diff --git a/src/services/NativeLocationService.ts b/src/services/NativeLocationService.ts
index 4bae3549..78c9ab11 100644
--- a/src/services/NativeLocationService.ts
+++ b/src/services/NativeLocationService.ts
@@ -482,6 +482,94 @@ class NativeLocationService {
}
return BuildConfigModule;
}
+
+ // ============================================================================
+ // DEVICE INFORMATION
+ // ============================================================================
+
+ /**
+ * Get all device information at once
+ */
+ static async getDeviceInfo(): Promise<{
+ model: string;
+ brand: string;
+ manufacturer: string;
+ device: string;
+ deviceId: string;
+ systemVersion: string;
+ apiLevel: number;
+ }> {
+ this.ensureModule();
+ return LocationServiceModule.getDeviceInfo();
+ }
+
+ /**
+ * Individual getters (for drop-in replacement compatibility)
+ */
+ static async getSystemVersion(): Promise<string> {
+ this.ensureModule();
+ return LocationServiceModule.getSystemVersion();
+ }
+
+ static async getApiLevel(): Promise<number> {
+ this.ensureModule();
+ return LocationServiceModule.getApiLevel();
+ }
+
+ static async getModel(): Promise<string> {
+ this.ensureModule();
+ return LocationServiceModule.getModel();
+ }
+
+ static async getBrand(): Promise<string> {
+ this.ensureModule();
+ return LocationServiceModule.getBrand();
+ }
+
+ static async getDeviceId(): Promise<string> {
+ this.ensureModule();
+ return LocationServiceModule.getDeviceId();
+ }
+
+ // ============================================================================
+ // FILE MANAGEMENT
+ // ============================================================================
+
+ /**
+ * Writes content to a file in cache directory
+ */
+ static async writeFile(fileName: string, content: string): Promise<string> {
+ this.ensureModule();
+ return LocationServiceModule.writeFile(fileName, content);
+ }
+
+ /**
+ * Shares a file using native share sheet
+ */
+ static async shareFile(
+ filePath: string,
+ mimeType: string,
+ title: string
+ ): Promise<boolean> {
+ this.ensureModule();
+ return LocationServiceModule.shareFile(filePath, mimeType, title);
+ }
+
+ /**
+ * Deletes a file
+ */
+ static async deleteFile(filePath: string): Promise<boolean> {
+ this.ensureModule();
+ return LocationServiceModule.deleteFile(filePath);
+ }
+
+ /**
+ * Gets cache directory path
+ */
+ static async getCacheDirectory(): Promise<string> {
+ this.ensureModule();
+ return LocationServiceModule.getCacheDirectory();
+ }
}
-export default NativeLocationService;
+export default NativeLocationService;
\ No newline at end of file
diff --git a/src/types/assets.d.ts b/src/types/assets.d.ts
new file mode 100644
index 00000000..69a62f9a
--- /dev/null
+++ b/src/types/assets.d.ts
@@ -0,0 +1,12 @@
+declare module "*.png" {
+ const value: any;
+ export default value;
+}
+declare module "*.css" {
+ const value: any;
+ export default value;
+}
+declare module "*.js" {
+ const value: any;
+ export default value;
+}
\ No newline at end of file