Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorАлександр Зацепин <az@mapswithme.com>2017-09-20 14:43:21 +0300
committerRoman Kuznetsov <r.kuznetsow@gmail.com>2017-09-22 13:17:20 +0300
commit378cb2bfb223efffd51858548fc96b1583ad81ec (patch)
treebe4c4ccd4f1747a445ce11ae777310ad47510eb2 /android
parentd045d10f61798f6cceea7985cc7b2793c5f15344 (diff)
[android] Implmented UGC review item UI
Diffstat (limited to 'android')
-rw-r--r--android/res/layout/item_ugc_comment.xml73
-rw-r--r--android/res/layout/place_page_ugc.xml2
-rw-r--r--android/res/values/attrs.xml1
-rw-r--r--android/res/values/dimens.xml1
-rw-r--r--android/src/com/mapswithme/maps/ugc/UGCReviewAdapter.java14
-rw-r--r--android/src/com/mapswithme/maps/widget/RatingView.java25
6 files changed, 62 insertions, 54 deletions
diff --git a/android/res/layout/item_ugc_comment.xml b/android/res/layout/item_ugc_comment.xml
index e01f6a2651..4c1573ec87 100644
--- a/android/res/layout/item_ugc_comment.xml
+++ b/android/res/layout/item_ugc_comment.xml
@@ -1,55 +1,56 @@
<?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:background="?cardBackground"
- android:layout_width="match_parent"
- 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"/>
-
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:background="?cardBackground"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="@dimen/margin_base">
<TextView
- android:id="@+id/tv__user_name"
+ android:id="@+id/name"
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__comment_date"
- android:layout_toStartOf="@+id/tv__comment_date"
- android:layout_below="@id/v__divider"
- android:textAppearance="@style/MwmTextAppearance.Body3"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
+ android:layout_toLeftOf="@+id/rating"
+ android:layout_toStartOf="@id/rating"
+ android:textAppearance="@style/MwmTextAppearance.Body3.Primary"
+ android:textStyle="bold"
tools:text="Аleksey"/>
<TextView
- android:id="@+id/tv__comment_date"
+ android:id="@+id/date"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/name"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:layout_marginTop="@dimen/margin_quarter"
+ android:textAppearance="@style/MwmTextAppearance.Body3"
+ tools:text="March 29, 2016"/>
+
+ <com.mapswithme.maps.widget.RatingView
+ android:id="@id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/margin_base"
- android:layout_marginRight="@dimen/margin_base"
- android:layout_marginEnd="@dimen/margin_base"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
- android:textAppearance="@style/MwmTextAppearance.Body4"
- tools:text="March 29, 2016"/>
+ android:text="2.0"
+ android:textSize="@dimen/text_size_body_1"
+ app:drawSmile="false"
+ android:textAppearance="@style/MwmTextAppearance.Body2"/>
<TextView
- android:id="@+id/tv__review"
+ android:id="@+id/review"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/margin_base"
- android:layout_marginStart="@dimen/margin_base"
- android:layout_marginRight="@dimen/margin_base"
- android:layout_marginEnd="@dimen/margin_base"
- android:layout_marginTop="@dimen/margin_half_plus"
- android:layout_marginBottom="@dimen/margin_base"
- android:layout_below="@id/tv__user_name"
+ android:layout_marginTop="@dimen/margin_half"
+ android:layout_below="@id/date"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
android:textAppearance="@style/MwmTextAppearance.Body3.Primary"
android:visibility="visible"
tools:visibility="visible"
diff --git a/android/res/layout/place_page_ugc.xml b/android/res/layout/place_page_ugc.xml
index f1231feda2..b76bb6cdca 100644
--- a/android/res/layout/place_page_ugc.xml
+++ b/android/res/layout/place_page_ugc.xml
@@ -241,8 +241,6 @@
<View
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__pp_ugc_reviews_more"
diff --git a/android/res/values/attrs.xml b/android/res/values/attrs.xml
index cc97d746aa..f90b460c45 100644
--- a/android/res/values/attrs.xml
+++ b/android/res/values/attrs.xml
@@ -36,6 +36,7 @@
<enum name="good" value="3"/>
<enum name="excellent" value="4"/>
</attr>
+ <attr name="drawSmile" format="boolean"/>
</declare-styleable>
<bool name="isTablet">false</bool>
diff --git a/android/res/values/dimens.xml b/android/res/values/dimens.xml
index 22dfe7d14b..69762acb5d 100644
--- a/android/res/values/dimens.xml
+++ b/android/res/values/dimens.xml
@@ -214,4 +214,5 @@
<!-- Rating-->
<dimen name="rating_view_height">40dp</dimen>
<dimen name="rating_view_height_small">20dp</dimen>
+ <dimen name="rating_view_background_radius">20dp</dimen>
</resources>
diff --git a/android/src/com/mapswithme/maps/ugc/UGCReviewAdapter.java b/android/src/com/mapswithme/maps/ugc/UGCReviewAdapter.java
index fb26fa1ab0..db0375b5fc 100644
--- a/android/src/com/mapswithme/maps/ugc/UGCReviewAdapter.java
+++ b/android/src/com/mapswithme/maps/ugc/UGCReviewAdapter.java
@@ -33,7 +33,7 @@ public class UGCReviewAdapter extends Adapter<UGCReviewAdapter.ViewHolder>
@Override
public void onBindViewHolder(ViewHolder holder, int position)
{
- holder.bind(mItems.get(position), position > 0);
+ holder.bind(mItems.get(position));
}
@Override
@@ -52,8 +52,6 @@ public class UGCReviewAdapter extends Adapter<UGCReviewAdapter.ViewHolder>
static class ViewHolder extends RecyclerView.ViewHolder
{
@NonNull
- final View mDivider;
- @NonNull
final TextView mAuthor;
@NonNull
final TextView mCommentDate;
@@ -63,15 +61,13 @@ public class UGCReviewAdapter extends Adapter<UGCReviewAdapter.ViewHolder>
public ViewHolder(View itemView)
{
super(itemView);
- mDivider = itemView.findViewById(R.id.v__divider);
- mAuthor = (TextView) itemView.findViewById(R.id.tv__user_name);
- mCommentDate = (TextView) itemView.findViewById(R.id.tv__comment_date);
- mReview = (TextView) itemView.findViewById(R.id.tv__review);
+ mAuthor = (TextView) itemView.findViewById(R.id.name);
+ mCommentDate = (TextView) itemView.findViewById(R.id.date);
+ mReview = (TextView) itemView.findViewById(R.id.review);
}
- public void bind(UGC.Review review, boolean isShowDivider)
+ public void bind(UGC.Review review)
{
- UiUtils.showIf(isShowDivider, mDivider);
mAuthor.setText(review.getAuthor());
mCommentDate.setText(review.getDaysAgo() + " days ago");
mReview.setText(review.getText());
diff --git a/android/src/com/mapswithme/maps/widget/RatingView.java b/android/src/com/mapswithme/maps/widget/RatingView.java
index 33f51567f1..5dc22a0c63 100644
--- a/android/src/com/mapswithme/maps/widget/RatingView.java
+++ b/android/src/com/mapswithme/maps/widget/RatingView.java
@@ -22,7 +22,6 @@ import com.mapswithme.maps.ugc.Rating;
public class RatingView extends View
{
- private static final float CORNER_RADIUS_PX = 40;
@Nullable
private Drawable mDrawable;
@NonNull
@@ -39,6 +38,8 @@ public class RatingView extends View
private String mRatingValue;
@ColorInt
private int mRatingColor;
+ private boolean mDrawSmile;
+ private int mBackgroundCornerRaduis;
public RatingView(Context context, @Nullable AttributeSet attrs)
{
@@ -54,6 +55,7 @@ public class RatingView extends View
private void init(@Nullable AttributeSet attrs)
{
+ mBackgroundCornerRaduis = getResources().getDimensionPixelSize(R.dimen.rating_view_background_radius);
TypedArray a = getContext().obtainStyledAttributes(
attrs, R.styleable.RatingView);
@@ -61,6 +63,7 @@ public class RatingView extends View
mTextPaint.setTextSize(textSize);
mTextPaint.setTypeface(Typeface.create("Roboto", Typeface.BOLD));
mRatingValue = a.getString(R.styleable.RatingView_android_text);
+ mDrawSmile = a.getBoolean(R.styleable.RatingView_drawSmile, true);
int rating = a.getInteger(R.styleable.RatingView_rating, 0);
a.recycle();
@@ -79,7 +82,8 @@ public class RatingView extends View
mRatingColor = res.getColor(r.getColorId());
mBackgroundPaint.setColor(mRatingColor);
mBackgroundPaint.setAlpha(31 /* 12% */);
- mDrawable = res.getDrawable(r.getDrawableId());
+ if (mDrawSmile)
+ mDrawable = res.getDrawable(r.getDrawableId());
mTextPaint.setColor(mRatingColor);
invalidate();
requestLayout();
@@ -109,7 +113,7 @@ public class RatingView extends View
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
- final int height = getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec);
+ int height = getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec);
int width = getPaddingLeft();
if (mDrawable != null)
{
@@ -122,7 +126,9 @@ public class RatingView extends View
if (mRatingValue != null)
{
mTextPaint.getTextBounds(mRatingValue, 0, mRatingValue.length(), mTextBounds);
- width += getPaddingLeft() + mTextBounds.width();
+ width += (mDrawable != null ? getPaddingLeft() : 0) + mTextPaint.measureText(mRatingValue);
+ if (height == 0)
+ height = getPaddingTop() + mTextBounds.height() + getPaddingBottom();
}
width += getPaddingRight();
@@ -134,8 +140,11 @@ public class RatingView extends View
@Override
protected void onDraw(Canvas canvas)
{
- if (getBackground() == null)
- canvas.drawRoundRect(mBackgroundBounds, CORNER_RADIUS_PX, CORNER_RADIUS_PX, mBackgroundPaint);
+ if (getBackground() == null && mDrawable != null)
+ {
+ canvas.drawRoundRect(mBackgroundBounds, mBackgroundCornerRaduis, mBackgroundCornerRaduis,
+ mBackgroundPaint);
+ }
if (mDrawable != null)
{
@@ -149,7 +158,9 @@ public class RatingView extends View
{
float yPos = getHeight() / 2;
yPos += (Math.abs(mTextBounds.height())) / 2;
- canvas.drawText(mRatingValue, mDrawable.getBounds().right + getPaddingLeft(), yPos, mTextPaint);
+ float xPos = mDrawable != null ? mDrawable.getBounds().right + getPaddingLeft()
+ : getPaddingLeft();
+ canvas.drawText(mRatingValue, xPos, yPos, mTextPaint);
}
}
}