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:
-rw-r--r--android/jni/com/mapswithme/maps/LocationState.cpp23
-rw-r--r--android/src/com/mapswithme/maps/LocationState.java2
-rw-r--r--android/src/com/mapswithme/maps/MWMActivity.java13
-rw-r--r--iphone/Maps/Bookmarks/BookmarksVC.mm4
-rw-r--r--iphone/Maps/Classes/MapViewController.mm25
-rw-r--r--iphone/Maps/Classes/SearchVC.mm4
-rw-r--r--iphone/Maps/Platform/LocationManager.h5
-rw-r--r--iphone/Maps/Platform/LocationManager.mm20
-rw-r--r--map/framework.cpp5
-rw-r--r--map/framework.hpp2
-rw-r--r--platform/location.hpp3
-rw-r--r--qt/mainwindow.cpp7
-rw-r--r--qt/mainwindow.hpp1
13 files changed, 56 insertions, 58 deletions
diff --git a/android/jni/com/mapswithme/maps/LocationState.cpp b/android/jni/com/mapswithme/maps/LocationState.cpp
index 60d94841bb..f48eb8fa2d 100644
--- a/android/jni/com/mapswithme/maps/LocationState.cpp
+++ b/android/jni/com/mapswithme/maps/LocationState.cpp
@@ -63,56 +63,63 @@ extern "C"
Java_com_mapswithme_maps_LocationState_addCompassStatusListener(JNIEnv * env, jobject thiz, jobject obj)
{
location::State::TCompassStatusListener fn = bind(&CompassStatusChanged, _1, jni::make_global_ref(obj));
- shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState();
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetLocationState();
return ls->AddCompassStatusListener(fn);
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_LocationState_removeCompassStatusListener(JNIEnv * env, jobject thiz, jint slotID)
{
- shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState();
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetLocationState();
ls->RemoveCompassStatusListener(slotID);
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_LocationState_hasPosition(JNIEnv * env, jobject thiz)
{
- shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState();
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetLocationState();
return ls->HasPosition();
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_LocationState_hasCompass(JNIEnv * env, jobject thiz)
{
- shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState();
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetLocationState();
return ls->HasCompass();
}
+ JNIEXPORT jboolean JNICALL
+ Java_com_mapswithme_maps_LocationState_isFirstPosition(JNIEnv * env, jobject thiz)
+ {
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetLocationState();
+ return ls->IsFirstPosition();
+ }
+
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_LocationState_turnOff(JNIEnv * env, jobject thiz)
{
- shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState();
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetLocationState();
return ls->TurnOff();
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_LocationState_isVisible(JNIEnv * env, jobject thiz)
{
- shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState();
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetLocationState();
return ls->isVisible();
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_LocationState_onStartLocation(JNIEnv * env, jobject thiz)
{
- shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState();
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetLocationState();
ls->OnStartLocation();
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_LocationState_onStopLocation(JNIEnv * env, jobject thiz)
{
- shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState();
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetLocationState();
ls->OnStopLocation();
}
}
diff --git a/android/src/com/mapswithme/maps/LocationState.java b/android/src/com/mapswithme/maps/LocationState.java
index 280d12682b..a830d8ca08 100644
--- a/android/src/com/mapswithme/maps/LocationState.java
+++ b/android/src/com/mapswithme/maps/LocationState.java
@@ -31,6 +31,8 @@ public class LocationState
public native boolean hasPosition();
public native boolean hasCompass();
+ public native boolean isFirstPosition();
+
public native void turnOff();
public native boolean isVisible();
}
diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java
index f0a36f2445..e3fc54fa11 100644
--- a/android/src/com/mapswithme/maps/MWMActivity.java
+++ b/android/src/com/mapswithme/maps/MWMActivity.java
@@ -38,7 +38,6 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
private BroadcastReceiver m_externalStorageReceiver = null;
private AlertDialog m_storageDisconnectedDialog = null;
private boolean m_locationWasActive = false;
- private boolean m_isFirstLocation = false;
private LocationService getLocationService()
{
@@ -57,17 +56,13 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
private void startLocation()
{
- getLocationState().setLocationProcessMode(LocationState.LOCATION_CENTER_AND_SCALE);
- getLocationState().setCompassProcessMode(LocationState.COMPASS_DO_NOTHING);
- m_isFirstLocation = true;
+ getLocationState().onStartLocation();
resumeLocation();
}
private void stopLocation()
{
- getLocationState().setLocationProcessMode(LocationState.LOCATION_DO_NOTHING);
- getLocationState().setCompassProcessMode(LocationState.COMPASS_DO_NOTHING);
- getLocationState().turnOff();
+ getLocationState().onStopLocation();
pauseLocation();
}
@@ -666,14 +661,12 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
@Override
public void onLocationUpdated(long time, double lat, double lon, float accuracy)
{
- if (m_isFirstLocation)
+ if (getLocationState().isFirstPosition())
{
final View v = findViewById(R.id.map_button_myposition);
v.setBackgroundResource(R.drawable.myposition_button_found);
v.setSelected(true);
-
- m_isFirstLocation = false;
}
nativeLocationUpdated(time, lat, lon, accuracy);
diff --git a/iphone/Maps/Bookmarks/BookmarksVC.mm b/iphone/Maps/Bookmarks/BookmarksVC.mm
index 12f2d1c359..250054ffbd 100644
--- a/iphone/Maps/Bookmarks/BookmarksVC.mm
+++ b/iphone/Maps/Bookmarks/BookmarksVC.mm
@@ -201,12 +201,12 @@
//******************************************************************
//*********** Location manager callbacks ***************************
-- (void)onLocationStatusChanged:(location::TLocationStatus)newStatus
+- (void)onLocationError:(location::TLocationError)errorCode
{
// Handle location status changes if necessary
}
-- (void)onGpsUpdate:(location::GpsInfo const &)info
+- (void)onLocationUpdate:(location::GpsInfo const &)info
{
// Refresh distance
BookmarkCategory * cat = GetFramework().GetBmCategory(m_categoryIndex);
diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm
index da58948797..22639006c9 100644
--- a/iphone/Maps/Classes/MapViewController.mm
+++ b/iphone/Maps/Classes/MapViewController.mm
@@ -19,12 +19,12 @@
//********************************************************************************************
//*********************** Callbacks from LocationManager *************************************
-- (void) onLocationStatusChanged:(location::TLocationStatus)newStatus
+- (void) onLocationError:(location::TLocationError)errorCode
{
- GetFramework().OnLocationStatusChanged(newStatus);
- switch (newStatus)
+ GetFramework().OnLocationError(errorCode);
+ switch (errorCode)
{
- case location::EDisabledByUser:
+ case location::EDenied:
{
UIAlertView * alert = [[CustomAlertView alloc] initWithTitle:nil
message:NSLocalizedString(@"location_is_disabled_long_text", @"Location services are disabled by user alert - message")
@@ -36,7 +36,7 @@
[[MapsAppDelegate theApp].m_locationManager stop:self];
}
break;
- case location::ENotSupported:
+ case location::ENotSupported:
{
UIAlertView * alert = [[CustomAlertView alloc] initWithTitle:nil
message:NSLocalizedString(@"device_doesnot_support_location_services", @"Location Services are not available on the device alert - message")
@@ -48,18 +48,19 @@
[[MapsAppDelegate theApp].m_locationManager stop:self];
}
break;
- case location::EFirstEvent:
- [m_myPositionButton setImage:[UIImage imageNamed:@"location-selected.png"] forState:UIControlStateSelected];
- break;
default:
break;
}
}
-- (void) onGpsUpdate:(location::GpsInfo const &)info
+- (void) onLocationUpdate:(location::GpsInfo const &)info
{
- GetFramework().OnGpsUpdate(info);
-
+ if (GetFramework().GetLocationState()->IsFirstPosition())
+ {
+ [m_myPositionButton setImage:[UIImage imageNamed:@"location-selected.png"] forState:UIControlStateSelected];
+ }
+
+ GetFramework().OnLocationUpdate(info);
[self updateDataAfterScreenChanged];
}
@@ -76,6 +77,7 @@
{
m_myPositionButton.selected = YES;
[m_myPositionButton setImage:[UIImage imageNamed:@"location-search.png"] forState:UIControlStateSelected];
+ GetFramework().StartLocation();
[[MapsAppDelegate theApp] disableStandby];
[[MapsAppDelegate theApp].m_locationManager start:self];
}
@@ -83,6 +85,7 @@
{
m_myPositionButton.selected = NO;
[m_myPositionButton setImage:[UIImage imageNamed:@"location.png"] forState:UIControlStateSelected];
+ GetFramework().StopLocation();
[[MapsAppDelegate theApp] enableStandby];
[[MapsAppDelegate theApp].m_locationManager stop:self];
}
diff --git a/iphone/Maps/Classes/SearchVC.mm b/iphone/Maps/Classes/SearchVC.mm
index fa411e0c41..832f9bf276 100644
--- a/iphone/Maps/Classes/SearchVC.mm
+++ b/iphone/Maps/Classes/SearchVC.mm
@@ -471,12 +471,12 @@ static void OnSearchResultCallback(search::Results const & res)
//******************************************************************
//*********** Location manager callbacks ***************************
-- (void)onLocationStatusChanged:(location::TLocationStatus)newStatus
+- (void)onLocationError:(location::TLocationError)errorCode
{
// Handle location status changes if necessary
}
-- (void)onGpsUpdate:(location::GpsInfo const &)info
+- (void)onLocationUpdate:(location::GpsInfo const &)info
{
// Refresh search results with newer location.
NSString * queryString = m_searchBar.text;
diff --git a/iphone/Maps/Platform/LocationManager.h b/iphone/Maps/Platform/LocationManager.h
index f6cf047dec..e1f0c6db69 100644
--- a/iphone/Maps/Platform/LocationManager.h
+++ b/iphone/Maps/Platform/LocationManager.h
@@ -9,8 +9,8 @@
@protocol LocationObserver
@required
- - (void)onLocationStatusChanged:(location::TLocationStatus)newStatus;
- - (void)onGpsUpdate:(location::GpsInfo const &)info;
+ - (void)onLocationError:(location::TLocationError)errorCode;
+ - (void)onLocationUpdate:(location::GpsInfo const &)info;
- (void)onCompassUpdate:(location::CompassInfo const &)info;
@end
@@ -18,7 +18,6 @@
{
CLLocationManager * m_locationManager;
BOOL m_isStarted;
- BOOL m_reportFirstUpdate;
NSMutableSet * m_observers;
BOOL m_isTimerActive;
}
diff --git a/iphone/Maps/Platform/LocationManager.mm b/iphone/Maps/Platform/LocationManager.mm
index 8a8f12c354..4c5c077abd 100644
--- a/iphone/Maps/Platform/LocationManager.mm
+++ b/iphone/Maps/Platform/LocationManager.mm
@@ -20,7 +20,6 @@
m_locationManager.headingFilter = 3.0;
m_locationManager.distanceFilter = 3.0;
m_isStarted = NO;
- m_reportFirstUpdate = YES;
m_observers = [[NSMutableSet alloc] init];
}
return self;
@@ -53,21 +52,19 @@
[m_locationManager startUpdatingHeading];
m_isStarted = YES;
[m_observers addObject:observer];
- [observer onLocationStatusChanged:location::EStarted];
break;
case kCLAuthorizationStatusRestricted:
case kCLAuthorizationStatusDenied:
- [observer onLocationStatusChanged:location::EDisabledByUser];
+ [observer onLocationError:location::EDenied];
break;
}
}
else
- [observer onLocationStatusChanged:location::ENotSupported];
+ [observer onLocationError:location::ENotSupported];
}
else
{
[m_observers addObject:observer];
- [observer onLocationStatusChanged:location::EStarted];
}
}
@@ -80,13 +77,11 @@
{
// stop only if no more observers are subsribed
m_isStarted = NO;
- m_reportFirstUpdate = YES;
if ([CLLocationManager headingAvailable])
[m_locationManager stopUpdatingHeading];
[m_locationManager stopUpdatingLocation];
}
}
- [observer onLocationStatusChanged:location::EStopped];
}
- (CLLocation *)lastLocation
@@ -118,17 +113,10 @@
if (location::IsLatValid(newLocation.coordinate.latitude) &&
location::IsLonValid(newLocation.coordinate.longitude))
{
- if (m_reportFirstUpdate)
- {
- for (id observer in m_observers)
- [observer onLocationStatusChanged:location::EFirstEvent];
- m_reportFirstUpdate = NO;
- }
-
location::GpsInfo newInfo;
[self location:newLocation toGpsInfo:newInfo];
for (id observer in m_observers)
- [observer onGpsUpdate:newInfo];
+ [observer onLocationUpdate:newInfo];
}
}
@@ -151,7 +139,7 @@
if (error.code == kCLErrorDenied)
{
for (id observer in m_observers)
- [observer onLocationStatusChanged:location::EDisabledByUser];
+ [observer onLocationError:location::EDenied];
}
}
diff --git a/map/framework.cpp b/map/framework.cpp
index ee76a48597..018b16695b 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -1430,3 +1430,8 @@ Navigator & Framework::GetNavigator()
{
return m_navigator;
}
+
+shared_ptr<location::State> const & Framework::GetLocationState() const
+{
+ return m_informationDisplay.locationState();
+}
diff --git a/map/framework.hpp b/map/framework.hpp
index 265caf58f3..a3c29b899e 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -410,4 +410,6 @@ public:
/// Checks, whether the country which contains
/// the specified point is loaded
bool IsCountryLoaded(m2::PointD const & pt) const;
+
+ shared_ptr<location::State> const & GetLocationState() const;
};
diff --git a/platform/location.hpp b/platform/location.hpp
index b6df73b4e7..87261f68c1 100644
--- a/platform/location.hpp
+++ b/platform/location.hpp
@@ -11,7 +11,8 @@ namespace location
enum TLocationError
{
- EDenied
+ EDenied,
+ ENotSupported
};
enum TLocationSource
diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp
index e0ee73b8ec..9553a76855 100644
--- a/qt/mainwindow.cpp
+++ b/qt/mainwindow.cpp
@@ -40,7 +40,6 @@ namespace qt
MainWindow::MainWindow()
{
m_pDrawWidget = new DrawWidget(this);
- m_isFirstLocation = true;
m_locationService.reset(CreateDesktopLocationService(*this));
CreateNavigationBar();
@@ -315,11 +314,10 @@ void MainWindow::OnLocationError(location::TLocationError errorCode)
void MainWindow::OnLocationUpdated(location::GpsInfo const & info)
{
- if (m_isFirstLocation)
+ if (m_pDrawWidget->GetFramework().GetLocationState()->IsFirstPosition())
{
m_pMyPositionAction->setIcon(QIcon(":/navig64/location.png"));
m_pMyPositionAction->setToolTip(tr("My Position"));
- m_isFirstLocation = false;
}
m_pDrawWidget->GetFramework().OnLocationUpdate(info);
@@ -331,14 +329,15 @@ void MainWindow::OnMyPosition()
{
m_pMyPositionAction->setIcon(QIcon(":/navig64/location-search.png"));
m_pMyPositionAction->setToolTip(tr("Looking for position..."));
- m_isFirstLocation = true;
m_locationService->Start();
+ m_pDrawWidget->GetFramework().StartLocation();
}
else
{
m_pMyPositionAction->setIcon(QIcon(":/navig64/location.png"));
m_pMyPositionAction->setToolTip(tr("My Position"));
m_locationService->Stop();
+ m_pDrawWidget->GetFramework().StopLocation();
}
}
diff --git a/qt/mainwindow.hpp b/qt/mainwindow.hpp
index abcb0589be..fc0942f790 100644
--- a/qt/mainwindow.hpp
+++ b/qt/mainwindow.hpp
@@ -23,7 +23,6 @@ namespace qt
QDockWidget * m_Docks[3];
- bool m_isFirstLocation;
scoped_ptr<location::LocationService> m_locationService;
Q_OBJECT