Skip to content

Changed Unknown to Wikidata Description #5697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,9 @@ private void addMarkerToMap(Place place, Boolean isBookMarked) {
ArrayList<OverlayItem> items = new ArrayList<>();
Drawable icon = ContextCompat.getDrawable(getContext(), getIconFor(place, isBookMarked));
GeoPoint point = new GeoPoint(place.location.getLatitude(), place.location.getLongitude());
OverlayItem item = new OverlayItem(place.name, null, point);
OverlayItem item = new OverlayItem(place.name,
containsParentheses(place.getLongDescription()) ? getTextBetweenParentheses(
place.getLongDescription()) : place.getLongDescription(), point);
item.setMarker(icon);
items.add(item);
ItemizedOverlayWithFocus overlay = new ItemizedOverlayWithFocus(items,
Expand Down Expand Up @@ -1813,7 +1815,11 @@ private void addMarkersToMap(List<BaseMarker> nearbyBaseMarkers) {
GeoPoint point = new GeoPoint(
nearbyBaseMarkers.get(i).getPlace().location.getLatitude(),
nearbyBaseMarkers.get(i).getPlace().location.getLongitude());
OverlayItem item = new OverlayItem(nearbyBaseMarkers.get(i).getPlace().name, null,
OverlayItem item = new OverlayItem(nearbyBaseMarkers.get(i).getPlace().name,
containsParentheses(nearbyBaseMarkers.get(i).getPlace().getLongDescription())
? getTextBetweenParentheses(
nearbyBaseMarkers.get(i).getPlace().getLongDescription())
: nearbyBaseMarkers.get(i).getPlace().getLongDescription(),
point);
item.setMarker(icon);
items.add(item);
Expand Down Expand Up @@ -1844,6 +1850,32 @@ public boolean onItemLongPress(int index, OverlayItem item) {
binding.map.getOverlays().add(overlay);
}

/**
* Extracts text between the first occurrence of '(' and its corresponding ')' in the input string.
*
* @param input The input string from which to extract text between parentheses.
* @return The text between parentheses if found, or {@code null} if no parentheses are found.
*/
public static String getTextBetweenParentheses(String input) {
int startIndex = input.indexOf('(');
int endIndex = input.indexOf(')', startIndex);
if (startIndex != -1 && endIndex != -1) {
return input.substring(startIndex + 1, endIndex);
} else {
return null;
}
}

/**
* Checks if the given text contains '(' or ')'.
*
* @param input The input text to check.
* @return {@code true} if '(' or ')' is found, {@code false} otherwise.
*/
public static boolean containsParentheses(String input) {
return input.contains("(") || input.contains(")");
}

private void removeMarker(Place place){
List<Overlay> overlays = binding.map.getOverlays();
for (int i = 0; i < overlays.size();i++){
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/res/values-yue-hant/error.xml

This file was deleted.

Loading