From 9cc26c89b1afc8a249822889cfc63a370311da4c Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Tue, 13 Sep 2016 10:39:38 +0400 Subject: [PATCH 01/26] [android] place page hotel description --- .../com/mapswithme/maps/SponsoredHotel.cpp | 18 +++++++ android/res/layout/place_page_details.xml | 4 ++ .../layout/place_page_hotel_description.xml | 29 +++++++++++ android/res/values-v16/styles-text.xml | 7 +++ android/res/values/styles-place_page.xml | 6 +++ android/res/values/styles-text.xml | 8 +++ .../maps/widget/LineCountTextView.java | 49 +++++++++++++++++++ .../maps/widget/placepage/PlacePageView.java | 39 ++++++++++++++- .../maps/widget/placepage/SponsoredHotel.java | 48 ++++++++++++++++-- 9 files changed, 201 insertions(+), 7 deletions(-) create mode 100644 android/res/layout/place_page_hotel_description.xml create mode 100644 android/res/values-v16/styles-text.xml create mode 100644 android/src/com/mapswithme/maps/widget/LineCountTextView.java diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp index b9ece774fd..c651ea2eee 100644 --- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp +++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp @@ -12,6 +12,7 @@ namespace jclass g_hotelClass; jmethodID g_hotelClassCtor; jmethodID g_priceCallback; +jmethodID g_descriptionCallback; void PrepareClassRefs(JNIEnv * env, jclass hotelClass) { @@ -24,6 +25,8 @@ void PrepareClassRefs(JNIEnv * env, jclass hotelClass) g_hotelClassCtor = jni::GetConstructorID(env, g_hotelClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); // static void onPriceReceived(final String id, final String price, final String currency) g_priceCallback = jni::GetStaticMethodID(env, g_hotelClass, "onPriceReceived", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); + // static void onDescriptionReceived(final String id, final String description) + g_descriptionCallback = jni::GetStaticMethodID(env, g_hotelClass, "onDescriptionReceived", "(Ljava/lang/String;Ljava/lang/String;)V"); } } // namespace @@ -68,4 +71,19 @@ Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestPrice(JNIE }); } +// static void nativeRequestDescription(String id, String locale); +JNIEXPORT void JNICALL +Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestDescription(JNIEnv * env, jclass clazz, jstring id, jstring locale) +{ + PrepareClassRefs(env, clazz); + + string const hotelId = jni::ToNativeString(env, id); + string const localeCode = jni::ToNativeString(env, locale); + + //TODO make request + //JNIEnv * env = jni::GetEnv(); + env->CallStaticVoidMethod(g_hotelClass, g_descriptionCallback, jni::ToJavaString(env, hotelId), + jni::ToJavaString(env, "One of our top picks in New York City. This boutique hotel in the Manhattan neighborhood of Nolita features a private rooftop and rooms with free WiFi. The Bowery subway station is 1 block from this New York hotel. One of our top picks in New York City. This boutique hotel in the Manhattan neighborhood of Nolita features a private rooftop and rooms with free WiFi. The Bowery subway station is 1 block from this New York hotel.")); +} + } // extern "C" diff --git a/android/res/layout/place_page_details.xml b/android/res/layout/place_page_details.xml index b3b07aa77c..14f899acf5 100644 --- a/android/res/layout/place_page_details.xml +++ b/android/res/layout/place_page_details.xml @@ -27,6 +27,10 @@ android:layout_marginBottom="@dimen/margin_half" tools:visibility="gone"/> + + + + diff --git a/android/res/layout/place_page_hotel_description.xml b/android/res/layout/place_page_hotel_description.xml new file mode 100644 index 0000000000..b37cad21cb --- /dev/null +++ b/android/res/layout/place_page_hotel_description.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/android/res/values-v16/styles-text.xml b/android/res/values-v16/styles-text.xml new file mode 100644 index 0000000000..a9ba1ab5b2 --- /dev/null +++ b/android/res/values-v16/styles-text.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/android/res/values/styles-place_page.xml b/android/res/values/styles-place_page.xml index ce734846a6..de018232d0 100644 --- a/android/res/values/styles-place_page.xml +++ b/android/res/values/styles-place_page.xml @@ -59,6 +59,12 @@ @style/MwmTextAppearance.PlacePage.Accent + + + + @@ -150,6 +155,9 @@ ?colorAccent + diff --git a/android/src/com/mapswithme/maps/widget/LineCountTextView.java b/android/src/com/mapswithme/maps/widget/LineCountTextView.java new file mode 100644 index 0000000000..afd4f9a4bd --- /dev/null +++ b/android/src/com/mapswithme/maps/widget/LineCountTextView.java @@ -0,0 +1,49 @@ +package com.mapswithme.maps.widget; + +import android.content.Context; +import android.graphics.Canvas; +import android.text.Layout; +import android.util.AttributeSet; +import android.widget.TextView; + +public class LineCountTextView extends TextView { + + public interface OnLineCountCalculatedListener { + + void onLineCountCalculated(boolean grater); + } + + private OnLineCountCalculatedListener mListener; + + public LineCountTextView(Context context) { + super(context); + } + + public LineCountTextView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public LineCountTextView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + Layout layout = getLayout(); + + if (layout != null) { + int textHeight = layout.getHeight(); + int viewHeight = getHeight(); + + if (mListener != null) { + mListener.onLineCountCalculated(textHeight > viewHeight); + } + } + } + + public void setListener( + OnLineCountCalculatedListener listener) { + mListener = listener; + } +} diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index bd14f2a079..3405abc4bf 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -61,6 +61,7 @@ import com.mapswithme.maps.location.LocationHelper; import com.mapswithme.maps.routing.RoutingController; import com.mapswithme.maps.widget.ArrowView; import com.mapswithme.maps.widget.BaseShadowController; +import com.mapswithme.maps.widget.LineCountTextView; import com.mapswithme.maps.widget.ObservableScrollView; import com.mapswithme.maps.widget.ScrollViewShadowController; import com.mapswithme.util.Graphics; @@ -77,7 +78,9 @@ import com.mapswithme.util.statistics.Statistics; public class PlacePageView extends RelativeLayout implements View.OnClickListener, View.OnLongClickListener, - SponsoredHotel.OnPriceReceivedListener + SponsoredHotel.OnPriceReceivedListener, + SponsoredHotel.OnDescriptionReceivedListener, + LineCountTextView.OnLineCountCalculatedListener { private static final String PREF_USE_DMS = "use_dms"; @@ -126,6 +129,10 @@ public class PlacePageView extends RelativeLayout // Place page buttons private PlacePageButtons mButtons; private ImageView mBookmarkButtonIcon; + // Hotel + private View mHotelDescription; + private LineCountTextView mTvHotelDescription; + private View mHotelMoreDescription; // Animations private BaseShadowController mShadowController; @@ -274,6 +281,12 @@ public class PlacePageView extends RelativeLayout ViewGroup ppButtons = (ViewGroup) findViewById(R.id.pp__buttons); + 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); + mTvHotelDescription.setListener(this); + mHotelMoreDescription.setOnClickListener(this); + mButtons = new PlacePageButtons(this, ppButtons, new PlacePageButtons.ItemListener() { @Override @@ -401,7 +414,8 @@ public class PlacePageView extends RelativeLayout if (UiUtils.isLandscape(getContext())) mDetails.setBackgroundResource(0); - SponsoredHotel.setListener(this); + SponsoredHotel.setPriceListener(this); + SponsoredHotel.setDescriptionListener(this); } @Override @@ -424,6 +438,22 @@ public class PlacePageView extends RelativeLayout refreshPreview(); } + @Override + public void onDescriptionReceived(String id, String description) { + if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) { + return; + } + + mTvHotelDescription.setMaxLines(5); + refreshMetadataOrHide(description, mHotelDescription, mTvHotelDescription); + mHotelMoreDescription.setVisibility(GONE); + } + + @Override + public void onLineCountCalculated(boolean grater) { + mHotelMoreDescription.setVisibility(grater ? VISIBLE : GONE); + } + private void onBookingClick(final boolean book) { // TODO (trashkalmar): Set correct text @@ -559,6 +589,7 @@ public class PlacePageView extends RelativeLayout Currency currency = Currency.getInstance(Locale.getDefault()); SponsoredHotel.requestPrice(mSponsoredHotel.getId(), currency.getCurrencyCode()); + SponsoredHotel.requestDescription(mSponsoredHotel.getId(), Locale.getDefault().toString()); } String country = MapManager.nativeGetSelectedCountry(); @@ -945,6 +976,10 @@ public class PlacePageView extends RelativeLayout EditBookmarkFragment.editBookmark(bookmark.getCategoryId(), bookmark.getBookmarkId(), getActivity(), getActivity().getSupportFragmentManager()); break; + case R.id.tv__place_hotel_more: + mHotelMoreDescription.setVisibility(GONE); + mTvHotelDescription.setMaxLines(Integer.MAX_VALUE); + break; } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java index 2b97298c41..eeb645d3ec 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java +++ b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java @@ -31,9 +31,17 @@ public final class SponsoredHotel void onPriceReceived(String id, String price, String currency); } + interface OnDescriptionReceivedListener + { + void onDescriptionReceived(String id, String description); + } + // Hotel ID -> Price private static final Map sPriceCache = new HashMap<>(); - private static WeakReference sListener; + // Hotel ID -> Description + private static final Map sDescriptionCache = new HashMap<>(); + private static WeakReference sPriceListener; + private static WeakReference sDescriptionListener; private String mId; @@ -80,9 +88,14 @@ public final class SponsoredHotel return urlDescription; } - public static void setListener(OnPriceReceivedListener listener) + public static void setPriceListener(OnPriceReceivedListener listener) { - sListener = new WeakReference<>(listener); + sPriceListener = new WeakReference<>(listener); + } + + public static void setDescriptionListener(OnDescriptionReceivedListener listener) + { + sDescriptionListener = new WeakReference<>(listener); } static void requestPrice(String id, String currencyCode) @@ -94,6 +107,15 @@ public final class SponsoredHotel nativeRequestPrice(id, currencyCode); } + static void requestDescription(String id, String locale) + { + String description = sDescriptionCache.get(id); + if (description != null) + onDescriptionReceived(id, description); + + nativeRequestDescription(id, locale); + } + @SuppressWarnings("unused") private static void onPriceReceived(String id, String price, String currency) { @@ -102,14 +124,30 @@ public final class SponsoredHotel sPriceCache.put(id, new Price(price, currency)); - OnPriceReceivedListener listener = sListener.get(); + OnPriceReceivedListener listener = sPriceListener.get(); if (listener == null) - sListener = null; + sPriceListener = null; else listener.onPriceReceived(id, price, currency); } + @SuppressWarnings("unused") + private static void onDescriptionReceived(String id, String description) + { + if (TextUtils.isEmpty(description)) + return; + + sDescriptionCache.put(id, description); + + OnDescriptionReceivedListener listener = sDescriptionListener.get(); + if (listener == null) + sDescriptionListener = null; + else + listener.onDescriptionReceived(id, description); + } + @Nullable public static native SponsoredHotel nativeGetCurrent(); private static native void nativeRequestPrice(String id, String currencyCode); + private static native void nativeRequestDescription(String id, String locale); } From 99ae639ca45596393c6a1bd3eb07e08c8311843e Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Tue, 13 Sep 2016 15:09:12 +0400 Subject: [PATCH 02/26] [android] facility types --- .../com/mapswithme/maps/SponsoredHotel.cpp | 22 +++++ android/res/layout/item_facility.xml | 24 ++++++ android/res/layout/place_page_details.xml | 4 + .../layout/place_page_hotel_description.xml | 39 ++++----- .../layout/place_page_hotel_facilities.xml | 29 +++++++ android/res/values/strings.xml | 1 + .../maps/widget/StaticGridView.java | 26 ++++++ .../widget/placepage/FacilitiesAdapter.java | 81 +++++++++++++++++++ .../maps/widget/placepage/PlacePageView.java | 46 +++++++++-- .../maps/widget/placepage/SponsoredHotel.java | 78 ++++++++++++++++++ map/booking_api.cpp | 2 +- 11 files changed, 327 insertions(+), 25 deletions(-) create mode 100644 android/res/layout/item_facility.xml create mode 100644 android/res/layout/place_page_hotel_facilities.xml create mode 100644 android/src/com/mapswithme/maps/widget/StaticGridView.java create mode 100644 android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp index c651ea2eee..4c01673361 100644 --- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp +++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp @@ -13,6 +13,7 @@ jclass g_hotelClass; jmethodID g_hotelClassCtor; jmethodID g_priceCallback; jmethodID g_descriptionCallback; +jmethodID g_facilitiesCallback; void PrepareClassRefs(JNIEnv * env, jclass hotelClass) { @@ -27,6 +28,8 @@ void PrepareClassRefs(JNIEnv * env, jclass hotelClass) g_priceCallback = jni::GetStaticMethodID(env, g_hotelClass, "onPriceReceived", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); // static void onDescriptionReceived(final String id, final String description) g_descriptionCallback = jni::GetStaticMethodID(env, g_hotelClass, "onDescriptionReceived", "(Ljava/lang/String;Ljava/lang/String;)V"); + // static void onFacilitiesReceived(final String id, int[] ids, String[] names) + g_facilitiesCallback = jni::GetStaticMethodID(env, g_hotelClass, "onFacilitiesReceived", "(Ljava/lang/String;[I[Ljava/lang/String;)V"); } } // namespace @@ -86,4 +89,23 @@ Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestDescriptio jni::ToJavaString(env, "One of our top picks in New York City. This boutique hotel in the Manhattan neighborhood of Nolita features a private rooftop and rooms with free WiFi. The Bowery subway station is 1 block from this New York hotel. One of our top picks in New York City. This boutique hotel in the Manhattan neighborhood of Nolita features a private rooftop and rooms with free WiFi. The Bowery subway station is 1 block from this New York hotel.")); } +// static void nativeRequestFacilities(String id, String locale); +JNIEXPORT void JNICALL +Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestFacilities(JNIEnv * env, jclass clazz, jstring id, jstring locale) +{ + PrepareClassRefs(env, clazz); + + string const hotelId = jni::ToNativeString(env, id); + string const localeCode = jni::ToNativeString(env, locale); + + //TODO make request + jintArray result; + result = env->NewIntArray(7); + jint fill[7]{0, 1, 2, 3, 4, 5, 6}; + env->SetIntArrayRegion(result, 0, 7, fill); + env->CallStaticVoidMethod(g_hotelClass, g_facilitiesCallback, jni::ToJavaString(env, hotelId), + result, + jni::ToJavaStringArray(env, {"Bar", "Terrace", "Fitness Center", "Pets are allowed on request", "Restaurant", "Private parking", "Ghost Busters"})); +} + } // extern "C" diff --git a/android/res/layout/item_facility.xml b/android/res/layout/item_facility.xml new file mode 100644 index 0000000000..aabc553c69 --- /dev/null +++ b/android/res/layout/item_facility.xml @@ -0,0 +1,24 @@ + + + + + + + \ No newline at end of file diff --git a/android/res/layout/place_page_details.xml b/android/res/layout/place_page_details.xml index 14f899acf5..79e4267d64 100644 --- a/android/res/layout/place_page_details.xml +++ b/android/res/layout/place_page_details.xml @@ -27,6 +27,10 @@ android:layout_marginBottom="@dimen/margin_half" tools:visibility="gone"/> + + + + diff --git a/android/res/layout/place_page_hotel_description.xml b/android/res/layout/place_page_hotel_description.xml index b37cad21cb..a2913ce02e 100644 --- a/android/res/layout/place_page_hotel_description.xml +++ b/android/res/layout/place_page_hotel_description.xml @@ -4,26 +4,27 @@ android:id="@+id/ll__place_hotel_description" android:orientation="vertical" style="@style/PlacePageItemFrame" - tools:background="#20FF0000"> + tools:background="#20FF0000" + tools:visibility="visible"> - + - + - + \ No newline at end of file diff --git a/android/res/layout/place_page_hotel_facilities.xml b/android/res/layout/place_page_hotel_facilities.xml new file mode 100644 index 0000000000..7a450f4de3 --- /dev/null +++ b/android/res/layout/place_page_hotel_facilities.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index 79a04bf47e..064aa3b800 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -971,4 +971,5 @@ For pedestrian and bike routes we now display the elevation profile. Save when booking hotels Search results for hotels now contain the price category.\nWe also added more than 110,000 hotels. + Facilities diff --git a/android/src/com/mapswithme/maps/widget/StaticGridView.java b/android/src/com/mapswithme/maps/widget/StaticGridView.java new file mode 100644 index 0000000000..db77432f2b --- /dev/null +++ b/android/src/com/mapswithme/maps/widget/StaticGridView.java @@ -0,0 +1,26 @@ +package com.mapswithme.maps.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.GridView; + +public class StaticGridView extends GridView { + + public StaticGridView(Context context) { + super(context); + } + + public StaticGridView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public StaticGridView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST)); + getLayoutParams().height = getMeasuredHeight(); + } +} diff --git a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java new file mode 100644 index 0000000000..c5e0f2793c --- /dev/null +++ b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java @@ -0,0 +1,81 @@ +package com.mapswithme.maps.widget.placepage; + +import com.mapswithme.maps.R; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + +public class FacilitiesAdapter extends BaseAdapter { + private static final int MAX_SIZE = 6; + + private List items = new ArrayList<>(); + private boolean isShowAll = false; + + @Override + public int getCount() { + if (items.size() > MAX_SIZE && !isShowAll) { + return MAX_SIZE; + } + 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_facility, parent, false); + holder = new ViewHolder(convertView); + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + holder.bind(items.get(position)); + + return convertView; + } + + public void setItems( + List items) { + this.items = items; + notifyDataSetChanged(); + } + + public void setShowAll(boolean showAll) { + isShowAll = showAll; + notifyDataSetChanged(); + } + + private static class ViewHolder { + ImageView mIcon; + TextView mName; + + public ViewHolder(View view) { + mIcon = (ImageView) view.findViewById(R.id.iv__icon); + mName = (TextView) view.findViewById(R.id.tv__facility); + } + + public void bind(SponsoredHotel.FacilityType facility) { + mIcon.setImageResource(facility.getIcon()); + 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 3405abc4bf..a90538dbca 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -24,6 +24,7 @@ import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.widget.GridView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupMenu; @@ -80,8 +81,8 @@ public class PlacePageView extends RelativeLayout View.OnLongClickListener, SponsoredHotel.OnPriceReceivedListener, SponsoredHotel.OnDescriptionReceivedListener, - LineCountTextView.OnLineCountCalculatedListener -{ + LineCountTextView.OnLineCountCalculatedListener, + SponsoredHotel.OnFacilitiesReceivedListener { private static final String PREF_USE_DMS = "use_dms"; private boolean mIsDocked; @@ -133,6 +134,9 @@ public class PlacePageView extends RelativeLayout private View mHotelDescription; private LineCountTextView mTvHotelDescription; private View mHotelMoreDescription; + private View mHotelFacilities; + private GridView mGvHotelFacilities; + private View mHotelMoreFacilities; // Animations private BaseShadowController mShadowController; @@ -143,6 +147,7 @@ public class PlacePageView extends RelativeLayout private SponsoredHotel mSponsoredHotel; private String mSponsoredHotelPrice; private boolean mIsLatLonDms; + private FacilitiesAdapter mFacilitiesAdapter = new FacilitiesAdapter(); // Downloader`s stuff private DownloaderStatusIcon mDownloaderIcon; @@ -286,6 +291,11 @@ public class PlacePageView extends RelativeLayout mHotelMoreDescription = findViewById(R.id.tv__place_hotel_more); mTvHotelDescription.setListener(this); mHotelMoreDescription.setOnClickListener(this); + mHotelFacilities = findViewById(R.id.ll__place_hotel_facilities); + mGvHotelFacilities = (GridView) findViewById(R.id.gv__place_hotel_facilities); + mHotelMoreFacilities = findViewById(R.id.tv__place_hotel_facilities_more); + mGvHotelFacilities.setAdapter(mFacilitiesAdapter); + mHotelMoreFacilities.setOnClickListener(this); mButtons = new PlacePageButtons(this, ppButtons, new PlacePageButtons.ItemListener() { @@ -416,6 +426,7 @@ public class PlacePageView extends RelativeLayout SponsoredHotel.setPriceListener(this); SponsoredHotel.setDescriptionListener(this); + SponsoredHotel.setFacilitiesListener(this); } @Override @@ -449,6 +460,22 @@ public class PlacePageView extends RelativeLayout mHotelMoreDescription.setVisibility(GONE); } + @Override + public void onFacilitiesReceived(String id, List facilities) { + if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) { + return; + } + + if (facilities == null || facilities.isEmpty()) { + UiUtils.hide(mHotelFacilities); + return; + } + UiUtils.show(mHotelFacilities); + mFacilitiesAdapter.setShowAll(false); + mFacilitiesAdapter.setItems(facilities); + mHotelMoreFacilities.setVisibility(facilities.size() > 6 ? VISIBLE : GONE); + } + @Override public void onLineCountCalculated(boolean grater) { mHotelMoreDescription.setVisibility(grater ? VISIBLE : GONE); @@ -587,9 +614,11 @@ public class PlacePageView extends RelativeLayout mSponsoredHotel.updateId(mMapObject); mSponsoredHotelPrice = mSponsoredHotel.price; - Currency currency = Currency.getInstance(Locale.getDefault()); + Locale locale = Locale.getDefault(); + Currency currency = Currency.getInstance(locale); SponsoredHotel.requestPrice(mSponsoredHotel.getId(), currency.getCurrencyCode()); - SponsoredHotel.requestDescription(mSponsoredHotel.getId(), Locale.getDefault().toString()); + SponsoredHotel.requestDescription(mSponsoredHotel.getId(), locale.toString()); + SponsoredHotel.requestFacilities(mSponsoredHotel.getId(), locale.toString()); } String country = MapManager.nativeGetSelectedCountry(); @@ -689,9 +718,12 @@ public class PlacePageView extends RelativeLayout { final String website = mMapObject.getMetadata(Metadata.MetadataType.FMD_WEBSITE); refreshMetadataOrHide(TextUtils.isEmpty(website) ? mMapObject.getMetadata(Metadata.MetadataType.FMD_URL) : website, mWebsite, mTvWebsite); + UiUtils.hide(mHotelDescription); + UiUtils.hide(mHotelFacilities); } - else + else { UiUtils.hide(mWebsite); + } refreshMetadataOrHide(mMapObject.getMetadata(Metadata.MetadataType.FMD_PHONE_NUMBER), mPhone, mTvPhone); refreshMetadataOrHide(mMapObject.getMetadata(Metadata.MetadataType.FMD_EMAIL), mEmail, mTvEmail); @@ -980,6 +1012,10 @@ public class PlacePageView extends RelativeLayout mHotelMoreDescription.setVisibility(GONE); mTvHotelDescription.setMaxLines(Integer.MAX_VALUE); break; + case R.id.tv__place_hotel_facilities_more: + mHotelMoreFacilities.setVisibility(GONE); + mFacilitiesAdapter.setShowAll(true); + break; } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java index eeb645d3ec..75829be32f 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java +++ b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java @@ -1,13 +1,17 @@ package com.mapswithme.maps.widget.placepage; import android.support.annotation.Nullable; +import android.support.annotation.DrawableRes; import android.support.annotation.UiThread; import android.text.TextUtils; import java.lang.ref.WeakReference; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import com.mapswithme.maps.R; import com.mapswithme.maps.bookmarks.data.MapObject; import com.mapswithme.maps.bookmarks.data.Metadata; @@ -26,6 +30,26 @@ public final class SponsoredHotel } } + public static class FacilityType { + @DrawableRes + private final int icon; + private final String name; + + public FacilityType(@DrawableRes int icon, String name) { + this.icon = icon; + this.name = name; + } + + @DrawableRes + public int getIcon() { + return icon; + } + + public String getName() { + return name; + } + } + interface OnPriceReceivedListener { void onPriceReceived(String id, String price, String currency); @@ -36,12 +60,20 @@ public final class SponsoredHotel void onDescriptionReceived(String id, String description); } + interface OnFacilitiesReceivedListener + { + void onFacilitiesReceived(String id, List facilities); + } + // Hotel ID -> Price private static final Map sPriceCache = new HashMap<>(); // Hotel ID -> Description private static final Map sDescriptionCache = new HashMap<>(); + // Hotel ID -> Facilities + private static final Map> sFacilitiesCache = new HashMap<>(); private static WeakReference sPriceListener; private static WeakReference sDescriptionListener; + private static WeakReference sFacilityListener; private String mId; @@ -98,6 +130,17 @@ public final class SponsoredHotel sDescriptionListener = new WeakReference<>(listener); } + public static void setFacilitiesListener(OnFacilitiesReceivedListener listener) + { + sFacilityListener = new WeakReference<>(listener); + } + + @DrawableRes + public static int mapFacilityId(int facilityId) { +// TODO map facility id to drawable resource + return R.drawable.ic_entrance; + } + static void requestPrice(String id, String currencyCode) { Price p = sPriceCache.get(id); @@ -116,6 +159,20 @@ public final class SponsoredHotel nativeRequestDescription(id, locale); } + static void requestFacilities(String id, String locale) + { + List facilities = sFacilitiesCache.get(id); + if (facilities != null) { + OnFacilitiesReceivedListener listener = sFacilityListener.get(); + if (listener == null) + sDescriptionListener = null; + else + listener.onFacilitiesReceived(id, facilities); + } + + nativeRequestFacilities(id, locale); + } + @SuppressWarnings("unused") private static void onPriceReceived(String id, String price, String currency) { @@ -146,8 +203,29 @@ public final class SponsoredHotel listener.onDescriptionReceived(id, description); } + @SuppressWarnings("unused") + private static void onFacilitiesReceived(String id, int[] ids, String[] names) + { + if (ids.length == 0) + return; + + List result = new ArrayList<>(); + for (int i = 0; i < ids.length; i++) { + result.add(new FacilityType(mapFacilityId(ids[i]), names[i])); + } + + sFacilitiesCache.put(id, result); + + OnFacilitiesReceivedListener listener = sFacilityListener.get(); + if (listener == null) + sDescriptionListener = null; + else + listener.onFacilitiesReceived(id, result); + } + @Nullable public static native SponsoredHotel nativeGetCurrent(); private static native void nativeRequestPrice(String id, String currencyCode); private static native void nativeRequestDescription(String id, String locale); + private static native void nativeRequestFacilities(String id, String locale); } diff --git a/map/booking_api.cpp b/map/booking_api.cpp index 1e3aef6e73..95bad8fe36 100644 --- a/map/booking_api.cpp +++ b/map/booking_api.cpp @@ -90,7 +90,7 @@ void BookingApi::GetMinPrice(string const & hotelId, string const & currency, } catch (my::Json::Exception const & e) { - LOG(LERROR, (e.Msg())); +// LOG(LERROR, (e.Msg())); minPrice.clear(); priceCurrency.clear(); } From 10a5e9620d22d2a0ce398607abdb77875405d818 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Wed, 14 Sep 2016 12:40:37 +0400 Subject: [PATCH 03/26] [android] place page hotel gallery --- android/build.gradle | 2 + .../com/mapswithme/maps/SponsoredHotel.cpp | 22 +++ android/res/drawable/divider_transparent.xml | 6 + .../res/drawable/ic_chevron_right_white.xml | 9 + android/res/layout/item_gallery.xml | 23 +++ android/res/layout/place_page_details.xml | 6 +- .../layout/place_page_hotel_description.xml | 15 +- .../layout/place_page_hotel_facilities.xml | 15 +- .../res/layout/place_page_hotel_gallery.xml | 17 ++ android/res/values/dimens.xml | 4 +- android/res/values/styles-place_page.xml | 11 ++ .../maps/widget/placepage/GalleryAdapter.java | 169 ++++++++++++++++++ .../maps/widget/placepage/PlacePageView.java | 50 +++++- .../maps/widget/placepage/SponsoredHotel.java | 64 ++++++- .../recycler/DividerItemDecoration.java | 124 +++++++++++++ 15 files changed, 524 insertions(+), 13 deletions(-) create mode 100644 android/res/drawable/divider_transparent.xml create mode 100644 android/res/drawable/ic_chevron_right_white.xml create mode 100644 android/res/layout/item_gallery.xml create mode 100644 android/res/layout/place_page_hotel_gallery.xml create mode 100644 android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java create mode 100644 android/src/com/mapswithme/maps/widget/recycler/DividerItemDecoration.java diff --git a/android/build.gradle b/android/build.gradle index 23d3f503c9..ad41954325 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -57,6 +57,8 @@ dependencies { // TODO remove this library when default LinearLayoutManager will be fixed. compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar' compile 'com.timehop.stickyheadersrecyclerview:library:0.4.3@aar' + //Glide + compile 'com.github.bumptech.glide:glide:3.7.0' } def getDate() { diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp index 4c01673361..c297e13f45 100644 --- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp +++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp @@ -14,6 +14,7 @@ jmethodID g_hotelClassCtor; jmethodID g_priceCallback; jmethodID g_descriptionCallback; jmethodID g_facilitiesCallback; +jmethodID g_imagesCallback; void PrepareClassRefs(JNIEnv * env, jclass hotelClass) { @@ -30,6 +31,8 @@ void PrepareClassRefs(JNIEnv * env, jclass hotelClass) g_descriptionCallback = jni::GetStaticMethodID(env, g_hotelClass, "onDescriptionReceived", "(Ljava/lang/String;Ljava/lang/String;)V"); // static void onFacilitiesReceived(final String id, int[] ids, String[] names) g_facilitiesCallback = jni::GetStaticMethodID(env, g_hotelClass, "onFacilitiesReceived", "(Ljava/lang/String;[I[Ljava/lang/String;)V"); + // static void onImagesReceived(final String id, String[] urls) + g_imagesCallback = jni::GetStaticMethodID(env, g_hotelClass, "onImagesReceived", "(Ljava/lang/String;[Ljava/lang/String;)V"); } } // namespace @@ -108,4 +111,23 @@ Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestFacilities jni::ToJavaStringArray(env, {"Bar", "Terrace", "Fitness Center", "Pets are allowed on request", "Restaurant", "Private parking", "Ghost Busters"})); } +// static void nativeRequestImages(String id, String locale); +JNIEXPORT void JNICALL +Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestImages(JNIEnv * env, jclass clazz, jstring id, jstring locale) +{ + PrepareClassRefs(env, clazz); + + string const hotelId = jni::ToNativeString(env, id); + string const localeCode = jni::ToNativeString(env, locale); + + //TODO make request + env->CallStaticVoidMethod(g_hotelClass, g_imagesCallback, jni::ToJavaString(env, hotelId), + jni::ToJavaStringArray(env, {"http://www.libertyhotelslara.com/dosyalar/resimler/liberty-lara-hotel1.jpg", + "https://www.omnihotels.com/-/media/images/hotels/ausctr/pool/ausctr-omni-austin-hotel-downtown-evening-pool.jpg?h=660&la=en&w=1170", + "http://www.thefloridahotelorlando.com/var/floridahotelorlando/storage/images/media/images/photo-gallery/hotel-images/florida-hotel-orlando-night/27177-1-eng-US/Florida-Hotel-Orlando-Night.jpg", + "http://www.college-hotel.com/client/cache/contenu/_500____college-hotelp1diapo1_718.jpg", + "http://top10hotelbookingsites.webs.com/besthotelsites-1.jpg", + "http://www.litorehotel.com/web/en/images/placeholders/1920x1200-0.jpg"})); +} + } // extern "C" diff --git a/android/res/drawable/divider_transparent.xml b/android/res/drawable/divider_transparent.xml new file mode 100644 index 0000000000..1719475d7f --- /dev/null +++ b/android/res/drawable/divider_transparent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/android/res/drawable/ic_chevron_right_white.xml b/android/res/drawable/ic_chevron_right_white.xml new file mode 100644 index 0000000000..490d31b048 --- /dev/null +++ b/android/res/drawable/ic_chevron_right_white.xml @@ -0,0 +1,9 @@ + + + diff --git a/android/res/layout/item_gallery.xml b/android/res/layout/item_gallery.xml new file mode 100644 index 0000000000..3770701e5a --- /dev/null +++ b/android/res/layout/item_gallery.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file diff --git a/android/res/layout/place_page_details.xml b/android/res/layout/place_page_details.xml index 79e4267d64..155a206bc0 100644 --- a/android/res/layout/place_page_details.xml +++ b/android/res/layout/place_page_details.xml @@ -27,14 +27,12 @@ android:layout_marginBottom="@dimen/margin_half" tools:visibility="gone"/> + + - - - - diff --git a/android/res/layout/place_page_hotel_description.xml b/android/res/layout/place_page_hotel_description.xml index a2913ce02e..db3e442da1 100644 --- a/android/res/layout/place_page_hotel_description.xml +++ b/android/res/layout/place_page_hotel_description.xml @@ -2,12 +2,18 @@ @@ -15,7 +21,10 @@ android:id="@+id/tv__place_hotel_details" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base" android:layout_marginTop="@dimen/margin_half_plus" + android:layout_marginBottom="@dimen/margin_half_plus" android:textAppearance="@style/MwmTextAppearance.Body3.Primary" android:maxLines="5" tools:text="One of our top picks in New York City. This boutique hotel in the Manhattan neighborhood of Nolita features a private rooftop and rooms with free WiFi. The Bowery subway station is 1 block from this New York hotel."/> @@ -23,8 +32,12 @@ + + \ No newline at end of file diff --git a/android/res/layout/place_page_hotel_facilities.xml b/android/res/layout/place_page_hotel_facilities.xml index 7a450f4de3..a8bab592f9 100644 --- a/android/res/layout/place_page_hotel_facilities.xml +++ b/android/res/layout/place_page_hotel_facilities.xml @@ -2,12 +2,18 @@ @@ -15,15 +21,22 @@ android:id="@+id/gv__place_hotel_facilities" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base" android:layout_marginTop="@dimen/margin_base" + android:layout_marginBottom="@dimen/margin_base" android:numColumns="2" tools:listitem="@layout/item_facility"/> + + \ No newline at end of file diff --git a/android/res/layout/place_page_hotel_gallery.xml b/android/res/layout/place_page_hotel_gallery.xml new file mode 100644 index 0000000000..11b81db657 --- /dev/null +++ b/android/res/layout/place_page_hotel_gallery.xml @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/android/res/values/dimens.xml b/android/res/values/dimens.xml index 3639d21f51..ec5a07ae97 100644 --- a/android/res/values/dimens.xml +++ b/android/res/values/dimens.xml @@ -144,6 +144,8 @@ 40dp 232dp - + + 100dp + 150dp diff --git a/android/res/values/styles-place_page.xml b/android/res/values/styles-place_page.xml index de018232d0..013abc689f 100644 --- a/android/res/values/styles-place_page.xml +++ b/android/res/values/styles-place_page.xml @@ -65,6 +65,17 @@ @style/MwmTextAppearance.PlacePage.Title + + + + + + + + \ No newline at end of file diff --git a/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java new file mode 100644 index 0000000000..7bc449ac7d --- /dev/null +++ b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java @@ -0,0 +1,163 @@ +package com.mapswithme.maps.gallery; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.target.BitmapImageViewTarget; +import com.mapswithme.maps.R; +import com.mapswithme.maps.base.BaseMwmFragmentActivity; +import com.mapswithme.util.ThemeUtils; +import com.mapswithme.util.UiUtils; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Bitmap; +import android.os.Build; +import android.os.Bundle; +import android.support.v4.graphics.drawable.RoundedBitmapDrawable; +import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory; +import android.support.v4.view.ViewPager; +import android.support.v7.widget.Toolbar; +import android.text.TextUtils; +import android.text.format.DateFormat; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class FullScreenGalleryActivity extends BaseMwmFragmentActivity + implements ViewPager.OnPageChangeListener { + public static final String EXTRA_IMAGES = "gallery_images"; + public static final String EXTRA_POSITION = "gallery_position"; + + private List mImages; + private int mPosition; + private View mUserBlock; + private TextView mDescription; + private TextView mUserName; + private TextView mSource; + private TextView mDate; + private ImageView mAvatar; + + private GalleryPageAdapter mGalleryPageAdapter; + + public static void start(Context context, ArrayList images, int position) + { + final Intent i = new Intent(context, FullScreenGalleryActivity.class); + i.putParcelableArrayListExtra(EXTRA_IMAGES, images); + i.putExtra(EXTRA_POSITION, position); + context.startActivity(i); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + requestWindowFeature(Window.FEATURE_NO_TITLE); + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); + + super.onCreate(savedInstanceState); + Toolbar toolbar = getToolbar(); + toolbar.setTitle(""); + UiUtils.showHomeUpButton(toolbar); + displayToolbarAsActionBar(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + } + + mUserBlock = findViewById(R.id.rl__user_block); + mDescription = (TextView) findViewById(R.id.tv__description); + mUserName = (TextView) findViewById(R.id.tv__name); + mSource = (TextView) findViewById(R.id.tv__source); + mDate = (TextView) findViewById(R.id.tv__date); + mAvatar = (ImageView) findViewById(R.id.iv__avatar); + + readParameters(); + mGalleryPageAdapter = new GalleryPageAdapter(getSupportFragmentManager(), mImages); + ViewPager viewPager = (ViewPager) findViewById(R.id.vp__image); + viewPager.setAdapter(mGalleryPageAdapter); + viewPager.addOnPageChangeListener(this); + viewPager.setCurrentItem(mPosition); + } + + @Override + public int getThemeResourceId(String theme) + { + if (ThemeUtils.isDefaultTheme(theme)) + return R.style.MwmTheme_FullScreenGalleryActivity; + + if (ThemeUtils.isNightTheme(theme)) + return R.style.MwmTheme_Night_FullScreenGalleryActivity; + + throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme); + } + + + @Override + protected int getContentLayoutResId() { + return R.layout.activity_viewpager_transparent_toolbar; + } + + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + + } + + @Override + public void onPageSelected(int position) { + updateInformation(mGalleryPageAdapter.getImage(position)); + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + + private void readParameters() { + Bundle extras = getIntent().getExtras(); + if (extras != null) { + mImages = extras.getParcelableArrayList(EXTRA_IMAGES); + mPosition = extras.getInt(EXTRA_POSITION); + } + } + + private void updateInformation(Image image) { + UiUtils.setTextAndHideIfEmpty(mDescription, image.getDescription()); + UiUtils.setTextAndHideIfEmpty(mUserName, image.getUserName()); + UiUtils.setTextAndHideIfEmpty(mSource, image.getSource()); + if (image.getDate() != null) { + Date date = new Date(image.getDate()); + mDate.setText(DateFormat.getMediumDateFormat(this).format(date)); + UiUtils.show(mDate); + } else { + UiUtils.hide(mDate); + } + if (!TextUtils.isEmpty(image.getUserAvatar())) { + UiUtils.show(mAvatar); + Glide.with(this) + .load(image.getUserAvatar()) + .asBitmap() + .centerCrop() + .into(new BitmapImageViewTarget(mAvatar) { + @Override + protected void setResource(Bitmap resource) { + RoundedBitmapDrawable circularBitmapDrawable = + RoundedBitmapDrawableFactory.create(getResources(), resource); + circularBitmapDrawable.setCircular(true); + mAvatar.setImageDrawable(circularBitmapDrawable); + } + }); + } else { + UiUtils.hide(mAvatar); + } + if (UiUtils.isHidden(mUserName) + && UiUtils.isHidden(mSource) + && UiUtils.isHidden(mDate) + && UiUtils.isHidden(mAvatar)) { + UiUtils.hide(mUserBlock); + } else { + UiUtils.show(mUserBlock); + } + } +} diff --git a/android/src/com/mapswithme/maps/gallery/FullScreenGalleryFragment.java b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryFragment.java new file mode 100644 index 0000000000..15c2a3b8b3 --- /dev/null +++ b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryFragment.java @@ -0,0 +1,45 @@ +package com.mapswithme.maps.gallery; + +import com.bumptech.glide.Glide; +import com.mapswithme.maps.R; +import com.mapswithme.maps.base.BaseMwmFragment; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +public class FullScreenGalleryFragment extends BaseMwmFragment { + static final String ARGUMENT_IMAGE = "argument_image"; + + private Image mImage; + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_fullscreen_image, container, false); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + readArguments(); + + if (mImage != null) { + ImageView imageView = (ImageView) view.findViewById(R.id.iv__image); + Glide.with(view.getContext()) + .load(mImage.getUrl()) + .into(imageView); + } + } + + private void readArguments() { + Bundle args = getArguments(); + if (args != null) { + mImage = args.getParcelable(ARGUMENT_IMAGE); + } + } +} diff --git a/android/src/com/mapswithme/maps/gallery/GalleryFragment.java b/android/src/com/mapswithme/maps/gallery/GalleryFragment.java index b3bd734071..9be54ce3dc 100644 --- a/android/src/com/mapswithme/maps/gallery/GalleryFragment.java +++ b/android/src/com/mapswithme/maps/gallery/GalleryFragment.java @@ -51,6 +51,6 @@ public class GalleryFragment extends BaseMwmFragment implements RecyclerClickLis @Override public void onItemClick(View v, int position) { -// TODO show full screen image activity + FullScreenGalleryActivity.start(getContext(), mImages, position); } } diff --git a/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java b/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java new file mode 100644 index 0000000000..bd168af410 --- /dev/null +++ b/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java @@ -0,0 +1,36 @@ +package com.mapswithme.maps.gallery; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentStatePagerAdapter; + +import java.util.List; + +public class GalleryPageAdapter extends FragmentStatePagerAdapter { + + private final List mImages; + + public GalleryPageAdapter(FragmentManager fm, List images) { + super(fm); + mImages = images; + } + + @Override + public Fragment getItem(int position) { + Bundle args = new Bundle(); + args.putParcelable(FullScreenGalleryFragment.ARGUMENT_IMAGE, mImages.get(position)); + FullScreenGalleryFragment fragment = new FullScreenGalleryFragment(); + fragment.setArguments(args); + return fragment; + } + + @Override + public int getCount() { + return mImages.size(); + } + + public Image getImage(int position) { + return mImages.get(position); + } +} diff --git a/android/src/com/mapswithme/maps/gallery/Image.java b/android/src/com/mapswithme/maps/gallery/Image.java index c9be0b2fcb..fd8d85776c 100644 --- a/android/src/com/mapswithme/maps/gallery/Image.java +++ b/android/src/com/mapswithme/maps/gallery/Image.java @@ -5,6 +5,11 @@ import android.os.Parcelable; public class Image implements Parcelable { private final String url; + private String description; + private String userName; + private String userAvatar; + private String source; + private Long date; public Image(String url) { this.url = url; @@ -12,11 +17,21 @@ public class Image implements Parcelable { protected Image(Parcel in) { url = in.readString(); + description = in.readString(); + userName = in.readString(); + userAvatar = in.readString(); + source = in.readString(); + date = (Long) in.readValue(Long.class.getClassLoader()); } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(url); + dest.writeString(description); + dest.writeString(userName); + dest.writeString(userAvatar); + dest.writeString(source); + dest.writeValue(date); } @Override @@ -39,4 +54,44 @@ public class Image implements Parcelable { public String getUrl() { return url; } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserAvatar() { + return userAvatar; + } + + public void setUserAvatar(String userAvatar) { + this.userAvatar = userAvatar; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public Long getDate() { + return date; + } + + public void setDate(Long date) { + this.date = date; + } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java index e556ec54c1..64f7f9c936 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java +++ b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java @@ -259,7 +259,13 @@ public final class SponsoredHotel ArrayList result = new ArrayList<>(); for (String url: urls) { - result.add(new Image(url)); + Image image = new Image(url); + image.setDescription("Staff, rooftop view, location, free bike…"); + image.setDate(System.currentTimeMillis()); + image.setSource("via Booking"); + image.setUserAvatar("http://www.interdating-ukrainian-women.com/wp-content/uploads/2013/06/avatar.jpg"); + image.setUserName("Polina"); + result.add(image); } sImagesCache.put(id, result); From bdba8ffd727adbc1ef6ddb9390509e6bbb6d70ef Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Fri, 16 Sep 2016 11:34:34 +0400 Subject: [PATCH 07/26] [android] added hotel nearby objects block --- .../com/mapswithme/maps/SponsoredHotel.cpp | 15 +++ android/res/layout/item_nearby.xml | 62 ++++++++++ android/res/layout/place_page_details.xml | 2 + .../res/layout/place_page_hotel_nearby.xml | 32 +++++ android/res/values/dimens.xml | 4 + android/res/values/strings.xml | 1 + .../maps/widget/placepage/NearbyAdapter.java | 113 ++++++++++++++++++ .../maps/widget/placepage/PlacePageView.java | 34 +++++- .../maps/widget/placepage/SponsoredHotel.java | 77 ++++++++++++ 9 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 android/res/layout/item_nearby.xml create mode 100644 android/res/layout/place_page_hotel_nearby.xml create mode 100644 android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp index c297e13f45..ab264187c7 100644 --- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp +++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp @@ -15,6 +15,7 @@ jmethodID g_priceCallback; jmethodID g_descriptionCallback; jmethodID g_facilitiesCallback; jmethodID g_imagesCallback; +jmethodID g_nearbyCallback; void PrepareClassRefs(JNIEnv * env, jclass hotelClass) { @@ -33,6 +34,8 @@ void PrepareClassRefs(JNIEnv * env, jclass hotelClass) g_facilitiesCallback = jni::GetStaticMethodID(env, g_hotelClass, "onFacilitiesReceived", "(Ljava/lang/String;[I[Ljava/lang/String;)V"); // static void onImagesReceived(final String id, String[] urls) g_imagesCallback = jni::GetStaticMethodID(env, g_hotelClass, "onImagesReceived", "(Ljava/lang/String;[Ljava/lang/String;)V"); + // static void onNearbyReceived(final String id) + g_nearbyCallback = jni::GetStaticMethodID(env, g_hotelClass, "onNearbyReceived", "(Ljava/lang/String;)V"); } } // namespace @@ -130,4 +133,16 @@ Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestImages(JNI "http://www.litorehotel.com/web/en/images/placeholders/1920x1200-0.jpg"})); } +// static void nativeRequestNearby(String id, double lat, double lon); +JNIEXPORT void JNICALL +Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestNearby(JNIEnv * env, jclass clazz, jstring id, jdouble lat, jdouble lon) +{ + PrepareClassRefs(env, clazz); + + string const hotelId = jni::ToNativeString(env, id); + + //TODO make request + env->CallStaticVoidMethod(g_hotelClass, g_nearbyCallback, jni::ToJavaString(env, hotelId)); +} + } // extern "C" diff --git a/android/res/layout/item_nearby.xml b/android/res/layout/item_nearby.xml new file mode 100644 index 0000000000..99c55a5529 --- /dev/null +++ b/android/res/layout/item_nearby.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/res/layout/place_page_details.xml b/android/res/layout/place_page_details.xml index 155a206bc0..cff136e493 100644 --- a/android/res/layout/place_page_details.xml +++ b/android/res/layout/place_page_details.xml @@ -55,6 +55,8 @@ + + diff --git a/android/res/layout/place_page_hotel_nearby.xml b/android/res/layout/place_page_hotel_nearby.xml new file mode 100644 index 0000000000..9c27aaa5e5 --- /dev/null +++ b/android/res/layout/place_page_hotel_nearby.xml @@ -0,0 +1,32 @@ + + + + + + + + + \ No newline at end of file diff --git a/android/res/values/dimens.xml b/android/res/values/dimens.xml index ae3275e251..d9fad64f46 100644 --- a/android/res/values/dimens.xml +++ b/android/res/values/dimens.xml @@ -149,4 +149,8 @@ 150dp 84dp + + 64dp + 24dp + diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index 064aa3b800..f19f55527f 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -972,4 +972,5 @@ Save when booking hotels Search results for hotels now contain the price category.\nWe also added more than 110,000 hotels. Facilities + Nearby diff --git a/android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java new file mode 100644 index 0000000000..4086a2fabf --- /dev/null +++ b/android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java @@ -0,0 +1,113 @@ +package com.mapswithme.maps.widget.placepage; + +import com.mapswithme.maps.R; +import com.mapswithme.util.ThemeUtils; + +import android.content.res.Resources; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + +public class NearbyAdapter extends BaseAdapter { + + public NearbyAdapter(OnItemClickListener listener) { + mListener = listener; + } + + public interface OnItemClickListener { + void onItemClick(SponsoredHotel.NearbyObject item); + } + + private List items = new ArrayList<>(); + private final OnItemClickListener mListener; + + @Override + public int getCount() { + 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_nearby, parent, false); + holder = new ViewHolder(convertView, mListener); + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + holder.bind(items.get(position)); + + return convertView; + } + + public void setItems( + List items) { + this.items = items; + notifyDataSetChanged(); + } + + private static class ViewHolder implements View.OnClickListener { + final OnItemClickListener mListener; + ImageView mIcon; + TextView mTitle; + TextView mType; + TextView mDistance; + SponsoredHotel.NearbyObject mItem; + + public ViewHolder(View view, OnItemClickListener listener) { + mListener = listener; + mIcon = (ImageView) view.findViewById(R.id.iv__icon); + mTitle = (TextView) view.findViewById(R.id.tv__title); + mType = (TextView) view.findViewById(R.id.tv__type); + mDistance = (TextView) view.findViewById(R.id.tv__distance); + view.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + if (mListener != null) { + mListener.onItemClick(mItem); + } + } + + public void bind(SponsoredHotel.NearbyObject item) { + mItem = item; + String packageName = mType.getContext().getPackageName(); + final boolean isNightTheme = ThemeUtils.isNightTheme(); + Resources resources = mType.getResources(); + int categoryRes = resources.getIdentifier(item.getCategory(), "string", packageName); + if (categoryRes == 0) + throw new IllegalStateException("Can't get string resource id for category:" + item.getCategory()); + + String iconId = "ic_category_" + item.getCategory(); + if (isNightTheme) + iconId = iconId + "_night"; + int iconRes = resources.getIdentifier(iconId, "drawable", packageName); + if (iconRes == 0) + throw new IllegalStateException("Can't get icon resource id:" + iconId); + mIcon.setImageResource(iconRes); + mTitle.setText(item.getTitle()); + mType.setText(categoryRes); + mDistance.setText(item.getDistance()); + } + } +} diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 9c3ec9f0c3..8676ccf47b 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -1,5 +1,7 @@ package com.mapswithme.maps.widget.placepage; +import com.google.android.gms.maps.model.LatLng; + import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; @@ -91,7 +93,9 @@ public class PlacePageView extends RelativeLayout LineCountTextView.OnLineCountCalculatedListener, SponsoredHotel.OnFacilitiesReceivedListener, SponsoredHotel.OnImagesReceivedListener, - RecyclerClickListener { + RecyclerClickListener, + SponsoredHotel.OnNearbyReceivedListener, + NearbyAdapter.OnItemClickListener { private static final String PREF_USE_DMS = "use_dms"; private boolean mIsDocked; @@ -147,6 +151,7 @@ public class PlacePageView extends RelativeLayout private View mHotelMoreFacilities; private View mHotelGallery; private RecyclerView mRvHotelGallery; + private View mHotelNearby; // Animations private BaseShadowController mShadowController; @@ -159,6 +164,7 @@ public class PlacePageView extends RelativeLayout private boolean mIsLatLonDms; private FacilitiesAdapter mFacilitiesAdapter = new FacilitiesAdapter(); private GalleryAdapter mGalleryAdapter; + private NearbyAdapter mNearbyAdapter = new NearbyAdapter(this); // Downloader`s stuff private DownloaderStatusIcon mDownloaderIcon; @@ -317,6 +323,9 @@ public class PlacePageView extends RelativeLayout mGalleryAdapter = new GalleryAdapter(getContext()); mGalleryAdapter.setListener(this); mRvHotelGallery.setAdapter(mGalleryAdapter); + mHotelNearby = findViewById(R.id.ll__place_hotel_nearby); + GridView gvHotelNearby = (GridView) findViewById(R.id.gv__place_hotel_nearby); + gvHotelNearby.setAdapter(mNearbyAdapter); mButtons = new PlacePageButtons(this, ppButtons, new PlacePageButtons.ItemListener() { @@ -449,6 +458,7 @@ public class PlacePageView extends RelativeLayout SponsoredHotel.setDescriptionListener(this); SponsoredHotel.setFacilitiesListener(this); SponsoredHotel.setImagesListener(this); + SponsoredHotel.setNearbyListener(this); } @Override @@ -513,6 +523,20 @@ public class PlacePageView extends RelativeLayout mRvHotelGallery.scrollToPosition(0); } + @Override + public void onNearbyReceived(String id, ArrayList objects) { + if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) { + return; + } + + if (objects == null || objects.isEmpty()) { + UiUtils.hide(mHotelNearby); + return; + } + UiUtils.show(mHotelNearby); + mNearbyAdapter.setItems(objects); + } + @Override public void onLineCountCalculated(boolean grater) { mHotelMoreDescription.setVisibility(grater ? VISIBLE : GONE); @@ -523,6 +547,11 @@ public class PlacePageView extends RelativeLayout GalleryActivity.start(getContext(), mGalleryAdapter.getItems(), mMapObject.getTitle()); } + @Override + public void onItemClick(SponsoredHotel.NearbyObject item) { +// TODO go to selected object on map + } + private void onBookingClick(final boolean book) { // TODO (trashkalmar): Set correct text @@ -662,6 +691,8 @@ public class PlacePageView extends RelativeLayout SponsoredHotel.requestDescription(mSponsoredHotel.getId(), locale.toString()); SponsoredHotel.requestFacilities(mSponsoredHotel.getId(), locale.toString()); SponsoredHotel.requestImages(mSponsoredHotel.getId(), locale.toString()); + SponsoredHotel.requestNearby(mSponsoredHotel.getId(), new LatLng(mMapObject.getLat(), + mMapObject.getLon())); } String country = MapManager.nativeGetSelectedCountry(); @@ -764,6 +795,7 @@ public class PlacePageView extends RelativeLayout UiUtils.hide(mHotelDescription); UiUtils.hide(mHotelFacilities); UiUtils.hide(mHotelGallery); + UiUtils.hide(mHotelNearby); } else { UiUtils.hide(mWebsite); diff --git a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java index 64f7f9c936..e563d4ee18 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java +++ b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java @@ -1,5 +1,7 @@ package com.mapswithme.maps.widget.placepage; +import com.google.android.gms.maps.model.LatLng; + import android.support.annotation.Nullable; import android.support.annotation.DrawableRes; import android.support.annotation.UiThread; @@ -51,6 +53,36 @@ public final class SponsoredHotel } } + public static class NearbyObject { + private final String category; + private final String title; + private final String distance; + private final LatLng location; + + public NearbyObject(String category, String title, String distance, LatLng location) { + this.category = category; + this.title = title; + this.distance = distance; + this.location = location; + } + + public String getCategory() { + return category; + } + + public String getTitle() { + return title; + } + + public String getDistance() { + return distance; + } + + public LatLng getLocation() { + return location; + } + } + interface OnPriceReceivedListener { void onPriceReceived(String id, String price, String currency); @@ -71,6 +103,11 @@ public final class SponsoredHotel void onImagesReceived(String id, ArrayList images); } + interface OnNearbyReceivedListener + { + void onNearbyReceived(String id, ArrayList images); + } + // Hotel ID -> Price private static final Map sPriceCache = new HashMap<>(); // Hotel ID -> Description @@ -79,10 +116,13 @@ public final class SponsoredHotel private static final Map> sFacilitiesCache = new HashMap<>(); // Hotel ID -> Images private static final Map> sImagesCache = new HashMap<>(); + // Hotel ID -> Nearby + private static final Map> sNearbyCache = new HashMap<>(); private static WeakReference sPriceListener; private static WeakReference sDescriptionListener; private static WeakReference sFacilityListener; private static WeakReference sImagesListener; + private static WeakReference sNearbyListener; private String mId; @@ -149,6 +189,11 @@ public final class SponsoredHotel sImagesListener = new WeakReference<>(listener); } + public static void setNearbyListener(OnNearbyReceivedListener listener) + { + sNearbyListener = new WeakReference<>(listener); + } + @DrawableRes public static int mapFacilityId(int facilityId) { // TODO map facility id to drawable resource @@ -201,6 +246,20 @@ public final class SponsoredHotel nativeRequestImages(id, locale); } + static void requestNearby(String id, LatLng position) + { + ArrayList objects = sNearbyCache.get(id); + if (objects != null) { + OnNearbyReceivedListener listener = sNearbyListener.get(); + if (listener == null) + sNearbyListener = null; + else + listener.onNearbyReceived(id, objects); + } + + nativeRequestNearby(id, position.latitude, position.longitude); + } + @SuppressWarnings("unused") private static void onPriceReceived(String id, String price, String currency) { @@ -277,10 +336,28 @@ public final class SponsoredHotel listener.onImagesReceived(id, result); } + @SuppressWarnings("unused") + private static void onNearbyReceived(String id) + { + ArrayList result = new ArrayList<>(); + result.add(new NearbyObject("transport", "Bowery", "800 ft", new LatLng(0, 0))); + result.add(new NearbyObject("food", "Egg Shop", "300 ft", new LatLng(0, 0))); + result.add(new NearbyObject("shop", "Fay Yee Inc", "200 ft", new LatLng(0, 0))); + + sNearbyCache.put(id, result); + + OnNearbyReceivedListener listener = sNearbyListener.get(); + if (listener == null) + sNearbyListener = null; + else + listener.onNearbyReceived(id, result); + } + @Nullable public static native SponsoredHotel nativeGetCurrent(); private static native void nativeRequestPrice(String id, String currencyCode); private static native void nativeRequestDescription(String id, String locale); private static native void nativeRequestFacilities(String id, String locale); private static native void nativeRequestImages(String id, String locale); + private static native void nativeRequestNearby(String id, double lat, double lon); } From 97839cb0163f095bb004b13a3caf9786c385cb4f Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Fri, 16 Sep 2016 15:42:59 +0400 Subject: [PATCH 08/26] [android] added place page hotel rating layout --- android/res/layout/item_comment.xml | 33 ++++++++++++++ android/res/layout/item_nearby.xml | 4 ++ android/res/layout/place_page_details.xml | 2 + .../res/layout/place_page_hotel_nearby.xml | 5 +-- .../res/layout/place_page_hotel_rating.xml | 45 +++++++++++++++++++ android/res/values/colors.xml | 4 ++ android/res/values/dimens.xml | 3 ++ 7 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 android/res/layout/item_comment.xml create mode 100644 android/res/layout/place_page_hotel_rating.xml diff --git a/android/res/layout/item_comment.xml b/android/res/layout/item_comment.xml new file mode 100644 index 0000000000..1ad209b51c --- /dev/null +++ b/android/res/layout/item_comment.xml @@ -0,0 +1,33 @@ + + + + + + + \ No newline at end of file diff --git a/android/res/layout/item_nearby.xml b/android/res/layout/item_nearby.xml index 99c55a5529..4b5a28003a 100644 --- a/android/res/layout/item_nearby.xml +++ b/android/res/layout/item_nearby.xml @@ -5,6 +5,10 @@ xmlns:tools="http://schemas.android.com/tools" android:paddingTop="@dimen/margin_half_plus" android:paddingBottom="@dimen/margin_half_plus" + android:paddingRight="@dimen/margin_base" + android:paddingEnd="@dimen/margin_base" + android:paddingLeft="@dimen/margin_base" + android:paddingStart="@dimen/margin_base" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground" diff --git a/android/res/layout/place_page_details.xml b/android/res/layout/place_page_details.xml index cff136e493..cc0939dedf 100644 --- a/android/res/layout/place_page_details.xml +++ b/android/res/layout/place_page_details.xml @@ -57,6 +57,8 @@ + + diff --git a/android/res/layout/place_page_hotel_nearby.xml b/android/res/layout/place_page_hotel_nearby.xml index 9c27aaa5e5..13810b7db2 100644 --- a/android/res/layout/place_page_hotel_nearby.xml +++ b/android/res/layout/place_page_hotel_nearby.xml @@ -23,10 +23,7 @@ android:id="@+id/gv__place_hotel_nearby" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/margin_base" - android:layout_marginRight="@dimen/margin_base" - android:layout_marginTop="@dimen/margin_half" - android:layout_marginBottom="@dimen/margin_half" + android:layout_marginTop="@dimen/margin_quarter" android:numColumns="1" tools:listitem="@layout/item_nearby"/> \ 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 new file mode 100644 index 0000000000..c1de9a6be8 --- /dev/null +++ b/android/res/layout/place_page_hotel_rating.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/android/res/values/colors.xml b/android/res/values/colors.xml index 11ba6235ba..001d2328f7 100644 --- a/android/res/values/colors.xml +++ b/android/res/values/colors.xml @@ -34,6 +34,8 @@ #1EFFFFFF #66FFFFFF + #568B2E + #FFEEEEEE #FF32363A @@ -60,6 +62,8 @@ #1D414651 #FFFFFFFF + #F1F8E9 + @color/button_normal @color/button_normal_night diff --git a/android/res/values/dimens.xml b/android/res/values/dimens.xml index d9fad64f46..a7cdd8663d 100644 --- a/android/res/values/dimens.xml +++ b/android/res/values/dimens.xml @@ -153,4 +153,7 @@ 64dp 24dp + + 20dp + From 95bcc19681d70c0d152797ffc15705f30ddc7927 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Mon, 19 Sep 2016 10:01:59 +0400 Subject: [PATCH 09/26] [android] jni bindings for BookingApi::GetHotelInfo. Refactoring. --- android/jni/com/mapswithme/maps/Framework.cpp | 5 + android/jni/com/mapswithme/maps/Framework.hpp | 1 + .../com/mapswithme/maps/SponsoredHotel.cpp | 130 ++++---- .../gallery/FullScreenGalleryActivity.java | 12 +- .../com/mapswithme/maps/gallery/Image.java | 10 +- .../mapswithme/maps/gallery/ImageAdapter.java | 2 +- .../widget/placepage/FacilitiesAdapter.java | 3 +- .../maps/widget/placepage/GalleryAdapter.java | 2 +- .../maps/widget/placepage/PlacePageView.java | 59 +--- .../maps/widget/placepage/SponsoredHotel.java | 284 ++++++------------ 10 files changed, 200 insertions(+), 308 deletions(-) diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index bbd1d9e42c..67412a3c7c 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -476,6 +476,11 @@ void Framework::RequestBookingMinPrice(string const & hotelId, string const & cu return m_work.GetBookingApi().GetMinPrice(hotelId, currencyCode, callback); } +void Framework::RequestBookingInfo(string const & hotelId, string const & lang, function const & callback) +{ + return m_work.GetBookingApi().GetHotelInfo(hotelId, lang, callback); +} + bool Framework::HasSpaceForMigration() { return m_work.IsEnoughSpaceForMigrate(); diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index 2937dbb7bc..b7962696c7 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -155,6 +155,7 @@ namespace android void SetPlacePageInfo(place_page::Info const & info); place_page::Info & GetPlacePageInfo(); void RequestBookingMinPrice(string const & hotelId, string const & currency, function const & callback); + void RequestBookingInfo(string const & hotelId, string const & lang, function const & callback); bool HasSpaceForMigration(); storage::TCountryId PreMigrate(ms::LatLon const & position, storage::Storage::TChangeCountryFunction const & statusChangeListener, diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp index ab264187c7..61c27dc012 100644 --- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp +++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp @@ -3,6 +3,7 @@ #include "../core/jni_helper.hpp" #include "../platform/Platform.hpp" #include "map/place_page_info.hpp" +#include "map/booking_api.hpp" #include "std/bind.hpp" @@ -10,12 +11,19 @@ namespace { jclass g_hotelClass; +jclass g_facilityTypeClass; +jclass g_nearbyObjectClass; +jclass g_imageClass; +jclass g_reviewClass; +jclass g_hotelInfoClass; +jmethodID g_facilityConstructor; +jmethodID g_nearbyConstructor; +jmethodID g_imageConstructor; +jmethodID g_reviewConstructor; +jmethodID g_hotelInfoConstructor; jmethodID g_hotelClassCtor; jmethodID g_priceCallback; -jmethodID g_descriptionCallback; -jmethodID g_facilitiesCallback; -jmethodID g_imagesCallback; -jmethodID g_nearbyCallback; +jmethodID g_infoCallback; void PrepareClassRefs(JNIEnv * env, jclass hotelClass) { @@ -23,19 +31,24 @@ void PrepareClassRefs(JNIEnv * env, jclass hotelClass) return; g_hotelClass = static_cast(env->NewGlobalRef(hotelClass)); + g_hotelInfoClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$HotelInfo"); + g_facilityTypeClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$FacilityType"); + g_nearbyObjectClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$NearbyObject"); + g_reviewClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$Review"); + g_imageClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/gallery/Image"); + + g_facilityConstructor = jni::GetConstructorID(env, g_facilityTypeClass, "(Ljava/lang/String;Ljava/lang/String;)V"); + g_nearbyConstructor = jni::GetConstructorID(env, g_nearbyObjectClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;DD)V"); + g_imageConstructor = jni::GetConstructorID(env, g_imageClass, "(Ljava/lang/String;Ljava/lang/String;)V"); + g_reviewConstructor = jni::GetConstructorID(env, g_reviewClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FJ)V"); + g_hotelInfoConstructor = jni::GetConstructorID(env, g_hotelInfoClass, "(Ljava/lang/String;[Lcom/mapswithme/maps/gallery/Image;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$FacilityType;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$Review;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$NearbyObject;)V"); // SponsoredHotel(String rating, String price, String urlBook, String urlDescription) g_hotelClassCtor = jni::GetConstructorID(env, g_hotelClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); // static void onPriceReceived(final String id, final String price, final String currency) g_priceCallback = jni::GetStaticMethodID(env, g_hotelClass, "onPriceReceived", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); // static void onDescriptionReceived(final String id, final String description) - g_descriptionCallback = jni::GetStaticMethodID(env, g_hotelClass, "onDescriptionReceived", "(Ljava/lang/String;Ljava/lang/String;)V"); - // static void onFacilitiesReceived(final String id, int[] ids, String[] names) - g_facilitiesCallback = jni::GetStaticMethodID(env, g_hotelClass, "onFacilitiesReceived", "(Ljava/lang/String;[I[Ljava/lang/String;)V"); - // static void onImagesReceived(final String id, String[] urls) - g_imagesCallback = jni::GetStaticMethodID(env, g_hotelClass, "onImagesReceived", "(Ljava/lang/String;[Ljava/lang/String;)V"); - // static void onNearbyReceived(final String id) - g_nearbyCallback = jni::GetStaticMethodID(env, g_hotelClass, "onNearbyReceived", "(Ljava/lang/String;)V"); + g_infoCallback = jni::GetStaticMethodID(env, g_hotelClass, "onInfoReceived", "(Ljava/lang/String;Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$HotelInfo;)V"); } } // namespace @@ -80,69 +93,52 @@ Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestPrice(JNIE }); } -// static void nativeRequestDescription(String id, String locale); +// static void nativeRequestInfo(String id, String locale); JNIEXPORT void JNICALL -Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestDescription(JNIEnv * env, jclass clazz, jstring id, jstring locale) +Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestInfo(JNIEnv * env, jclass clazz, jstring id, jstring locale) { PrepareClassRefs(env, clazz); string const hotelId = jni::ToNativeString(env, id); - string const localeCode = jni::ToNativeString(env, locale); + string const code = jni::ToNativeString(env, locale); - //TODO make request - //JNIEnv * env = jni::GetEnv(); - env->CallStaticVoidMethod(g_hotelClass, g_descriptionCallback, jni::ToJavaString(env, hotelId), - jni::ToJavaString(env, "One of our top picks in New York City. This boutique hotel in the Manhattan neighborhood of Nolita features a private rooftop and rooms with free WiFi. The Bowery subway station is 1 block from this New York hotel. One of our top picks in New York City. This boutique hotel in the Manhattan neighborhood of Nolita features a private rooftop and rooms with free WiFi. The Bowery subway station is 1 block from this New York hotel.")); -} + g_framework->RequestBookingInfo(hotelId, code, [hotelId](BookingApi::HotelInfo const & hotelInfo) + { + GetPlatform().RunOnGuiThread([=]() + { + JNIEnv * env = jni::GetEnv(); -// static void nativeRequestFacilities(String id, String locale); -JNIEXPORT void JNICALL -Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestFacilities(JNIEnv * env, jclass clazz, jstring id, jstring locale) -{ - PrepareClassRefs(env, clazz); - - string const hotelId = jni::ToNativeString(env, id); - string const localeCode = jni::ToNativeString(env, locale); - - //TODO make request - jintArray result; - result = env->NewIntArray(7); - jint fill[7]{0, 1, 2, 3, 4, 5, 6}; - env->SetIntArrayRegion(result, 0, 7, fill); - env->CallStaticVoidMethod(g_hotelClass, g_facilitiesCallback, jni::ToJavaString(env, hotelId), - result, - jni::ToJavaStringArray(env, {"Bar", "Terrace", "Fitness Center", "Pets are allowed on request", "Restaurant", "Private parking", "Ghost Busters"})); -} - -// static void nativeRequestImages(String id, String locale); -JNIEXPORT void JNICALL -Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestImages(JNIEnv * env, jclass clazz, jstring id, jstring locale) -{ - PrepareClassRefs(env, clazz); - - string const hotelId = jni::ToNativeString(env, id); - string const localeCode = jni::ToNativeString(env, locale); - - //TODO make request - env->CallStaticVoidMethod(g_hotelClass, g_imagesCallback, jni::ToJavaString(env, hotelId), - jni::ToJavaStringArray(env, {"http://www.libertyhotelslara.com/dosyalar/resimler/liberty-lara-hotel1.jpg", - "https://www.omnihotels.com/-/media/images/hotels/ausctr/pool/ausctr-omni-austin-hotel-downtown-evening-pool.jpg?h=660&la=en&w=1170", - "http://www.thefloridahotelorlando.com/var/floridahotelorlando/storage/images/media/images/photo-gallery/hotel-images/florida-hotel-orlando-night/27177-1-eng-US/Florida-Hotel-Orlando-Night.jpg", - "http://www.college-hotel.com/client/cache/contenu/_500____college-hotelp1diapo1_718.jpg", - "http://top10hotelbookingsites.webs.com/besthotelsites-1.jpg", - "http://www.litorehotel.com/web/en/images/placeholders/1920x1200-0.jpg"})); -} - -// static void nativeRequestNearby(String id, double lat, double lon); -JNIEXPORT void JNICALL -Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestNearby(JNIEnv * env, jclass clazz, jstring id, jdouble lat, jdouble lon) -{ - PrepareClassRefs(env, clazz); - - string const hotelId = jni::ToNativeString(env, id); - - //TODO make request - env->CallStaticVoidMethod(g_hotelClass, g_nearbyCallback, jni::ToJavaString(env, hotelId)); + env->CallStaticVoidMethod(g_hotelClass, g_infoCallback, jni::ToJavaString(env, hotelId), + env->NewObject(g_hotelInfoClass, g_hotelInfoConstructor, + jni::ToJavaString(env, hotelInfo.m_description), + jni::ToJavaArray(env, g_imageClass, hotelInfo.m_photos, + [](JNIEnv * env, BookingApi::HotelPhotoUrls const & item) + { + return env->NewObject(g_imageClass, g_imageConstructor, + jni::ToJavaString(env, item.m_original), + jni::ToJavaString(env, item.m_small)); + }), + jni::ToJavaArray(env, g_facilityTypeClass, hotelInfo.m_facilities, + [](JNIEnv * env, BookingApi::Facility const & item) + { + return env->NewObject(g_facilityTypeClass, g_facilityConstructor, + jni::ToJavaString(env, item.m_id), + jni::ToJavaString(env, item.m_localizedName)); + }), + jni::ToJavaArray(env, g_reviewClass, hotelInfo.m_reviews, + [](JNIEnv * env, BookingApi::HotelReview const & item) + { + return env->NewObject(g_reviewClass, g_reviewConstructor, + jni::ToJavaString(env, item.m_reviewPositive), + jni::ToJavaString(env, item.m_reviewNegative), + jni::ToJavaString(env, item.m_author), + jni::ToJavaString(env, item.m_authorPictUrl), + item.m_rating, + std::chrono::time_point_cast(item.m_date).time_since_epoch().count()); + }), + env->NewObjectArray(0, g_nearbyObjectClass, 0))); + }); + }); } } // extern "C" diff --git a/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java index 7bc449ac7d..592ba34c10 100644 --- a/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java +++ b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java @@ -75,10 +75,18 @@ public class FullScreenGalleryActivity extends BaseMwmFragmentActivity readParameters(); mGalleryPageAdapter = new GalleryPageAdapter(getSupportFragmentManager(), mImages); - ViewPager viewPager = (ViewPager) findViewById(R.id.vp__image); - viewPager.setAdapter(mGalleryPageAdapter); + final ViewPager viewPager = (ViewPager) findViewById(R.id.vp__image); viewPager.addOnPageChangeListener(this); + viewPager.setAdapter(mGalleryPageAdapter); viewPager.setCurrentItem(mPosition); + viewPager.post(new Runnable() + { + @Override + public void run() + { + onPageSelected(viewPager.getCurrentItem()); + } + }); } @Override diff --git a/android/src/com/mapswithme/maps/gallery/Image.java b/android/src/com/mapswithme/maps/gallery/Image.java index fd8d85776c..7a26b43918 100644 --- a/android/src/com/mapswithme/maps/gallery/Image.java +++ b/android/src/com/mapswithme/maps/gallery/Image.java @@ -5,18 +5,21 @@ import android.os.Parcelable; public class Image implements Parcelable { private final String url; + private final String smallUrl; private String description; private String userName; private String userAvatar; private String source; private Long date; - public Image(String url) { + public Image(String url, String smallUrl) { this.url = url; + this.smallUrl = smallUrl; } protected Image(Parcel in) { url = in.readString(); + smallUrl = in.readString(); description = in.readString(); userName = in.readString(); userAvatar = in.readString(); @@ -27,6 +30,7 @@ public class Image implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(url); + dest.writeString(smallUrl); dest.writeString(description); dest.writeString(userName); dest.writeString(userAvatar); @@ -55,6 +59,10 @@ public class Image implements Parcelable { return url; } + public String getSmallUrl() { + return smallUrl; + } + public String getDescription() { return description; } diff --git a/android/src/com/mapswithme/maps/gallery/ImageAdapter.java b/android/src/com/mapswithme/maps/gallery/ImageAdapter.java index b0bf080690..bead1e5def 100644 --- a/android/src/com/mapswithme/maps/gallery/ImageAdapter.java +++ b/android/src/com/mapswithme/maps/gallery/ImageAdapter.java @@ -62,7 +62,7 @@ public class ImageAdapter extends RecyclerView.Adapter public void bind(Image image, int position) { mPosition = position; Glide.with(mImage.getContext()) - .load(image.getUrl()) + .load(image.getSmallUrl()) .centerCrop() .into(mImage); } diff --git a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java index c5e0f2793c..98efd23bb6 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java @@ -74,7 +74,8 @@ public class FacilitiesAdapter extends BaseAdapter { } public void bind(SponsoredHotel.FacilityType facility) { - mIcon.setImageResource(facility.getIcon()); +// 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/GalleryAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java index 85cb85e83c..197c355130 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java @@ -93,7 +93,7 @@ public class GalleryAdapter extends RecyclerView.Adapter(mImageWidth, mImageHeight) { diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 8676ccf47b..01542bc507 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -1,7 +1,5 @@ package com.mapswithme.maps.widget.placepage; -import com.google.android.gms.maps.model.LatLng; - import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; @@ -39,6 +37,7 @@ import android.widget.TextView; import java.text.NumberFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Calendar; import java.util.Currency; import java.util.HashMap; @@ -64,7 +63,6 @@ import com.mapswithme.maps.editor.OpeningHours; import com.mapswithme.maps.editor.data.TimeFormatUtils; import com.mapswithme.maps.editor.data.Timetable; import com.mapswithme.maps.gallery.GalleryActivity; -import com.mapswithme.maps.gallery.Image; import com.mapswithme.maps.location.LocationHelper; import com.mapswithme.maps.routing.RoutingController; import com.mapswithme.maps.widget.ArrowView; @@ -89,12 +87,9 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListener, View.OnLongClickListener, SponsoredHotel.OnPriceReceivedListener, - SponsoredHotel.OnDescriptionReceivedListener, + SponsoredHotel.OnInfoReceivedListener, LineCountTextView.OnLineCountCalculatedListener, - SponsoredHotel.OnFacilitiesReceivedListener, - SponsoredHotel.OnImagesReceivedListener, RecyclerClickListener, - SponsoredHotel.OnNearbyReceivedListener, NearbyAdapter.OnItemClickListener { private static final String PREF_USE_DMS = "use_dms"; @@ -455,10 +450,7 @@ public class PlacePageView extends RelativeLayout mDetails.setBackgroundResource(0); SponsoredHotel.setPriceListener(this); - SponsoredHotel.setDescriptionListener(this); - SponsoredHotel.setFacilitiesListener(this); - SponsoredHotel.setImagesListener(this); - SponsoredHotel.setNearbyListener(this); + SponsoredHotel.setInfoListener(this); } @Override @@ -482,59 +474,38 @@ public class PlacePageView extends RelativeLayout } @Override - public void onDescriptionReceived(String id, String description) { + public void onInfoReceived(String id, SponsoredHotel.HotelInfo info) { if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) { return; } mTvHotelDescription.setMaxLines(5); - refreshMetadataOrHide(description, mHotelDescription, mTvHotelDescription); + refreshMetadataOrHide(info.description, mHotelDescription, mTvHotelDescription); mHotelMoreDescription.setVisibility(GONE); - } - @Override - public void onFacilitiesReceived(String id, List facilities) { - if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) { - return; - } - - if (facilities == null || facilities.isEmpty()) { + if (info.facilities == null || info.facilities.length == 0) { UiUtils.hide(mHotelFacilities); return; } UiUtils.show(mHotelFacilities); mFacilitiesAdapter.setShowAll(false); - mFacilitiesAdapter.setItems(facilities); - mHotelMoreFacilities.setVisibility(facilities.size() > 6 ? VISIBLE : GONE); - } + mFacilitiesAdapter.setItems(Arrays.asList(info.facilities)); + mHotelMoreFacilities.setVisibility(info.facilities.length > 6 ? VISIBLE : GONE); - @Override - public void onImagesReceived(String id, ArrayList images) { - if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) { - return; - } - - if (images == null || images.isEmpty()) { + if (info.photos == null || info.photos.length == 0) { UiUtils.hide(mHotelGallery); return; } UiUtils.show(mHotelGallery); - mGalleryAdapter.setItems(images); + mGalleryAdapter.setItems(new ArrayList<>(Arrays.asList(info.photos))); mRvHotelGallery.scrollToPosition(0); - } - @Override - public void onNearbyReceived(String id, ArrayList objects) { - if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) { - return; - } - - if (objects == null || objects.isEmpty()) { + if (info.nearby == null || info.nearby.length == 0) { UiUtils.hide(mHotelNearby); return; } UiUtils.show(mHotelNearby); - mNearbyAdapter.setItems(objects); + mNearbyAdapter.setItems(Arrays.asList(info.nearby)); } @Override @@ -688,11 +659,7 @@ public class PlacePageView extends RelativeLayout Locale locale = Locale.getDefault(); Currency currency = Currency.getInstance(locale); SponsoredHotel.requestPrice(mSponsoredHotel.getId(), currency.getCurrencyCode()); - SponsoredHotel.requestDescription(mSponsoredHotel.getId(), locale.toString()); - SponsoredHotel.requestFacilities(mSponsoredHotel.getId(), locale.toString()); - SponsoredHotel.requestImages(mSponsoredHotel.getId(), locale.toString()); - SponsoredHotel.requestNearby(mSponsoredHotel.getId(), new LatLng(mMapObject.getLat(), - mMapObject.getLon())); + SponsoredHotel.requestInfo(mSponsoredHotel.getId(), locale.toString()); } String country = MapManager.nativeGetSelectedCountry(); diff --git a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java index e563d4ee18..1a622c586f 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java +++ b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java @@ -1,19 +1,13 @@ package com.mapswithme.maps.widget.placepage; -import com.google.android.gms.maps.model.LatLng; - import android.support.annotation.Nullable; -import android.support.annotation.DrawableRes; import android.support.annotation.UiThread; import android.text.TextUtils; import java.lang.ref.WeakReference; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; -import com.mapswithme.maps.R; import com.mapswithme.maps.bookmarks.data.MapObject; import com.mapswithme.maps.bookmarks.data.Metadata; import com.mapswithme.maps.gallery.Image; @@ -34,18 +28,16 @@ public final class SponsoredHotel } public static class FacilityType { - @DrawableRes - private final int icon; + private final String key; private final String name; - public FacilityType(@DrawableRes int icon, String name) { - this.icon = icon; + public FacilityType(String key, String name) { + this.key = key; this.name = name; } - @DrawableRes - public int getIcon() { - return icon; + public String getKey() { + return key; } public String getName() { @@ -57,13 +49,15 @@ public final class SponsoredHotel private final String category; private final String title; private final String distance; - private final LatLng location; + private final double latitude; + private final double longitude; - public NearbyObject(String category, String title, String distance, LatLng location) { + public NearbyObject(String category, String title, String distance, double lat, double lon) { this.category = category; this.title = title; this.distance = distance; - this.location = location; + this.latitude = lat; + this.longitude = lon; } public String getCategory() { @@ -78,8 +72,73 @@ public final class SponsoredHotel return distance; } - public LatLng getLocation() { - return location; + public double getLatitude() { + return latitude; + } + + public double getLongitude() { + return longitude; + } + } + + public static class Review { + private final String mReviewPositive; + private final String mReviewNegative; + private final String mAuthor; + private final String mAuthorAvatar; + private final float mRating; + private final long mDate; + + public Review(String reviewPositive, String reviewNegative, String author, String authorAvatar, + float rating, long date) { + mReviewPositive = reviewPositive; + mReviewNegative = reviewNegative; + mAuthor = author; + mAuthorAvatar = authorAvatar; + mRating = rating; + mDate = date; + } + + public String getReviewPositive() { + return mReviewPositive; + } + + public String getReviewNegative() { + return mReviewNegative; + } + + public String getAuthor() { + return mAuthor; + } + + public String getAuthorAvatar() { + return mAuthorAvatar; + } + + public float getRating() { + return mRating; + } + + public long getDate() { + return mDate; + } + } + + public static class HotelInfo { + final String description; + final Image[] photos; + final FacilityType[] facilities; + final Review[] reviews; + final NearbyObject[] nearby; + + public HotelInfo(String description, Image[] photos, + FacilityType[] facilities, Review[] reviews, + NearbyObject[] nearby) { + this.description = description; + this.photos = photos; + this.facilities = facilities; + this.reviews = reviews; + this.nearby = nearby; } } @@ -88,41 +147,17 @@ public final class SponsoredHotel void onPriceReceived(String id, String price, String currency); } - interface OnDescriptionReceivedListener + interface OnInfoReceivedListener { - void onDescriptionReceived(String id, String description); - } - - interface OnFacilitiesReceivedListener - { - void onFacilitiesReceived(String id, List facilities); - } - - interface OnImagesReceivedListener - { - void onImagesReceived(String id, ArrayList images); - } - - interface OnNearbyReceivedListener - { - void onNearbyReceived(String id, ArrayList images); + void onInfoReceived(String id, HotelInfo info); } // Hotel ID -> Price private static final Map sPriceCache = new HashMap<>(); // Hotel ID -> Description - private static final Map sDescriptionCache = new HashMap<>(); - // Hotel ID -> Facilities - private static final Map> sFacilitiesCache = new HashMap<>(); - // Hotel ID -> Images - private static final Map> sImagesCache = new HashMap<>(); - // Hotel ID -> Nearby - private static final Map> sNearbyCache = new HashMap<>(); + private static final Map sInfoCache = new HashMap<>(); private static WeakReference sPriceListener; - private static WeakReference sDescriptionListener; - private static WeakReference sFacilityListener; - private static WeakReference sImagesListener; - private static WeakReference sNearbyListener; + private static WeakReference sInfoListener; private String mId; @@ -174,30 +209,9 @@ public final class SponsoredHotel sPriceListener = new WeakReference<>(listener); } - public static void setDescriptionListener(OnDescriptionReceivedListener listener) + public static void setInfoListener(OnInfoReceivedListener listener) { - sDescriptionListener = new WeakReference<>(listener); - } - - public static void setFacilitiesListener(OnFacilitiesReceivedListener listener) - { - sFacilityListener = new WeakReference<>(listener); - } - - public static void setImagesListener(OnImagesReceivedListener listener) - { - sImagesListener = new WeakReference<>(listener); - } - - public static void setNearbyListener(OnNearbyReceivedListener listener) - { - sNearbyListener = new WeakReference<>(listener); - } - - @DrawableRes - public static int mapFacilityId(int facilityId) { -// TODO map facility id to drawable resource - return R.drawable.ic_entrance; + sInfoListener = new WeakReference<>(listener); } static void requestPrice(String id, String currencyCode) @@ -209,55 +223,13 @@ public final class SponsoredHotel nativeRequestPrice(id, currencyCode); } - static void requestDescription(String id, String locale) + static void requestInfo(String id, String locale) { - String description = sDescriptionCache.get(id); - if (description != null) - onDescriptionReceived(id, description); + HotelInfo info = sInfoCache.get(id); + if (info != null) + onInfoReceived(id, info); - nativeRequestDescription(id, locale); - } - - static void requestFacilities(String id, String locale) - { - List facilities = sFacilitiesCache.get(id); - if (facilities != null) { - OnFacilitiesReceivedListener listener = sFacilityListener.get(); - if (listener == null) - sFacilityListener = null; - else - listener.onFacilitiesReceived(id, facilities); - } - - nativeRequestFacilities(id, locale); - } - - static void requestImages(String id, String locale) - { - ArrayList images = sImagesCache.get(id); - if (images != null) { - OnImagesReceivedListener listener = sImagesListener.get(); - if (listener == null) - sImagesListener = null; - else - listener.onImagesReceived(id, images); - } - - nativeRequestImages(id, locale); - } - - static void requestNearby(String id, LatLng position) - { - ArrayList objects = sNearbyCache.get(id); - if (objects != null) { - OnNearbyReceivedListener listener = sNearbyListener.get(); - if (listener == null) - sNearbyListener = null; - else - listener.onNearbyReceived(id, objects); - } - - nativeRequestNearby(id, position.latitude, position.longitude); + nativeRequestInfo(id, locale); } @SuppressWarnings("unused") @@ -276,88 +248,22 @@ public final class SponsoredHotel } @SuppressWarnings("unused") - private static void onDescriptionReceived(String id, String description) + private static void onInfoReceived(String id, HotelInfo info) { - if (TextUtils.isEmpty(description)) + if (info == null) return; - sDescriptionCache.put(id, description); + sInfoCache.put(id, info); - OnDescriptionReceivedListener listener = sDescriptionListener.get(); + OnInfoReceivedListener listener = sInfoListener.get(); if (listener == null) - sDescriptionListener = null; + sInfoListener = null; else - listener.onDescriptionReceived(id, description); - } - - @SuppressWarnings("unused") - private static void onFacilitiesReceived(String id, int[] ids, String[] names) - { - if (ids.length == 0) - return; - - List result = new ArrayList<>(); - for (int i = 0; i < ids.length; i++) { - result.add(new FacilityType(mapFacilityId(ids[i]), names[i])); - } - - sFacilitiesCache.put(id, result); - - OnFacilitiesReceivedListener listener = sFacilityListener.get(); - if (listener == null) - sFacilityListener = null; - else - listener.onFacilitiesReceived(id, result); - } - - @SuppressWarnings("unused") - private static void onImagesReceived(String id, String[] urls) - { - if (urls.length == 0) - return; - - ArrayList result = new ArrayList<>(); - for (String url: urls) { - Image image = new Image(url); - image.setDescription("Staff, rooftop view, location, free bike…"); - image.setDate(System.currentTimeMillis()); - image.setSource("via Booking"); - image.setUserAvatar("http://www.interdating-ukrainian-women.com/wp-content/uploads/2013/06/avatar.jpg"); - image.setUserName("Polina"); - result.add(image); - } - - sImagesCache.put(id, result); - - OnImagesReceivedListener listener = sImagesListener.get(); - if (listener == null) - sImagesListener = null; - else - listener.onImagesReceived(id, result); - } - - @SuppressWarnings("unused") - private static void onNearbyReceived(String id) - { - ArrayList result = new ArrayList<>(); - result.add(new NearbyObject("transport", "Bowery", "800 ft", new LatLng(0, 0))); - result.add(new NearbyObject("food", "Egg Shop", "300 ft", new LatLng(0, 0))); - result.add(new NearbyObject("shop", "Fay Yee Inc", "200 ft", new LatLng(0, 0))); - - sNearbyCache.put(id, result); - - OnNearbyReceivedListener listener = sNearbyListener.get(); - if (listener == null) - sNearbyListener = null; - else - listener.onNearbyReceived(id, result); + listener.onInfoReceived(id, info); } @Nullable public static native SponsoredHotel nativeGetCurrent(); private static native void nativeRequestPrice(String id, String currencyCode); - private static native void nativeRequestDescription(String id, String locale); - private static native void nativeRequestFacilities(String id, String locale); - private static native void nativeRequestImages(String id, String locale); - private static native void nativeRequestNearby(String id, double lat, double lon); + private static native void nativeRequestInfo(String id, String locale); } From c7761277083408d712b59d8395bec00b3836c464 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Mon, 19 Sep 2016 13:53:47 +0400 Subject: [PATCH 10/26] [android] added place page reviews block --- android/res/drawable/bg_circle_green.xml | 7 ++ android/res/drawable/bg_circle_red.xml | 7 ++ android/res/drawable/ic_minus_red.xml | 4 + android/res/drawable/ic_negative_review.xml | 15 +++ android/res/drawable/ic_plus_green.xml | 4 + android/res/drawable/ic_positive_review.xml | 15 +++ android/res/layout/item_comment.xml | 79 ++++++++++++- .../res/layout/place_page_hotel_rating.xml | 13 ++- android/res/values/colors.xml | 2 + android/res/values/strings.xml | 10 ++ .../widget/placepage/FacilitiesAdapter.java | 6 +- .../maps/widget/placepage/PlacePageView.java | 57 +++++++--- .../maps/widget/placepage/ReviewAdapter.java | 106 ++++++++++++++++++ 13 files changed, 304 insertions(+), 21 deletions(-) create mode 100644 android/res/drawable/bg_circle_green.xml create mode 100644 android/res/drawable/bg_circle_red.xml create mode 100644 android/res/drawable/ic_minus_red.xml create mode 100644 android/res/drawable/ic_negative_review.xml create mode 100644 android/res/drawable/ic_plus_green.xml create mode 100644 android/res/drawable/ic_positive_review.xml create mode 100644 android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java 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 @@ + + + + + \ 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 @@ + + + + + \ 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 @@ + + + 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 @@ + + + + + \ 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 @@ + + + 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 @@ + + + + + \ 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 @@ + android:layout_height="wrap_content"> + + + + + + + + + + + + + + + + + \ 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 @@ + + \ 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 @@ #FFFFFFFF #F1F8E9 + #DCEDC8 + #FFCDD2 @color/button_normal 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 @@ min Description More + More Reviews Book Call Edit Bookmark @@ -973,4 +974,13 @@ Search results for hotels now contain the price category.\nWe also added more than 110,000 hotels. Facilities Nearby + + + Based on %1$d hotel reviews + Based on %1$d hotel reviews + Based on %1$d hotel reviews + Based on %1$d hotel reviews + Based on %1$d hotel reviews + Based on %1$d hotel reviews + 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 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 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 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 From 4571b089fc119bd28562ed15151ded4874884b48 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Mon, 19 Sep 2016 16:40:06 +0400 Subject: [PATCH 11/26] [android] added review activity --- android/AndroidManifest.xml | 9 ++ android/res/layout/fragment_review.xml | 39 +++++ android/res/layout/item_more_button.xml | 8 + .../res/layout/place_page_hotel_rating.xml | 8 +- .../maps/review/ReviewActivity.java | 64 ++++++++ .../mapswithme/maps/review/ReviewAdapter.java | 148 ++++++++++++++++++ .../maps/review/ReviewFragment.java | 70 +++++++++ .../maps/widget/placepage/PlacePageView.java | 13 +- .../maps/widget/placepage/ReviewAdapter.java | 9 +- .../maps/widget/placepage/SponsoredHotel.java | 40 ++++- 10 files changed, 395 insertions(+), 13 deletions(-) create mode 100644 android/res/layout/fragment_review.xml create mode 100644 android/res/layout/item_more_button.xml create mode 100644 android/src/com/mapswithme/maps/review/ReviewActivity.java create mode 100644 android/src/com/mapswithme/maps/review/ReviewAdapter.java create mode 100644 android/src/com/mapswithme/maps/review/ReviewFragment.java diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 92ed583af1..95c0151f2b 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -307,6 +307,15 @@ android:value="com.mapswithme.maps.MwmActivity"/> + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/res/layout/item_more_button.xml b/android/res/layout/item_more_button.xml new file mode 100644 index 0000000000..e4e113952d --- /dev/null +++ b/android/res/layout/item_more_button.xml @@ -0,0 +1,8 @@ + + \ 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 218e5b1ae0..2b47b9da2a 100644 --- a/android/res/layout/place_page_hotel_rating.xml +++ b/android/res/layout/place_page_hotel_rating.xml @@ -42,11 +42,15 @@ android:numColumns="1" tools:listitem="@layout/item_comment"/> + items, String title, + String rating, int ratingBase, String url) + { + final Intent i = new Intent(context, ReviewActivity.class); + i.putParcelableArrayListExtra(EXTRA_REVIEWS, items); + i.putExtra(EXTRA_TITLE, title); + i.putExtra(EXTRA_RATING, rating); + i.putExtra(EXTRA_RATING_BASE, ratingBase); + i.putExtra(EXTRA_RATING_URL, url); + context.startActivity(i); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + String title = ""; + Bundle bundle = getIntent().getExtras(); + if (bundle != null) { + title = bundle.getString(EXTRA_TITLE); + } + Toolbar toolbar = getToolbar(); + toolbar.setTitle(title); + UiUtils.showHomeUpButton(toolbar); + displayToolbarAsActionBar(); + } + + @Override + protected Class getFragmentClass() { + return ReviewFragment.class; + } + + @Override + protected int getContentLayoutResId() { + return R.layout.activity_fragment_and_toolbar; + } + + @Override + protected int getFragmentContentResId() { + return R.id.fragment_container; + } +} diff --git a/android/src/com/mapswithme/maps/review/ReviewAdapter.java b/android/src/com/mapswithme/maps/review/ReviewAdapter.java new file mode 100644 index 0000000000..f31940aae0 --- /dev/null +++ b/android/src/com/mapswithme/maps/review/ReviewAdapter.java @@ -0,0 +1,148 @@ +package com.mapswithme.maps.review; + +import com.mapswithme.maps.R; +import com.mapswithme.maps.widget.placepage.SponsoredHotel; +import com.mapswithme.maps.widget.recycler.RecyclerClickListener; +import com.mapswithme.util.UiUtils; + +import android.support.annotation.CallSuper; +import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; +import android.text.format.DateFormat; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.Date; +import java.util.Locale; + +public class ReviewAdapter extends RecyclerView.Adapter { + private static final int MAX_COUNT = 15; + private static final int VIEW_TYPE_REVIEW = 0; + private static final int VIEW_TYPE_MORE = 1; + + private final ArrayList mItems; + private final RecyclerClickListener mListener; + + public ReviewAdapter(ArrayList images, RecyclerClickListener listener) { + mItems = images; + mListener = listener; + } + + @Override + public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + if (viewType == VIEW_TYPE_REVIEW) { + return new ReviewHolder(LayoutInflater.from(parent.getContext()) + .inflate(R.layout.item_comment, parent, false), mListener); + } + + return new MoreHolder(LayoutInflater.from(parent.getContext()) + .inflate(R.layout.item_more_button, parent, false), mListener); + } + + @Override + public void onBindViewHolder(BaseViewHolder holder, int position) { + if (position < mItems.size()) { + holder.bind(mItems.get(position), position); + } else { + holder.bind(null, position); + } + } + + @Override + public int getItemCount() { + if (mItems == null) { + return 0; + } + if (mItems.size() > MAX_COUNT) { + return MAX_COUNT + 1; + } + return mItems.size() + 1; + } + + @Override + public int getItemViewType(int position) { + if (position == mItems.size()) { + return VIEW_TYPE_MORE; + } + + return VIEW_TYPE_REVIEW; + } + + static abstract class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + private final RecyclerClickListener mListener; + private int mPosition; + + public BaseViewHolder(View itemView, RecyclerClickListener listener) { + super(itemView); + mListener = listener; + } + + @Override + public void onClick(View v) { + if (mListener != null) { + mListener.onItemClick(v, mPosition); + } + } + + @CallSuper + public void bind(SponsoredHotel.Review item, int position) { + mPosition = position; + } + } + + static class ReviewHolder extends BaseViewHolder { + 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 ReviewHolder(View itemView, RecyclerClickListener listener) { + super(itemView, listener); + mDivider = itemView.findViewById(R.id.v__divider); + mUserName = (TextView) itemView.findViewById(R.id.tv__user_name); + mCommentDate = (TextView) itemView.findViewById(R.id.tv__comment_date); + mRating = (TextView) itemView.findViewById(R.id.tv__user_rating); + mPositiveReview = itemView.findViewById(R.id.ll__positive_review); + mTvPositiveReview = (TextView) itemView.findViewById(R.id.tv__positive_review); + mNegativeReview = itemView.findViewById(R.id.ll__negative_review); + mTvNegativeReview = (TextView) itemView.findViewById(R.id.tv__negative_review); + } + + @Override + public void bind(SponsoredHotel.Review item, int position) { + super.bind(item, position); + UiUtils.showIf(position > 0, 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()); + } + } + } + + static class MoreHolder extends BaseViewHolder { + + public MoreHolder(View itemView, RecyclerClickListener listener) { + super(itemView, listener); + itemView.setOnClickListener(this); + } + } +} diff --git a/android/src/com/mapswithme/maps/review/ReviewFragment.java b/android/src/com/mapswithme/maps/review/ReviewFragment.java new file mode 100644 index 0000000000..0a834c98fd --- /dev/null +++ b/android/src/com/mapswithme/maps/review/ReviewFragment.java @@ -0,0 +1,70 @@ +package com.mapswithme.maps.review; + +import com.mapswithme.maps.R; +import com.mapswithme.maps.base.BaseMwmFragment; +import com.mapswithme.maps.widget.placepage.SponsoredHotel; +import com.mapswithme.maps.widget.recycler.RecyclerClickListener; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import java.util.ArrayList; + +public class ReviewFragment extends BaseMwmFragment implements RecyclerClickListener { + private ArrayList mItems; + private String mRating; + private int mRatingBase; + private String mUrl; + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_review, container, false); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + readArguments(); + + RecyclerView rvGallery = (RecyclerView) view.findViewById(R.id.rv__review); + rvGallery.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); + rvGallery.setAdapter(new ReviewAdapter(mItems, this)); + TextView hotelRating = (TextView) view.findViewById(R.id.tv__place_hotel_rating); + TextView hotelRatingBase = (TextView) view.findViewById(R.id.tv__place_hotel_rating_base); + hotelRating.setText(mRating); + hotelRatingBase.setText(getResources().getQuantityString(R.plurals.place_page_booking_rating_base, + mRatingBase, mRatingBase)); + } + + private void readArguments() + { + final Bundle arguments = getArguments(); + if (arguments == null) + return; + + mItems = arguments.getParcelableArrayList(ReviewActivity.EXTRA_REVIEWS); + mRating = arguments.getString(ReviewActivity.EXTRA_RATING); + mRatingBase = arguments.getInt(ReviewActivity.EXTRA_RATING_BASE); + mUrl = arguments.getString(ReviewActivity.EXTRA_RATING_URL); + } + + @Override + public void onItemClick(View v, int position) { + final Intent intent = new Intent(Intent.ACTION_VIEW); + String url = mUrl; + if (!url.startsWith("http://") && !url.startsWith("https://")) + url = "http://" + url; + intent.setData(Uri.parse(url)); + getContext().startActivity(intent); + } +} diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 1be90edc1e..008144c3d4 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -64,6 +64,7 @@ import com.mapswithme.maps.editor.data.TimeFormatUtils; import com.mapswithme.maps.editor.data.Timetable; import com.mapswithme.maps.gallery.GalleryActivity; 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; @@ -150,7 +151,6 @@ public class PlacePageView extends RelativeLayout private View mHotelReview; private TextView mHotelRating; private TextView mHotelRatingBase; - private View mHotelMoreReviews; // Animations private BaseShadowController mShadowController; @@ -331,8 +331,8 @@ public class PlacePageView extends RelativeLayout 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); + View hotelMoreReviews = findViewById(R.id.tv__place_hotel_reviews_more); + hotelMoreReviews.setOnClickListener(this); mButtons = new PlacePageButtons(this, ppButtons, new PlacePageButtons.ItemListener() { @@ -524,12 +524,10 @@ public class PlacePageView extends RelativeLayout UiUtils.hide(mHotelReview); } else { UiUtils.show(mHotelReview); - mReviewAdapter.setItems(Arrays.asList(info.reviews)); + mReviewAdapter.setItems(new ArrayList<>(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); } } @@ -1086,7 +1084,8 @@ public class PlacePageView extends RelativeLayout mFacilitiesAdapter.setShowAll(true); break; case R.id.tv__place_hotel_reviews_more: -// TODO go to reviews activity + ReviewActivity.start(getContext(), mReviewAdapter.getItems(), mMapObject.getTitle(), + mSponsoredHotel.rating, mReviewAdapter.getItems().size(), mSponsoredHotel.urlBook); break; } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java index b0b7014ed4..06eb0285df 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java @@ -13,13 +13,12 @@ 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 items = new ArrayList<>(); + private ArrayList items = new ArrayList<>(); @Override public int getCount() { @@ -57,11 +56,15 @@ public class ReviewAdapter extends BaseAdapter { } public void setItems( - List items) { + ArrayList items) { this.items = items; notifyDataSetChanged(); } + public ArrayList getItems() { + return items; + } + private static class ViewHolder { final View mDivider; final TextView mUserName; diff --git a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java index 1a622c586f..2792bf4a06 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java +++ b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java @@ -1,6 +1,8 @@ package com.mapswithme.maps.widget.placepage; import android.support.annotation.Nullable; +import android.os.Parcel; +import android.os.Parcelable; import android.support.annotation.UiThread; import android.text.TextUtils; @@ -81,7 +83,7 @@ public final class SponsoredHotel } } - public static class Review { + public static class Review implements Parcelable { private final String mReviewPositive; private final String mReviewNegative; private final String mAuthor; @@ -99,6 +101,42 @@ public final class SponsoredHotel mDate = date; } + protected Review(Parcel in) { + mReviewPositive = in.readString(); + mReviewNegative = in.readString(); + mAuthor = in.readString(); + mAuthorAvatar = in.readString(); + mRating = in.readFloat(); + mDate = in.readLong(); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(mReviewPositive); + dest.writeString(mReviewNegative); + dest.writeString(mAuthor); + dest.writeString(mAuthorAvatar); + dest.writeFloat(mRating); + dest.writeLong(mDate); + } + + @Override + public int describeContents() { + return 0; + } + + public static final Creator CREATOR = new Creator() { + @Override + public Review createFromParcel(Parcel in) { + return new Review(in); + } + + @Override + public Review[] newArray(int size) { + return new Review[size]; + } + }; + public String getReviewPositive() { return mReviewPositive; } From 6f6f9125216b04da04200716f74cf21a915f7302 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Tue, 20 Sep 2016 08:56:24 +0400 Subject: [PATCH 12/26] [android] Refactoring. Move Review class from SponsoredHotel class. --- .../com/mapswithme/maps/SponsoredHotel.cpp | 4 +- .../maps/gallery/GalleryPageAdapter.java | 6 +- .../com/mapswithme/maps/gallery/Image.java | 7 +- .../mapswithme/maps/gallery/ImageAdapter.java | 4 +- .../com/mapswithme/maps/review/Review.java | 90 ++++++++++++++++++ .../maps/review/ReviewActivity.java | 3 +- .../mapswithme/maps/review/ReviewAdapter.java | 21 ++--- .../maps/review/ReviewFragment.java | 3 +- .../widget/placepage/FacilitiesAdapter.java | 6 +- .../maps/widget/placepage/GalleryAdapter.java | 12 +-- .../maps/widget/placepage/NearbyAdapter.java | 6 +- .../maps/widget/placepage/ReviewAdapter.java | 13 +-- .../maps/widget/placepage/SponsoredHotel.java | 94 ++----------------- 13 files changed, 140 insertions(+), 129 deletions(-) create mode 100644 android/src/com/mapswithme/maps/review/Review.java diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp index 61c27dc012..2f9e65301e 100644 --- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp +++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp @@ -34,14 +34,14 @@ void PrepareClassRefs(JNIEnv * env, jclass hotelClass) g_hotelInfoClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$HotelInfo"); g_facilityTypeClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$FacilityType"); g_nearbyObjectClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$NearbyObject"); - g_reviewClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$Review"); + g_reviewClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/review/Review"); g_imageClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/gallery/Image"); g_facilityConstructor = jni::GetConstructorID(env, g_facilityTypeClass, "(Ljava/lang/String;Ljava/lang/String;)V"); g_nearbyConstructor = jni::GetConstructorID(env, g_nearbyObjectClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;DD)V"); g_imageConstructor = jni::GetConstructorID(env, g_imageClass, "(Ljava/lang/String;Ljava/lang/String;)V"); g_reviewConstructor = jni::GetConstructorID(env, g_reviewClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FJ)V"); - g_hotelInfoConstructor = jni::GetConstructorID(env, g_hotelInfoClass, "(Ljava/lang/String;[Lcom/mapswithme/maps/gallery/Image;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$FacilityType;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$Review;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$NearbyObject;)V"); + g_hotelInfoConstructor = jni::GetConstructorID(env, g_hotelInfoClass, "(Ljava/lang/String;[Lcom/mapswithme/maps/gallery/Image;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$FacilityType;[Lcom/mapswithme/maps/review/Review;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$NearbyObject;)V"); // SponsoredHotel(String rating, String price, String urlBook, String urlDescription) g_hotelClassCtor = jni::GetConstructorID(env, g_hotelClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); diff --git a/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java b/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java index bd168af410..12ed1a1120 100644 --- a/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java +++ b/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java @@ -7,11 +7,11 @@ import android.support.v4.app.FragmentStatePagerAdapter; import java.util.List; -public class GalleryPageAdapter extends FragmentStatePagerAdapter { +class GalleryPageAdapter extends FragmentStatePagerAdapter { private final List mImages; - public GalleryPageAdapter(FragmentManager fm, List images) { + GalleryPageAdapter(FragmentManager fm, List images) { super(fm); mImages = images; } @@ -30,7 +30,7 @@ public class GalleryPageAdapter extends FragmentStatePagerAdapter { return mImages.size(); } - public Image getImage(int position) { + Image getImage(int position) { return mImages.get(position); } } diff --git a/android/src/com/mapswithme/maps/gallery/Image.java b/android/src/com/mapswithme/maps/gallery/Image.java index 7a26b43918..38c67d321f 100644 --- a/android/src/com/mapswithme/maps/gallery/Image.java +++ b/android/src/com/mapswithme/maps/gallery/Image.java @@ -12,6 +12,7 @@ public class Image implements Parcelable { private String source; private Long date; + @SuppressWarnings("unused") public Image(String url, String smallUrl) { this.url = url; this.smallUrl = smallUrl; @@ -71,18 +72,20 @@ public class Image implements Parcelable { this.description = description; } - public String getUserName() { + String getUserName() { return userName; } + @SuppressWarnings("unused") public void setUserName(String userName) { this.userName = userName; } - public String getUserAvatar() { + String getUserAvatar() { return userAvatar; } + @SuppressWarnings("unused") public void setUserAvatar(String userAvatar) { this.userAvatar = userAvatar; } diff --git a/android/src/com/mapswithme/maps/gallery/ImageAdapter.java b/android/src/com/mapswithme/maps/gallery/ImageAdapter.java index bead1e5def..b1b7ab4a34 100644 --- a/android/src/com/mapswithme/maps/gallery/ImageAdapter.java +++ b/android/src/com/mapswithme/maps/gallery/ImageAdapter.java @@ -12,11 +12,11 @@ import android.widget.ImageView; import java.util.ArrayList; -public class ImageAdapter extends RecyclerView.Adapter { +class ImageAdapter extends RecyclerView.Adapter { private final ArrayList mItems; private final RecyclerClickListener mListener; - public ImageAdapter(ArrayList images, RecyclerClickListener listener) { + ImageAdapter(ArrayList images, RecyclerClickListener listener) { mItems = images; mListener = listener; } diff --git a/android/src/com/mapswithme/maps/review/Review.java b/android/src/com/mapswithme/maps/review/Review.java new file mode 100644 index 0000000000..249e9a237a --- /dev/null +++ b/android/src/com/mapswithme/maps/review/Review.java @@ -0,0 +1,90 @@ +package com.mapswithme.maps.review; + +import android.os.Parcel; +import android.os.Parcelable; + +public class Review implements Parcelable { + + private final String mReviewPositive; + + private final String mReviewNegative; + + private final String mAuthor; + + private final String mAuthorAvatar; + + private final float mRating; + + private final long mDate; + + public Review(String reviewPositive, String reviewNegative, String author, String authorAvatar, + float rating, long date) { + mReviewPositive = reviewPositive; + mReviewNegative = reviewNegative; + mAuthor = author; + mAuthorAvatar = authorAvatar; + mRating = rating; + mDate = date; + } + + protected Review(Parcel in) { + mReviewPositive = in.readString(); + mReviewNegative = in.readString(); + mAuthor = in.readString(); + mAuthorAvatar = in.readString(); + mRating = in.readFloat(); + mDate = in.readLong(); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(mReviewPositive); + dest.writeString(mReviewNegative); + dest.writeString(mAuthor); + dest.writeString(mAuthorAvatar); + dest.writeFloat(mRating); + dest.writeLong(mDate); + } + + @Override + public int describeContents() { + return 0; + } + + public static final Creator CREATOR = new Creator() { + @Override + public Review createFromParcel(Parcel in) { + return new Review(in); + } + + @Override + public Review[] newArray(int size) { + return new Review[size]; + } + }; + + public String getReviewPositive() { + return mReviewPositive; + } + + public String getReviewNegative() { + return mReviewNegative; + } + + public String getAuthor() { + return mAuthor; + } + + @SuppressWarnings("unused") + public String getAuthorAvatar() { + return mAuthorAvatar; + } + + public float getRating() { + return mRating; + } + + public long getDate() { + return mDate; + } +} diff --git a/android/src/com/mapswithme/maps/review/ReviewActivity.java b/android/src/com/mapswithme/maps/review/ReviewActivity.java index a34e663eef..d0ee0e0517 100644 --- a/android/src/com/mapswithme/maps/review/ReviewActivity.java +++ b/android/src/com/mapswithme/maps/review/ReviewActivity.java @@ -2,7 +2,6 @@ package com.mapswithme.maps.review; import com.mapswithme.maps.R; import com.mapswithme.maps.base.BaseMwmFragmentActivity; -import com.mapswithme.maps.widget.placepage.SponsoredHotel; import com.mapswithme.util.UiUtils; import android.content.Context; @@ -20,7 +19,7 @@ public class ReviewActivity extends BaseMwmFragmentActivity { static final String EXTRA_RATING_BASE = "review_rating_base"; static final String EXTRA_RATING_URL = "review_rating_url"; - public static void start(Context context, ArrayList items, String title, + public static void start(Context context, ArrayList items, String title, String rating, int ratingBase, String url) { final Intent i = new Intent(context, ReviewActivity.class); diff --git a/android/src/com/mapswithme/maps/review/ReviewAdapter.java b/android/src/com/mapswithme/maps/review/ReviewAdapter.java index f31940aae0..f756af6147 100644 --- a/android/src/com/mapswithme/maps/review/ReviewAdapter.java +++ b/android/src/com/mapswithme/maps/review/ReviewAdapter.java @@ -1,7 +1,6 @@ package com.mapswithme.maps.review; import com.mapswithme.maps.R; -import com.mapswithme.maps.widget.placepage.SponsoredHotel; import com.mapswithme.maps.widget.recycler.RecyclerClickListener; import com.mapswithme.util.UiUtils; @@ -18,15 +17,15 @@ import java.util.ArrayList; import java.util.Date; import java.util.Locale; -public class ReviewAdapter extends RecyclerView.Adapter { +class ReviewAdapter extends RecyclerView.Adapter { private static final int MAX_COUNT = 15; private static final int VIEW_TYPE_REVIEW = 0; private static final int VIEW_TYPE_MORE = 1; - private final ArrayList mItems; + private final ArrayList mItems; private final RecyclerClickListener mListener; - public ReviewAdapter(ArrayList images, RecyclerClickListener listener) { + ReviewAdapter(ArrayList images, RecyclerClickListener listener) { mItems = images; mListener = listener; } @@ -75,7 +74,7 @@ public class ReviewAdapter extends RecyclerView.Adapter 0, mDivider); mUserName.setText(item.getAuthor()); @@ -138,9 +137,9 @@ public class ReviewAdapter extends RecyclerView.Adapter mItems; + private ArrayList mItems; private String mRating; private int mRatingBase; private String mUrl; diff --git a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java index 8019e4060d..9ab248ef03 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java @@ -12,8 +12,8 @@ import android.widget.TextView; import java.util.ArrayList; import java.util.List; -public class FacilitiesAdapter extends BaseAdapter { - public static final int MAX_COUNT = 6; +class FacilitiesAdapter extends BaseAdapter { + static final int MAX_COUNT = 6; private List items = new ArrayList<>(); private boolean isShowAll = false; @@ -59,7 +59,7 @@ public class FacilitiesAdapter extends BaseAdapter { notifyDataSetChanged(); } - public void setShowAll(boolean showAll) { + void setShowAll(boolean showAll) { isShowAll = showAll; notifyDataSetChanged(); } diff --git a/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java index 197c355130..1a8338dd5f 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java @@ -19,7 +19,7 @@ import android.widget.ImageView; import java.util.ArrayList; import java.util.List; -public class GalleryAdapter extends RecyclerView.Adapter { +class GalleryAdapter extends RecyclerView.Adapter { private static final int MAX_COUNT = 5; private final Context mContext; @@ -31,7 +31,7 @@ public class GalleryAdapter extends RecyclerView.Adapter mDownloadStates = new ArrayList<>(); - public GalleryAdapter(Context context) { + GalleryAdapter(Context context) { mContext = context; mImageWidth = (int)context.getResources().getDimension(R.dimen.placepage_hotel_gallery_width); @@ -162,20 +162,20 @@ public class GalleryAdapter extends RecyclerView.Adapter items = new ArrayList<>(); + private ArrayList items = new ArrayList<>(); @Override public int getCount() { @@ -56,12 +57,12 @@ public class ReviewAdapter extends BaseAdapter { } public void setItems( - ArrayList items) { + ArrayList items) { this.items = items; notifyDataSetChanged(); } - public ArrayList getItems() { + public ArrayList getItems() { return items; } @@ -86,7 +87,7 @@ public class ReviewAdapter extends BaseAdapter { mTvNegativeReview = (TextView) view.findViewById(R.id.tv__negative_review); } - public void bind(SponsoredHotel.Review item, boolean isShowDivider) { + public void bind(Review item, boolean isShowDivider) { UiUtils.showIf(isShowDivider, mDivider); mUserName.setText(item.getAuthor()); Date date = new Date(item.getDate()); diff --git a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java index 2792bf4a06..dc3da30561 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java +++ b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java @@ -1,8 +1,6 @@ package com.mapswithme.maps.widget.placepage; import android.support.annotation.Nullable; -import android.os.Parcel; -import android.os.Parcelable; import android.support.annotation.UiThread; import android.text.TextUtils; @@ -13,9 +11,10 @@ import java.util.Map; 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; @UiThread -public final class SponsoredHotel +final class SponsoredHotel { private static class Price { @@ -29,7 +28,7 @@ public final class SponsoredHotel } } - public static class FacilityType { + static class FacilityType { private final String key; private final String name; @@ -47,7 +46,7 @@ public final class SponsoredHotel } } - public static class NearbyObject { + static class NearbyObject { private final String category; private final String title; private final String distance; @@ -83,86 +82,7 @@ public final class SponsoredHotel } } - public static class Review implements Parcelable { - private final String mReviewPositive; - private final String mReviewNegative; - private final String mAuthor; - private final String mAuthorAvatar; - private final float mRating; - private final long mDate; - - public Review(String reviewPositive, String reviewNegative, String author, String authorAvatar, - float rating, long date) { - mReviewPositive = reviewPositive; - mReviewNegative = reviewNegative; - mAuthor = author; - mAuthorAvatar = authorAvatar; - mRating = rating; - mDate = date; - } - - protected Review(Parcel in) { - mReviewPositive = in.readString(); - mReviewNegative = in.readString(); - mAuthor = in.readString(); - mAuthorAvatar = in.readString(); - mRating = in.readFloat(); - mDate = in.readLong(); - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mReviewPositive); - dest.writeString(mReviewNegative); - dest.writeString(mAuthor); - dest.writeString(mAuthorAvatar); - dest.writeFloat(mRating); - dest.writeLong(mDate); - } - - @Override - public int describeContents() { - return 0; - } - - public static final Creator CREATOR = new Creator() { - @Override - public Review createFromParcel(Parcel in) { - return new Review(in); - } - - @Override - public Review[] newArray(int size) { - return new Review[size]; - } - }; - - public String getReviewPositive() { - return mReviewPositive; - } - - public String getReviewNegative() { - return mReviewNegative; - } - - public String getAuthor() { - return mAuthor; - } - - public String getAuthorAvatar() { - return mAuthorAvatar; - } - - public float getRating() { - return mRating; - } - - public long getDate() { - return mDate; - } - } - - public static class HotelInfo { + static class HotelInfo { final String description; final Image[] photos; final FacilityType[] facilities; @@ -242,12 +162,12 @@ public final class SponsoredHotel return urlDescription; } - public static void setPriceListener(OnPriceReceivedListener listener) + static void setPriceListener(OnPriceReceivedListener listener) { sPriceListener = new WeakReference<>(listener); } - public static void setInfoListener(OnInfoReceivedListener listener) + static void setInfoListener(OnInfoReceivedListener listener) { sInfoListener = new WeakReference<>(listener); } From cc70981b727907978a659eb92f2e7f469131c7d4 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Wed, 21 Sep 2016 08:15:23 +0400 Subject: [PATCH 13/26] [android] gallery photo on place page is now clickable --- .../maps/widget/placepage/GalleryAdapter.java | 11 ++--------- .../maps/widget/placepage/PlacePageView.java | 7 ++++++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java index 1a8338dd5f..54d3f29b7b 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; class GalleryAdapter extends RecyclerView.Adapter { - private static final int MAX_COUNT = 5; + static final int MAX_COUNT = 5; private final Context mContext; private ArrayList mItems = new ArrayList<>(); @@ -114,7 +114,6 @@ class GalleryAdapter extends RecyclerView.Adapter { } static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { - private final View mParentView; private ImageView mImage; private View mMore; private final RecyclerClickListener mListener; @@ -122,10 +121,10 @@ class GalleryAdapter extends RecyclerView.Adapter { public ViewHolder(View itemView, RecyclerClickListener listener) { super(itemView); - mParentView = itemView; mListener = listener; mImage = (ImageView) itemView.findViewById(R.id.iv__image); mMore = itemView.findViewById(R.id.tv__more); + itemView.setOnClickListener(this); } @Override @@ -142,14 +141,8 @@ class GalleryAdapter extends RecyclerView.Adapter { mImage.setImageBitmap(item.getBitmap()); if (item.isShowMore()) { UiUtils.show(mMore); - mParentView.setClickable(true); - mParentView.setFocusable(true); - mParentView.setOnClickListener(this); } else { UiUtils.hide(mMore); - mParentView.setOnClickListener(null); - mParentView.setClickable(false); - mParentView.setFocusable(false); } } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 008144c3d4..878419562e 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -62,6 +62,7 @@ import com.mapswithme.maps.editor.Editor; import com.mapswithme.maps.editor.OpeningHours; import com.mapswithme.maps.editor.data.TimeFormatUtils; import com.mapswithme.maps.editor.data.Timetable; +import com.mapswithme.maps.gallery.FullScreenGalleryActivity; import com.mapswithme.maps.gallery.GalleryActivity; import com.mapswithme.maps.location.LocationHelper; import com.mapswithme.maps.review.ReviewActivity; @@ -538,7 +539,11 @@ public class PlacePageView extends RelativeLayout @Override public void onItemClick(View v, int position) { - GalleryActivity.start(getContext(), mGalleryAdapter.getItems(), mMapObject.getTitle()); + if (position == GalleryAdapter.MAX_COUNT - 1) { + GalleryActivity.start(getContext(), mGalleryAdapter.getItems(), mMapObject.getTitle()); + } else { + FullScreenGalleryActivity.start(getContext(), mGalleryAdapter.getItems(), position); + } } @Override From b646149b0573675562633e8e13904be12b1a8406 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Wed, 21 Sep 2016 09:25:08 +0400 Subject: [PATCH 14/26] [android] rating scrolled with reviews --- android/res/layout/fragment_review.xml | 30 +--------- android/res/layout/item_rating.xml | 28 +++++++++ .../mapswithme/maps/review/ReviewAdapter.java | 58 +++++++++++++++---- .../maps/review/ReviewFragment.java | 8 +-- 4 files changed, 79 insertions(+), 45 deletions(-) create mode 100644 android/res/layout/item_rating.xml diff --git a/android/res/layout/fragment_review.xml b/android/res/layout/fragment_review.xml index a0a0e70860..1cf112d06e 100644 --- a/android/res/layout/fragment_review.xml +++ b/android/res/layout/fragment_review.xml @@ -3,34 +3,8 @@ xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="match_parent"> - - - - - - - + android:layout_height="match_parent" + android:background="?cardBackground"> + + + + + + \ No newline at end of file diff --git a/android/src/com/mapswithme/maps/review/ReviewAdapter.java b/android/src/com/mapswithme/maps/review/ReviewAdapter.java index f756af6147..920d730d91 100644 --- a/android/src/com/mapswithme/maps/review/ReviewAdapter.java +++ b/android/src/com/mapswithme/maps/review/ReviewAdapter.java @@ -21,13 +21,19 @@ class ReviewAdapter extends RecyclerView.Adapter { private static final int MAX_COUNT = 15; private static final int VIEW_TYPE_REVIEW = 0; private static final int VIEW_TYPE_MORE = 1; + private static final int VIEW_TYPE_RATING = 2; private final ArrayList mItems; private final RecyclerClickListener mListener; + private final String mRating; + private final int mRatingBase; - ReviewAdapter(ArrayList images, RecyclerClickListener listener) { + ReviewAdapter(ArrayList images, RecyclerClickListener listener, String rating, + int ratingBase) { mItems = images; mListener = listener; + mRating = rating; + mRatingBase = ratingBase; } @Override @@ -37,33 +43,47 @@ class ReviewAdapter extends RecyclerView.Adapter { .inflate(R.layout.item_comment, parent, false), mListener); } - return new MoreHolder(LayoutInflater.from(parent.getContext()) - .inflate(R.layout.item_more_button, parent, false), mListener); + if (viewType == VIEW_TYPE_MORE) { + return new MoreHolder(LayoutInflater.from(parent.getContext()) + .inflate(R.layout.item_more_button, parent, false), mListener); + } + + return new RatingHolder(LayoutInflater.from(parent.getContext()) + .inflate(R.layout.item_rating, parent, false), mListener); } @Override public void onBindViewHolder(BaseViewHolder holder, int position) { - if (position < mItems.size()) { - holder.bind(mItems.get(position), position); + int positionNoHeader = position - 1; + + if (position == 0) { + ((RatingHolder)holder).bind(mRating, mRatingBase); + } else if (positionNoHeader < mItems.size()) { + holder.bind(mItems.get(positionNoHeader), positionNoHeader); } else { - holder.bind(null, position); + holder.bind(null, positionNoHeader); } } @Override public int getItemCount() { if (mItems == null) { - return 0; + return 1; } if (mItems.size() > MAX_COUNT) { - return MAX_COUNT + 1; + return MAX_COUNT + 2; } - return mItems.size() + 1; + return mItems.size() + 2; } @Override public int getItemViewType(int position) { - if (position == mItems.size()) { + int positionNoHeader = position - 1; + + if (position == 0) { + return VIEW_TYPE_RATING; + } + if (positionNoHeader == mItems.size()) { return VIEW_TYPE_MORE; } @@ -144,4 +164,22 @@ class ReviewAdapter extends RecyclerView.Adapter { itemView.setOnClickListener(this); } } + + private static class RatingHolder extends BaseViewHolder { + final TextView mHotelRating; + final TextView mHotelRatingBase; + + RatingHolder(View itemView, RecyclerClickListener listener) { + super(itemView, listener); + mHotelRating = (TextView) itemView.findViewById(R.id.tv__place_hotel_rating); + mHotelRatingBase = (TextView) itemView.findViewById(R.id.tv__place_hotel_rating_base); + } + + public void bind(String rating, int ratingBase) { + mHotelRating.setText(rating); + mHotelRatingBase.setText(mHotelRatingBase.getContext().getResources() + .getQuantityString(R.plurals.place_page_booking_rating_base, + ratingBase, ratingBase)); + } + } } diff --git a/android/src/com/mapswithme/maps/review/ReviewFragment.java b/android/src/com/mapswithme/maps/review/ReviewFragment.java index 0cc0657af4..7f5f562054 100644 --- a/android/src/com/mapswithme/maps/review/ReviewFragment.java +++ b/android/src/com/mapswithme/maps/review/ReviewFragment.java @@ -13,7 +13,6 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import java.util.ArrayList; @@ -37,12 +36,7 @@ public class ReviewFragment extends BaseMwmFragment implements RecyclerClickList RecyclerView rvGallery = (RecyclerView) view.findViewById(R.id.rv__review); rvGallery.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); - rvGallery.setAdapter(new ReviewAdapter(mItems, this)); - TextView hotelRating = (TextView) view.findViewById(R.id.tv__place_hotel_rating); - TextView hotelRatingBase = (TextView) view.findViewById(R.id.tv__place_hotel_rating_base); - hotelRating.setText(mRating); - hotelRatingBase.setText(getResources().getQuantityString(R.plurals.place_page_booking_rating_base, - mRatingBase, mRatingBase)); + rvGallery.setAdapter(new ReviewAdapter(mItems, this, mRating, mRatingBase)); } private void readArguments() From 2a3bb51c4447d01fe1cbef04e67aed3a9d2d8d31 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Wed, 21 Sep 2016 09:35:44 +0400 Subject: [PATCH 15/26] [android] remove more button --- android/res/layout-w600dp-port/place_page_details.xml | 1 - android/res/layout/place_page_details.xml | 2 -- .../com/mapswithme/maps/widget/placepage/PlacePageView.java | 5 ----- 3 files changed, 8 deletions(-) diff --git a/android/res/layout-w600dp-port/place_page_details.xml b/android/res/layout-w600dp-port/place_page_details.xml index 790899f741..1e5d60eb54 100644 --- a/android/res/layout-w600dp-port/place_page_details.xml +++ b/android/res/layout-w600dp-port/place_page_details.xml @@ -82,7 +82,6 @@ - diff --git a/android/res/layout/place_page_details.xml b/android/res/layout/place_page_details.xml index cc0939dedf..7e5a23d2d8 100644 --- a/android/res/layout/place_page_details.xml +++ b/android/res/layout/place_page_details.xml @@ -59,8 +59,6 @@ - - diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 878419562e..00eaf99ba9 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -132,7 +132,6 @@ public class PlacePageView extends RelativeLayout private View mEditPlace; private View mAddOrganisation; private View mAddPlace; - private View mMoreInfo; // Bookmark private View mBookmarkFrame; private TextView mBookmarkNote; @@ -287,8 +286,6 @@ public class PlacePageView extends RelativeLayout mAddOrganisation.setOnClickListener(this); mAddPlace = mDetails.findViewById(R.id.ll__place_add); mAddPlace.setOnClickListener(this); - mMoreInfo = mDetails.findViewById(R.id.ll__more); - mMoreInfo.setOnClickListener(this); latlon.setOnLongClickListener(this); address.setOnLongClickListener(this); mPhone.setOnLongClickListener(this); @@ -818,8 +815,6 @@ public class PlacePageView extends RelativeLayout UiUtils.showIf(Editor.nativeShouldShowAddBusiness(), mAddOrganisation); UiUtils.showIf(Editor.nativeShouldShowAddPlace(), mAddPlace); } - - UiUtils.showIf(mSponsoredHotel != null, mMoreInfo); } private void refreshOpeningHours() From 4951ee7e8e57a7e9363a1ae8ed5dd31fc42e0ac0 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Wed, 21 Sep 2016 11:05:20 +0400 Subject: [PATCH 16/26] [android] fix touch event consuption in place page landscape mode --- .../LeftPlacePageAnimationController.java | 4 ++++ .../maps/widget/placepage/PlacePageView.java | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/android/src/com/mapswithme/maps/widget/placepage/LeftPlacePageAnimationController.java b/android/src/com/mapswithme/maps/widget/placepage/LeftPlacePageAnimationController.java index 40f45ec182..b68a2b068e 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/LeftPlacePageAnimationController.java +++ b/android/src/com/mapswithme/maps/widget/placepage/LeftPlacePageAnimationController.java @@ -27,6 +27,10 @@ class LeftPlacePageAnimationController extends BasePlacePageAnimationController @Override protected boolean onInterceptTouchEvent(MotionEvent event) { + if (mPlacePage.isTouchGallery(event)) { + return false; + } + switch (event.getAction()) { case MotionEvent.ACTION_DOWN: diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 00eaf99ba9..2447002fb3 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -205,6 +205,22 @@ public class PlacePageView extends RelativeLayout } }; + public boolean isTouchGallery(MotionEvent event) { + if (UiUtils.isHidden(mHotelGallery)) + return false; + + float x = event.getX(); + float y = event.getY(); + int[] location = new int[2]; + mHotelGallery.getLocationOnScreen(location); + float viewX = (float) location[0]; + float viewY = (float) location[1]; + float width = (float) mHotelGallery.getWidth(); + float height = (float) mHotelGallery.getHeight(); + + return !(x < viewX || x > viewX + width || y < viewY || y > viewY + height); + } + public enum State { HIDDEN, From 41d744377d13932882f9ba6815390be153c08c30 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Wed, 21 Sep 2016 11:43:40 +0400 Subject: [PATCH 17/26] [android] fix place page details tablet layout --- android/res/layout-w600dp-port/place_page_details.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/android/res/layout-w600dp-port/place_page_details.xml b/android/res/layout-w600dp-port/place_page_details.xml index 1e5d60eb54..3c52cb9ffa 100644 --- a/android/res/layout-w600dp-port/place_page_details.xml +++ b/android/res/layout-w600dp-port/place_page_details.xml @@ -47,6 +47,12 @@ android:layout_toLeftOf="@id/anchor_center" android:layout_toStartOf="@id/anchor_center" android:orientation="vertical"> + + + + + + @@ -82,6 +88,10 @@ + + + + From ce81c3676ad4766160e3551ed3b40aea57c85b72 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Thu, 22 Sep 2016 07:58:05 +0400 Subject: [PATCH 18/26] [android] added single comment to review --- android/jni/com/mapswithme/maps/SponsoredHotel.cpp | 3 ++- android/res/layout/item_comment.xml | 14 ++++++++++++++ android/src/com/mapswithme/maps/review/Review.java | 12 +++++++++++- .../com/mapswithme/maps/review/ReviewAdapter.java | 7 +++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp index 2f9e65301e..eabef51cbc 100644 --- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp +++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp @@ -40,7 +40,7 @@ void PrepareClassRefs(JNIEnv * env, jclass hotelClass) g_facilityConstructor = jni::GetConstructorID(env, g_facilityTypeClass, "(Ljava/lang/String;Ljava/lang/String;)V"); g_nearbyConstructor = jni::GetConstructorID(env, g_nearbyObjectClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;DD)V"); g_imageConstructor = jni::GetConstructorID(env, g_imageClass, "(Ljava/lang/String;Ljava/lang/String;)V"); - g_reviewConstructor = jni::GetConstructorID(env, g_reviewClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FJ)V"); + g_reviewConstructor = jni::GetConstructorID(env, g_reviewClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FJ)V"); g_hotelInfoConstructor = jni::GetConstructorID(env, g_hotelInfoClass, "(Ljava/lang/String;[Lcom/mapswithme/maps/gallery/Image;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$FacilityType;[Lcom/mapswithme/maps/review/Review;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$NearbyObject;)V"); // SponsoredHotel(String rating, String price, String urlBook, String urlDescription) @@ -129,6 +129,7 @@ Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestInfo(JNIEn [](JNIEnv * env, BookingApi::HotelReview const & item) { return env->NewObject(g_reviewClass, g_reviewConstructor, + jni::ToJavaString(env, item.m_reviewPositive), jni::ToJavaString(env, item.m_reviewPositive), jni::ToJavaString(env, item.m_reviewNegative), jni::ToJavaString(env, item.m_author), diff --git a/android/res/layout/item_comment.xml b/android/res/layout/item_comment.xml index b8342956a1..6718f94d4c 100644 --- a/android/res/layout/item_comment.xml +++ b/android/res/layout/item_comment.xml @@ -49,6 +49,20 @@ android:textAppearance="@style/MwmTextAppearance.Headline" tools:text="9.2"/> + + { final TextView mUserName; final TextView mCommentDate; final TextView mRating; + final TextView mReview; final View mPositiveReview; final TextView mTvPositiveReview; final View mNegativeReview; @@ -128,6 +129,7 @@ class ReviewAdapter extends RecyclerView.Adapter { mUserName = (TextView) itemView.findViewById(R.id.tv__user_name); mCommentDate = (TextView) itemView.findViewById(R.id.tv__comment_date); mRating = (TextView) itemView.findViewById(R.id.tv__user_rating); + mReview = (TextView) itemView.findViewById(R.id.tv__review); mPositiveReview = itemView.findViewById(R.id.ll__positive_review); mTvPositiveReview = (TextView) itemView.findViewById(R.id.tv__positive_review); mNegativeReview = itemView.findViewById(R.id.ll__negative_review); @@ -154,6 +156,11 @@ class ReviewAdapter extends RecyclerView.Adapter { UiUtils.show(mNegativeReview); mTvNegativeReview.setText(item.getReviewNegative()); } + if (UiUtils.isHidden(mNegativeReview) && UiUtils.isHidden(mPositiveReview)) { + UiUtils.showIf(!TextUtils.isEmpty(item.getReview()), mReview); + } else { + UiUtils.hide(mReview); + } } } From e8fb2ed4465c4b2e023cf0598b29b6455082fe64 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Fri, 23 Sep 2016 08:11:46 +0400 Subject: [PATCH 19/26] [android] get neutral review in jni binding --- android/jni/com/mapswithme/maps/SponsoredHotel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp index eabef51cbc..86291b6113 100644 --- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp +++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp @@ -129,7 +129,7 @@ Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestInfo(JNIEn [](JNIEnv * env, BookingApi::HotelReview const & item) { return env->NewObject(g_reviewClass, g_reviewConstructor, - jni::ToJavaString(env, item.m_reviewPositive), + jni::ToJavaString(env, item.m_reviewNeutral), jni::ToJavaString(env, item.m_reviewPositive), jni::ToJavaString(env, item.m_reviewNegative), jni::ToJavaString(env, item.m_author), From 50b5ebda6eca1ead54a16cf84fa22e11d6146fd7 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Mon, 26 Sep 2016 10:18:46 +0400 Subject: [PATCH 20/26] [android] Review fixes. --- android/res/values-ru/strings.xml | 5 +++++ android/res/values-v16/strings.xml | 11 +++++++++++ android/res/values-w840dp/strings.xml | 11 +++++++++++ android/res/values/strings.xml | 17 +++-------------- iphone/Maps/ar.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/cs.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/da.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/de.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/en-GB.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/en.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/es.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/fi.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/fr.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/hu.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/id.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/it.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/ja.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/ko.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/nb.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/nl.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/pl.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/pt.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/ro.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/ru.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/sk.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/sv.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/th.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/tr.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/uk.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/vi.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/zh-Hans.lproj/Localizable.strings | 8 ++++++++ iphone/Maps/zh-Hant.lproj/Localizable.strings | 8 ++++++++ 32 files changed, 254 insertions(+), 14 deletions(-) create mode 100644 android/res/values-v16/strings.xml create mode 100644 android/res/values-w840dp/strings.xml diff --git a/android/res/values-ru/strings.xml b/android/res/values-ru/strings.xml index 05915fed30..f774e89010 100644 --- a/android/res/values-ru/strings.xml +++ b/android/res/values-ru/strings.xml @@ -882,6 +882,7 @@ мин Описание Ещё + Ещё отзывы Забронировать Позвонить Редактировать метку @@ -967,4 +968,8 @@ На пеших и веломаршрутах отображается профиль рельефа. Экономь на бронировании отеля Результаты поиска отелей на карте показывают ценовую категорию.\nОтелей для бронирования стало на 110 000 больше. + + Удобства + + Рядом diff --git a/android/res/values-v16/strings.xml b/android/res/values-v16/strings.xml new file mode 100644 index 0000000000..b7ddcc4b0b --- /dev/null +++ b/android/res/values-v16/strings.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/android/res/values-w840dp/strings.xml b/android/res/values-w840dp/strings.xml new file mode 100644 index 0000000000..388be69c77 --- /dev/null +++ b/android/res/values-w840dp/strings.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index 820ee012c2..39fb5359bf 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -886,7 +886,7 @@ min Description More - More Reviews + More Reviews Book Call Edit Bookmark @@ -968,19 +968,8 @@ Accept Decline - Better go about than fall into the ditch - For pedestrian and bike routes we now display the elevation profile. - Save when booking hotels - Search results for hotels now contain the price category.\nWe also added more than 110,000 hotels. + Facilities + Nearby - - - Based on %1$d hotel reviews - Based on %1$d hotel reviews - Based on %1$d hotel reviews - Based on %1$d hotel reviews - Based on %1$d hotel reviews - Based on %1$d hotel reviews - diff --git a/iphone/Maps/ar.lproj/Localizable.strings b/iphone/Maps/ar.lproj/Localizable.strings index bb750339de..a66431376e 100644 --- a/iphone/Maps/ar.lproj/Localizable.strings +++ b/iphone/Maps/ar.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "المزيد"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "حجز"; "placepage_call_button" = "اتصال"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "توفير عند حجز الفنادق"; "whats_new_booking_improve_message" = "تحتوي نتائج البحث عن الفنادق الآن على فئة السعر.\nوأضفنا أيضًا أكثر من 110000 فندق."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/cs.lproj/Localizable.strings b/iphone/Maps/cs.lproj/Localizable.strings index e8685d34a7..add9fa7446 100644 --- a/iphone/Maps/cs.lproj/Localizable.strings +++ b/iphone/Maps/cs.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Více"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Rezervace"; "placepage_call_button" = "Volat"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Ušetřete při rezervaci hotelů"; "whats_new_booking_improve_message" = "Výsledky hledání hotelů nyní obsahují cenové kategorie. \nTaké jsme přidali více než 110 000 hotelů."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/da.lproj/Localizable.strings b/iphone/Maps/da.lproj/Localizable.strings index 6230fb1434..1cf0e933e0 100644 --- a/iphone/Maps/da.lproj/Localizable.strings +++ b/iphone/Maps/da.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Mere"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Bog"; "placepage_call_button" = "Ring"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Spar penge når du bestiller hotelværelser"; "whats_new_booking_improve_message" = "Søgeresultater for hoteller viser nu også priskategorien.\nVi har desuden tilføjet mere end 110.000 hoteller."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/de.lproj/Localizable.strings b/iphone/Maps/de.lproj/Localizable.strings index 86a56cc799..b88fb21d16 100644 --- a/iphone/Maps/de.lproj/Localizable.strings +++ b/iphone/Maps/de.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Mehr"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Buchen"; "placepage_call_button" = "Anruf"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Beim Buchen von Hotels sparen"; "whats_new_booking_improve_message" = "Suchergebnisse für Hotels enthalten jetzt die Kategorie Preis.\nAußerdem haben wir über 110.000 Hotels hinzugefügt."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/en-GB.lproj/Localizable.strings b/iphone/Maps/en-GB.lproj/Localizable.strings index 8e5bcebb29..3adf7e53e7 100644 --- a/iphone/Maps/en-GB.lproj/Localizable.strings +++ b/iphone/Maps/en-GB.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "More"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Book"; "placepage_call_button" = "Call"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Save when booking hotels"; "whats_new_booking_improve_message" = "Search results for hotels now contain the price category.\nWe also added more than 110,000 hotels."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/en.lproj/Localizable.strings b/iphone/Maps/en.lproj/Localizable.strings index f2c6aa9cd5..1c7d3ac0c7 100644 --- a/iphone/Maps/en.lproj/Localizable.strings +++ b/iphone/Maps/en.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "More"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Book"; "placepage_call_button" = "Call"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Save when booking hotels"; "whats_new_booking_improve_message" = "Search results for hotels now contain the price category.\nWe also added more than 110,000 hotels."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/es.lproj/Localizable.strings b/iphone/Maps/es.lproj/Localizable.strings index 5fb18cc385..d671f66be3 100644 --- a/iphone/Maps/es.lproj/Localizable.strings +++ b/iphone/Maps/es.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Más"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Reservar"; "placepage_call_button" = "Llamar"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Ahorrar al reservar hoteles"; "whats_new_booking_improve_message" = "La búsqueda de resultados de hoteles ahora contiene la categoría de precios.\nHemos añadido más de 110 000 hoteles."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/fi.lproj/Localizable.strings b/iphone/Maps/fi.lproj/Localizable.strings index 38b3cd5dc1..6a6eec5704 100644 --- a/iphone/Maps/fi.lproj/Localizable.strings +++ b/iphone/Maps/fi.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Lisää"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Varaa"; "placepage_call_button" = "Soita"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Säästä hotellivarauksissa"; "whats_new_booking_improve_message" = "Hotellien hakutuloksissa näkyy nyt hintakategoria.\nLisäsimme myös yli 110 000 hotellia."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/fr.lproj/Localizable.strings b/iphone/Maps/fr.lproj/Localizable.strings index 3a19dbd63a..3639b56c4e 100644 --- a/iphone/Maps/fr.lproj/Localizable.strings +++ b/iphone/Maps/fr.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Plus"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Réserver"; "placepage_call_button" = "Appeler"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Économisez de l'argent en réservant des hôtels"; "whats_new_booking_improve_message" = "Les résultats des recherches d'hôtels comprennent maintenant la catégorie de prix.\nNous avons aussi ajouté plus de 110.000 hôtels."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/hu.lproj/Localizable.strings b/iphone/Maps/hu.lproj/Localizable.strings index 9acf495dba..3784bfa716 100644 --- a/iphone/Maps/hu.lproj/Localizable.strings +++ b/iphone/Maps/hu.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Még"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Foglalás"; "placepage_call_button" = "Hívás"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Takarékoskodjon szálláshely foglalásakor"; "whats_new_booking_improve_message" = "A szálláshely keresési eredménye már tartalmazza az árkategóriát. \nEmellett kiegészítettük több mint 110.000 szálláshellyel."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/id.lproj/Localizable.strings b/iphone/Maps/id.lproj/Localizable.strings index 582068245d..c5329312c2 100644 --- a/iphone/Maps/id.lproj/Localizable.strings +++ b/iphone/Maps/id.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Lainnya"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Pesan"; "placepage_call_button" = "Hubungi"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Berhemat saat memesan hotel"; "whats_new_booking_improve_message" = "Hasil pencarian untuk hotel kini disertai kategori harga.\nKami juga menambahkan lebih dari 110.000 hotel."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/it.lproj/Localizable.strings b/iphone/Maps/it.lproj/Localizable.strings index 9800d1f220..d90d497a3a 100644 --- a/iphone/Maps/it.lproj/Localizable.strings +++ b/iphone/Maps/it.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Altro"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Prenota"; "placepage_call_button" = "Chiama"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Risparmia alla prenotazione degli hotel"; "whats_new_booking_improve_message" = "I risultati della ricerca per gli hotel contengono ora la categoria di prezzo.\nInoltre, abbiamo aggiunto più di 110.000 hotel."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/ja.lproj/Localizable.strings b/iphone/Maps/ja.lproj/Localizable.strings index 9b977e4e57..a067b93a0d 100644 --- a/iphone/Maps/ja.lproj/Localizable.strings +++ b/iphone/Maps/ja.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "さらに詳しく"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "予約"; "placepage_call_button" = "コール"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "ホテル予約時に節約しましょう"; "whats_new_booking_improve_message" = "ホテルの検索結果に価格のカテゴリーが表示されるようになりました。\nさらに、 110,000 軒を超えるホテルを追加しました。"; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/ko.lproj/Localizable.strings b/iphone/Maps/ko.lproj/Localizable.strings index a80efc21a9..2610b2df6f 100644 --- a/iphone/Maps/ko.lproj/Localizable.strings +++ b/iphone/Maps/ko.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "자세히"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "예약"; "placepage_call_button" = "전화"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "호텔 예약 시 절약"; "whats_new_booking_improve_message" = "이제 가격 범주를 포함하는 호텔에 대한 결과를 검색하세요.\n또한 110,000곳 이상의 호텔이 추가되었습니다."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/nb.lproj/Localizable.strings b/iphone/Maps/nb.lproj/Localizable.strings index ddc849c5e3..c7b3421dfa 100644 --- a/iphone/Maps/nb.lproj/Localizable.strings +++ b/iphone/Maps/nb.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Mer"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Bestill"; "placepage_call_button" = "Ring"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Spar penger når du bestiller hotell"; "whats_new_booking_improve_message" = "Søkeresultatene for hoteller inneholder nå priskategori.\nVi har også lagt til flere enn 110.000 hoteller."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/nl.lproj/Localizable.strings b/iphone/Maps/nl.lproj/Localizable.strings index a86870baaa..7ec5db7cf1 100644 --- a/iphone/Maps/nl.lproj/Localizable.strings +++ b/iphone/Maps/nl.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Meer"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Boeken"; "placepage_call_button" = "Bellen"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Bespaar op het boeken van hotels"; "whats_new_booking_improve_message" = "Zoekresultaten voor hotels bevatten nu de prijscategorie.\nWe hebben ook meer dan 110.000 hotels toegevoegd."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/pl.lproj/Localizable.strings b/iphone/Maps/pl.lproj/Localizable.strings index 07723f74a7..2f2dd28875 100644 --- a/iphone/Maps/pl.lproj/Localizable.strings +++ b/iphone/Maps/pl.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Więcej"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Zarezerwuj"; "placepage_call_button" = "Zadzwoń"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Oszczędzaj przy rezerwacji hotelów"; "whats_new_booking_improve_message" = "Wyniki wyszukiwania hoteli zawierają teraz kategorię cenową. \nDodaliśmy też ponad 110 000 hoteli."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/pt.lproj/Localizable.strings b/iphone/Maps/pt.lproj/Localizable.strings index fcb25c47f5..3838cbc7f0 100644 --- a/iphone/Maps/pt.lproj/Localizable.strings +++ b/iphone/Maps/pt.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Mais"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Livro"; "placepage_call_button" = "Chamada"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Poupe nas reservas de hotéis"; "whats_new_booking_improve_message" = "Agora, os resultados da pesquisa de hotéis contêm a categoria de preços.\nAdicinámos mais de 110.000 hotéis."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/ro.lproj/Localizable.strings b/iphone/Maps/ro.lproj/Localizable.strings index 115a126eeb..9059c1fb09 100644 --- a/iphone/Maps/ro.lproj/Localizable.strings +++ b/iphone/Maps/ro.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Mai multe"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Rezervare"; "placepage_call_button" = "Apel"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Economisiți bani când rezervați hoteluri"; "whats_new_booking_improve_message" = "Rezultatele de căutare pentru hoteluri conțin acum categoria de preț. \nAm mai adăugat și peste 110.000 de hoteluri."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/ru.lproj/Localizable.strings b/iphone/Maps/ru.lproj/Localizable.strings index 0d81dae310..2b9a8b64ff 100644 --- a/iphone/Maps/ru.lproj/Localizable.strings +++ b/iphone/Maps/ru.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Ещё"; +"placepage_more_reviews_button" = "Ещё отзывы"; + "bookingcom_book_button" = "Забронировать"; "placepage_call_button" = "Позвонить"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Экономь на бронировании отеля"; "whats_new_booking_improve_message" = "Результаты поиска отелей на карте показывают ценовую категорию.\nОтелей для бронирования стало на 110 000 больше."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Удобства"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Рядом"; diff --git a/iphone/Maps/sk.lproj/Localizable.strings b/iphone/Maps/sk.lproj/Localizable.strings index 30ec214553..69df26c6b2 100644 --- a/iphone/Maps/sk.lproj/Localizable.strings +++ b/iphone/Maps/sk.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Viac"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Rezervovať"; "placepage_call_button" = "Zavolať"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Ušetriť pri rezervácii hotelov"; "whats_new_booking_improve_message" = "Výsledky vyhľadávania hotelov odteraz obsahujú aj cenové kategórie. \nTiež sme pridali viac ako 110 000 hotelov."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/sv.lproj/Localizable.strings b/iphone/Maps/sv.lproj/Localizable.strings index 3a94aca6e6..9b8dbef222 100644 --- a/iphone/Maps/sv.lproj/Localizable.strings +++ b/iphone/Maps/sv.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Mer"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Boka"; "placepage_call_button" = "Ring"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Spara pengar när du bokar hotell"; "whats_new_booking_improve_message" = "Sökresultat för hotell innehåller nu priskategorin.\nVi har även lagt till över 110 000 hotell."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/th.lproj/Localizable.strings b/iphone/Maps/th.lproj/Localizable.strings index f4bb0add13..a517e7283b 100644 --- a/iphone/Maps/th.lproj/Localizable.strings +++ b/iphone/Maps/th.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "เพิ่มเติม"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "จอง"; "placepage_call_button" = "โทร"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "ประหยัดเมื่อจองโรงแรม"; "whats_new_booking_improve_message" = "การค้นหาโรงแรมตอนนี้มีหมวดหมู่ราคาแล้ว\nเรายังได้เพิ่มโรงแรมเข้ามากว่า 110,000 โรงแรมอีกด้วย"; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/tr.lproj/Localizable.strings b/iphone/Maps/tr.lproj/Localizable.strings index af765d0166..d7c37f3c5f 100644 --- a/iphone/Maps/tr.lproj/Localizable.strings +++ b/iphone/Maps/tr.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Diğer"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Rezervasyon"; "placepage_call_button" = "Çağrı"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Otel rezervasyonlarınızdan tasarruf edin"; "whats_new_booking_improve_message" = "Artık otel arama sonuçlarında fiyat kategorisi de gösteriliyor.\nVe 110,000'den fazla oteli sistemimize ekledik."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/uk.lproj/Localizable.strings b/iphone/Maps/uk.lproj/Localizable.strings index 6173e5da24..8da372ebd8 100644 --- a/iphone/Maps/uk.lproj/Localizable.strings +++ b/iphone/Maps/uk.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Ще"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Забронювати"; "placepage_call_button" = "Подзвонити"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Заощаджуйте на бронюванні готелів"; "whats_new_booking_improve_message" = "В результатах пошуку готелів на карті відображається цінова категорія.\nКрім того, тепер у нашій базі даних з'явилося 110 000 нових готелів."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/vi.lproj/Localizable.strings b/iphone/Maps/vi.lproj/Localizable.strings index 85e0479fe5..92e93d5910 100644 --- a/iphone/Maps/vi.lproj/Localizable.strings +++ b/iphone/Maps/vi.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "Bổ sung"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "Đặt trước"; "placepage_call_button" = "Gọi"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "Tiết kiệm khi đặt khách sạn"; "whats_new_booking_improve_message" = "Kết quả tìm kiếm cho khách sạn giờ đã có bậc giá cả.\nChúng tôi cũng đã bổ sung hơn 110.000 khách sạn."; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/zh-Hans.lproj/Localizable.strings b/iphone/Maps/zh-Hans.lproj/Localizable.strings index 72b7e693d1..139aae5d90 100644 --- a/iphone/Maps/zh-Hans.lproj/Localizable.strings +++ b/iphone/Maps/zh-Hans.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "更多"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "预約"; "placepage_call_button" = "呼叫"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "优惠预订酒店"; "whats_new_booking_improve_message" = "酒店的搜索结果现在包含价格类别。\n我们还添加了超过 110,000 家酒店。"; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; diff --git a/iphone/Maps/zh-Hant.lproj/Localizable.strings b/iphone/Maps/zh-Hant.lproj/Localizable.strings index ea8a9f5b89..dc37c16faf 100644 --- a/iphone/Maps/zh-Hant.lproj/Localizable.strings +++ b/iphone/Maps/zh-Hant.lproj/Localizable.strings @@ -1479,6 +1479,8 @@ "placepage_more_button" = "更多"; +"placepage_more_reviews_button" = "More Reviews"; + "bookingcom_book_button" = "預約"; "placepage_call_button" = "呼叫"; @@ -1631,3 +1633,9 @@ "whats_new_booking_improve_title" = "優惠預訂飯店"; "whats_new_booking_improve_message" = "飯店搜尋結果現在還包含價格類別。\n我們還加入了超過 110,000 間飯店。"; + +/* For place page hotel facilities block */ +"placepage_hotel_facilities" = "Facilities"; + +/* For place page hotel nearby block */ +"placepage_hotel_nearby" = "Nearby"; From edcb5ba0640d1481be99d69b615a0e9a94c03969 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Mon, 26 Sep 2016 13:05:54 +0400 Subject: [PATCH 21/26] [android] Added night theme resources for place page rating block. --- android/res/drawable/bg_circle_green.xml | 4 +-- .../res/drawable/bg_circle_green_night.xml | 8 +++++ android/res/drawable/bg_circle_red.xml | 4 +-- android/res/drawable/bg_circle_red_night.xml | 8 +++++ .../res/drawable/ic_negative_review_night.xml | 15 +++++++++ .../res/drawable/ic_positive_review_night.xml | 15 +++++++++ android/res/layout/item_comment.xml | 26 +++++++-------- android/res/layout/item_rating.xml | 33 ++++++++++--------- .../res/layout/place_page_hotel_rating.xml | 30 ++++++++--------- android/res/values/colors.xml | 4 +++ android/res/values/dimens.xml | 2 +- android/res/values/themes-attrs.xml | 4 +++ android/res/values/themes-base.xml | 10 ++++++ 13 files changed, 114 insertions(+), 49 deletions(-) create mode 100644 android/res/drawable/bg_circle_green_night.xml create mode 100644 android/res/drawable/bg_circle_red_night.xml create mode 100644 android/res/drawable/ic_negative_review_night.xml create mode 100644 android/res/drawable/ic_positive_review_night.xml diff --git a/android/res/drawable/bg_circle_green.xml b/android/res/drawable/bg_circle_green.xml index 31d0db282b..8d3ca03796 100644 --- a/android/res/drawable/bg_circle_green.xml +++ b/android/res/drawable/bg_circle_green.xml @@ -2,6 +2,6 @@ + android:height="@dimen/placepage_margin_rating" + android:width="@dimen/placepage_margin_rating"/> \ No newline at end of file diff --git a/android/res/drawable/bg_circle_green_night.xml b/android/res/drawable/bg_circle_green_night.xml new file mode 100644 index 0000000000..59127c39ac --- /dev/null +++ b/android/res/drawable/bg_circle_green_night.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/android/res/drawable/bg_circle_red.xml b/android/res/drawable/bg_circle_red.xml index 3de65a6bc3..a3c80e6627 100644 --- a/android/res/drawable/bg_circle_red.xml +++ b/android/res/drawable/bg_circle_red.xml @@ -2,6 +2,6 @@ + android:height="@dimen/placepage_margin_rating" + android:width="@dimen/placepage_margin_rating"/> \ No newline at end of file diff --git a/android/res/drawable/bg_circle_red_night.xml b/android/res/drawable/bg_circle_red_night.xml new file mode 100644 index 0000000000..61cb40cf65 --- /dev/null +++ b/android/res/drawable/bg_circle_red_night.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/android/res/drawable/ic_negative_review_night.xml b/android/res/drawable/ic_negative_review_night.xml new file mode 100644 index 0000000000..475fd403dc --- /dev/null +++ b/android/res/drawable/ic_negative_review_night.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/android/res/drawable/ic_positive_review_night.xml b/android/res/drawable/ic_positive_review_night.xml new file mode 100644 index 0000000000..317ce7719c --- /dev/null +++ b/android/res/drawable/ic_positive_review_night.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/android/res/layout/item_comment.xml b/android/res/layout/item_comment.xml index 6718f94d4c..5d193788a8 100644 --- a/android/res/layout/item_comment.xml +++ b/android/res/layout/item_comment.xml @@ -70,11 +70,11 @@ android:layout_height="wrap_content" android:layout_below="@id/tv__comment_date"> + 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="?ppPositive"/> + 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="?ppNegative"/> - \ No newline at end of file + diff --git a/android/res/layout/item_rating.xml b/android/res/layout/item_rating.xml index 29b625fcd3..f426782160 100644 --- a/android/res/layout/item_rating.xml +++ b/android/res/layout/item_rating.xml @@ -1,22 +1,23 @@ + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="@dimen/placepage_margin_rating" + android:paddingBottom="@dimen/margin_base" + android:paddingLeft="@dimen/margin_base" + android:paddingRight="@dimen/margin_base" + android:background="?ppRatingBackground"> + android:id="@+id/tv__place_hotel_rating" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textAppearance="@style/MwmTextAppearance.Body1" + android:textColor="?ppRatingText" + tools:text="Rating: 8.7 (Excellent)"/> - \ 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 2b47b9da2a..be2c248f85 100644 --- a/android/res/layout/place_page_hotel_rating.xml +++ b/android/res/layout/place_page_hotel_rating.xml @@ -9,22 +9,22 @@ tools:visibility="visible"> + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="@dimen/placepage_margin_rating" + android:paddingBottom="@dimen/margin_base" + android:paddingLeft="@dimen/margin_base" + android:paddingRight="@dimen/margin_base" + android:background="?ppRatingBackground"> + android:id="@+id/tv__place_hotel_rating" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textAppearance="@style/MwmTextAppearance.Body1" + android:textColor="?ppRatingText" + tools:text="Rating: 8.7 (Excellent)"/> - \ No newline at end of file + diff --git a/android/res/values/colors.xml b/android/res/values/colors.xml index 4a0e25c9ea..0e9f2bfe07 100644 --- a/android/res/values/colors.xml +++ b/android/res/values/colors.xml @@ -35,6 +35,7 @@ #66FFFFFF #568B2E + #46A046 #FFEEEEEE @@ -63,8 +64,11 @@ #FFFFFFFF #F1F8E9 + #1EF0FAEB #DCEDC8 + #1EF0FAEB #FFCDD2 + #1EFFEBF0 @color/button_normal diff --git a/android/res/values/dimens.xml b/android/res/values/dimens.xml index a7cdd8663d..5b0b11489f 100644 --- a/android/res/values/dimens.xml +++ b/android/res/values/dimens.xml @@ -154,6 +154,6 @@ 24dp - 20dp + 20dp diff --git a/android/res/values/themes-attrs.xml b/android/res/values/themes-attrs.xml index da4c68bd8e..ea638e55b7 100644 --- a/android/res/values/themes-attrs.xml +++ b/android/res/values/themes-attrs.xml @@ -24,6 +24,10 @@ + + + + diff --git a/android/res/values/themes-base.xml b/android/res/values/themes-base.xml index be39a44486..bc57ba64b7 100644 --- a/android/res/values/themes-base.xml +++ b/android/res/values/themes-base.xml @@ -75,6 +75,11 @@ @color/routing_button_tint @color/routing_button_pressed_tint + + @color/bg_placepage_rating + @color/text_placepage_rating + @drawable/ic_positive_review + @drawable/ic_negative_review @@ -152,5 +157,10 @@ @color/routing_button_tint @color/routing_button_pressed_tint + + @color/bg_placepage_rating_night + @color/text_placepage_rating_night + @drawable/ic_positive_review_night + @drawable/ic_negative_review_night \ No newline at end of file From 79300a23ee39492d7884de092cac1a20bd55cf09 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Fri, 23 Sep 2016 10:38:50 +0400 Subject: [PATCH 22/26] [android] Review fixes. --- android/AndroidManifest.xml | 92 +- android/build.gradle | 19 +- android/jni/com/mapswithme/maps/Framework.cpp | 3 +- android/jni/com/mapswithme/maps/Framework.hpp | 3 +- .../com/mapswithme/maps/SponsoredHotel.cpp | 151 +- android/res/drawable/bg_circle_green.xml | 9 +- android/res/drawable/bg_circle_red.xml | 9 +- android/res/drawable/divider_transparent.xml | 2 +- .../res/drawable/ic_chevron_right_white.xml | 6 +- android/res/drawable/ic_minus_red.xml | 10 +- android/res/drawable/ic_negative_review.xml | 22 +- android/res/drawable/ic_plus_green.xml | 10 +- android/res/drawable/ic_positive_review.xml | 22 +- .../layout/activity_full_screen_gallery.xml | 94 ++ ...activity_viewpager_transparent_toolbar.xml | 94 -- .../res/layout/fragment_fullscreen_image.xml | 8 +- android/res/layout/fragment_gallery.xml | 16 +- android/res/layout/fragment_review.xml | 10 +- android/res/layout/item_comment.xml | 162 +-- android/res/layout/item_facility.xml | 18 +- android/res/layout/item_gallery.xml | 32 +- android/res/layout/item_image.xml | 22 +- android/res/layout/item_more_button.xml | 12 +- android/res/layout/item_nearby.xml | 82 +- android/res/layout/item_rating.xml | 12 +- .../layout/place_page_hotel_description.xml | 48 +- .../layout/place_page_hotel_facilities.xml | 46 +- .../res/layout/place_page_hotel_gallery.xml | 10 +- .../res/layout/place_page_hotel_nearby.xml | 24 +- .../res/layout/place_page_hotel_rating.xml | 44 +- android/res/layout/toolbar_transparent.xml | 12 +- android/res/values-v16/styles-text.xml | 10 +- android/res/values/integer.xml | 3 +- android/res/values/plurals.xml | 11 + android/res/values/strings.xml | 1214 ++++++++--------- android/res/values/styles-place_page.xml | 2 +- android/res/values/styles-text.xml | 12 +- android/res/values/styles.xml | 61 +- android/res/values/themes.xml | 2 +- .../maps/base/BaseMwmExtraTitleActivity.java | 43 + .../gallery/FullScreenGalleryActivity.java | 139 +- .../gallery/FullScreenGalleryFragment.java | 31 +- .../maps/gallery/GalleryActivity.java | 43 +- .../maps/gallery/GalleryFragment.java | 37 +- .../maps/gallery/GalleryPageAdapter.java | 18 +- .../com/mapswithme/maps/gallery/Image.java | 146 +- .../mapswithme/maps/gallery/ImageAdapter.java | 53 +- .../com/mapswithme/maps/review/Review.java | 68 +- .../maps/review/ReviewActivity.java | 46 +- .../mapswithme/maps/review/ReviewAdapter.java | 128 +- .../maps/review/ReviewFragment.java | 35 +- .../maps/widget/LineCountTextView.java | 28 +- .../maps/widget/StaticGridView.java | 15 +- .../widget/placepage/FacilitiesAdapter.java | 59 +- .../maps/widget/placepage/GalleryAdapter.java | 188 ++- .../LeftPlacePageAnimationController.java | 43 +- .../maps/widget/placepage/NearbyAdapter.java | 85 +- .../maps/widget/placepage/PlacePageView.java | 637 +++++---- .../maps/widget/placepage/ReviewAdapter.java | 90 +- .../maps/widget/placepage/SponsoredHotel.java | 257 ++-- .../recycler/DividerItemDecoration.java | 49 +- .../recycler/GridDividerItemDecoration.java | 62 +- android/src/com/mapswithme/util/UiUtils.java | 20 + map/booking_api.cpp | 2 +- strings.txt | 14 + 65 files changed, 2597 insertions(+), 2158 deletions(-) create mode 100644 android/res/layout/activity_full_screen_gallery.xml delete mode 100644 android/res/layout/activity_viewpager_transparent_toolbar.xml create mode 100644 android/res/values/plurals.xml create mode 100644 android/src/com/mapswithme/maps/base/BaseMwmExtraTitleActivity.java diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 95c0151f2b..af1a0b02e9 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -71,11 +71,11 @@ + android:value="${PW_APPID}"/> + android:value="${PW_PROJECT_ID}"/> + android:name="android.support.PARENT_ACTIVITY" + android:value="com.mapswithme.maps.MwmActivity"/> + android:name="com.mapswithme.maps.editor.ProfileActivity" + android:parentActivityName="com.mapswithme.maps.settings.SettingsActivity"> + android:name="android.support.PARENT_ACTIVITY" + android:value="com.mapswithme.maps.settings.SettingsActivity"/> + android:name="com.mapswithme.maps.editor.FeatureCategoryActivity" + android:parentActivityName="com.mapswithme.maps.MwmActivity"> + android:name="android.support.PARENT_ACTIVITY" + android:value="com.mapswithme.maps.MwmActivity"/> + android:name="com.mapswithme.maps.editor.ReportActivity" + android:parentActivityName="com.mapswithme.maps.MwmActivity"> + android:name="android.support.PARENT_ACTIVITY" + android:value="com.mapswithme.maps.MwmActivity"/> + android:name="com.mapswithme.maps.editor.OsmAuthActivity" + android:parentActivityName="com.mapswithme.maps.MwmActivity"> + android:name="android.support.PARENT_ACTIVITY" + android:value="com.mapswithme.maps.MwmActivity"/> + android:name="com.mapswithme.maps.gallery.GalleryActivity" + android:parentActivityName="com.mapswithme.maps.MwmActivity"> + android:name="android.support.PARENT_ACTIVITY" + android:value="com.mapswithme.maps.MwmActivity"/> + android:name="com.mapswithme.maps.gallery.FullScreenGalleryActivity" + android:parentActivityName="com.mapswithme.maps.MwmActivity"> + android:name="android.support.PARENT_ACTIVITY" + android:value="com.mapswithme.maps.MwmActivity"/> + android:name="com.mapswithme.maps.review.ReviewActivity" + android:parentActivityName="com.mapswithme.maps.MwmActivity"> + android:name="android.support.PARENT_ACTIVITY" + android:value="com.mapswithme.maps.MwmActivity"/> @@ -373,17 +373,17 @@ - - - + + + + android:permission="com.google.android.c2dm.permission.SEND"> - - + + @@ -405,10 +405,10 @@ + android:exported="false"/> + android:name="com.pushwoosh.location.GeoLocationService"/> diff --git a/android/build.gradle b/android/build.gradle index ad41954325..1f1c3b43f7 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -95,15 +95,15 @@ android { // Crashlytics API key Properties props = new Properties() props.load(new FileInputStream("${projectDir}/fabric.properties")); - manifestPlaceholders = [ 'FABRIC_API_KEY': props['apiKey'] ] + manifestPlaceholders = ['FABRIC_API_KEY': props['apiKey']] buildConfigField 'String', 'FABRIC_API_KEY', /"${props['apiKey']}"/ // PushWoosh keys Properties pwProps = new Properties() pwProps.load(new FileInputStream("${projectDir}/pushwoosh.properties")); - manifestPlaceholders += [ 'PW_APPID': pwProps['pwAppId'] ] + manifestPlaceholders += ['PW_APPID': pwProps['pwAppId']] buildConfigField 'String', 'PW_APPID', /"${pwProps['pwAppId']}"/ - manifestPlaceholders += [ 'PW_PROJECT_ID': pwProps['pwProjectId'] ] + manifestPlaceholders += ['PW_PROJECT_ID': pwProps['pwProjectId']] } sourceSets.main { @@ -212,13 +212,6 @@ android { android.sourceSets.blackberry.assets.srcDirs = ['flavors/mwm-ttf-assets'] buildConfigField 'String', 'REVIEW_URL', '"https://appworld.blackberry.com/webstore/content/51013892"' } - - nineStore { - versionName = android.defaultConfig.versionName + '-NineStore' - android.sourceSets.blackberry.assets.srcDirs = ['flavors/mwm-ttf-assets'] - buildConfigField 'String', 'SUPPORT_MAIL', '"ninestore@mapswithme.com"' - buildConfigField 'String', 'REVIEW_URL', '"http://www.ninestore.ru/android-apps/mapswithme-maps-pro"' - } } // Currently (as of 1.2.3 gradle plugin) ABI filters aren't supported inside of product flavors, so we cannot generate splitted builds only for Google build. @@ -333,7 +326,7 @@ if (System.properties['os.name'].toLowerCase().contains('windows')) project.ext.NDK_BUILD += ".cmd" def archs = ['x86', 'armeabi-v7a-hard'] -def buildTypes = [[ndkType: 'release', cppType: "production", flags : propReleaseNdkFlags], [ndkType: 'debug', cppType: "debug", flags : propDebugNdkFlags]] +def buildTypes = [[ndkType: 'release', cppType: "production", flags: propReleaseNdkFlags], [ndkType: 'debug', cppType: "debug", flags: propDebugNdkFlags]] buildTypes.each { type -> def suffix = type.ndkType.capitalize() @@ -410,14 +403,14 @@ obbGenerate.dependsOn obbClean, obbMainGenerate, obbPatchGenerate, obbMainAlign, def createObbGenerateTask(type, data, name) { return tasks.create(name: "obb${type}Generate", type: Exec, description: 'Generate obb files') { - commandLine ((['zip', '-0', '-j', name, data]).flatten()) + commandLine((['zip', '-0', '-j', name, data]).flatten()) } } def createObbAlignTask(type, rawObb, alignedObb) { def sdkDir = "${android.getSdkDirectory().getAbsolutePath()}" def zipalignPath = sdkDir + File.separator + "build-tools" + File.separator + - propBuildToolsVersion + File.separator + "zipalign"; + propBuildToolsVersion + File.separator + "zipalign"; return tasks.create(name: "obb${type}Align", dependsOn: "obb${type}Generate", type: Exec, description: 'Align obb files') { commandLine zipalignPath, '-v', '8', rawObb, alignedObb diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 67412a3c7c..361dba42b5 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -476,7 +476,8 @@ void Framework::RequestBookingMinPrice(string const & hotelId, string const & cu return m_work.GetBookingApi().GetMinPrice(hotelId, currencyCode, callback); } -void Framework::RequestBookingInfo(string const & hotelId, string const & lang, function const & callback) +void Framework::RequestBookingInfo(string const & hotelId, string const & lang, + function const & callback) { return m_work.GetBookingApi().GetHotelInfo(hotelId, lang, callback); } diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index b7962696c7..12fcdcd85d 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -155,7 +155,8 @@ namespace android void SetPlacePageInfo(place_page::Info const & info); place_page::Info & GetPlacePageInfo(); void RequestBookingMinPrice(string const & hotelId, string const & currency, function const & callback); - void RequestBookingInfo(string const & hotelId, string const & lang, function const & callback); + void RequestBookingInfo(string const & hotelId, string const & lang, + function const & callback); bool HasSpaceForMigration(); storage::TCountryId PreMigrate(ms::LatLon const & position, storage::Storage::TChangeCountryFunction const & statusChangeListener, diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp index 86291b6113..1eb94e0e1b 100644 --- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp +++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp @@ -2,14 +2,15 @@ #include "../core/jni_helper.hpp" #include "../platform/Platform.hpp" -#include "map/place_page_info.hpp" #include "map/booking_api.hpp" +#include "map/place_page_info.hpp" #include "std/bind.hpp" +using namespace std::chrono; + namespace { - jclass g_hotelClass; jclass g_facilityTypeClass; jclass g_nearbyObjectClass; @@ -21,7 +22,7 @@ jmethodID g_nearbyConstructor; jmethodID g_imageConstructor; jmethodID g_reviewConstructor; jmethodID g_hotelInfoConstructor; -jmethodID g_hotelClassCtor; +jmethodID g_hotelClassConstructor; jmethodID g_priceCallback; jmethodID g_infoCallback; @@ -31,34 +32,51 @@ void PrepareClassRefs(JNIEnv * env, jclass hotelClass) return; g_hotelClass = static_cast(env->NewGlobalRef(hotelClass)); - g_hotelInfoClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$HotelInfo"); - g_facilityTypeClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$FacilityType"); - g_nearbyObjectClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$NearbyObject"); + g_hotelInfoClass = + jni::GetGlobalClassRef(env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$HotelInfo"); + g_facilityTypeClass = jni::GetGlobalClassRef( + env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$FacilityType"); + g_nearbyObjectClass = jni::GetGlobalClassRef( + env, "com/mapswithme/maps/widget/placepage/SponsoredHotel$NearbyObject"); g_reviewClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/review/Review"); g_imageClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/gallery/Image"); - g_facilityConstructor = jni::GetConstructorID(env, g_facilityTypeClass, "(Ljava/lang/String;Ljava/lang/String;)V"); - g_nearbyConstructor = jni::GetConstructorID(env, g_nearbyObjectClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;DD)V"); - g_imageConstructor = jni::GetConstructorID(env, g_imageClass, "(Ljava/lang/String;Ljava/lang/String;)V"); - g_reviewConstructor = jni::GetConstructorID(env, g_reviewClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FJ)V"); - g_hotelInfoConstructor = jni::GetConstructorID(env, g_hotelInfoClass, "(Ljava/lang/String;[Lcom/mapswithme/maps/gallery/Image;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$FacilityType;[Lcom/mapswithme/maps/review/Review;[Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$NearbyObject;)V"); + g_facilityConstructor = + jni::GetConstructorID(env, g_facilityTypeClass, "(Ljava/lang/String;Ljava/lang/String;)V"); + g_nearbyConstructor = jni::GetConstructorID( + env, g_nearbyObjectClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;DD)V"); + g_imageConstructor = + jni::GetConstructorID(env, g_imageClass, "(Ljava/lang/String;Ljava/lang/String;)V"); + g_reviewConstructor = jni::GetConstructorID(env, g_reviewClass, + "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/" + "String;Ljava/lang/String;Ljava/lang/String;FJ)V"); + g_hotelInfoConstructor = jni::GetConstructorID( + env, g_hotelInfoClass, + "(Ljava/lang/String;[Lcom/mapswithme/maps/gallery/Image;[Lcom/mapswithme/maps/widget/" + "placepage/SponsoredHotel$FacilityType;[Lcom/mapswithme/maps/review/Review;[Lcom/mapswithme/" + "maps/widget/placepage/SponsoredHotel$NearbyObject;)V"); // SponsoredHotel(String rating, String price, String urlBook, String urlDescription) - g_hotelClassCtor = jni::GetConstructorID(env, g_hotelClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); + g_hotelClassConstructor = jni::GetConstructorID( + env, g_hotelClass, + "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); // static void onPriceReceived(final String id, final String price, final String currency) - g_priceCallback = jni::GetStaticMethodID(env, g_hotelClass, "onPriceReceived", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); + g_priceCallback = + jni::GetStaticMethodID(env, g_hotelClass, "onPriceReceived", + "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); // static void onDescriptionReceived(final String id, final String description) - g_infoCallback = jni::GetStaticMethodID(env, g_hotelClass, "onInfoReceived", "(Ljava/lang/String;Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$HotelInfo;)V"); + g_infoCallback = jni::GetStaticMethodID( + env, g_hotelClass, "onInfoReceived", + "(Ljava/lang/String;Lcom/mapswithme/maps/widget/placepage/SponsoredHotel$HotelInfo;)V"); } -} // namespace +} // namespace -extern "C" -{ +extern "C" { // static SponsoredHotel nativeGetCurrent(); -JNIEXPORT jobject JNICALL -Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeGetCurrent(JNIEnv * env, jclass clazz) +JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeGetCurrent( + JNIEnv * env, jclass clazz) { PrepareClassRefs(env, clazz); @@ -66,80 +84,79 @@ Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeGetCurrent(JNIEnv if (!ppInfo.m_isSponsoredHotel) return nullptr; - return env->NewObject(g_hotelClass, g_hotelClassCtor, jni::ToJavaString(env, ppInfo.GetRatingFormatted()), - jni::ToJavaString(env, ppInfo.GetApproximatePricing()), - jni::ToJavaString(env, ppInfo.GetSponsoredBookingUrl()), - jni::ToJavaString(env, ppInfo.GetSponsoredDescriptionUrl())); + return env->NewObject(g_hotelClass, g_hotelClassConstructor, + jni::ToJavaString(env, ppInfo.GetRatingFormatted()), + jni::ToJavaString(env, ppInfo.GetApproximatePricing()), + jni::ToJavaString(env, ppInfo.GetSponsoredBookingUrl()), + jni::ToJavaString(env, ppInfo.GetSponsoredDescriptionUrl())); } // static void nativeRequestPrice(String id, String currencyCode); -JNIEXPORT void JNICALL -Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestPrice(JNIEnv * env, jclass clazz, jstring id, jstring currencyCode) +JNIEXPORT void JNICALL Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestPrice( + JNIEnv * env, jclass clazz, jstring id, jstring currencyCode) { PrepareClassRefs(env, clazz); string const hotelId = jni::ToNativeString(env, id); string const code = jni::ToNativeString(env, currencyCode); - g_framework->RequestBookingMinPrice(hotelId, code, [hotelId](string const & price, string const & currency) - { - GetPlatform().RunOnGuiThread([=]() - { + g_framework->RequestBookingMinPrice(hotelId, code, [hotelId](string const & price, + string const & currency) { + GetPlatform().RunOnGuiThread([=]() { JNIEnv * env = jni::GetEnv(); env->CallStaticVoidMethod(g_hotelClass, g_priceCallback, jni::ToJavaString(env, hotelId), - jni::ToJavaString(env, price), - jni::ToJavaString(env, currency)); + jni::ToJavaString(env, price), jni::ToJavaString(env, currency)); }); }); } // static void nativeRequestInfo(String id, String locale); -JNIEXPORT void JNICALL -Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestInfo(JNIEnv * env, jclass clazz, jstring id, jstring locale) +JNIEXPORT void JNICALL Java_com_mapswithme_maps_widget_placepage_SponsoredHotel_nativeRequestInfo( + JNIEnv * env, jclass clazz, jstring id, jstring locale) { PrepareClassRefs(env, clazz); string const hotelId = jni::ToNativeString(env, id); string const code = jni::ToNativeString(env, locale); - g_framework->RequestBookingInfo(hotelId, code, [hotelId](BookingApi::HotelInfo const & hotelInfo) - { - GetPlatform().RunOnGuiThread([=]() - { + g_framework->RequestBookingInfo(hotelId, code, [hotelId]( + BookingApi::HotelInfo const & hotelInfo) { + GetPlatform().RunOnGuiThread([=]() { JNIEnv * env = jni::GetEnv(); + auto description = jni::ToJavaString(env, hotelInfo.m_description); + auto photos = + jni::ToJavaArray(env, g_imageClass, hotelInfo.m_photos, + [](JNIEnv * env, BookingApi::HotelPhotoUrls const & item) { + return env->NewObject(g_imageClass, g_imageConstructor, + jni::ToJavaString(env, item.m_original), + jni::ToJavaString(env, item.m_small)); + }); + auto facilities = + jni::ToJavaArray(env, g_facilityTypeClass, hotelInfo.m_facilities, + [](JNIEnv * env, BookingApi::Facility const & item) { + return env->NewObject(g_facilityTypeClass, g_facilityConstructor, + jni::ToJavaString(env, item.m_id), + jni::ToJavaString(env, item.m_localizedName)); + }); + auto reviews = jni::ToJavaArray( + env, g_reviewClass, hotelInfo.m_reviews, + [](JNIEnv * env, BookingApi::HotelReview const & item) { + return env->NewObject( + g_reviewClass, g_reviewConstructor, jni::ToJavaString(env, item.m_reviewNeutral), + jni::ToJavaString(env, item.m_reviewPositive), + jni::ToJavaString(env, item.m_reviewNegative), + jni::ToJavaString(env, item.m_author), jni::ToJavaString(env, item.m_authorPictUrl), + item.m_rating, + time_point_cast(item.m_date).time_since_epoch().count()); + }); + auto nearby = env->NewObjectArray(0, g_nearbyObjectClass, 0); + env->CallStaticVoidMethod(g_hotelClass, g_infoCallback, jni::ToJavaString(env, hotelId), - env->NewObject(g_hotelInfoClass, g_hotelInfoConstructor, - jni::ToJavaString(env, hotelInfo.m_description), - jni::ToJavaArray(env, g_imageClass, hotelInfo.m_photos, - [](JNIEnv * env, BookingApi::HotelPhotoUrls const & item) - { - return env->NewObject(g_imageClass, g_imageConstructor, - jni::ToJavaString(env, item.m_original), - jni::ToJavaString(env, item.m_small)); - }), - jni::ToJavaArray(env, g_facilityTypeClass, hotelInfo.m_facilities, - [](JNIEnv * env, BookingApi::Facility const & item) - { - return env->NewObject(g_facilityTypeClass, g_facilityConstructor, - jni::ToJavaString(env, item.m_id), - jni::ToJavaString(env, item.m_localizedName)); - }), - jni::ToJavaArray(env, g_reviewClass, hotelInfo.m_reviews, - [](JNIEnv * env, BookingApi::HotelReview const & item) - { - return env->NewObject(g_reviewClass, g_reviewConstructor, - jni::ToJavaString(env, item.m_reviewNeutral), - jni::ToJavaString(env, item.m_reviewPositive), - jni::ToJavaString(env, item.m_reviewNegative), - jni::ToJavaString(env, item.m_author), - jni::ToJavaString(env, item.m_authorPictUrl), - item.m_rating, - std::chrono::time_point_cast(item.m_date).time_since_epoch().count()); - }), - env->NewObjectArray(0, g_nearbyObjectClass, 0))); + env->NewObject(g_hotelInfoClass, g_hotelInfoConstructor, + description, photos, facilities, reviews, nearby)); }); }); } -} // extern "C" +} // extern "C" diff --git a/android/res/drawable/bg_circle_green.xml b/android/res/drawable/bg_circle_green.xml index 8d3ca03796..24f254e751 100644 --- a/android/res/drawable/bg_circle_green.xml +++ b/android/res/drawable/bg_circle_green.xml @@ -1,7 +1,8 @@ - + - \ No newline at end of file + android:height="@dimen/placepage_margin_rating" + android:width="@dimen/placepage_margin_rating"/> + diff --git a/android/res/drawable/bg_circle_red.xml b/android/res/drawable/bg_circle_red.xml index a3c80e6627..c5a44a59a0 100644 --- a/android/res/drawable/bg_circle_red.xml +++ b/android/res/drawable/bg_circle_red.xml @@ -1,7 +1,8 @@ - + - \ No newline at end of file + android:height="@dimen/placepage_margin_rating" + android:width="@dimen/placepage_margin_rating"/> + diff --git a/android/res/drawable/divider_transparent.xml b/android/res/drawable/divider_transparent.xml index 1719475d7f..377b4d7e12 100644 --- a/android/res/drawable/divider_transparent.xml +++ b/android/res/drawable/divider_transparent.xml @@ -3,4 +3,4 @@ - \ No newline at end of file + diff --git a/android/res/drawable/ic_chevron_right_white.xml b/android/res/drawable/ic_chevron_right_white.xml index 490d31b048..0563f22f11 100644 --- a/android/res/drawable/ic_chevron_right_white.xml +++ b/android/res/drawable/ic_chevron_right_white.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> - + diff --git a/android/res/drawable/ic_minus_red.xml b/android/res/drawable/ic_minus_red.xml index 411438dca0..b108146e81 100644 --- a/android/res/drawable/ic_minus_red.xml +++ b/android/res/drawable/ic_minus_red.xml @@ -1,4 +1,8 @@ - - + + diff --git a/android/res/drawable/ic_negative_review.xml b/android/res/drawable/ic_negative_review.xml index 7d75805c7d..a28a8a5646 100644 --- a/android/res/drawable/ic_negative_review.xml +++ b/android/res/drawable/ic_negative_review.xml @@ -1,15 +1,15 @@ + 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"/> - \ No newline at end of file + 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"/> + diff --git a/android/res/drawable/ic_plus_green.xml b/android/res/drawable/ic_plus_green.xml index 10385ed4eb..d8e49364af 100644 --- a/android/res/drawable/ic_plus_green.xml +++ b/android/res/drawable/ic_plus_green.xml @@ -1,4 +1,8 @@ - - + + diff --git a/android/res/drawable/ic_positive_review.xml b/android/res/drawable/ic_positive_review.xml index 8d0948109f..e3fc607c73 100644 --- a/android/res/drawable/ic_positive_review.xml +++ b/android/res/drawable/ic_positive_review.xml @@ -1,15 +1,15 @@ + 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"/> - \ No newline at end of file + 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"/> + diff --git a/android/res/layout/activity_full_screen_gallery.xml b/android/res/layout/activity_full_screen_gallery.xml new file mode 100644 index 0000000000..69411ca818 --- /dev/null +++ b/android/res/layout/activity_full_screen_gallery.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/android/res/layout/activity_viewpager_transparent_toolbar.xml b/android/res/layout/activity_viewpager_transparent_toolbar.xml deleted file mode 100644 index 8abdb88b0f..0000000000 --- a/android/res/layout/activity_viewpager_transparent_toolbar.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/android/res/layout/fragment_fullscreen_image.xml b/android/res/layout/fragment_fullscreen_image.xml index bd7207d7b4..2894f973c2 100644 --- a/android/res/layout/fragment_fullscreen_image.xml +++ b/android/res/layout/fragment_fullscreen_image.xml @@ -6,8 +6,8 @@ android:background="@android:color/black"> + android:id="@+id/iv__image" + android:layout_width="match_parent" + android:layout_height="match_parent"/> - \ No newline at end of file + diff --git a/android/res/layout/fragment_gallery.xml b/android/res/layout/fragment_gallery.xml index ebb841f3ec..840069a296 100644 --- a/android/res/layout/fragment_gallery.xml +++ b/android/res/layout/fragment_gallery.xml @@ -6,12 +6,12 @@ android:layout_height="match_parent"> + android:id="@+id/rv__gallery" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingLeft="@dimen/margin_half" + android:paddingRight="@dimen/margin_half" + android:paddingTop="@dimen/margin_half_plus" + tools:listitem="@layout/item_image"/> - \ No newline at end of file + diff --git a/android/res/layout/fragment_review.xml b/android/res/layout/fragment_review.xml index 1cf112d06e..a8d0336aee 100644 --- a/android/res/layout/fragment_review.xml +++ b/android/res/layout/fragment_review.xml @@ -6,8 +6,8 @@ android:layout_height="match_parent" android:background="?cardBackground"> - \ No newline at end of file + android:id="@+id/rv__review" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:listitem="@layout/item_comment"/> + diff --git a/android/res/layout/item_comment.xml b/android/res/layout/item_comment.xml index 5d193788a8..7497d9c945 100644 --- a/android/res/layout/item_comment.xml +++ b/android/res/layout/item_comment.xml @@ -5,70 +5,70 @@ android:layout_height="wrap_content"> + 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"/> + android:id="@+id/tv__user_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__user_rating" + android:layout_toStartOf="@+id/tv__user_rating" + android:layout_below="@id/v__divider" + android:textAppearance="@style/MwmTextAppearance.Body1" + tools:text="Аleksey"/> + 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"/> + 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"/> + android:id="@+id/tv__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_marginBottom="@dimen/margin_base" + android:layout_below="@id/tv__comment_date" + android:textAppearance="@style/MwmTextAppearance.Body3.Primary" + android:visibility="gone" + 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."/> + 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"> + 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."/> + 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"> + 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"/> diff --git a/android/res/layout/item_facility.xml b/android/res/layout/item_facility.xml index aabc553c69..69790a57e5 100644 --- a/android/res/layout/item_facility.xml +++ b/android/res/layout/item_facility.xml @@ -11,14 +11,14 @@ tools:visibility="visible"> + android:id="@+id/iv__icon" + style="@style/PlacePageMetadataIcon" + android:src="@drawable/ic_entrance"/> - \ No newline at end of file + android:id="@+id/tv__facility" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textAppearance="@style/MwmTextAppearance.Body3.Primary" + tools:text="Pets are allowed on request"/> + diff --git a/android/res/layout/item_gallery.xml b/android/res/layout/item_gallery.xml index 3712672871..ae725d082b 100644 --- a/android/res/layout/item_gallery.xml +++ b/android/res/layout/item_gallery.xml @@ -1,22 +1,22 @@ + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="@dimen/placepage_hotel_gallery_width" + android:layout_height="@dimen/placepage_hotel_gallery_height" + android:clickable="true" + android:focusable="true" + android:foreground="?attr/selectableItemBackground"> + android:id="@+id/iv__image" + android:layout_width="@dimen/placepage_hotel_gallery_width" + android:layout_height="@dimen/placepage_hotel_gallery_height" + tools:src="@color/base_green"/> - \ No newline at end of file + android:id="@+id/tv__more" + style="@style/PlacePageGalleryText" + android:text="@string/placepage_more_button" + android:visibility="gone" + tools:visibility="visible"/> + diff --git a/android/res/layout/item_image.xml b/android/res/layout/item_image.xml index 5c3443e5c1..9cc9280539 100644 --- a/android/res/layout/item_image.xml +++ b/android/res/layout/item_image.xml @@ -1,15 +1,15 @@ + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="@dimen/gallery_image_height" + android:clickable="true" + android:focusable="true" + android:foreground="?attr/selectableItemBackground"> - \ No newline at end of file + android:id="@+id/iv__image" + android:layout_width="match_parent" + android:layout_height="@dimen/gallery_image_height" + tools:src="@color/base_green"/> + diff --git a/android/res/layout/item_more_button.xml b/android/res/layout/item_more_button.xml index e4e113952d..8854ec9750 100644 --- a/android/res/layout/item_more_button.xml +++ b/android/res/layout/item_more_button.xml @@ -1,8 +1,8 @@ \ No newline at end of file + xmlns:android="http://schemas.android.com/apk/res/android" + style="@style/PlacePageMetadataText.Button" + android:height="@dimen/height_block_base" + android:background="?clickableBackground" + android:gravity="center" + android:text="@string/placepage_more_reviews_button"/> diff --git a/android/res/layout/item_nearby.xml b/android/res/layout/item_nearby.xml index 4b5a28003a..da838d14bf 100644 --- a/android/res/layout/item_nearby.xml +++ b/android/res/layout/item_nearby.xml @@ -15,52 +15,52 @@ tools:background="#4000FFFF"> + android:id="@+id/iv__icon" + android:layout_width="@dimen/placepage_hotel_nearby_icon_size" + android:layout_height="@dimen/placepage_hotel_nearby_icon_size" + android:layout_centerVertical="true" + tools:src="@color/base_green"/> + android:id="@+id/ll__info" + android:orientation="vertical" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="@dimen/margin_double" + android:layout_marginStart="@dimen/margin_double" + android:layout_centerVertical="true" + android:layout_toRightOf="@id/iv__icon" + android:layout_toEndOf="@id/iv__icon" + android:gravity="center_vertical"> + android:id="@+id/tv__title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:maxLines="1" + android:textAppearance="@style/MwmTextAppearance.Body1" + tools:text="Bowery"/> + android:id="@+id/tv__type" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/margin_quarter" + android:maxLines="1" + android:textAppearance="@style/MwmTextAppearance.Body3" + tools:text="Subway Station"/> - \ No newline at end of file + android:id="@+id/tv__distance" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" + android:layout_centerVertical="true" + android:layout_toRightOf="@id/ll__info" + android:layout_toEndOf="@id/ll__info" + android:maxLines="1" + android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent" + android:gravity="end" + tools:text="800 ft"/> + diff --git a/android/res/layout/item_rating.xml b/android/res/layout/item_rating.xml index f426782160..b079ce2110 100644 --- a/android/res/layout/item_rating.xml +++ b/android/res/layout/item_rating.xml @@ -20,10 +20,10 @@ tools:text="Rating: 8.7 (Excellent)"/> + android:id="@+id/tv__place_hotel_rating_base" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/margin_half" + android:textAppearance="@style/MwmTextAppearance.Body3" + tools:text="Based on 848 hotel reviews"/> diff --git a/android/res/layout/place_page_hotel_description.xml b/android/res/layout/place_page_hotel_description.xml index db3e442da1..9cd23bdf12 100644 --- a/android/res/layout/place_page_hotel_description.xml +++ b/android/res/layout/place_page_hotel_description.xml @@ -11,33 +11,33 @@ tools:visibility="visible"> + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base" + android:layout_marginTop="@dimen/margin_base" + style="@style/PlacePageTitleText" + android:text="@string/details"/> + android:id="@+id/tv__place_hotel_details" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base" + android:layout_marginTop="@dimen/margin_half_plus" + android:layout_marginBottom="@dimen/margin_half_plus" + android:textAppearance="@style/MwmTextAppearance.Body3.Primary" + android:maxLines="@integer/pp_hotel_description_lines" + tools:text="One of our top picks in New York City. This boutique hotel in the Manhattan neighborhood of Nolita features a private rooftop and rooms with free WiFi. The Bowery subway station is 1 block from this New York hotel."/> + android:id="@+id/tv__place_hotel_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_button"/> - \ No newline at end of file + diff --git a/android/res/layout/place_page_hotel_facilities.xml b/android/res/layout/place_page_hotel_facilities.xml index a8bab592f9..d126cbbe70 100644 --- a/android/res/layout/place_page_hotel_facilities.xml +++ b/android/res/layout/place_page_hotel_facilities.xml @@ -11,32 +11,32 @@ tools:visibility="visible"> + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base" + android:layout_marginTop="@dimen/margin_base" + style="@style/PlacePageTitleText" + android:text="@string/placepage_hotel_facilities"/> + android:id="@+id/gv__place_hotel_facilities" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base" + android:layout_marginTop="@dimen/margin_base" + android:layout_marginBottom="@dimen/margin_base" + android:numColumns="2" + tools:listitem="@layout/item_facility"/> + android:id="@+id/tv__place_hotel_facilities_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_button"/> - \ No newline at end of file + diff --git a/android/res/layout/place_page_hotel_gallery.xml b/android/res/layout/place_page_hotel_gallery.xml index 11b81db657..3b964ea024 100644 --- a/android/res/layout/place_page_hotel_gallery.xml +++ b/android/res/layout/place_page_hotel_gallery.xml @@ -10,8 +10,8 @@ tools:visibility="visible"> - \ No newline at end of file + android:id="@+id/rv__place_hotel_gallery" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:listitem="@layout/item_gallery"/> + diff --git a/android/res/layout/place_page_hotel_nearby.xml b/android/res/layout/place_page_hotel_nearby.xml index 13810b7db2..ea675113cb 100644 --- a/android/res/layout/place_page_hotel_nearby.xml +++ b/android/res/layout/place_page_hotel_nearby.xml @@ -13,17 +13,17 @@ + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base" + android:layout_marginTop="@dimen/margin_base" + style="@style/PlacePageTitleText" + android:text="@string/placepage_hotel_nearby"/> - \ No newline at end of file + android:id="@+id/gv__place_hotel_nearby" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/margin_quarter" + android:numColumns="1" + tools:listitem="@layout/item_nearby"/> + diff --git a/android/res/layout/place_page_hotel_rating.xml b/android/res/layout/place_page_hotel_rating.xml index be2c248f85..864e64538d 100644 --- a/android/res/layout/place_page_hotel_rating.xml +++ b/android/res/layout/place_page_hotel_rating.xml @@ -27,32 +27,32 @@ tools:text="Rating: 8.7 (Excellent)"/> + android:id="@+id/tv__place_hotel_rating_base" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/margin_half" + android:textAppearance="@style/MwmTextAppearance.Body3" + tools:text="Based on 848 hotel reviews"/> + android:id="@+id/gv__place_hotel_review" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:numColumns="1" + tools:listitem="@layout/item_comment"/> + android:layout_width="match_parent" + android:layout_height="1dp" + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base" + android:background="?dividerHorizontal"/> + 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"/> diff --git a/android/res/layout/toolbar_transparent.xml b/android/res/layout/toolbar_transparent.xml index 7eb9e7d32f..9a18440d8d 100644 --- a/android/res/layout/toolbar_transparent.xml +++ b/android/res/layout/toolbar_transparent.xml @@ -1,8 +1,8 @@ \ No newline at end of file + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/toolbar" + style="@style/MwmWidget.ToolbarStyle" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:theme="@style/MwmWidget.ToolbarTheme.Transparent"/> diff --git a/android/res/values-v16/styles-text.xml b/android/res/values-v16/styles-text.xml index a9ba1ab5b2..03e6be2368 100644 --- a/android/res/values-v16/styles-text.xml +++ b/android/res/values-v16/styles-text.xml @@ -1,7 +1,7 @@ - - \ No newline at end of file + + diff --git a/android/res/values/integer.xml b/android/res/values/integer.xml index 1eb091d22b..cebfdf8b74 100644 --- a/android/res/values/integer.xml +++ b/android/res/values/integer.xml @@ -2,6 +2,7 @@ 5 4 + 5 2 - \ No newline at end of file + diff --git a/android/res/values/plurals.xml b/android/res/values/plurals.xml new file mode 100644 index 0000000000..92249cb081 --- /dev/null +++ b/android/res/values/plurals.xml @@ -0,0 +1,11 @@ + + + + Based on %d hotel reviews + Based on %d hotel reviews + Based on %d hotel reviews + Based on %d hotel reviews + Based on %d hotel reviews + Based on %d hotel reviews + + diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index 39fb5359bf..e19925317d 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -3,614 +3,614 @@ - - - About - - Back - - Cancel - - Cancel Download - - Delete - - Do not ask me again - - Continue - Download Maps - - Download %qu kB - - Download %qu MB - - Download has failed, touch again for one more try - - Downloaded (%1$qu %2$s), touch to delete - - Downloading %qu%%, touch to cancel - - Downloading… - Get it now - - Thank you for using MAPS.ME! Do you like the app? Tell your friends about it! This is the best thanks you could give us. - - kB - - Kilometers - - Leave a Review - - Maps - - Maps: - - Marked for downloading, touch to cancel - - MB - GB - - Miles - - My Position - OK - - Please free some space on your device first in order to download %s - - Remind me later - - Later - - Never - - Report an issue - - Search - - Search Map - - Touch to download - - Yes - - We recommend using WiFi to download large maps - - Which measurement system do you prefer? - - You currently have all Location Services for this device or application disabled. Please enable them in Settings. - - Your device doesn\'t support Location Services - - Show on the map - - ^\nis added to the downloading queue. - - Downloading\n^\n^ - - Download Map\n(^ ^) - - Download Map - - Download map\nwithout routing (^ ^) - - Downloading has failed - - Try Again - MAPS.ME - About MAPS.ME - Downloading %d%%, touch to cancel - Downloaded (%s), touch to delete - Connection Settings - Download %s - Close - A hardware accelerated OpenGL is required. Unfortunately, your device is not supported. - Download - SD card/USB storage with downloaded maps is not available - Please disconnect USB cable or insert memory card to use MAPS.ME - Please free some space on SD card/USB storage first in order to use the app - Not enough memory to launch app - Please free %1$s on your device first in order to download %2$s - Before you start let us download general world map into your device.\nIt needs %s of data. - Getting current position - Go to Map - Downloading %s. You can now\nproceed to the map. - Download %s? - Update %s? - - You can download the map\nof your current location. - - You can update the map\nof your current location. - - The map of your current\nlocation (%s) is up-to-date - - Pause - - Continue - Downloaded (%s), touch to update or delete - Update %s - - You need updated maps for search function: - - Update available for these maps: - - You don\'t need MAPS.ME Lite any more, so you can uninstall it. - - %s downloaded successfully - - %s download has failed - - Add New Set - - Add to Bookmarks - - Bookmark Color - - Bookmark Set Name - - Bookmark Sets - - Bookmarks - - Color - - My Places - - Name - - Address - - Remove Pin - - Set - - You have no bookmarks yet.\nTap on any place on the map to add a bookmark.\nBookmarks from other sources can also be imported and displayed in MAPS.ME. Open KML/KMZ file with saved bookmarks from email, Dropbox or weblink. - - Bookmarks from other sources can be imported and displayed in MAPS.ME. Open KML/KMZ file with saved bookmarks from mail, Dropbox or weblink. - - Settings - - Maps storage - - Select the place where maps should be downloaded to - - Move maps? - - This can take several minutes.\nPlease wait… - - Visible - - GPS is disabled. Please enable it in Settings. - - Measurement units - - Choose between miles and kilometers - - Everywhere - - Near Me - - On the Screen - - Food - - Transport - - Gas - - Parking - - Shop - - Hotel - - Sights - - Entertainment - - ATM - - Bank - - Pharmacy - - Hospital - - Toilet - - Post - - Police - - No results found - - Notes - - Share by email - - Shared MAPS.ME bookmarks - - Greetings,\n\nAttached are my bookmarks from MAPS.ME offline maps. Please open it if you have MAPS.ME installed. If not, download the app for your iOS or Android device following this link: http://maps.me/get?kmz\n\nEnjoy traveling with MAPS.ME! - - Loading Bookmarks - - Bookmarks loaded successfully! You can find them on the map or on the Bookmarks Manager screen. - - Bookmarks upload failed. The file may be corrupted or defective. - - Edit - - Your location hasn\'t been determined yet - - Download the country of your current location (%s) - - Download the country you are searching on (%s) - - Sorry, Map Storage settings are currently disabled. - - Country download is in progress now. - - Hope you enjoy using MAPS.ME! If so, please rate or review the app at the App Store. It takes less than a minute but can really help us. Thanks for your support! - - No, thanks - - Hey, check out my pin at MAPS.ME! %1$s or %2$s Don\'t have offline maps installed? Download here: http://maps.me/get - - Hey, check out my current location at MAPS.ME! %1$s or %2$s Don\'t have offline maps? Download here: http://maps.me/get - - Hey, check out my pin at MAPS.ME map! - - Hi,\n\nI pinned: %1$s at MAPS.ME, world offline maps. Click this link %2$s or this one %3$s to see the place on the map.\n\nThanks. - - Hey, check out my current location at MAPS.ME map! - - Hi,\n\nI\'m here now: %1$s. Click this link %2$s or this one %3$s to see the place on the map.\n\nThanks. - - Share by message - - Share - - Message - - Email - - Copy Link - - Show More Info - - Copied to Clipboard: %1$s - - Send Statistics - - Info - - Done - - Choose Back Screen settings - - Back Screen Settings - - Show on Back screen - - Version: %s - - Data version: %d - - Are you sure you want to continue? - - Tracks - - Length - Share My Location - Search - - Map - - Miscellaneous - Navigation - Zoom buttons - Display on the screen - - Night Mode - - Off - - On - - Auto - - Perspective view - - 3D buildings - - Affects battery life - - Voice Instructions - - Voice Language - - Not Available - - Other - How to set up voice - - Recent track - Auto zoom - Off - 1 hour - 2 hours - 6 hours - 12 hours - 1 day - Please note: activation of this function causes increased battery usage. - Recent track shows your traveled path. - Please select the time range of saving the track. - Distance - Coordinates - Unsorted - View on map - - Map data storage has been optimized. Please restart the app.\n\nMapsWithMe folder in the root of SD card is not needed anymore, you can delete it. - - Due to changes in Android 4.4, we need to optimize map data storage, but there is no enough space to copy map data.\n\nPlease free up the memory, otherwise maps will be available in read-only mode. - - We need to move your bookmarks to internal memory, but there is no available space for them. Please free up the memory, otherwise bookmarks won’t be available. - - Your map storage is being optimized now. Please wait, it may take a few minutes. - - Free - - Buy - - Search on map - - No route found - - Route - - Routes - - This applications uses geographical data (including maps, business listings, points of interest, borders of countries and regions, etc.) taken from the OpenStreetMap project. We do not warrant any consistency, accuracy, completeness or applicability of the OpenStreetMap data. - - I agree - - I disagree - - Download the map of the place where you are - - Full version of MAPS.ME is free today! Download now and tell your friends. - - We are transferring your downloaded maps from MAPS.ME Lite to MAPS.ME. It may take a few minutes. - - Your downloaded maps are successfully transferred to MAPS.ME. - - Your maps failed to transfer. Please delete MAPS.ME Lite and download the maps again. - - Settings & More - - Website - - MAPS.ME Community - - Like on Facebook - - Follow on Twitter - - Contact us - - Feedback - - General feedback - - Subscribe to our news - - Rate the app - - Help - - Copyright - - Report a bug - - Please subscribe me to the MAPS.ME newsletter - - I want to be the first to learn about latest news updates and promotions. I can cancel my subscription at any time. - - MAPS.ME offers the fastest offline maps of all the cities, all countries of the world. Travel with full confidence: wherever you are, MAPS.ME helps to locate yourself on the map, find the nearest restaurant, hotel, bank, gas station etc. It doesn’t require internet connection.\n\nWe are always working on new features and would love to hear from you on how you think we could improve MAPS.ME. If you have any problems with the app, don\'t hesitate to contact us at support@maps.me. We respond to every request!\n\nDo you like MAPS.ME and want to support us? There are some simple and absolutely free ways:\n\n- post a review at your App Market\n- like our Facebook page http://www.facebook.com/mapswithme\n- or just tell about MAPS.ME to your mom, friends and colleagues :)\n\nThank you for being with us. We appreciate your support very much!\n\nP.S. We take map data from OpenStreetMap, a mapping project similar to Wikipedia, which allows users to create and edit maps. If you see something is missing or wrong on the map, you can correct the maps directly at http://openstreetmap.org, and your changes will appear in MAPS.ME app with the next version release. - - The email client has not been set up. Please configure it or use any other way to contact us at %s - - Mail sending error - - Compass calibration - - WiFi - - Please update the map to create a route - - The new version of MAPS.ME allows creating routes from your current position to a destination point. Please update maps to use this feature. - - Update All - - Cancel All - - Downloaded - - Available - - queued - Near me - Maps - Download All - Downloading: - Found - - Creating routes in MAPS.ME app, please keep in mind the following:\n\n - Suggested routes can be considered as recommendations only.\n - Road conditions, traffic rules and signs have higher priority than navigation advice.\n - The map may be incorrect or outdated, and routes may not be created the best possible way.\n\n Be safe on roads and take care of yourself! - - Outdated - - Up-to-date - - Update - - Failed - - To delete map please stop navigation. - - Current location is undefined. Please specify location to create route. - - Additional data is required to create the route. Download data now? - - Cannot calculate the route. No roads near your starting point. - - Cannot calculate the route. No roads near your destination. - - Routes can only be created that are fully contained within a single map. - - There is no route found between the selected origin and destination. Please select a different start or end point. - - Internal error occurred. Please try to delete and download the map again. If problem persist please contact us at support@maps.me. - - Download Map + Routing - - Download Routing - - Delete Routing - - Download map - Download map without routing - - Go! - - Retry - - Map + Routing - - Delete Map - - Update Map - - Update Map + Routing - - Map Only - - Application menu - - Use Google Play Services to get your current location - - I’ve just rated your app - - I’ve been MAPS.ME user since %s - - Do you like MAPS.ME? - - Tap a star to rate our app. - - Thank you! - - Share any ideas or issues so we can improve the app for you. - - Send feedback - - Click g+ to tell your friends about the app. - - Download maps along route - - Get map - - Download updated map and routing data to get all MAPS.ME features. - - Get routing data - - Additional data required to create routes from your location. - - Creating a route requires all the maps from your location to destination downloaded and updated. - - Not enough space - - You need to download %1$s MB, but only %2$s MB are available. - - You are going to download %s MB using Mobile Data (in Roaming). This may result in additional charges, depending on your operator mobile data plan. - - bookmark - - The map for your location is not downloaded - - Please enable Location Services - - Download the map for your location - - Download a current location map on your iPhone - - Nearby - - Clear Pin - - Current location is undefined. - - Download the country of your current location - - download has failed - - Get the map - Save - Your descriptions (text or html) - new group - create - - Red - - Yellow - - Blue - - Green - - Purple - - Orange - - Brown - - Pink - - Yes + + + About + + Back + + Cancel + + Cancel Download + + Delete + + Do not ask me again + + Continue + Download Maps + + Download %qu kB + + Download %qu MB + + Download has failed, touch again for one more try + + Downloaded (%1$qu %2$s), touch to delete + + Downloading %qu%%, touch to cancel + + Downloading… + Get it now + + Thank you for using MAPS.ME! Do you like the app? Tell your friends about it! This is the best thanks you could give us. + + kB + + Kilometers + + Leave a Review + + Maps + + Maps: + + Marked for downloading, touch to cancel + + MB + GB + + Miles + + My Position + OK + + Please free some space on your device first in order to download %s + + Remind me later + + Later + + Never + + Report an issue + + Search + + Search Map + + Touch to download + + Yes + + We recommend using WiFi to download large maps + + Which measurement system do you prefer? + + You currently have all Location Services for this device or application disabled. Please enable them in Settings. + + Your device doesn\'t support Location Services + + Show on the map + + ^\nis added to the downloading queue. + + Downloading\n^\n^ + + Download Map\n(^ ^) + + Download Map + + Download map\nwithout routing (^ ^) + + Downloading has failed + + Try Again + MAPS.ME + About MAPS.ME + Downloading %d%%, touch to cancel + Downloaded (%s), touch to delete + Connection Settings + Download %s + Close + A hardware accelerated OpenGL is required. Unfortunately, your device is not supported. + Download + SD card/USB storage with downloaded maps is not available + Please disconnect USB cable or insert memory card to use MAPS.ME + Please free some space on SD card/USB storage first in order to use the app + Not enough memory to launch app + Please free %1$s on your device first in order to download %2$s + Before you start let us download general world map into your device.\nIt needs %s of data. + Getting current position + Go to Map + Downloading %s. You can now\nproceed to the map. + Download %s? + Update %s? + + You can download the map\nof your current location. + + You can update the map\nof your current location. + + The map of your current\nlocation (%s) is up-to-date + + Pause + + Continue + Downloaded (%s), touch to update or delete + Update %s + + You need updated maps for search function: + + Update available for these maps: + + You don\'t need MAPS.ME Lite any more, so you can uninstall it. + + %s downloaded successfully + + %s download has failed + + Add New Set + + Add to Bookmarks + + Bookmark Color + + Bookmark Set Name + + Bookmark Sets + + Bookmarks + + Color + + My Places + + Name + + Address + + Remove Pin + + Set + + You have no bookmarks yet.\nTap on any place on the map to add a bookmark.\nBookmarks from other sources can also be imported and displayed in MAPS.ME. Open KML/KMZ file with saved bookmarks from email, Dropbox or weblink. + + Bookmarks from other sources can be imported and displayed in MAPS.ME. Open KML/KMZ file with saved bookmarks from mail, Dropbox or weblink. + + Settings + + Maps storage + + Select the place where maps should be downloaded to + + Move maps? + + This can take several minutes.\nPlease wait… + + Visible + + GPS is disabled. Please enable it in Settings. + + Measurement units + + Choose between miles and kilometers + + Everywhere + + Near Me + + On the Screen + + Food + + Transport + + Gas + + Parking + + Shop + + Hotel + + Sights + + Entertainment + + ATM + + Bank + + Pharmacy + + Hospital + + Toilet + + Post + + Police + + No results found + + Notes + + Share by email + + Shared MAPS.ME bookmarks + + Greetings,\n\nAttached are my bookmarks from MAPS.ME offline maps. Please open it if you have MAPS.ME installed. If not, download the app for your iOS or Android device following this link: http://maps.me/get?kmz\n\nEnjoy traveling with MAPS.ME! + + Loading Bookmarks + + Bookmarks loaded successfully! You can find them on the map or on the Bookmarks Manager screen. + + Bookmarks upload failed. The file may be corrupted or defective. + + Edit + + Your location hasn\'t been determined yet + + Download the country of your current location (%s) + + Download the country you are searching on (%s) + + Sorry, Map Storage settings are currently disabled. + + Country download is in progress now. + + Hope you enjoy using MAPS.ME! If so, please rate or review the app at the App Store. It takes less than a minute but can really help us. Thanks for your support! + + No, thanks + + Hey, check out my pin at MAPS.ME! %1$s or %2$s Don\'t have offline maps installed? Download here: http://maps.me/get + + Hey, check out my current location at MAPS.ME! %1$s or %2$s Don\'t have offline maps? Download here: http://maps.me/get + + Hey, check out my pin at MAPS.ME map! + + Hi,\n\nI pinned: %1$s at MAPS.ME, world offline maps. Click this link %2$s or this one %3$s to see the place on the map.\n\nThanks. + + Hey, check out my current location at MAPS.ME map! + + Hi,\n\nI\'m here now: %1$s. Click this link %2$s or this one %3$s to see the place on the map.\n\nThanks. + + Share by message + + Share + + Message + + Email + + Copy Link + + Show More Info + + Copied to Clipboard: %1$s + + Send Statistics + + Info + + Done + + Choose Back Screen settings + + Back Screen Settings + + Show on Back screen + + Version: %s + + Data version: %d + + Are you sure you want to continue? + + Tracks + + Length + Share My Location + Search + + Map + + Miscellaneous + Navigation + Zoom buttons + Display on the screen + + Night Mode + + Off + + On + + Auto + + Perspective view + + 3D buildings + + Affects battery life + + Voice Instructions + + Voice Language + + Not Available + + Other + How to set up voice + + Recent track + Auto zoom + Off + 1 hour + 2 hours + 6 hours + 12 hours + 1 day + Please note: activation of this function causes increased battery usage. + Recent track shows your traveled path. + Please select the time range of saving the track. + Distance + Coordinates + Unsorted + View on map + + Map data storage has been optimized. Please restart the app.\n\nMapsWithMe folder in the root of SD card is not needed anymore, you can delete it. + + Due to changes in Android 4.4, we need to optimize map data storage, but there is no enough space to copy map data.\n\nPlease free up the memory, otherwise maps will be available in read-only mode. + + We need to move your bookmarks to internal memory, but there is no available space for them. Please free up the memory, otherwise bookmarks won’t be available. + + Your map storage is being optimized now. Please wait, it may take a few minutes. + + Free + + Buy + + Search on map + + No route found + + Route + + Routes + + This applications uses geographical data (including maps, business listings, points of interest, borders of countries and regions, etc.) taken from the OpenStreetMap project. We do not warrant any consistency, accuracy, completeness or applicability of the OpenStreetMap data. + + I agree + + I disagree + + Download the map of the place where you are + + Full version of MAPS.ME is free today! Download now and tell your friends. + + We are transferring your downloaded maps from MAPS.ME Lite to MAPS.ME. It may take a few minutes. + + Your downloaded maps are successfully transferred to MAPS.ME. + + Your maps failed to transfer. Please delete MAPS.ME Lite and download the maps again. + + Settings & More + + Website + + MAPS.ME Community + + Like on Facebook + + Follow on Twitter + + Contact us + + Feedback + + General feedback + + Subscribe to our news + + Rate the app + + Help + + Copyright + + Report a bug + + Please subscribe me to the MAPS.ME newsletter + + I want to be the first to learn about latest news updates and promotions. I can cancel my subscription at any time. + + MAPS.ME offers the fastest offline maps of all the cities, all countries of the world. Travel with full confidence: wherever you are, MAPS.ME helps to locate yourself on the map, find the nearest restaurant, hotel, bank, gas station etc. It doesn’t require internet connection.\n\nWe are always working on new features and would love to hear from you on how you think we could improve MAPS.ME. If you have any problems with the app, don\'t hesitate to contact us at support@maps.me. We respond to every request!\n\nDo you like MAPS.ME and want to support us? There are some simple and absolutely free ways:\n\n- post a review at your App Market\n- like our Facebook page http://www.facebook.com/mapswithme\n- or just tell about MAPS.ME to your mom, friends and colleagues :)\n\nThank you for being with us. We appreciate your support very much!\n\nP.S. We take map data from OpenStreetMap, a mapping project similar to Wikipedia, which allows users to create and edit maps. If you see something is missing or wrong on the map, you can correct the maps directly at http://openstreetmap.org, and your changes will appear in MAPS.ME app with the next version release. + + The email client has not been set up. Please configure it or use any other way to contact us at %s + + Mail sending error + + Compass calibration + + WiFi + + Please update the map to create a route + + The new version of MAPS.ME allows creating routes from your current position to a destination point. Please update maps to use this feature. + + Update All + + Cancel All + + Downloaded + + Available + + queued + Near me + Maps + Download All + Downloading: + Found + + Creating routes in MAPS.ME app, please keep in mind the following:\n\n - Suggested routes can be considered as recommendations only.\n - Road conditions, traffic rules and signs have higher priority than navigation advice.\n - The map may be incorrect or outdated, and routes may not be created the best possible way.\n\n Be safe on roads and take care of yourself! + + Outdated + + Up-to-date + + Update + + Failed + + To delete map please stop navigation. + + Current location is undefined. Please specify location to create route. + + Additional data is required to create the route. Download data now? + + Cannot calculate the route. No roads near your starting point. + + Cannot calculate the route. No roads near your destination. + + Routes can only be created that are fully contained within a single map. + + There is no route found between the selected origin and destination. Please select a different start or end point. + + Internal error occurred. Please try to delete and download the map again. If problem persist please contact us at support@maps.me. + + Download Map + Routing + + Download Routing + + Delete Routing + + Download map + Download map without routing + + Go! + + Retry + + Map + Routing + + Delete Map + + Update Map + + Update Map + Routing + + Map Only + + Application menu + + Use Google Play Services to get your current location + + I’ve just rated your app + + I’ve been MAPS.ME user since %s + + Do you like MAPS.ME? + + Tap a star to rate our app. + + Thank you! + + Share any ideas or issues so we can improve the app for you. + + Send feedback + + Click g+ to tell your friends about the app. + + Download maps along route + + Get map + + Download updated map and routing data to get all MAPS.ME features. + + Get routing data + + Additional data required to create routes from your location. + + Creating a route requires all the maps from your location to destination downloaded and updated. + + Not enough space + + You need to download %1$s MB, but only %2$s MB are available. + + You are going to download %s MB using Mobile Data (in Roaming). This may result in additional charges, depending on your operator mobile data plan. + + bookmark + + The map for your location is not downloaded + + Please enable Location Services + + Download the map for your location + + Download a current location map on your iPhone + + Nearby + + Clear Pin + + Current location is undefined. + + Download the country of your current location + + download has failed + + Get the map + Save + Your descriptions (text or html) + new group + create + + Red + + Yellow + + Blue + + Green + + Purple + + Orange + + Brown + + Pink + + Yes - - When following the route, please keep in mind: - — Road conditions, traffic laws and road signs always take priority over the navigational advice; - — The map might be inaccurate and the suggested route might not always be the most optimal way to reach the destination; - — Suggested routes are to be taken only as recommendations; - — Exercise caution with routes in border zones: the routes created by our app may sometimes cross country borders in unauthorized places; - Please stay alert and safe on the roads! - Check GPS signal - Unable to create route. Current GPS coordinates could not be identified. - Please check your GPS signal. Enabling Wi-Fi will improve your location accuracy. - Enable location services - Unable to locate current GPS coordinates. Enable location services to calculate route. - Unable to locate current GPS coordinates. - Download required files - Download and update all map and routing information along the projected path to calculate route. - Routing information files - Unable to locate route - Unable to create route. - Please adjust your starting point or your destination. - Adjust starting point - Route was not created. Unable to locate starting point. - Please select a starting point closer to a road. - Adjust destination - Route was not created. Unable to locate the destination. - Please select a destination point located closer to a road. - System error - Unable to create route due to an application error. - Please try again - Report the Problem - Would you like to create a more direct route that spans more than one map? - A more optimal route that crosses the edge of this map is available. - Not Now - Create - Would you like to download the map and create a more optimal route spanning more than one map? - Download the map to create a more optimal route that crosses the edge of this map. - Always cross this boundary + + When following the route, please keep in mind: + — Road conditions, traffic laws and road signs always take priority over the navigational advice; + — The map might be inaccurate and the suggested route might not always be the most optimal way to reach the destination; + — Suggested routes are to be taken only as recommendations; + — Exercise caution with routes in border zones: the routes created by our app may sometimes cross country borders in unauthorized places; + Please stay alert and safe on the roads! + Check GPS signal + Unable to create route. Current GPS coordinates could not be identified. + Please check your GPS signal. Enabling Wi-Fi will improve your location accuracy. + Enable location services + Unable to locate current GPS coordinates. Enable location services to calculate route. + Unable to locate current GPS coordinates. + Download required files + Download and update all map and routing information along the projected path to calculate route. + Routing information files + Unable to locate route + Unable to create route. + Please adjust your starting point or your destination. + Adjust starting point + Route was not created. Unable to locate starting point. + Please select a starting point closer to a road. + Adjust destination + Route was not created. Unable to locate the destination. + Please select a destination point located closer to a road. + System error + Unable to create route due to an application error. + Please try again + Report the Problem + Would you like to create a more direct route that spans more than one map? + A more optimal route that crosses the edge of this map is available. + Not Now + Create + Would you like to download the map and create a more optimal route spanning more than one map? + Download the map to create a more optimal route that crosses the edge of this map. + Always cross this boundary To start searching and creating routes, please download the map, and you will not need Internet connection anymore. diff --git a/android/res/values/styles-place_page.xml b/android/res/values/styles-place_page.xml index 013abc689f..6feb7dc81a 100644 --- a/android/res/values/styles-place_page.xml +++ b/android/res/values/styles-place_page.xml @@ -83,4 +83,4 @@ @dimen/margin_base @dimen/margin_base - \ No newline at end of file + diff --git a/android/res/values/styles-text.xml b/android/res/values/styles-text.xml index 1f9607f975..dc016d2b54 100644 --- a/android/res/values/styles-text.xml +++ b/android/res/values/styles-text.xml @@ -121,6 +121,10 @@ bold + + - - @@ -169,4 +171,4 @@ - \ No newline at end of file + diff --git a/android/res/values/styles.xml b/android/res/values/styles.xml index d1df9725e6..56c21826f4 100644 --- a/android/res/values/styles.xml +++ b/android/res/values/styles.xml @@ -16,8 +16,7 @@ 0dp - - - - - @@ -124,9 +101,7 @@ true - - @@ -210,8 +184,7 @@ @drawable/shadow_top - @@ -247,9 +220,7 @@ @style/MwmTextAppearance.Toolbar.Title.Button - - \ No newline at end of file + diff --git a/android/src/com/mapswithme/maps/base/BaseMwmExtraTitleActivity.java b/android/src/com/mapswithme/maps/base/BaseMwmExtraTitleActivity.java new file mode 100644 index 0000000000..13b2fbbfb1 --- /dev/null +++ b/android/src/com/mapswithme/maps/base/BaseMwmExtraTitleActivity.java @@ -0,0 +1,43 @@ +package com.mapswithme.maps.base; + +import android.os.Bundle; +import android.support.annotation.CallSuper; +import android.support.v7.widget.Toolbar; + +import com.mapswithme.maps.R; +import com.mapswithme.util.UiUtils; + +public class BaseMwmExtraTitleActivity extends BaseMwmFragmentActivity +{ + protected static final String EXTRA_TITLE = "activity_title"; + + @Override + @CallSuper + protected void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + String title = ""; + Bundle bundle = getIntent().getExtras(); + if (bundle != null) + { + title = bundle.getString(EXTRA_TITLE); + } + Toolbar toolbar = getToolbar(); + toolbar.setTitle(title); + UiUtils.showHomeUpButton(toolbar); + displayToolbarAsActionBar(); + } + + @Override + protected int getContentLayoutResId() + { + return R.layout.activity_fragment_and_toolbar; + } + + @Override + protected int getFragmentContentResId() + { + return R.id.fragment_container; + } +} diff --git a/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java index 592ba34c10..bfba3eb345 100644 --- a/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java +++ b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java @@ -1,17 +1,11 @@ package com.mapswithme.maps.gallery; -import com.bumptech.glide.Glide; -import com.bumptech.glide.request.target.BitmapImageViewTarget; -import com.mapswithme.maps.R; -import com.mapswithme.maps.base.BaseMwmFragmentActivity; -import com.mapswithme.util.ThemeUtils; -import com.mapswithme.util.UiUtils; - import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.os.Build; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.graphics.drawable.RoundedBitmapDrawable; import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory; import android.support.v4.view.ViewPager; @@ -24,12 +18,20 @@ import android.view.WindowManager; import android.widget.ImageView; import android.widget.TextView; +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.target.BitmapImageViewTarget; +import com.mapswithme.maps.R; +import com.mapswithme.maps.base.BaseMwmFragmentActivity; +import com.mapswithme.util.ThemeUtils; +import com.mapswithme.util.UiUtils; + import java.util.ArrayList; import java.util.Date; import java.util.List; public class FullScreenGalleryActivity extends BaseMwmFragmentActivity - implements ViewPager.OnPageChangeListener { + implements ViewPager.OnPageChangeListener +{ public static final String EXTRA_IMAGES = "gallery_images"; public static final String EXTRA_POSITION = "gallery_position"; @@ -53,7 +55,8 @@ public class FullScreenGalleryActivity extends BaseMwmFragmentActivity } @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(Bundle savedInstanceState) + { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); @@ -62,9 +65,8 @@ public class FullScreenGalleryActivity extends BaseMwmFragmentActivity toolbar.setTitle(""); UiUtils.showHomeUpButton(toolbar); displayToolbarAsActionBar(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - } mUserBlock = findViewById(R.id.rl__user_block); mDescription = (TextView) findViewById(R.id.tv__description); @@ -74,19 +76,22 @@ public class FullScreenGalleryActivity extends BaseMwmFragmentActivity mAvatar = (ImageView) findViewById(R.id.iv__avatar); readParameters(); - mGalleryPageAdapter = new GalleryPageAdapter(getSupportFragmentManager(), mImages); - final ViewPager viewPager = (ViewPager) findViewById(R.id.vp__image); - viewPager.addOnPageChangeListener(this); - viewPager.setAdapter(mGalleryPageAdapter); - viewPager.setCurrentItem(mPosition); - viewPager.post(new Runnable() + if (mImages != null) { - @Override - public void run() + mGalleryPageAdapter = new GalleryPageAdapter(getSupportFragmentManager(), mImages); + final ViewPager viewPager = (ViewPager) findViewById(R.id.vp__image); + viewPager.addOnPageChangeListener(this); + viewPager.setAdapter(mGalleryPageAdapter); + viewPager.setCurrentItem(mPosition); + viewPager.post(new Runnable() { - onPageSelected(viewPager.getCurrentItem()); - } - }); + @Override + public void run() + { + onPageSelected(viewPager.getCurrentItem()); + } + }); + } } @Override @@ -101,71 +106,93 @@ public class FullScreenGalleryActivity extends BaseMwmFragmentActivity throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme); } - @Override - protected int getContentLayoutResId() { - return R.layout.activity_viewpager_transparent_toolbar; + protected int getContentLayoutResId() + { + return R.layout.activity_full_screen_gallery; } @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) + { } @Override - public void onPageSelected(int position) { + public void onPageSelected(int position) + { updateInformation(mGalleryPageAdapter.getImage(position)); } @Override - public void onPageScrollStateChanged(int state) { - + public void onPageScrollStateChanged(int state) + { } - private void readParameters() { + private void readParameters() + { Bundle extras = getIntent().getExtras(); - if (extras != null) { + if (extras != null) + { mImages = extras.getParcelableArrayList(EXTRA_IMAGES); mPosition = extras.getInt(EXTRA_POSITION); } } - private void updateInformation(Image image) { + private void updateInformation(@NonNull Image image) + { UiUtils.setTextAndHideIfEmpty(mDescription, image.getDescription()); UiUtils.setTextAndHideIfEmpty(mUserName, image.getUserName()); UiUtils.setTextAndHideIfEmpty(mSource, image.getSource()); - if (image.getDate() != null) { + updateDate(image); + updateUserAvatar(image); + updateUserBlock(); + } + + private void updateDate(Image image) + { + if (image.getDate() != null) + { Date date = new Date(image.getDate()); mDate.setText(DateFormat.getMediumDateFormat(this).format(date)); UiUtils.show(mDate); - } else { - UiUtils.hide(mDate); } - if (!TextUtils.isEmpty(image.getUserAvatar())) { + else + UiUtils.hide(mDate); + } + + private void updateUserAvatar(Image image) + { + if (!TextUtils.isEmpty(image.getUserAvatar())) + { UiUtils.show(mAvatar); Glide.with(this) - .load(image.getUserAvatar()) - .asBitmap() - .centerCrop() - .into(new BitmapImageViewTarget(mAvatar) { - @Override - protected void setResource(Bitmap resource) { - RoundedBitmapDrawable circularBitmapDrawable = - RoundedBitmapDrawableFactory.create(getResources(), resource); - circularBitmapDrawable.setCircular(true); - mAvatar.setImageDrawable(circularBitmapDrawable); - } - }); - } else { + .load(image.getUserAvatar()) + .asBitmap() + .centerCrop() + .into(new BitmapImageViewTarget(mAvatar) + { + @Override + protected void setResource(Bitmap resource) + { + RoundedBitmapDrawable circularBitmapDrawable = + RoundedBitmapDrawableFactory.create(getResources(), resource); + circularBitmapDrawable.setCircular(true); + mAvatar.setImageDrawable(circularBitmapDrawable); + } + }); + } + else UiUtils.hide(mAvatar); - } + } + + private void updateUserBlock() + { if (UiUtils.isHidden(mUserName) - && UiUtils.isHidden(mSource) - && UiUtils.isHidden(mDate) - && UiUtils.isHidden(mAvatar)) { + && UiUtils.isHidden(mSource) + && UiUtils.isHidden(mDate) + && UiUtils.isHidden(mAvatar)) UiUtils.hide(mUserBlock); - } else { + else UiUtils.show(mUserBlock); - } } } diff --git a/android/src/com/mapswithme/maps/gallery/FullScreenGalleryFragment.java b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryFragment.java index 15c2a3b8b3..465ff4f515 100644 --- a/android/src/com/mapswithme/maps/gallery/FullScreenGalleryFragment.java +++ b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryFragment.java @@ -1,9 +1,5 @@ package com.mapswithme.maps.gallery; -import com.bumptech.glide.Glide; -import com.mapswithme.maps.R; -import com.mapswithme.maps.base.BaseMwmFragment; - import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; @@ -11,35 +7,44 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -public class FullScreenGalleryFragment extends BaseMwmFragment { +import com.bumptech.glide.Glide; +import com.mapswithme.maps.R; +import com.mapswithme.maps.base.BaseMwmFragment; + +public class FullScreenGalleryFragment extends BaseMwmFragment +{ static final String ARGUMENT_IMAGE = "argument_image"; + @Nullable private Image mImage; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, - @Nullable Bundle savedInstanceState) { + @Nullable Bundle savedInstanceState) + { return inflater.inflate(R.layout.fragment_fullscreen_image, container, false); } @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) + { super.onViewCreated(view, savedInstanceState); readArguments(); - if (mImage != null) { + if (mImage != null) + { ImageView imageView = (ImageView) view.findViewById(R.id.iv__image); Glide.with(view.getContext()) - .load(mImage.getUrl()) - .into(imageView); + .load(mImage.getUrl()) + .into(imageView); } } - private void readArguments() { + private void readArguments() + { Bundle args = getArguments(); - if (args != null) { + if (args != null) mImage = args.getParcelable(ARGUMENT_IMAGE); - } } } diff --git a/android/src/com/mapswithme/maps/gallery/GalleryActivity.java b/android/src/com/mapswithme/maps/gallery/GalleryActivity.java index 27c19cbdcc..bd9b7b6805 100644 --- a/android/src/com/mapswithme/maps/gallery/GalleryActivity.java +++ b/android/src/com/mapswithme/maps/gallery/GalleryActivity.java @@ -1,22 +1,19 @@ package com.mapswithme.maps.gallery; -import com.mapswithme.maps.R; -import com.mapswithme.maps.base.BaseMwmFragmentActivity; -import com.mapswithme.util.UiUtils; - import android.content.Context; import android.content.Intent; -import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.Fragment; -import android.support.v7.widget.Toolbar; + +import com.mapswithme.maps.base.BaseMwmExtraTitleActivity; import java.util.ArrayList; -public class GalleryActivity extends BaseMwmFragmentActivity { +public class GalleryActivity extends BaseMwmExtraTitleActivity +{ public static final String EXTRA_IMAGES = "gallery_images"; - public static final String EXTRA_TITLE = "gallery_title"; - public static void start(Context context, ArrayList images, String title) + public static void start(Context context, @NonNull ArrayList images, @NonNull String title) { final Intent i = new Intent(context, GalleryActivity.class); i.putParcelableArrayListExtra(EXTRA_IMAGES, images); @@ -25,32 +22,8 @@ public class GalleryActivity extends BaseMwmFragmentActivity { } @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - String title = ""; - Bundle bundle = getIntent().getExtras(); - if (bundle != null) { - title = bundle.getString(EXTRA_TITLE); - } - Toolbar toolbar = getToolbar(); - toolbar.setTitle(title); - UiUtils.showHomeUpButton(toolbar); - displayToolbarAsActionBar(); - } - - @Override - protected Class getFragmentClass() { + protected Class getFragmentClass() + { return GalleryFragment.class; } - - @Override - protected int getContentLayoutResId() { - return R.layout.activity_fragment_and_toolbar; - } - - @Override - protected int getFragmentContentResId() { - return R.id.fragment_container; - } } diff --git a/android/src/com/mapswithme/maps/gallery/GalleryFragment.java b/android/src/com/mapswithme/maps/gallery/GalleryFragment.java index 9be54ce3dc..c1c02c8f5d 100644 --- a/android/src/com/mapswithme/maps/gallery/GalleryFragment.java +++ b/android/src/com/mapswithme/maps/gallery/GalleryFragment.java @@ -1,10 +1,5 @@ package com.mapswithme.maps.gallery; -import com.mapswithme.maps.R; -import com.mapswithme.maps.base.BaseMwmFragment; -import com.mapswithme.maps.widget.recycler.GridDividerItemDecoration; -import com.mapswithme.maps.widget.recycler.RecyclerClickListener; - import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.Nullable; @@ -15,29 +10,42 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import com.mapswithme.maps.R; +import com.mapswithme.maps.base.BaseMwmFragment; +import com.mapswithme.maps.widget.recycler.GridDividerItemDecoration; +import com.mapswithme.maps.widget.recycler.RecyclerClickListener; + import java.util.ArrayList; -public class GalleryFragment extends BaseMwmFragment implements RecyclerClickListener { +public class GalleryFragment extends BaseMwmFragment implements RecyclerClickListener +{ + private static final int NUM_COLUMNS = 3; + @Nullable private ArrayList mImages; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, - @Nullable Bundle savedInstanceState) { + @Nullable Bundle savedInstanceState) + { return inflater.inflate(R.layout.fragment_gallery, container, false); } @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) + { super.onViewCreated(view, savedInstanceState); readArguments(); - RecyclerView rvGallery = (RecyclerView) view.findViewById(R.id.rv__gallery); - rvGallery.setLayoutManager(new GridLayoutManager(getContext(), 3)); - rvGallery.setAdapter(new ImageAdapter(mImages, this)); - Drawable divider = ContextCompat.getDrawable(getContext(), R.drawable.divider_transparent); - rvGallery.addItemDecoration(new GridDividerItemDecoration(divider, divider, 3)); + if (mImages != null) + { + RecyclerView rvGallery = (RecyclerView) view.findViewById(R.id.rv__gallery); + rvGallery.setLayoutManager(new GridLayoutManager(getContext(), NUM_COLUMNS)); + rvGallery.setAdapter(new ImageAdapter(mImages, this)); + Drawable divider = ContextCompat.getDrawable(getContext(), R.drawable.divider_transparent); + rvGallery.addItemDecoration(new GridDividerItemDecoration(divider, divider, NUM_COLUMNS)); + } } private void readArguments() @@ -50,7 +58,8 @@ public class GalleryFragment extends BaseMwmFragment implements RecyclerClickLis } @Override - public void onItemClick(View v, int position) { + public void onItemClick(View v, int position) + { FullScreenGalleryActivity.start(getContext(), mImages, position); } } diff --git a/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java b/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java index 12ed1a1120..14724038d5 100644 --- a/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java +++ b/android/src/com/mapswithme/maps/gallery/GalleryPageAdapter.java @@ -1,23 +1,28 @@ package com.mapswithme.maps.gallery; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import java.util.List; -class GalleryPageAdapter extends FragmentStatePagerAdapter { +class GalleryPageAdapter extends FragmentStatePagerAdapter +{ + @NonNull private final List mImages; - GalleryPageAdapter(FragmentManager fm, List images) { + GalleryPageAdapter(@NonNull FragmentManager fm, @NonNull List images) + { super(fm); mImages = images; } @Override - public Fragment getItem(int position) { + public Fragment getItem(int position) + { Bundle args = new Bundle(); args.putParcelable(FullScreenGalleryFragment.ARGUMENT_IMAGE, mImages.get(position)); FullScreenGalleryFragment fragment = new FullScreenGalleryFragment(); @@ -26,11 +31,14 @@ class GalleryPageAdapter extends FragmentStatePagerAdapter { } @Override - public int getCount() { + public int getCount() + { return mImages.size(); } - Image getImage(int position) { + @NonNull + Image getImage(int position) + { return mImages.get(position); } } diff --git a/android/src/com/mapswithme/maps/gallery/Image.java b/android/src/com/mapswithme/maps/gallery/Image.java index 38c67d321f..8812814779 100644 --- a/android/src/com/mapswithme/maps/gallery/Image.java +++ b/android/src/com/mapswithme/maps/gallery/Image.java @@ -2,107 +2,143 @@ package com.mapswithme.maps.gallery; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; -public class Image implements Parcelable { - private final String url; - private final String smallUrl; - private String description; - private String userName; - private String userAvatar; - private String source; - private Long date; +public class Image implements Parcelable +{ + @NonNull + private final String mUrl; + @NonNull + private final String mSmallUrl; + @Nullable + private String mDescription; + @Nullable + private String mUserName; + @Nullable + private String mUserAvatar; + @Nullable + private String mSource; + @Nullable + private Long mDate; @SuppressWarnings("unused") - public Image(String url, String smallUrl) { - this.url = url; - this.smallUrl = smallUrl; + public Image(@NonNull String url, @NonNull String smallUrl) + { + this.mUrl = url; + this.mSmallUrl = smallUrl; } - protected Image(Parcel in) { - url = in.readString(); - smallUrl = in.readString(); - description = in.readString(); - userName = in.readString(); - userAvatar = in.readString(); - source = in.readString(); - date = (Long) in.readValue(Long.class.getClassLoader()); + protected Image(Parcel in) + { + mUrl = in.readString(); + mSmallUrl = in.readString(); + mDescription = in.readString(); + mUserName = in.readString(); + mUserAvatar = in.readString(); + mSource = in.readString(); + mDate = (Long) in.readValue(Long.class.getClassLoader()); } @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(url); - dest.writeString(smallUrl); - dest.writeString(description); - dest.writeString(userName); - dest.writeString(userAvatar); - dest.writeString(source); - dest.writeValue(date); + public void writeToParcel(Parcel dest, int flags) + { + dest.writeString(mUrl); + dest.writeString(mSmallUrl); + dest.writeString(mDescription); + dest.writeString(mUserName); + dest.writeString(mUserAvatar); + dest.writeString(mSource); + dest.writeValue(mDate); } @Override - public int describeContents() { + public int describeContents() + { return 0; } - public static final Creator CREATOR = new Creator() { + public static final Creator CREATOR = new Creator() + { @Override - public Image createFromParcel(Parcel in) { + public Image createFromParcel(Parcel in) + { return new Image(in); } @Override - public Image[] newArray(int size) { + public Image[] newArray(int size) + { return new Image[size]; } }; - public String getUrl() { - return url; + @NonNull + public String getUrl() + { + return mUrl; } - public String getSmallUrl() { - return smallUrl; + @NonNull + public String getSmallUrl() + { + return mSmallUrl; } - public String getDescription() { - return description; + @Nullable + public String getDescription() + { + return mDescription; } - public void setDescription(String description) { - this.description = description; + public void setDescription(@Nullable String description) + { + this.mDescription = description; } - String getUserName() { - return userName; + @Nullable + String getUserName() + { + return mUserName; } @SuppressWarnings("unused") - public void setUserName(String userName) { - this.userName = userName; + public void setUserName(@Nullable String userName) + { + this.mUserName = userName; } - String getUserAvatar() { - return userAvatar; + @Nullable + String getUserAvatar() + { + return mUserAvatar; } @SuppressWarnings("unused") - public void setUserAvatar(String userAvatar) { - this.userAvatar = userAvatar; + public void setUserAvatar(@Nullable String userAvatar) + { + this.mUserAvatar = userAvatar; } - public String getSource() { - return source; + @Nullable + public String getSource() + { + return mSource; } - public void setSource(String source) { - this.source = source; + public void setSource(@Nullable String source) + { + this.mSource = source; } - public Long getDate() { - return date; + @Nullable + public Long getDate() + { + return mDate; } - public void setDate(Long date) { - this.date = date; + public void setDate(@Nullable Long date) + { + this.mDate = date; } } diff --git a/android/src/com/mapswithme/maps/gallery/ImageAdapter.java b/android/src/com/mapswithme/maps/gallery/ImageAdapter.java index b1b7ab4a34..ff0d977ac8 100644 --- a/android/src/com/mapswithme/maps/gallery/ImageAdapter.java +++ b/android/src/com/mapswithme/maps/gallery/ImageAdapter.java @@ -1,51 +1,59 @@ package com.mapswithme.maps.gallery; -import com.bumptech.glide.Glide; -import com.mapswithme.maps.R; -import com.mapswithme.maps.widget.recycler.RecyclerClickListener; - +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import com.bumptech.glide.Glide; +import com.mapswithme.maps.R; +import com.mapswithme.maps.widget.recycler.RecyclerClickListener; + import java.util.ArrayList; -class ImageAdapter extends RecyclerView.Adapter { +class ImageAdapter extends RecyclerView.Adapter +{ + @NonNull private final ArrayList mItems; + @Nullable private final RecyclerClickListener mListener; - ImageAdapter(ArrayList images, RecyclerClickListener listener) { + ImageAdapter(@NonNull ArrayList images, @Nullable RecyclerClickListener listener) + { mItems = images; mListener = listener; } @Override - public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) + { return new ViewHolder(LayoutInflater.from(parent.getContext()) - .inflate(R.layout.item_image, parent, false), mListener); + .inflate(R.layout.item_image, parent, false), mListener); } @Override - public void onBindViewHolder(ViewHolder holder, int position) { + public void onBindViewHolder(ViewHolder holder, int position) + { holder.bind(mItems.get(position), position); } @Override - public int getItemCount() { - if (mItems == null) { - return 0; - } + public int getItemCount() + { return mItems.size(); } - static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener + { private ImageView mImage; private final RecyclerClickListener mListener; private int mPosition; - public ViewHolder(View itemView, RecyclerClickListener listener) { + public ViewHolder(View itemView, RecyclerClickListener listener) + { super(itemView); mListener = listener; itemView.setOnClickListener(this); @@ -53,18 +61,19 @@ class ImageAdapter extends RecyclerView.Adapter { } @Override - public void onClick(View v) { - if (mListener != null) { + public void onClick(View v) + { + if (mListener != null) mListener.onItemClick(v, mPosition); - } } - public void bind(Image image, int position) { + public void bind(Image image, int position) + { mPosition = position; Glide.with(mImage.getContext()) - .load(image.getSmallUrl()) - .centerCrop() - .into(mImage); + .load(image.getSmallUrl()) + .centerCrop() + .into(mImage); } } } diff --git a/android/src/com/mapswithme/maps/review/Review.java b/android/src/com/mapswithme/maps/review/Review.java index f7cb7ae5ab..11b3b22d77 100644 --- a/android/src/com/mapswithme/maps/review/Review.java +++ b/android/src/com/mapswithme/maps/review/Review.java @@ -2,26 +2,30 @@ package com.mapswithme.maps.review; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; -public class Review implements Parcelable { +public class Review implements Parcelable +{ + @Nullable private final String mReview; - + @Nullable private final String mReviewPositive; - + @Nullable private final String mReviewNegative; - + @NonNull private final String mAuthor; - + @NonNull private final String mAuthorAvatar; - private final float mRating; - private final long mDate; - public Review(String review, String reviewPositive, String reviewNegative, String author, - String authorAvatar, - float rating, long date) { + public Review(@Nullable String review, @Nullable String reviewPositive, + @Nullable String reviewNegative, @NonNull String author, + @NonNull String authorAvatar, + float rating, long date) + { mReview = review; mReviewPositive = reviewPositive; mReviewNegative = reviewNegative; @@ -31,7 +35,8 @@ public class Review implements Parcelable { mDate = date; } - protected Review(Parcel in) { + protected Review(Parcel in) + { mReview = in.readString(); mReviewPositive = in.readString(); mReviewNegative = in.readString(); @@ -42,7 +47,8 @@ public class Review implements Parcelable { } @Override - public void writeToParcel(Parcel dest, int flags) { + public void writeToParcel(Parcel dest, int flags) + { dest.writeString(mReview); dest.writeString(mReviewPositive); dest.writeString(mReviewNegative); @@ -53,48 +59,64 @@ public class Review implements Parcelable { } @Override - public int describeContents() { + public int describeContents() + { return 0; } - public static final Creator CREATOR = new Creator() { + public static final Creator CREATOR = new Creator() + { @Override - public Review createFromParcel(Parcel in) { + public Review createFromParcel(Parcel in) + { return new Review(in); } @Override - public Review[] newArray(int size) { + public Review[] newArray(int size) + { return new Review[size]; } }; - public String getReview() { + @Nullable + public String getReview() + { return mReview; } - public String getReviewPositive() { + @Nullable + public String getReviewPositive() + { return mReviewPositive; } - public String getReviewNegative() { + @Nullable + public String getReviewNegative() + { return mReviewNegative; } - public String getAuthor() { + @NonNull + public String getAuthor() + { return mAuthor; } @SuppressWarnings("unused") - public String getAuthorAvatar() { + @NonNull + public String getAuthorAvatar() + { return mAuthorAvatar; } - public float getRating() { + public float getRating() + { return mRating; } - public long getDate() { + public long getDate() + { return mDate; } } diff --git a/android/src/com/mapswithme/maps/review/ReviewActivity.java b/android/src/com/mapswithme/maps/review/ReviewActivity.java index d0ee0e0517..588580a961 100644 --- a/android/src/com/mapswithme/maps/review/ReviewActivity.java +++ b/android/src/com/mapswithme/maps/review/ReviewActivity.java @@ -1,26 +1,24 @@ package com.mapswithme.maps.review; -import com.mapswithme.maps.R; -import com.mapswithme.maps.base.BaseMwmFragmentActivity; -import com.mapswithme.util.UiUtils; - import android.content.Context; import android.content.Intent; -import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.Fragment; -import android.support.v7.widget.Toolbar; + +import com.mapswithme.maps.base.BaseMwmExtraTitleActivity; import java.util.ArrayList; -public class ReviewActivity extends BaseMwmFragmentActivity { +public class ReviewActivity extends BaseMwmExtraTitleActivity +{ static final String EXTRA_REVIEWS = "review_items"; - static final String EXTRA_TITLE = "review_title"; static final String EXTRA_RATING = "review_rating"; static final String EXTRA_RATING_BASE = "review_rating_base"; static final String EXTRA_RATING_URL = "review_rating_url"; - public static void start(Context context, ArrayList items, String title, - String rating, int ratingBase, String url) + public static void start(Context context, @NonNull ArrayList items, + @NonNull String title, @NonNull String rating, int ratingBase, + @NonNull String url) { final Intent i = new Intent(context, ReviewActivity.class); i.putParcelableArrayListExtra(EXTRA_REVIEWS, items); @@ -32,32 +30,8 @@ public class ReviewActivity extends BaseMwmFragmentActivity { } @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - String title = ""; - Bundle bundle = getIntent().getExtras(); - if (bundle != null) { - title = bundle.getString(EXTRA_TITLE); - } - Toolbar toolbar = getToolbar(); - toolbar.setTitle(title); - UiUtils.showHomeUpButton(toolbar); - displayToolbarAsActionBar(); - } - - @Override - protected Class getFragmentClass() { + protected Class getFragmentClass() + { return ReviewFragment.class; } - - @Override - protected int getContentLayoutResId() { - return R.layout.activity_fragment_and_toolbar; - } - - @Override - protected int getFragmentContentResId() { - return R.id.fragment_container; - } } diff --git a/android/src/com/mapswithme/maps/review/ReviewAdapter.java b/android/src/com/mapswithme/maps/review/ReviewAdapter.java index 130b2ea9f5..151c4e3ccd 100644 --- a/android/src/com/mapswithme/maps/review/ReviewAdapter.java +++ b/android/src/com/mapswithme/maps/review/ReviewAdapter.java @@ -1,10 +1,8 @@ package com.mapswithme.maps.review; -import com.mapswithme.maps.R; -import com.mapswithme.maps.widget.recycler.RecyclerClickListener; -import com.mapswithme.util.UiUtils; - import android.support.annotation.CallSuper; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.text.format.DateFormat; @@ -13,23 +11,33 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import com.mapswithme.maps.R; +import com.mapswithme.maps.widget.recycler.RecyclerClickListener; +import com.mapswithme.util.UiUtils; + import java.util.ArrayList; import java.util.Date; import java.util.Locale; -class ReviewAdapter extends RecyclerView.Adapter { +class ReviewAdapter extends RecyclerView.Adapter +{ private static final int MAX_COUNT = 15; private static final int VIEW_TYPE_REVIEW = 0; private static final int VIEW_TYPE_MORE = 1; private static final int VIEW_TYPE_RATING = 2; + @NonNull private final ArrayList mItems; + @Nullable private final RecyclerClickListener mListener; + @NonNull private final String mRating; private final int mRatingBase; - ReviewAdapter(ArrayList images, RecyclerClickListener listener, String rating, - int ratingBase) { + ReviewAdapter(@NonNull ArrayList images, @Nullable RecyclerClickListener listener, + @NonNull String rating, + int ratingBase) + { mItems = images; mListener = listener; mRating = rating; @@ -37,82 +45,84 @@ class ReviewAdapter extends RecyclerView.Adapter { } @Override - public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - if (viewType == VIEW_TYPE_REVIEW) { + public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) + { + if (viewType == VIEW_TYPE_REVIEW) return new ReviewHolder(LayoutInflater.from(parent.getContext()) - .inflate(R.layout.item_comment, parent, false), mListener); - } + .inflate(R.layout.item_comment, parent, false), mListener); - if (viewType == VIEW_TYPE_MORE) { + if (viewType == VIEW_TYPE_MORE) return new MoreHolder(LayoutInflater.from(parent.getContext()) - .inflate(R.layout.item_more_button, parent, false), mListener); - } + .inflate(R.layout.item_more_button, parent, false), mListener); return new RatingHolder(LayoutInflater.from(parent.getContext()) - .inflate(R.layout.item_rating, parent, false), mListener); + .inflate(R.layout.item_rating, parent, false), mListener); } @Override - public void onBindViewHolder(BaseViewHolder holder, int position) { + public void onBindViewHolder(BaseViewHolder holder, int position) + { int positionNoHeader = position - 1; - if (position == 0) { - ((RatingHolder)holder).bind(mRating, mRatingBase); - } else if (positionNoHeader < mItems.size()) { + if (position == 0) + ((RatingHolder) holder).bind(mRating, mRatingBase); + else if (positionNoHeader < mItems.size()) holder.bind(mItems.get(positionNoHeader), positionNoHeader); - } else { + else holder.bind(null, positionNoHeader); - } } @Override - public int getItemCount() { - if (mItems == null) { - return 1; - } - if (mItems.size() > MAX_COUNT) { + public int getItemCount() + { + if (mItems.size() > MAX_COUNT) + // 1 overall rating item + MAX_COUNT user reviews + 1 "more reviews" item return MAX_COUNT + 2; - } + + // 1 overall rating item + count of user reviews + 1 "more reviews" item return mItems.size() + 2; } @Override - public int getItemViewType(int position) { + public int getItemViewType(int position) + { int positionNoHeader = position - 1; - if (position == 0) { + if (position == 0) return VIEW_TYPE_RATING; - } - if (positionNoHeader == mItems.size()) { + if (positionNoHeader == mItems.size()) return VIEW_TYPE_MORE; - } return VIEW_TYPE_REVIEW; } - static abstract class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + static abstract class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener + { private final RecyclerClickListener mListener; private int mPosition; - BaseViewHolder(View itemView, RecyclerClickListener listener) { + BaseViewHolder(View itemView, RecyclerClickListener listener) + { super(itemView); mListener = listener; } @Override - public void onClick(View v) { - if (mListener != null) { + public void onClick(View v) + { + if (mListener != null) mListener.onItemClick(v, mPosition); - } } @CallSuper - public void bind(Review item, int position) { + public void bind(Review item, int position) + { mPosition = position; } } - private static class ReviewHolder extends BaseViewHolder { + private static class ReviewHolder extends BaseViewHolder + { final View mDivider; final TextView mUserName; final TextView mCommentDate; @@ -123,7 +133,8 @@ class ReviewAdapter extends RecyclerView.Adapter { final View mNegativeReview; final TextView mTvNegativeReview; - ReviewHolder(View itemView, RecyclerClickListener listener) { + ReviewHolder(View itemView, RecyclerClickListener listener) + { super(itemView, listener); mDivider = itemView.findViewById(R.id.v__divider); mUserName = (TextView) itemView.findViewById(R.id.tv__user_name); @@ -137,56 +148,65 @@ class ReviewAdapter extends RecyclerView.Adapter { } @Override - public void bind(Review item, int position) { + public void bind(Review item, int position) + { super.bind(item, position); UiUtils.showIf(position > 0, 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())) { + if (TextUtils.isEmpty(item.getReviewPositive())) UiUtils.hide(mPositiveReview); - } else { + else + { UiUtils.show(mPositiveReview); mTvPositiveReview.setText(item.getReviewPositive()); } - if (TextUtils.isEmpty(item.getReviewNegative())) { + if (TextUtils.isEmpty(item.getReviewNegative())) UiUtils.hide(mNegativeReview); - } else { + else + { UiUtils.show(mNegativeReview); mTvNegativeReview.setText(item.getReviewNegative()); } - if (UiUtils.isHidden(mNegativeReview) && UiUtils.isHidden(mPositiveReview)) { + if (UiUtils.isHidden(mNegativeReview) && UiUtils.isHidden(mPositiveReview)) UiUtils.showIf(!TextUtils.isEmpty(item.getReview()), mReview); - } else { + else + { UiUtils.hide(mReview); } } } - private static class MoreHolder extends BaseViewHolder { + private static class MoreHolder extends BaseViewHolder + { - MoreHolder(View itemView, RecyclerClickListener listener) { + MoreHolder(View itemView, RecyclerClickListener listener) + { super(itemView, listener); itemView.setOnClickListener(this); } } - private static class RatingHolder extends BaseViewHolder { + private static class RatingHolder extends BaseViewHolder + { final TextView mHotelRating; final TextView mHotelRatingBase; - RatingHolder(View itemView, RecyclerClickListener listener) { + RatingHolder(View itemView, RecyclerClickListener listener) + { super(itemView, listener); mHotelRating = (TextView) itemView.findViewById(R.id.tv__place_hotel_rating); mHotelRatingBase = (TextView) itemView.findViewById(R.id.tv__place_hotel_rating_base); } - public void bind(String rating, int ratingBase) { + public void bind(String rating, int ratingBase) + { mHotelRating.setText(rating); mHotelRatingBase.setText(mHotelRatingBase.getContext().getResources() - .getQuantityString(R.plurals.place_page_booking_rating_base, - ratingBase, ratingBase)); + .getQuantityString(R.plurals.place_page_booking_rating_base, + ratingBase, ratingBase)); } } } diff --git a/android/src/com/mapswithme/maps/review/ReviewFragment.java b/android/src/com/mapswithme/maps/review/ReviewFragment.java index 7f5f562054..cfb39156e1 100644 --- a/android/src/com/mapswithme/maps/review/ReviewFragment.java +++ b/android/src/com/mapswithme/maps/review/ReviewFragment.java @@ -1,9 +1,5 @@ package com.mapswithme.maps.review; -import com.mapswithme.maps.R; -import com.mapswithme.maps.base.BaseMwmFragment; -import com.mapswithme.maps.widget.recycler.RecyclerClickListener; - import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -14,29 +10,42 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import com.mapswithme.maps.R; +import com.mapswithme.maps.base.BaseMwmFragment; +import com.mapswithme.maps.widget.recycler.RecyclerClickListener; + import java.util.ArrayList; -public class ReviewFragment extends BaseMwmFragment implements RecyclerClickListener { +public class ReviewFragment extends BaseMwmFragment implements RecyclerClickListener +{ + @Nullable private ArrayList mItems; + @Nullable private String mRating; private int mRatingBase; + @Nullable private String mUrl; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, - @Nullable Bundle savedInstanceState) { + @Nullable Bundle savedInstanceState) + { return inflater.inflate(R.layout.fragment_review, container, false); } @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) + { super.onViewCreated(view, savedInstanceState); readArguments(); - RecyclerView rvGallery = (RecyclerView) view.findViewById(R.id.rv__review); - rvGallery.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); - rvGallery.setAdapter(new ReviewAdapter(mItems, this, mRating, mRatingBase)); + if (mItems != null && mRating != null) + { + RecyclerView rvGallery = (RecyclerView) view.findViewById(R.id.rv__review); + rvGallery.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); + rvGallery.setAdapter(new ReviewAdapter(mItems, this, mRating, mRatingBase)); + } } private void readArguments() @@ -52,7 +61,11 @@ public class ReviewFragment extends BaseMwmFragment implements RecyclerClickList } @Override - public void onItemClick(View v, int position) { + public void onItemClick(View v, int position) + { + if (mUrl == null) + return; + final Intent intent = new Intent(Intent.ACTION_VIEW); String url = mUrl; if (!url.startsWith("http://") && !url.startsWith("https://")) diff --git a/android/src/com/mapswithme/maps/widget/LineCountTextView.java b/android/src/com/mapswithme/maps/widget/LineCountTextView.java index afd4f9a4bd..34060ab173 100644 --- a/android/src/com/mapswithme/maps/widget/LineCountTextView.java +++ b/android/src/com/mapswithme/maps/widget/LineCountTextView.java @@ -6,44 +6,52 @@ import android.text.Layout; import android.util.AttributeSet; import android.widget.TextView; -public class LineCountTextView extends TextView { +public class LineCountTextView extends TextView +{ - public interface OnLineCountCalculatedListener { + public interface OnLineCountCalculatedListener + { void onLineCountCalculated(boolean grater); } private OnLineCountCalculatedListener mListener; - public LineCountTextView(Context context) { + public LineCountTextView(Context context) + { super(context); } - public LineCountTextView(Context context, AttributeSet attrs) { + public LineCountTextView(Context context, AttributeSet attrs) + { super(context, attrs); } - public LineCountTextView(Context context, AttributeSet attrs, int defStyleAttr) { + public LineCountTextView(Context context, AttributeSet attrs, int defStyleAttr) + { super(context, attrs, defStyleAttr); } @Override - protected void onDraw(Canvas canvas) { + protected void onDraw(Canvas canvas) + { super.onDraw(canvas); Layout layout = getLayout(); - if (layout != null) { + if (layout != null) + { int textHeight = layout.getHeight(); int viewHeight = getHeight(); - if (mListener != null) { + if (mListener != null) + { mListener.onLineCountCalculated(textHeight > viewHeight); } } } - public void setListener( - OnLineCountCalculatedListener listener) { + public void setListener(OnLineCountCalculatedListener listener) + { mListener = listener; } } diff --git a/android/src/com/mapswithme/maps/widget/StaticGridView.java b/android/src/com/mapswithme/maps/widget/StaticGridView.java index db77432f2b..a89fbe6fcf 100644 --- a/android/src/com/mapswithme/maps/widget/StaticGridView.java +++ b/android/src/com/mapswithme/maps/widget/StaticGridView.java @@ -4,22 +4,27 @@ import android.content.Context; import android.util.AttributeSet; import android.widget.GridView; -public class StaticGridView extends GridView { +public class StaticGridView extends GridView +{ - public StaticGridView(Context context) { + public StaticGridView(Context context) + { super(context); } - public StaticGridView(Context context, AttributeSet attrs) { + public StaticGridView(Context context, AttributeSet attrs) + { super(context, attrs); } - public StaticGridView(Context context, AttributeSet attrs, int defStyleAttr) { + public StaticGridView(Context context, AttributeSet attrs, int defStyleAttr) + { super(context, attrs, defStyleAttr); } @Override - public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) + { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST)); getLayoutParams().height = getMeasuredHeight(); } diff --git a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java index 9ab248ef03..3a5aa72e7e 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/FacilitiesAdapter.java @@ -1,7 +1,6 @@ package com.mapswithme.maps.widget.placepage; -import com.mapswithme.maps.R; - +import android.support.annotation.NonNull; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -9,71 +8,87 @@ import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; +import com.mapswithme.maps.R; + import java.util.ArrayList; import java.util.List; -class FacilitiesAdapter extends BaseAdapter { +class FacilitiesAdapter extends BaseAdapter +{ static final int MAX_COUNT = 6; - private List items = new ArrayList<>(); + @NonNull + private List mItems = new ArrayList<>(); private boolean isShowAll = false; @Override - public int getCount() { - if (items.size() > MAX_COUNT && !isShowAll) { + public int getCount() + { + if (mItems.size() > MAX_COUNT && !isShowAll) + { return MAX_COUNT; } - return items.size(); + return mItems.size(); } @Override - public Object getItem(int position) { - return items.get(position); + public Object getItem(int position) + { + return mItems.get(position); } @Override - public long getItemId(int position) { + public long getItemId(int position) + { return position; } @Override - public View getView(int position, View convertView, ViewGroup parent) { + public View getView(int position, View convertView, ViewGroup parent) + { ViewHolder holder; - if (convertView == null) { + if (convertView == null) + { convertView = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.item_facility, parent, false); + .inflate(R.layout.item_facility, parent, false); holder = new ViewHolder(convertView); convertView.setTag(holder); - } else { + } + else + { holder = (ViewHolder) convertView.getTag(); } - holder.bind(items.get(position)); + holder.bind(mItems.get(position)); return convertView; } - public void setItems( - List items) { - this.items = items; + public void setItems(@NonNull List items) + { + this.mItems = items; notifyDataSetChanged(); } - void setShowAll(boolean showAll) { + void setShowAll(boolean showAll) + { isShowAll = showAll; notifyDataSetChanged(); } - private static class ViewHolder { + private static class ViewHolder + { ImageView mIcon; TextView mName; - public ViewHolder(View view) { + public ViewHolder(View view) + { mIcon = (ImageView) view.findViewById(R.id.iv__icon); mName = (TextView) view.findViewById(R.id.tv__facility); } - public void bind(SponsoredHotel.FacilityType facility) { + public void bind(SponsoredHotel.FacilityType facility) + { // 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/GalleryAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java index 54d3f29b7b..a7ec45ea17 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java @@ -1,5 +1,15 @@ package com.mapswithme.maps.widget.placepage; +import android.content.Context; +import android.graphics.Bitmap; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + import com.bumptech.glide.Glide; import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SimpleTarget; @@ -8,118 +18,123 @@ import com.mapswithme.maps.gallery.Image; import com.mapswithme.maps.widget.recycler.RecyclerClickListener; import com.mapswithme.util.UiUtils; -import android.content.Context; -import android.graphics.Bitmap; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; - import java.util.ArrayList; import java.util.List; -class GalleryAdapter extends RecyclerView.Adapter { +class GalleryAdapter extends RecyclerView.Adapter +{ static final int MAX_COUNT = 5; private final Context mContext; + @NonNull private ArrayList mItems = new ArrayList<>(); + @NonNull private final List mLoadedItems = new ArrayList<>(); + @NonNull + private final List mItemsToDownload = new ArrayList<>(); + @Nullable private RecyclerClickListener mListener; private final int mImageWidth; private final int mImageHeight; - private final Object mMutex = new Object(); - private final List mDownloadStates = new ArrayList<>(); - GalleryAdapter(Context context) { + GalleryAdapter(Context context) + { mContext = context; - mImageWidth = (int)context.getResources().getDimension(R.dimen.placepage_hotel_gallery_width); - mImageHeight = (int)context.getResources().getDimension(R.dimen.placepage_hotel_gallery_height); + mImageWidth = (int) context.getResources().getDimension(R.dimen.placepage_hotel_gallery_width); + mImageHeight = (int) context.getResources() + .getDimension(R.dimen.placepage_hotel_gallery_height); } @Override - public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) + { return new ViewHolder(LayoutInflater.from(mContext) - .inflate(R.layout.item_gallery, parent, false), mListener); + .inflate(R.layout.item_gallery, parent, false), mListener); } @Override - public void onBindViewHolder(ViewHolder holder, int position) { + public void onBindViewHolder(ViewHolder holder, int position) + { Item item = mLoadedItems.get(position); item.setShowMore(position == MAX_COUNT - 1); holder.bind(item, position); } @Override - public int getItemCount() { - synchronized (mMutex) { - return mLoadedItems.size(); - } + public int getItemCount() + { + return mLoadedItems.size(); } - public ArrayList getItems() { + @NonNull + public ArrayList getItems() + { return mItems; } - public void setItems(ArrayList items) { + public void setItems(@NonNull ArrayList items) + { mItems = items; - synchronized (mMutex) { - mLoadedItems.clear(); - for (DownloadState state: mDownloadStates) { - state.isCanceled = true; - } - mDownloadStates.clear(); + + for (Item item : mItemsToDownload) + { + item.setCanceled(true); } + mItemsToDownload.clear(); + mLoadedItems.clear(); loadImages(); notifyDataSetChanged(); } - public void setListener(RecyclerClickListener listener) { + public void setListener(@Nullable RecyclerClickListener listener) + { mListener = listener; } - private void loadImages() { - int size = mItems.size(); - if (size > MAX_COUNT) { - size = MAX_COUNT; - } + private void loadImages() + { + int size = mItems.size() > MAX_COUNT ? MAX_COUNT : mItems.size(); - for (int i = 0; i < size; i++) { - final DownloadState state; - synchronized (mMutex) { - state = new DownloadState(); - mDownloadStates.add(state); - } + for (int i = 0; i < size; i++) + { + final Item item = new Item(null); + mItemsToDownload.add(item); Image image = mItems.get(i); Glide.with(mContext) - .load(image.getSmallUrl()) - .asBitmap() - .centerCrop() - .into(new SimpleTarget(mImageWidth, mImageHeight) { - @Override - public void onResourceReady(Bitmap resource, - GlideAnimation glideAnimation) { - synchronized (mMutex) { - if (state.isCanceled) { - return; - } - int size = mLoadedItems.size(); - mLoadedItems.add(new Item(resource)); - notifyItemInserted(size); - } - } - }); + .load(image.getSmallUrl()) + .asBitmap() + .centerCrop() + .into(new SimpleTarget(mImageWidth, mImageHeight) + { + @Override + public void onResourceReady(Bitmap resource, + GlideAnimation glideAnimation) + { + if (item.isCanceled()) + return; + + item.setBitmap(resource); + int size = mLoadedItems.size(); + mLoadedItems.add(item); + notifyItemInserted(size); + } + }); } } - static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener + { + @NonNull private ImageView mImage; + @NonNull private View mMore; + @Nullable private final RecyclerClickListener mListener; private int mPosition; - public ViewHolder(View itemView, RecyclerClickListener listener) { + public ViewHolder(View itemView, @Nullable RecyclerClickListener listener) + { super(itemView); mListener = listener; mImage = (ImageView) itemView.findViewById(R.id.iv__image); @@ -128,47 +143,70 @@ class GalleryAdapter extends RecyclerView.Adapter { } @Override - public void onClick(View v) { - if (mListener == null) { + public void onClick(View v) + { + if (mListener == null) return; - } mListener.onItemClick(v, mPosition); } - public void bind(Item item, int position) { + public void bind(Item item, int position) + { mPosition = position; mImage.setImageBitmap(item.getBitmap()); - if (item.isShowMore()) { + if (item.isShowMore()) + { UiUtils.show(mMore); - } else { + } + else + { UiUtils.hide(mMore); } } } - static class Item { - private final Bitmap mBitmap; + static class Item + { + @Nullable + private Bitmap mBitmap; private boolean isShowMore; + private boolean isCanceled = false; - Item(Bitmap bitmap) { + Item(@Nullable Bitmap bitmap) + { this.mBitmap = bitmap; } - Bitmap getBitmap() { + @Nullable + Bitmap getBitmap() + { return mBitmap; } - void setShowMore(boolean showMore) { + void setBitmap(@Nullable Bitmap bitmap) + { + mBitmap = bitmap; + } + + void setShowMore(boolean showMore) + { isShowMore = showMore; } - boolean isShowMore() { + boolean isShowMore() + { return isShowMore; } - } - private static class DownloadState { - boolean isCanceled = false; + boolean isCanceled() + { + return isCanceled; + } + + void setCanceled(boolean canceled) + { + isCanceled = canceled; + } } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/LeftPlacePageAnimationController.java b/android/src/com/mapswithme/maps/widget/placepage/LeftPlacePageAnimationController.java index b68a2b068e..d981692c74 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/LeftPlacePageAnimationController.java +++ b/android/src/com/mapswithme/maps/widget/placepage/LeftPlacePageAnimationController.java @@ -13,7 +13,7 @@ import com.mapswithme.util.UiUtils; class LeftPlacePageAnimationController extends BasePlacePageAnimationController { - public LeftPlacePageAnimationController(@NonNull PlacePageView placePage) + LeftPlacePageAnimationController(@NonNull PlacePageView placePage) { super(placePage); } @@ -27,22 +27,21 @@ class LeftPlacePageAnimationController extends BasePlacePageAnimationController @Override protected boolean onInterceptTouchEvent(MotionEvent event) { - if (mPlacePage.isTouchGallery(event)) { + if (mPlacePage.isTouchGallery(event)) return false; - } switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - mIsDragging = false; - mDownCoord = event.getX(); - break; - case MotionEvent.ACTION_MOVE: - if (mDownCoord > mPlacePage.getRight()) - return false; - if (Math.abs(mDownCoord - event.getX()) > mTouchSlop) - return true; - break; + case MotionEvent.ACTION_DOWN: + mIsDragging = false; + mDownCoord = event.getX(); + break; + case MotionEvent.ACTION_MOVE: + if (mDownCoord > mPlacePage.getRight()) + return false; + if (Math.abs(mDownCoord - event.getX()) > mTouchSlop) + return true; + break; } return false; @@ -74,7 +73,7 @@ class LeftPlacePageAnimationController extends BasePlacePageAnimationController final boolean isInRange = Math.abs(distanceX) > X_MIN && Math.abs(distanceX) < X_MAX; if (!isHorizontal || !isInRange) - return false;; + return false; if (!mIsDragging) { @@ -94,13 +93,13 @@ class LeftPlacePageAnimationController extends BasePlacePageAnimationController { switch (newState) { - case HIDDEN: - hidePlacePage(); - break; - case DETAILS: - case PREVIEW: - showPlacePage(currentState, newState); - break; + case HIDDEN: + hidePlacePage(); + break; + case DETAILS: + case PREVIEW: + showPlacePage(currentState); + break; } } @@ -134,7 +133,7 @@ class LeftPlacePageAnimationController extends BasePlacePageAnimationController tracker.onTrackLeftAnimation(offset + mPlacePage.getDockedWidth()); } - private void showPlacePage(final State currentState, final State newState) + private void showPlacePage(final State currentState) { UiUtils.show(mPlacePage); if (currentState != State.HIDDEN) diff --git a/android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java index 154d342f1d..97bdca8995 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/NearbyAdapter.java @@ -1,9 +1,8 @@ package com.mapswithme.maps.widget.placepage; -import com.mapswithme.maps.R; -import com.mapswithme.util.ThemeUtils; - import android.content.res.Resources; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -11,69 +10,90 @@ import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; +import com.mapswithme.maps.R; +import com.mapswithme.util.ThemeUtils; + import java.util.ArrayList; import java.util.List; -class NearbyAdapter extends BaseAdapter { +class NearbyAdapter extends BaseAdapter +{ + @NonNull + private List mItems = new ArrayList<>(); + @Nullable + private final OnItemClickListener mListener; - NearbyAdapter(OnItemClickListener listener) { + NearbyAdapter(@Nullable OnItemClickListener listener) + { mListener = listener; } - interface OnItemClickListener { - void onItemClick(SponsoredHotel.NearbyObject item); - } - - private List items = new ArrayList<>(); - private final OnItemClickListener mListener; - - @Override - public int getCount() { - return items.size(); + interface OnItemClickListener + { + void onItemClick(@NonNull SponsoredHotel.NearbyObject item); } @Override - public Object getItem(int position) { - return items.get(position); + public int getCount() + { + return mItems.size(); } @Override - public long getItemId(int position) { + public Object getItem(int position) + { + return mItems.get(position); + } + + @Override + public long getItemId(int position) + { return position; } @Override - public View getView(int position, View convertView, ViewGroup parent) { + public View getView(int position, View convertView, ViewGroup parent) + { ViewHolder holder; - if (convertView == null) { + if (convertView == null) + { convertView = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.item_nearby, parent, false); + .inflate(R.layout.item_nearby, parent, false); holder = new ViewHolder(convertView, mListener); convertView.setTag(holder); - } else { + } else + { holder = (ViewHolder) convertView.getTag(); } - holder.bind(items.get(position)); + holder.bind(mItems.get(position)); return convertView; } - public void setItems( - List items) { - this.items = items; + public void setItems(@NonNull List items) + { + this.mItems = items; notifyDataSetChanged(); } - private static class ViewHolder implements View.OnClickListener { + private static class ViewHolder implements View.OnClickListener + { + @Nullable final OnItemClickListener mListener; + @NonNull ImageView mIcon; + @NonNull TextView mTitle; + @NonNull TextView mType; + @NonNull TextView mDistance; + @Nullable SponsoredHotel.NearbyObject mItem; - public ViewHolder(View view, OnItemClickListener listener) { + public ViewHolder(View view, @Nullable OnItemClickListener listener) + { mListener = listener; mIcon = (ImageView) view.findViewById(R.id.iv__icon); mTitle = (TextView) view.findViewById(R.id.tv__title); @@ -83,13 +103,14 @@ class NearbyAdapter extends BaseAdapter { } @Override - public void onClick(View v) { - if (mListener != null) { + public void onClick(View v) + { + if (mListener != null && mItem != null) mListener.onItemClick(mItem); - } } - public void bind(SponsoredHotel.NearbyObject item) { + public void bind(@NonNull SponsoredHotel.NearbyObject item) + { mItem = item; String packageName = mType.getContext().getPackageName(); final boolean isNightTheme = ThemeUtils.isNightTheme(); diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 2447002fb3..dcdae42812 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -35,16 +35,6 @@ import android.widget.RelativeLayout; import android.widget.ScrollView; import android.widget.TextView; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Currency; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - import com.mapswithme.maps.Framework; import com.mapswithme.maps.MwmActivity; import com.mapswithme.maps.MwmApplication; @@ -84,15 +74,25 @@ import com.mapswithme.util.sharing.ShareOption; import com.mapswithme.util.statistics.AlohaHelper; import com.mapswithme.util.statistics.Statistics; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Currency; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; public class PlacePageView extends RelativeLayout - implements View.OnClickListener, - View.OnLongClickListener, - SponsoredHotel.OnPriceReceivedListener, - SponsoredHotel.OnInfoReceivedListener, - LineCountTextView.OnLineCountCalculatedListener, - RecyclerClickListener, - NearbyAdapter.OnItemClickListener { + implements View.OnClickListener, + View.OnLongClickListener, + SponsoredHotel.OnPriceReceivedListener, + SponsoredHotel.OnInfoReceivedListener, + LineCountTextView.OnLineCountCalculatedListener, + RecyclerClickListener, + NearbyAdapter.OnItemClickListener +{ private static final String PREF_USE_DMS = "use_dms"; private boolean mIsDocked; @@ -161,10 +161,14 @@ public class PlacePageView extends RelativeLayout private SponsoredHotel mSponsoredHotel; private String mSponsoredHotelPrice; private boolean mIsLatLonDms; - private FacilitiesAdapter mFacilitiesAdapter = new FacilitiesAdapter(); - private GalleryAdapter mGalleryAdapter; - private NearbyAdapter mNearbyAdapter = new NearbyAdapter(this); - private ReviewAdapter mReviewAdapter = new ReviewAdapter(); + @NonNull + private final FacilitiesAdapter mFacilitiesAdapter = new FacilitiesAdapter(); + @NonNull + private final GalleryAdapter mGalleryAdapter; + @NonNull + private final NearbyAdapter mNearbyAdapter = new NearbyAdapter(this); + @NonNull + private final ReviewAdapter mReviewAdapter = new ReviewAdapter(); // Downloader`s stuff private DownloaderStatusIcon mDownloaderIcon; @@ -205,22 +209,6 @@ public class PlacePageView extends RelativeLayout } }; - public boolean isTouchGallery(MotionEvent event) { - if (UiUtils.isHidden(mHotelGallery)) - return false; - - float x = event.getX(); - float y = event.getY(); - int[] location = new int[2]; - mHotelGallery.getLocationOnScreen(location); - float viewX = (float) location[0]; - float viewY = (float) location[1]; - float width = (float) mHotelGallery.getWidth(); - float height = (float) mHotelGallery.getHeight(); - - return !(x < viewX || x > viewX + width || y < viewY || y > viewY + height); - } - public enum State { HIDDEN, @@ -243,12 +231,17 @@ public class PlacePageView extends RelativeLayout super(context, attrs); mIsLatLonDms = MwmApplication.prefs().getBoolean(PREF_USE_DMS, false); - + mGalleryAdapter = new GalleryAdapter(context); init(attrs, defStyleAttr); } public ViewGroup GetPreview() { return mPreview; } + public boolean isTouchGallery(@NonNull MotionEvent event) + { + return UiUtils.isViewTouched(event, mHotelGallery); + } + private void initViews() { LayoutInflater.from(getContext()).inflate(R.layout.place_page, this); @@ -317,36 +310,11 @@ public class PlacePageView extends RelativeLayout ViewGroup ppButtons = (ViewGroup) findViewById(R.id.pp__buttons); - 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); - mTvHotelDescription.setListener(this); - mHotelMoreDescription.setOnClickListener(this); - mHotelFacilities = findViewById(R.id.ll__place_hotel_facilities); - GridView gvHotelFacilities = (GridView) findViewById(R.id.gv__place_hotel_facilities); - mHotelMoreFacilities = findViewById(R.id.tv__place_hotel_facilities_more); - gvHotelFacilities.setAdapter(mFacilitiesAdapter); - mHotelMoreFacilities.setOnClickListener(this); - mHotelGallery = findViewById(R.id.ll__place_hotel_gallery); - mRvHotelGallery = (RecyclerView) findViewById( - R.id.rv__place_hotel_gallery); - mRvHotelGallery.setLayoutManager(new LinearLayoutManager(getContext(), - LinearLayoutManager.HORIZONTAL, false)); - mRvHotelGallery.addItemDecoration(new DividerItemDecoration(ContextCompat.getDrawable(getContext(), - R.drawable.divider_transparent))); - mGalleryAdapter = new GalleryAdapter(getContext()); - mGalleryAdapter.setListener(this); - mRvHotelGallery.setAdapter(mGalleryAdapter); - 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); - View hotelMoreReviews = findViewById(R.id.tv__place_hotel_reviews_more); - hotelMoreReviews.setOnClickListener(this); + initHotelDescriptionView(); + initHotelFacilitiesView(); + initHotelGalleryView(); + initHotelNearbyView(); + initHotelRatingView(); mButtons = new PlacePageButtons(this, ppButtons, new PlacePageButtons.ItemListener() { @@ -357,21 +325,21 @@ public class PlacePageView extends RelativeLayout switch (item) { - case BOOKING: - frame.setBackgroundResource(R.drawable.button_booking); - color = Color.WHITE; - break; + case BOOKING: + frame.setBackgroundResource(R.drawable.button_booking); + color = Color.WHITE; + break; - case BOOKMARK: - mBookmarkButtonIcon = icon; - updateButtons(); - color = ThemeUtils.getColor(getContext(), R.attr.iconTint); - break; + case BOOKMARK: + mBookmarkButtonIcon = icon; + updateButtons(); + color = ThemeUtils.getColor(getContext(), R.attr.iconTint); + break; - default: - color = ThemeUtils.getColor(getContext(), R.attr.iconTint); - icon.setColorFilter(color); - break; + default: + color = ThemeUtils.getColor(getContext(), R.attr.iconTint); + icon.setColorFilter(color); + break; } title.setTextColor(color); @@ -412,62 +380,63 @@ public class PlacePageView extends RelativeLayout hide(); break; - case ROUTE_TO: - if (RoutingController.get().isPlanning()) - { - if (RoutingController.get().setEndPoint(mMapObject)) - hide(); - } - else - { - getActivity().startLocationToPoint(Statistics.EventName.PP_ROUTE, AlohaHelper.PP_ROUTE, getMapObject()); - } - break; + case ROUTE_TO: + if (RoutingController.get().isPlanning()) + { + if (RoutingController.get().setEndPoint(mMapObject)) + hide(); + } + else + { + getActivity().startLocationToPoint(Statistics.EventName.PP_ROUTE, AlohaHelper.PP_ROUTE, getMapObject()); + } + break; - case BOOKING: - onBookingClick(true /* book */); - break; + case BOOKING: + onBookingClick(true /* book */); + break; } } }); mDownloaderIcon = new DownloaderStatusIcon(mPreview.findViewById(R.id.downloader_status_frame)) - .setOnIconClickListener(new OnClickListener() - { - @Override - public void onClick(View v) - { - MapManager.warn3gAndDownload(getActivity(), mCurrentCountry.id, new Runnable() - { - @Override - public void run() - { - Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_ACTION, - Statistics.params() - .add(Statistics.EventParam.ACTION, "download") - .add(Statistics.EventParam.FROM, "placepage") - .add("is_auto", "false") - .add("scenario", (mCurrentCountry.isExpandable() ? "download_group" - : "download"))); - } - }); - } - }).setOnCancelClickListener(new OnClickListener() - { - @Override - public void onClick(View v) - { - MapManager.nativeCancel(mCurrentCountry.id); - Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_CANCEL, - Statistics.params().add(Statistics.EventParam.FROM, "placepage")); - } - }); + .setOnIconClickListener(new OnClickListener() + { + @Override + public void onClick(View v) + { + MapManager.warn3gAndDownload(getActivity(), mCurrentCountry.id, new Runnable() + { + @Override + public void run() + { + Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_ACTION, + Statistics.params() + .add(Statistics.EventParam.ACTION, "download") + .add(Statistics.EventParam.FROM, "placepage") + .add("is_auto", "false") + .add("scenario", (mCurrentCountry.isExpandable() ? "download_group" + : "download"))); + } + }); + } + }).setOnCancelClickListener(new OnClickListener() + { + @Override + public void onClick(View v) + { + MapManager.nativeCancel(mCurrentCountry.id); + Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_CANCEL, + Statistics.params() + .add(Statistics.EventParam.FROM, "placepage")); + } + }); mDownloaderInfo = (TextView) mPreview.findViewById(R.id.tv__downloader_details); mShadowController = new ScrollViewShadowController((ObservableScrollView) mDetails) - .addBottomShadow() - .attach(); + .addBottomShadow() + .attach(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) setElevation(UiUtils.dimen(R.dimen.placepage_elevation)); @@ -479,8 +448,58 @@ public class PlacePageView extends RelativeLayout SponsoredHotel.setInfoListener(this); } + private void initHotelRatingView() + { + 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); + View hotelMoreReviews = findViewById(R.id.tv__place_hotel_reviews_more); + hotelMoreReviews.setOnClickListener(this); + } + + private void initHotelNearbyView() + { + mHotelNearby = findViewById(R.id.ll__place_hotel_nearby); + GridView gvHotelNearby = (GridView) findViewById(R.id.gv__place_hotel_nearby); + gvHotelNearby.setAdapter(mNearbyAdapter); + } + + private void initHotelGalleryView() + { + mHotelGallery = findViewById(R.id.ll__place_hotel_gallery); + mRvHotelGallery = (RecyclerView) findViewById( + R.id.rv__place_hotel_gallery); + mRvHotelGallery.setLayoutManager(new LinearLayoutManager(getContext(), + LinearLayoutManager.HORIZONTAL, false)); + mRvHotelGallery.addItemDecoration(new DividerItemDecoration(ContextCompat.getDrawable(getContext(), + R.drawable.divider_transparent))); + mGalleryAdapter.setListener(this); + mRvHotelGallery.setAdapter(mGalleryAdapter); + } + + private void initHotelFacilitiesView() + { + mHotelFacilities = findViewById(R.id.ll__place_hotel_facilities); + GridView gvHotelFacilities = (GridView) findViewById(R.id.gv__place_hotel_facilities); + mHotelMoreFacilities = findViewById(R.id.tv__place_hotel_facilities_more); + gvHotelFacilities.setAdapter(mFacilitiesAdapter); + mHotelMoreFacilities.setOnClickListener(this); + } + + private void initHotelDescriptionView() + { + 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); + mTvHotelDescription.setListener(this); + mHotelMoreDescription.setOnClickListener(this); + } + @Override - public void onPriceReceived(String id, String price, String currencyCode) + public void onPriceReceived(@NonNull String id, @NonNull String price, + @NonNull String currencyCode) { if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) return; @@ -500,67 +519,98 @@ public class PlacePageView extends RelativeLayout } @Override - public void onInfoReceived(String id, SponsoredHotel.HotelInfo info) { - if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) { + public void onInfoReceived(@NonNull String id, @NonNull SponsoredHotel.HotelInfo info) + { + if (mSponsoredHotel == null || !TextUtils.equals(id, mSponsoredHotel.getId())) return; - } - mTvHotelDescription.setMaxLines(5); - refreshMetadataOrHide(info.description, mHotelDescription, mTvHotelDescription); - mHotelMoreDescription.setVisibility(GONE); + updateHotelDetails(info); + updateHotelFacilities(info); + updateHotelGallery(info); + updateHotelNearby(info); + updateHotelRating(info); + } - if (info.facilities == null || info.facilities.length == 0) { - UiUtils.hide(mHotelFacilities); - } else { - UiUtils.show(mHotelFacilities); - mFacilitiesAdapter.setShowAll(false); - mFacilitiesAdapter.setItems(Arrays.asList(info.facilities)); - mHotelMoreFacilities.setVisibility(info.facilities.length > FacilitiesAdapter.MAX_COUNT - ? VISIBLE : GONE); - } - - if (info.photos == null || info.photos.length == 0) { - UiUtils.hide(mHotelGallery); - } else { - 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); - } else { - UiUtils.show(mHotelNearby); - mNearbyAdapter.setItems(Arrays.asList(info.nearby)); - } - - if (info.reviews == null || info.reviews.length == 0) { + private void updateHotelRating(@NonNull SponsoredHotel.HotelInfo info) + { + if (info.mReviews == null || info.mReviews.length == 0) UiUtils.hide(mHotelReview); - } else { + else + { UiUtils.show(mHotelReview); - mReviewAdapter.setItems(new ArrayList<>(Arrays.asList(info.reviews))); - mHotelRating.setText(mSponsoredHotel.rating); + mReviewAdapter.setItems(new ArrayList<>(Arrays.asList(info.mReviews))); + mHotelRating.setText(mSponsoredHotel.mRating); mHotelRatingBase.setText(getResources().getQuantityString(R.plurals.place_page_booking_rating_base, - info.reviews.length, info.reviews.length)); + info.mReviews.length, info.mReviews.length)); } } + private void updateHotelNearby(@NonNull SponsoredHotel.HotelInfo info) + { + if (info.mNearby == null || info.mNearby.length == 0) + UiUtils.hide(mHotelNearby); + else + { + UiUtils.show(mHotelNearby); + mNearbyAdapter.setItems(Arrays.asList(info.mNearby)); + } + } + + private void updateHotelGallery(@NonNull SponsoredHotel.HotelInfo info) + { + if (info.mPhotos == null || info.mPhotos.length == 0) + UiUtils.hide(mHotelGallery); + else + { + UiUtils.show(mHotelGallery); + mGalleryAdapter.setItems(new ArrayList<>(Arrays.asList(info.mPhotos))); + mRvHotelGallery.scrollToPosition(0); + } + } + + private void updateHotelFacilities(@NonNull SponsoredHotel.HotelInfo info) + { + if (info.mFacilities == null || info.mFacilities.length == 0) + UiUtils.hide(mHotelFacilities); + else + { + UiUtils.show(mHotelFacilities); + mFacilitiesAdapter.setShowAll(false); + mFacilitiesAdapter.setItems(Arrays.asList(info.mFacilities)); + mHotelMoreFacilities.setVisibility(info.mFacilities.length > FacilitiesAdapter.MAX_COUNT + ? VISIBLE : GONE); + } + } + + private void updateHotelDetails(@NonNull SponsoredHotel.HotelInfo info) + { + mTvHotelDescription.setMaxLines(getResources().getInteger(R.integer.pp_hotel_description_lines)); + refreshMetadataOrHide(info.mDescription, mHotelDescription, mTvHotelDescription); + mHotelMoreDescription.setVisibility(GONE); + } + @Override - public void onLineCountCalculated(boolean grater) { + public void onLineCountCalculated(boolean grater) + { mHotelMoreDescription.setVisibility(grater ? VISIBLE : GONE); } @Override - public void onItemClick(View v, int position) { - if (position == GalleryAdapter.MAX_COUNT - 1) { + public void onItemClick(View v, int position) + { + if (position == GalleryAdapter.MAX_COUNT - 1) + { GalleryActivity.start(getContext(), mGalleryAdapter.getItems(), mMapObject.getTitle()); - } else { + } + else + { FullScreenGalleryActivity.start(getContext(), mGalleryAdapter.getItems(), position); } } @Override - public void onItemClick(SponsoredHotel.NearbyObject item) { + public void onItemClick(@NonNull SponsoredHotel.NearbyObject item) + { // TODO go to selected object on map } @@ -593,7 +643,7 @@ public class PlacePageView extends RelativeLayout try { - followUrl(book ? info.urlBook : info.urlDescription); + followUrl(book ? info.mUrlBook : info.mUrlDescription); } catch (ActivityNotFoundException e) { AlohaHelper.logException(e); @@ -622,7 +672,7 @@ public class PlacePageView extends RelativeLayout public void restore() { // if (mMapObject != null) - // FIXME query map object again + // FIXME query map object again } @Override @@ -679,7 +729,7 @@ public class PlacePageView extends RelativeLayout /** * @param mapObject new MapObject - * @param force if true, new object'll be set without comparison with the old one + * @param force if true, new object'll be set without comparison with the old one */ public void setMapObject(MapObject mapObject, boolean force) { @@ -695,7 +745,7 @@ public class PlacePageView extends RelativeLayout if (mSponsoredHotel != null) { mSponsoredHotel.updateId(mMapObject); - mSponsoredHotelPrice = mSponsoredHotel.price; + mSponsoredHotelPrice = mSponsoredHotel.mPrice; Locale locale = Locale.getDefault(); Currency currency = Currency.getInstance(locale); @@ -722,27 +772,27 @@ public class PlacePageView extends RelativeLayout switch (mMapObject.getMapObjectType()) { - case MapObject.BOOKMARK: - refreshDistanceToObject(loc); - showBookmarkDetails(); - setButtons(false, true); - break; - case MapObject.POI: - case MapObject.SEARCH: - refreshDistanceToObject(loc); - hideBookmarkDetails(); - setButtons(false, true); - break; - case MapObject.API_POINT: - refreshDistanceToObject(loc); - hideBookmarkDetails(); - setButtons(true, true); - break; - case MapObject.MY_POSITION: - refreshMyPosition(loc); - hideBookmarkDetails(); - setButtons(false, false); - break; + case MapObject.BOOKMARK: + refreshDistanceToObject(loc); + showBookmarkDetails(); + setButtons(false, true); + break; + case MapObject.POI: + case MapObject.SEARCH: + refreshDistanceToObject(loc); + hideBookmarkDetails(); + setButtons(false, true); + break; + case MapObject.API_POINT: + refreshDistanceToObject(loc); + hideBookmarkDetails(); + setButtons(true, true); + break; + case MapObject.MY_POSITION: + refreshMyPosition(loc); + hideBookmarkDetails(); + setButtons(false, false); + break; } UiThread.runLater(new Runnable() @@ -787,7 +837,7 @@ public class PlacePageView extends RelativeLayout UiUtils.showIf(sponsored, mHotelInfo); if (sponsored) { - mTvHotelRating.setText(mSponsoredHotel.rating); + mTvHotelRating.setText(mSponsoredHotel.mRating); UiUtils.setTextAndHideIfEmpty(mTvHotelPrice, mSponsoredHotelPrice); } } @@ -806,7 +856,8 @@ public class PlacePageView extends RelativeLayout UiUtils.hide(mHotelNearby); UiUtils.hide(mHotelReview); } - else { + else + { UiUtils.hide(mWebsite); } @@ -970,8 +1021,11 @@ public class PlacePageView extends RelativeLayout return; mTvDistance.setVisibility(View.VISIBLE); - DistanceAndAzimut distanceAndAzimuth = Framework.nativeGetDistanceAndAzimuthFromLatLon(mMapObject.getLat(), mMapObject.getLon(), - l.getLatitude(), l.getLongitude(), 0.0); + DistanceAndAzimut distanceAndAzimuth = Framework.nativeGetDistanceAndAzimuthFromLatLon(mMapObject + .getLat(), mMapObject + .getLon(), + l.getLatitude(), l + .getLongitude(), 0.0); mTvDistance.setText(distanceAndAzimuth.getDistance()); } @@ -999,16 +1053,18 @@ public class PlacePageView extends RelativeLayout public void refreshAzimuth(double northAzimuth) { if (isHidden() || - mMapObject == null || - MapObject.isOfType(MapObject.MY_POSITION, mMapObject)) + mMapObject == null || + MapObject.isOfType(MapObject.MY_POSITION, mMapObject)) return; final Location location = LocationHelper.INSTANCE.getSavedLocation(); if (location == null) return; - final double azimuth = Framework.nativeGetDistanceAndAzimuthFromLatLon(mMapObject.getLat(), mMapObject.getLon(), - location.getLatitude(), location.getLongitude(), + final double azimuth = Framework.nativeGetDistanceAndAzimuthFromLatLon(mMapObject.getLat(), mMapObject + .getLon(), + location.getLatitude(), location + .getLongitude(), northAzimuth) .getAzimuth(); if (azimuth >= 0) @@ -1026,7 +1082,8 @@ public class PlacePageView extends RelativeLayout private void addOrganisation() { Statistics.INSTANCE.trackEvent(Statistics.EventName.EDITOR_ADD_CLICK, - Statistics.params().add(Statistics.EventParam.FROM, "placepage")); + Statistics.params() + .add(Statistics.EventParam.FROM, "placepage")); getActivity().showPositionChooser(true, false); } @@ -1041,68 +1098,69 @@ public class PlacePageView extends RelativeLayout { switch (v.getId()) { - case R.id.ll__place_editor: - getActivity().showEditor(); - break; - case R.id.ll__add_organisation: - addOrganisation(); - break; - case R.id.ll__place_add: - addPlace(); - break; - case R.id.ll__more: - onBookingClick(false /* book */); - break; - case R.id.ll__place_latlon: - mIsLatLonDms = !mIsLatLonDms; - MwmApplication.prefs().edit().putBoolean(PREF_USE_DMS, mIsLatLonDms).commit(); - refreshLatLon(); - break; - case R.id.ll__place_phone: - Intent intent = new Intent(Intent.ACTION_DIAL); - intent.setData(Uri.parse("tel:" + mTvPhone.getText())); - try - { + case R.id.ll__place_editor: + getActivity().showEditor(); + break; + case R.id.ll__add_organisation: + addOrganisation(); + break; + case R.id.ll__place_add: + addPlace(); + break; + case R.id.ll__more: + onBookingClick(false /* book */); + break; + case R.id.ll__place_latlon: + mIsLatLonDms = !mIsLatLonDms; + MwmApplication.prefs().edit().putBoolean(PREF_USE_DMS, mIsLatLonDms).commit(); + refreshLatLon(); + break; + case R.id.ll__place_phone: + Intent intent = new Intent(Intent.ACTION_DIAL); + intent.setData(Uri.parse("tel:" + mTvPhone.getText())); + try + { + getContext().startActivity(intent); + } catch (ActivityNotFoundException e) + { + AlohaHelper.logException(e); + } + break; + case R.id.ll__place_website: + followUrl(mTvWebsite.getText().toString()); + break; + case R.id.ll__place_wiki: + // TODO: Refactor and use separate getters for Wiki and all other PP meta info too. + followUrl(mMapObject.getMetadata(Metadata.MetadataType.FMD_WIKIPEDIA)); + break; + case R.id.direction_frame: + Statistics.INSTANCE.trackEvent(Statistics.EventName.PP_DIRECTION_ARROW); + AlohaHelper.logClick(AlohaHelper.PP_DIRECTION_ARROW); + showBigDirection(); + break; + case R.id.ll__place_email: + intent = new Intent(Intent.ACTION_SENDTO); + intent.setData(Utils.buildMailUri(mTvEmail.getText().toString(), "", "")); getContext().startActivity(intent); - } catch (ActivityNotFoundException e) - { - AlohaHelper.logException(e); - } - break; - case R.id.ll__place_website: - followUrl(mTvWebsite.getText().toString()); - break; - case R.id.ll__place_wiki: - // TODO: Refactor and use separate getters for Wiki and all other PP meta info too. - followUrl(mMapObject.getMetadata(Metadata.MetadataType.FMD_WIKIPEDIA)); - break; - case R.id.direction_frame: - Statistics.INSTANCE.trackEvent(Statistics.EventName.PP_DIRECTION_ARROW); - AlohaHelper.logClick(AlohaHelper.PP_DIRECTION_ARROW); - showBigDirection(); - break; - case R.id.ll__place_email: - intent = new Intent(Intent.ACTION_SENDTO); - intent.setData(Utils.buildMailUri(mTvEmail.getText().toString(), "", "")); - getContext().startActivity(intent); - break; - case R.id.tv__bookmark_edit: - Bookmark bookmark = (Bookmark) mMapObject; - EditBookmarkFragment.editBookmark(bookmark.getCategoryId(), bookmark.getBookmarkId(), - getActivity(), getActivity().getSupportFragmentManager()); - break; - case R.id.tv__place_hotel_more: - UiUtils.hide(mHotelMoreDescription); - mTvHotelDescription.setMaxLines(Integer.MAX_VALUE); - break; - case R.id.tv__place_hotel_facilities_more: - UiUtils.hide(mHotelMoreFacilities); - mFacilitiesAdapter.setShowAll(true); - break; - case R.id.tv__place_hotel_reviews_more: - ReviewActivity.start(getContext(), mReviewAdapter.getItems(), mMapObject.getTitle(), - mSponsoredHotel.rating, mReviewAdapter.getItems().size(), mSponsoredHotel.urlBook); - break; + break; + case R.id.tv__bookmark_edit: + Bookmark bookmark = (Bookmark) mMapObject; + EditBookmarkFragment.editBookmark(bookmark.getCategoryId(), bookmark.getBookmarkId(), + getActivity(), getActivity().getSupportFragmentManager()); + break; + case R.id.tv__place_hotel_more: + UiUtils.hide(mHotelMoreDescription); + mTvHotelDescription.setMaxLines(Integer.MAX_VALUE); + break; + case R.id.tv__place_hotel_facilities_more: + UiUtils.hide(mHotelMoreFacilities); + mFacilitiesAdapter.setShowAll(true); + break; + case R.id.tv__place_hotel_reviews_more: + ReviewActivity.start(getContext(), mReviewAdapter.getItems(), mMapObject.getTitle(), + mSponsoredHotel.mRating, mReviewAdapter.getItems() + .size(), mSponsoredHotel.mUrlBook); + break; } } @@ -1134,7 +1192,8 @@ public class PlacePageView extends RelativeLayout private void showBigDirection() { - final DirectionFragment fragment = (DirectionFragment) Fragment.instantiate(getActivity(), DirectionFragment.class.getName(), null); + final DirectionFragment fragment = (DirectionFragment) Fragment.instantiate(getActivity(), DirectionFragment.class + .getName(), null); fragment.setMapObject(mMapObject); fragment.show(getActivity().getSupportFragmentManager(), null); } @@ -1151,30 +1210,30 @@ public class PlacePageView extends RelativeLayout final List items = new ArrayList<>(); switch (v.getId()) { - case R.id.ll__place_latlon: - final double lat = mMapObject.getLat(); - final double lon = mMapObject.getLon(); - items.add(Framework.nativeFormatLatLon(lat, lon, false)); - items.add(Framework.nativeFormatLatLon(lat, lon, true)); - break; - case R.id.ll__place_website: - items.add(mTvWebsite.getText().toString()); - break; - case R.id.ll__place_email: - items.add(mTvEmail.getText().toString()); - break; - case R.id.ll__place_phone: - items.add(mTvPhone.getText().toString()); - break; - case R.id.ll__place_schedule: - items.add(mFullOpeningHours.getText().toString()); - break; - case R.id.ll__place_operator: - items.add(mTvOperator.getText().toString()); - break; - case R.id.ll__place_wiki: - items.add(mMapObject.getMetadata(Metadata.MetadataType.FMD_WIKIPEDIA)); - break; + case R.id.ll__place_latlon: + final double lat = mMapObject.getLat(); + final double lon = mMapObject.getLon(); + items.add(Framework.nativeFormatLatLon(lat, lon, false)); + items.add(Framework.nativeFormatLatLon(lat, lon, true)); + break; + case R.id.ll__place_website: + items.add(mTvWebsite.getText().toString()); + break; + case R.id.ll__place_email: + items.add(mTvEmail.getText().toString()); + break; + case R.id.ll__place_phone: + items.add(mTvPhone.getText().toString()); + break; + case R.id.ll__place_schedule: + items.add(mFullOpeningHours.getText().toString()); + break; + case R.id.ll__place_operator: + items.add(mTvOperator.getText().toString()); + break; + case R.id.ll__place_wiki: + items.add(mMapObject.getMetadata(Metadata.MetadataType.FMD_WIKIPEDIA)); + break; } final String copyText = getResources().getString(android.R.string.copy); diff --git a/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java index 90ef5d214e..8c91269b81 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java @@ -1,9 +1,6 @@ package com.mapswithme.maps.widget.placepage; -import com.mapswithme.maps.R; -import com.mapswithme.maps.review.Review; -import com.mapswithme.util.UiUtils; - +import android.support.annotation.NonNull; import android.text.TextUtils; import android.text.format.DateFormat; import android.view.LayoutInflater; @@ -12,71 +9,93 @@ import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; +import com.mapswithme.maps.R; +import com.mapswithme.maps.review.Review; +import com.mapswithme.util.UiUtils; + import java.util.ArrayList; import java.util.Date; import java.util.Locale; -class ReviewAdapter extends BaseAdapter { +class ReviewAdapter extends BaseAdapter +{ private static final int MAX_COUNT = 3; - private ArrayList items = new ArrayList<>(); + @NonNull + private ArrayList mItems = new ArrayList<>(); @Override - public int getCount() { - if (items.size() > MAX_COUNT) { - return MAX_COUNT; - } - return items.size(); + public int getCount() + { + return mItems.size() > MAX_COUNT ? MAX_COUNT : mItems.size(); } @Override - public Object getItem(int position) { - return items.get(position); + public Object getItem(int position) + { + return mItems.get(position); } @Override - public long getItemId(int position) { + public long getItemId(int position) + { return position; } @Override - public View getView(int position, View convertView, ViewGroup parent) { + public View getView(int position, View convertView, ViewGroup parent) + { ViewHolder holder; - if (convertView == null) { + if (convertView == null) + { convertView = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.item_comment, parent, false); + .inflate(R.layout.item_comment, parent, false); holder = new ViewHolder(convertView); convertView.setTag(holder); - } else { + } + else + { holder = (ViewHolder) convertView.getTag(); } - holder.bind(items.get(position), position > 0); + holder.bind(mItems.get(position), position > 0); return convertView; } - public void setItems( - ArrayList items) { - this.items = items; + public void setItems(@NonNull ArrayList items) + { + this.mItems = items; notifyDataSetChanged(); } - public ArrayList getItems() { - return items; + @NonNull + public ArrayList getItems() + { + return mItems; } - private static class ViewHolder { + private static class ViewHolder + { + @NonNull final View mDivider; + @NonNull final TextView mUserName; + @NonNull final TextView mCommentDate; + @NonNull final TextView mRating; + @NonNull final View mPositiveReview; + @NonNull final TextView mTvPositiveReview; + @NonNull final View mNegativeReview; + @NonNull final TextView mTvNegativeReview; - public ViewHolder(View view) { + 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); @@ -87,24 +106,31 @@ class ReviewAdapter extends BaseAdapter { mTvNegativeReview = (TextView) view.findViewById(R.id.tv__negative_review); } - public void bind(Review item, boolean isShowDivider) { + public void bind(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())) { + if (TextUtils.isEmpty(item.getReviewPositive())) + { UiUtils.hide(mPositiveReview); - } else { + } + else + { UiUtils.show(mPositiveReview); mTvPositiveReview.setText(item.getReviewPositive()); } - if (TextUtils.isEmpty(item.getReviewNegative())) { + if (TextUtils.isEmpty(item.getReviewNegative())) + { UiUtils.hide(mNegativeReview); - } else { + } + else + { UiUtils.show(mNegativeReview); mTvNegativeReview.setText(item.getReviewNegative()); } } } -} \ No newline at end of file +} diff --git a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java index dc3da30561..1ef4c46d28 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java +++ b/android/src/com/mapswithme/maps/widget/placepage/SponsoredHotel.java @@ -1,135 +1,194 @@ package com.mapswithme.maps.widget.placepage; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.UiThread; import android.text.TextUtils; -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.Map; - 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 java.lang.ref.WeakReference; +import java.util.HashMap; +import java.util.Map; + @UiThread -final class SponsoredHotel +public final class SponsoredHotel { private static class Price { - final String price; - final String currency; + @NonNull + final String mPrice; + @NonNull + final String mCurrency; - private Price(String price, String currency) + private Price(@NonNull String price, @NonNull String currency) { - this.price = price; - this.currency = currency; + mPrice = price; + mCurrency = currency; } } - static class FacilityType { - private final String key; - private final String name; + static class FacilityType + { + @NonNull + private final String mKey; + @NonNull + private final String mName; - public FacilityType(String key, String name) { - this.key = key; - this.name = name; + public FacilityType(@NonNull String key, @NonNull String name) + { + mKey = key; + mName = name; } - public String getKey() { - return key; + @NonNull + public String getKey() + { + return mKey; } - public String getName() { - return name; + @NonNull + public String getName() + { + return mName; } } - static class NearbyObject { - private final String category; - private final String title; - private final String distance; - private final double latitude; - private final double longitude; + static class NearbyObject + { + @NonNull + private final String mCategory; + @NonNull + private final String mTitle; + @NonNull + private final String mDistance; + private final double mLatitude; + private final double mLongitude; - public NearbyObject(String category, String title, String distance, double lat, double lon) { - this.category = category; - this.title = title; - this.distance = distance; - this.latitude = lat; - this.longitude = lon; + public NearbyObject(@NonNull String category, @NonNull String title, + @NonNull String distance, double lat, double lon) + { + mCategory = category; + mTitle = title; + mDistance = distance; + mLatitude = lat; + mLongitude = lon; } - public String getCategory() { - return category; + @NonNull + public String getCategory() + { + return mCategory; } - public String getTitle() { - return title; + @NonNull + public String getTitle() + { + return mTitle; } - public String getDistance() { - return distance; + @NonNull + public String getDistance() + { + return mDistance; } - public double getLatitude() { - return latitude; + public double getLatitude() + { + return mLatitude; } - public double getLongitude() { - return longitude; + public double getLongitude() + { + return mLongitude; } } - static class HotelInfo { - final String description; - final Image[] photos; - final FacilityType[] facilities; - final Review[] reviews; - final NearbyObject[] nearby; + static class HotelInfo + { + @Nullable + final String mDescription; + @Nullable + final Image[] mPhotos; + @Nullable + final FacilityType[] mFacilities; + @Nullable + final Review[] mReviews; + @Nullable + final NearbyObject[] mNearby; - public HotelInfo(String description, Image[] photos, - FacilityType[] facilities, Review[] reviews, - NearbyObject[] nearby) { - this.description = description; - this.photos = photos; - this.facilities = facilities; - this.reviews = reviews; - this.nearby = nearby; + public HotelInfo(@Nullable String description, @Nullable Image[] photos, + @Nullable FacilityType[] facilities, @Nullable Review[] reviews, + @Nullable NearbyObject[] nearby) + { + mDescription = description; + mPhotos = photos; + mFacilities = facilities; + mReviews = reviews; + mNearby = nearby; } } interface OnPriceReceivedListener { - void onPriceReceived(String id, String price, String currency); + /** + * This method is called from the native core on the UI thread + * when the Hotel price will be obtained + * + * @param id A hotel id + * @param price A price + * @param currency A price currency + */ + @UiThread + void onPriceReceived(@NonNull String id, @NonNull String price, @NonNull String currency); } interface OnInfoReceivedListener { - void onInfoReceived(String id, HotelInfo info); + /** + * This method is called from the native core on the UI thread + * when the Hotel information will be obtained + * + * @param id A hotel id + * @param info A hotel info + */ + @UiThread + void onInfoReceived(@NonNull String id, @NonNull HotelInfo info); } // Hotel ID -> Price + @NonNull private static final Map sPriceCache = new HashMap<>(); // Hotel ID -> Description + @NonNull private static final Map sInfoCache = new HashMap<>(); - private static WeakReference sPriceListener; - private static WeakReference sInfoListener; + @NonNull + private static WeakReference sPriceListener = new WeakReference<>(null); + @NonNull + private static WeakReference sInfoListener = new WeakReference<>(null); + @Nullable private String mId; - final String rating; - final String price; - final String urlBook; - final String urlDescription; + @NonNull + final String mRating; + @NonNull + final String mPrice; + @NonNull + final String mUrlBook; + @NonNull + final String mUrlDescription; - public SponsoredHotel(String rating, String price, String urlBook, String urlDescription) + public SponsoredHotel(@NonNull String rating, @NonNull String price, @NonNull String urlBook, + @NonNull String urlDescription) { - this.rating = rating; - this.price = price; - this.urlBook = urlBook; - this.urlDescription = urlDescription; + mRating = rating; + mPrice = price; + mUrlBook = urlBook; + mUrlDescription = urlDescription; } void updateId(MapObject point) @@ -137,50 +196,71 @@ final class SponsoredHotel mId = point.getMetadata(Metadata.MetadataType.FMD_SPONSORED_ID); } + @Nullable public String getId() { return mId; } + @NonNull public String getRating() { - return rating; + return mRating; } + @NonNull public String getPrice() { - return price; + return mPrice; } + @NonNull public String getUrlBook() { - return urlBook; + return mUrlBook; } + @NonNull public String getUrlDescription() { - return urlDescription; + return mUrlDescription; } - static void setPriceListener(OnPriceReceivedListener listener) + static void setPriceListener(@NonNull OnPriceReceivedListener listener) { sPriceListener = new WeakReference<>(listener); } - static void setInfoListener(OnInfoReceivedListener listener) + static void setInfoListener(@NonNull OnInfoReceivedListener listener) { sInfoListener = new WeakReference<>(listener); } + /** + * Make request to obtain hotel price information. + * This method also checks cache for requested hotel id + * and if cache exists - call {@link #onPriceReceived(String, String, String) onPriceReceived} immediately + * + * @param id A Hotel id + * @param currencyCode A user currency + */ static void requestPrice(String id, String currencyCode) { Price p = sPriceCache.get(id); if (p != null) - onPriceReceived(id, p.price, p.currency); + onPriceReceived(id, p.mPrice, p.mCurrency); nativeRequestPrice(id, currencyCode); } + /** + * Make request to obtain hotel information. + * This method also checks cache for requested hotel id + * and if cache exists - call {@link #onInfoReceived(String, HotelInfo) onInfoReceived} immediately + * + * @param id A Hotel id + * @param locale A user locale + */ static void requestInfo(String id, String locale) { HotelInfo info = sInfoCache.get(id); @@ -190,38 +270,33 @@ final class SponsoredHotel nativeRequestInfo(id, locale); } - @SuppressWarnings("unused") - private static void onPriceReceived(String id, String price, String currency) + private static void onPriceReceived(@NonNull String id, @NonNull String price, + @NonNull String currency) { if (TextUtils.isEmpty(price)) return; sPriceCache.put(id, new Price(price, currency)); + OnPriceReceivedListener listener = sPriceListener.get(); - if (listener == null) - sPriceListener = null; - else + if (listener != null) listener.onPriceReceived(id, price, currency); } - @SuppressWarnings("unused") - private static void onInfoReceived(String id, HotelInfo info) + private static void onInfoReceived(@NonNull String id, @NonNull HotelInfo info) { - if (info == null) - return; - sInfoCache.put(id, info); OnInfoReceivedListener listener = sInfoListener.get(); - if (listener == null) - sInfoListener = null; - else + if (listener != null) listener.onInfoReceived(id, info); } @Nullable public static native SponsoredHotel nativeGetCurrent(); - private static native void nativeRequestPrice(String id, String currencyCode); - private static native void nativeRequestInfo(String id, String locale); + + private static native void nativeRequestPrice(@NonNull String id, @NonNull String currencyCode); + + private static native void nativeRequestInfo(@NonNull String id, @NonNull String locale); } diff --git a/android/src/com/mapswithme/maps/widget/recycler/DividerItemDecoration.java b/android/src/com/mapswithme/maps/widget/recycler/DividerItemDecoration.java index a7624fab85..ea3d6f0da1 100644 --- a/android/src/com/mapswithme/maps/widget/recycler/DividerItemDecoration.java +++ b/android/src/com/mapswithme/maps/widget/recycler/DividerItemDecoration.java @@ -3,6 +3,7 @@ package com.mapswithme.maps.widget.recycler; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.View; @@ -11,9 +12,11 @@ import android.view.View; * Adds interior dividers to a RecyclerView with a LinearLayoutManager or its * subclass. */ -public class DividerItemDecoration extends RecyclerView.ItemDecoration { +public class DividerItemDecoration extends RecyclerView.ItemDecoration +{ - private Drawable mDivider; + @NonNull + private final Drawable mDivider; private int mOrientation; /** @@ -22,7 +25,8 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration { * * @param divider A divider {@code Drawable} to be drawn on the RecyclerView */ - public DividerItemDecoration(Drawable divider) { + public DividerItemDecoration(@NonNull Drawable divider) + { mDivider = divider; } @@ -31,15 +35,15 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration { * * @param canvas The {@link Canvas} onto which dividers will be drawn * @param parent The RecyclerView onto which dividers are being added - * @param state The current RecyclerView.State of the RecyclerView + * @param state The current RecyclerView.State of the RecyclerView */ @Override - public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) { - if (mOrientation == LinearLayoutManager.HORIZONTAL) { + public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) + { + if (mOrientation == LinearLayoutManager.HORIZONTAL) drawHorizontalDividers(canvas, parent); - } else if (mOrientation == LinearLayoutManager.VERTICAL) { + else if (mOrientation == LinearLayoutManager.VERTICAL) drawVerticalDividers(canvas, parent); - } } /** @@ -48,24 +52,23 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration { * * @param outRect The {@link Rect} of offsets to be added around the child * view - * @param view The child view to be decorated with an offset - * @param parent The RecyclerView onto which dividers are being added - * @param state The current RecyclerView.State of the RecyclerView + * @param view The child view to be decorated with an offset + * @param parent The RecyclerView onto which dividers are being added + * @param state The current RecyclerView.State of the RecyclerView */ @Override - public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { + public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) + { super.getItemOffsets(outRect, view, parent, state); - if (parent.getChildAdapterPosition(view) == 0) { + if (parent.getChildAdapterPosition(view) == 0) return; - } mOrientation = ((LinearLayoutManager) parent.getLayoutManager()).getOrientation(); - if (mOrientation == LinearLayoutManager.HORIZONTAL) { + if (mOrientation == LinearLayoutManager.HORIZONTAL) outRect.left = mDivider.getIntrinsicWidth(); - } else if (mOrientation == LinearLayoutManager.VERTICAL) { + else if (mOrientation == LinearLayoutManager.VERTICAL) outRect.top = mDivider.getIntrinsicHeight(); - } } /** @@ -77,12 +80,14 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration { * @param parent The RecyclerView onto which horizontal dividers are being * added */ - private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) { + private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) + { int parentTop = parent.getPaddingTop(); int parentBottom = parent.getHeight() - parent.getPaddingBottom(); int childCount = parent.getChildCount(); - for (int i = 0; i < childCount - 1; i++) { + for (int i = 0; i < childCount - 1; i++) + { View child = parent.getChildAt(i); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); @@ -104,12 +109,14 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration { * @param parent The RecyclerView onto which vertical dividers are being * added */ - private void drawVerticalDividers(Canvas canvas, RecyclerView parent) { + private void drawVerticalDividers(Canvas canvas, RecyclerView parent) + { int parentLeft = parent.getPaddingLeft(); int parentRight = parent.getWidth() - parent.getPaddingRight(); int childCount = parent.getChildCount(); - for (int i = 0; i < childCount - 1; i++) { + for (int i = 0; i < childCount - 1; i++) + { View child = parent.getChildAt(i); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); diff --git a/android/src/com/mapswithme/maps/widget/recycler/GridDividerItemDecoration.java b/android/src/com/mapswithme/maps/widget/recycler/GridDividerItemDecoration.java index abfd10496e..1dc7334c46 100644 --- a/android/src/com/mapswithme/maps/widget/recycler/GridDividerItemDecoration.java +++ b/android/src/com/mapswithme/maps/widget/recycler/GridDividerItemDecoration.java @@ -3,17 +3,21 @@ package com.mapswithme.maps.widget.recycler; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.View; /** * Adds interior dividers to a RecyclerView with a GridLayoutManager. */ -public class GridDividerItemDecoration extends RecyclerView.ItemDecoration { +public class GridDividerItemDecoration extends RecyclerView.ItemDecoration +{ - private Drawable mHorizontalDivider; - private Drawable mVerticalDivider; - private int mNumColumns; + @NonNull + private final Drawable mHorizontalDivider; + @NonNull + private final Drawable mVerticalDivider; + private final int mNumColumns; /** * Sole constructor. Takes in {@link Drawable} objects to be used as @@ -21,11 +25,13 @@ public class GridDividerItemDecoration extends RecyclerView.ItemDecoration { * * @param horizontalDivider A divider {@code Drawable} to be drawn on the * rows of the grid of the RecyclerView - * @param verticalDivider A divider {@code Drawable} to be drawn on the - * columns of the grid of the RecyclerView - * @param numColumns The number of columns in the grid of the RecyclerView + * @param verticalDivider A divider {@code Drawable} to be drawn on the + * columns of the grid of the RecyclerView + * @param numColumns The number of columns in the grid of the RecyclerView */ - public GridDividerItemDecoration(Drawable horizontalDivider, Drawable verticalDivider, int numColumns) { + public GridDividerItemDecoration(@NonNull Drawable horizontalDivider, + @NonNull Drawable verticalDivider, int numColumns) + { mHorizontalDivider = horizontalDivider; mVerticalDivider = verticalDivider; mNumColumns = numColumns; @@ -36,10 +42,11 @@ public class GridDividerItemDecoration extends RecyclerView.ItemDecoration { * * @param canvas The {@link Canvas} onto which dividers will be drawn * @param parent The RecyclerView onto which dividers are being added - * @param state The current RecyclerView.State of the RecyclerView + * @param state The current RecyclerView.State of the RecyclerView */ @Override - public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) { + public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) + { drawHorizontalDividers(canvas, parent); drawVerticalDividers(canvas, parent); } @@ -49,23 +56,22 @@ public class GridDividerItemDecoration extends RecyclerView.ItemDecoration { * RecyclerView. * * @param outRect The {@link Rect} of offsets to be added around the child view - * @param view The child view to be decorated with an offset - * @param parent The RecyclerView onto which dividers are being added - * @param state The current RecyclerView.State of the RecyclerView + * @param view The child view to be decorated with an offset + * @param parent The RecyclerView onto which dividers are being added + * @param state The current RecyclerView.State of the RecyclerView */ @Override - public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { + public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) + { super.getItemOffsets(outRect, view, parent, state); boolean childIsInLeftmostColumn = (parent.getChildAdapterPosition(view) % mNumColumns) == 0; - if (!childIsInLeftmostColumn) { + if (!childIsInLeftmostColumn) outRect.left = mHorizontalDivider.getIntrinsicWidth(); - } boolean childIsInFirstRow = (parent.getChildAdapterPosition(view)) < mNumColumns; - if (!childIsInFirstRow) { + if (!childIsInFirstRow) outRect.top = mVerticalDivider.getIntrinsicHeight(); - } } /** @@ -75,11 +81,13 @@ public class GridDividerItemDecoration extends RecyclerView.ItemDecoration { * @param canvas The {@link Canvas} onto which dividers will be drawn * @param parent The RecyclerView onto which dividers are being added */ - private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) { + private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) + { int parentTop = parent.getPaddingTop(); int parentBottom = parent.getHeight() - parent.getPaddingBottom(); - for (int i = 0; i < mNumColumns; i++) { + for (int i = 0; i < mNumColumns; i++) + { View child = parent.getChildAt(i); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); @@ -98,17 +106,15 @@ public class GridDividerItemDecoration extends RecyclerView.ItemDecoration { * @param canvas The {@link Canvas} onto which dividers will be drawn * @param parent The RecyclerView onto which dividers are being added */ - private void drawVerticalDividers(Canvas canvas, RecyclerView parent) { + private void drawVerticalDividers(Canvas canvas, RecyclerView parent) + { int parentLeft = parent.getPaddingLeft(); int parentRight = parent.getWidth() - parent.getPaddingRight(); int childCount = parent.getChildCount(); - int numChildrenOnLastRow = childCount % mNumColumns; - int numRows = childCount / mNumColumns; - if (numChildrenOnLastRow == 0) { // TODO: Replace this with math - numRows--; - } - for (int i = 0; i < numRows; i++) { + int numRows = (childCount + (mNumColumns - 1)) / mNumColumns; + for (int i = 0; i < numRows - 1; i++) + { View child = parent.getChildAt(i * mNumColumns); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); @@ -119,4 +125,4 @@ public class GridDividerItemDecoration extends RecyclerView.ItemDecoration { mVerticalDivider.draw(canvas); } } -} \ No newline at end of file +} diff --git a/android/src/com/mapswithme/util/UiUtils.java b/android/src/com/mapswithme/util/UiUtils.java index 55c329dc93..1e9fdfb469 100644 --- a/android/src/com/mapswithme/util/UiUtils.java +++ b/android/src/com/mapswithme/util/UiUtils.java @@ -7,6 +7,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Rect; import android.net.Uri; import android.os.Build; import android.support.annotation.AnyRes; @@ -19,6 +20,7 @@ import android.support.design.widget.TextInputLayout; import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; import android.text.TextUtils; +import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewTreeObserver; @@ -339,6 +341,24 @@ public final class UiUtils return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; } + public static boolean isViewTouched(@NonNull MotionEvent event, @NonNull View view) + { + if (UiUtils.isHidden(view)) + return false; + + int x = (int) event.getX(); + int y = (int) event.getY(); + int[] location = new int[2]; + view.getLocationOnScreen(location); + int viewX = location[0]; + int viewY = location[1]; + int width = view.getWidth(); + int height = view.getHeight(); + Rect viewRect = new Rect(viewX, viewY, viewX + width, viewY + height); + + return viewRect.contains(x, y); + } + // utility class private UiUtils() {} } diff --git a/map/booking_api.cpp b/map/booking_api.cpp index 95bad8fe36..1e3aef6e73 100644 --- a/map/booking_api.cpp +++ b/map/booking_api.cpp @@ -90,7 +90,7 @@ void BookingApi::GetMinPrice(string const & hotelId, string const & currency, } catch (my::Json::Exception const & e) { -// LOG(LERROR, (e.Msg())); + LOG(LERROR, (e.Msg())); minPrice.clear(); priceCurrency.clear(); } diff --git a/strings.txt b/strings.txt index ed95cf256e..5f27356044 100644 --- a/strings.txt +++ b/strings.txt @@ -17909,6 +17909,10 @@ zh-Hant = 更多 sk = Viac + [placepage_more_reviews_button] + en = More Reviews + ru = Ещё отзывы + [bookingcom_book_button] en = Book ru = Забронировать @@ -19919,3 +19923,13 @@ zh-Hant = 飯店搜尋結果現在還包含價格類別。\n我們還加入了超過 110,000 間飯店。 el = Τα αποτελέσματα αναζήτησης για ξενοδοχεία περιέχουν πλέον κατηγορία τιμής. \nΠροσθέσαμε επίσης περισσότερα από 110.000 ξενοδοχεία. sk = Výsledky vyhľadávania hotelov odteraz obsahujú aj cenové kategórie. \nTiež sme pridali viac ako 110 000 hotelov. + + [placepage_hotel_facilities] + comment = For place page hotel facilities block + en = Facilities + ru = Удобства + + [placepage_hotel_nearby] + comment = For place page hotel nearby block + en = Nearby + ru = Рядом From 027c34d8704113704c2c248bd09ec8b08a6415d6 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Mon, 3 Oct 2016 16:59:05 +0400 Subject: [PATCH 23/26] [android] Added temporary flag for switching from old booking place page to the new booking place page. --- android/res/layout/place_page_details.xml | 3 +++ .../res/layout/place_page_hotel_gallery.xml | 1 + android/res/layout/place_page_more.xml | 1 + .../maps/widget/placepage/PlacePageView.java | 18 +++++++++++++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/android/res/layout/place_page_details.xml b/android/res/layout/place_page_details.xml index 7e5a23d2d8..515eac12f6 100644 --- a/android/res/layout/place_page_details.xml +++ b/android/res/layout/place_page_details.xml @@ -59,6 +59,9 @@ + + + diff --git a/android/res/layout/place_page_hotel_gallery.xml b/android/res/layout/place_page_hotel_gallery.xml index 3b964ea024..15c541325c 100644 --- a/android/res/layout/place_page_hotel_gallery.xml +++ b/android/res/layout/place_page_hotel_gallery.xml @@ -6,6 +6,7 @@ android:layout_height="@dimen/placepage_hotel_gallery_height" android:orientation="horizontal" android:minHeight="@dimen/placepage_hotel_gallery_height" + android:visibility="gone" tools:background="#20FF0000" tools:visibility="visible"> diff --git a/android/res/layout/place_page_more.xml b/android/res/layout/place_page_more.xml index e93771213c..b597a2c134 100644 --- a/android/res/layout/place_page_more.xml +++ b/android/res/layout/place_page_more.xml @@ -1,4 +1,5 @@ + Date: Tue, 4 Oct 2016 08:04:52 +0400 Subject: [PATCH 24/26] [android] Review fixes --- android/jni/com/mapswithme/maps/SponsoredHotel.cpp | 3 +-- .../com/mapswithme/maps/widget/placepage/GalleryAdapter.java | 2 +- std/chrono.hpp | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp index 1eb94e0e1b..cabe3fe119 100644 --- a/android/jni/com/mapswithme/maps/SponsoredHotel.cpp +++ b/android/jni/com/mapswithme/maps/SponsoredHotel.cpp @@ -6,8 +6,7 @@ #include "map/place_page_info.hpp" #include "std/bind.hpp" - -using namespace std::chrono; +#include "std/chrono.hpp" namespace { diff --git a/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java index a7ec45ea17..ffcce5c2fd 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java @@ -57,7 +57,7 @@ class GalleryAdapter extends RecyclerView.Adapter public void onBindViewHolder(ViewHolder holder, int position) { Item item = mLoadedItems.get(position); - item.setShowMore(position == MAX_COUNT - 1); + item.setShowMore(position == MAX_COUNT - 1 && mItems.size() > MAX_COUNT); holder.bind(item, position); } diff --git a/std/chrono.hpp b/std/chrono.hpp index 1ac4f3f731..3aadbf8ae6 100644 --- a/std/chrono.hpp +++ b/std/chrono.hpp @@ -17,6 +17,7 @@ using std::chrono::seconds; using std::chrono::steady_clock; using std::chrono::system_clock; using std::chrono::time_point; +using std::chrono::time_point_cast; #ifdef DEBUG_NEW #define new DEBUG_NEW From 4931943b57dc7c3e84c9dcb161e7c64eccae1fb0 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Wed, 5 Oct 2016 13:34:55 +0400 Subject: [PATCH 25/26] [android] Fix crash on tablet devices. --- android/res/layout-w600dp-port/place_page_details.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/res/layout-w600dp-port/place_page_details.xml b/android/res/layout-w600dp-port/place_page_details.xml index 3c52cb9ffa..1e03e0f8e7 100644 --- a/android/res/layout-w600dp-port/place_page_details.xml +++ b/android/res/layout-w600dp-port/place_page_details.xml @@ -92,6 +92,9 @@ + + + From e666c1dad90a5db45455eb19a73e33307d39d0f8 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Wed, 5 Oct 2016 15:04:32 +0400 Subject: [PATCH 26/26] [android] Review fixes --- android/res/layout/fragment_gallery.xml | 1 - android/res/values/strings.xml | 1218 +++++++++-------- .../gallery/FullScreenGalleryActivity.java | 6 + .../com/mapswithme/maps/review/Review.java | 1 - .../mapswithme/maps/review/ReviewAdapter.java | 7 +- .../maps/widget/LineCountTextView.java | 1 - .../maps/widget/StaticGridView.java | 1 - .../maps/widget/placepage/GalleryAdapter.java | 11 +- .../maps/widget/placepage/PlacePageView.java | 10 +- .../maps/widget/placepage/ReviewAdapter.java | 2 +- 10 files changed, 635 insertions(+), 623 deletions(-) diff --git a/android/res/layout/fragment_gallery.xml b/android/res/layout/fragment_gallery.xml index 840069a296..3e09892448 100644 --- a/android/res/layout/fragment_gallery.xml +++ b/android/res/layout/fragment_gallery.xml @@ -13,5 +13,4 @@ android:paddingRight="@dimen/margin_half" android:paddingTop="@dimen/margin_half_plus" tools:listitem="@layout/item_image"/> - diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index e19925317d..ec468f9a97 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -3,614 +3,614 @@ - - - About - - Back - - Cancel - - Cancel Download - - Delete - - Do not ask me again - - Continue - Download Maps - - Download %qu kB - - Download %qu MB - - Download has failed, touch again for one more try - - Downloaded (%1$qu %2$s), touch to delete - - Downloading %qu%%, touch to cancel - - Downloading… - Get it now - - Thank you for using MAPS.ME! Do you like the app? Tell your friends about it! This is the best thanks you could give us. - - kB - - Kilometers - - Leave a Review - - Maps - - Maps: - - Marked for downloading, touch to cancel - - MB - GB - - Miles - - My Position - OK - - Please free some space on your device first in order to download %s - - Remind me later - - Later - - Never - - Report an issue - - Search - - Search Map - - Touch to download - - Yes - - We recommend using WiFi to download large maps - - Which measurement system do you prefer? - - You currently have all Location Services for this device or application disabled. Please enable them in Settings. - - Your device doesn\'t support Location Services - - Show on the map - - ^\nis added to the downloading queue. - - Downloading\n^\n^ - - Download Map\n(^ ^) - - Download Map - - Download map\nwithout routing (^ ^) - - Downloading has failed - - Try Again - MAPS.ME - About MAPS.ME - Downloading %d%%, touch to cancel - Downloaded (%s), touch to delete - Connection Settings - Download %s - Close - A hardware accelerated OpenGL is required. Unfortunately, your device is not supported. - Download - SD card/USB storage with downloaded maps is not available - Please disconnect USB cable or insert memory card to use MAPS.ME - Please free some space on SD card/USB storage first in order to use the app - Not enough memory to launch app - Please free %1$s on your device first in order to download %2$s - Before you start let us download general world map into your device.\nIt needs %s of data. - Getting current position - Go to Map - Downloading %s. You can now\nproceed to the map. - Download %s? - Update %s? - - You can download the map\nof your current location. - - You can update the map\nof your current location. - - The map of your current\nlocation (%s) is up-to-date - - Pause - - Continue - Downloaded (%s), touch to update or delete - Update %s - - You need updated maps for search function: - - Update available for these maps: - - You don\'t need MAPS.ME Lite any more, so you can uninstall it. - - %s downloaded successfully - - %s download has failed - - Add New Set - - Add to Bookmarks - - Bookmark Color - - Bookmark Set Name - - Bookmark Sets - - Bookmarks - - Color - - My Places - - Name - - Address - - Remove Pin - - Set - - You have no bookmarks yet.\nTap on any place on the map to add a bookmark.\nBookmarks from other sources can also be imported and displayed in MAPS.ME. Open KML/KMZ file with saved bookmarks from email, Dropbox or weblink. - - Bookmarks from other sources can be imported and displayed in MAPS.ME. Open KML/KMZ file with saved bookmarks from mail, Dropbox or weblink. - - Settings - - Maps storage - - Select the place where maps should be downloaded to - - Move maps? - - This can take several minutes.\nPlease wait… - - Visible - - GPS is disabled. Please enable it in Settings. - - Measurement units - - Choose between miles and kilometers - - Everywhere - - Near Me - - On the Screen - - Food - - Transport - - Gas - - Parking - - Shop - - Hotel - - Sights - - Entertainment - - ATM - - Bank - - Pharmacy - - Hospital - - Toilet - - Post - - Police - - No results found - - Notes - - Share by email - - Shared MAPS.ME bookmarks - - Greetings,\n\nAttached are my bookmarks from MAPS.ME offline maps. Please open it if you have MAPS.ME installed. If not, download the app for your iOS or Android device following this link: http://maps.me/get?kmz\n\nEnjoy traveling with MAPS.ME! - - Loading Bookmarks - - Bookmarks loaded successfully! You can find them on the map or on the Bookmarks Manager screen. - - Bookmarks upload failed. The file may be corrupted or defective. - - Edit - - Your location hasn\'t been determined yet - - Download the country of your current location (%s) - - Download the country you are searching on (%s) - - Sorry, Map Storage settings are currently disabled. - - Country download is in progress now. - - Hope you enjoy using MAPS.ME! If so, please rate or review the app at the App Store. It takes less than a minute but can really help us. Thanks for your support! - - No, thanks - - Hey, check out my pin at MAPS.ME! %1$s or %2$s Don\'t have offline maps installed? Download here: http://maps.me/get - - Hey, check out my current location at MAPS.ME! %1$s or %2$s Don\'t have offline maps? Download here: http://maps.me/get - - Hey, check out my pin at MAPS.ME map! - - Hi,\n\nI pinned: %1$s at MAPS.ME, world offline maps. Click this link %2$s or this one %3$s to see the place on the map.\n\nThanks. - - Hey, check out my current location at MAPS.ME map! - - Hi,\n\nI\'m here now: %1$s. Click this link %2$s or this one %3$s to see the place on the map.\n\nThanks. - - Share by message - - Share - - Message - - Email - - Copy Link - - Show More Info - - Copied to Clipboard: %1$s - - Send Statistics - - Info - - Done - - Choose Back Screen settings - - Back Screen Settings - - Show on Back screen - - Version: %s - - Data version: %d - - Are you sure you want to continue? - - Tracks - - Length - Share My Location - Search - - Map - - Miscellaneous - Navigation - Zoom buttons - Display on the screen - - Night Mode - - Off - - On - - Auto - - Perspective view - - 3D buildings - - Affects battery life - - Voice Instructions - - Voice Language - - Not Available - - Other - How to set up voice - - Recent track - Auto zoom - Off - 1 hour - 2 hours - 6 hours - 12 hours - 1 day - Please note: activation of this function causes increased battery usage. - Recent track shows your traveled path. - Please select the time range of saving the track. - Distance - Coordinates - Unsorted - View on map - - Map data storage has been optimized. Please restart the app.\n\nMapsWithMe folder in the root of SD card is not needed anymore, you can delete it. - - Due to changes in Android 4.4, we need to optimize map data storage, but there is no enough space to copy map data.\n\nPlease free up the memory, otherwise maps will be available in read-only mode. - - We need to move your bookmarks to internal memory, but there is no available space for them. Please free up the memory, otherwise bookmarks won’t be available. - - Your map storage is being optimized now. Please wait, it may take a few minutes. - - Free - - Buy - - Search on map - - No route found - - Route - - Routes - - This applications uses geographical data (including maps, business listings, points of interest, borders of countries and regions, etc.) taken from the OpenStreetMap project. We do not warrant any consistency, accuracy, completeness or applicability of the OpenStreetMap data. - - I agree - - I disagree - - Download the map of the place where you are - - Full version of MAPS.ME is free today! Download now and tell your friends. - - We are transferring your downloaded maps from MAPS.ME Lite to MAPS.ME. It may take a few minutes. - - Your downloaded maps are successfully transferred to MAPS.ME. - - Your maps failed to transfer. Please delete MAPS.ME Lite and download the maps again. - - Settings & More - - Website - - MAPS.ME Community - - Like on Facebook - - Follow on Twitter - - Contact us - - Feedback - - General feedback - - Subscribe to our news - - Rate the app - - Help - - Copyright - - Report a bug - - Please subscribe me to the MAPS.ME newsletter - - I want to be the first to learn about latest news updates and promotions. I can cancel my subscription at any time. - - MAPS.ME offers the fastest offline maps of all the cities, all countries of the world. Travel with full confidence: wherever you are, MAPS.ME helps to locate yourself on the map, find the nearest restaurant, hotel, bank, gas station etc. It doesn’t require internet connection.\n\nWe are always working on new features and would love to hear from you on how you think we could improve MAPS.ME. If you have any problems with the app, don\'t hesitate to contact us at support@maps.me. We respond to every request!\n\nDo you like MAPS.ME and want to support us? There are some simple and absolutely free ways:\n\n- post a review at your App Market\n- like our Facebook page http://www.facebook.com/mapswithme\n- or just tell about MAPS.ME to your mom, friends and colleagues :)\n\nThank you for being with us. We appreciate your support very much!\n\nP.S. We take map data from OpenStreetMap, a mapping project similar to Wikipedia, which allows users to create and edit maps. If you see something is missing or wrong on the map, you can correct the maps directly at http://openstreetmap.org, and your changes will appear in MAPS.ME app with the next version release. - - The email client has not been set up. Please configure it or use any other way to contact us at %s - - Mail sending error - - Compass calibration - - WiFi - - Please update the map to create a route - - The new version of MAPS.ME allows creating routes from your current position to a destination point. Please update maps to use this feature. - - Update All - - Cancel All - - Downloaded - - Available - - queued - Near me - Maps - Download All - Downloading: - Found - - Creating routes in MAPS.ME app, please keep in mind the following:\n\n - Suggested routes can be considered as recommendations only.\n - Road conditions, traffic rules and signs have higher priority than navigation advice.\n - The map may be incorrect or outdated, and routes may not be created the best possible way.\n\n Be safe on roads and take care of yourself! - - Outdated - - Up-to-date - - Update - - Failed - - To delete map please stop navigation. - - Current location is undefined. Please specify location to create route. - - Additional data is required to create the route. Download data now? - - Cannot calculate the route. No roads near your starting point. - - Cannot calculate the route. No roads near your destination. - - Routes can only be created that are fully contained within a single map. - - There is no route found between the selected origin and destination. Please select a different start or end point. - - Internal error occurred. Please try to delete and download the map again. If problem persist please contact us at support@maps.me. - - Download Map + Routing - - Download Routing - - Delete Routing - - Download map - Download map without routing - - Go! - - Retry - - Map + Routing - - Delete Map - - Update Map - - Update Map + Routing - - Map Only - - Application menu - - Use Google Play Services to get your current location - - I’ve just rated your app - - I’ve been MAPS.ME user since %s - - Do you like MAPS.ME? - - Tap a star to rate our app. - - Thank you! - - Share any ideas or issues so we can improve the app for you. - - Send feedback - - Click g+ to tell your friends about the app. - - Download maps along route - - Get map - - Download updated map and routing data to get all MAPS.ME features. - - Get routing data - - Additional data required to create routes from your location. - - Creating a route requires all the maps from your location to destination downloaded and updated. - - Not enough space - - You need to download %1$s MB, but only %2$s MB are available. - - You are going to download %s MB using Mobile Data (in Roaming). This may result in additional charges, depending on your operator mobile data plan. - - bookmark - - The map for your location is not downloaded - - Please enable Location Services - - Download the map for your location - - Download a current location map on your iPhone - - Nearby - - Clear Pin - - Current location is undefined. - - Download the country of your current location - - download has failed - - Get the map - Save - Your descriptions (text or html) - new group - create - - Red - - Yellow - - Blue - - Green - - Purple - - Orange - - Brown - - Pink - - Yes + + + About + + Back + + Cancel + + Cancel Download + + Delete + + Do not ask me again + + Continue + Download Maps + + Download %qu kB + + Download %qu MB + + Download has failed, touch again for one more try + + Downloaded (%1$qu %2$s), touch to delete + + Downloading %qu%%, touch to cancel + + Downloading… + Get it now + + Thank you for using MAPS.ME! Do you like the app? Tell your friends about it! This is the best thanks you could give us. + + kB + + Kilometers + + Leave a Review + + Maps + + Maps: + + Marked for downloading, touch to cancel + + MB + GB + + Miles + + My Position + OK + + Please free some space on your device first in order to download %s + + Remind me later + + Later + + Never + + Report an issue + + Search + + Search Map + + Touch to download + + Yes + + We recommend using WiFi to download large maps + + Which measurement system do you prefer? + + You currently have all Location Services for this device or application disabled. Please enable them in Settings. + + Your device doesn\'t support Location Services + + Show on the map + + ^\nis added to the downloading queue. + + Downloading\n^\n^ + + Download Map\n(^ ^) + + Download Map + + Download map\nwithout routing (^ ^) + + Downloading has failed + + Try Again + MAPS.ME + About MAPS.ME + Downloading %d%%, touch to cancel + Downloaded (%s), touch to delete + Connection Settings + Download %s + Close + A hardware accelerated OpenGL is required. Unfortunately, your device is not supported. + Download + SD card/USB storage with downloaded maps is not available + Please disconnect USB cable or insert memory card to use MAPS.ME + Please free some space on SD card/USB storage first in order to use the app + Not enough memory to launch app + Please free %1$s on your device first in order to download %2$s + Before you start let us download general world map into your device.\nIt needs %s of data. + Getting current position + Go to Map + Downloading %s. You can now\nproceed to the map. + Download %s? + Update %s? + + You can download the map\nof your current location. + + You can update the map\nof your current location. + + The map of your current\nlocation (%s) is up-to-date + + Pause + + Continue + Downloaded (%s), touch to update or delete + Update %s + + You need updated maps for search function: + + Update available for these maps: + + You don\'t need MAPS.ME Lite any more, so you can uninstall it. + + %s downloaded successfully + + %s download has failed + + Add New Set + + Add to Bookmarks + + Bookmark Color + + Bookmark Set Name + + Bookmark Sets + + Bookmarks + + Color + + My Places + + Name + + Address + + Remove Pin + + Set + + You have no bookmarks yet.\nTap on any place on the map to add a bookmark.\nBookmarks from other sources can also be imported and displayed in MAPS.ME. Open KML/KMZ file with saved bookmarks from email, Dropbox or weblink. + + Bookmarks from other sources can be imported and displayed in MAPS.ME. Open KML/KMZ file with saved bookmarks from mail, Dropbox or weblink. + + Settings + + Maps storage + + Select the place where maps should be downloaded to + + Move maps? + + This can take several minutes.\nPlease wait… + + Visible + + GPS is disabled. Please enable it in Settings. + + Measurement units + + Choose between miles and kilometers + + Everywhere + + Near Me + + On the Screen + + Food + + Transport + + Gas + + Parking + + Shop + + Hotel + + Sights + + Entertainment + + ATM + + Bank + + Pharmacy + + Hospital + + Toilet + + Post + + Police + + No results found + + Notes + + Share by email + + Shared MAPS.ME bookmarks + + Greetings,\n\nAttached are my bookmarks from MAPS.ME offline maps. Please open it if you have MAPS.ME installed. If not, download the app for your iOS or Android device following this link: http://maps.me/get?kmz\n\nEnjoy traveling with MAPS.ME! + + Loading Bookmarks + + Bookmarks loaded successfully! You can find them on the map or on the Bookmarks Manager screen. + + Bookmarks upload failed. The file may be corrupted or defective. + + Edit + + Your location hasn\'t been determined yet + + Download the country of your current location (%s) + + Download the country you are searching on (%s) + + Sorry, Map Storage settings are currently disabled. + + Country download is in progress now. + + Hope you enjoy using MAPS.ME! If so, please rate or review the app at the App Store. It takes less than a minute but can really help us. Thanks for your support! + + No, thanks + + Hey, check out my pin at MAPS.ME! %1$s or %2$s Don\'t have offline maps installed? Download here: http://maps.me/get + + Hey, check out my current location at MAPS.ME! %1$s or %2$s Don\'t have offline maps? Download here: http://maps.me/get + + Hey, check out my pin at MAPS.ME map! + + Hi,\n\nI pinned: %1$s at MAPS.ME, world offline maps. Click this link %2$s or this one %3$s to see the place on the map.\n\nThanks. + + Hey, check out my current location at MAPS.ME map! + + Hi,\n\nI\'m here now: %1$s. Click this link %2$s or this one %3$s to see the place on the map.\n\nThanks. + + Share by message + + Share + + Message + + Email + + Copy Link + + Show More Info + + Copied to Clipboard: %1$s + + Send Statistics + + Info + + Done + + Choose Back Screen settings + + Back Screen Settings + + Show on Back screen + + Version: %s + + Data version: %d + + Are you sure you want to continue? + + Tracks + + Length + Share My Location + Search + + Map + + Miscellaneous + Navigation + Zoom buttons + Display on the screen + + Night Mode + + Off + + On + + Auto + + Perspective view + + 3D buildings + + Affects battery life + + Voice Instructions + + Voice Language + + Not Available + + Other + How to set up voice + + Recent track + Auto zoom + Off + 1 hour + 2 hours + 6 hours + 12 hours + 1 day + Please note: activation of this function causes increased battery usage. + Recent track shows your traveled path. + Please select the time range of saving the track. + Distance + Coordinates + Unsorted + View on map + + Map data storage has been optimized. Please restart the app.\n\nMapsWithMe folder in the root of SD card is not needed anymore, you can delete it. + + Due to changes in Android 4.4, we need to optimize map data storage, but there is no enough space to copy map data.\n\nPlease free up the memory, otherwise maps will be available in read-only mode. + + We need to move your bookmarks to internal memory, but there is no available space for them. Please free up the memory, otherwise bookmarks won’t be available. + + Your map storage is being optimized now. Please wait, it may take a few minutes. + + Free + + Buy + + Search on map + + No route found + + Route + + Routes + + This applications uses geographical data (including maps, business listings, points of interest, borders of countries and regions, etc.) taken from the OpenStreetMap project. We do not warrant any consistency, accuracy, completeness or applicability of the OpenStreetMap data. + + I agree + + I disagree + + Download the map of the place where you are + + Full version of MAPS.ME is free today! Download now and tell your friends. + + We are transferring your downloaded maps from MAPS.ME Lite to MAPS.ME. It may take a few minutes. + + Your downloaded maps are successfully transferred to MAPS.ME. + + Your maps failed to transfer. Please delete MAPS.ME Lite and download the maps again. + + Settings & More + + Website + + MAPS.ME Community + + Like on Facebook + + Follow on Twitter + + Contact us + + Feedback + + General feedback + + Subscribe to our news + + Rate the app + + Help + + Copyright + + Report a bug + + Please subscribe me to the MAPS.ME newsletter + + I want to be the first to learn about latest news updates and promotions. I can cancel my subscription at any time. + + MAPS.ME offers the fastest offline maps of all the cities, all countries of the world. Travel with full confidence: wherever you are, MAPS.ME helps to locate yourself on the map, find the nearest restaurant, hotel, bank, gas station etc. It doesn’t require internet connection.\n\nWe are always working on new features and would love to hear from you on how you think we could improve MAPS.ME. If you have any problems with the app, don\'t hesitate to contact us at support@maps.me. We respond to every request!\n\nDo you like MAPS.ME and want to support us? There are some simple and absolutely free ways:\n\n- post a review at your App Market\n- like our Facebook page http://www.facebook.com/mapswithme\n- or just tell about MAPS.ME to your mom, friends and colleagues :)\n\nThank you for being with us. We appreciate your support very much!\n\nP.S. We take map data from OpenStreetMap, a mapping project similar to Wikipedia, which allows users to create and edit maps. If you see something is missing or wrong on the map, you can correct the maps directly at http://openstreetmap.org, and your changes will appear in MAPS.ME app with the next version release. + + The email client has not been set up. Please configure it or use any other way to contact us at %s + + Mail sending error + + Compass calibration + + WiFi + + Please update the map to create a route + + The new version of MAPS.ME allows creating routes from your current position to a destination point. Please update maps to use this feature. + + Update All + + Cancel All + + Downloaded + + Available + + queued + Near me + Maps + Download All + Downloading: + Found + + Creating routes in MAPS.ME app, please keep in mind the following:\n\n - Suggested routes can be considered as recommendations only.\n - Road conditions, traffic rules and signs have higher priority than navigation advice.\n - The map may be incorrect or outdated, and routes may not be created the best possible way.\n\n Be safe on roads and take care of yourself! + + Outdated + + Up-to-date + + Update + + Failed + + To delete map please stop navigation. + + Current location is undefined. Please specify location to create route. + + Additional data is required to create the route. Download data now? + + Cannot calculate the route. No roads near your starting point. + + Cannot calculate the route. No roads near your destination. + + Routes can only be created that are fully contained within a single map. + + There is no route found between the selected origin and destination. Please select a different start or end point. + + Internal error occurred. Please try to delete and download the map again. If problem persist please contact us at support@maps.me. + + Download Map + Routing + + Download Routing + + Delete Routing + + Download map + Download map without routing + + Go! + + Retry + + Map + Routing + + Delete Map + + Update Map + + Update Map + Routing + + Map Only + + Application menu + + Use Google Play Services to get your current location + + I’ve just rated your app + + I’ve been MAPS.ME user since %s + + Do you like MAPS.ME? + + Tap a star to rate our app. + + Thank you! + + Share any ideas or issues so we can improve the app for you. + + Send feedback + + Click g+ to tell your friends about the app. + + Download maps along route + + Get map + + Download updated map and routing data to get all MAPS.ME features. + + Get routing data + + Additional data required to create routes from your location. + + Creating a route requires all the maps from your location to destination downloaded and updated. + + Not enough space + + You need to download %1$s MB, but only %2$s MB are available. + + You are going to download %s MB using Mobile Data (in Roaming). This may result in additional charges, depending on your operator mobile data plan. + + bookmark + + The map for your location is not downloaded + + Please enable Location Services + + Download the map for your location + + Download a current location map on your iPhone + + Nearby + + Clear Pin + + Current location is undefined. + + Download the country of your current location + + download has failed + + Get the map + Save + Your descriptions (text or html) + new group + create + + Red + + Yellow + + Blue + + Green + + Purple + + Orange + + Brown + + Pink + + Yes - - When following the route, please keep in mind: - — Road conditions, traffic laws and road signs always take priority over the navigational advice; - — The map might be inaccurate and the suggested route might not always be the most optimal way to reach the destination; - — Suggested routes are to be taken only as recommendations; - — Exercise caution with routes in border zones: the routes created by our app may sometimes cross country borders in unauthorized places; - Please stay alert and safe on the roads! - Check GPS signal - Unable to create route. Current GPS coordinates could not be identified. - Please check your GPS signal. Enabling Wi-Fi will improve your location accuracy. - Enable location services - Unable to locate current GPS coordinates. Enable location services to calculate route. - Unable to locate current GPS coordinates. - Download required files - Download and update all map and routing information along the projected path to calculate route. - Routing information files - Unable to locate route - Unable to create route. - Please adjust your starting point or your destination. - Adjust starting point - Route was not created. Unable to locate starting point. - Please select a starting point closer to a road. - Adjust destination - Route was not created. Unable to locate the destination. - Please select a destination point located closer to a road. - System error - Unable to create route due to an application error. - Please try again - Report the Problem - Would you like to create a more direct route that spans more than one map? - A more optimal route that crosses the edge of this map is available. - Not Now - Create - Would you like to download the map and create a more optimal route spanning more than one map? - Download the map to create a more optimal route that crosses the edge of this map. - Always cross this boundary + + When following the route, please keep in mind: + — Road conditions, traffic laws and road signs always take priority over the navigational advice; + — The map might be inaccurate and the suggested route might not always be the most optimal way to reach the destination; + — Suggested routes are to be taken only as recommendations; + — Exercise caution with routes in border zones: the routes created by our app may sometimes cross country borders in unauthorized places; + Please stay alert and safe on the roads! + Check GPS signal + Unable to create route. Current GPS coordinates could not be identified. + Please check your GPS signal. Enabling Wi-Fi will improve your location accuracy. + Enable location services + Unable to locate current GPS coordinates. Enable location services to calculate route. + Unable to locate current GPS coordinates. + Download required files + Download and update all map and routing information along the projected path to calculate route. + Routing information files + Unable to locate route + Unable to create route. + Please adjust your starting point or your destination. + Adjust starting point + Route was not created. Unable to locate starting point. + Please select a starting point closer to a road. + Adjust destination + Route was not created. Unable to locate the destination. + Please select a destination point located closer to a road. + System error + Unable to create route due to an application error. + Please try again + Report the Problem + Would you like to create a more direct route that spans more than one map? + A more optimal route that crosses the edge of this map is available. + Not Now + Create + Would you like to download the map and create a more optimal route spanning more than one map? + Download the map to create a more optimal route that crosses the edge of this map. + Always cross this boundary To start searching and creating routes, please download the map, and you will not need Internet connection anymore. @@ -968,6 +968,10 @@ Accept Decline + Better go about than fall into the ditch + For pedestrian and bike routes we now display the elevation profile. + Save when booking hotels + Search results for hotels now contain the price category.\nWe also added more than 110,000 hotels. Facilities diff --git a/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java index bfba3eb345..96c2d13620 100644 --- a/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java +++ b/android/src/com/mapswithme/maps/gallery/FullScreenGalleryActivity.java @@ -157,7 +157,9 @@ public class FullScreenGalleryActivity extends BaseMwmFragmentActivity UiUtils.show(mDate); } else + { UiUtils.hide(mDate); + } } private void updateUserAvatar(Image image) @@ -191,8 +193,12 @@ public class FullScreenGalleryActivity extends BaseMwmFragmentActivity && UiUtils.isHidden(mSource) && UiUtils.isHidden(mDate) && UiUtils.isHidden(mAvatar)) + { UiUtils.hide(mUserBlock); + } else + { UiUtils.show(mUserBlock); + } } } diff --git a/android/src/com/mapswithme/maps/review/Review.java b/android/src/com/mapswithme/maps/review/Review.java index 11b3b22d77..bc55fc569e 100644 --- a/android/src/com/mapswithme/maps/review/Review.java +++ b/android/src/com/mapswithme/maps/review/Review.java @@ -7,7 +7,6 @@ import android.support.annotation.Nullable; public class Review implements Parcelable { - @Nullable private final String mReview; @Nullable diff --git a/android/src/com/mapswithme/maps/review/ReviewAdapter.java b/android/src/com/mapswithme/maps/review/ReviewAdapter.java index 151c4e3ccd..b4ea102f97 100644 --- a/android/src/com/mapswithme/maps/review/ReviewAdapter.java +++ b/android/src/com/mapswithme/maps/review/ReviewAdapter.java @@ -157,21 +157,27 @@ class ReviewAdapter extends RecyclerView.Adapter 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()); } if (UiUtils.isHidden(mNegativeReview) && UiUtils.isHidden(mPositiveReview)) + { UiUtils.showIf(!TextUtils.isEmpty(item.getReview()), mReview); + } else { UiUtils.hide(mReview); @@ -181,7 +187,6 @@ class ReviewAdapter extends RecyclerView.Adapter private static class MoreHolder extends BaseViewHolder { - MoreHolder(View itemView, RecyclerClickListener listener) { super(itemView, listener); diff --git a/android/src/com/mapswithme/maps/widget/LineCountTextView.java b/android/src/com/mapswithme/maps/widget/LineCountTextView.java index 34060ab173..46d3d9e644 100644 --- a/android/src/com/mapswithme/maps/widget/LineCountTextView.java +++ b/android/src/com/mapswithme/maps/widget/LineCountTextView.java @@ -8,7 +8,6 @@ import android.widget.TextView; public class LineCountTextView extends TextView { - public interface OnLineCountCalculatedListener { diff --git a/android/src/com/mapswithme/maps/widget/StaticGridView.java b/android/src/com/mapswithme/maps/widget/StaticGridView.java index a89fbe6fcf..f2a1662c16 100644 --- a/android/src/com/mapswithme/maps/widget/StaticGridView.java +++ b/android/src/com/mapswithme/maps/widget/StaticGridView.java @@ -6,7 +6,6 @@ import android.widget.GridView; public class StaticGridView extends GridView { - public StaticGridView(Context context) { super(context); diff --git a/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java index ffcce5c2fd..ed3cfba45e 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/GalleryAdapter.java @@ -94,7 +94,7 @@ class GalleryAdapter extends RecyclerView.Adapter private void loadImages() { - int size = mItems.size() > MAX_COUNT ? MAX_COUNT : mItems.size(); + int size = Math.min(mItems.size(), MAX_COUNT); for (int i = 0; i < size; i++) { @@ -155,14 +155,7 @@ class GalleryAdapter extends RecyclerView.Adapter { mPosition = position; mImage.setImageBitmap(item.getBitmap()); - if (item.isShowMore()) - { - UiUtils.show(mMore); - } - else - { - UiUtils.hide(mMore); - } + UiUtils.showIf(item.isShowMore(), mMore); } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index b49815cfcd..7a679cd25e 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -543,7 +543,9 @@ public class PlacePageView extends RelativeLayout private void updateHotelRating(@NonNull SponsoredHotel.HotelInfo info) { if (info.mReviews == null || info.mReviews.length == 0) + { UiUtils.hide(mHotelReview); + } else { UiUtils.show(mHotelReview); @@ -557,7 +559,9 @@ public class PlacePageView extends RelativeLayout private void updateHotelNearby(@NonNull SponsoredHotel.HotelInfo info) { if (info.mNearby == null || info.mNearby.length == 0) + { UiUtils.hide(mHotelNearby); + } else { UiUtils.show(mHotelNearby); @@ -568,7 +572,9 @@ public class PlacePageView extends RelativeLayout private void updateHotelGallery(@NonNull SponsoredHotel.HotelInfo info) { if (info.mPhotos == null || info.mPhotos.length == 0) + { UiUtils.hide(mHotelGallery); + } else { UiUtils.show(mHotelGallery); @@ -580,7 +586,9 @@ public class PlacePageView extends RelativeLayout private void updateHotelFacilities(@NonNull SponsoredHotel.HotelInfo info) { if (info.mFacilities == null || info.mFacilities.length == 0) + { UiUtils.hide(mHotelFacilities); + } else { UiUtils.show(mHotelFacilities); @@ -601,7 +609,7 @@ public class PlacePageView extends RelativeLayout @Override public void onLineCountCalculated(boolean grater) { - mHotelMoreDescription.setVisibility(grater ? VISIBLE : GONE); + UiUtils.showIf(grater, mHotelMoreDescription); } @Override diff --git a/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java b/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java index 8c91269b81..901acbe98a 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java +++ b/android/src/com/mapswithme/maps/widget/placepage/ReviewAdapter.java @@ -27,7 +27,7 @@ class ReviewAdapter extends BaseAdapter @Override public int getCount() { - return mItems.size() > MAX_COUNT ? MAX_COUNT : mItems.size(); + return Math.min(mItems.size(), MAX_COUNT); } @Override