Colota - Android GPS Location tracker
replaced center icon with html/css
Max Dietrichda1f8c12305b
diff --git a/.eslintignore b/.eslintignoreindex 909c3006..622417cd 100644--- a/.eslintignore+++ b/.eslintignore@@ -1,3 +1,4 @@# .eslintignore*.min.js+coverage**/openlayers/*.js\ No newline at end of filediff --git a/android/app/build.gradle b/android/app/build.gradleindex 221af4f4..93107a85 100644--- a/android/app/build.gradle+++ b/android/app/build.gradle@@ -83,8 +83,8 @@ android {applicationId "com.Colota"minSdkVersion rootProject.ext.minSdkVersiontargetSdkVersion rootProject.ext.targetSdkVersion- versionCode 7- versionName "1.3.1"+ versionCode 8+ versionName "1.4.1"// Expose build config to the modulebuildConfigField "int", "MIN_SDK_VERSION", "${rootProject.ext.minSdkVersion}"diff --git a/android/app/src/main/java/com/locata/FileOperations.kt b/android/app/src/main/java/com/locata/FileOperations.ktindex f5d90d0c..32cf37cd 100644--- a/android/app/src/main/java/com/locata/FileOperations.kt+++ b/android/app/src/main/java/com/locata/FileOperations.kt@@ -7,6 +7,7 @@ package com.Colotaimport android.content.Intentimport android.net.Uri+import android.util.Logimport androidx.core.content.FileProviderimport com.facebook.react.bridge.*import java.io.File@@ -27,12 +28,13 @@ class FileOperations(private val context: ReactApplicationContext) {}/**- * 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) {+ * 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+ * @return true if the share intent was started+ */+ fun shareFile(filePath: String, mimeType: String, title: String): Boolean {val file = File(filePath)if (!file.exists()) {throw IllegalArgumentException("File does not exist: $filePath")@@ -58,7 +60,7 @@ class FileOperations(private val context: ReactApplicationContext) {context.startActivity(chooser)- // Schedule deletion after 30 seconds+ // Schedule deletion after 60 secondsandroid.os.Handler(android.os.Looper.getMainLooper()).postDelayed({try {if (file.exists()) {@@ -70,7 +72,7 @@ class FileOperations(private val context: ReactApplicationContext) {} catch (e: Exception) {Log.w("FileOperations", "Failed to cleanup file", e)}- }, 30000)+ }, 60000)return true}diff --git a/src/components/features/dashboard/DashboardMap.tsx b/src/components/features/dashboard/DashboardMap.tsxindex 4bd548eb..234b8a67 100644--- a/src/components/features/dashboard/DashboardMap.tsx+++ b/src/components/features/dashboard/DashboardMap.tsx@@ -15,7 +15,6 @@ import {StyleSheet,Text,ActivityIndicator,- TouchableOpacity,DeviceEventEmitter,Image,} from "react-native";@@ -23,7 +22,7 @@ import { WebView } from "react-native-webview";import { LocationCoords } from "../../../types/global";import { useTheme } from "../../../hooks/useTheme";import NativeLocationService from "../../../services/NativeLocationService";-import centerIcon from "../../../assets/icons/center.png";+import { MapCenterButton } from "../map/MapCenterButton";import icon from "../../../assets/icons/icon.png"type Props = {@@ -136,8 +135,7 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {<head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/ol.css">- <!-- <link rel="stylesheet" href="openlayers/ol.css"> -->+ <link rel="stylesheet" href="openlayers/ol.css"><style>html, body, #map {margin: 0;@@ -247,8 +245,7 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {</head><body><div id="map"></div>- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ol.js"></script>- <!-- <script src="openlayers/ol.js"></script> -->+ <script src="openlayers/ol.js"></script><script>const vectorSource = new ol.source.Vector();@@ -387,7 +384,7 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {if (data.action === "center_map") {const pos = ol.proj.fromLonLat([data.coords.longitude, data.coords.latitude]);- map.getView().animate({ center: pos, zoom: 16, duration: 400 });+ map.getView().animate({ center: pos, zoom: 17, duration: 400 });}if (data.action === "zoom_to_geofence") {@@ -434,7 +431,7 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {<View style={[styles.iconCircle, { backgroundColor: colors.border }]}><Imagesource={icon}- style={{ width: 52, height: 52, }}+ style={styles.icon}/></View><Text style={[styles.stateTitle, { color: colors.text }]}>@@ -480,7 +477,7 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {originWhitelist={["*"]}source={{html: html,- //baseUrl: "file:///android_asset/",+ baseUrl: "file:///android_asset/",}}style={styles.webview}scrollEnabled={false}@@ -538,20 +535,10 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {</View>)}- {!isCentered && (- <TouchableOpacity- style={[- styles.centerButton,- { backgroundColor: colors.card, borderColor: colors.border },- ]}- onPress={handleCenterMe}- >- <Image- source={centerIcon}- style={{ width: 28, height: 28, tintColor: colors.text }}- />- </TouchableOpacity>- )}+ <MapCenterButton+ visible={!isCentered}+ onPress={handleCenterMe}+ />{activeZoneName && (<View@@ -578,66 +565,16 @@ export function DashboardMap({ coords, tracking, activeZoneName }: Props) {const styles = StyleSheet.create({container: { flex: 1, width: "100%", overflow: "hidden" },webview: { flex: 1 },- stateContainer: {- flex: 1,- justifyContent: "center",- alignItems: "center",- padding: 24,- },- iconCircle: {- width: 80,- height: 80,- borderRadius: 40,- justifyContent: "center",- alignItems: "center",- marginBottom: 16,- },+ stateContainer: { flex: 1, justifyContent: "center", alignItems: "center", padding: 24 },+ icon: { width: 64, height: 64 },+ iconCircle: { width: 80, height: 80, borderRadius: 40, justifyContent: "center", alignItems: "center", marginBottom: 16 },stateTitle: { fontSize: 18, fontWeight: "bold", textAlign: "center" },- stateTitleSpaced: {- marginTop: 20,- },- stateSubtext: {- fontSize: 14,- textAlign: "center",- marginTop: 8,- lineHeight: 20,- },- centerButton: {- position: "absolute",- bottom: 30,- right: 10,- width: 50,- height: 50,- borderRadius: 25,- justifyContent: "center",- alignItems: "center",- elevation: 5,- shadowColor: "#000",- shadowOffset: { width: 0, height: 2 },- shadowOpacity: 0.25,- shadowRadius: 3.84,- borderWidth: 1,- },+ stateTitleSpaced: { marginTop: 20 },+ stateSubtext: { fontSize: 14, textAlign: "center", marginTop: 8, lineHeight: 20 },topInfoCard: {- position: "absolute",- top: 20,- left: 80,- right: 20,- padding: 16,- borderRadius: 16,- elevation: 8,- shadowOffset: { width: 0, height: 2 },- shadowOpacity: 0.2,- shadowRadius: 4,- borderLeftWidth: 5,- zIndex: 5,- },- infoTitle: {- fontSize: 16,- fontWeight: "bold",- marginBottom: 2,- },- infoSub: {- fontSize: 13,+ position: "absolute", top: 20, left: 80, right: 20, padding: 16,+ borderRadius: 16, elevation: 8, shadowOpacity: 0.2, borderLeftWidth: 5, zIndex: 5,},-});+ infoTitle: { fontSize: 16, fontWeight: "bold", marginBottom: 2 },+ infoSub: { fontSize: 13 },+});\ No newline at end of filediff --git a/src/components/features/map/MapCenterButton.tsx b/src/components/features/map/MapCenterButton.tsxnew file mode 100644index 00000000..c4874abc--- /dev/null+++ b/src/components/features/map/MapCenterButton.tsx@@ -0,0 +1,118 @@+/**+ * Copyright (C) 2026 Max Dietrich+ * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.+ */++import React from "react";+import {+ TouchableOpacity,+ View,+ StyleSheet,+ ViewStyle,+ StyleProp,+} from "react-native";+import { useTheme } from "@react-navigation/native";++interface Props {+ onPress: () => void;+ visible: boolean;+ style?: StyleProp<ViewStyle>;+}++export const MapCenterButton: React.FC<Props> = ({ onPress, visible, style }) => {+ const { colors } = useTheme();++ if (!visible) return null;++ return (+ <TouchableOpacity+ style={[+ styles.centerButton,+ { backgroundColor: colors.card, borderColor: colors.border },+ style,+ ]}+ onPress={onPress}+ activeOpacity={0.7}+ >+ <View style={[styles.crosshairOuter, { borderColor: colors.text }]}>+ <View+ style={[styles.crosshairInner, { backgroundColor: colors.text }]}+ />+ {/* The four notches */}+ <View+ style={[styles.notch, styles.notchTop, { backgroundColor: colors.text }]}+ />+ <View+ style={[styles.notch, styles.notchBottom, { backgroundColor: colors.text }]}+ />+ <View+ style={[styles.notch, styles.notchLeft, { backgroundColor: colors.text }]}+ />+ <View+ style={[styles.notch, styles.notchRight, { backgroundColor: colors.text }]}+ />+ </View>+ </TouchableOpacity>+ );+};++const styles = StyleSheet.create({+ centerButton: {+ position: "absolute",+ bottom: 30,+ right: 16,+ width: 48,+ height: 48,+ borderRadius: 24,+ justifyContent: "center",+ alignItems: "center",+ elevation: 5,+ shadowColor: "#000",+ shadowOffset: { width: 0, height: 2 },+ shadowOpacity: 0.25,+ shadowRadius: 3.84,+ borderWidth: 1,+ zIndex: 10,+ },+ crosshairOuter: {+ width: 20,+ height: 20,+ borderRadius: 10,+ borderWidth: 2,+ alignItems: "center",+ justifyContent: "center",+ position: "relative",+ },+ crosshairInner: {+ width: 6,+ height: 6,+ borderRadius: 3,+ },+ notch: {+ position: "absolute",+ },+ notchTop: {+ top: -6,+ width: 2,+ height: 5,+ left: 7,+ },+ notchBottom: {+ bottom: -6,+ width: 2,+ height: 5,+ left: 7,+ },+ notchLeft: {+ left: -6,+ width: 5,+ height: 2,+ top: 7,+ },+ notchRight: {+ right: -6,+ width: 5,+ height: 2,+ top: 7,+ },+});\ No newline at end of filediff --git a/src/screens/AboutScreen.tsx b/src/screens/AboutScreen.tsxindex e7e68898..6085bfeb 100644--- a/src/screens/AboutScreen.tsx+++ b/src/screens/AboutScreen.tsx@@ -45,14 +45,14 @@ function getAndroidVersion(sdkVersion: number): string {// Moved outside of AboutScreen componentconst LinkButton = ({- icon,+ iconLabel,title,subtitle,url,colors,onOpenURL,}: {- icon: string;+ iconLabel: string;title: string;subtitle: string;url: string;@@ -65,7 +65,7 @@ const LinkButton = ({activeOpacity={0.7}><View style={styles.linkContent}>- <Text style={styles.linkIcon}>{icon}</Text>+ <Text style={styles.linkIcon}>{iconLabel}</Text><View style={styles.linkTextContainer}><Text style={[styles.linkTitle, { color: colors.text }]}>{title}</Text><Text style={[styles.linkSubtitle, { color: colors.textSecondary }]}>@@ -233,7 +233,7 @@ export function AboutScreen({}: ScreenProps) {<View style={styles.section}><SectionTitle>QUICK LINKS</SectionTitle><LinkButton- icon="π"+ iconLabel="π"title="Privacy Policy"subtitle="How your data is handled"url={PRIVACY_POLICY_URL}@@ -241,7 +241,7 @@ export function AboutScreen({}: ScreenProps) {onOpenURL={handleOpenURL}/><LinkButton- icon="π»"+ iconLabel="π»"title="View Source Code"subtitle="GitHub Repository"url={REPO_URL}diff --git a/src/screens/ExportDataScreen.tsx b/src/screens/ExportDataScreen.tsxindex ab4770df..1081d566 100644--- a/src/screens/ExportDataScreen.tsx+++ b/src/screens/ExportDataScreen.tsx@@ -11,7 +11,6 @@ import {Alert,ActivityIndicator,ScrollView,- Platform,TouchableOpacity,} from "react-native";import { Container, Card, SectionTitle, Divider } from "../components";diff --git a/src/screens/GeofenceScreen.tsx b/src/screens/GeofenceScreen.tsxindex 1cdc8e9d..549ffaa3 100644--- a/src/screens/GeofenceScreen.tsx+++ b/src/screens/GeofenceScreen.tsx@@ -20,15 +20,14 @@ import {Alert,Switch,DeviceEventEmitter,- Image,} from "react-native";import { WebView } from "react-native-webview";-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 { MapCenterButton } from "../components/features/map/MapCenterButton";export function GeofenceScreen({}: ScreenProps) {const { coords, tracking } = useTracking();@@ -486,7 +485,7 @@ export function GeofenceScreen({}: ScreenProps) {if (data.action === "center_map") {const pos = ol.proj.fromLonLat([data.coords.longitude, data.coords.latitude]);- map.getView().animate({ center: pos, zoom: 16, duration: 400 });+ map.getView().animate({ center: pos, zoom: 17, duration: 400 });}if (data.action === "zoom_to_geofence") {@@ -603,21 +602,7 @@ export function GeofenceScreen({}: ScreenProps) {onMessage={onMessage}/>- {!isCentered && (- <TouchableOpacity- style={[- styles.centerBtn,- { backgroundColor: colors.card, borderColor: colors.border },- ]}- onPress={handleCenterMe}- activeOpacity={0.7}- >- <Image- source={centerIcon}- style={{ width: 28, height: 28, tintColor: colors.text }}- />- </TouchableOpacity>- )}+ <MapCenterButton visible={!isCentered} onPress={handleCenterMe} /></View><FlatList@@ -765,6 +750,9 @@ const styles = StyleSheet.create({inputCentered: {textAlign: "center",},+ centerIcon: {+ width: 28, height: 28,+ },placeBtn: { padding: 16, borderRadius: 12, alignItems: "center" },placeBtnText: { color: "#f8f7f7", fontSize: 15, fontWeight: "600" },card: { marginBottom: 12, padding: 14 },