Skip to content

Commit

Permalink
Android Gradle plugin 8 preparation (#1034)
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 authored Apr 17, 2023
1 parent eef8ee3 commit ff92461
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 269 deletions.
4 changes: 2 additions & 2 deletions docs/Integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
```

Expand Down Expand Up @@ -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)
Expand Down
70 changes: 32 additions & 38 deletions vtm-android-example/src/org/oscim/android/test/BaseMapActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,46 +75,40 @@ public void onCreate(Bundle savedInstanceState) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {
case R.id.theme_default:
mMap.setTheme(VtmThemes.DEFAULT);
item.setChecked(true);
return true;

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);
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_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;
Expand Down
119 changes: 56 additions & 63 deletions vtm-android-example/src/org/oscim/android/test/MapsforgeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,71 +114,64 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {
case R.id.theme_default:
if (mTheme != null)
mTheme.dispose();
mTheme = mMap.setTheme(VtmThemes.DEFAULT);
item.setChecked(true);
return true;

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);
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_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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ public boolean onCreateOptionsMenu(Menu menu) {

@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,13 @@ public void onRadioButtonClicked(View view) {
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;
Expand Down
22 changes: 9 additions & 13 deletions vtm-app/src/org/oscim/app/MapLayers.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,15 @@ void setBackgroundMap(int id) {
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)
Expand Down
29 changes: 13 additions & 16 deletions vtm-app/src/org/oscim/app/POISearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,23 +293,20 @@ public void onOpen(ExtendedMarkerItem item) {
}

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;

case R.id.menu_poi_clear:
poiMarkers.removeAllItems();
mPOIs.clear();
App.map.updateMap(true);

return true;
default:
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);

return true;
}
return false;

return false;
}

}
Loading

0 comments on commit ff92461

Please sign in to comment.