Skip to content

Commit

Permalink
feat: add samples for release 3.1.0 (#519)
Browse files Browse the repository at this point in the history
* feat: add Java and Kotlin samples for new isOpen API
* feat: add Place Details option to programmatic autocomplete prediction selection handling
* fix: TypeFilter to PlaceType for setTypesFilter #522 
* fix: update deprecated patterns
* fix: update snippets
* chore: update build workflow to use JDK 17
* refactor: general improvements to Java and Kotlin samples
---------

Co-authored-by: Enrique López-Manas <[email protected]>
  • Loading branch information
wangela and kikoso authored Apr 27, 2023
1 parent 9d8d968 commit 3684bc5
Show file tree
Hide file tree
Showing 49 changed files with 1,412 additions and 426 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: set up JDK 11
uses: actions/setup-java@v2.3.1
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'

- name: Install NDK
Expand All @@ -59,12 +59,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: set up JDK 11
uses: actions/setup-java@v2.3.1
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'

- name: Install NDK
Expand All @@ -85,12 +85,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: set up JDK 11
uses: actions/setup-java@v2.3.1
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'

- name: Install NDK
Expand All @@ -106,12 +106,12 @@ jobs:
with:
name: snippets-build-reports
path: snippets/app/build/reports

test: # used as required status check
runs-on: ubuntu-latest
needs:
- build-demo-java
- build-demo-kotlin
- build-snippets
steps:
- run: echo "Fail if all other steps are not successful"
- build-snippets
steps:
- run: echo "Fail if all other steps are not successful"
17 changes: 7 additions & 10 deletions demo-java/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'com.android.application'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}

android {
Expand All @@ -19,10 +20,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'com.example.placesdemo'

buildFeatures {
Expand All @@ -31,26 +28,26 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3'
implementation "androidx.activity:activity:1.6.1"
implementation "androidx.fragment:fragment:1.5.5"
implementation "androidx.fragment:fragment:1.5.7"
implementation 'com.android.volley:volley:1.2.1'
implementation "com.github.bumptech.glide:glide:4.13.2"
implementation "com.android.databinding:viewbinding:7.3.1"
implementation "com.android.databinding:viewbinding:8.0.0"

// Places and Maps SDKs
implementation 'com.google.android.libraries.places:places:3.0.0'
implementation 'com.google.android.libraries.places:places:3.1.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.maps.android:android-maps-utils:2.4.0'
}

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
// 1. Create or open file local.properties in this folder, which will be read by default
// 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
Expand Down
2 changes: 2 additions & 0 deletions demo-java/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

<application
android:allowBackup="true"
Expand Down Expand Up @@ -49,6 +50,7 @@
android:name=".AutocompleteAddressActivity"
android:windowSoftInputMode="stateHidden" />
<activity android:name=".PlaceDetailsAndPhotosActivity" />
<activity android:name=".PlaceIsOpenActivity"/>
<activity android:name=".CurrentPlaceActivity" />
<activity
android:name=".programmatic_autocomplete.ProgrammaticAutocompleteToolbarActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void startAutocompleteIntent() {

// Build the autocomplete intent with field, country, and type filters applied
Intent intent = new Autocomplete.IntentBuilder(AutocompleteActivityMode.OVERLAY, fields)
.setCountry("US")
.setCountries(Arrays.asList("US"))
.setTypesFilter(new ArrayList<String>() {{
add(TypeFilter.ADDRESS.toString().toLowerCase());
}})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,25 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
List<Field> placeFields = FieldSelector.allExcept(
Field.ADDRESS_COMPONENTS,
Field.CURBSIDE_PICKUP,
Field.CURRENT_OPENING_HOURS,
Field.DELIVERY,
Field.DINE_IN,
Field.OPENING_HOURS,
Field.PHONE_NUMBER,
Field.RESERVABLE,
Field.SECONDARY_OPENING_HOURS,
Field.SERVES_BEER,
Field.SERVES_BREAKFAST,
Field.SERVES_BRUNCH,
Field.SERVES_DINNER,
Field.SERVES_LUNCH,
Field.SERVES_VEGETARIAN_FOOD,
Field.SERVES_WINE,
Field.UTC_OFFSET,
Field.TAKEOUT,
Field.WEBSITE_URI);
Field.WEBSITE_URI,
Field.WHEELCHAIR_ACCESSIBLE_ENTRANCE
);
fieldSelector = new FieldSelector(
binding.useCustomFields,
binding.customFieldsList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

package com.example.placesdemo;

import com.example.placesdemo.programmatic_autocomplete.ProgrammaticAutocompleteToolbarActivity;
import com.google.android.libraries.places.api.Places;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.placesdemo.programmatic_autocomplete.ProgrammaticAutocompleteToolbarActivity;
import com.google.android.libraries.places.api.Places;

public class MainActivity extends AppCompatActivity {

@Override
Expand All @@ -47,8 +47,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

setLaunchActivityClickListener(R.id.autocomplete_button, PlaceAutocompleteActivity.class);
setLaunchActivityClickListener(R.id.autocomplete_address_button, AutocompleteAddressActivity.class);
setLaunchActivityClickListener(R.id.programmatic_autocomplete_button, ProgrammaticAutocompleteToolbarActivity.class);
setLaunchActivityClickListener(R.id.programmatic_autocomplete_button, ProgrammaticAutocompleteToolbarActivity.class
);
setLaunchActivityClickListener(R.id.place_and_photo_button, PlaceDetailsAndPhotosActivity.class);
setLaunchActivityClickListener(R.id.is_open_button, PlaceIsOpenActivity.class);
setLaunchActivityClickListener(R.id.current_place_button, CurrentPlaceActivity.class);
}

Expand Down
Loading

0 comments on commit 3684bc5

Please sign in to comment.