Skip to content

Commit

Permalink
feat!: bump places to 3.0.0 (#455)
Browse files Browse the repository at this point in the history
feat: add 4 new Atmosphere data fields:
* Place.Field.TAKEOUT
* Place.Field.DELIVERY
* Place.Field.DINE_IN
* Place.Field.CURBSIDE_PICKUP

refactor: rename activities to match product names

BREAKING: New minSDK is API Level 21
BREAKING: Remove v3 beta directory
  • Loading branch information
wangela authored Dec 16, 2022
1 parent 9237a08 commit ea7e0dc
Show file tree
Hide file tree
Showing 78 changed files with 114 additions and 5,127 deletions.
7 changes: 0 additions & 7 deletions V3_FILE_HEADER

This file was deleted.

48 changes: 5 additions & 43 deletions demo-java/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.apache.tools.ant.filters.ConcatFilter

plugins {
id 'com.android.application'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
Expand All @@ -9,7 +7,7 @@ android {
compileSdkVersion 33
defaultConfig {
applicationId "com.example.placesdemo"
minSdkVersion 19
minSdkVersion 21
targetSdkVersion 33
multiDexEnabled true
versionCode 1
Expand All @@ -25,34 +23,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "version"
productFlavors {
gms {
dimension "version"
applicationIdSuffix ".gms"
versionNameSuffix "-gms"
}
v3 {
dimension "version"
applicationIdSuffix ".v3"
versionNameSuffix "-v3"
}
}
namespace 'com.example.placesdemo'
}

task generateV3(type: Copy) {
group "V3 Beta"
description "Copies source code from GMS to V3 BETA."

from 'src/gms/java'
into 'src/v3/java'
filter { line ->
line.replace('com.google.android.gms.maps', 'com.google.android.libraries.maps')
}
filter(ConcatFilter, prepend: file('../../V3_FILE_HEADER'))
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
Expand All @@ -64,21 +37,10 @@ dependencies {
implementation 'com.android.volley:volley:1.2.1'
implementation "com.github.bumptech.glide:glide:4.13.2"

// GMS
gmsImplementation 'com.google.android.libraries.places:places:2.7.0'
gmsImplementation 'com.google.android.gms:play-services-maps:18.1.0'
gmsImplementation 'com.google.maps.android:android-maps-utils:2.4.0'

// V3
v3Implementation name:'places-maps-sdk-3.1.0-beta', ext:'aar'
v3Implementation 'com.google.android.gms:play-services-base:18.1.0'
v3Implementation 'com.google.android.gms:play-services-basement:18.1.0'
v3Implementation 'com.google.android.gms:play-services-gcm:17.0.0'
v3Implementation 'com.google.android.gms:play-services-location:21.0.1'
v3Implementation 'com.google.android.gms:play-services-tasks:18.0.2'
v3Implementation 'com.google.android.libraries.maps:maps:3.1.0-beta'
v3Implementation 'com.google.auto.value:auto-value-annotations:1.9'
v3Implementation 'com.google.code.gson:gson:2.9.0'
// Places and Maps SDKs
implementation 'com.google.android.libraries.places:places:3.0.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.maps.android:android-maps-utils:2.4.0'
}

secrets {
Expand Down
Binary file removed demo-java/app/libs/places-maps-sdk-3.1.0-beta.aar
Binary file not shown.
6 changes: 3 additions & 3 deletions demo-java/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
</intent-filter>
</activity>

<activity android:name=".AutocompleteTestActivity" />
<activity android:name=".PlaceAutocompleteActivity" />
<activity
android:name=".AutocompleteAddressActivity"
android:windowSoftInputMode="stateHidden" />
<activity android:name=".PlaceAndPhotoTestActivity" />
<activity android:name=".CurrentPlaceTestActivity" />
<activity android:name=".PlaceDetailsAndPhotosActivity" />
<activity android:name=".CurrentPlaceActivity" />
<activity
android:name=".programmatic_autocomplete.ProgrammaticAutocompleteToolbarActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
import static android.Manifest.permission.ACCESS_WIFI_STATE;

/**
* Activity for testing {@link PlacesClient#findCurrentPlace(FindCurrentPlaceRequest)}.
* Activity to demonstrate {@link PlacesClient#findCurrentPlace(FindCurrentPlaceRequest)}.
*/
public class CurrentPlaceTestActivity extends AppCompatActivity {
public class CurrentPlaceActivity extends AppCompatActivity {

private PlacesClient placesClient;
private TextView responseView;
Expand All @@ -62,25 +62,27 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setTheme(theme);
}

setContentView(R.layout.current_place_test_activity);
setContentView(R.layout.current_place_activity);

// Retrieve a PlacesClient (previously initialized - see MainActivity)
placesClient = Places.createClient(this);

// Set view objects
List<Field> placeFields =
FieldSelector.allExcept(
Field.ADDRESS_COMPONENTS,
Field.OPENING_HOURS,
Field.PHONE_NUMBER,
Field.UTC_OFFSET,
Field.WEBSITE_URI);
fieldSelector =
new FieldSelector(
findViewById(R.id.use_custom_fields),
findViewById(R.id.custom_fields_list),
placeFields,
savedInstanceState);
List<Field> placeFields = FieldSelector.allExcept(
Field.ADDRESS_COMPONENTS,
Field.CURBSIDE_PICKUP,
Field.DELIVERY,
Field.DINE_IN,
Field.OPENING_HOURS,
Field.PHONE_NUMBER,
Field.UTC_OFFSET,
Field.TAKEOUT,
Field.WEBSITE_URI);
fieldSelector = new FieldSelector(
findViewById(R.id.use_custom_fields),
findViewById(R.id.custom_fields_list),
placeFields,
savedInstanceState);
responseView = findViewById(R.id.response);
setLoading(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.example.placesdemo;

import com.google.android.libraries.places.api.model.Place;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
Expand All @@ -30,6 +28,9 @@
import android.widget.ListView;
import android.widget.TextView;

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

import com.google.android.libraries.places.api.model.Place.Field;

import java.util.ArrayList;
Expand All @@ -39,9 +40,6 @@
import java.util.List;
import java.util.Map;

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

/** Helper class for selecting {@link Field} values. */
public final class FieldSelector {
private static final String SELECTED_PLACE_FIELDS_KEY = "selected_place_fields";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
Places.initialize(getApplicationContext(), apiKey);
}

setLaunchActivityClickListener(R.id.autocomplete_button, AutocompleteTestActivity.class);
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.place_and_photo_button, PlaceAndPhotoTestActivity.class);
setLaunchActivityClickListener(R.id.current_place_button, CurrentPlaceTestActivity.class);
setLaunchActivityClickListener(R.id.place_and_photo_button, PlaceDetailsAndPhotosActivity.class);
setLaunchActivityClickListener(R.id.current_place_button, CurrentPlaceActivity.class);

widgetThemeSpinner = findViewById(R.id.theme_spinner);
widgetThemeSpinner.setAdapter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@
import java.util.List;

/**
* Activity for testing Autocomplete (activity and fragment widgets, and programmatic).
* Activity to demonstrate Place Autocomplete (activity widget intent, fragment widget, and
* {@link PlacesClient#([PlacesClient.findAutocompletePredictions])}).
*/
public class AutocompleteTestActivity extends AppCompatActivity {
public class PlaceAutocompleteActivity extends AppCompatActivity {

private static final int AUTOCOMPLETE_REQUEST_CODE = 23487;
private PlacesClient placesClient;
Expand All @@ -75,7 +76,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setTheme(theme);
}

setContentView(R.layout.autocomplete_test_activity);
setContentView(R.layout.place_autocomplete_activity);

// Retrieve a PlacesClient (previously initialized - see MainActivity)
placesClient = Places.createClient(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@
import androidx.appcompat.app.AppCompatActivity;

/**
* Activity for testing {@link PlacesClient#fetchPlace(FetchPlaceRequest)}.
* Activity to demonstrate {@link PlacesClient#fetchPlace(FetchPlaceRequest)}.
*/
public class PlaceAndPhotoTestActivity extends AppCompatActivity {
public class PlaceDetailsAndPhotosActivity extends AppCompatActivity {

private static final String FETCHED_PHOTO_KEY = "photo_image";
private PlacesClient placesClient;
private ImageView photoView;
private ImageView iconView;
private TextView responseView;
private TextView photoMetadataView;
private PhotoMetadata photo;
private FieldSelector fieldSelector;

Expand All @@ -70,7 +71,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setTheme(theme);
}

setContentView(R.layout.place_and_photo_test_activity);
setContentView(R.layout.place_details_and_photos_activity);

// Retrieve a PlacesClient (previously initialized - see MainActivity)
placesClient = Places.createClient(this);
Expand All @@ -81,6 +82,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
// Set up view objects
responseView = findViewById(R.id.response);
photoView = findViewById(R.id.photo);
photoMetadataView = findViewById(R.id.photo_metadata);
iconView = findViewById(R.id.icon);
CheckBox fetchPhotoCheckbox = findViewById(R.id.fetch_photo_checkbox);
fetchPhotoCheckbox.setOnCheckedChangeListener(
Expand Down Expand Up @@ -118,9 +120,7 @@ protected void onSaveInstanceState(Bundle bundle) {
* #fetchPhoto(PhotoMetadata)} if set in the UI.
*/
private void fetchPlace() {
responseView.setText(null);
photoView.setImageBitmap(null);
iconView.setImageBitmap(null);
clearViews();

dismissKeyboard(findViewById(R.id.place_id_field));

Expand Down Expand Up @@ -206,7 +206,7 @@ private void fetchPhoto(PhotoMetadata photoMetadata) {
response -> {
Bitmap bitmap = response.getBitmap();
photoView.setImageBitmap(bitmap);
StringUtil.prepend(responseView, StringUtil.stringify(bitmap));
StringUtil.prepend(photoMetadataView, StringUtil.stringify(bitmap));
});

photoTask.addOnFailureListener(
Expand Down Expand Up @@ -321,4 +321,11 @@ private void showErrorAlert(@StringRes int messageResId) {
private void setLoading(boolean loading) {
findViewById(R.id.loading).setVisibility(loading ? View.VISIBLE : View.INVISIBLE);
}

private void clearViews() {
responseView.setText(null);
photoView.setImageBitmap(null);
photoMetadataView.setText(null);
iconView.setImageBitmap(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/spacing_large"
tools:context=".CurrentPlaceTestActivity">
tools:context=".CurrentPlaceActivity">

<LinearLayout
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/spacing_large"
tools:context=".AutocompleteTestActivity">
tools:context=".PlaceAutocompleteActivity">

<LinearLayout
android:id="@+id/autocomplete_scroll_container"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/spacing_large"
tools:context=".PlaceAndPhotoTestActivity">
tools:context=".PlaceDetailsAndPhotosActivity">

<LinearLayout
android:id="@+id/place_scroll_container"
Expand Down Expand Up @@ -174,8 +174,15 @@

</LinearLayout>

<TextView
android:id="@+id/photo_metadata"
android:textIsSelectable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/response"
android:freezesText="true"
android:textIsSelectable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Expand Down
6 changes: 3 additions & 3 deletions demo-java/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@
<string name="theme_spinner_text" translatable="false">Choose a color theme…</string>

<!-- Button for launching autocomplete test activity. -->
<string name="autocomplete_button" translatable="false">Autocomplete</string>
<string name="autocomplete_button" translatable="false">Place Autocomplete</string>

<!-- Button for launching autocomplete address form activity. -->
<string name="autocomplete_address_button" translatable="false">Autocomplete Address Form</string>
<string name="autocomplete_address_button" translatable="false">Place Autocomplete Address Form</string>

<!-- Button for launching autocomplete address form activity. -->
<string name="programmatic_autocomplete_geocoding_button">Programmatic Autocomplete + Geocoding</string>

<!-- Button for launching place and photo test activity. -->
<string name="place_and_photo_button" translatable="false">Place and Photo</string>
<string name="place_and_photo_button" translatable="false">Place Details and Place Photos</string>

<!-- Button for launching current place test activity. -->
<string name="current_place_button" translatable="false">Current Place</string>
Expand Down
Loading

0 comments on commit ea7e0dc

Please sign in to comment.