diff --git a/android/app/src/main/java/app/organicmaps/MwmActivity.java b/android/app/src/main/java/app/organicmaps/MwmActivity.java index bbe986c6bb..c3e27b7853 100644 --- a/android/app/src/main/java/app/organicmaps/MwmActivity.java +++ b/android/app/src/main/java/app/organicmaps/MwmActivity.java @@ -152,6 +152,7 @@ public class MwmActivity extends BaseMwmFragmentActivity public static final String EXTRA_TRACK_ID = "track_id"; public static final String EXTRA_UPDATE_THEME = "update_theme"; private static final String EXTRA_CONSUMED = "mwm.extra.intent.processed"; + private boolean mPreciseLocationDialogShown = false; private static final String[] DOCKED_FRAGMENTS = { SearchFragment.class.getName(), DownloaderFragment.class.getName(), @@ -1830,7 +1831,7 @@ public class MwmActivity extends BaseMwmFragmentActivity } // Check for any location permissions. - if (!LocationUtils.checkCoarseLocationPermission(this)) + if (!LocationUtils.checkLocationPermission(this)) { Logger.w(LOCATION_TAG, "Permissions ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION are not granted"); // Calls onMyPositionModeChanged(NOT_FOLLOW_NO_POSITION). @@ -1968,12 +1969,50 @@ public class MwmActivity extends BaseMwmFragmentActivity mLocationPermissionRequestedForRecording = false; if (LocationUtils.checkLocationPermission(this)) { + final boolean hasFineLocationPermission = LocationUtils.checkFineLocationPermission(this); + if (LocationState.getMode() == LocationState.NOT_FOLLOW_NO_POSITION) LocationState.nativeSwitchToNextMode(); - if (requestedForRecording && LocationUtils.checkFineLocationPermission(this)) + if (requestedForRecording && hasFineLocationPermission) startTrackRecording(); + if (hasFineLocationPermission) + { + Logger.i(LOCATION_TAG, "ACCESS_FINE_LOCATION permission granted"); + } + else + { + Logger.w(LOCATION_TAG, "Only ACCESS_COARSE_LOCATION permission granted"); + if (mLocationErrorDialog != null && mLocationErrorDialog.isShowing()) + { + Logger.w(LOCATION_TAG, "Don't show 'Precise Location denied' dialog because another dialog is in progress"); + return; + } + if (!mPreciseLocationDialogShown) + { + mPreciseLocationDialogShown = true; + final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog) + .setTitle("⚠ " + getString(R.string.limited_accuracy)) + .setMessage(R.string.precise_location_is_disabled_long_text) + .setNegativeButton(R.string.close, (dialog, which) -> dialog.dismiss()) + .setCancelable(true) + .setOnDismissListener(dialog -> mLocationErrorDialog = null); + final Intent intent = Utils.makeSystemLocationSettingIntent(this); + if (intent != null) + { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); + intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + builder.setPositiveButton(R.string.location_settings, (dialog, which) -> startActivity(intent)); + } + mLocationErrorDialog = builder.show(); + } + else + { + Toast.makeText(this, R.string.precise_location_is_disabled_long_text, Toast.LENGTH_LONG).show(); + } + } return; } diff --git a/android/app/src/main/java/app/organicmaps/SplashActivity.java b/android/app/src/main/java/app/organicmaps/SplashActivity.java index 7f4ae291a9..37c7cd976b 100644 --- a/android/app/src/main/java/app/organicmaps/SplashActivity.java +++ b/android/app/src/main/java/app/organicmaps/SplashActivity.java @@ -91,7 +91,7 @@ public class SplashActivity extends AppCompatActivity super.onResume(); if (mCanceled) return; - if (!Config.isLocationRequested() && !LocationUtils.checkCoarseLocationPermission(this)) + if (!Config.isLocationRequested() && !LocationUtils.checkLocationPermission(this)) { Logger.d(TAG, "Requesting location permissions"); mPermissionRequest.launch(new String[]{ diff --git a/android/app/src/main/java/app/organicmaps/util/LocationUtils.java b/android/app/src/main/java/app/organicmaps/util/LocationUtils.java index 0631893b7e..e8c2571514 100644 --- a/android/app/src/main/java/app/organicmaps/util/LocationUtils.java +++ b/android/app/src/main/java/app/organicmaps/util/LocationUtils.java @@ -118,13 +118,14 @@ public class LocationUtils return ContextCompat.checkSelfPermission(context, ACCESS_FINE_LOCATION) == PERMISSION_GRANTED; } - public static boolean checkCoarseLocationPermission(@NonNull Context context) + /** + * Checks if the app has location permissions granted. + * Returns true if either: + * Only ACCESS_COARSE_LOCATION is granted + * Both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION are granted + */ + public static boolean checkLocationPermission(@NonNull Context context) { return ContextCompat.checkSelfPermission(context, ACCESS_COARSE_LOCATION) == PERMISSION_GRANTED; } - - public static boolean checkLocationPermission(@NonNull Context context) - { - return checkFineLocationPermission(context) || checkCoarseLocationPermission(context); - } } diff --git a/android/app/src/main/java/app/organicmaps/util/Utils.java b/android/app/src/main/java/app/organicmaps/util/Utils.java index 64a0b14245..a13374805e 100644 --- a/android/app/src/main/java/app/organicmaps/util/Utils.java +++ b/android/app/src/main/java/app/organicmaps/util/Utils.java @@ -271,10 +271,12 @@ public class Utils * @param context the app context * @param uri the URI to open. * @param failMessage string id: message to show in a toast when the system can't find an app to open with. + * @param action (optional) the Intent action to use. If none is provided, defaults to Intent.ACTION_VIEW. */ - public static void openUri(@NonNull Context context, @NonNull Uri uri, Integer failMessage) + public static void openUri(@NonNull Context context, @NonNull Uri uri, Integer failMessage, @NonNull String... action) { - final Intent intent = new Intent(Intent.ACTION_VIEW); + final String act = (action != null && action.length > 0 && action[0] != null) ? action[0] : Intent.ACTION_VIEW; + final Intent intent = new Intent(act); intent.setData(uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/data/strings/strings.txt b/data/strings/strings.txt index 4d91c28ae9..50f9de91ce 100644 --- a/data/strings/strings.txt +++ b/data/strings/strings.txt @@ -808,6 +808,99 @@ vi = Bạn hiện đang tắt tất cả Dịch vụ Định vị cho thiết bị hoặc ứng dụng này. Bạn vui lòng bật lại chúng trong Thiết lập. zh-Hans = 您当前已禁用此设备或应用程序的所有位置服务,请在设置中启用。 zh-Hant = 您目前已禁用此裝置或應用程式的所有位置權限,請在設定中啟用。 + + [limited_accuracy] + comment = A dialog title, that warns a user that Precise Location is disabled and suggests to turn it on + tags = android + en = Limited Accuracy + af = Beperkte akkuraatheid + ar = دقة محدودة + az = Məhdud dəqiqlik + be = Абмежаваная дакладнасць + bg = Ограничена точност + ca = Precisió limitada + cs = Omezená přesnost + da = Begrænset nøjagtighed + de = Begrenzte Genauigkeit + el = Περιορισμένη ακρίβεια + es = Precisión limitada + et = Piiratud täpsus + eu = Zehaztasun mugatua + fa = دقت محدود + fi = Rajoitettu tarkkuus + fr = Précision limitée + he = דיוק מוגבל + hi = सीमित सटीकता + hu = Korlátozott pontosság + id = Akurasi Terbatas + it = Precisione limitata + ja = 限られた精度 + ko = 제한된 정확도 + lt = Ribotas tikslumas + lv = Piekļuve precīzai atrašanās vietai ir ierobežota. + mr = मर्यादित अचूकता + nb = Begrenset nøyaktighet + nl = Beperkte nauwkeurigheid + pl = Ograniczona dokładność + pt = Precisão limitada + ro = Acuratețe limitată + ru = Точность местоположения ограничена + sk = Obmedzená presnosť + sv = Begränsad noggrannhet + sw = Usahihi mdogo + th = ความแม่นยำ จำกัด + tr = Sınırlı Doğruluk + uk = Обмежена точність + vi = Độ chính xác hạn chế + zh-Hans = 精度有限 + zh-Hant = 精度有限 + + [precise_location_is_disabled_long_text] + comment = A dialog text, that warns a user that Precise Location is disabled and suggests to turn it on + tags = android + en = To ensure accurate navigation enable Precise Location in settings. + af = Om 'n akkurate navigasie te verseker, maak dit 'n presiese ligging in instellings moontlik. + ar = لضمان التنقل الدقيق، قم بتمكين الموقع الدقيق في الإعدادات. + az = Dəqiq naviqasiyanı təmin etmək üçün parametrlərdə dəqiq bir yer təmin edin. + be = Для забеспячэння дакладнай навігацыі ўключыце дакладнае месцазнаходжанне ў наладах. + bg = За да осигурите точна навигация, активирайте функцията "Точно местоположение" в настройките. + ca = Per assegurar la navegació precisa, activeu la ubicació precisa en la configuració. + cs = Chcete-li zajistit přesnou navigaci, povolte v nastavení možnost Přesná poloha. + da = For at sikre nøjagtig navigation skal du aktivere Præcis placering i indstillingerne. + de = Um eine genaue Navigation zu gewährleisten, aktivieren Sie in den Einstellungen die Option Genauen Standort verwenden. + el = Για να εξασφαλίσετε ακριβή πλοήγηση, ενεργοποιήστε την Ακριβής τοποθεσία στις ρυθμίσεις. + es = Para garantizar una navegación más exacta, active la opción de ubicación precisa en los ajustes. + et = Täpse navigeerimise tagamiseks lülitage seadetes sisse Täpne asukoht. + eu = Nabigazio zehatzagoa ziurtatzeko, gaitu kokapen zehatza ezarpenetan. + fa = برای اطمینان از دقیق ناوبری ، موقعیت مکانی دقیق را در تنظیمات فعال کنید. + fi = Tarkan navigoinnin varmistamiseksi ota Tarkka sijainti käyttöön asetuksissa. + fr = Pour garantir une navigation précise, activez l'option Localisation précise dans les paramètres. + he = כדי להבטיח ניווט מדויק לאפשר מיקום מדויק בהגדרות. + hi = सटीक नेविगेशन सुनिश्चित करने के लिए सेटिंग्स में सटीक स्थान सक्षम करें। + hu = A pontos navigáció érdekében engedélyezze a beállítások között a Pontos helymeghatározás opciót. + id = Untuk memastikan navigasi yang akurat, aktifkan Lokasi Tepat dalam pengaturan. + it = Per garantire una navigazione accurata, attivi la funzione Posizione precisa nelle impostazioni. + ja = 正確なナビゲーションを実現するには、設定で「正確な位置情報」を有効にしてください。 + ko = 정확한 탐색을 위해 설정에서 정확한 위치를 활성화합니다. + lt = Norėdami užtikrinti tikslią navigaciją, nustatymuose įjunkite funkciją Tiksli vieta. + lv = Lai nodrošinātu pareizu navigāciju, ieslēdziet iestatījumos "Precīzo" atrašanās vietas noteikšanu. + mr = अचूक नेव्हिगेशन सुनिश्चित करण्यासाठी सेटिंग्जमध्ये अचूक स्थान सक्षम करा. + nb = For å sikre nøyaktig navigering aktiverer du Precise Location i innstillingene. + nl = Voor nauwkeurige navigatie schakelt u Precise Location in bij instellingen. + pl = Aby zapewnić dokładną nawigację, proszę włączyć opcję Precyzyjna lokalizacja w ustawieniach. + pt = Para garantir uma navegação precisa, active a opção Localização precisa nas definições. + pt-BR = Para garantir uma navegação precisa, ative a Localização precisa nas configurações. + ro = Pentru a asigura o navigare precisă, activați Localizare precisă în setări. + ru = Включите в настройках точное определение местоположения. + sk = Ak chcete zabezpečiť presnú navigáciu, v nastaveniach povoľte funkciu Presná poloha. + sv = För att säkerställa korrekt navigering aktiverar du Precise Location i inställningarna. + sw = Ili kuhakikisha urambazaji sahihi huwezesha eneo sahihi katika mipangilio. + th = เพื่อให้แน่ใจว่าการนำทางที่ถูกต้องเปิดใช้งานตำแหน่งที่แม่นยำในการตั้งค่า + tr = Doğru navigasyon sağlamak için ayarlardan Hassas Konum'u etkinleştirin. + uk = Щоб забезпечити точну навігацію, увімкніть у налаштуваннях функцію Точне місцезнаходження. + vi = Để đảm bảo điều hướng chính xác, bật vị trí chính xác trong cài đặt. + zh-Hans = 为确保导航准确,请在设置中启用 "精确定位"。 + zh-Hant = 為了確保准確的導航啟用設置中的精確位置。 [zoom_to_country] comment = View and button titles for accessibility