Skip to content

Commit

Permalink
feat: update to places SDK 4.0.0 (#746)
Browse files Browse the repository at this point in the history
* fix: initialize Places SDK at the application level

* fix: initialize Places SDK at the application level

* fix! update to PlacesSDK 4.0.0.
Upgrade dependencies.
Min SDK version 23.
Target SDK version 25.

* feat: updates to places SDK 4.0.0

* fix: addes missing copyright headers
  • Loading branch information
dkhawk authored Sep 20, 2024
1 parent 22a6fb3 commit 00cefeb
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 68 deletions.
24 changes: 12 additions & 12 deletions demo-java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
compileSdk 34
defaultConfig {
applicationId "com.example.placesdemo"
minSdkVersion 21
targetSdkVersion 34
minSdkVersion 23
targetSdkVersion 35
multiDexEnabled true
versionCode 1
versionName "1.0"
Expand All @@ -28,21 +28,21 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.7.6'
implementation 'androidx.navigation:navigation-ui:2.7.6'
implementation "androidx.activity:activity:1.8.2"
implementation "androidx.fragment:fragment:1.6.2"
implementation 'androidx.navigation:navigation-fragment:2.8.1'
implementation 'androidx.navigation:navigation-ui:2.8.1'
implementation "androidx.activity:activity:1.9.2"
implementation "androidx.fragment:fragment:1.8.3"
implementation 'com.android.volley:volley:1.2.1'
implementation "com.github.bumptech.glide:glide:4.16.0"
implementation "com.android.databinding:viewbinding:8.2.2"
implementation "com.android.databinding:viewbinding:8.6.1"

// Places and Maps SDKs
implementation 'com.google.android.libraries.places:places:3.3.0'
implementation 'com.google.android.gms:play-services-maps:18.2.0'
implementation 'com.google.maps.android:android-maps-utils:3.8.0'
implementation 'com.google.android.libraries.places:places:4.0.0'
implementation 'com.google.android.gms:play-services-maps:19.0.0'
implementation 'com.google.maps.android:android-maps-utils:3.8.2'
}

secrets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
Field.CURRENT_OPENING_HOURS,
Field.DELIVERY,
Field.DINE_IN,
Field.EDITORIAL_SUMMARY,
Field.INTERNATIONAL_PHONE_NUMBER,
Field.OPENING_HOURS,
Field.PHONE_NUMBER,
Field.RESERVABLE,
Expand All @@ -114,8 +116,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
Field.SERVES_LUNCH,
Field.SERVES_VEGETARIAN_FOOD,
Field.SERVES_WINE,
Field.UTC_OFFSET,
Field.TAKEOUT,
Field.UTC_OFFSET,
Field.WEBSITE_URI,
Field.WHEELCHAIR_ACCESSIBLE_ENTRANCE
);
Expand Down
2 changes: 1 addition & 1 deletion demo-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.2'
classpath 'com.android.tools.build:gradle:8.6.1'
classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
}
}
Expand Down
2 changes: 1 addition & 1 deletion demo-java/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Mar 28 15:43:44 PDT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
15 changes: 8 additions & 7 deletions demo-kotlin/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ plugins {

android {
namespace = "com.example.placesdemo"
compileSdk = 34
compileSdk = 35

defaultConfig {
applicationId = "com.example.placesdemo"
minSdk = 21
targetSdk = 34
minSdk = 23
targetSdk = 35
versionCode = 1
versionName = "1.0"

multiDexEnabled = true
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

buildFeatures {
Expand All @@ -40,7 +41,7 @@ dependencies {
implementation(libs.multidex)

// Google Places
implementation(libs.places.ktx)
implementation(libs.places)
implementation(libs.maps.utils.ktx)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class CurrentPlaceActivity : AppCompatActivity() {
Place.Field.DELIVERY,
Place.Field.DINE_IN,
Place.Field.EDITORIAL_SUMMARY,
Place.Field.INTERNATIONAL_PHONE_NUMBER,
Place.Field.OPENING_HOURS,
Place.Field.PHONE_NUMBER,
Place.Field.RESERVABLE,
Expand All @@ -93,7 +94,7 @@ class CurrentPlaceActivity : AppCompatActivity() {
Place.Field.TAKEOUT,
Place.Field.UTC_OFFSET,
Place.Field.WEBSITE_URI,
Place.Field.WHEELCHAIR_ACCESSIBLE_ENTRANCE
Place.Field.WHEELCHAIR_ACCESSIBLE_ENTRANCE,
)
fieldSelector = FieldSelector(
binding.useCustomFields,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.example.placesdemo

import android.app.Application
Expand All @@ -16,4 +30,4 @@ class PlacesDemoApplication : Application() {

Places.initialize(applicationContext, BuildConfig.PLACES_API_KEY)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
package com.example.placesdemo.model

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.appcompat.widget.AppCompatEditText

class AutocompleteEditText : AppCompatEditText {
constructor(context: Context?) : super(context!!) {}
constructor(context: Context?, attrs: AttributeSet?) : super(
context!!, attrs
) {
}

override fun onTouchEvent(event: MotionEvent): Boolean {
super.onTouchEvent(event)
when (event.action) {
MotionEvent.ACTION_DOWN -> return true
MotionEvent.ACTION_UP -> {
performClick()
return true
}
}
return false
}

// Because we call this from onTouchEvent, this code will be executed for both
// normal touch events and for when the system calls this using Accessibility
override fun performClick(): Boolean {
super.performClick()
return true
}
}
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.example.placesdemo.model

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.appcompat.widget.AppCompatEditText

class AutocompleteEditText : AppCompatEditText {
constructor(context: Context?) : super(context!!) {}
constructor(context: Context?, attrs: AttributeSet?) : super(
context!!, attrs
) {
}

override fun onTouchEvent(event: MotionEvent): Boolean {
super.onTouchEvent(event)
when (event.action) {
MotionEvent.ACTION_DOWN -> return true
MotionEvent.ACTION_UP -> {
performClick()
return true
}
}
return false
}

// Because we call this from onTouchEvent, this code will be executed for both
// normal touch events and for when the system calls this using Accessibility
override fun performClick(): Boolean {
super.performClick()
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
android:hint="@string/autocomplete_location_origin_hint"
android:autofillHints=""
android:imeOptions="actionNext"
android:inputType="text"/>
android:inputType="numberDecimal|numberSigned"
android:digits="0123456789.,- "
/>

<TextView
android:layout_width="wrap_content"
Expand All @@ -63,7 +65,9 @@
android:hint="@string/autocomplete_location_south_west_hint"
android:autofillHints=""
android:imeOptions="actionNext"
android:inputType="text"/>
android:inputType="numberDecimal|numberSigned"
android:digits="0123456789.,- "
/>

<EditText
android:id="@+id/autocomplete_location_bias_north_east"
Expand All @@ -73,7 +77,9 @@
android:hint="@string/autocomplete_location_north_east_hint"
android:autofillHints=""
android:imeOptions="actionNext"
android:inputType="text"/>
android:inputType="numberDecimal|numberSigned"
android:digits="0123456789.,- "
/>
</LinearLayout>

<TextView
Expand All @@ -95,7 +101,9 @@
android:hint="@string/autocomplete_location_south_west_hint"
android:autofillHints=""
android:imeOptions="actionNext"
android:inputType="text"/>
android:inputType="numberDecimal|numberSigned"
android:digits="0123456789.,- "
/>

<EditText
android:id="@+id/autocomplete_location_restriction_north_east"
Expand All @@ -105,7 +113,9 @@
android:hint="@string/autocomplete_location_north_east_hint"
android:autofillHints=""
android:imeOptions="actionNext"
android:inputType="text"/>
android:inputType="numberDecimal|numberSigned"
android:digits="0123456789.,- "
/>
</LinearLayout>

<EditText
Expand Down
10 changes: 5 additions & 5 deletions demo-kotlin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[versions]
androidGradlePlugin = "8.4.1"
androidGradlePlugin = "8.6.1"
appcompat = "1.7.0"
coreKtx = "1.13.1"
glide = "4.16.0"
kotlin = "2.0.0"
mapsSecretsGradlePlugin = "2.0.1"
mapsUtilsKtx = "5.0.0"
mapsUtilsKtx = "5.1.1"
material = "1.12.0"
multidex = "2.0.1"
placesKtx = "3.2.0"
viewbinding = "8.4.1"
places = "4.0.0"
viewbinding = "8.6.1"
volley = "1.2.1"
kotlinParcelize = "1.9.24"

Expand All @@ -20,7 +20,7 @@ glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" }
maps-utils-ktx = { module = "com.google.maps.android:maps-utils-ktx", version.ref = "mapsUtilsKtx" }
material = { module = "com.google.android.material:material", version.ref = "material" }
multidex = { module = "androidx.multidex:multidex", version.ref = "multidex" }
places-ktx = { module = "com.google.maps.android:places-ktx", version.ref = "placesKtx" }
places = { module = "com.google.android.libraries.places:places", version.ref = "places" }
viewbinding = { module = "com.android.databinding:viewbinding", version.ref = "viewbinding" }
volley = { module = "com.android.volley:volley", version.ref = "volley" }

Expand Down
2 changes: 1 addition & 1 deletion demo-kotlin/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Mar 28 15:44:27 PDT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 00cefeb

Please sign in to comment.