Loading cardinal-android/app/src/main/java/earth/maps/cardinal/geocoding/GeocodingService.kt +7 −3 Original line number Diff line number Diff line Loading @@ -52,8 +52,8 @@ abstract class GeocodingService(private val locationRepository: LocationReposito * @param longitude The longitude coordinate * @return Place objects */ suspend fun nearby(latitude: Double, longitude: Double): List<Place> { return convertResultsToPlaces(nearbyRaw(latitude, longitude)) suspend fun nearby(latitude: Double, longitude: Double, selectedCategories: List<String>): List<Place> { return convertResultsToPlaces(nearbyRaw(latitude, longitude, selectedCategories)) } /** Loading Loading @@ -96,7 +96,11 @@ abstract class GeocodingService(private val locationRepository: LocationReposito * @param longitude The longitude coordinate * @return Raw nearby places */ abstract suspend fun nearbyRaw(latitude: Double, longitude: Double): List<GeocodeResult> abstract suspend fun nearbyRaw( latitude: Double, longitude: Double, selectedCategories: List<String> ): List<GeocodeResult> } fun deduplicateSearchResults(results: List<GeocodeResult>): List<GeocodeResult> { Loading cardinal-android/app/src/main/java/earth/maps/cardinal/geocoding/MultiplexedGeocodingService.kt +7 −4 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import earth.maps.cardinal.data.AppPreferenceRepository import earth.maps.cardinal.data.GeocodeResult import earth.maps.cardinal.data.LatLng import earth.maps.cardinal.data.LocationRepository import kotlinx.coroutines.flow.Flow class MultiplexedGeocodingService( private val appPreferenceRepository: AppPreferenceRepository, Loading Loading @@ -50,11 +49,15 @@ class MultiplexedGeocodingService( } } override suspend fun nearbyRaw(latitude: Double, longitude: Double): List<GeocodeResult> { override suspend fun nearbyRaw( latitude: Double, longitude: Double, selectedCategories: List<String> ): List<GeocodeResult> { return if (appPreferenceRepository.offlineMode.value) { offlineGeocodingService.nearbyRaw(latitude, longitude) offlineGeocodingService.nearbyRaw(latitude, longitude, selectedCategories) } else { onlineGeocodingService.nearbyRaw(latitude, longitude) onlineGeocodingService.nearbyRaw(latitude, longitude, selectedCategories) } } } cardinal-android/app/src/main/java/earth/maps/cardinal/geocoding/OfflineGeocodingService.kt +5 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,11 @@ class OfflineGeocodingService( return emptyList() } override suspend fun nearbyRaw(latitude: Double, longitude: Double): List<GeocodeResult> { override suspend fun nearbyRaw( latitude: Double, longitude: Double, selectedCategories: List<String> ): List<GeocodeResult> { return emptyList() } Loading cardinal-android/app/src/main/java/earth/maps/cardinal/geocoding/PeliasGeocodingService.kt +8 −1 Original line number Diff line number Diff line Loading @@ -119,7 +119,11 @@ class PeliasGeocodingService( } } override suspend fun nearbyRaw(latitude: Double, longitude: Double): List<GeocodeResult> { override suspend fun nearbyRaw( latitude: Double, longitude: Double, selectedCategories: List<String> ): List<GeocodeResult> { try { Log.d(TAG, "Nearby: $latitude, $longitude") val config = appPreferenceRepository.peliasApiConfig.value Loading @@ -128,6 +132,9 @@ class PeliasGeocodingService( parameter("point.lon", longitude.toString()) parameter("size", "50") parameter("layers", "venue") if (selectedCategories.isNotEmpty()) { parameter("categories", selectedCategories.joinToString(",")) } config.apiKey?.let { parameter("api_key", it) } } Loading cardinal-android/app/src/main/java/earth/maps/cardinal/ui/home/NearbyScreen.kt +21 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize Loading @@ -36,6 +37,7 @@ import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.FilterChip import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton Loading @@ -44,7 +46,9 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.onGloballyPositioned Loading Loading @@ -92,7 +96,24 @@ fun NearbyScreenContent(viewModel: NearbyViewModel, onPlaceSelected: (Place) -> contentDescription = stringResource(string.refresh_nearby_places) ) } } FlowRow { for (chipSpec in viewModel.allCategories) { var isSelected by remember { mutableStateOf(false) } FilterChip( modifier = Modifier.padding(end = 8.dp), selected = isSelected, onClick = { isSelected = !isSelected viewModel.setCategorySelection(chipSpec.category, isSelected) }, label = { val label = stringResource(chipSpec.labelResource) Text(text = label) } ) } } when { Loading Loading
cardinal-android/app/src/main/java/earth/maps/cardinal/geocoding/GeocodingService.kt +7 −3 Original line number Diff line number Diff line Loading @@ -52,8 +52,8 @@ abstract class GeocodingService(private val locationRepository: LocationReposito * @param longitude The longitude coordinate * @return Place objects */ suspend fun nearby(latitude: Double, longitude: Double): List<Place> { return convertResultsToPlaces(nearbyRaw(latitude, longitude)) suspend fun nearby(latitude: Double, longitude: Double, selectedCategories: List<String>): List<Place> { return convertResultsToPlaces(nearbyRaw(latitude, longitude, selectedCategories)) } /** Loading Loading @@ -96,7 +96,11 @@ abstract class GeocodingService(private val locationRepository: LocationReposito * @param longitude The longitude coordinate * @return Raw nearby places */ abstract suspend fun nearbyRaw(latitude: Double, longitude: Double): List<GeocodeResult> abstract suspend fun nearbyRaw( latitude: Double, longitude: Double, selectedCategories: List<String> ): List<GeocodeResult> } fun deduplicateSearchResults(results: List<GeocodeResult>): List<GeocodeResult> { Loading
cardinal-android/app/src/main/java/earth/maps/cardinal/geocoding/MultiplexedGeocodingService.kt +7 −4 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import earth.maps.cardinal.data.AppPreferenceRepository import earth.maps.cardinal.data.GeocodeResult import earth.maps.cardinal.data.LatLng import earth.maps.cardinal.data.LocationRepository import kotlinx.coroutines.flow.Flow class MultiplexedGeocodingService( private val appPreferenceRepository: AppPreferenceRepository, Loading Loading @@ -50,11 +49,15 @@ class MultiplexedGeocodingService( } } override suspend fun nearbyRaw(latitude: Double, longitude: Double): List<GeocodeResult> { override suspend fun nearbyRaw( latitude: Double, longitude: Double, selectedCategories: List<String> ): List<GeocodeResult> { return if (appPreferenceRepository.offlineMode.value) { offlineGeocodingService.nearbyRaw(latitude, longitude) offlineGeocodingService.nearbyRaw(latitude, longitude, selectedCategories) } else { onlineGeocodingService.nearbyRaw(latitude, longitude) onlineGeocodingService.nearbyRaw(latitude, longitude, selectedCategories) } } }
cardinal-android/app/src/main/java/earth/maps/cardinal/geocoding/OfflineGeocodingService.kt +5 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,11 @@ class OfflineGeocodingService( return emptyList() } override suspend fun nearbyRaw(latitude: Double, longitude: Double): List<GeocodeResult> { override suspend fun nearbyRaw( latitude: Double, longitude: Double, selectedCategories: List<String> ): List<GeocodeResult> { return emptyList() } Loading
cardinal-android/app/src/main/java/earth/maps/cardinal/geocoding/PeliasGeocodingService.kt +8 −1 Original line number Diff line number Diff line Loading @@ -119,7 +119,11 @@ class PeliasGeocodingService( } } override suspend fun nearbyRaw(latitude: Double, longitude: Double): List<GeocodeResult> { override suspend fun nearbyRaw( latitude: Double, longitude: Double, selectedCategories: List<String> ): List<GeocodeResult> { try { Log.d(TAG, "Nearby: $latitude, $longitude") val config = appPreferenceRepository.peliasApiConfig.value Loading @@ -128,6 +132,9 @@ class PeliasGeocodingService( parameter("point.lon", longitude.toString()) parameter("size", "50") parameter("layers", "venue") if (selectedCategories.isNotEmpty()) { parameter("categories", selectedCategories.joinToString(",")) } config.apiKey?.let { parameter("api_key", it) } } Loading
cardinal-android/app/src/main/java/earth/maps/cardinal/ui/home/NearbyScreen.kt +21 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize Loading @@ -36,6 +37,7 @@ import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.FilterChip import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton Loading @@ -44,7 +46,9 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.onGloballyPositioned Loading Loading @@ -92,7 +96,24 @@ fun NearbyScreenContent(viewModel: NearbyViewModel, onPlaceSelected: (Place) -> contentDescription = stringResource(string.refresh_nearby_places) ) } } FlowRow { for (chipSpec in viewModel.allCategories) { var isSelected by remember { mutableStateOf(false) } FilterChip( modifier = Modifier.padding(end = 8.dp), selected = isSelected, onClick = { isSelected = !isSelected viewModel.setCategorySelection(chipSpec.category, isSelected) }, label = { val label = stringResource(chipSpec.labelResource) Text(text = label) } ) } } when { Loading