From d23bca9c7f6cc1da31357e697b7594759564710f Mon Sep 17 00:00:00 2001 From: Emux Date: Mon, 30 Oct 2017 08:47:09 +0200 Subject: [PATCH] Gradle 4 and Android plugin 3 improvements #433, fix #436 --- vtm-android-example/AndroidManifest.xml | 6 - vtm-android-example/build.gradle | 21 ++-- vtm-android-example/proguard-rules.pro | 10 ++ .../src/android-logger.properties | 1 - .../android/test/MapFragmentActivity.java | 105 ------------------ .../android/test/MapPositionActivity.java | 88 --------------- .../src/org/oscim/android/test/Samples.java | 2 - vtm-app/build.gradle | 2 +- vtm-app/src/android-logger.properties | 1 - vtm-extras/build.gradle | 2 +- vtm-jts/build.gradle | 2 +- vtm-playground/build.gradle | 16 +-- vtm-tests/build.gradle | 2 +- 13 files changed, 28 insertions(+), 230 deletions(-) create mode 100644 vtm-android-example/proguard-rules.pro delete mode 100644 vtm-android-example/src/android-logger.properties delete mode 100644 vtm-android-example/src/org/oscim/android/test/MapFragmentActivity.java delete mode 100644 vtm-android-example/src/org/oscim/android/test/MapPositionActivity.java delete mode 100644 vtm-app/src/android-logger.properties diff --git a/vtm-android-example/AndroidManifest.xml b/vtm-android-example/AndroidManifest.xml index 15f21ff2..1e6ba131 100644 --- a/vtm-android-example/AndroidManifest.xml +++ b/vtm-android-example/AndroidManifest.xml @@ -52,12 +52,6 @@ - - diff --git a/vtm-android-example/build.gradle b/vtm-android-example/build.gradle index 1a694fca..c151d5b3 100644 --- a/vtm-android-example/build.gradle +++ b/vtm-android-example/build.gradle @@ -7,32 +7,23 @@ repositories { dependencies { implementation project(':vtm-android') implementation project(':vtm-http') - implementation(project(':vtm-jeo')) { - exclude group: 'com.vividsolutions', module: 'jts' - } + implementation project(':vtm-jeo') implementation project(':vtm-json') implementation project(':vtm-jts') implementation project(':vtm-themes') - implementation 'com.noveogroup.android:android-logger:1.3.6' - implementation 'com.vividsolutions:jts-core:1.14.0' implementation('org.jeo:jeo:0-SNAPSHOT') { - exclude group: 'com.vividsolutions', module: 'jts' exclude group: 'org.slf4j', module: 'slf4j-jdk14' } implementation('org.jeo:jeo-render:0-SNAPSHOT') { - exclude group: 'com.vividsolutions', module: 'jts' exclude group: 'org.slf4j', module: 'slf4j-jdk14' } - implementation 'com.android.support:support-v4:27.0.0' + implementation "org.slf4j:slf4j-android:$slf4jVersion" implementation project(':vtm-android-gdx') implementation project(':vtm-gdx') implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" - implementation 'org.mapsforge:mapsforge-core:master-SNAPSHOT' - implementation 'org.mapsforge:mapsforge-poi:master-SNAPSHOT' implementation 'org.mapsforge:mapsforge-poi-android:master-SNAPSHOT' - implementation 'org.mapsforge:spatialite-android:master-SNAPSHOT' implementation 'org.mapsforge:spatialite-android:master-SNAPSHOT:natives-armeabi' implementation 'org.mapsforge:spatialite-android:master-SNAPSHOT:natives-armeabi-v7a' implementation 'org.mapsforge:spatialite-android:master-SNAPSHOT:natives-x86' @@ -79,6 +70,14 @@ android { exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' } + + buildTypes { + all { + minifyEnabled true + useProguard false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } } task run(dependsOn: 'installDebug') { diff --git a/vtm-android-example/proguard-rules.pro b/vtm-android-example/proguard-rules.pro new file mode 100644 index 00000000..584189fa --- /dev/null +++ b/vtm-android-example/proguard-rules.pro @@ -0,0 +1,10 @@ +-keep class com.** { *; } +-dontwarn com.** +-keep class jsqlite.** { *; } +-dontwarn jsqlite.** +-keep class okhttp3.** { *; } +-dontwarn okhttp3.** +-keep class okio.** { *; } +-dontwarn okio.** +-keep class org.** { *; } +-dontwarn org.** diff --git a/vtm-android-example/src/android-logger.properties b/vtm-android-example/src/android-logger.properties deleted file mode 100644 index 47f60ed5..00000000 --- a/vtm-android-example/src/android-logger.properties +++ /dev/null @@ -1 +0,0 @@ -root=DEBUG:%logger \ No newline at end of file diff --git a/vtm-android-example/src/org/oscim/android/test/MapFragmentActivity.java b/vtm-android-example/src/org/oscim/android/test/MapFragmentActivity.java deleted file mode 100644 index 200dc2aa..00000000 --- a/vtm-android-example/src/org/oscim/android/test/MapFragmentActivity.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2016 Mathieu De Brito - * Copyright 2017 devemux86 - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ -package org.oscim.android.test; - -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import org.oscim.android.MapPreferences; -import org.oscim.android.MapView; -import org.oscim.core.MapPosition; -import org.oscim.layers.GroupLayer; -import org.oscim.layers.tile.buildings.BuildingLayer; -import org.oscim.layers.tile.vector.VectorTileLayer; -import org.oscim.layers.tile.vector.labeling.LabelLayer; -import org.oscim.theme.VtmThemes; -import org.oscim.tiling.source.oscimap4.OSciMap4TileSource; - -public class MapFragmentActivity extends FragmentActivity { - - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_map_fragment); - - setTitle(getClass().getSimpleName()); - - MapFragment newFragment = new MapFragment(); - getSupportFragmentManager() - .beginTransaction() - .add(R.id.fragment_container, newFragment) - .commit(); - } - - public static class MapFragment extends Fragment { - - private MapView mMapView; - private MapPreferences mPrefs; - - @Nullable - @Override - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View contentView = super.onCreateView(inflater, container, savedInstanceState); - if (contentView == null) { - contentView = inflater.inflate(R.layout.fragment_map, container, false); - } - return contentView; - } - - @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - mMapView = (MapView) view.findViewById(R.id.mapView); - mPrefs = new MapPreferences(MapFragment.class.getName(), getContext()); - - VectorTileLayer l = mMapView.map().setBaseMap(new OSciMap4TileSource()); - - GroupLayer groupLayer = new GroupLayer(mMapView.map()); - groupLayer.layers.add(new BuildingLayer(mMapView.map(), l)); - groupLayer.layers.add(new LabelLayer(mMapView.map(), l)); - mMapView.map().layers().add(groupLayer); - - mMapView.map().setTheme(VtmThemes.DEFAULT); - - // set initial position on first run - MapPosition pos = new MapPosition(); - mMapView.map().getMapPosition(pos); - if (pos.x == 0.5 && pos.y == 0.5) - mMapView.map().setMapPosition(53.08, 8.83, Math.pow(2, 16)); - } - - @Override - public void onResume() { - super.onResume(); - - mPrefs.load(mMapView.map()); - mMapView.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - - mMapView.onPause(); - mPrefs.save(mMapView.map()); - } - } -} diff --git a/vtm-android-example/src/org/oscim/android/test/MapPositionActivity.java b/vtm-android-example/src/org/oscim/android/test/MapPositionActivity.java deleted file mode 100644 index 1a00ea28..00000000 --- a/vtm-android-example/src/org/oscim/android/test/MapPositionActivity.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2016 Mathieu De Brito - * Copyright 2016 devemux86 - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ -package org.oscim.android.test; - -import android.os.Bundle; -import android.widget.Toast; - -import org.oscim.core.MapPosition; -import org.oscim.core.MercatorProjection; - -/** - * Test consecutive map position animations. - */ -public class MapPositionActivity extends SimpleMapActivity { - - // Reuse MapPosition instance - private final MapPosition mapPosition = new MapPosition(); - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - runTest(); - } - - @Override - protected void onResume() { - super.onResume(); - - /* ignore saved position */ - mMap.setMapPosition(0, 0, 1 << 2); - } - - private void animateToBearing(final float bearing) { - mMap.postDelayed(new Runnable() { - @Override - public void run() { - mMap.getMapPosition(mapPosition); - mapPosition.setBearing(bearing); - mMap.animator().animateTo(1000, mapPosition); - } - }, 500); - } - - private void animateToLocation(final double latitude, final double longitude) { - mMap.postDelayed(new Runnable() { - @Override - public void run() { - mMap.getMapPosition(true, mapPosition); - mapPosition.setPosition(latitude, longitude); - mMap.animator().animateTo(1000, mapPosition); - } - }, 1000); - } - - private void runTest() { - // 1 - ask for a bearing - final float bearing = 180; - animateToBearing(bearing); - - // 2 - ask for a new location - double latitude = Math.random() * MercatorProjection.LATITUDE_MAX; - double longitude = Math.random() * MercatorProjection.LONGITUDE_MAX; - animateToLocation(latitude, longitude); - - // If animations were merged, final bearing should be 180° - mMap.postDelayed(new Runnable() { - @Override - public void run() { - mMap.getMapPosition(mapPosition); - Toast.makeText(MapPositionActivity.this, "Bearing expected: " + bearing + ", got: " + mapPosition.getBearing(), Toast.LENGTH_LONG).show(); - } - }, 3000); - } -} diff --git a/vtm-android-example/src/org/oscim/android/test/Samples.java b/vtm-android-example/src/org/oscim/android/test/Samples.java index 39affab9..0340ab3a 100644 --- a/vtm-android-example/src/org/oscim/android/test/Samples.java +++ b/vtm-android-example/src/org/oscim/android/test/Samples.java @@ -118,14 +118,12 @@ public class Samples extends Activity { linearLayout.addView(createLabel("User Interaction")); linearLayout.addView(createButton(NewGesturesActivity.class)); linearLayout.addView(createButton(LayerGroupActivity.class)); - linearLayout.addView(createButton(MapFragmentActivity.class)); linearLayout.addView(createLabel("Dual Map Views")); linearLayout.addView(createButton(MultiMapActivity.class)); linearLayout.addView(createLabel("Experiments")); linearLayout.addView(createButton(ReverseGeocodeActivity.class)); - linearLayout.addView(createButton(MapPositionActivity.class)); linearLayout.addView(createButton(S3DBMapActivity.class)); linearLayout.addView(createButton(ThemeStylerActivity.class)); linearLayout.addView(createButton(JeoIndoorMapActivity.class)); diff --git a/vtm-app/build.gradle b/vtm-app/build.gradle index f21f1a49..3dcbe77f 100644 --- a/vtm-app/build.gradle +++ b/vtm-app/build.gradle @@ -4,8 +4,8 @@ dependencies { implementation project(':vtm-android') implementation project(':vtm-themes') implementation project(':vtm-extras') - implementation 'com.noveogroup.android:android-logger:1.3.6' implementation 'com.squareup.okhttp3:okhttp:3.8.0' + implementation "org.slf4j:slf4j-android:$slf4jVersion" } android { diff --git a/vtm-app/src/android-logger.properties b/vtm-app/src/android-logger.properties deleted file mode 100644 index 47f60ed5..00000000 --- a/vtm-app/src/android-logger.properties +++ /dev/null @@ -1 +0,0 @@ -root=DEBUG:%logger \ No newline at end of file diff --git a/vtm-extras/build.gradle b/vtm-extras/build.gradle index 573e5129..5a4b3ac4 100644 --- a/vtm-extras/build.gradle +++ b/vtm-extras/build.gradle @@ -5,7 +5,7 @@ dependencies { api project(':vtm') implementation 'com.fasterxml.jackson.core:jackson-core:2.8.4' implementation 'com.google.protobuf:protobuf-java:2.6.1' - implementation 'com.vividsolutions:jts-core:1.14.0' + implementation 'com.vividsolutions:jts:1.13' implementation 'org.openstreetmap.osmosis:osmosis-osm-binary:0.45' implementation "org.slf4j:slf4j-api:$slf4jVersion" } diff --git a/vtm-jts/build.gradle b/vtm-jts/build.gradle index 6d0ecea3..e1990851 100644 --- a/vtm-jts/build.gradle +++ b/vtm-jts/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'maven' dependencies { api project(':vtm') - implementation 'com.vividsolutions:jts-core:1.14.0' + implementation 'com.vividsolutions:jts:1.13' implementation "org.slf4j:slf4j-api:$slf4jVersion" } diff --git a/vtm-playground/build.gradle b/vtm-playground/build.gradle index 04474137..af02e4d4 100644 --- a/vtm-playground/build.gradle +++ b/vtm-playground/build.gradle @@ -4,23 +4,15 @@ dependencies { implementation project(':vtm-desktop') implementation project(':vtm-extras') implementation project(':vtm-http') - implementation(project(':vtm-jeo')) { - exclude group: 'com.vividsolutions', module: 'jts' - } + implementation project(':vtm-jeo') implementation project(':vtm-json') implementation project(':vtm-jts') implementation "com.badlogicgames.gdx:gdx:$gdxVersion" implementation "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion" implementation 'com.squareup.okhttp3:okhttp:3.8.0' - implementation('org.jeo:jeo:0-SNAPSHOT') { - exclude group: 'com.vividsolutions', module: 'jts' - exclude group: 'org.slf4j', module: 'slf4j-jdk14' - } - implementation('org.jeo:jeo-render:0-SNAPSHOT') { - exclude group: 'com.vividsolutions', module: 'jts' - exclude group: 'org.slf4j', module: 'slf4j-jdk14' - } - implementation "org.slf4j:slf4j-simple:$slf4jVersion" + implementation 'org.jeo:jeo:0-SNAPSHOT' + implementation 'org.jeo:jeo-render:0-SNAPSHOT' + implementation "org.slf4j:slf4j-jdk14:$slf4jVersion" } sourceSets { diff --git a/vtm-tests/build.gradle b/vtm-tests/build.gradle index 6479a969..301cd476 100644 --- a/vtm-tests/build.gradle +++ b/vtm-tests/build.gradle @@ -7,7 +7,7 @@ dependencies { testImplementation 'junit:junit:4.12' testImplementation 'org.easytesting:fest-assert-core:2.0M10' testImplementation 'org.mockito:mockito-all:1.10.19' - testImplementation "org.slf4j:slf4j-simple:$slf4jVersion" + testImplementation "org.slf4j:slf4j-jdk14:$slf4jVersion" } sourceSets {