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,46 +75,40 @@ 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);
return true;
} else if (itemId == R.id.theme_osmarender) {
mMap.setTheme(VtmThemes.OSMARENDER);
item.setChecked(true);
return true;
} else if (itemId == R.id.theme_osmagray) {
mMap.setTheme(VtmThemes.OSMAGRAY);
item.setChecked(true);
return true;
} else if (itemId == R.id.theme_tubes) {
mMap.setTheme(VtmThemes.TRONRENDER);
item.setChecked(true);
return true;
} else if (itemId == R.id.theme_newtron) {
mMap.setTheme(VtmThemes.NEWTRON);
item.setChecked(true);
return true;
} else if (itemId == R.id.gridlayer) {
if (item.isChecked()) {
item.setChecked(false);
mMap.layers().remove(mGridLayer);
} else {
item.setChecked(true); item.setChecked(true);
return true; if (mGridLayer == null)
mGridLayer = new TileGridLayer(mMap);
case R.id.theme_osmarender: mMap.layers().add(mGridLayer);
mMap.setTheme(VtmThemes.OSMARENDER); }
item.setChecked(true); mMap.updateMap(true);
return true; return true;
case R.id.theme_osmagray:
mMap.setTheme(VtmThemes.OSMAGRAY);
item.setChecked(true);
return true;
case R.id.theme_tubes:
mMap.setTheme(VtmThemes.TRONRENDER);
item.setChecked(true);
return true;
case R.id.theme_newtron:
mMap.setTheme(VtmThemes.NEWTRON);
item.setChecked(true);
return true;
case R.id.gridlayer:
if (item.isChecked()) {
item.setChecked(false);
mMap.layers().remove(mGridLayer);
} else {
item.setChecked(true);
if (mGridLayer == null)
mGridLayer = new TileGridLayer(mMap);
mMap.layers().add(mGridLayer);
}
mMap.updateMap(true);
return true;
} }
return false; return false;

View File

@ -114,71 +114,64 @@ 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);
return true;
} else if (itemId == R.id.theme_osmarender) {
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.OSMARENDER);
item.setChecked(true);
return true;
} else if (itemId == R.id.theme_osmagray) {
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.OSMAGRAY);
item.setChecked(true);
return true;
} else if (itemId == R.id.theme_tubes) {
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.TRONRENDER);
item.setChecked(true);
return true;
} else if (itemId == R.id.theme_newtron) {
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.NEWTRON);
item.setChecked(true);
return true;
} else if (itemId == 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.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
startActivityForResult(intent, SELECT_THEME_ARCHIVE);
return true;
} else if (itemId == R.id.theme_external) {
Intent intent;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
return false;
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, SELECT_THEME_DIR);
return true;
} else if (itemId == R.id.gridlayer) {
if (item.isChecked()) {
item.setChecked(false);
mMap.layers().remove(mGridLayer);
} else {
item.setChecked(true); item.setChecked(true);
return true; if (mGridLayer == null)
mGridLayer = new TileGridLayer(mMap);
case R.id.theme_osmarender: mMap.layers().add(mGridLayer);
if (mTheme != null) }
mTheme.dispose(); mMap.updateMap(true);
mTheme = mMap.setTheme(VtmThemes.OSMARENDER); return true;
item.setChecked(true);
return true;
case R.id.theme_osmagray:
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.OSMAGRAY);
item.setChecked(true);
return true;
case R.id.theme_tubes:
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.TRONRENDER);
item.setChecked(true);
return true;
case R.id.theme_newtron:
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.NEWTRON);
item.setChecked(true);
return true;
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.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
startActivityForResult(intent, SELECT_THEME_ARCHIVE);
return true;
case R.id.theme_external:
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
return false;
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, SELECT_THEME_DIR);
return true;
case R.id.gridlayer:
if (item.isChecked()) {
item.setChecked(false);
mMap.layers().remove(mGridLayer);
} else {
item.setChecked(true);
if (mGridLayer == null)
mGridLayer = new TileGridLayer(mMap);
mMap.layers().add(mGridLayer);
}
mMap.updateMap(true);
return true;
} }
return false; return false;

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; } else if (id == R.id.checkBoxOutline) {
break; c = outlineColor;
case R.id.checkBoxOutline:
c = outlineColor;
break;
} }
if (c == null) if (c == null)
return; return;

View File

@ -182,19 +182,15 @@ 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); } else if (id == R.id.menu_layer_naturalearth) {
break; mBackgroundLayer = new BitmapTileLayer(App.map, DefaultSources.NE_LANDCOVER.build());
} else {
case R.id.menu_layer_naturalearth: mBackgroundLayer = mBackroundPlaceholder;
mBackgroundLayer = new BitmapTileLayer(App.map, DefaultSources.NE_LANDCOVER.build()); id = -1;
break;
default:
mBackgroundLayer = mBackroundPlaceholder;
id = -1;
} }
if (mBackgroundLayer instanceof BitmapTileLayer) if (mBackgroundLayer instanceof BitmapTileLayer)

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) {
poiMarkers.removeAllItems();
mPOIs.clear();
App.map.updateMap(true);
case R.id.menu_poi_clear: return true;
poiMarkers.removeAllItems();
mPOIs.clear();
App.map.updateMap(true);
return true;
default:
} }
return false; return false;
} }
} }

View File

@ -321,39 +321,35 @@ 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,
R.string.departure, R.drawable.marker_departure, -1); R.string.departure, R.drawable.marker_departure, -1);
getRouteAsync(); getRouteAsync();
return true; return true;
} else if (itemId == R.id.menu_route_destination) {
mDestinationPoint = geoPoint;
case R.id.menu_route_destination: markerDestination = putMarkerItem(markerDestination, mDestinationPoint, DEST_INDEX,
mDestinationPoint = geoPoint; R.string.destination,
R.drawable.marker_destination, -1);
markerDestination = putMarkerItem(markerDestination, mDestinationPoint, DEST_INDEX, getRouteAsync();
R.string.destination, return true;
R.drawable.marker_destination, -1); } else if (itemId == R.id.menu_route_viapoint) {
GeoPoint viaPoint = geoPoint;
addViaPoint(viaPoint);
getRouteAsync(); getRouteAsync();
return true; return true;
} else if (itemId == R.id.menu_route_clear) {
case R.id.menu_route_viapoint: clearOverlays();
GeoPoint viaPoint = geoPoint; return true;
addViaPoint(viaPoint);
getRouteAsync();
return true;
case R.id.menu_route_clear:
clearOverlays();
return true;
default:
} }
return false; return false;
} }

View File

@ -149,88 +149,62 @@ 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();
if (itemId == R.id.menu_info_about) {
startActivity(new Intent(this, InfoView.class));
} else if (itemId == R.id.menu_position) {
} else if (itemId == R.id.menu_poi_nearby) {
Intent intent = new Intent(this, POIActivity.class);
startActivityForResult(intent, TileMap.POIS_REQUEST);
} else if (itemId == R.id.menu_compass_2d) {
if (!item.isChecked()) {
// FIXME
//mMapView.getMapViewPosition().setTilt(0);
mCompass.setMode(Compass.Mode.C2D);
} else {
mCompass.setMode(Compass.Mode.OFF);
}
} else if (itemId == R.id.menu_compass_3d) {
if (!item.isChecked()) {
mCompass.setMode(Compass.Mode.C3D);
} else {
mCompass.setMode(Compass.Mode.OFF);
}
} else if (itemId == R.id.menu_position_my_location_enable) {
if (!item.isChecked()) {
mLocation.setMode(LocationHandler.Mode.SHOW);
mLocation.setCenterOnFirstFix();
} else {
mLocation.setMode(LocationHandler.Mode.OFF);
}
} else if (itemId == R.id.menu_position_follow_location) {
if (!item.isChecked()) {
mLocation.setMode(LocationHandler.Mode.SNAP);
} else {
mLocation.setMode(LocationHandler.Mode.OFF);
}
} else if (itemId == R.id.menu_layer_openstreetmap || itemId == R.id.menu_layer_naturalearth) {
int bgId = item.getItemId();
// toggle if already enabled
if (bgId == mMapLayers.getBackgroundId())
bgId = -1;
switch (item.getItemId()) { mMapLayers.setBackgroundMap(bgId);
case R.id.menu_info_about: mMap.updateMap(true);
startActivity(new Intent(this, InfoView.class)); } else if (itemId == R.id.menu_layer_grid) {
break; mMapLayers.enableGridOverlay(this, !mMapLayers.isGridEnabled());
mMap.updateMap(true);
case R.id.menu_position: } else if (itemId == R.id.menu_position_enter_coordinates) {
break; showDialog(DIALOG_ENTER_COORDINATES);
/*} else if (itemId == R.id.menu_position_map_center) {
case R.id.menu_poi_nearby: MapPosition mapCenter = mBaseLayer.getMapFileCenter();
Intent intent = new Intent(this, POIActivity.class); if (mapCenter != null)
startActivityForResult(intent, TileMap.POIS_REQUEST); mMap.setCenter(mapCenter.getGeoPoint());*/
break; } else if (itemId == R.id.menu_preferences) {
startActivity(new Intent(this, EditPreferences.class));
case R.id.menu_compass_2d: overridePendingTransition(R.anim.slide_right, R.anim.slide_left2);
if (!item.isChecked()) { } else {
// FIXME return false;
//mMapView.getMapViewPosition().setTilt(0);
mCompass.setMode(Compass.Mode.C2D);
} else {
mCompass.setMode(Compass.Mode.OFF);
}
break;
case R.id.menu_compass_3d:
if (!item.isChecked()) {
mCompass.setMode(Compass.Mode.C3D);
} else {
mCompass.setMode(Compass.Mode.OFF);
}
break;
case R.id.menu_position_my_location_enable:
if (!item.isChecked()) {
mLocation.setMode(LocationHandler.Mode.SHOW);
mLocation.setCenterOnFirstFix();
} else {
mLocation.setMode(LocationHandler.Mode.OFF);
}
break;
case R.id.menu_position_follow_location:
if (!item.isChecked()) {
mLocation.setMode(LocationHandler.Mode.SNAP);
} else {
mLocation.setMode(LocationHandler.Mode.OFF);
}
break;
case R.id.menu_layer_openstreetmap:
case R.id.menu_layer_naturalearth:
int bgId = item.getItemId();
// toggle if already enabled
if (bgId == mMapLayers.getBackgroundId())
bgId = -1;
mMapLayers.setBackgroundMap(bgId);
mMap.updateMap(true);
break;
case R.id.menu_layer_grid:
mMapLayers.enableGridOverlay(this, !mMapLayers.isGridEnabled());
mMap.updateMap(true);
break;
case R.id.menu_position_enter_coordinates:
showDialog(DIALOG_ENTER_COORDINATES);
break;
//case R.id.menu_position_map_center:
// MapPosition mapCenter = mBaseLayer.getMapFileCenter();
// if (mapCenter != null)
// mMap.setCenter(mapCenter.getGeoPoint());
// break;
case R.id.menu_preferences:
startActivity(new Intent(this, EditPreferences.class));
overridePendingTransition(R.anim.slide_right, R.anim.slide_left2);
break;
default:
return false;
} }
toggleMenuCheck(); toggleMenuCheck();

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'
} }