Remove location stuff for now
This commit is contained in:
parent
45da8803f8
commit
35438ebcb0
7 changed files with 32 additions and 79 deletions
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<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
|
<application
|
||||||
android:name=".QWeather"
|
android:name=".QWeather"
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.henryhiles.qweather
|
package com.henryhiles.qweather
|
||||||
|
|
||||||
import android.app.Application
|
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.android.ext.koin.androidContext
|
||||||
import org.koin.core.context.startKoin
|
import org.koin.core.context.startKoin
|
||||||
|
|
||||||
|
@ -11,7 +14,7 @@ class QWeather : Application() {
|
||||||
startKoin {
|
startKoin {
|
||||||
androidContext(this@QWeather)
|
androidContext(this@QWeather)
|
||||||
modules(
|
modules(
|
||||||
appModule, locationModule, repositoryModule, screenModelModule, managerModule
|
appModule, repositoryModule, screenModelModule, managerModule
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
|
||||||
}
|
|
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,7 +10,6 @@ import androidx.compose.foundation.text.selection.SelectionContainer
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Check
|
import androidx.compose.material.icons.filled.Check
|
||||||
import androidx.compose.material.icons.outlined.Info
|
import androidx.compose.material.icons.outlined.Info
|
||||||
import androidx.compose.material.icons.outlined.MyLocation
|
|
||||||
import androidx.compose.material.icons.outlined.Search
|
import androidx.compose.material.icons.outlined.Search
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
|
@ -41,19 +40,23 @@ class LocationPickerScreen : Screen {
|
||||||
val navigator = LocalNavigator.current
|
val navigator = LocalNavigator.current
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
Scaffold(floatingActionButton = {
|
Scaffold(modifier = Modifier.imePadding(),
|
||||||
FloatingActionButton(onClick = {
|
floatingActionButton = {
|
||||||
screenModel.prefs.location = location
|
FloatingActionButton(onClick = {
|
||||||
screenModel.prefs.latitude = latitude
|
if (location == "") isAboutOpen = true
|
||||||
screenModel.prefs.longitude = longitude
|
else {
|
||||||
navigator?.push(MainScreen())
|
screenModel.prefs.location = location
|
||||||
|
screenModel.prefs.latitude = latitude
|
||||||
|
screenModel.prefs.longitude = longitude
|
||||||
|
navigator?.push(MainScreen())
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.Check,
|
||||||
|
contentDescription = stringResource(id = R.string.action_apply)
|
||||||
|
)
|
||||||
|
}
|
||||||
}) {
|
}) {
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Check,
|
|
||||||
contentDescription = stringResource(id = R.string.action_apply)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}) {
|
|
||||||
screenModel.state.error?.let {
|
screenModel.state.error?.let {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = {},
|
onDismissRequest = {},
|
||||||
|
@ -107,26 +110,16 @@ class LocationPickerScreen : Screen {
|
||||||
value = locationSearch,
|
value = locationSearch,
|
||||||
onValueChange = { locationSearch = it },
|
onValueChange = { locationSearch = it },
|
||||||
trailingIcon = {
|
trailingIcon = {
|
||||||
if (locationSearch == "")
|
IconButton(onClick = {
|
||||||
IconButton(onClick = {
|
screenModel.loadGeolocationInfo(
|
||||||
|
locationSearch
|
||||||
}) {
|
)
|
||||||
Icon(
|
}, enabled = locationSearch != "") {
|
||||||
imageVector = Icons.Outlined.MyLocation,
|
Icon(
|
||||||
contentDescription = stringResource(id = R.string.location_auto_pick)
|
imageVector = Icons.Outlined.Search,
|
||||||
)
|
contentDescription = stringResource(id = R.string.action_search)
|
||||||
}
|
)
|
||||||
else
|
}
|
||||||
IconButton(onClick = {
|
|
||||||
screenModel.loadGeolocationInfo(
|
|
||||||
locationSearch
|
|
||||||
)
|
|
||||||
}) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Outlined.Search,
|
|
||||||
contentDescription = stringResource(id = R.string.action_search)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,7 +6,6 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import cafe.adriel.voyager.core.model.ScreenModel
|
import cafe.adriel.voyager.core.model.ScreenModel
|
||||||
import cafe.adriel.voyager.core.model.coroutineScope
|
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.manager.BasePreferenceManager
|
||||||
import com.henryhiles.qweather.domain.remote.GeocodingLocationDto
|
import com.henryhiles.qweather.domain.remote.GeocodingLocationDto
|
||||||
import com.henryhiles.qweather.domain.repository.GeocodingRepository
|
import com.henryhiles.qweather.domain.repository.GeocodingRepository
|
||||||
|
@ -29,8 +28,6 @@ class LocationPreferenceManager(context: Context) :
|
||||||
class LocationPickerScreenModel(
|
class LocationPickerScreenModel(
|
||||||
val prefs: LocationPreferenceManager,
|
val prefs: LocationPreferenceManager,
|
||||||
private val repository: GeocodingRepository,
|
private val repository: GeocodingRepository,
|
||||||
private val locationTracker: LocationTracker,
|
|
||||||
private val context: Context
|
|
||||||
) : ScreenModel {
|
) : ScreenModel {
|
||||||
var state by mutableStateOf(LocationPickerState())
|
var state by mutableStateOf(LocationPickerState())
|
||||||
private set
|
private set
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<string name="selected">Selected</string>x
|
<string name="selected">Selected</string>x
|
||||||
|
|
||||||
<string name="help_screen">How do I use this screen?</string>
|
<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_theme">Theme</string>
|
||||||
<string name="appearance_monet">Dynamic Theme</string>
|
<string name="appearance_monet">Dynamic Theme</string>
|
||||||
|
|
Reference in a new issue