Skip to content

Commit

Permalink
feat: copies some snippets that were in v3 only to gms (#1715)
Browse files Browse the repository at this point in the history
* feat: copies some snippets that were in v3 only to gms
chore: the java compatibility version

* fix: updates copyright dates and adds missing copyright

* fix: copyright header for strings.xml

* fix: set Java Version back to 17

* fix: set Java Version back to 17

* fix: set Java Version back to 17

* fix: set Java Version back to 17

* fix: set Java Version back to 17

* feat: creates AdvancedMarkersCollisionActivity to demonstrate marker collision behavior

* chore: not adding jar files in libs directory

* feat: set Java 21 everywhere

---------

Co-authored-by: Enrique López Mañas <[email protected]>
  • Loading branch information
dkhawk and kikoso authored Jul 24, 2024
1 parent dabe959 commit 59d32e4
Show file tree
Hide file tree
Showing 23 changed files with 349 additions and 52 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: set up Java 17
- name: set up Java 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
java-version: '21'

- name: Build and check
run: |
Expand All @@ -54,11 +54,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: set up Java 17
- name: set up Java 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
java-version: '21'

- name: Build and check
run: cd WearOS && ./gradlew build
Expand All @@ -70,11 +70,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: set up Java 17
- name: set up Java 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
java-version: '21'

- name: Build and check
run: |
Expand All @@ -88,11 +88,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: set up Java 17
- name: set up Java 21
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
java-version: '21'

- name: Build and check
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
with:
token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}

- name: set up Java 17
- name: set up Java 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Build APKs
run: |
Expand Down
4 changes: 2 additions & 2 deletions ApiDemos/java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
namespace "com.example.mapdemo"
}
Expand Down
4 changes: 2 additions & 2 deletions ApiDemos/kotlin/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
lintOptions {
abortOnError false
Expand Down
5 changes: 2 additions & 3 deletions WearOS/Wearable/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ android {
namespace 'com.example.wearosmap'

kotlinOptions {
jvmTarget = "17"
jvmTarget = "21"
}
kotlin {
jvmToolchain(17)
jvmToolchain(21)
}
}

// [START maps_wear_os_dependencies]
dependencies {
// [START_EXCLUDE]
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.core:core-ktx:1.13.1"
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0'
// [END_EXCLUDE]
Expand Down
7 changes: 3 additions & 4 deletions snippets/app-compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@ android {
buildConfig = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '21'
}
}

// [START maps_android_compose_dependency]
dependencies {

// [START_EXCLUDE silent]
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'org.jetbrains.kotlin:kotlin-stdlib:2.0.0'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
Expand Down
6 changes: 3 additions & 3 deletions snippets/app-ktx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '21'
}
}

Expand Down
6 changes: 3 additions & 3 deletions snippets/app-places-ktx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '21'
}
}
// [START places_android_ktx_install_snippet]
Expand Down
6 changes: 3 additions & 3 deletions snippets/app-rx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '21'
}
}

Expand Down
6 changes: 3 additions & 3 deletions snippets/app-utils-ktx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '21'
}
}

Expand Down
6 changes: 3 additions & 3 deletions snippets/app-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '21'
}
}

Expand Down
9 changes: 4 additions & 5 deletions snippets/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,20 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
namespace 'com.google.maps.example'
}

// [START maps_android_play_services_maps_dependency]
dependencies {
// [START_EXCLUDE silent]
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'org.jetbrains.kotlin:kotlin-stdlib:2.0.0'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation "androidx.compose.foundation:foundation:1.7.0-beta04"
implementation "androidx.compose.material:material:1.7.0-beta04"
implementation "androidx.compose.foundation:foundation:1.7.0-beta05"
implementation "androidx.compose.material:material:1.7.0-beta05"
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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.google.maps.example;

import android.os.Bundle;

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

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.AdvancedMarkerOptions;
import com.google.android.gms.maps.model.AdvancedMarkerOptions.CollisionBehavior;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;

class AdvancedMarkersCollisionActivity extends AppCompatActivity {

private GoogleMap map;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// [START maps_android_marker_collision]
Marker marker = map.addMarker(
new AdvancedMarkerOptions()
.position(new LatLng(10.0, 10.0))
.zIndex(10f) // Optional.
.collisionBehavior(CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY)
);
// [END maps_android_marker_collision]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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.google.maps.example;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.google.android.gms.maps.GoogleMapOptions;
import com.google.android.gms.maps.MapFragment;

public class CloudBasedMapStylingActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// [START maps_android_cloud_based_map_styling]
MapFragment mapFragment = MapFragment.newInstance(
new GoogleMapOptions()
.mapId(getResources().getString(R.string.map_id)));
// [END maps_android_cloud_based_map_styling]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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.google.maps.example;

import android.graphics.Color;

import androidx.appcompat.app.AppCompatActivity;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.gms.maps.model.StampStyle;
import com.google.android.gms.maps.model.StrokeStyle;
import com.google.android.gms.maps.model.StyleSpan;
import com.google.android.gms.maps.model.TextureStyle;

public class PolylineCustomizationActivity extends AppCompatActivity {

private GoogleMap map;

private void multicoloredPolyline() {
// [START maps_android_polyline_multicolored]
Polyline line = map.addPolyline(new PolylineOptions()
.add(new LatLng(47.6677146,-122.3470447), new LatLng(47.6442757,-122.2814693))
.addSpan(new StyleSpan(Color.RED))
.addSpan(new StyleSpan(Color.GREEN)));
// [END maps_android_polyline_multicolored]
}

private void multicoloredGradientPolyline() {
// [START maps_android_polyline_gradient]
Polyline line = map.addPolyline(new PolylineOptions()
.add(new LatLng(47.6677146,-122.3470447), new LatLng(47.6442757,-122.2814693))
.addSpan(new StyleSpan(StrokeStyle.gradientBuilder(Color.RED, Color.YELLOW).build())));
// [END maps_android_polyline_gradient]
}

private void stampedPolyline() {
// [START maps_android_polyline_stamped]
StampStyle stampStyle =
TextureStyle.newBuilder(BitmapDescriptorFactory.fromResource(R.drawable.walking_dot)).build();
StyleSpan span = new StyleSpan(StrokeStyle.colorBuilder(Color.RED).stamp(stampStyle).build());
map.addPolyline(new PolylineOptions()
.add(new LatLng(47.6677146,-122.3470447), new LatLng(47.6442757,-122.2814693))
.addSpan(span));
// [END maps_android_polyline_stamped]
}
}
Loading

0 comments on commit 59d32e4

Please sign in to comment.