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
implementation 'org.mapsforge:vtm:[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'
```
@ -55,7 +54,8 @@ runtimeOnly 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-osx'
runtimeOnly 'org.mapsforge:vtm-desktop:[CURRENT-VERSION]:natives-windows'
implementation 'com.badlogicgames.gdx:gdx:1.11.0'
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)

View File

@ -75,46 +75,40 @@ public class BaseMapActivity extends MapActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.theme_default:
mMap.setTheme(VtmThemes.DEFAULT);
int itemId = item.getItemId();
if (itemId == R.id.theme_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);
return true;
if (mGridLayer == null)
mGridLayer = new TileGridLayer(mMap);
case R.id.theme_osmarender:
mMap.setTheme(VtmThemes.OSMARENDER);
item.setChecked(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;
mMap.layers().add(mGridLayer);
}
mMap.updateMap(true);
return true;
}
return false;

View File

@ -114,71 +114,64 @@ public class MapsforgeActivity extends MapActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.theme_default:
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.DEFAULT);
int itemId = item.getItemId();
if (itemId == R.id.theme_default) {
if (mTheme != null)
mTheme.dispose();
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);
return true;
if (mGridLayer == null)
mGridLayer = new TileGridLayer(mMap);
case R.id.theme_osmarender:
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.OSMARENDER);
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;
mMap.layers().add(mGridLayer);
}
mMap.updateMap(true);
return true;
}
return false;

View File

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

View File

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

View File

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

View File

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

View File

@ -321,39 +321,35 @@ public class RouteSearch {
}
boolean onContextItemSelected(MenuItem item, GeoPoint geoPoint) {
switch (item.getItemId()) {
case R.id.menu_route_departure:
mStartPoint = geoPoint;
int itemId = item.getItemId();
if (itemId == R.id.menu_route_departure) {
mStartPoint = geoPoint;
markerStart = putMarkerItem(markerStart, mStartPoint, START_INDEX,
R.string.departure, R.drawable.marker_departure, -1);
markerStart = putMarkerItem(markerStart, mStartPoint, START_INDEX,
R.string.departure, R.drawable.marker_departure, -1);
getRouteAsync();
return true;
getRouteAsync();
return true;
} else if (itemId == R.id.menu_route_destination) {
mDestinationPoint = geoPoint;
case R.id.menu_route_destination:
mDestinationPoint = geoPoint;
markerDestination = putMarkerItem(markerDestination, mDestinationPoint, DEST_INDEX,
R.string.destination,
R.drawable.marker_destination, -1);
markerDestination = putMarkerItem(markerDestination, mDestinationPoint, DEST_INDEX,
R.string.destination,
R.drawable.marker_destination, -1);
getRouteAsync();
return true;
} else if (itemId == R.id.menu_route_viapoint) {
GeoPoint viaPoint = geoPoint;
addViaPoint(viaPoint);
getRouteAsync();
return true;
case R.id.menu_route_viapoint:
GeoPoint viaPoint = geoPoint;
addViaPoint(viaPoint);
getRouteAsync();
return true;
case R.id.menu_route_clear:
clearOverlays();
return true;
default:
getRouteAsync();
return true;
} else if (itemId == R.id.menu_route_clear) {
clearOverlays();
return true;
}
return false;
}

View File

@ -149,88 +149,62 @@ public class TileMap extends MapActivity implements MapEventsReceiver {
@SuppressWarnings("deprecation")
@Override
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()) {
case R.id.menu_info_about:
startActivity(new Intent(this, InfoView.class));
break;
case R.id.menu_position:
break;
case R.id.menu_poi_nearby:
Intent intent = new Intent(this, POIActivity.class);
startActivityForResult(intent, TileMap.POIS_REQUEST);
break;
case R.id.menu_compass_2d:
if (!item.isChecked()) {
// FIXME
//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;
mMapLayers.setBackgroundMap(bgId);
mMap.updateMap(true);
} else if (itemId == R.id.menu_layer_grid) {
mMapLayers.enableGridOverlay(this, !mMapLayers.isGridEnabled());
mMap.updateMap(true);
} else if (itemId == R.id.menu_position_enter_coordinates) {
showDialog(DIALOG_ENTER_COORDINATES);
/*} else if (itemId == R.id.menu_position_map_center) {
MapPosition mapCenter = mBaseLayer.getMapFileCenter();
if (mapCenter != null)
mMap.setCenter(mapCenter.getGeoPoint());*/
} else if (itemId == R.id.menu_preferences) {
startActivity(new Intent(this, EditPreferences.class));
overridePendingTransition(R.anim.slide_right, R.anim.slide_left2);
} else {
return false;
}
toggleMenuCheck();

View File

@ -3,7 +3,8 @@ apply plugin: 'maven-publish'
dependencies {
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 {

View File

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