[search] Add warning message to download absent countries if no search results found.

This commit is contained in:
vng 2013-02-06 13:11:46 +03:00 committed by Alex Zolotarev
parent dab75b47b6
commit 85d9ad665c
17 changed files with 180 additions and 14 deletions

View file

@ -491,12 +491,31 @@ namespace android
storage::TIndex Framework::GetCountryIndex(double lat, double lon) const
{
return m_work.GetCountryIndex(m2::PointD(MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat)));
return m_work.GetCountryIndex(m2::PointD(MercatorBounds::LonToX(lon),
MercatorBounds::LatToY(lat)));
}
string Framework::GetCountryCode(double lat, double lon) const
{
return m_work.GetCountryCode(m2::PointD(MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat)));
return m_work.GetCountryCode(m2::PointD(MercatorBounds::LonToX(lon),
MercatorBounds::LatToY(lat)));
}
string Framework::GetCountryNameIfAbsent(m2::PointD const & pt) const
{
using namespace storage;
TIndex const idx = m_work.GetCountryIndex(pt);
TStatus const status = m_work.GetCountryStatus(idx);
if (status != EOnDisk && status != EOnDiskOutOfDate)
return m_work.GetCountryName(idx);
else
return string();
}
m2::PointD Framework::GetViewportCenter() const
{
return m_work.GetViewportCenter();
}
void Framework::AddString(string const & name, string const & value)

View file

@ -105,6 +105,9 @@ namespace android
storage::TIndex GetCountryIndex(double lat, double lon) const;
string GetCountryCode(double lat, double lon) const;
string GetCountryNameIfAbsent(m2::PointD const & pt) const;
m2::PointD GetViewportCenter() const;
void AddString(string const & name, string const & value);
void Scale(double k);

View file

@ -255,4 +255,21 @@ Java_com_mapswithme_maps_SearchActivity_nativeGetResult(
}
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_SearchActivity_getCountryNameIfAbsent(JNIEnv * env, jobject thiz,
jdouble lat, jdouble lon)
{
string const name = g_framework->GetCountryNameIfAbsent(m2::PointD(
MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat)));
return (name.empty() ? 0 : jni::ToJavaString(env, name));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_SearchActivity_getViewportCountryNameIfAbsent(JNIEnv * env, jobject thiz)
{
string const name = g_framework->GetCountryNameIfAbsent(g_framework->GetViewportCenter());
return (name.empty() ? 0 : jni::ToJavaString(env, name));
}
}

View file

@ -245,4 +245,10 @@
<string name="load_kmz_successful">Lesezeichen erfolgreich geladen! Sie können diese nun auf Ihrer Karte oder im Lesezeichen-Manager sehen.</string>
<!-- Kml file loading failed -->
<string name="load_kmz_failed">Hochladen der Lesezeichen fehlgeschlagen. Die Datei könnte beschädigt oder defekt sein.</string>
<!-- Warning message when doing search around current position -->
<string name="unknown_current_position">Ihr Standort wurde bisher noch nicht bestimmt</string>
<!-- Warning message when location country isn't downloaded during search (see also download_location_map_proposal). -->
<string name="download_location_country">Land (%s) Ihres derzeitigen Standorts herunterladen</string>
<!-- Warning message when viewport country isn't downloaded during search -->
<string name="download_viewport_country_to_search">Land (%s) herunterladen, von dem aus Sie suchen</string>
</resources>

View file

@ -241,4 +241,10 @@
<string name="load_kmz_successful">¡Los favoritos se han cargado con éxito! Puedes encontrarlos en el mapa o en la pantalla de Gestión de favoritos.</string>
<!-- Kml file loading failed -->
<string name="load_kmz_failed">La carga de favoritos ha fallado. El archivo puede estar corrupto o ser defectuoso.</string>
<!-- Warning message when doing search around current position -->
<string name="unknown_current_position">Tu ubicación aún no ha sido determinada</string>
<!-- Warning message when location country isn't downloaded during search (see also download_location_map_proposal). -->
<string name="download_location_country">Descargar país (%s) de tu ubicación actual</string>
<!-- Warning message when viewport country isn't downloaded during search -->
<string name="download_viewport_country_to_search">Descargar país (%s) en el que estás buscando</string>
</resources>

View file

@ -237,4 +237,10 @@
<string name="load_kmz_successful">Favoris chargés avec succès ! Vous pouvez les trouver sur la carte ou sur l\'écran de gestion des favoris.</string>
<!-- Kml file loading failed -->
<string name="load_kmz_failed">Chargement des favoris échoué. Le dossier peut être corrompu ou défectueux.</string>
<!-- Warning message when doing search around current position -->
<string name="unknown_current_position">Votre position n\'a pas encore été déterminée</string>
<!-- Warning message when location country isn't downloaded during search (see also download_location_map_proposal). -->
<string name="download_location_country">Téléchargez le pays (%s) de votre position actuelle</string>
<!-- Warning message when viewport country isn't downloaded during search -->
<string name="download_viewport_country_to_search">Téléchargez le pays (%s) que vous recherchez sur</string>
</resources>

View file

@ -39,4 +39,10 @@
<string name="load_kmz_successful">Segnalibri caricati con successo! Puoi trovare i segnalibri direttamente sulla mappa, oppure aprendo la schermata dedicata alla Gestione dei segnalibri.</string>
<!-- Kml file loading failed -->
<string name="load_kmz_failed">Caricamento dei segnalibri non riuscito. Il file potrebbe essere corrotto o difettoso.</string>
<!-- Warning message when doing search around current position -->
<string name="unknown_current_position">La tua posizione non è stata ancora stabilita</string>
<!-- Warning message when location country isn't downloaded during search (see also download_location_map_proposal). -->
<string name="download_location_country">Scarica il paese (%s) della tua posizione attuale</string>
<!-- Warning message when viewport country isn't downloaded during search -->
<string name="download_viewport_country_to_search">Scarica il paese (%s) che stai cercando</string>
</resources>

View file

@ -243,4 +243,10 @@
<string name="load_kmz_successful">ブックマークが無事読み込まれました! ブックマークはマップ上またはブックマークマネージャー画面上にあります。</string>
<!-- Kml file loading failed -->
<string name="load_kmz_failed">ブックマークのアップロードに失敗しました。ファイルが破損していた、または問題があった可能性があります。</string>
<!-- Warning message when doing search around current position -->
<string name="unknown_current_position">現在地がまだ決定されていません</string>
<!-- Warning message when location country isn't downloaded during search (see also download_location_map_proposal). -->
<string name="download_location_country">現在地である国(%s)をダウンロード</string>
<!-- Warning message when viewport country isn't downloaded during search -->
<string name="download_viewport_country_to_search">現在マップで検索している国(%s)をダウンロード</string>
</resources>

View file

@ -239,4 +239,10 @@
<string name="load_kmz_successful">즐겨찾기가 성공적으로 로드되었습니다! 지도 또는 즐겨찾기 관리자 화면에서 찾으실 수 있습니다.</string>
<!-- Kml file loading failed -->
<string name="load_kmz_failed">즐겨찾기 업로드가 실패했습니다. 파일이 훼손되었거나 결함이 있을지도 모릅니다.</string>
<!-- Warning message when doing search around current position -->
<string name="unknown_current_position">귀하의 위치를 아직 알아내지 못 했습니다</string>
<!-- Warning message when location country isn't downloaded during search (see also download_location_map_proposal). -->
<string name="download_location_country">귀하께서 현재 계신 국가인 (%s)을(를) 다운로드</string>
<!-- Warning message when viewport country isn't downloaded during search -->
<string name="download_viewport_country_to_search">귀하께서 검색 중인 국가인 (%s)을(를) 다운로드</string>
</resources>

View file

@ -249,4 +249,10 @@
<string name="load_kmz_successful">Bladwijzers met succes geüpload! U vindt ze op de kaart of op het scherm van de Bladwijzer Manager.</string>
<!-- Kml file loading failed -->
<string name="load_kmz_failed">Bladwijzers uploaden mislukt. Het bestand is mogelijk beschadigd of defect.</string>
<!-- Warning message when doing search around current position -->
<string name="unknown_current_position">Je plaats werd nog niet vastgesteld</string>
<!-- Warning message when location country isn't downloaded during search (see also download_location_map_proposal). -->
<string name="download_location_country">Download land (%s) waar je nu bent</string>
<!-- Warning message when viewport country isn't downloaded during search -->
<string name="download_viewport_country_to_search">Download land (%s) waar je op wilt zoeken</string>
</resources>

View file

@ -253,6 +253,10 @@
<string name="edit">Редактировать</string>
<!-- Title for Confirm dialog -->
<string name="are_you_sure">Вы уверены?</string>
<!-- Warning message when searching around current position -->
<string name="unknown_current_position">Текущая позиция недоступна</string>
<!-- Warning message when doing search around current position -->
<string name="unknown_current_position">Ваше местоположение еще не определено</string>
<!-- Warning message when location country isn't downloaded during search (see also download_location_map_proposal). -->
<string name="download_location_country">Скачайте страну (%s) вашего текущего местоположения</string>
<!-- Warning message when viewport country isn't downloaded during search -->
<string name="download_viewport_country_to_search">Скачайте страну (%s), на которой вы ищете</string>
</resources>

View file

@ -220,4 +220,10 @@
<string name="load_kmz_successful">Закладки успішно завантажено! Ви можете знайти їх на карті або у меню Менеджер закладок.</string>
<!-- Kml file loading failed -->
<string name="load_kmz_failed">Не вдалося завантажити закладки. Файл може бути пошкодженим або несправним.</string>
<!-- Warning message when doing search around current position -->
<string name="unknown_current_position">Ваше місце розташування не визначено</string>
<!-- Warning message when location country isn't downloaded during search (see also download_location_map_proposal). -->
<string name="download_location_country">Завантажити країну (%s) вашого поточного місця розташування</string>
<!-- Warning message when viewport country isn't downloaded during search -->
<string name="download_viewport_country_to_search">Завантажити країну (% @), в якій ви шукаєте</string>
</resources>

View file

@ -257,6 +257,10 @@
<string name="edit">Edit</string>
<!-- Title for Confirm dialog -->
<string name="are_you_sure">Are you sure?</string>
<!-- Warning message when searching around current position -->
<string name="unknown_current_position">Current postion is not available</string>
<!-- Warning message when doing search around current position -->
<string name="unknown_current_position">Your location hasn\'t been determined yet</string>
<!-- Warning message when location country isn't downloaded during search (see also download_location_map_proposal). -->
<string name="download_location_country">Download the country (%s) of your current location</string>
<!-- Warning message when viewport country isn't downloaded during search -->
<string name="download_viewport_country_to_search">Download the country (%s) you are searching on</string>
</resources>

View file

@ -5,6 +5,7 @@ import java.util.Locale;
import android.app.ListActivity;
import android.content.Context;
import android.content.res.Resources;
import android.location.Location;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@ -77,11 +78,34 @@ public class SearchActivity extends ListActivity implements LocationService.List
return m_context.isShowCategories();
}
private boolean isShowPositionWarning()
private String getWarningForEmptyResults()
{
return (m_context.m_location.getLastKnown() == null && m_context.m_searchMode == AROUND_POSITION);
}
// First try to show warning if no country downloaded for viewport.
if (m_context.m_searchMode != AROUND_POSITION)
{
final String name = m_context.getViewportCountryNameIfAbsent();
if (name != null)
return String.format(m_context.getString(R.string.download_viewport_country_to_search), name);
}
// If now position detected or no country downloaded for position.
if (m_context.m_searchMode != IN_VIEWPORT)
{
final Location loc = m_context.m_location.getLastKnown();
if (loc == null)
{
return m_context.getString(R.string.unknown_current_position);
}
else
{
final String name = m_context.getCountryNameIfAbsent(loc.getLatitude(), loc.getLongitude());
if (name != null)
return String.format(m_context.getString(R.string.download_location_country), name);
}
}
return null;
}
@Override
public boolean isEnabled(int position)
@ -259,10 +283,11 @@ public class SearchActivity extends ListActivity implements LocationService.List
holder.m_name.setText(m_context.getString(R.string.no_search_results_found));
if (isShowPositionWarning())
final String msg = getWarningForEmptyResults();
if (msg != null)
{
holder.m_country.setVisibility(View.VISIBLE);
holder.m_country.setText(R.string.unknown_current_position);
holder.m_country.setText(msg);
}
else
holder.m_country.setVisibility(View.GONE);
@ -690,4 +715,7 @@ public class SearchActivity extends ListActivity implements LocationService.List
double lat, double lon, int flags,
int searchMode, int queryID);
private static native void nativeShowItem(int position);
private native String getCountryNameIfAbsent(double lat, double lon);
private native String getViewportCountryNameIfAbsent();
}

View file

@ -310,6 +310,11 @@ TStatus Framework::GetCountryStatus(TIndex const & index) const
return res;
}
string Framework::GetCountryName(storage::TIndex const & index) const
{
return m_storage.CountryName(index);
}
m2::RectD Framework::GetCountryBounds(string const & file) const
{
m2::RectD const r = GetSearchEngine()->GetCountryBounds(file);

View file

@ -175,6 +175,7 @@ public:
void DeleteCountry(storage::TIndex const & index);
storage::TStatus GetCountryStatus(storage::TIndex const & index) const;
string GetCountryName(storage::TIndex const & index) const;
/// Get country rect from borders (not from mwm file).
/// @param[in] file Pass country file name without extension as an id.

View file

@ -1639,7 +1639,44 @@
comment = Title for Confirm dialog
ru = Вы уверены?
[unknown_current_position]
en = Current postion is not available
en = Your location hasn't been determined yet
tags = ios, android
comment = Warning message when searching around current position
ru = Текущая позиция недоступна
comment = Warning message when doing search around current position
ru = Ваше местоположение еще не определено
uk = Ваше місце розташування не визначено
ko = 귀하의 위치를 아직 알아내지 못 했습니다
es = Tu ubicación aún no ha sido determinada
it = La tua posizione non è stata ancora stabilita
ja = 現在地がまだ決定されていません
fr = Votre position n'a pas encore été déterminée
cz = Vaše poloha zatím nebyla určena
nl = Je plaats werd nog niet vastgesteld
de = Ihr Standort wurde bisher noch nicht bestimmt
[download_location_country]
en = Download the country (%@) of your current location
tags = ios, android
comment = Warning message when location country isn't downloaded during search (see also download_location_map_proposal).
ru = Скачайте страну (%@) вашего текущего местоположения
uk = Завантажити країну (%@) вашого поточного місця розташування
ko = 귀하께서 현재 계신 국가인 (%@)을(를) 다운로드
es = Descargar país (%@) de tu ubicación actual
it = Scarica il paese (%@) della tua posizione attuale
ja = 現在地である国(%@)をダウンロード
fr = Téléchargez le pays (%@) de votre position actuelle
cz = Země stahování (%@) Vašeho současného místa
nl = Download land (%@) waar je nu bent
de = Land (%@) Ihres derzeitigen Standorts herunterladen
[download_viewport_country_to_search]
en = Download the country (%@) you are searching on
tags = ios, android
comment = Warning message when viewport country isn't downloaded during search
ru = Скачайте страну (%@), на которой вы ищете
uk = Завантажити країну (% @), в якій ви шукаєте
ko = 귀하께서 검색 중인 국가인 (%@)을(를) 다운로드
es = Descargar país (%@) en el que estás buscando
it = Scarica il paese (%@) che stai cercando
ja = 現在マップで検索している国(%@)をダウンロード
fr = Téléchargez le pays (%@) que vous recherchez sur
cz = Země stahování (%@), o níž hledáte
nl = Download land (%@) waar je op wilt zoeken
de = Land (%@) herunterladen, von dem aus Sie suchen