diff options
-rw-r--r-- | android/AndroidManifest.xml | 9 | ||||
-rw-r--r-- | android/jni/com/mapswithme/maps/Sponsored.cpp | 7 | ||||
-rw-r--r-- | android/res/layout-land/place_page_details.xml | 11 | ||||
-rw-r--r-- | android/res/layout-w600dp-port/place_page_details.xml | 17 | ||||
-rw-r--r-- | android/res/layout/item_facility.xml | 6 | ||||
-rw-r--r-- | android/res/layout/place_page_details.xml | 11 | ||||
-rw-r--r-- | android/res/layout/place_page_hotel_description.xml | 12 | ||||
-rw-r--r-- | android/res/layout/place_page_hotel_rating.xml | 5 | ||||
-rw-r--r-- | android/res/layout/place_page_more.xml | 7 | ||||
-rw-r--r-- | android/res/values/dimens.xml | 3 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java | 9 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java | 32 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/widget/placepage/Sponsored.java | 37 | ||||
-rw-r--r-- | android/src/com/mapswithme/util/HttpClient.java | 27 |
14 files changed, 107 insertions, 86 deletions
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 3a652ef716..0ed7c82451 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -310,15 +310,6 @@ android:value="com.mapswithme.maps.MwmActivity"/> </activity> - <activity - android:name="com.mapswithme.maps.review.ReviewActivity" - android:parentActivityName="com.mapswithme.maps.MwmActivity"> - <!-- The meta-data element is needed for versions lower than 4.1 --> - <meta-data - android:name="android.support.PARENT_ACTIVITY" - android:value="com.mapswithme.maps.MwmActivity"/> - </activity> - <!-- facebook --> <activity android:name="com.facebook.FacebookActivity" diff --git a/android/jni/com/mapswithme/maps/Sponsored.cpp b/android/jni/com/mapswithme/maps/Sponsored.cpp index ed699c69ea..b271e0c12b 100644 --- a/android/jni/com/mapswithme/maps/Sponsored.cpp +++ b/android/jni/com/mapswithme/maps/Sponsored.cpp @@ -56,12 +56,12 @@ void PrepareClassRefs(JNIEnv * env, jclass sponsoredClass) env, g_hotelInfoClass, "(Ljava/lang/String;[Lcom/mapswithme/maps/gallery/Image;[Lcom/mapswithme/maps/widget/" "placepage/Sponsored$FacilityType;[Lcom/mapswithme/maps/review/Review;[Lcom/mapswithme/" - "maps/widget/placepage/Sponsored$NearbyObject;)V"); + "maps/widget/placepage/Sponsored$NearbyObject;J)V"); // 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;I)V"); + "(Ljava/lang/String;Ljava/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", @@ -122,6 +122,7 @@ JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_widget_placepage_Sponsored_na jni::ToJavaString(env, ppInfo.GetApproximatePricing()), jni::ToJavaString(env, ppInfo.GetSponsoredUrl()), jni::ToJavaString(env, ppInfo.GetSponsoredDescriptionUrl()), + jni::ToJavaString(env, ppInfo.GetSponsoredReviewUrl()), (jint)ppInfo.m_sponsoredType); } @@ -177,7 +178,7 @@ JNIEXPORT void JNICALL Java_com_mapswithme_maps_widget_placepage_Sponsored_nativ env->CallStaticVoidMethod(g_sponsoredClass, g_infoCallback, jni::ToJavaString(env, hotelId), env->NewObject(g_hotelInfoClass, g_hotelInfoConstructor, description, - photos, facilities, reviews, nearby)); + photos, facilities, reviews, nearby, hotelInfo.m_scoreCount)); }); }); } diff --git a/android/res/layout-land/place_page_details.xml b/android/res/layout-land/place_page_details.xml index 30d3bba2ee..d68b1a30af 100644 --- a/android/res/layout-land/place_page_details.xml +++ b/android/res/layout-land/place_page_details.xml @@ -37,9 +37,13 @@ <include layout="@layout/place_page_hotel_gallery"/> + <include layout="@layout/place_page_hotel_description"/> + <include layout="@layout/place_page_hotel_facilities"/> - <include layout="@layout/place_page_hotel_description"/> + <include layout="@layout/place_page_hotel_nearby"/> + + <include layout="@layout/place_page_hotel_rating"/> <include layout="@layout/place_page_placename"/> @@ -67,11 +71,8 @@ <include layout="@layout/place_page_taxi"/> - <include layout="@layout/place_page_hotel_nearby"/> - - <include layout="@layout/place_page_hotel_rating"/> + <include layout="@layout/divider_horizontal"/> - <!--TODO: remove this after booking_api.cpp will be done--> <include layout="@layout/place_page_more"/> <include layout="@layout/divider_horizontal"/> diff --git a/android/res/layout-w600dp-port/place_page_details.xml b/android/res/layout-w600dp-port/place_page_details.xml index 74562b6fec..3d6d42ba15 100644 --- a/android/res/layout-w600dp-port/place_page_details.xml +++ b/android/res/layout-w600dp-port/place_page_details.xml @@ -47,11 +47,18 @@ android:layout_toLeftOf="@id/anchor_center" android:layout_toStartOf="@id/anchor_center" android:orientation="vertical"> + <include layout="@layout/place_page_hotel_gallery"/> + <include layout="@layout/place_page_hotel_description"/> + + <include layout="@layout/place_page_more"/> + <include layout="@layout/place_page_hotel_facilities"/> - <include layout="@layout/place_page_hotel_description"/> + <include layout="@layout/place_page_hotel_nearby"/> + + <include layout="@layout/place_page_hotel_rating"/> <include layout="@layout/place_page_placename"/> @@ -92,13 +99,9 @@ <include layout="@layout/place_page_taxi"/> - <include layout="@layout/place_page_hotel_nearby"/> - - <include layout="@layout/place_page_hotel_rating"/> + <include layout="@layout/divider_horizontal"/> - <!--TODO: remove this after booking_api.cpp will be done--> <include layout="@layout/place_page_more"/> - </LinearLayout> </RelativeLayout> @@ -108,4 +111,4 @@ <include layout="@layout/shadow_top"/> <include layout="@layout/shadow_bottom"/> -</FrameLayout>
\ No newline at end of file +</FrameLayout> diff --git a/android/res/layout/item_facility.xml b/android/res/layout/item_facility.xml index e906e92f26..ef61d5b9ce 100644 --- a/android/res/layout/item_facility.xml +++ b/android/res/layout/item_facility.xml @@ -3,17 +3,17 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:minHeight="@dimen/height_block_base" + android:minHeight="@dimen/placepage_facilities_item" android:orientation="horizontal" android:gravity="center_vertical" android:background="?clickableBackground" android:clickable="true" tools:visibility="visible"> - <ImageView +<!-- <ImageView android:id="@+id/iv__icon" style="@style/PlacePageMetadataIcon" - android:src="@drawable/ic_entrance"/> + android:src="@drawable/ic_entrance"/>--> <TextView android:id="@+id/tv__facility" diff --git a/android/res/layout/place_page_details.xml b/android/res/layout/place_page_details.xml index 9867e493fd..d39b09bad3 100644 --- a/android/res/layout/place_page_details.xml +++ b/android/res/layout/place_page_details.xml @@ -23,9 +23,13 @@ <include layout="@layout/place_page_hotel_gallery"/> + <include layout="@layout/place_page_hotel_description"/> + <include layout="@layout/place_page_hotel_facilities"/> - <include layout="@layout/place_page_hotel_description"/> + <include layout="@layout/place_page_hotel_nearby"/> + + <include layout="@layout/place_page_hotel_rating"/> <include layout="@layout/place_page_placename"/> @@ -53,11 +57,8 @@ <include layout="@layout/place_page_taxi"/> - <include layout="@layout/place_page_hotel_nearby"/> - - <include layout="@layout/place_page_hotel_rating"/> + <include layout="@layout/divider_horizontal"/> - <!--TODO: remove this after booking_api.cpp will be done--> <include layout="@layout/place_page_more"/> <include layout="@layout/divider_horizontal"/> diff --git a/android/res/layout/place_page_hotel_description.xml b/android/res/layout/place_page_hotel_description.xml index 9cd23bdf12..f4af325e3a 100644 --- a/android/res/layout/place_page_hotel_description.xml +++ b/android/res/layout/place_page_hotel_description.xml @@ -15,7 +15,7 @@ android:layout_marginRight="@dimen/margin_base" android:layout_marginTop="@dimen/margin_base" style="@style/PlacePageTitleText" - android:text="@string/details"/> + android:text="@string/placepage_place_description"/> <com.mapswithme.maps.widget.LineCountTextView android:id="@+id/tv__place_hotel_details" @@ -40,4 +40,14 @@ android:text="@string/placepage_more_button"/> <include layout="@layout/divider_horizontal"/> + + <TextView + android:id="@+id/tv__place_hotel_more_on_web" + style="@style/PlacePageMetadataText.Button" + android:height="@dimen/height_block_base" + android:background="?clickableBackground" + android:gravity="center" + android:text="@string/more_on_bookingcom"/> + + <include layout="@layout/divider_horizontal"/> </LinearLayout> diff --git a/android/res/layout/place_page_hotel_rating.xml b/android/res/layout/place_page_hotel_rating.xml index 37c3920de5..b3291ec450 100644 --- a/android/res/layout/place_page_hotel_rating.xml +++ b/android/res/layout/place_page_hotel_rating.xml @@ -47,11 +47,14 @@ android:layout_marginLeft="@dimen/margin_base" android:layout_marginRight="@dimen/margin_base" android:background="?dividerHorizontal"/> + <TextView android:id="@+id/tv__place_hotel_reviews_more" style="@style/PlacePageMetadataText.Button" android:height="@dimen/height_block_base" android:background="?clickableBackground" android:gravity="center" - android:text="@string/placepage_more_reviews_button"/> + android:text="@string/reviews_on_bookingcom"/> + + <include layout="@layout/divider_horizontal"/> </LinearLayout> diff --git a/android/res/layout/place_page_more.xml b/android/res/layout/place_page_more.xml index b597a2c134..1eaab75844 100644 --- a/android/res/layout/place_page_more.xml +++ b/android/res/layout/place_page_more.xml @@ -7,13 +7,10 @@ android:layout_height="wrap_content" android:orientation="vertical"> - <include - layout="@layout/divider_horizontal"/> - <TextView style="@style/PlacePageMetadataText.Button" android:height="@dimen/height_block_base" android:background="?clickableBackground" android:gravity="center" - android:text="@string/details"/> -</LinearLayout>
\ No newline at end of file + android:text="@string/details_on_bookingcom"/> +</LinearLayout> diff --git a/android/res/values/dimens.xml b/android/res/values/dimens.xml index 04129bae92..d4e8d30e1c 100644 --- a/android/res/values/dimens.xml +++ b/android/res/values/dimens.xml @@ -163,6 +163,9 @@ <!-- Rating--> <dimen name="placepage_margin_rating">20dp</dimen> + <!-- Facilities--> + <dimen name="placepage_facilities_item">32dp</dimen> + <!-- Banner--> <dimen name="placepage_banner_height">64dp</dimen> <dimen name="placepage_banner_icon_size">40dp</dimen> diff --git a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java index 918710011d..1ebe5532d1 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java @@ -79,12 +79,13 @@ class FacilitiesAdapter extends BaseAdapter private static class ViewHolder implements View.OnClickListener { - ImageView mIcon; +// ImageView mIcon; TextView mName; public ViewHolder(View view) { - mIcon = (ImageView) view.findViewById(R.id.iv__icon); +// TODO we need icons from designer +// mIcon = (ImageView) view.findViewById(R.id.iv__icon); mName = (TextView) view.findViewById(R.id.tv__facility); view.setOnClickListener(this); } @@ -97,8 +98,8 @@ class FacilitiesAdapter extends BaseAdapter public void bind(Sponsored.FacilityType facility) { -// TODO map facility key to image resource id - mIcon.setImageResource(R.drawable.ic_entrance); +// TODO map facility key to image resource id +// mIcon.setImageResource(R.drawable.ic_entrance); mName.setText(facility.getName()); } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 9fc9a95ec6..b4599cdb41 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -59,7 +59,6 @@ import com.mapswithme.maps.gallery.FullScreenGalleryActivity; import com.mapswithme.maps.gallery.GalleryActivity; import com.mapswithme.maps.gallery.Image; import com.mapswithme.maps.location.LocationHelper; -import com.mapswithme.maps.review.ReviewActivity; import com.mapswithme.maps.routing.RoutingController; import com.mapswithme.maps.widget.ArrowView; import com.mapswithme.maps.widget.BaseShadowController; @@ -103,9 +102,6 @@ public class PlacePageView extends RelativeLayout { private static final String PREF_USE_DMS = "use_dms"; -//TODO: remove this after booking_api.cpp will be done - private static final boolean USE_OLD_BOOKING = false; - private boolean mIsDocked; private boolean mIsFloating; @@ -156,6 +152,7 @@ public class PlacePageView extends RelativeLayout private View mHotelDescription; private LineCountTextView mTvHotelDescription; private View mHotelMoreDescription; + private View mHotelMoreDescriptionOnWeb; private View mHotelFacilities; private View mHotelMoreFacilities; private View mHotelGallery; @@ -556,8 +553,10 @@ public class PlacePageView extends RelativeLayout mHotelDescription = findViewById(R.id.ll__place_hotel_description); mTvHotelDescription = (LineCountTextView) findViewById(R.id.tv__place_hotel_details); mHotelMoreDescription = findViewById(R.id.tv__place_hotel_more); + mHotelMoreDescriptionOnWeb = findViewById(R.id.tv__place_hotel_more_on_web); mTvHotelDescription.setListener(this); mHotelMoreDescription.setOnClickListener(this); + mHotelMoreDescriptionOnWeb.setOnClickListener(this); } @Override @@ -604,9 +603,9 @@ public class PlacePageView extends RelativeLayout { UiUtils.show(mHotelReview); mReviewAdapter.setItems(new ArrayList<>(Arrays.asList(info.mReviews))); - mHotelRating.setText(mSponsored.mRating); + mHotelRating.setText(mSponsored.getRating()); mHotelRatingBase.setText(getResources().getQuantityString(R.plurals.place_page_booking_rating_base, - info.mReviews.length, info.mReviews.length)); + info.mReviews.length, info.mReviewsAmount)); } } @@ -738,7 +737,7 @@ public class PlacePageView extends RelativeLayout try { - followUrl(book ? info.mUrl : info.mUrlDescription); + followUrl(book ? info.getUrl() : info.getDescriptionUrl()); } catch (ActivityNotFoundException e) { @@ -919,15 +918,13 @@ public class PlacePageView extends RelativeLayout if (mSponsored != null) { mSponsored.updateId(mMapObject); - mSponsoredPrice = mSponsored.mPrice; + mSponsoredPrice = mSponsored.getPrice(); Locale locale = Locale.getDefault(); Currency currency = Currency.getInstance(locale); if (mSponsored.getType() == Sponsored.TYPE_BOOKING && mSponsored.getId() != null) Sponsored.requestPrice(mSponsored.getId(), currency.getCurrencyCode(), policy); -// TODO: remove this after booking_api.cpp will be done - if (!USE_OLD_BOOKING) - Sponsored.requestInfo(mSponsored, locale.toString(), policy); + Sponsored.requestInfo(mSponsored, locale.toString(), policy); } String country = MapManager.nativeGetSelectedCountry(); @@ -1048,8 +1045,8 @@ public class PlacePageView extends RelativeLayout if (sponsored) { boolean isPriceEmpty = TextUtils.isEmpty(mSponsoredPrice); - boolean isRatingEmpty = TextUtils.isEmpty(mSponsored.mRating); - mTvSponsoredRating.setText(mSponsored.mRating); + boolean isRatingEmpty = TextUtils.isEmpty(mSponsored.getRating()); + mTvSponsoredRating.setText(mSponsored.getRating()); UiUtils.showIf(!isPriceEmpty && !isRatingEmpty, mTvSponsoredRating); mTvSponsoredPrice.setText(mSponsoredPrice); UiUtils.showIf(!isPriceEmpty, mTvSponsoredPrice); @@ -1081,8 +1078,7 @@ public class PlacePageView extends RelativeLayout else { UiUtils.hide(mWebsite); -// TODO: remove this after booking_api.cpp will be done - UiUtils.showIf(USE_OLD_BOOKING, mHotelMore); + UiUtils.show(mHotelMore); if (mSponsored.getType() != Sponsored.TYPE_BOOKING) UiUtils.hide(mHotelMore); @@ -1383,6 +1379,7 @@ public class PlacePageView extends RelativeLayout addPlace(); break; case R.id.ll__more: + case R.id.tv__place_hotel_more_on_web: onSponsoredClick(false /* book */); break; case R.id.ll__place_latlon: @@ -1423,9 +1420,8 @@ public class PlacePageView extends RelativeLayout mFacilitiesAdapter.setShowAll(true); break; case R.id.tv__place_hotel_reviews_more: - ReviewActivity.start(getContext(), mReviewAdapter.getItems(), mMapObject.getTitle(), - mSponsored.mRating, mReviewAdapter.getItems() - .size(), mSponsored.mUrl); + if (isSponsored()) + followUrl(mSponsored.getReviewUrl()); break; case R.id.tv__place_page_order_taxi: RoutingController.get().prepare(LocationHelper.INSTANCE.getMyPosition(), mMapObject, diff --git a/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java b/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java index c2b7440e2a..fa5fbcf724 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java +++ b/android/src/com/mapswithme/maps/widget/placepage/Sponsored.java @@ -132,16 +132,19 @@ public final class Sponsored final Review[] mReviews; @Nullable final NearbyObject[] mNearby; + final long mReviewsAmount; + public HotelInfo(@Nullable String description, @Nullable Image[] photos, @Nullable FacilityType[] facilities, @Nullable Review[] reviews, - @Nullable NearbyObject[] nearby) + @Nullable NearbyObject[] nearby, long reviewsAmount) { mDescription = description; mPhotos = photos; mFacilities = facilities; mReviews = reviews; mNearby = nearby; + mReviewsAmount = reviewsAmount; } } @@ -187,23 +190,27 @@ public final class Sponsored private String mId; @NonNull - final String mRating; + private final String mRating; + @NonNull + private final String mPrice; @NonNull - final String mPrice; + private final String mUrl; @NonNull - final String mUrl; + private final String mDescriptionUrl; @NonNull - final String mUrlDescription; + private final String mReviewUrl; @SponsoredType private final int mType; public Sponsored(@NonNull String rating, @NonNull String price, @NonNull String url, - @NonNull String urlDescription, @SponsoredType int type) + @NonNull String descriptionUrl, @NonNull String reviewUrl, + @SponsoredType int type) { mRating = rating; mPrice = price; mUrl = url; - mUrlDescription = urlDescription; + mDescriptionUrl = descriptionUrl; + mReviewUrl = reviewUrl; mType = type; } @@ -213,19 +220,19 @@ public final class Sponsored } @Nullable - public String getId() + String getId() { return mId; } @NonNull - public String getRating() + String getRating() { return mRating; } @NonNull - public String getPrice() + String getPrice() { return mPrice; } @@ -237,9 +244,15 @@ public final class Sponsored } @NonNull - public String getUrlDescription() + String getDescriptionUrl() + { + return mDescriptionUrl; + } + + @NonNull + String getReviewUrl() { - return mUrlDescription; + return mReviewUrl; } @SponsoredType diff --git a/android/src/com/mapswithme/util/HttpClient.java b/android/src/com/mapswithme/util/HttpClient.java index 76d3881f34..21ac0ecb59 100644 --- a/android/src/com/mapswithme/util/HttpClient.java +++ b/android/src/com/mapswithme/util/HttpClient.java @@ -54,7 +54,7 @@ public final class HttpClient // TODO(AlexZ): tune for larger files private final static int STREAM_BUFFER_SIZE = 1024 * 64; // Globally accessible for faster unit-testing - public static int TIMEOUT_IN_MILLISECONDS = 30000; + private static int TIMEOUT_IN_MILLISECONDS = 30000; private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.NETWORK); public static Params run(@NonNull final Params p) throws IOException, NullPointerException @@ -142,7 +142,8 @@ public final class HttpClient } // GET data from the server or receive response body p.httpResponseCode = connection.getResponseCode(); - LOGGER.d(TAG, "Received HTTP " + p.httpResponseCode + " from server."); + LOGGER.d(TAG, "Received HTTP " + p.httpResponseCode + " from server, content encoding = " + + connection.getContentEncoding() + ", for request = " + p.url); if (p.httpResponseCode >= 300 && p.httpResponseCode < 400) p.receivedUrl = connection.getHeaderField("Location"); @@ -222,12 +223,12 @@ public final class HttpClient private static void logUrlSafely(@NonNull final String url) { String safeUrl = url.replaceAll("(token|password|key)=([^&]+)", "***"); - LOGGER.d("Connecting to ", safeUrl); + LOGGER.d(TAG, "Connecting to " + safeUrl); } private static class HttpHeader { - public HttpHeader(@NonNull String key, @NonNull String value) + HttpHeader(@NonNull String key, @NonNull String value) { this.key = key; this.value = value; @@ -251,22 +252,22 @@ public final class HttpClient public String url; // Can be different from url in case of redirects. - public String receivedUrl; - public String httpMethod; + String receivedUrl; + String httpMethod; // Should be specified for any request whose method allows non-empty body. // On return, contains received Content-Type or null. // Can be specified for any request whose method allows non-empty body. // On return, contains received Content-Encoding or null. public byte[] data; // Send from input file if specified instead of data. - public String inputFilePath; + String inputFilePath; // Received data is stored here if not null or in data otherwise. - public String outputFilePath; - public String cookies; - public ArrayList<HttpHeader> headers = new ArrayList<>(); - public int httpResponseCode = -1; - public boolean followRedirects = true; - public boolean loadHeaders; + String outputFilePath; + String cookies; + ArrayList<HttpHeader> headers = new ArrayList<>(); + int httpResponseCode = -1; + boolean followRedirects = true; + boolean loadHeaders; // Simple GET request constructor. public Params(String url) |