diff options
author | Roman Romanov <rromanov@65gb.net> | 2016-09-19 12:53:47 +0300 |
---|---|---|
committer | Roman Romanov <rromanov@65gb.net> | 2016-10-03 13:31:58 +0300 |
commit | c7761277083408d712b59d8395bec00b3836c464 (patch) | |
tree | a66fee48d6e966a550da02b1f12426e721f1c9a0 | |
parent | 95bcc19681d70c0d152797ffc15705f30ddc7927 (diff) |
[android] added place page reviews block
-rw-r--r-- | android/res/drawable/bg_circle_green.xml | 7 | ||||
-rw-r--r-- | android/res/drawable/bg_circle_red.xml | 7 | ||||
-rw-r--r-- | android/res/drawable/ic_minus_red.xml | 4 | ||||
-rw-r--r-- | android/res/drawable/ic_negative_review.xml | 15 | ||||
-rw-r--r-- | android/res/drawable/ic_plus_green.xml | 4 | ||||
-rw-r--r-- | android/res/drawable/ic_positive_review.xml | 15 | ||||
-rw-r--r-- | android/res/layout/item_comment.xml | 79 | ||||
-rw-r--r-- | android/res/layout/place_page_hotel_rating.xml | 13 | ||||
-rw-r--r-- | android/res/values/colors.xml | 2 | ||||
-rw-r--r-- | android/res/values/strings.xml | 10 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java | 6 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java | 57 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java | 106 |
13 files changed, 304 insertions, 21 deletions
diff --git a/android/res/drawable/bg_circle_green.xml b/android/res/drawable/bg_circle_green.xml new file mode 100644 index 0000000000..31d0db282b --- /dev/null +++ b/android/res/drawable/bg_circle_green.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> + <solid android:color="@color/bg_placepage_rating_positive"/> + <size + android:height="@dimen/margin_placepage_rating" + android:width="@dimen/margin_placepage_rating"/> +</shape>
\ No newline at end of file diff --git a/android/res/drawable/bg_circle_red.xml b/android/res/drawable/bg_circle_red.xml new file mode 100644 index 0000000000..3de65a6bc3 --- /dev/null +++ b/android/res/drawable/bg_circle_red.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> + <solid android:color="@color/bg_placepage_rating_negative"/> + <size + android:height="@dimen/margin_placepage_rating" + android:width="@dimen/margin_placepage_rating"/> +</shape>
\ No newline at end of file diff --git a/android/res/drawable/ic_minus_red.xml b/android/res/drawable/ic_minus_red.xml new file mode 100644 index 0000000000..411438dca0 --- /dev/null +++ b/android/res/drawable/ic_minus_red.xml @@ -0,0 +1,4 @@ +<vector android:height="10dp" android:viewportHeight="24.0" + android:viewportWidth="24.0" android:width="10dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#FFF44336" android:pathData="M19,13H5v-2h14v2z"/> +</vector> diff --git a/android/res/drawable/ic_negative_review.xml b/android/res/drawable/ic_negative_review.xml new file mode 100644 index 0000000000..7d75805c7d --- /dev/null +++ b/android/res/drawable/ic_negative_review.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:drawable="@drawable/bg_circle_red" + android:left="@dimen/margin_eighth" + android:right="@dimen/margin_eighth" + android:bottom="@dimen/margin_eighth" + android:top="@dimen/margin_eighth"/> + <item + android:drawable="@drawable/ic_minus_red" + android:left="@dimen/margin_eighth" + android:right="@dimen/margin_eighth" + android:bottom="@dimen/margin_eighth" + android:top="@dimen/margin_eighth"/> +</layer-list>
\ No newline at end of file diff --git a/android/res/drawable/ic_plus_green.xml b/android/res/drawable/ic_plus_green.xml new file mode 100644 index 0000000000..10385ed4eb --- /dev/null +++ b/android/res/drawable/ic_plus_green.xml @@ -0,0 +1,4 @@ +<vector android:height="10dp" android:viewportHeight="24.0" + android:viewportWidth="24.0" android:width="10dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#FF578B2D" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/> +</vector> diff --git a/android/res/drawable/ic_positive_review.xml b/android/res/drawable/ic_positive_review.xml new file mode 100644 index 0000000000..8d0948109f --- /dev/null +++ b/android/res/drawable/ic_positive_review.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:drawable="@drawable/bg_circle_green" + android:left="@dimen/margin_eighth" + android:right="@dimen/margin_eighth" + android:bottom="@dimen/margin_eighth" + android:top="@dimen/margin_eighth"/> + <item + android:drawable="@drawable/ic_plus_green" + android:left="@dimen/margin_eighth" + android:right="@dimen/margin_eighth" + android:bottom="@dimen/margin_eighth" + android:top="@dimen/margin_eighth"/> +</layer-list>
\ No newline at end of file diff --git a/android/res/layout/item_comment.xml b/android/res/layout/item_comment.xml index 1ad209b51c..b8342956a1 100644 --- a/android/res/layout/item_comment.xml +++ b/android/res/layout/item_comment.xml @@ -1,33 +1,108 @@ <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content" xmlns:tools="http://schemas.android.com/tools"> + android:layout_height="wrap_content"> + + <View + android:id="@+id/v__divider" + android:layout_width="match_parent" + android:layout_height="1dp" + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base" + android:background="?dividerHorizontal"/> <TextView android:id="@+id/tv__user_name" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/margin_base" android:layout_marginStart="@dimen/margin_base" + android:layout_marginTop="@dimen/margin_base" + android:layout_toLeftOf="@+id/tv__user_rating" + android:layout_toStartOf="@+id/tv__user_rating" + android:layout_below="@id/v__divider" android:textAppearance="@style/MwmTextAppearance.Body1" tools:text="Аleksey"/> + <TextView android:id="@+id/tv__comment_date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/margin_base" android:layout_marginStart="@dimen/margin_base" + android:layout_marginBottom="@dimen/margin_base" android:layout_below="@id/tv__user_name" android:textAppearance="@style/MwmTextAppearance.Body4" tools:text="March 29, 2016"/> + <TextView android:id="@+id/tv__user_rating" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="@dimen/margin_base" android:layout_marginEnd="@dimen/margin_base" + android:layout_marginTop="@dimen/margin_base" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" + android:layout_below="@id/v__divider" android:textAppearance="@style/MwmTextAppearance.Headline" tools:text="9.2"/> + + <LinearLayout + android:id="@+id/ll__positive_review" + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/tv__comment_date"> + <ImageView + android:layout_width="@dimen/margin_base_plus" + android:layout_height="@dimen/margin_base_plus" + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginStart="@dimen/margin_base" + android:src="@drawable/ic_positive_review"/> + + <TextView + android:id="@+id/tv__positive_review" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="@dimen/margin_double" + android:layout_marginStart="@dimen/margin_double" + android:layout_marginRight="@dimen/margin_base" + android:layout_marginEnd="@dimen/margin_base" + android:layout_marginBottom="@dimen/margin_base" + android:paddingTop="@dimen/margin_eighth" + android:textAppearance="@style/MwmTextAppearance.Body3.Primary" + tools:text="Interesting place among SoHo, Little Italy and China town. Modern design. Great view from roof. Near subway. Free refreshment every afternoon. The staff was very friendly."/> + </LinearLayout> + + <LinearLayout + android:id="@+id/ll__negative_review" + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/ll__positive_review"> + <ImageView + android:id="@+id/iv__negative_review" + android:layout_width="@dimen/margin_base_plus" + android:layout_height="@dimen/margin_base_plus" + android:layout_marginBottom="@dimen/margin_base" + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginStart="@dimen/margin_base" + android:src="@drawable/ic_negative_review"/> + + <TextView + android:id="@+id/tv__negative_review" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="@dimen/margin_double" + android:layout_marginStart="@dimen/margin_double" + android:layout_marginRight="@dimen/margin_base" + android:layout_marginEnd="@dimen/margin_base" + android:layout_marginBottom="@dimen/margin_base" + android:paddingTop="@dimen/margin_eighth" + android:textAppearance="@style/MwmTextAppearance.Body3.Primary" + tools:text="Little bit noise from outsideLittle bit noise from outside"/> + </LinearLayout> + </RelativeLayout>
\ No newline at end of file diff --git a/android/res/layout/place_page_hotel_rating.xml b/android/res/layout/place_page_hotel_rating.xml index c1de9a6be8..218e5b1ae0 100644 --- a/android/res/layout/place_page_hotel_rating.xml +++ b/android/res/layout/place_page_hotel_rating.xml @@ -36,10 +36,19 @@ </LinearLayout> <com.mapswithme.maps.widget.StaticGridView - android:id="@+id/gv__place_hotel_nearby" + android:id="@+id/gv__place_hotel_review" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/margin_base" android:numColumns="1" tools:listitem="@layout/item_comment"/> + + <TextView + android:id="@+id/tv__place_hotel_reviews_more" + style="@style/PlacePageMetadataText.Button" + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base" + android:height="@dimen/height_block_base" + android:background="?clickableBackground" + android:gravity="center" + android:text="@string/placepage_more_reviews_button"/> </LinearLayout>
\ No newline at end of file diff --git a/android/res/values/colors.xml b/android/res/values/colors.xml index 001d2328f7..4a0e25c9ea 100644 --- a/android/res/values/colors.xml +++ b/android/res/values/colors.xml @@ -63,6 +63,8 @@ <color name="fg_azimut_arrow">#FFFFFFFF</color> <color name="bg_placepage_rating">#F1F8E9</color> + <color name="bg_placepage_rating_positive">#DCEDC8</color> + <color name="bg_placepage_rating_negative">#FFCDD2</color> <!-- Buttons --> <color name="button">@color/button_normal</color> diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index f19f55527f..820ee012c2 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -886,6 +886,7 @@ <string name="minute">min</string> <string name="placepage_place_description">Description</string> <string name="placepage_more_button">More</string> + <string name="placepage_more_reviews_button">More Reviews</string> <string name="bookingcom_book_button">Book</string> <string name="placepage_call_button">Call</string> <string name="placepage_edit_bookmark_button">Edit Bookmark</string> @@ -973,4 +974,13 @@ <string name="whats_new_booking_improve_message">Search results for hotels now contain the price category.\nWe also added more than 110,000 hotels.</string> <string name="placepage_hotel_facilities">Facilities</string> <string name="placepage_hotel_nearby">Nearby</string> + + <plurals name="place_page_booking_rating_base"> + <item quantity="zero">Based on %1$d hotel reviews</item> + <item quantity="one">Based on %1$d hotel reviews</item> + <item quantity="two">Based on %1$d hotel reviews</item> + <item quantity="few">Based on %1$d hotel reviews</item> + <item quantity="many">Based on %1$d hotel reviews</item> + <item quantity="other">Based on %1$d hotel reviews</item> + </plurals> </resources> diff --git a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java index 98efd23bb6..8019e4060d 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java @@ -13,15 +13,15 @@ import java.util.ArrayList; import java.util.List; public class FacilitiesAdapter extends BaseAdapter { - private static final int MAX_SIZE = 6; + public static final int MAX_COUNT = 6; private List<SponsoredHotel.FacilityType> items = new ArrayList<>(); private boolean isShowAll = false; @Override public int getCount() { - if (items.size() > MAX_SIZE && !isShowAll) { - return MAX_SIZE; + if (items.size() > MAX_COUNT && !isShowAll) { + return MAX_COUNT; } return items.size(); } diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 01542bc507..1be90edc1e 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -147,6 +147,10 @@ public class PlacePageView extends RelativeLayout private View mHotelGallery; private RecyclerView mRvHotelGallery; private View mHotelNearby; + private View mHotelReview; + private TextView mHotelRating; + private TextView mHotelRatingBase; + private View mHotelMoreReviews; // Animations private BaseShadowController mShadowController; @@ -160,6 +164,7 @@ public class PlacePageView extends RelativeLayout private FacilitiesAdapter mFacilitiesAdapter = new FacilitiesAdapter(); private GalleryAdapter mGalleryAdapter; private NearbyAdapter mNearbyAdapter = new NearbyAdapter(this); + private ReviewAdapter mReviewAdapter = new ReviewAdapter(); // Downloader`s stuff private DownloaderStatusIcon mDownloaderIcon; @@ -321,6 +326,13 @@ public class PlacePageView extends RelativeLayout mHotelNearby = findViewById(R.id.ll__place_hotel_nearby); GridView gvHotelNearby = (GridView) findViewById(R.id.gv__place_hotel_nearby); gvHotelNearby.setAdapter(mNearbyAdapter); + mHotelReview = findViewById(R.id.ll__place_hotel_rating); + GridView gvHotelReview = (GridView) findViewById(R.id.gv__place_hotel_review); + gvHotelReview.setAdapter(mReviewAdapter); + mHotelRating = (TextView) findViewById(R.id.tv__place_hotel_rating); + mHotelRatingBase = (TextView) findViewById(R.id.tv__place_hotel_rating_base); + mHotelMoreReviews = findViewById(R.id.tv__place_hotel_reviews_more); + mHotelMoreReviews.setOnClickListener(this); mButtons = new PlacePageButtons(this, ppButtons, new PlacePageButtons.ItemListener() { @@ -485,27 +497,40 @@ public class PlacePageView extends RelativeLayout if (info.facilities == null || info.facilities.length == 0) { UiUtils.hide(mHotelFacilities); - return; + } else { + UiUtils.show(mHotelFacilities); + mFacilitiesAdapter.setShowAll(false); + mFacilitiesAdapter.setItems(Arrays.asList(info.facilities)); + mHotelMoreFacilities.setVisibility(info.facilities.length > FacilitiesAdapter.MAX_COUNT + ? VISIBLE : GONE); } - UiUtils.show(mHotelFacilities); - mFacilitiesAdapter.setShowAll(false); - mFacilitiesAdapter.setItems(Arrays.asList(info.facilities)); - mHotelMoreFacilities.setVisibility(info.facilities.length > 6 ? VISIBLE : GONE); if (info.photos == null || info.photos.length == 0) { UiUtils.hide(mHotelGallery); - return; + } else { + UiUtils.show(mHotelGallery); + mGalleryAdapter.setItems(new ArrayList<>(Arrays.asList(info.photos))); + mRvHotelGallery.scrollToPosition(0); } - UiUtils.show(mHotelGallery); - mGalleryAdapter.setItems(new ArrayList<>(Arrays.asList(info.photos))); - mRvHotelGallery.scrollToPosition(0); if (info.nearby == null || info.nearby.length == 0) { UiUtils.hide(mHotelNearby); - return; + } else { + UiUtils.show(mHotelNearby); + mNearbyAdapter.setItems(Arrays.asList(info.nearby)); + } + + if (info.reviews == null || info.reviews.length == 0) { + UiUtils.hide(mHotelReview); + } else { + UiUtils.show(mHotelReview); + mReviewAdapter.setItems(Arrays.asList(info.reviews)); + mHotelRating.setText(mSponsoredHotel.rating); + mHotelRatingBase.setText(getResources().getQuantityString(R.plurals.place_page_booking_rating_base, + info.reviews.length, info.reviews.length)); + mHotelMoreReviews.setVisibility(info.reviews.length > ReviewAdapter.MAX_COUNT + ? VISIBLE : GONE); } - UiUtils.show(mHotelNearby); - mNearbyAdapter.setItems(Arrays.asList(info.nearby)); } @Override @@ -763,6 +788,7 @@ public class PlacePageView extends RelativeLayout UiUtils.hide(mHotelFacilities); UiUtils.hide(mHotelGallery); UiUtils.hide(mHotelNearby); + UiUtils.hide(mHotelReview); } else { UiUtils.hide(mWebsite); @@ -1052,13 +1078,16 @@ public class PlacePageView extends RelativeLayout getActivity(), getActivity().getSupportFragmentManager()); break; case R.id.tv__place_hotel_more: - mHotelMoreDescription.setVisibility(GONE); + UiUtils.hide(mHotelMoreDescription); mTvHotelDescription.setMaxLines(Integer.MAX_VALUE); break; case R.id.tv__place_hotel_facilities_more: - mHotelMoreFacilities.setVisibility(GONE); + UiUtils.hide(mHotelMoreFacilities); mFacilitiesAdapter.setShowAll(true); break; + case R.id.tv__place_hotel_reviews_more: +// TODO go to reviews activity + break; } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java new file mode 100644 index 0000000000..b0b7014ed4 --- /dev/null +++ b/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java @@ -0,0 +1,106 @@ +package com.mapswithme.maps.widget.placepage; + +import com.mapswithme.maps.R; +import com.mapswithme.util.UiUtils; + +import android.text.TextUtils; +import android.text.format.DateFormat; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +public class ReviewAdapter extends BaseAdapter { + public static final int MAX_COUNT = 3; + + private List<SponsoredHotel.Review> items = new ArrayList<>(); + + @Override + public int getCount() { + if (items.size() > MAX_COUNT) { + return MAX_COUNT; + } + return items.size(); + } + + @Override + public Object getItem(int position) { + return items.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + ViewHolder holder; + if (convertView == null) { + convertView = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.item_comment, parent, false); + holder = new ViewHolder(convertView); + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + holder.bind(items.get(position), position > 0); + + return convertView; + } + + public void setItems( + List<SponsoredHotel.Review> items) { + this.items = items; + notifyDataSetChanged(); + } + + private static class ViewHolder { + final View mDivider; + final TextView mUserName; + final TextView mCommentDate; + final TextView mRating; + final View mPositiveReview; + final TextView mTvPositiveReview; + final View mNegativeReview; + final TextView mTvNegativeReview; + + public ViewHolder(View view) { + mDivider = view.findViewById(R.id.v__divider); + mUserName = (TextView) view.findViewById(R.id.tv__user_name); + mCommentDate = (TextView) view.findViewById(R.id.tv__comment_date); + mRating = (TextView) view.findViewById(R.id.tv__user_rating); + mPositiveReview = view.findViewById(R.id.ll__positive_review); + mTvPositiveReview = (TextView) view.findViewById(R.id.tv__positive_review); + mNegativeReview = view.findViewById(R.id.ll__negative_review); + mTvNegativeReview = (TextView) view.findViewById(R.id.tv__negative_review); + } + + public void bind(SponsoredHotel.Review item, boolean isShowDivider) { + UiUtils.showIf(isShowDivider, mDivider); + mUserName.setText(item.getAuthor()); + Date date = new Date(item.getDate()); + mCommentDate.setText(DateFormat.getMediumDateFormat(mCommentDate.getContext()).format(date)); + mRating.setText(String.format(Locale.getDefault(), "%.1f", item.getRating())); + if (TextUtils.isEmpty(item.getReviewPositive())) { + UiUtils.hide(mPositiveReview); + } else { + UiUtils.show(mPositiveReview); + mTvPositiveReview.setText(item.getReviewPositive()); + } + if (TextUtils.isEmpty(item.getReviewNegative())) { + UiUtils.hide(mNegativeReview); + } else { + UiUtils.show(mNegativeReview); + mTvNegativeReview.setText(item.getReviewNegative()); + } + } + } +}
\ No newline at end of file |