[bookmarks][android] Displaying feature type in bookmark items.

This commit is contained in:
Daria Volvenkova 2019-08-23 04:15:21 +03:00 committed by Aleksey Belousov
parent 1fe0a02300
commit cd58a0c21d
4 changed files with 25 additions and 4 deletions

View file

@ -25,6 +25,14 @@ Java_com_mapswithme_maps_bookmarks_data_Bookmark_nativeGetName(
return jni::ToJavaString(env, getBookmark(bmk)->GetPreferredName());
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_bookmarks_data_Bookmark_nativeGetFeatureType(
JNIEnv * env, jobject thiz, jlong bmk)
{
return jni::ToJavaString(env,
kml::GetLocalizedFeatureType(getBookmark(bmk)->GetData().m_featureTypes));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_bookmarks_data_Bookmark_nativeGetBookmarkDescription(
JNIEnv * env, jobject thiz, jlong bmk)

View file

@ -260,10 +260,15 @@ public class Holders
mName.setText(bookmark.getTitle());
final Location loc = LocationHelper.INSTANCE.getSavedLocation();
String distanceValue = loc == null ? null : bookmark.getDistance(loc.getLatitude(),
loc.getLongitude(), 0.0);
mDistance.setText(distanceValue);
UiUtils.hideIf(TextUtils.isEmpty(distanceValue), mDistance);
String distanceValue = loc == null ? "" : bookmark.getDistance(loc.getLatitude(),
loc.getLongitude(), 0.0);
String separator = "";
if (!distanceValue.isEmpty() && !bookmark.getFeatureType().isEmpty())
separator = "";
String subtitleValue = distanceValue.concat(separator).concat(bookmark.getFeatureType());
mDistance.setText(subtitleValue);
UiUtils.hideIf(TextUtils.isEmpty(subtitleValue), mDistance);
mIcon.setImageResource(bookmark.getIcon().getResId());
UiUtils.hideIf(!sectionsDataSource.isEditable(position.sectionIndex), mMore);
Drawable circle = Graphics.drawCircleAndImage(bookmark.getIcon().argb(),

View file

@ -167,6 +167,8 @@ public class Bookmark extends MapObject
public static native String nativeGetName(@IntRange(from = 0) long bookmarkId);
public static native String nativeGetFeatureType(@IntRange(from = 0) long bookmarkId);
public static native ParcelablePointD nativeGetXY(@IntRange(from = 0) long bookmarkId);
@Icon.PredefinedColor

View file

@ -12,6 +12,8 @@ public class BookmarkInfo
@NonNull
private String mTitle;
@NonNull
private String mFeatureType;
@NonNull
private Icon mIcon;
private double mMerX;
private double mMerY;
@ -21,6 +23,7 @@ public class BookmarkInfo
mCategoryId = categoryId;
mBookmarkId = bookmarkId;
mTitle = Bookmark.nativeGetName(mBookmarkId);
mFeatureType = Bookmark.nativeGetFeatureType(mBookmarkId);
mIcon = new Icon(Bookmark.nativeGetColor(mBookmarkId), Bookmark.nativeGetIcon(mBookmarkId));
final ParcelablePointD ll = Bookmark.nativeGetXY(mBookmarkId);
mMerX = ll.x;
@ -42,6 +45,9 @@ public class BookmarkInfo
return Framework.nativeGetDistanceAndAzimuth(mMerX, mMerY, cLat, cLon, north);
}
@NonNull
public String getFeatureType() { return mFeatureType; }
@NonNull
public String getTitle()
{