Skip to content

Commit

Permalink
feat: Create maps-ktx module (#20)
Browse files Browse the repository at this point in the history
* Adding maps-ktx module.

* refactor: Move maps utils KTX into a different directory

BREAKING CHANGE: Moved KTX for utils from com.google.maps.android.ktx to
com.google.maps.android.ktx.utils to avoid package name conflicts with
the new maps-ktx module.

* refactor: move core extensions to separate package.

* Using shared version.

* Adjusting settings.gradle.
  • Loading branch information
arriolac authored Mar 26, 2020
1 parent 8a1845a commit 597a70c
Show file tree
Hide file tree
Showing 22 changed files with 113 additions and 32 deletions.
1 change: 1 addition & 0 deletions maps-ktx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
45 changes: 45 additions & 0 deletions maps-ktx/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2020 Google Inc.
*
* 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.
*
*/

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion versions.android.compileSdk
buildToolsVersion versions.android.buildTools

defaultConfig {
minSdkVersion versions.android.minSdk
targetSdkVersion versions.android.targetSdk
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
}

dependencies {
api deps.kotlin
implementation deps.playServicesMaps
implementation deps.kotlinxCoroutines

// Tests
testImplementation deps.androidx.test
testImplementation deps.androidx.junit
testImplementation deps.junit
testImplementation deps.mockito
testImplementation deps.mockitoKotlin
}
Empty file added maps-ktx/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions maps-ktx/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
19 changes: 19 additions & 0 deletions maps-ktx/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
~ Copyright 2020 Google Inc.
~
~ 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.
~
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.maps.android.ktx" />
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

package com.google.maps.android.ktx.core
package com.google.maps.android.ktx

import com.google.android.gms.maps.model.PolygonOptions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

package com.google.maps.android.ktx.core
package com.google.maps.android.ktx

import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.SupportMapFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

package com.google.maps.android.ktx.core
package com.google.maps.android.ktx

import android.graphics.Color
import com.google.android.gms.maps.model.LatLng
Expand All @@ -25,11 +25,12 @@ import org.junit.Test
class PolygonOptionsTest {
@Test
fun testBuilder() {
val polygonOptions = buildPolygonOptions {
strokeWidth(1.0f)
strokeColor(Color.BLACK)
add(LatLng(0.0, 0.0))
}
val polygonOptions =
com.google.maps.android.ktx.buildPolygonOptions {
strokeWidth(1.0f)
strokeColor(Color.BLACK)
add(LatLng(0.0, 0.0))
}
assertEquals(1.0f, polygonOptions.strokeWidth)
assertEquals(Color.BLACK, polygonOptions.strokeColor)
assertEquals(listOf(LatLng(0.0, 0.0)), polygonOptions.points)
Expand Down
10 changes: 0 additions & 10 deletions maps-utils-ktx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,10 @@ android {
defaultConfig {
minSdkVersion versions.android.minSdk
targetSdkVersion versions.android.targetSdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

libraryVariants.all {
it.generateBuildConfig.enabled = false
}
Expand All @@ -49,7 +40,6 @@ dependencies {
api deps.kotlin
api deps.androidMapsUtils
implementation deps.playServicesMaps
implementation deps.kotlinxCoroutines

// Tests
testImplementation deps.androidx.test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
@file:Suppress("NOTHING_TO_INLINE")

package com.google.maps.android.ktx
package com.google.maps.android.ktx.utils

import com.google.android.gms.maps.model.LatLng
import com.google.maps.android.PolyUtil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

@file:Suppress("NOTHING_TO_INLINE")
package com.google.maps.android.ktx
package com.google.maps.android.ktx.utils

import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Polygon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

@file:Suppress("NOTHING_TO_INLINE")
package com.google.maps.android.ktx
package com.google.maps.android.ktx.utils

import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Polyline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

@file:Suppress("NOTHING_TO_INLINE")
package com.google.maps.android.ktx.geojson
package com.google.maps.android.ktx.utils.geojson

import com.google.android.gms.maps.GoogleMap
import com.google.maps.android.collections.GroundOverlayManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

@file:Suppress("NOTHING_TO_INLINE")
package com.google.maps.android.ktx.geometry
package com.google.maps.android.ktx.utils.geometry

import com.google.maps.android.geometry.Point

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

@file:Suppress("NOTHING_TO_INLINE")
package com.google.maps.android.ktx.heatmaps
package com.google.maps.android.ktx.utils.heatmaps

import com.google.android.gms.maps.model.LatLng
import com.google.maps.android.heatmaps.Gradient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

@file:Suppress("NOTHING_TO_INLINE")
package com.google.maps.android.ktx.kml
package com.google.maps.android.ktx.utils.kml

import android.content.Context
import androidx.annotation.RawRes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

package com.google.maps.android.ktx
package com.google.maps.android.ktx.utils

import com.google.android.gms.maps.model.LatLng
import org.junit.Assert.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
*
*/

package com.google.maps.android.ktx
package com.google.maps.android.ktx.utils

import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Polygon
import com.google.maps.android.ktx.utils.contains
import com.google.maps.android.ktx.utils.isOnEdge
import com.nhaarman.mockitokotlin2.doReturn
import com.nhaarman.mockitokotlin2.mock
import org.junit.Assert.assertFalse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
*
*/

package com.google.maps.android.ktx
package com.google.maps.android.ktx.utils

import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Polyline
import com.google.maps.android.ktx.utils.contains
import com.google.maps.android.ktx.utils.sphericalPathLength
import com.nhaarman.mockitokotlin2.doReturn
import com.nhaarman.mockitokotlin2.mock
import org.junit.Assert.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

package com.google.maps.android.ktx.geometry
package com.google.maps.android.ktx.utils.geometry

import com.google.maps.android.geometry.Point
import org.junit.Assert.assertEquals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*
*/

package com.google.maps.android.ktx.heatmap
package com.google.maps.android.ktx.utils.heatmap

import com.google.android.gms.maps.model.LatLng
import com.google.maps.android.heatmaps.WeightedLatLng
import com.google.maps.android.ktx.heatmaps.toWeightedLatLng
import com.google.maps.android.ktx.utils.heatmaps.toWeightedLatLng
import org.junit.Assert.*
import org.junit.Test

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include ':app', ':maps-utils-ktx'
include ':app', ':maps-ktx', ':maps-utils-ktx'
rootProject.name='android-maps-ktx'

0 comments on commit 597a70c

Please sign in to comment.