Skip to content

Commit

Permalink
chore: set up new snippets modules for region tags (#1368)
Browse files Browse the repository at this point in the history
* chore: move MapsCompose.kt to snippets/app-compose app

* chore: create app-places-ktx snippets module with places-ktx install snippet

* chore: create app-maps-rx snippets module

* chore: create app-ktx snippets module

* chore: add app-utils-ktx snippets module

* chore: rename app-maps-rx to app-rx

* chore: add app-utils snippets module

* chore: move region tag from tutorials to snippets for play services sdk dependency

* chore: move kotlin utils to app-utils-ktx module

* chore: move utils and utils-ktx snippets into corresponding modules

* chore: finalize maps sdk snippets

* chore: upgrade AGP and add namespaces

* chore: fix build issues

* chore: udpate build workflow to Java 17

* chore: fix build errors

* chore: remove v3 files

* Revert "chore: remove v3 files"

This reverts commit f70c47b.

* chore: add default PLACES_API_KEY to Current Place tutorial

* chore: fix tutorial builds
  • Loading branch information
wangela authored Oct 31, 2023
1 parent ff1b2de commit f777167
Show file tree
Hide file tree
Showing 189 changed files with 3,551 additions and 381 deletions.
14 changes: 7 additions & 7 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 11
- name: set up Java 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
java-version: '17'

- name: Uninstall NDK
run: |
Expand All @@ -58,11 +58,11 @@ jobs:
steps:
- uses: actions/checkout@v2

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

- name: Build and check
run: cd WearOS && ./gradlew build
Expand All @@ -87,7 +87,7 @@ jobs:
- name: Build and check
run: |
cd snippets
./gradlew assembleGmsDebug assembleV3Debug lintGmsDebug lintV3Debug
./gradlew assembleGmsDebug lintGmsDebug
build-tutorials:
runs-on: ubuntu-latest
Expand All @@ -96,11 +96,11 @@ jobs:
steps:
- uses: actions/checkout@v2

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

- name: Build and check
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ build/
.gradle
*.iml
local.properties
secrets.properties
.DS_Store
.java-version
46 changes: 9 additions & 37 deletions ApiDemos/java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ plugins {
}

android {
compileSdkVersion 33
compileSdk 33

defaultConfig {
applicationId "com.example.mapdemo"
minSdkVersion 19
targetSdkVersion 33
minSdk 19
targetSdk 33
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildFeatures {
compose true
buildConfig = true
}
buildTypes {
release {
minifyEnabled false
Expand All @@ -30,16 +34,12 @@ android {
applicationIdSuffix ".gms"
versionNameSuffix "-gms"
}
v3 {
dimension "version"
applicationIdSuffix ".v3"
versionNameSuffix "-v3"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
namespace "com.example.mapdemo"
}

dependencies {
Expand All @@ -49,42 +49,14 @@ dependencies {
implementation 'com.android.volley:volley:1.2.1'

// GMS
gmsImplementation 'com.google.android.gms:play-services-maps:18.1.0'

// V3
v3Implementation 'com.google.android.libraries.maps:maps:3.1.0-beta'
gmsImplementation 'com.google.android.gms:play-services-maps:18.2.0'

// Tests
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

// Deprecated
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'))
}

// Deprecated
task generateV3Layout(type: Copy) {
group "V3 Beta"
description "Copies layout files from GMS to V3 BETA."

from 'src/gms/res/layout'
into 'src/v3/res/layout'
filter { line ->
line.replace('com.google.android.gms.maps', 'com.google.android.libraries.maps')
}
}

secrets {
// To add your Maps API key to this project:
// 1. Open the root project's local.properties file
Expand Down
3 changes: 1 addition & 2 deletions ApiDemos/java/app/src/gms/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapdemo">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,17 @@ public void onCircleClick(Circle circle) {
}

private List<PatternItem> getSelectedPattern(int pos) {
switch (PATTERN_TYPE_NAME_RESOURCE_IDS[pos]) {
case R.string.pattern_solid:
return null;
case R.string.pattern_dotted:
return PATTERN_DOTTED;
case R.string.pattern_dashed:
return PATTERN_DASHED;
case R.string.pattern_mixed:
return PATTERN_MIXED;
default:
return null;
int id = PATTERN_TYPE_NAME_RESOURCE_IDS[pos];
if (id == R.string.pattern_solid) {
return null;
} else if (id == R.string.pattern_dotted) {
return PATTERN_DOTTED;
} else if (id == R.string.pattern_dashed) {
return PATTERN_DASHED;
} else if (id == R.string.pattern_mixed) {
return PATTERN_MIXED;
} else {
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.layout_linear:
mRecyclerView.setLayoutManager(mLinearLayoutManager);
break;
case R.id.layout_grid:
mRecyclerView.setLayoutManager(mGridLayoutManager);
break;
int id = item.getItemId();
if (id == R.id.layout_linear) {
mRecyclerView.setLayoutManager(mLinearLayoutManager);
} else if (id == R.id.layout_grid) {
mRecyclerView.setLayoutManager(mGridLayoutManager);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,41 +198,39 @@ private List<LatLng> createRectangle(LatLng center, double halfWidth, double hal
}

private int getSelectedJointType(int pos) {
switch (JOINT_TYPE_NAME_RESOURCE_IDS[pos]) {
case R.string.joint_type_bevel:
return JointType.BEVEL;
case R.string.joint_type_round:
return JointType.ROUND;
case R.string.joint_type_default:
return JointType.DEFAULT;
int id = JOINT_TYPE_NAME_RESOURCE_IDS[pos];
if (id == R.string.joint_type_bevel) {
return JointType.BEVEL;
} else if (id == R.string.joint_type_round) {
return JointType.ROUND;
} else if (id == R.string.joint_type_default) {
return JointType.DEFAULT;
}
return 0;
}

private List<PatternItem> getSelectedPattern(int pos) {
switch (PATTERN_TYPE_NAME_RESOURCE_IDS[pos]) {
case R.string.pattern_solid:
return null;
case R.string.pattern_dotted:
return PATTERN_DOTTED;
case R.string.pattern_dashed:
return PATTERN_DASHED;
case R.string.pattern_mixed:
return PATTERN_MIXED;
default:
int id = PATTERN_TYPE_NAME_RESOURCE_IDS[pos];
if (id == R.string.pattern_solid) {
return null;
} else if (id == R.string.pattern_dotted) {
return PATTERN_DOTTED;
} else if (id == R.string.pattern_dashed) {
return PATTERN_DASHED;
} else if (id == R.string.pattern_mixed) {
return PATTERN_MIXED;
} else {
return null;
}
}

@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
switch (parent.getId()) {
case R.id.strokeJointTypeSpinner:
mutablePolygon.setStrokeJointType(getSelectedJointType(pos));
break;
case R.id.strokePatternSpinner:
mutablePolygon.setStrokePattern(getSelectedPattern(pos));
break;
int parentId = parent.getId();
if (parentId == R.id.strokeJointTypeSpinner) {
mutablePolygon.setStrokeJointType(getSelectedJointType(pos));
} else if (parentId == R.id.strokePatternSpinner) {
mutablePolygon.setStrokePattern(getSelectedPattern(pos));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,48 +140,43 @@ public void onClick(DialogInterface dialog, int which) {
*/
private void setSelectedStyle() {
MapStyleOptions style;
switch (mSelectedStyleId) {
case R.string.style_label_retro:
// Sets the retro style via raw resource JSON.
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_retro);
break;
case R.string.style_label_night:
// Sets the night style via raw resource JSON.
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night);
break;
case R.string.style_label_grayscale:
// Sets the grayscale style via raw resource JSON.
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_grayscale);
break;
case R.string.style_label_no_pois_no_transit:
// Sets the no POIs or transit style via JSON string.
style = new MapStyleOptions("[" +
" {" +
" \"featureType\":\"poi.business\"," +
" \"elementType\":\"all\"," +
" \"stylers\":[" +
" {" +
" \"visibility\":\"off\"" +
" }" +
" ]" +
" }," +
" {" +
" \"featureType\":\"transit\"," +
" \"elementType\":\"all\"," +
" \"stylers\":[" +
" {" +
" \"visibility\":\"off\"" +
" }" +
" ]" +
" }" +
"]");
break;
case R.string.style_label_default:
// Removes previously set style, by setting it to null.
style = null;
break;
default:
return;
int id = mSelectedStyleId;
if (id == R.string.style_label_retro) {
// Sets the retro style via raw resource JSON.
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_retro);
} else if (id == R.string.style_label_night) {
// Sets the night style via raw resource JSON.
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night);
} else if (id == R.string.style_label_grayscale) {
// Sets the grayscale style via raw resource JSON.
style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_grayscale);
} else if (id == R.string.style_label_no_pois_no_transit) {
// Sets the no POIs or transit style via JSON string.
style = new MapStyleOptions("[" +
" {" +
" \"featureType\":\"poi.business\"," +
" \"elementType\":\"all\"," +
" \"stylers\":[" +
" {" +
" \"visibility\":\"off\"" +
" }" +
" ]" +
" }," +
" {" +
" \"featureType\":\"transit\"," +
" \"elementType\":\"all\"," +
" \"stylers\":[" +
" {" +
" \"visibility\":\"off\"" +
" }" +
" ]" +
" }" +
"]");
} else if (id == R.string.style_label_default) {
// Removes previously set style, by setting it to null.
style = null;
} else {
return;
}
mMap.setMapStyle(style);
}
Expand Down
Loading

0 comments on commit f777167

Please sign in to comment.