Skip to content

Commit

Permalink
Update Mapbox SDK to 9.7.1 and move common gradle methods to configs.…
Browse files Browse the repository at this point in the history
…gradle
  • Loading branch information
ekigamba committed Aug 15, 2022
1 parent db2a14b commit 7dd6d66
Show file tree
Hide file tree
Showing 27 changed files with 234 additions and 165 deletions.
25 changes: 10 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ buildscript {
}

apply plugin: 'com.github.kt3k.coveralls'

apply from: 'configs.gradle'

allprojects {
repositories {
google()
jcenter()
/*maven {
mavenLocal()
maven { url "https://jitpack.io" }
maven {
url "https://dl.cloudsmith.io/public/terraframe/geoprism-registry/maven/"
}
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
Expand All @@ -38,10 +43,11 @@ allprojects {
// This should always be `mapbox` (not your username).
username = "mapbox"
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
password = localProperties['mapbox.repo.token'] ?: ""
}
}*/
}
}

}
/*
task clean(type: Delete) {
Expand All @@ -51,17 +57,6 @@ task clean(type: Delete) {

apply plugin: 'java'

ext {
supportVersion = '1.0.0'
buildToolsVersion = "30.0.2"
compileSdkVersion = 28
volleyVersion = "1.1.0"
targetSdkVersion = 27
jacocoVersion = "0.8.8"
mapboxSdkVersion = "8.3.3"
mapboxAnnotationPluginVersion = "0.6.0"
}

coveralls {
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoFullReport/jacocoFullReport.xml"
sourceDirs += ["utils/src/main/java"
Expand Down
139 changes: 139 additions & 0 deletions configs.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@

ant.condition(property: 'os', value: 'windows') {
os(family: 'windows')
}
ant.condition(property: 'os', value: 'unix') {
os(family: 'unix')
}

// Based on http://stackoverflow.com/questions/17097263#24121734
def getMasterCommitCount = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
switch (ant.properties.os) {
case 'windows':
commandLine 'cmd', '/c', 'git', 'rev-list', '--first-parent', '--count', 'master'
break
case 'unix':
commandLine 'git', 'rev-list', '--first-parent', '--count', 'origin/master'
break
}
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())
} catch (ignored) {
return -1
}
}

def getVersionName = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
switch (ant.properties.os) {
case 'windows':
commandLine 'cmd', '/c', 'git', 'describe', '--tags', '--dirty', '--always'
break
case 'unix':
commandLine 'git', 'describe', '--tags', '--dirty', '--always'
break
}
standardOutput = stdout
}
return stdout.toString().trim()
} catch (ignored) {
return null
}
}

ext.getMasterCommitCount = getMasterCommitCount
ext.getVersionName = getVersionName


// LOAD PROPERTIES FILE
Properties properties = new Properties()
String[] propertyKeys = ["cgr.username", "cgr.password", "cgr.url", "mapbox.sdk.token", "mapbox.repo.token"]


if (project.rootProject.file("local.properties").exists()) {
properties.load(project.rootProject.file("local.properties").newDataInputStream())

if (properties != null) {
boolean containsAllKeys = true
ArrayList<String> missingKeys = new ArrayList<>()

for (String propertyKey: propertyKeys) {
if (!properties.containsKey(propertyKey)) {
missingKeys.add(propertyKey)
containsAllKeys = false
}
}

if (!containsAllKeys) {
println(("One of the required config variables is not set in your local.properties. Make sure you have " + missingKeys.join(", ")))
}
} else {
println("Properties was null!! The file does not exist or contains nothing")
}
} else {
println("local.properties does not exist")
}

if (properties == null) {
properties = new Properties()
}

for (String propertyKey: propertyKeys) {
if (!properties.containsKey(propertyKey)) {
properties.put(propertyKey, "\"\"")
}
}

ext.localProperties = properties


/**
Dependencies
*/

ext {
supportVersion = '1.0.0'
buildToolsVersion = "30.0.2"
compileSdkVersion = 28
volleyVersion = "1.2.0"
targetSdkVersion = 27
jacocoVersion = "0.8.8"
mapboxSdkVersion = "9.7.1"
mapboxAnnotationPluginVersion = "0.6.0"

mapboxSDK = "com.mapbox.mapboxsdk:mapbox-android-sdk:$mapboxSdkVersion"
mapboxSDKTurf = "com.mapbox.mapboxsdk:mapbox-sdk-turf:4.8.0"
mapboxAnnotationPlugin = "com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:$mapboxAnnotationPluginVersion"
}


//ext.mapboxSDK = "com.mapbox.maps:android:10.7.0"

ext.mapboxDependencies = { instance, configuration ->

configuration.implementation("com.mapbox.maps:android:$mapboxSdkVersion") {
transitive = true;
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-fragment'
}


// The local build has an issue fetching this library for some reason which
// is a dependency of the mapbox-android-sdk. The mapbox-sdk-turf is declared as
// a runtime dependency
configuration.implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.8.0'
configuration.implementation "com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:${instance.mapboxAnnotationPluginVersion}"

}

//ext.mapboxDependencies = mapboxDependencies
24 changes: 8 additions & 16 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,11 @@ buildscript {
}
}

allprojects {
repositories {
maven { url "https://dl.google.com/dl/android/maven2/" }
mavenLocal()
}
}

apply plugin: 'realm-android'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'

version '0.9.0'
version '0.10.0'

project.version = this.version

Expand Down Expand Up @@ -58,7 +51,7 @@ android {
properties.load(project.rootProject.file("local.properties").newDataInputStream())
if (properties != null &&
properties.containsKey("mapbox.sdk.token")) {
buildConfigField "String", "MAPBOX_SDK_ACCESS_TOKEN", properties["mapbox.sdk.token"]
buildConfigField "String", "MAPBOX_SDK_ACCESS_TOKEN", localProperties["mapbox.sdk.token"]
} else {
println("One of the required config variables is not set in your local.properties");
buildConfigField "String", "MAPBOX_SDK_ACCESS_TOKEN", "\"sample_key\""
Expand All @@ -78,7 +71,7 @@ android {
properties.load(project.rootProject.file("local.properties").newDataInputStream())
if (properties != null &&
properties.containsKey("mapbox.sdk.token")) {
buildConfigField "String", "MAPBOX_SDK_ACCESS_TOKEN", properties["mapbox.sdk.token"]
buildConfigField "String", "MAPBOX_SDK_ACCESS_TOKEN", localProperties["mapbox.sdk.token"]
} else {
println("One of the required config variables is not set in your local.properties");
buildConfigField "String", "MAPBOX_SDK_ACCESS_TOKEN", "\"sample_key\""
Expand All @@ -105,7 +98,7 @@ android {

dependencies { configuration ->
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation ("com.mapbox.mapboxsdk:mapbox-android-sdk:${mapboxSdkVersion}") {
implementation (mapboxSDK) {
transitive = true;
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-annotations'
Expand All @@ -115,14 +108,13 @@ dependencies { configuration ->
// The local build has an issue fetching this library for some reason which
// is a dependency of the mapbox-android-sdk. The mapbox-sdk-turf is declared as
// a runtime dependency
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.8.0'

implementation "com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:${mapboxAnnotationPluginVersion}"
implementation mapboxSDKTurf
implementation mapboxAnnotationPlugin

// Comment the line below when creating releases - The line is for development of the library & utils
//implementation (project(":utils")) {
implementation (project(":utils")) {
// Uncomment the line below when creating releases
implementation('io.ona.kujaku:utils:0.8.0') {
//implementation('io.ona.kujaku:utils:0.9.0') {
transitive = true;
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
exclude group: 'com.android.support', module: 'support-v4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void addPointShouldMakeAddViewVisible() {
assertEquals(View.GONE, addBtn.getVisibility());
kujakuMapView.addPoint(false, new AddPointCallback() {
@Override
public void onPointAdd(JSONObject jsonObject) {
public void onPointAdd(JSONObject featureGeoJSON) {
// Do nothing
}

Expand All @@ -210,7 +210,7 @@ public void addPointShouldPerformActionsOnClick() {

kujakuMapView.addPoint(false, new AddPointCallback() {
@Override
public void onPointAdd(JSONObject jsonObject) {
public void onPointAdd(JSONObject featureGeoJSON) {
states.put(isPointAddCalled, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
public interface AddPointCallback {

/**
* Called when the user selects a specific point on the UI.
* Called when the user selects a specific point on the UI. A JSONObject of the Feature
* is returned to the application
*
* @param jsonObject
* @param featureGeoJSON
*/
void onPointAdd(JSONObject jsonObject);
void onPointAdd(JSONObject featureGeoJSON);

/**
* This method is called if & when the user cancels the <strong>Add Point</strong> operation.
Expand Down
15 changes: 10 additions & 5 deletions library/src/main/java/io/ona/kujaku/views/KujakuMapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import androidx.annotation.VisibleForTesting;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.Button;
Expand Down Expand Up @@ -213,25 +214,29 @@ public class KujakuMapView extends MapView implements IKujakuMapView, MapboxMap.
// private DrawingManager drawingManager = null ;
public KujakuMapView(@NonNull Context context) {
super(context);
init(null);
init(context, null);
}

public KujakuMapView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(attrs);
init(context, attrs);
}

public KujakuMapView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(attrs);
init(context, attrs);
}

public KujakuMapView(@NonNull Context context, @Nullable MapboxMapOptions options) {
super(context, options);
init(null);
init(context, null);
}

private void init(@Nullable AttributeSet attributeSet) {
private void init(@NonNull Context context, @Nullable AttributeSet attributeSet) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.mapbox_mapview_internal, this, true);

PermissionsHelper.checkPermissions(TAG, getContext());

markerLayout = findViewById(R.id.iv_mapview_locationSelectionMarker);
Expand Down
Loading

0 comments on commit 7dd6d66

Please sign in to comment.