Skip to content

Commit

Permalink
Add icons to taginfo project file
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Sep 28, 2023
1 parent 8f6d404 commit d815a15
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/java/de/blau/android/contract/Urls.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ private Urls() {
public static final String EGM96 = "https://github.com/simonpoole/egm96/raw/master/src/main/resources/EGM96.dat";

public static final String GITHUB = "https://github.com/";

public static final String REMOTE_ICON_LOCATION = "https://simonpoole.github.io/beautified-JOSM-preset/icons/png/";
}
18 changes: 14 additions & 4 deletions src/main/java/de/blau/android/presets/PresetItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.xmlpull.v1.XmlSerializer;

import android.content.Context;
import android.net.Uri;
import android.util.Log;
import android.view.View;
import androidx.annotation.NonNull;
Expand Down Expand Up @@ -87,7 +88,7 @@ public class PresetItem extends PresetElement {
* Count of labels for naming
*/
private int labelCounter = 0;

/**
* Optional template for creating/formatting a name
*/
Expand Down Expand Up @@ -918,7 +919,7 @@ public String getNameTemplate() {
public void setNameTemplate(@Nullable String nameTemplate) {
this.nameTemplate = nameTemplate;
}

/**
* @return the fixed tags belonging to this item (unmodifiable)
*/
Expand Down Expand Up @@ -1299,8 +1300,17 @@ private static void appendEol(@NonNull StringBuilder jsonString) {
*/
@NonNull
private String tagToJSON(@NonNull String presetName, @NonNull String key, @Nullable StringWithDescription value) {
StringBuilder result = new StringBuilder(
"{\"description\":\"" + presetName + "\",\"key\": \"" + key + "\"" + (value == null ? "" : ",\"value\": \"" + value.getValue() + "\""));
StringBuilder result = new StringBuilder("{\"description\":\"" + presetName);
try {
Uri icon = Uri.parse(getIconpath());
final String lastPathSegment = icon.getLastPathSegment();
if (de.blau.android.util.Util.notEmpty(lastPathSegment)) {
result.append("\",\"icon_url\":" + "\"" + Urls.REMOTE_ICON_LOCATION + lastPathSegment);
}
} catch (Exception ex) {
// do nothing
}
result.append("\",\"key\": \"" + key + "\"" + (value == null ? "" : ",\"value\": \"" + value.getValue() + "\""));
result.append(",\"object_types\": [");
boolean first = true;
if (appliesToNode) {
Expand Down

0 comments on commit d815a15

Please sign in to comment.