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

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2016-02-11 00:16:13 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:20:39 +0300
commit35d40cd8fb0669eeefbf944251bf547312424ac2 (patch)
tree14acde7b693e4a529a464c33a2fd0b9634607806
parentc5d5981f17fd49e1f7eadb459df4dbdcad7bf41d (diff)
[ios][android] Support isOpen/isClosed/Unknown states in search results.
-rw-r--r--android/jni/com/mapswithme/maps/SearchEngine.cpp2
-rw-r--r--android/src/com/mapswithme/maps/search/SearchAdapter.java3
-rw-r--r--android/src/com/mapswithme/maps/search/SearchResult.java11
-rw-r--r--iphone/Maps/Classes/CustomViews/MapViewControls/Search/TableView/MWMSearchCommonCell.mm12
-rw-r--r--search/intermediate_result.cpp21
-rw-r--r--search/result.hpp6
6 files changed, 36 insertions, 19 deletions
diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp
index dd61f96251..b0c849d4a7 100644
--- a/android/jni/com/mapswithme/maps/SearchEngine.cpp
+++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp
@@ -78,7 +78,7 @@ jobject ToJavaResult(Result result, bool hasPosition, double lat, double lon)
featureType, region,
dist, cuisine,
result.GetStarsCount(),
- result.IsClosed());
+ static_cast<jint>(result.IsOpenNow()));
ASSERT(desc, ());
env->DeleteLocalRef(featureType);
env->DeleteLocalRef(region);
diff --git a/android/src/com/mapswithme/maps/search/SearchAdapter.java b/android/src/com/mapswithme/maps/search/SearchAdapter.java
index 1fc247e684..1aef2e1a18 100644
--- a/android/src/com/mapswithme/maps/search/SearchAdapter.java
+++ b/android/src/com/mapswithme/maps/search/SearchAdapter.java
@@ -207,7 +207,8 @@ class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.BaseViewHolder>
{
super.bind(result, order);
- UiUtils.showIf(result.description.closedNow, mClosedMarker);
+ // TODO: Support also "Open Now" mark.
+ UiUtils.showIf(result.description.openNow == SearchResult.OPEN_NOW_NO, mClosedMarker);
UiUtils.setTextAndHideIfEmpty(mDescription, formatDescription(result));
UiUtils.setTextAndHideIfEmpty(mRegion, result.description.region);
UiUtils.setTextAndHideIfEmpty(mDistance, result.description.distance);
diff --git a/android/src/com/mapswithme/maps/search/SearchResult.java b/android/src/com/mapswithme/maps/search/SearchResult.java
index 57ecb1dda4..315d2ddbe2 100644
--- a/android/src/com/mapswithme/maps/search/SearchResult.java
+++ b/android/src/com/mapswithme/maps/search/SearchResult.java
@@ -9,6 +9,11 @@ public class SearchResult
public static final int TYPE_SUGGEST = 0;
public static final int TYPE_RESULT = 1;
+ // Values should match osm::YesNoUnknown enum.
+ public static final int OPEN_NOW_UNKNOWN = 0;
+ public static final int OPEN_NOW_YES = 1;
+ public static final int OPEN_NOW_NO = 2;
+
public static class Description
{
public final String featureType;
@@ -16,16 +21,16 @@ public class SearchResult
public final String distance;
public final String cuisine;
public final int stars;
- public final boolean closedNow;
+ public final int openNow;
- public Description(String featureType, String region, String distance, String cuisine, int stars, boolean closedNow)
+ public Description(String featureType, String region, String distance, String cuisine, int stars, int openNow)
{
this.featureType = featureType;
this.region = region;
this.distance = distance;
this.cuisine = cuisine;
this.stars = stars;
- this.closedNow = closedNow;
+ this.openNow = openNow;
}
}
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TableView/MWMSearchCommonCell.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TableView/MWMSearchCommonCell.mm
index 32ea439ae7..2832249974 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TableView/MWMSearchCommonCell.mm
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/TableView/MWMSearchCommonCell.mm
@@ -42,7 +42,17 @@
else
[self clearInfo];
- self.closedView.hidden = !result.IsClosed();
+ switch (result.IsOpenNow())
+ {
+ case osm::Unknown:
+ // TODO: Correctly handle Open Now = YES value (show "OPEN" mark).
+ case osm::Yes:
+ self.closedView.hidden = YES;
+ break;
+ case osm::No:
+ self.closedView.hidden = NO;
+ break;
+ }
if (result.HasPoint())
{
string distanceStr;
diff --git a/search/intermediate_result.cpp b/search/intermediate_result.cpp
index f8c59e5dbb..f98e674c2e 100644
--- a/search/intermediate_result.cpp
+++ b/search/intermediate_result.cpp
@@ -35,19 +35,18 @@ void ProcessMetadata(FeatureType const & ft, Result::Metadata & meta)
string const openHours = src.Get(feature::Metadata::FMD_OPEN_HOURS);
if (!openHours.empty())
{
- osmoh::OpeningHours oh(openHours);
-
- // TODO(mgsergio): Switch to three-stated model instead of two-staed
- // I.e. set unknown if we can't parse or can't answer whether it's open.
- if (oh.IsValid())
- meta.m_isClosed = oh.IsClosed(time(nullptr));
- else
- meta.m_isClosed = false;
+ osmoh::OpeningHours const oh(openHours);
+ // TODO: We should check closed/open time for specific feature's timezone.
+ time_t const now = time(nullptr);
+ if (oh.IsValid() && !oh.IsUnknown(now))
+ meta.m_isOpenNow = oh.IsOpen(now) ? osm::Yes : osm::No;
+ // In else case value us osm::Unknown, it's set in preview's constructor.
}
- meta.m_stars = 0;
- (void) strings::to_int(src.Get(feature::Metadata::FMD_STARS), meta.m_stars);
- meta.m_stars = my::clamp(meta.m_stars, 0, 5);
+ if (strings::to_int(src.Get(feature::Metadata::FMD_STARS), meta.m_stars))
+ meta.m_stars = my::clamp(meta.m_stars, 0, 5);
+ else
+ meta.m_stars = 0;
}
namespace impl
diff --git a/search/result.hpp b/search/result.hpp
index 285f88d0f1..d4ed29ed58 100644
--- a/search/result.hpp
+++ b/search/result.hpp
@@ -1,6 +1,8 @@
#pragma once
#include "indexer/feature_decl.hpp"
+#include "editor/yes_no_unknown.hpp"
+
#include "geometry/point2d.hpp"
#include "geometry/rect2d.hpp"
@@ -30,7 +32,7 @@ public:
{
string m_cuisine; // Valid only if not empty. Used for restaurants.
int m_stars = 0; // Valid only if not 0. Used for hotels.
- bool m_isClosed = false; // Valid for any result.
+ osm::YesNoUnknown m_isOpenNow = osm::Unknown; // Valid for any result.
/// True if the struct is already assigned or need to be calculated otherwise.
bool m_isInitialized = false;
@@ -62,7 +64,7 @@ public:
string const & GetCuisine() const { return m_metadata.m_cuisine; }
//@}
- bool IsClosed() const { return m_metadata.m_isClosed; }
+ osm::YesNoUnknown IsOpenNow() const { return m_metadata.m_isOpenNow; }
int GetStarsCount() const { return m_metadata.m_stars; }
bool IsSuggest() const;