forked from organicmaps/organicmaps
[android] Add "GPS is off" Toast when pressing My Position button.
This commit is contained in:
parent
58d629c8e2
commit
8bd5e4920b
16 changed files with 71 additions and 17 deletions
|
@ -202,4 +202,6 @@
|
|||
<string name="visible">Показывать на карте</string>
|
||||
<!-- Proposal to download Pro version with Bookmarks -->
|
||||
<string name="bookmarks_in_pro_version">Закладки доступны в полной верии MapsWithMe. Скачать ее прямо сейчас?</string>
|
||||
<!-- GPS are disabled by user alert - message -->
|
||||
<string name="gps_is_disabled_long_text">GPS выключена в настройках устройства. Пожалуйста, включите ее для удобного использования программы.</string>
|
||||
</resources>
|
||||
|
|
|
@ -190,4 +190,6 @@
|
|||
<string name="visible">Показувати</string>
|
||||
<!-- Proposal to download Pro version with Bookmarks -->
|
||||
<string name="bookmarks_in_pro_version">Закладки доступні у повній версії MapsWithMe. Отримати просто зараз?</string>
|
||||
<!-- GPS are disabled by user alert - message -->
|
||||
<string name="gps_is_disabled_long_text">GPS вимкнена в налаштуваннях пристрою. Будь ласка, увімкніть її для зручного використання програми.</string>
|
||||
</resources>
|
||||
|
|
|
@ -206,4 +206,6 @@
|
|||
<string name="visible">Visible</string>
|
||||
<!-- Proposal to download Pro version with Bookmarks -->
|
||||
<string name="bookmarks_in_pro_version">Bookmarks are available in the full version of MapsWithMe. Get it right now?</string>
|
||||
<!-- GPS are disabled by user alert - message -->
|
||||
<string name="gps_is_disabled_long_text">You currently have GPS for this device or application disabled. Please enable it in Settings.</string>
|
||||
</resources>
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapswithme.maps.location.LocationService;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
|
@ -626,6 +627,10 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
|
|||
}).show();
|
||||
}
|
||||
}
|
||||
else if (errorCode == LocationService.ERROR_GPS_OFF)
|
||||
{
|
||||
Toast.makeText(this, R.string.gps_is_disabled_long_text, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void onCompassStatusChanged(int newStatus)
|
||||
|
|
|
@ -117,19 +117,27 @@ public class LocationService implements LocationListener, SensorEventListener, W
|
|||
|
||||
if (!m_isActive)
|
||||
{
|
||||
List<String> enabledProviders = m_locationManager.getProviders(true);
|
||||
List<String> providers = m_locationManager.getProviders(false);
|
||||
|
||||
// Remove passive provider, we don't use it in the current implementation
|
||||
for (int i = 0; i < enabledProviders.size(); ++i)
|
||||
if (enabledProviders.get(i).equals("passive"))
|
||||
// Remove passive provider and check for enabled providers.
|
||||
boolean isGPSOff = false;
|
||||
for (int i = 0; i < providers.size();)
|
||||
{
|
||||
final String provider = providers.get(i);
|
||||
if (!m_locationManager.isProviderEnabled(provider) ||
|
||||
provider.equals(LocationManager.PASSIVE_PROVIDER))
|
||||
{
|
||||
enabledProviders.remove(i);
|
||||
break;
|
||||
if (provider.equals(LocationManager.GPS_PROVIDER))
|
||||
isGPSOff = true;
|
||||
providers.remove(i);
|
||||
}
|
||||
else
|
||||
++i;
|
||||
}
|
||||
|
||||
Log.d(TAG, "Enabled providers count = " + enabledProviders.size());
|
||||
Log.d(TAG, "Enabled providers count = " + providers.size());
|
||||
|
||||
if (enabledProviders.size() == 0)
|
||||
if (providers.size() == 0)
|
||||
{
|
||||
// Use WiFi BSSIDS and Google Internet location service if no other options are available
|
||||
// But only if connection is available
|
||||
|
@ -149,17 +157,14 @@ public class LocationService implements LocationListener, SensorEventListener, W
|
|||
|
||||
Location lastKnown = null;
|
||||
|
||||
for (String provider : enabledProviders)
|
||||
for (String provider : providers)
|
||||
{
|
||||
if (m_locationManager.isProviderEnabled(provider))
|
||||
{
|
||||
Log.d(TAG, "Connected to provider = " + provider);
|
||||
// Half of a second is more than enough, I think ...
|
||||
m_locationManager.requestLocationUpdates(provider, 500, 0, this);
|
||||
Log.d(TAG, "Connected to provider = " + provider);
|
||||
// Half of a second is more than enough, I think ...
|
||||
m_locationManager.requestLocationUpdates(provider, 500, 0, this);
|
||||
|
||||
// Remember last known location
|
||||
lastKnown = getBestLastKnownLocation(lastKnown, m_locationManager.getLastKnownLocation(provider));
|
||||
}
|
||||
// Remember last known location
|
||||
lastKnown = getBestLastKnownLocation(lastKnown, m_locationManager.getLastKnownLocation(provider));
|
||||
}
|
||||
|
||||
if (m_sensorManager != null)
|
||||
|
@ -181,6 +186,9 @@ public class LocationService implements LocationListener, SensorEventListener, W
|
|||
onLocationChanged(lastKnown);
|
||||
}
|
||||
}
|
||||
|
||||
if (isGPSOff)
|
||||
observer.onLocationError(ERROR_GPS_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -320,3 +320,6 @@
|
|||
|
||||
/* Proposal to download Pro version with Bookmarks */
|
||||
"bookmarks_in_pro_version" = "Lesezeichen stehen in der Vollversion von MapsWithMe zur Verfügung. Jetzt sofort besorgen?";
|
||||
|
||||
/* GPS are disabled by user alert - message */
|
||||
"gps_is_disabled_long_text" = "You currently have GPS for this device or application disabled. Please enable it in Settings.";
|
||||
|
|
|
@ -320,3 +320,6 @@
|
|||
|
||||
/* Proposal to download Pro version with Bookmarks */
|
||||
"bookmarks_in_pro_version" = "Bookmarks are available in the full version of MapsWithMe. Get it right now?";
|
||||
|
||||
/* GPS are disabled by user alert - message */
|
||||
"gps_is_disabled_long_text" = "You currently have GPS for this device or application disabled. Please enable it in Settings.";
|
||||
|
|
|
@ -320,3 +320,6 @@
|
|||
|
||||
/* Proposal to download Pro version with Bookmarks */
|
||||
"bookmarks_in_pro_version" = "La opción de marcadores está disponible en la versión completa de MapsWithMe. ¿La quieres ya?";
|
||||
|
||||
/* GPS are disabled by user alert - message */
|
||||
"gps_is_disabled_long_text" = "You currently have GPS for this device or application disabled. Please enable it in Settings.";
|
||||
|
|
|
@ -320,3 +320,6 @@
|
|||
|
||||
/* Proposal to download Pro version with Bookmarks */
|
||||
"bookmarks_in_pro_version" = "Les marques-page sont disponibles dans la version complète de MapsWithMe. Se la procurer maintenant?";
|
||||
|
||||
/* GPS are disabled by user alert - message */
|
||||
"gps_is_disabled_long_text" = "You currently have GPS for this device or application disabled. Please enable it in Settings.";
|
||||
|
|
|
@ -320,3 +320,6 @@
|
|||
|
||||
/* Proposal to download Pro version with Bookmarks */
|
||||
"bookmarks_in_pro_version" = "Bookmarks are available in the full version of MapsWithMe. Get it right now?";
|
||||
|
||||
/* GPS are disabled by user alert - message */
|
||||
"gps_is_disabled_long_text" = "You currently have GPS for this device or application disabled. Please enable it in Settings.";
|
||||
|
|
|
@ -320,3 +320,6 @@
|
|||
|
||||
/* Proposal to download Pro version with Bookmarks */
|
||||
"bookmarks_in_pro_version" = "ブックマークはMapsWithMeの完全版でご利用いただけます。いますぐ取得されますか?";
|
||||
|
||||
/* GPS are disabled by user alert - message */
|
||||
"gps_is_disabled_long_text" = "You currently have GPS for this device or application disabled. Please enable it in Settings.";
|
||||
|
|
|
@ -320,3 +320,6 @@
|
|||
|
||||
/* Proposal to download Pro version with Bookmarks */
|
||||
"bookmarks_in_pro_version" = "MapsWithMe의 정식 버전에서는 즐겨찾기를 이용하실 수 있습니다. 지금 바로 구입하시겠습니까?";
|
||||
|
||||
/* GPS are disabled by user alert - message */
|
||||
"gps_is_disabled_long_text" = "You currently have GPS for this device or application disabled. Please enable it in Settings.";
|
||||
|
|
|
@ -320,3 +320,6 @@
|
|||
|
||||
/* Proposal to download Pro version with Bookmarks */
|
||||
"bookmarks_in_pro_version" = "Bladwijzers zijn beschikbaar in de volledige versie van MapsWithMe. Wilt u die nu gelijk?";
|
||||
|
||||
/* GPS are disabled by user alert - message */
|
||||
"gps_is_disabled_long_text" = "You currently have GPS for this device or application disabled. Please enable it in Settings.";
|
||||
|
|
|
@ -320,3 +320,6 @@
|
|||
|
||||
/* Proposal to download Pro version with Bookmarks */
|
||||
"bookmarks_in_pro_version" = "Закладки доступны в полной верии MapsWithMe. Скачать ее прямо сейчас?";
|
||||
|
||||
/* GPS are disabled by user alert - message */
|
||||
"gps_is_disabled_long_text" = "GPS выключена в настройках устройства. Пожалуйста, включите ее для удобного использования программы.";
|
||||
|
|
|
@ -320,3 +320,6 @@
|
|||
|
||||
/* Proposal to download Pro version with Bookmarks */
|
||||
"bookmarks_in_pro_version" = "Закладки доступні у повній версії MapsWithMe. Отримати просто зараз?";
|
||||
|
||||
/* GPS are disabled by user alert - message */
|
||||
"gps_is_disabled_long_text" = "GPS вимкнена в налаштуваннях пристрою. Будь ласка, увімкніть її для зручного використання програми.";
|
||||
|
|
|
@ -1308,3 +1308,8 @@
|
|||
ko = MapsWithMe의 정식 버전에서는 즐겨찾기를 이용하실 수 있습니다. 지금 바로 구입하시겠습니까?
|
||||
cs = V plné verzi MapsWithMe jsou k dispozici záložky. Chcete ji pořídit hned teď?
|
||||
nl = Bladwijzers zijn beschikbaar in de volledige versie van MapsWithMe. Wilt u die nu gelijk?
|
||||
[gps_is_disabled_long_text]
|
||||
en = You currently have GPS for this device or application disabled. Please enable it in Settings.
|
||||
comment = GPS are disabled by user alert - message
|
||||
ru = GPS выключена в настройках устройства. Пожалуйста, включите ее для удобного использования программы.
|
||||
uk = GPS вимкнена в налаштуваннях пристрою. Будь ласка, увімкніть її для зручного використання програми.
|
||||
|
|
Loading…
Add table
Reference in a new issue