Skip to content

Commit abcc8b5

Browse files
dkhawkkikoso
andauthored
feat: copies some snippets that were in v3 only to gms (#1715)
* 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]>
1 parent 4297488 commit abcc8b5

File tree

23 files changed

+349
-52
lines changed

23 files changed

+349
-52
lines changed

.github/workflows/build.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ jobs:
3636
steps:
3737
- uses: actions/checkout@v2
3838

39-
- name: set up Java 17
39+
- name: set up Java 21
4040
uses: actions/setup-java@v2
4141
with:
4242
distribution: 'adopt'
43-
java-version: '17'
43+
java-version: '21'
4444

4545
- name: Build and check
4646
run: |
@@ -54,11 +54,11 @@ jobs:
5454
steps:
5555
- uses: actions/checkout@v2
5656

57-
- name: set up Java 17
57+
- name: set up Java 21
5858
uses: actions/setup-java@v2
5959
with:
6060
distribution: 'adopt'
61-
java-version: '17'
61+
java-version: '21'
6262

6363
- name: Build and check
6464
run: cd WearOS && ./gradlew build
@@ -70,11 +70,11 @@ jobs:
7070
steps:
7171
- uses: actions/checkout@v2
7272

73-
- name: set up Java 17
73+
- name: set up Java 21
7474
uses: actions/setup-java@v2
7575
with:
7676
distribution: 'adopt'
77-
java-version: '17'
77+
java-version: '21'
7878

7979
- name: Build and check
8080
run: |
@@ -88,11 +88,11 @@ jobs:
8888
steps:
8989
- uses: actions/checkout@v2
9090

91-
- name: set up Java 17
91+
- name: set up Java 21
9292
uses: actions/setup-java@v2
9393
with:
9494
distribution: 'adopt'
95-
java-version: '17'
95+
java-version: '21'
9696

9797
- name: Build and check
9898
run: |

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626
with:
2727
token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}
2828

29-
- name: set up Java 17
29+
- name: set up Java 21
3030
uses: actions/setup-java@v3
3131
with:
3232
distribution: 'temurin'
33-
java-version: '17'
33+
java-version: '21'
3434

3535
- name: Build APKs
3636
run: |

ApiDemos/java/app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ android {
3636
}
3737
}
3838
compileOptions {
39-
sourceCompatibility JavaVersion.VERSION_17
40-
targetCompatibility JavaVersion.VERSION_17
39+
sourceCompatibility JavaVersion.VERSION_21
40+
targetCompatibility JavaVersion.VERSION_21
4141
}
4242
namespace "com.example.mapdemo"
4343
}

ApiDemos/kotlin/app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ android {
3636
}
3737
}
3838
compileOptions {
39-
sourceCompatibility JavaVersion.VERSION_17
40-
targetCompatibility JavaVersion.VERSION_17
39+
sourceCompatibility JavaVersion.VERSION_21
40+
targetCompatibility JavaVersion.VERSION_21
4141
}
4242
lintOptions {
4343
abortOnError false

WearOS/Wearable/build.gradle

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,16 @@ android {
3939
namespace 'com.example.wearosmap'
4040

4141
kotlinOptions {
42-
jvmTarget = "17"
42+
jvmTarget = "21"
4343
}
4444
kotlin {
45-
jvmToolchain(17)
45+
jvmToolchain(21)
4646
}
4747
}
4848

4949
// [START maps_wear_os_dependencies]
5050
dependencies {
5151
// [START_EXCLUDE]
52-
implementation fileTree(dir: 'libs', include: ['*.jar'])
5352
implementation "androidx.core:core-ktx:1.13.1"
5453
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0'
5554
// [END_EXCLUDE]

snippets/app-compose/build.gradle

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,18 @@ android {
3232
buildConfig = true
3333
}
3434
compileOptions {
35-
sourceCompatibility JavaVersion.VERSION_1_8
36-
targetCompatibility JavaVersion.VERSION_1_8
35+
sourceCompatibility JavaVersion.VERSION_21
36+
targetCompatibility JavaVersion.VERSION_21
3737
}
3838
kotlinOptions {
39-
jvmTarget = '1.8'
39+
jvmTarget = '21'
4040
}
4141
}
4242

4343
// [START maps_android_compose_dependency]
4444
dependencies {
4545

4646
// [START_EXCLUDE silent]
47-
implementation fileTree(dir: "libs", include: ["*.jar"])
4847
implementation 'org.jetbrains.kotlin:kotlin-stdlib:2.0.0'
4948
implementation 'androidx.core:core-ktx:1.13.1'
5049
implementation 'androidx.appcompat:appcompat:1.7.0'

snippets/app-ktx/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ android {
3131
}
3232
}
3333
compileOptions {
34-
sourceCompatibility JavaVersion.VERSION_1_8
35-
targetCompatibility JavaVersion.VERSION_1_8
34+
sourceCompatibility JavaVersion.VERSION_21
35+
targetCompatibility JavaVersion.VERSION_21
3636
}
3737
kotlinOptions {
38-
jvmTarget = '1.8'
38+
jvmTarget = '21'
3939
}
4040
}
4141

snippets/app-places-ktx/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ android {
2929
}
3030
}
3131
compileOptions {
32-
sourceCompatibility JavaVersion.VERSION_1_8
33-
targetCompatibility JavaVersion.VERSION_1_8
32+
sourceCompatibility JavaVersion.VERSION_21
33+
targetCompatibility JavaVersion.VERSION_21
3434
}
3535
kotlinOptions {
36-
jvmTarget = '1.8'
36+
jvmTarget = '21'
3737
}
3838
}
3939
// [START places_android_ktx_install_snippet]

snippets/app-rx/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ android {
2929
}
3030
}
3131
compileOptions {
32-
sourceCompatibility JavaVersion.VERSION_1_8
33-
targetCompatibility JavaVersion.VERSION_1_8
32+
sourceCompatibility JavaVersion.VERSION_21
33+
targetCompatibility JavaVersion.VERSION_21
3434
}
3535
kotlinOptions {
36-
jvmTarget = '1.8'
36+
jvmTarget = '21'
3737
}
3838
}
3939

snippets/app-utils-ktx/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ android {
2929
}
3030
}
3131
compileOptions {
32-
sourceCompatibility JavaVersion.VERSION_1_8
33-
targetCompatibility JavaVersion.VERSION_1_8
32+
sourceCompatibility JavaVersion.VERSION_21
33+
targetCompatibility JavaVersion.VERSION_21
3434
}
3535
kotlinOptions {
36-
jvmTarget = '1.8'
36+
jvmTarget = '21'
3737
}
3838
}
3939

snippets/app-utils/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ android {
2929
}
3030
}
3131
compileOptions {
32-
sourceCompatibility JavaVersion.VERSION_1_8
33-
targetCompatibility JavaVersion.VERSION_1_8
32+
sourceCompatibility JavaVersion.VERSION_21
33+
targetCompatibility JavaVersion.VERSION_21
3434
}
3535
kotlinOptions {
36-
jvmTarget = '1.8'
36+
jvmTarget = '21'
3737
}
3838
}
3939

snippets/app/build.gradle

+4-5
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,20 @@ android {
4141
}
4242

4343
compileOptions {
44-
sourceCompatibility JavaVersion.VERSION_17
45-
targetCompatibility JavaVersion.VERSION_17
44+
sourceCompatibility JavaVersion.VERSION_21
45+
targetCompatibility JavaVersion.VERSION_21
4646
}
4747
namespace 'com.google.maps.example'
4848
}
4949

5050
// [START maps_android_play_services_maps_dependency]
5151
dependencies {
5252
// [START_EXCLUDE silent]
53-
implementation fileTree(dir: "libs", include: ["*.jar"])
5453
implementation 'org.jetbrains.kotlin:kotlin-stdlib:2.0.0'
5554
implementation 'androidx.core:core-ktx:1.13.1'
5655
implementation 'androidx.appcompat:appcompat:1.7.0'
57-
implementation "androidx.compose.foundation:foundation:1.7.0-beta04"
58-
implementation "androidx.compose.material:material:1.7.0-beta04"
56+
implementation "androidx.compose.foundation:foundation:1.7.0-beta05"
57+
implementation "androidx.compose.material:material:1.7.0-beta05"
5958
implementation 'com.google.android.material:material:1.12.0'
6059
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
6160
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.maps.example;
16+
17+
import android.os.Bundle;
18+
19+
import androidx.annotation.Nullable;
20+
import androidx.appcompat.app.AppCompatActivity;
21+
22+
import com.google.android.gms.maps.GoogleMap;
23+
import com.google.android.gms.maps.model.AdvancedMarkerOptions;
24+
import com.google.android.gms.maps.model.AdvancedMarkerOptions.CollisionBehavior;
25+
import com.google.android.gms.maps.model.LatLng;
26+
import com.google.android.gms.maps.model.Marker;
27+
28+
class AdvancedMarkersCollisionActivity extends AppCompatActivity {
29+
30+
private GoogleMap map;
31+
32+
@Override
33+
protected void onCreate(@Nullable Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
// [START maps_android_marker_collision]
36+
Marker marker = map.addMarker(
37+
new AdvancedMarkerOptions()
38+
.position(new LatLng(10.0, 10.0))
39+
.zIndex(10f) // Optional.
40+
.collisionBehavior(CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY)
41+
);
42+
// [END maps_android_marker_collision]
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.maps.example;
16+
17+
import android.os.Bundle;
18+
19+
import androidx.appcompat.app.AppCompatActivity;
20+
21+
import com.google.android.gms.maps.GoogleMapOptions;
22+
import com.google.android.gms.maps.MapFragment;
23+
24+
public class CloudBasedMapStylingActivity extends AppCompatActivity {
25+
26+
@Override
27+
protected void onCreate(Bundle savedInstanceState) {
28+
super.onCreate(savedInstanceState);
29+
// [START maps_android_cloud_based_map_styling]
30+
MapFragment mapFragment = MapFragment.newInstance(
31+
new GoogleMapOptions()
32+
.mapId(getResources().getString(R.string.map_id)));
33+
// [END maps_android_cloud_based_map_styling]
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.maps.example;
16+
17+
import android.graphics.Color;
18+
19+
import androidx.appcompat.app.AppCompatActivity;
20+
21+
import com.google.android.gms.maps.GoogleMap;
22+
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
23+
import com.google.android.gms.maps.model.LatLng;
24+
import com.google.android.gms.maps.model.Polyline;
25+
import com.google.android.gms.maps.model.PolylineOptions;
26+
import com.google.android.gms.maps.model.StampStyle;
27+
import com.google.android.gms.maps.model.StrokeStyle;
28+
import com.google.android.gms.maps.model.StyleSpan;
29+
import com.google.android.gms.maps.model.TextureStyle;
30+
31+
public class PolylineCustomizationActivity extends AppCompatActivity {
32+
33+
private GoogleMap map;
34+
35+
private void multicoloredPolyline() {
36+
// [START maps_android_polyline_multicolored]
37+
Polyline line = map.addPolyline(new PolylineOptions()
38+
.add(new LatLng(47.6677146,-122.3470447), new LatLng(47.6442757,-122.2814693))
39+
.addSpan(new StyleSpan(Color.RED))
40+
.addSpan(new StyleSpan(Color.GREEN)));
41+
// [END maps_android_polyline_multicolored]
42+
}
43+
44+
private void multicoloredGradientPolyline() {
45+
// [START maps_android_polyline_gradient]
46+
Polyline line = map.addPolyline(new PolylineOptions()
47+
.add(new LatLng(47.6677146,-122.3470447), new LatLng(47.6442757,-122.2814693))
48+
.addSpan(new StyleSpan(StrokeStyle.gradientBuilder(Color.RED, Color.YELLOW).build())));
49+
// [END maps_android_polyline_gradient]
50+
}
51+
52+
private void stampedPolyline() {
53+
// [START maps_android_polyline_stamped]
54+
StampStyle stampStyle =
55+
TextureStyle.newBuilder(BitmapDescriptorFactory.fromResource(R.drawable.walking_dot)).build();
56+
StyleSpan span = new StyleSpan(StrokeStyle.colorBuilder(Color.RED).stamp(stampStyle).build());
57+
map.addPolyline(new PolylineOptions()
58+
.add(new LatLng(47.6677146,-122.3470447), new LatLng(47.6442757,-122.2814693))
59+
.addSpan(span));
60+
// [END maps_android_polyline_stamped]
61+
}
62+
}

0 commit comments

Comments
 (0)