Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions phoneClients/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- package attribute removed, namespace is defined in build.gradle -->
<!-- Required Permissions -->
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- Required for background location access on Android 10 (API 29) and above -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <!-- Required for Foreground Service -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" /> <!-- Required for Notification on Android 13+ -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <!-- Required for Wake Lock -->
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Required for Network State -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Add clear text traffic permission for testing -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application
android:name=".GpsTrackerApplication"
Expand All @@ -24,21 +23,19 @@
android:supportsRtl="true"
android:theme="@style/AppTheme.Splash"
android:usesCleartextTraffic="true"
tools:targetApi="33">
android:enableOnBackInvokedCallback="true"
tools:targetApi="35">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name">
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Declare the Foreground Service -->
<service
android:name=".service.TrackingService"
android:foregroundServiceType="location" />
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
// # android/app/src/main/java/com/websmithing/gpstracker2/GpsTrackerApplication.kt
package com.websmithing.gpstracker2

import android.app.Application
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber

/**
* Main application class for the GPS Tracker app.
*
* This class serves as the entry point for the application and handles initialization of
* app-wide components such as logging via Timber. It's annotated with [HiltAndroidApp]
* to enable dependency injection throughout the application.
*/
@HiltAndroidApp
class GpsTrackerApplication : Application() {

/**
* Initializes the application when it's first created.
*
* Sets up Timber for logging with different configurations based on the build type:
* - Debug builds: Uses [Timber.DebugTree] for detailed console logging
* - Release builds: Placeholder for a production-appropriate logging implementation
*/
override fun onCreate() {
super.onCreate()
// Initialize Timber
// TODO: Plant a different tree for release builds (e.g., one that logs to crash reporting)
if (BuildConfig.DEBUG) { // BuildConfig needs to be generated by Gradle sync
setupTimber()
}

private fun setupTimber() {
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
Timber.d("Timber DebugTree planted.")
} else {
// Timber.plant(CrashReportingTree()) // Example for release
Timber.d("Timber ReleaseTree planted (placeholder).") // Placeholder log
Timber.d("Timber DebugTree planted")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,68 +1,42 @@
package com.websmithing.gpstracker2

import android.content.Context
import android.content.pm.ActivityInfo
import android.graphics.Color
import android.os.Bundle
import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.websmithing.gpstracker2.di.SettingsRepositoryEntryPoint
import com.websmithing.gpstracker2.helper.LocaleHelper
import com.websmithing.gpstracker2.ui.App
import com.websmithing.gpstracker2.ui.checkFirstTimeLoading
import com.websmithing.gpstracker2.ui.checkIfGooglePlayEnabled
import com.websmithing.gpstracker2.util.LocaleHelper
import dagger.hilt.android.AndroidEntryPoint
import dagger.hilt.android.EntryPointAccessors
import kotlinx.coroutines.runBlocking

/**
* Main activity for the GPS Tracker application.
*
* This activity serves as the primary user interface for the GPS tracking functionality.
* It handles:
* - User configuration (username, server URL, tracking interval)
* - Permission management for location tracking
* - Starting and stopping the tracking service
* - Displaying real-time location data and tracking statistics
* - Communicating with the backend ViewModel that manages data and services
*
* The activity is integrated with Hilt for dependency injection.
*/
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
override fun attachBaseContext(newBase: Context) {
// 1. Get the EntryPoint accessor from the application context
val entryPoint = EntryPointAccessors.fromApplication(
newBase.applicationContext,
SettingsRepositoryEntryPoint::class.java
)

// 2. Use the EntryPoint to get the repository instance
val repo = entryPoint.getSettingsRepository()

// 3. Use your LocaleHelper to create the new context
val newCtx = LocaleHelper.onAttach(newBase, repo)

override fun attachBaseContext(newBase: Context) {
val repo = getSettingsRepository(newBase)
val newCtx = runBlocking {
LocaleHelper.wrapContext(newBase, repo)
}
super.attachBaseContext(newCtx)
}

override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)

requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT

checkIfGooglePlayEnabled()
checkFirstTimeLoading()

enableEdgeToEdge(
statusBarStyle = SystemBarStyle.dark(Color.TRANSPARENT),
navigationBarStyle = SystemBarStyle.dark(Color.TRANSPARENT),
)
setContent {
App()
}
}

private fun getSettingsRepository(context: Context) = EntryPointAccessors.fromApplication(
context.applicationContext,
SettingsRepositoryEntryPoint::class.java
).settingsRepository()
}

This file was deleted.

This file was deleted.

Loading