From 1e0053a859cbf33b1ba74e1eb1819a9869c1208b Mon Sep 17 00:00:00 2001 From: Angela Yu <5506675+wangela@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:19:43 -0800 Subject: [PATCH] feat: add samples for release 3.2.0 (#600) --- .github/snippet-bot.yml | 0 .gitignore | 1 + demo-kotlin/app/build.gradle | 19 +++++++++++-------- .../placesdemo/AutocompleteAddressActivity.kt | 5 ++--- .../placesdemo/CurrentPlaceActivity.kt | 1 + .../java/com/example/placesdemo/StringUtil.kt | 6 +++--- snippets/app/build.gradle | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 .github/snippet-bot.yml diff --git a/.github/snippet-bot.yml b/.github/snippet-bot.yml new file mode 100644 index 00000000..e69de29b diff --git a/.gitignore b/.gitignore index ee3cb603..2efc6c41 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ build/ .gradle *.iml local.properties +secrets.properties .DS_Store .java-version diff --git a/demo-kotlin/app/build.gradle b/demo-kotlin/app/build.gradle index ae60df50..44a3bc51 100644 --- a/demo-kotlin/app/build.gradle +++ b/demo-kotlin/app/build.gradle @@ -6,11 +6,11 @@ plugins { } android { - compileSdkVersion 33 + compileSdk 33 defaultConfig { applicationId "com.example.placesdemo" - minSdkVersion 21 - targetSdkVersion 33 + minSdk 21 + targetSdk 33 multiDexEnabled true versionCode 1 versionName "1.0" @@ -36,9 +36,11 @@ dependencies { implementation "com.github.bumptech.glide:glide:4.13.2" implementation "com.android.databinding:viewbinding:8.0.0" - // Places SDK for Android - implementation 'com.google.android.libraries.places:places:3.1.0' - implementation 'com.google.maps.android:android-maps-utils:2.4.0' + // KTX for the Places SDK for Android library + implementation 'com.google.maps.android:places-ktx:3.0.0' + + // KTX for the Maps SDK for Android Utility Library + implementation 'com.google.maps.android:maps-utils-ktx:5.0.0' } repositories { mavenCentral() @@ -46,12 +48,13 @@ repositories { secrets { // To add your Google Maps Platform API key to this project: - // 1. Create or open file local.properties in this folder, which will be ready by default - // by secrets_gradle_plugin + // 1. Create or open file secrets.properties in the root folder of the project, which will be + // read by secrets_gradle_plugin // 2. Add this line, replacing YOUR_API_KEY with a key from a project with Places API enabled: // PLACES_API_KEY=YOUR_API_KEY // 3. Add this line, replacing YOUR_API_KEY with a key from a project with Maps SDK for Android // enabled (can be the same project and key as in Step 2): // MAPS_API_KEY=YOUR_API_KEY + propertiesFileName = "secrets.properties" defaultPropertiesFileName 'local.defaults.properties' } \ No newline at end of file diff --git a/demo-kotlin/app/src/main/java/com/example/placesdemo/AutocompleteAddressActivity.kt b/demo-kotlin/app/src/main/java/com/example/placesdemo/AutocompleteAddressActivity.kt index 18143ac7..6380d3e5 100644 --- a/demo-kotlin/app/src/main/java/com/example/placesdemo/AutocompleteAddressActivity.kt +++ b/demo-kotlin/app/src/main/java/com/example/placesdemo/AutocompleteAddressActivity.kt @@ -41,7 +41,7 @@ import com.google.android.gms.maps.model.MapStyleOptions import com.google.android.gms.maps.model.Marker import com.google.android.gms.maps.model.MarkerOptions import com.google.android.libraries.places.api.model.Place -import com.google.android.libraries.places.api.model.TypeFilter +import com.google.android.libraries.places.api.model.PlaceTypes import com.google.android.libraries.places.widget.Autocomplete import com.google.android.libraries.places.widget.model.AutocompleteActivityMode import com.google.maps.android.SphericalUtil.computeDistanceBetween @@ -101,8 +101,7 @@ class AutocompleteAddressActivity : AppCompatActivity(R.layout.autocomplete_addr // Build the autocomplete intent with field, country, and type filters applied val intent = Autocomplete.IntentBuilder(AutocompleteActivityMode.OVERLAY, fields) .setCountries(listOf("US")) - //TODO: https://developers.google.com/maps/documentation/places/android-sdk/autocomplete - .setTypesFilter(listOf(TypeFilter.ADDRESS.toString().lowercase())) + .setTypesFilter(listOf(PlaceTypes.ADDRESS)) .build(this) startAutocomplete.launch(intent) } diff --git a/demo-kotlin/app/src/main/java/com/example/placesdemo/CurrentPlaceActivity.kt b/demo-kotlin/app/src/main/java/com/example/placesdemo/CurrentPlaceActivity.kt index 16aa63be..9df20a0e 100644 --- a/demo-kotlin/app/src/main/java/com/example/placesdemo/CurrentPlaceActivity.kt +++ b/demo-kotlin/app/src/main/java/com/example/placesdemo/CurrentPlaceActivity.kt @@ -78,6 +78,7 @@ class CurrentPlaceActivity : AppCompatActivity() { Place.Field.CURRENT_OPENING_HOURS, Place.Field.DELIVERY, Place.Field.DINE_IN, + Place.Field.EDITORIAL_SUMMARY, Place.Field.OPENING_HOURS, Place.Field.PHONE_NUMBER, Place.Field.RESERVABLE, diff --git a/demo-kotlin/app/src/main/java/com/example/placesdemo/StringUtil.kt b/demo-kotlin/app/src/main/java/com/example/placesdemo/StringUtil.kt index 1692ca2a..d32715ac 100644 --- a/demo-kotlin/app/src/main/java/com/example/placesdemo/StringUtil.kt +++ b/demo-kotlin/app/src/main/java/com/example/placesdemo/StringUtil.kt @@ -45,11 +45,11 @@ object StringUtil { fun convertToLatLngBounds( southWest: String?, northEast: String?): LatLngBounds? { - val soundWestLatLng = convertToLatLng(southWest) + val southWestLatLng = convertToLatLng(southWest) val northEastLatLng = convertToLatLng(northEast) - return if (soundWestLatLng == null || northEast == null) { + return if (southWestLatLng == null || northEastLatLng == null) { null - } else LatLngBounds(soundWestLatLng, northEastLatLng) + } else LatLngBounds(southWestLatLng, northEastLatLng) } fun convertToLatLng(value: String?): LatLng? { diff --git a/snippets/app/build.gradle b/snippets/app/build.gradle index 45bcb8be..792ac8de 100644 --- a/snippets/app/build.gradle +++ b/snippets/app/build.gradle @@ -47,7 +47,7 @@ dependencies { androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' // [END_EXCLUDE] // [START maps_android_places_upgrade_snippet] - implementation 'com.google.android.libraries.places:places:3.1.0' + implementation 'com.google.android.libraries.places:places:3.2.0' // [END maps_android_places_upgrade_snippet] } // [END maps_android_places_install_snippet]