Remove location stuff for now

This commit is contained in:
Henry Hiles 2023-04-18 10:01:33 -04:00
parent 45da8803f8
commit 35438ebcb0
7 changed files with 32 additions and 79 deletions

View file

@ -3,8 +3,6 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name=".QWeather"

View file

@ -1,7 +1,10 @@
package com.henryhiles.qweather
import android.app.Application
import com.henryhiles.qweather.di.*
import com.henryhiles.qweather.di.appModule
import com.henryhiles.qweather.di.managerModule
import com.henryhiles.qweather.di.repositoryModule
import com.henryhiles.qweather.di.screenModelModule
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin
@ -11,7 +14,7 @@ class QWeather : Application() {
startKoin {
androidContext(this@QWeather)
modules(
appModule, locationModule, repositoryModule, screenModelModule, managerModule
appModule, repositoryModule, screenModelModule, managerModule
)
}
}

View file

@ -1,9 +0,0 @@
package com.henryhiles.qweather.di
import com.henryhiles.qweather.domain.location.LocationTracker
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module
val locationModule = module {
singleOf(::LocationTracker)
}

View file

@ -1,29 +0,0 @@
package com.henryhiles.qweather.domain.location
import android.Manifest
import android.app.Application
import android.content.Context
import android.content.pm.PackageManager
import android.location.Location
import android.location.LocationManager
import androidx.core.content.ContextCompat
class LocationTracker(
private val application: Application
) {
fun getCurrentLocation(): Location? {
val hasAccessFineLocationPermission = ContextCompat.checkSelfPermission(
application,
Manifest.permission.ACCESS_FINE_LOCATION
) == PackageManager.PERMISSION_GRANTED
val locationManager =
application.getSystemService(Context.LOCATION_SERVICE) as LocationManager
val isGpsEnabled = locationManager.isProviderEnabled(
LocationManager.GPS_PROVIDER
)
if (!hasAccessFineLocationPermission || !isGpsEnabled) return null
return locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER)
}
}

View file

@ -10,7 +10,6 @@ import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.outlined.MyLocation
import androidx.compose.material.icons.outlined.Search
import androidx.compose.material3.*
import androidx.compose.runtime.*
@ -41,12 +40,16 @@ class LocationPickerScreen : Screen {
val navigator = LocalNavigator.current
val context = LocalContext.current
Scaffold(floatingActionButton = {
Scaffold(modifier = Modifier.imePadding(),
floatingActionButton = {
FloatingActionButton(onClick = {
if (location == "") isAboutOpen = true
else {
screenModel.prefs.location = location
screenModel.prefs.latitude = latitude
screenModel.prefs.longitude = longitude
navigator?.push(MainScreen())
}
}) {
Icon(
imageVector = Icons.Default.Check,
@ -107,21 +110,11 @@ class LocationPickerScreen : Screen {
value = locationSearch,
onValueChange = { locationSearch = it },
trailingIcon = {
if (locationSearch == "")
IconButton(onClick = {
}) {
Icon(
imageVector = Icons.Outlined.MyLocation,
contentDescription = stringResource(id = R.string.location_auto_pick)
)
}
else
IconButton(onClick = {
screenModel.loadGeolocationInfo(
locationSearch
)
}) {
}, enabled = locationSearch != "") {
Icon(
imageVector = Icons.Outlined.Search,
contentDescription = stringResource(id = R.string.action_search)

View file

@ -6,7 +6,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import cafe.adriel.voyager.core.model.ScreenModel
import cafe.adriel.voyager.core.model.coroutineScope
import com.henryhiles.qweather.domain.location.LocationTracker
import com.henryhiles.qweather.domain.manager.BasePreferenceManager
import com.henryhiles.qweather.domain.remote.GeocodingLocationDto
import com.henryhiles.qweather.domain.repository.GeocodingRepository
@ -29,8 +28,6 @@ class LocationPreferenceManager(context: Context) :
class LocationPickerScreenModel(
val prefs: LocationPreferenceManager,
private val repository: GeocodingRepository,
private val locationTracker: LocationTracker,
private val context: Context
) : ScreenModel {
var state by mutableStateOf(LocationPickerState())
private set

View file

@ -15,7 +15,7 @@
<string name="selected">Selected</string>x
<string name="help_screen">How do I use this screen?</string>
<string name="help_location_picker">Please either tap the auto-pick button or enter a location. Then tap the apply button in the bottom left corner.</string>
<string name="help_location_picker">Please search a location, then tap a result. Then tap the apply button in the bottom left corner.</string>
<string name="appearance_theme">Theme</string>
<string name="appearance_monet">Dynamic Theme</string>