diff --git a/android/jni/com/mapswithme/maps/Sponsored.cpp b/android/jni/com/mapswithme/maps/Sponsored.cpp index 80f8e12f52..d448cae692 100644 --- a/android/jni/com/mapswithme/maps/Sponsored.cpp +++ b/android/jni/com/mapswithme/maps/Sponsored.cpp @@ -61,7 +61,7 @@ void PrepareClassRefs(JNIEnv * env, jclass sponsoredClass) // Sponsored(String rating, String price, String urlBook, String urlDescription) g_sponsoredClassConstructor = jni::GetConstructorID( env, g_sponsoredClass, - "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V"); + "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V"); // static void onPriceReceived(final String id, final String price, final String currency) g_priceCallback = jni::GetStaticMethodID(env, g_sponsoredClass, "onPriceReceived", @@ -117,11 +117,10 @@ JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_widget_placepage_Sponsored_na if (!ppInfo.IsSponsored()) return nullptr; - //TODO: consider using the raw value and impress directly. std::string rating = place_page::rating::GetRatingFormatted(ppInfo.GetRatingRawValue()); - return env->NewObject(g_sponsoredClass, g_sponsoredClassConstructor, jni::ToJavaString(env, rating), + static_cast(place_page::rating::GetImpress(ppInfo.GetRatingRawValue())), jni::ToJavaString(env, ppInfo.GetApproximatePricing()), jni::ToJavaString(env, ppInfo.GetSponsoredUrl()), jni::ToJavaString(env, ppInfo.GetSponsoredDescriptionUrl()), diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 5cdaf5af89..8bbc2c548a 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -71,6 +71,7 @@ import com.mapswithme.maps.location.LocationHelper; import com.mapswithme.maps.review.Review; import com.mapswithme.maps.routing.RoutingController; import com.mapswithme.maps.taxi.TaxiManager; +import com.mapswithme.maps.ugc.Impress; import com.mapswithme.maps.ugc.UGCController; import com.mapswithme.maps.viator.Viator; import com.mapswithme.maps.viator.ViatorAdapter; @@ -733,9 +734,13 @@ public class PlacePageView extends RelativeLayout { UiUtils.show(mHotelReview); mReviewAdapter.setItems(new ArrayList<>(Arrays.asList(info.mReviews))); + //noinspection ConstantConditions mHotelRating.setText(mSponsored.getRating()); - mHotelRatingBase.setText(getResources().getString(R.string.booking_based_on_reviews, - info.mReviewsAmount)); + String text = getResources().getString(R.string.booking_based_on_reviews, + info.mReviewsAmount); + mHotelRatingBase.setText(text); + TextView previewReviewCountView = (TextView) mPreviewRatingInfo.findViewById(R.id.tv__review_count); + previewReviewCountView.setText(text); } } @@ -1449,19 +1454,18 @@ public class PlacePageView extends RelativeLayout colorizeSubtitle(); UiUtils.hide(mAvDirection); UiUtils.setTextAndHideIfEmpty(mTvAddress, mapObject.getAddress()); - //TODO: rating will be shown not only for sponsored objects now, change it when core is ready. boolean sponsored = isSponsored(); UiUtils.showIf(sponsored, mPreviewRatingInfo); if (sponsored) { boolean isPriceEmpty = TextUtils.isEmpty(mSponsoredPrice); + @SuppressWarnings("ConstantConditions") boolean isRatingEmpty = TextUtils.isEmpty(mSponsored.getRating()); - //TODO: remove this code when place_page_info.cpp is ready and use rating parameter. - mRatingView.setRating(null, mSponsored.getRating()); + Impress impress = Impress.values()[mSponsored.getImpress()]; + mRatingView.setRating(impress, mSponsored.getRating()); UiUtils.showIf(!isRatingEmpty, mRatingView); mTvSponsoredPrice.setText(mSponsoredPrice); UiUtils.showIf(!isPriceEmpty, mTvSponsoredPrice); - //TODO: set review count to mTvReviewCount when core is ready. UiUtils.showIf(!isRatingEmpty || !isPriceEmpty, mPreviewRatingInfo); } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java b/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java index ab6f2c997f..39c964f701 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java +++ b/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java @@ -10,6 +10,7 @@ import com.mapswithme.maps.bookmarks.data.MapObject; import com.mapswithme.maps.bookmarks.data.Metadata; import com.mapswithme.maps.gallery.Image; import com.mapswithme.maps.review.Review; +import com.mapswithme.maps.ugc.UGC; import com.mapswithme.util.NetworkPolicy; import java.lang.annotation.Retention; @@ -195,6 +196,8 @@ public final class Sponsored @NonNull private final String mRating; + @UGC.Impress + private final int mImpress; @NonNull private final String mPrice; @NonNull @@ -206,11 +209,12 @@ public final class Sponsored @SponsoredType private final int mType; - public Sponsored(@NonNull String rating, @NonNull String price, @NonNull String url, + public Sponsored(@NonNull String rating, @UGC.Impress int impress, @NonNull String price, @NonNull String url, @NonNull String descriptionUrl, @NonNull String reviewUrl, @SponsoredType int type) { mRating = rating; + mImpress = impress; mPrice = price; mUrl = url; mDescriptionUrl = descriptionUrl; @@ -235,6 +239,12 @@ public final class Sponsored return mRating; } + @UGC.Impress + int getImpress() + { + return mImpress; + } + @NonNull String getPrice() {