Skip to content

Commit

Permalink
fix: upgrade build dependencies (#216)
Browse files Browse the repository at this point in the history
* fix: MyItem class
* chore: update dependencies and secrets gradle plugin

BREAKING CHANGE: Since android-maps-utils v3.2.0 introduced z-index to marker clusters, this change propagates that change. See release notes from android-maps-utils v3.2.0 https://github.com/googlemaps/android-maps-utils/releases/tag/v3.2.0

---------

Co-authored-by: Angela Yu <[email protected]>
  • Loading branch information
kikoso and wangela authored Oct 27, 2023
1 parent 7d15c30 commit ac28a84
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ local.properties
.project
project.properties
secure.properties
secrets.properties
.DS_Store
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ It enables you to write more concise, idiomatic Kotlin. Each set of extensions c
## Requirements
* Kotlin-enabled project
* Kotlin coroutines
* API level 15+
* API level 21+
* An [API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)

## Installation

If you are using the Maps SDK through Google Play Services:

```groovy
dependencies {
Expand All @@ -33,8 +32,6 @@ dependencies {
}
```

_**Note**_: The Beta version of the SDK is deprecated and scheduled for decommissioning. A future version of the SDK will provide similar support for Beta features. See the [release notes](https://developers.google.com/maps/documentation/android-sdk/releases#2021-08-18) for more information.

## Example Usage

With this KTX library, you should be able to take advantage of several Kotlin language features such as extension functions, named parameters and default arguments, destructuring declarations, and coroutines.
Expand All @@ -48,8 +45,8 @@ This repository includes a [demo app](app) that illustrates the use of this KTX
To run the demo app, you'll have to:

1. [Get a Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key)
1. Create a file in the root directory called `secure.properties` (this file should *NOT* be under version control to protect your API key)
1. Add a single line to `secure.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
1. Create a file in the root directory called `secrets.properties` (this file should *NOT* be under version control to protect your API key)
1. Add a single line to `secrets.properties` that looks like `MAPS_API_KEY=YOUR_API_KEY`, where `YOUR_API_KEY` is the API key you obtained in the first step
1. Build and run

### Maps SDK KTX
Expand Down
20 changes: 8 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,24 @@ android {
namespace 'com.google.maps.android.ktx.demo'
}

// [START maps_android_utils_ktx_install_snippet]
dependencies {
// [START_EXCLUDE silent]
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation deps.kotlin
implementation deps.androidx.appcompat
implementation deps.androidx.coreKtx
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
implementation 'com.google.android.gms:play-services-maps:18.2.0'
// implementation 'com.google.maps.android:maps-ktx:3.4.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'

// Instead of the lines below, regular apps would load these libraries from Maven according to
// the README installation instructions
implementation project(':maps-ktx')
// implementation project(':maps-utils-ktx')
// [END_EXCLUDE]
implementation 'com.google.maps.android:maps-utils-ktx:3.4.0'
implementation project(':maps-utils-ktx')
}
// [END maps_android_utils_ktx_install_snippet]

secrets {
// To add your Maps API key to this project:
// 1. Create a file ./secure.properties
// 1. Create a file ./secrets.properties
// 2. Add this line, where YOUR_API_KEY is your API key:
// MAPS_API_KEY=YOUR_API_KEY
propertiesFileName 'secure.properties'
defaultPropertiesFileName 'secure.defaults.properties'
propertiesFileName 'secrets.properties'
defaultPropertiesFileName 'secrets.defaults.properties'
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<!--
To add your Maps API key to this project:
1. Create a file ./secure.properties
1. Create a file ./secrets.properties
2. Add this line, where YOUR_API_KEY is your API key:
MAPS_API_KEY=YOUR_API_KEY
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import org.json.JSONException
* A demo of multiple layers on the map.
*
* To add your Maps API key to this project:
* 1. Create a file ./secure.properties
* 1. Create a file ./secrets.properties
* 2. Add this line, where YOUR_API_KEY is your API key:
* MAPS_API_KEY=YOUR_API_KEY
*/
Expand All @@ -67,7 +67,7 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)

if (BuildConfig.MAPS_API_KEY.isEmpty()) {
Toast.makeText(this, "Add your own API key in ./secure.properties as MAPS_API_KEY=YOUR_API_KEY", Toast.LENGTH_LONG).show()
Toast.makeText(this, "Add your own API key in ./secrets.properties as MAPS_API_KEY=YOUR_API_KEY", Toast.LENGTH_LONG).show()
}

val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013 Google Inc.
* Copyright 2023 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,6 +44,7 @@ class MyItemReader {
for (i in 0 until array.length()) {
var title: String? = null
var snippet: String? = null
var zIndex: Double? = null
val `object` = array.getJSONObject(i)
val lat = `object`.getDouble("lat")
val lng = `object`.getDouble("lng")
Expand All @@ -53,7 +54,10 @@ class MyItemReader {
if (!`object`.isNull("snippet")) {
snippet = `object`.getString("snippet")
}
items.add(MyItem(LatLng(lat, lng), title, snippet))
if (!`object`.isNull("zIndex")) {
zIndex = `object`.getDouble("zIndex")
}
items.add(MyItem(LatLng(lat, lng), title, snippet, zIndex?.toFloat()))
}
return items
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Google Inc.
* Copyright 2023 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,8 +26,9 @@ import com.google.maps.android.clustering.ClusterItem
* (https://youtrack.jetbrains.com/issue/KT-6653?_ga=2.30406975.1494223917.1585591891-1137021041.1573759593)
* so we must name our fields differently and then pass them to the ClusterItem methods.
*/
data class MyItem(val latLng: LatLng, val myTitle: String?, val mySnippet: String?) : ClusterItem {
data class MyItem(val latLng: LatLng, val myTitle: String?, val mySnippet: String?, val myZIndex: Float?) : ClusterItem {
override fun getPosition() = latLng
override fun getTitle() = myTitle
override fun getSnippet() = mySnippet
override fun getZIndex() = myZIndex
}
11 changes: 5 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ buildscript {
"minSdk" : 19,
"targetSdk" : 34
],
'androidMapsUtils' : '3.5.3',
'androidMapsUtils' : '3.7.0',
'androidx' : [
'appcompat': '1.1.0',
'coreKtx' : '1.2.0',
Expand All @@ -35,7 +35,7 @@ buildscript {
'kotlinxCoroutines': '1.6.0',
'mockito' : '3.0.0',
'mockitoKotlin' : '2.2.0',
'playServices' : '18.1.0',
'androidMapsSdk' : '18.2.0',
'volley' : '1.2.0',
]

Expand All @@ -53,11 +53,10 @@ buildscript {
'junit' : "junit:junit:$versions.junit",
'kotlin' : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlin",
'kotlinxCoroutines': "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.kotlinxCoroutines",
'mapsBeta' : "com.google.android.libraries.maps:maps:$versions.mapsBeta",
'mockito' : "org.mockito:mockito-core:$versions.mockito",
'mockitoKotlin' : "com.nhaarman.mockitokotlin2:mockito-kotlin:$versions.mockitoKotlin",
'playServices' : [
'maps' : "com.google.android.gms:play-services-maps:$versions.playServices",
'maps' : "com.google.android.gms:play-services-maps:$versions.androidMapsSdk",
],
'volley' : "com.android.volley:volley:$versions.volley",
]
Expand All @@ -71,7 +70,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.9.10'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
classpath 'com.hiya:jacoco-android:0.2'
classpath 'com.mxalbert.gradle:jacoco-android:0.2.1'
classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
}
}
Expand Down Expand Up @@ -109,7 +108,7 @@ subprojects { project ->
if (project.ext.artifactId == null) return

apply plugin: 'com.android.library'
apply plugin: 'com.hiya.jacoco-android'
apply plugin: 'com.mxalbert.gradle.jacoco-android'
apply plugin: 'maven-publish'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'signing'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Sep 15 07:45:22 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
3 changes: 1 addition & 2 deletions maps-utils-ktx/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2020 Google Inc.
* Copyright 2023 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,7 +51,6 @@ android {
dependencies {
implementation deps.kotlin
api deps.androidMapsUtils.gms
api deps.playServices.maps

// Tests
testImplementation deps.androidx.test
Expand Down
File renamed without changes.

0 comments on commit ac28a84

Please sign in to comment.