feat: add sending geocoords
This commit is contained in:
@@ -7,8 +7,11 @@ package ru.risdeveau.geotracker
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.compose.setContent
|
||||
@@ -46,8 +49,10 @@ import splitties.init.appCtx
|
||||
import splitties.resources.appStr
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
enableEdgeToEdge()
|
||||
setContent {
|
||||
GeoTrackerTheme {
|
||||
@@ -60,6 +65,12 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
when (screen) {
|
||||
Screen.Main -> {
|
||||
LaunchedEffect(Unit) {
|
||||
Log.d("Thread", "Starting...")
|
||||
startLocationService()
|
||||
Log.d("Thread", "Started")
|
||||
}
|
||||
|
||||
Text("Hello world")
|
||||
}
|
||||
|
||||
@@ -101,8 +112,8 @@ sealed class Screen {
|
||||
@OptIn(ExperimentalSplittiesApi::class)
|
||||
@Composable
|
||||
fun Settings(modifier: Modifier = Modifier, onConfirm: () -> Unit) {
|
||||
var username by remember { mutableStateOf("") }
|
||||
var url by remember { mutableStateOf("") }
|
||||
var username by remember { mutableStateOf(SettingsPreferences.username) }
|
||||
var url by remember { mutableStateOf(SettingsPreferences.url) }
|
||||
var urlIsValid by remember { mutableStateOf(false) }
|
||||
var loading by remember { mutableStateOf(false) }
|
||||
|
||||
@@ -196,4 +207,14 @@ fun hasLocationPermissions(context: Context): Boolean {
|
||||
context,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
fun startLocationService() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
appCtx.startForegroundService(Intent(appCtx, LocationForegroundService::class.java))
|
||||
Log.d("startLocationService", "startForegroundService")
|
||||
} else {
|
||||
appCtx.startService(Intent(appCtx, LocationForegroundService::class.java))
|
||||
Log.d("startLocationService", "startService")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user