Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sets the correct permissions on PlacesClient.awaitFindCurrentPlace @RequiresPermission annotation #231

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.android.libraries.places.ktx.api.net

import android.Manifest.permission
import androidx.annotation.RequiresPermission
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.tasks.CancellationTokenSource
Expand All @@ -28,13 +29,15 @@ import com.google.android.libraries.places.api.net.FindAutocompletePredictionsRe
import com.google.android.libraries.places.api.net.FindCurrentPlaceRequest
import com.google.android.libraries.places.api.net.FindCurrentPlaceResponse
import com.google.android.libraries.places.api.net.PlacesClient
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.tasks.await

/**
* Wraps [PlacesClient.fetchPhoto] in a suspending function.
*
* Fetches a photo. If an error occurred, an [ApiException] will be thrown.
*/
@ExperimentalCoroutinesApi
public suspend fun PlacesClient.awaitFetchPhoto(
photoMetadata: PhotoMetadata,
actions: FetchPhotoRequest.Builder.() -> Unit = {}
Expand All @@ -53,6 +56,7 @@ public suspend fun PlacesClient.awaitFetchPhoto(
*
* Fetches the details of a place. If an error occurred, an [ApiException] will be thrown.
*/
@ExperimentalCoroutinesApi
public suspend fun PlacesClient.awaitFetchPlace(
placeId: String,
placeFields: List<Place.Field>,
Expand All @@ -69,6 +73,7 @@ public suspend fun PlacesClient.awaitFetchPlace(
*
* Fetches autocomplete predictions. If an error occurred, an [ApiException] will be thrown.
*/
@ExperimentalCoroutinesApi
public suspend fun PlacesClient.awaitFindAutocompletePredictions(
actions: FindAutocompletePredictionsRequest.Builder.() -> Unit
): FindAutocompletePredictionsResponse {
Expand All @@ -87,9 +92,8 @@ public suspend fun PlacesClient.awaitFindAutocompletePredictions(
* the appropriate permissions will result in a [SecurityException] being thrown. In addition, if
* an error occurred while fetching the current place, an [ApiException] will be thrown.
*/
@RequiresPermission(
allOf = ["android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_WIFI_STATE"]
)
@ExperimentalCoroutinesApi
@RequiresPermission(anyOf = [permission.ACCESS_FINE_LOCATION, permission.ACCESS_COARSE_LOCATION])
public suspend fun PlacesClient.awaitFindCurrentPlace(
placeFields: List<Place.Field>
): FindCurrentPlaceResponse {
Expand Down
Loading