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 = Рядом