Android Gradle plugin 8 preparation (#1034)

This commit is contained in:
Emux 2023-04-17 13:37:02 +03:00 committed by GitHub
parent eef8ee3934
commit ff9246168b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 214 additions and 266 deletions

View File

@ -10,7 +10,6 @@ Current version is [![Maven Central](https://img.shields.io/maven-central/v/org.
```groovy ```groovy
implementation 'org.mapsforge:vtm:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm:[CURRENT-VERSION]'
implementation 'org.mapsforge:vtm-themes:[CURRENT-VERSION]' implementation 'org.mapsforge:vtm-themes:[CURRENT-VERSION]'
implementation 'net.sf.kxml:kxml2:2.3.0'
implementation 'org.slf4j:slf4j-api:1.7.28' implementation 'org.slf4j:slf4j-api:1.7.28'
``` ```
@ -55,7 +54,8 @@ runtimeOnly 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-osx'
runtimeOnly 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-windows' runtimeOnly 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-windows'
implementation 'com.badlogicgames.gdx:gdx:1.11.0' implementation 'com.badlogicgames.gdx:gdx:1.11.0'
runtimeOnly 'com.badlogicgames.gdx:gdx-platform:1.11.0:natives-desktop' runtimeOnly 'com.badlogicgames.gdx:gdx-platform:1.11.0:natives-desktop'
implementation 'com.formdev:svgSalamander:1.1.3' implementation 'guru.nidi.com.kitfox:svgSalamander:1.1.3'
implementation 'net.sf.kxml:kxml2:2.3.0'
``` ```
### Desktop (LWJGL) ### Desktop (LWJGL)

View File

@ -75,34 +75,28 @@ public class BaseMapActivity extends MapActivity {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (item.getItemId()) { if (itemId == R.id.theme_default) {
case R.id.theme_default:
mMap.setTheme(VtmThemes.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);
item.setChecked(true); item.setChecked(true);
return true; return true;
} else if (itemId == R.id.theme_osmarender) {
case R.id.theme_osmarender:
mMap.setTheme(VtmThemes.OSMARENDER); mMap.setTheme(VtmThemes.OSMARENDER);
item.setChecked(true); item.setChecked(true);
return true; return true;
} else if (itemId == R.id.theme_osmagray) {
case R.id.theme_osmagray:
mMap.setTheme(VtmThemes.OSMAGRAY); mMap.setTheme(VtmThemes.OSMAGRAY);
item.setChecked(true); item.setChecked(true);
return true; return true;
} else if (itemId == R.id.theme_tubes) {
case R.id.theme_tubes:
mMap.setTheme(VtmThemes.TRONRENDER); mMap.setTheme(VtmThemes.TRONRENDER);
item.setChecked(true); item.setChecked(true);
return true; return true;
} else if (itemId == R.id.theme_newtron) {
case R.id.theme_newtron:
mMap.setTheme(VtmThemes.NEWTRON); mMap.setTheme(VtmThemes.NEWTRON);
item.setChecked(true); item.setChecked(true);
return true; return true;
} else if (itemId == R.id.gridlayer) {
case R.id.gridlayer:
if (item.isChecked()) { if (item.isChecked()) {
item.setChecked(false); item.setChecked(false);
mMap.layers().remove(mGridLayer); mMap.layers().remove(mGridLayer);

View File

@ -114,59 +114,52 @@ public class MapsforgeActivity extends MapActivity {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (item.getItemId()) { if (itemId == R.id.theme_default) {
case R.id.theme_default:
if (mTheme != null) if (mTheme != null)
mTheme.dispose(); mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.DEFAULT); mTheme = mMap.setTheme(VtmThemes.DEFAULT);
item.setChecked(true); item.setChecked(true);
return true; return true;
} else if (itemId == R.id.theme_osmarender) {
case R.id.theme_osmarender:
if (mTheme != null) if (mTheme != null)
mTheme.dispose(); mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.OSMARENDER); mTheme = mMap.setTheme(VtmThemes.OSMARENDER);
item.setChecked(true); item.setChecked(true);
return true; return true;
} else if (itemId == R.id.theme_osmagray) {
case R.id.theme_osmagray:
if (mTheme != null) if (mTheme != null)
mTheme.dispose(); mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.OSMAGRAY); mTheme = mMap.setTheme(VtmThemes.OSMAGRAY);
item.setChecked(true); item.setChecked(true);
return true; return true;
} else if (itemId == R.id.theme_tubes) {
case R.id.theme_tubes:
if (mTheme != null) if (mTheme != null)
mTheme.dispose(); mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.TRONRENDER); mTheme = mMap.setTheme(VtmThemes.TRONRENDER);
item.setChecked(true); item.setChecked(true);
return true; return true;
} else if (itemId == R.id.theme_newtron) {
case R.id.theme_newtron:
if (mTheme != null) if (mTheme != null)
mTheme.dispose(); mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.NEWTRON); mTheme = mMap.setTheme(VtmThemes.NEWTRON);
item.setChecked(true); item.setChecked(true);
return true; return true;
} else if (itemId == R.id.theme_external_archive) {
case R.id.theme_external_archive:
Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT); Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE); intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*"); intent.setType("*/*");
startActivityForResult(intent, SELECT_THEME_ARCHIVE); startActivityForResult(intent, SELECT_THEME_ARCHIVE);
return true; return true;
} else if (itemId == R.id.theme_external) {
case R.id.theme_external: Intent intent;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
return false; return false;
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, SELECT_THEME_DIR); startActivityForResult(intent, SELECT_THEME_DIR);
return true; return true;
} else if (itemId == R.id.gridlayer) {
case R.id.gridlayer:
if (item.isChecked()) { if (item.isChecked()) {
item.setChecked(false); item.setChecked(false);
mMap.layers().remove(mGridLayer); mMap.layers().remove(mGridLayer);

View File

@ -37,22 +37,22 @@ public class MapsforgeStyleActivity extends MapsforgeActivity {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { int itemId = item.getItemId();
case R.id.style_1: if (itemId == R.id.style_1) {
item.setChecked(true); item.setChecked(true);
loadTheme("1"); loadTheme("1");
mMap.clearMap(); mMap.clearMap();
Toast.makeText(this, "Show nature layers", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Show nature layers", Toast.LENGTH_SHORT).show();
return true; return true;
case R.id.style_2: } else if (itemId == R.id.style_2) {
item.setChecked(true); item.setChecked(true);
loadTheme("2"); loadTheme("2");
mMap.clearMap(); mMap.clearMap();
Toast.makeText(this, "Hide nature layers", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Hide nature layers", Toast.LENGTH_SHORT).show();
return true; return true;
default:
return false;
} }
return false;
} }
@Override @Override

View File

@ -163,16 +163,13 @@ public class ThemeStylerActivity extends BaseMapActivity implements OnSeekBarCha
return; return;
HSV c = null; HSV c = null;
switch (view.getId()) { int id = view.getId();
case R.id.checkBoxArea: if (id == R.id.checkBoxArea) {
c = areaColor; c = areaColor;
break; } else if (id == R.id.checkBoxLine) {
case R.id.checkBoxLine:
c = lineColor; c = lineColor;
break; } else if (id == R.id.checkBoxOutline) {
case R.id.checkBoxOutline:
c = outlineColor; c = outlineColor;
break;
} }
if (c == null) if (c == null)
return; return;

View File

@ -182,17 +182,13 @@ public class MapLayers {
App.map.layers().remove(mBackgroundLayer); App.map.layers().remove(mBackgroundLayer);
mBackgroundLayer = null; mBackgroundLayer = null;
switch (id) { if (id == R.id.menu_layer_openstreetmap) {
case R.id.menu_layer_openstreetmap:
UrlTileSource tileSource = DefaultSources.OPENSTREETMAP.build(); UrlTileSource tileSource = DefaultSources.OPENSTREETMAP.build();
tileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-playground")); tileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-playground"));
mBackgroundLayer = new BitmapTileLayer(App.map, tileSource); mBackgroundLayer = new BitmapTileLayer(App.map, tileSource);
break; } else if (id == R.id.menu_layer_naturalearth) {
case R.id.menu_layer_naturalearth:
mBackgroundLayer = new BitmapTileLayer(App.map, DefaultSources.NE_LANDCOVER.build()); mBackgroundLayer = new BitmapTileLayer(App.map, DefaultSources.NE_LANDCOVER.build());
break; } else {
default:
mBackgroundLayer = mBackroundPlaceholder; mBackgroundLayer = mBackroundPlaceholder;
id = -1; id = -1;
} }

View File

@ -293,23 +293,20 @@ public class POISearch {
} }
public boolean onContextItemSelected(MenuItem item, GeoPoint geoPoint) { public boolean onContextItemSelected(MenuItem item, GeoPoint geoPoint) {
switch (item.getItemId()) { int itemId = item.getItemId();
case R.id.menu_poi_nearby: if (itemId == R.id.menu_poi_nearby) {
Intent intent = new Intent(App.activity, POIActivity.class); Intent intent = new Intent(App.activity, POIActivity.class);
intent.putExtra("ID", poiMarkers.getBubbledItemId()); intent.putExtra("ID", poiMarkers.getBubbledItemId());
App.activity.startActivityForResult(intent, TileMap.POIS_REQUEST); App.activity.startActivityForResult(intent, TileMap.POIS_REQUEST);
return true; return true;
} else if (itemId == R.id.menu_poi_clear) {
case R.id.menu_poi_clear:
poiMarkers.removeAllItems(); poiMarkers.removeAllItems();
mPOIs.clear(); mPOIs.clear();
App.map.updateMap(true); App.map.updateMap(true);
return true; return true;
default:
} }
return false; return false;
} }
} }

View File

@ -321,8 +321,8 @@ public class RouteSearch {
} }
boolean onContextItemSelected(MenuItem item, GeoPoint geoPoint) { boolean onContextItemSelected(MenuItem item, GeoPoint geoPoint) {
switch (item.getItemId()) { int itemId = item.getItemId();
case R.id.menu_route_departure: if (itemId == R.id.menu_route_departure) {
mStartPoint = geoPoint; mStartPoint = geoPoint;
markerStart = putMarkerItem(markerStart, mStartPoint, START_INDEX, markerStart = putMarkerItem(markerStart, mStartPoint, START_INDEX,
@ -330,8 +330,7 @@ public class RouteSearch {
getRouteAsync(); getRouteAsync();
return true; return true;
} else if (itemId == R.id.menu_route_destination) {
case R.id.menu_route_destination:
mDestinationPoint = geoPoint; mDestinationPoint = geoPoint;
markerDestination = putMarkerItem(markerDestination, mDestinationPoint, DEST_INDEX, markerDestination = putMarkerItem(markerDestination, mDestinationPoint, DEST_INDEX,
@ -340,20 +339,17 @@ public class RouteSearch {
getRouteAsync(); getRouteAsync();
return true; return true;
} else if (itemId == R.id.menu_route_viapoint) {
case R.id.menu_route_viapoint:
GeoPoint viaPoint = geoPoint; GeoPoint viaPoint = geoPoint;
addViaPoint(viaPoint); addViaPoint(viaPoint);
getRouteAsync(); getRouteAsync();
return true; return true;
} else if (itemId == R.id.menu_route_clear) {
case R.id.menu_route_clear:
clearOverlays(); clearOverlays();
return true; return true;
default:
} }
return false; return false;
} }

View File

@ -149,21 +149,14 @@ public class TileMap extends MapActivity implements MapEventsReceiver {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (item.getItemId()) { if (itemId == R.id.menu_info_about) {
case R.id.menu_info_about:
startActivity(new Intent(this, InfoView.class)); startActivity(new Intent(this, InfoView.class));
break; } else if (itemId == R.id.menu_position) {
} else if (itemId == R.id.menu_poi_nearby) {
case R.id.menu_position:
break;
case R.id.menu_poi_nearby:
Intent intent = new Intent(this, POIActivity.class); Intent intent = new Intent(this, POIActivity.class);
startActivityForResult(intent, TileMap.POIS_REQUEST); startActivityForResult(intent, TileMap.POIS_REQUEST);
break; } else if (itemId == R.id.menu_compass_2d) {
case R.id.menu_compass_2d:
if (!item.isChecked()) { if (!item.isChecked()) {
// FIXME // FIXME
//mMapView.getMapViewPosition().setTilt(0); //mMapView.getMapViewPosition().setTilt(0);
@ -171,35 +164,26 @@ public class TileMap extends MapActivity implements MapEventsReceiver {
} else { } else {
mCompass.setMode(Compass.Mode.OFF); mCompass.setMode(Compass.Mode.OFF);
} }
break; } else if (itemId == R.id.menu_compass_3d) {
case R.id.menu_compass_3d:
if (!item.isChecked()) { if (!item.isChecked()) {
mCompass.setMode(Compass.Mode.C3D); mCompass.setMode(Compass.Mode.C3D);
} else { } else {
mCompass.setMode(Compass.Mode.OFF); mCompass.setMode(Compass.Mode.OFF);
} }
break; } else if (itemId == R.id.menu_position_my_location_enable) {
case R.id.menu_position_my_location_enable:
if (!item.isChecked()) { if (!item.isChecked()) {
mLocation.setMode(LocationHandler.Mode.SHOW); mLocation.setMode(LocationHandler.Mode.SHOW);
mLocation.setCenterOnFirstFix(); mLocation.setCenterOnFirstFix();
} else { } else {
mLocation.setMode(LocationHandler.Mode.OFF); mLocation.setMode(LocationHandler.Mode.OFF);
} }
break; } else if (itemId == R.id.menu_position_follow_location) {
case R.id.menu_position_follow_location:
if (!item.isChecked()) { if (!item.isChecked()) {
mLocation.setMode(LocationHandler.Mode.SNAP); mLocation.setMode(LocationHandler.Mode.SNAP);
} else { } else {
mLocation.setMode(LocationHandler.Mode.OFF); mLocation.setMode(LocationHandler.Mode.OFF);
} }
break; } else if (itemId == R.id.menu_layer_openstreetmap || itemId == R.id.menu_layer_naturalearth) {
case R.id.menu_layer_openstreetmap:
case R.id.menu_layer_naturalearth:
int bgId = item.getItemId(); int bgId = item.getItemId();
// toggle if already enabled // toggle if already enabled
if (bgId == mMapLayers.getBackgroundId()) if (bgId == mMapLayers.getBackgroundId())
@ -207,29 +191,19 @@ public class TileMap extends MapActivity implements MapEventsReceiver {
mMapLayers.setBackgroundMap(bgId); mMapLayers.setBackgroundMap(bgId);
mMap.updateMap(true); mMap.updateMap(true);
break; } else if (itemId == R.id.menu_layer_grid) {
case R.id.menu_layer_grid:
mMapLayers.enableGridOverlay(this, !mMapLayers.isGridEnabled()); mMapLayers.enableGridOverlay(this, !mMapLayers.isGridEnabled());
mMap.updateMap(true); mMap.updateMap(true);
break; } else if (itemId == R.id.menu_position_enter_coordinates) {
case R.id.menu_position_enter_coordinates:
showDialog(DIALOG_ENTER_COORDINATES); showDialog(DIALOG_ENTER_COORDINATES);
break; /*} else if (itemId == R.id.menu_position_map_center) {
MapPosition mapCenter = mBaseLayer.getMapFileCenter();
//case R.id.menu_position_map_center: if (mapCenter != null)
// MapPosition mapCenter = mBaseLayer.getMapFileCenter(); mMap.setCenter(mapCenter.getGeoPoint());*/
// if (mapCenter != null) } else if (itemId == R.id.menu_preferences) {
// mMap.setCenter(mapCenter.getGeoPoint());
// break;
case R.id.menu_preferences:
startActivity(new Intent(this, EditPreferences.class)); startActivity(new Intent(this, EditPreferences.class));
overridePendingTransition(R.anim.slide_right, R.anim.slide_left2); overridePendingTransition(R.anim.slide_right, R.anim.slide_left2);
break; } else {
default:
return false; return false;
} }

View File

@ -3,7 +3,8 @@ apply plugin: 'maven-publish'
dependencies { dependencies {
api project(':vtm-gdx') api project(':vtm-gdx')
api 'com.formdev:svgSalamander:1.1.3' api 'guru.nidi.com.kitfox:svgSalamander:1.1.3'
api 'net.sf.kxml:kxml2:2.3.0'
} }
sourceSets { sourceSets {

View File

@ -2,7 +2,7 @@ apply plugin: 'java-library'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
dependencies { dependencies {
api 'net.sf.kxml:kxml2:2.3.0' compileOnly 'net.sf.kxml:kxml2:2.3.0'
api "org.slf4j:slf4j-api:$slf4jVersion" api "org.slf4j:slf4j-api:$slf4jVersion"
compileOnly 'com.google.code.findbugs:jsr305:3.0.2' compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
} }