diff --git a/OsmAnd-java/build.gradle b/OsmAnd-java/build.gradle index 0b57c98947..62f3fe06d9 100644 --- a/OsmAnd-java/build.gradle +++ b/OsmAnd-java/build.gradle @@ -61,7 +61,11 @@ task collectExternalResources { } task androidJar(type: Jar) { - dependsOn collectExternalResources, build + if (!project.hasProperty('osmandCoreSimple')) { + dependsOn collectExternalResources, build + } else { + dependsOn build + } appendix = "android" from (sourceSets.main.java.outputDir) { exclude("**/PlatformUtil.*") @@ -70,7 +74,9 @@ task androidJar(type: Jar) { } compileJava { - dependsOn collectExternalResources + if (!project.hasProperty('osmandCoreSimple')) { + dependsOn collectExternalResources + } } artifacts { diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java index da870d898e..5dc434324e 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java @@ -407,7 +407,7 @@ public class BinaryMapTransportReaderAdapter { int tag = WireFormat.getTagFieldNumber(t); switch (tag) { case 0: - return; + break; case OsmandOdb.StringTable.S_FIELD_NUMBER: if (current == values[i]) { String value = codedIS.readString(); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java index c2d5776de4..65637ca190 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutePlannerFrontEnd.java @@ -26,6 +26,7 @@ import org.apache.commons.logging.Log; public class RoutePlannerFrontEnd { protected static final Log log = PlatformUtil.getLog(RoutePlannerFrontEnd.class); + protected static final double GPS_POSSIBLE_ERROR = 10; public boolean useSmartRouteRecalculation = true; @@ -78,13 +79,24 @@ public class RoutePlannerFrontEnd { double currentsDistSquare = squareDist((int) pr.x, (int) pr.y, px, py); if (road == null || currentsDistSquare < road.distSquare) { RouteDataObject ro = new RouteDataObject(r); + road = new RouteSegmentPoint(ro, j, currentsDistSquare); road.preciseX = (int) pr.x; road.preciseY = (int) pr.y; } } if (road != null) { - list.add(road); + if(!transportStop) { + float prio = ctx.getRouter().defineSpeedPriority(road.road); + if (prio > 0) { + road.distSquare = (road.distSquare + GPS_POSSIBLE_ERROR * GPS_POSSIBLE_ERROR) + / (prio * prio); + list.add(road); + } + } else { + list.add(road); + } + } } } @@ -99,7 +111,7 @@ public class RoutePlannerFrontEnd { RouteSegmentPoint ps = null; if (ctx.publicTransport) { for (RouteSegmentPoint p : list) { - if (transportStop && p.distSquare > 100) { + if (transportStop && p.distSquare > GPS_POSSIBLE_ERROR * GPS_POSSIBLE_ERROR) { break; } boolean platform = p.road.platform(); diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index 9d068fc78f..94522fc57c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -222,6 +222,11 @@ public class RouteResultPreparation { } } + // decrease speed proportionally from 15ms (50kmh) + private static final double SLOW_DOWN_SPEED_THRESHOLD = 15; + // reference speed 30ms (108kmh) - 2ms (7kmh) + private static final double SLOW_DOWN_SPEED = 2; + private void calculateTimeSpeed(RoutingContext ctx, List result) throws IOException { //for Naismith boolean usePedestrianHeight = ((((GeneralRouter) ctx.getRouter()).getProfile() == GeneralRouterProfile.PEDESTRIAN) && ((GeneralRouter) ctx.getRouter()).getHeightObstacles()); @@ -234,10 +239,8 @@ public class RouteResultPreparation { if (speed == 0) { speed = ctx.getRouter().getMinDefaultSpeed(); } else { - if(speed > 15) { - // decrease speed proportionally from 15ms=50kmh - - // reference speed 30ms=108kmh - 7kmh - speed = speed - ((speed - 15f) / (30f - 15f) * 2f); + if (speed > SLOW_DOWN_SPEED_THRESHOLD) { + speed = speed - (speed / SLOW_DOWN_SPEED_THRESHOLD - 1) * SLOW_DOWN_SPEED; } } boolean plus = rr.getStartPointIndex() < rr.getEndPointIndex(); diff --git a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java index adae84c2d9..9f299cd5e0 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java @@ -218,7 +218,8 @@ public class SearchUICore { } public boolean sameSearchResult(SearchResult r1, SearchResult r2) { - if (r1.location != null && r2.location != null) { + if (r1.location != null && r2.location != null && + !ObjectType.isTopVisible(r1.objectType) && !ObjectType.isTopVisible(r2.objectType)) { if (r1.objectType == r2.objectType) { if (r1.objectType == ObjectType.STREET) { Street st1 = (Street) r1.object; diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java index f0104c6811..96c2726ce6 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java @@ -516,16 +516,14 @@ public class SearchCoreFactory { if (!phrase.isUnknownSearchWordPresent()) { return false; } - if (phrase.isNoSelectedType() && phrase.isUnknownSearchWordPresent() - && phrase.isUnknownSearchWordComplete() && phrase.hasUnknownSearchWordPoiTypes()) { - return false; - } + boolean hasUnselectedType = phrase.isNoSelectedType() && phrase.isUnknownSearchWordPresent() + && phrase.isUnknownSearchWordComplete() && phrase.hasUnknownSearchWordPoiTypes(); final BinaryMapIndexReader[] currentFile = new BinaryMapIndexReader[1]; Iterator offlineIterator = phrase.getRadiusOfflineIndexes(BBOX_RADIUS, SearchPhraseDataType.POI); - String searchWord = phrase.getUnknownWordToSearch(); - final NameStringMatcher nm = phrase.getNameStringMatcher(searchWord, phrase.isUnknownSearchWordComplete()); String unknownSearchPhrase = phrase.getUnknownSearchPhrase().trim(); + String searchWord = hasUnselectedType ? unknownSearchPhrase : phrase.getUnknownWordToSearch(); + final NameStringMatcher nm = phrase.getNameStringMatcher(searchWord, phrase.isUnknownSearchWordComplete()); final NameStringMatcher phraseMatcher; if (!Algorithms.isEmpty(unknownSearchPhrase)) { phraseMatcher = new NameStringMatcher(unknownSearchPhrase, StringMatcherMode.CHECK_EQUALS); diff --git a/OsmAnd-telegram/build.gradle b/OsmAnd-telegram/build.gradle index aa13df28b0..4b215af1ad 100644 --- a/OsmAnd-telegram/build.gradle +++ b/OsmAnd-telegram/build.gradle @@ -88,6 +88,10 @@ android { disable 'InvalidPackage' disable 'MissingTranslation' } + + packagingOptions { + exclude 'META-INF/proguard/androidx-annotations.pro' + } } task downloadTdLibzip { @@ -149,4 +153,5 @@ dependencies { exclude group: 'com.android.support' } implementation 'org.jetbrains:annotations-java5:15.0' + implementation 'androidx.annotation:annotation:1.1.0' } diff --git a/OsmAnd-telegram/res/values-ar/strings.xml b/OsmAnd-telegram/res/values-ar/strings.xml index 4fd3a49dcd..774c6264fc 100644 --- a/OsmAnd-telegram/res/values-ar/strings.xml +++ b/OsmAnd-telegram/res/values-ar/strings.xml @@ -6,7 +6,6 @@ تعطيل العرض تسجيل الموقع ممكن تمكين العرض لتوفير جميع المواقع في السجل. - المتتبع عبر النت متتبعOsmAnd تيليجرام يستخدم تيليجرام (تطبيق المراسلة) للاتصال والتواصل مع الأشخاص. diff --git a/OsmAnd-telegram/res/values-be/strings.xml b/OsmAnd-telegram/res/values-be/strings.xml index b2ea517155..acb2bbc8a0 100644 --- a/OsmAnd-telegram/res/values-be/strings.xml +++ b/OsmAnd-telegram/res/values-be/strings.xml @@ -199,7 +199,6 @@ Выключыць маніторынг Запіс месцазнаходжання ўключаны Уключыць маніторынг, каб захоўваць пункты месцазнаходжання ў гісторыі. - Сеціўны назіральнік Назіральнік OsmAnd Telegram Telegram (дадатак для ліставання) выкарыстоўваецца для зносін паміж людзьмі. diff --git a/OsmAnd-telegram/res/values-ca/strings.xml b/OsmAnd-telegram/res/values-ca/strings.xml index 8573e5317e..aec720d8ed 100644 --- a/OsmAnd-telegram/res/values-ca/strings.xml +++ b/OsmAnd-telegram/res/values-ca/strings.xml @@ -9,7 +9,7 @@ Telegram (l\'aplicació de missatgeria) s\'utilitza per connectar i comunicar amb la gent. Actualitzeu OsmAnd per veure les dades al mapa S\'ha afegit %1$s. - Desactiveu l\'optimització de bateria per OsmAnd Telegram perquè no s\'aturi sobtadament quan quedi en procés de fons. + Desactiveu l\'optimització de bateria per OsmAnd Tracker perquè no s\'aturi sobtadament quan quedi en procés de fons. Ves a la configuració Seleccioneu la versió d\'OsmAnd on els contactes es situaran al mapa. Seleccioneu la versió d\'OsmAnd a utilitzar @@ -19,11 +19,11 @@ ja fa Darrera resposta Connecteu a Internet per sortir correctament de Telegram. - Per aturar l\'accés a compartir la posició. Obriu Telegram, aneu a Configuració → Seguretat i Privacitat→ Sessions, i tanqueu la sessió d\'OsmAnd Telegram. + Per aturar l\'accés a compartir la posició. Obriu Telegram, aneu a Configuració → Seguretat i Privacitat→ Sessions, i tanqueu la sessió d\'OsmAnd Tracker. Com aturar des de Telegram l\'enregistrador OsmAnd Com aturar des de Telegram l\'enregistrador OsmAnd dins %@ - Seleccioneu la versió d\'OsmAnd que OsmAnd Telegram utilitzarà per mostrar la posició. + Seleccioneu la versió d\'OsmAnd que OsmAnd Tracker utilitzarà per mostrar la posició. Connecta a OsmAnd Amaga els contactes quiets més d\'un temps determinat. Aturat @@ -44,7 +44,6 @@ Cerca: Grup o contacte Telegram us ha enviat un codi perquè OsmAnd pugui entrar en el vostre compte. S\'està tancant - Rastrejador en línia Rastrejador OsmAnd El rastrejador d\'OsmAnd és un dels clients que usen la plataforma oberta de Telegram. Els vostres contactes poden usar qualsevol altra client de Telegram. En fer clic a continuar, accepteu les condicions de la Política de Privadesa de Telegram i de la Política de Privadesa d\'OsmAnd. @@ -113,8 +112,8 @@ Afegeix un aparell Comparteix la ubicació com a Contactes i grups que compateixen la ubicació amb vós. - Esteu segur de voler tancar la sessió a OsmAnd Telegram i deixar de poder compartir la ubicació o veure la ubicació d\'altres usuaris\? - Voleu tancar la sessió de l\'OsmAnd Telegram\? + Esteu segur de voler tancar la sessió a OsmAnd Tracker i deixar de poder compartir la ubicació o veure la ubicació d\'altres usuaris\? + Voleu tancar la sessió de l\'OsmAnd Tracker\? Nom Per distància Per nom @@ -147,7 +146,7 @@ Enrere Comparteix la ubicació Mostra-ho al mapa - OsmAnd Telegram + OsmAnd Online GPS Tracker Número de telèfon Número de telèfon en format internacional Contrasenya @@ -170,7 +169,7 @@ Mode en segon pla Distància Comparteix la ubicació - Servei d\'OsmAnd Telegram + Servei d\'OsmAnd Tracker Logo de l\'OsmAnd Cal que primer instal·leu la versió gratuïta o la de pagament de l\'OsmAnd Instal·la l\'OsmAnd @@ -207,7 +206,7 @@ Cerca per tots els grups i contactes. Escriviu un nom de contacte o de grup Cerca - OsmAnd Telegram s\'executa en procés de fons amb la pantalla tancada. + OsmAnd Tracker s\'executa en procés de fons amb la pantalla tancada. S\'està compartint la ubicació min/m min/km diff --git a/OsmAnd-telegram/res/values-da/strings.xml b/OsmAnd-telegram/res/values-da/strings.xml index 53deaa098f..a2c4883c95 100644 --- a/OsmAnd-telegram/res/values-da/strings.xml +++ b/OsmAnd-telegram/res/values-da/strings.xml @@ -20,7 +20,7 @@ Del placering som Kontakter og grupper som der deles placering med. "Bekræft log af OsmAnd Tracker, der kan ikke deles placering eller se placering af andre\?" - Log ud af OsmAnd Telegram\? + Log ud af OsmAnd Tracker\? Navn Efter afstand Efter navn @@ -38,7 +38,7 @@ Gruppe Opret forbindelse til Internettet for at logge ud af Telegram. Luk - Sådan tilbagekaldes adgang til placeringsdeling. Åbn Telegram, gå til Settings - Privacy and Security - Sessions og afslut OsmAnd Telegram session. + Sådan tilbagekaldes adgang til placeringsdeling. Åbn Telegram, gå til Settings - Privacy and Security - Sessions og afslut OsmAnd Tracker session. Sådan afbrydes OsmAnd Tracker fra Telegram Sådan afbrydes OsmAnd Tracker fra Telegram Tilsluttet konto @@ -83,7 +83,7 @@ Søg: gruppe eller kontakt Del placering Vis på kort - OsmAnd Telegram + OsmAnd Online GPS Tracker Telefonnummer Telefonnummer i internationalt format Adgangskode @@ -199,7 +199,6 @@ Deaktiver overvågning Placeringsregistrering aktiveret Aktiver overvågning for at gemme alle placeringer i historikken. - Online sporing OsmAnd Tracker Telegram Telegram (besked app) bruges til at forbinde og kommunikere med mennesker. diff --git a/OsmAnd-telegram/res/values-de/strings.xml b/OsmAnd-telegram/res/values-de/strings.xml index bc919c5996..abdfd3aa1a 100644 --- a/OsmAnd-telegram/res/values-de/strings.xml +++ b/OsmAnd-telegram/res/values-de/strings.xml @@ -16,7 +16,7 @@ Letzter verfügbarer Standort Standort teilen als Kontakte und Gruppen, die ihren Standort mit Ihnen teilen. - Aus OsmAnd Telegram abmelden\? + Aus OsmAnd Tracker abmelden\? "Name " Nach Entfernung Nach Namen @@ -35,7 +35,7 @@ Verbundenes Konto Konto "in %1$s " - Wählen Sie die OsmAnd-Version, die OsmAnd Telegram verwendet, um Positionen anzuzeigen. + Wählen Sie die OsmAnd-Version, die OsmAnd Tracker verwendet, um Positionen anzuzeigen. OsmAnd verbinden Blendet Kontakte aus, die sich eine bestimmte Zeit lang nicht bewegt haben. Standortverlauf @@ -64,7 +64,7 @@ Zeit einstellen Suche: Gruppe oder Kontakt Auf Karte anzeigen - "OsmAnd Telegram " + OsmAnd Online GPS Tracker Telefonnummer Telefonnummer in internationalem Format Passwort @@ -81,10 +81,10 @@ Der App fehlt die Berechtigung, auf Standortdaten zuzugreifen. Bitte schalten Sie \"Standort\" in den Systemeinstellungen ein Hintergrundmodus - OsmAnd Telegram läuft im Hintergrund bei ausgeschaltetem Bildschirm. + OsmAnd Tracker läuft im Hintergrund bei ausgeschaltetem Bildschirm. Distanz Standort teilen - OsmAnd Telegram-Service + OsmAnd Tracker-Service OsmAnd-Logo Sie müssen zuerst die kostenlose oder kostenpflichtige Version von OsmAnd installieren OsmAnd installieren @@ -131,11 +131,11 @@ kn/h Zuletzt aktualisierter Ort: Es ist nicht möglich, an Telegram-Chats zu senden: - Schalten Sie die Batterieoptimierung für OsmAnd Telegram aus, damit es nicht plötzlich im Hintergrund ausgeschaltet wird. - Sind Sie sicher, dass Sie sich von OsmAnd Telegram abmelden möchten, so dass Sie den Standort nicht teilen oder den Standort anderer sehen können\? + Schalten Sie die Batterieoptimierung für OsmAnd Tracker aus, damit es nicht plötzlich im Hintergrund ausgeschaltet wird. + Sind Sie sicher, dass Sie sich von OsmAnd Tracker abmelden möchten, so dass Sie den Standort nicht teilen oder den Standort anderer sehen können\? Schaltet die Standortfreigabe für alle ausgewählten Chats aus (%1$d). Alle Freigaben deaktivieren - Um den Zugriff auf die Standortfreigabe zu widerrufen, öffnen Sie Telegram, gehen zu Einstellungen → Datenschutz und Sicherheit → Sitzungen und beenden die OsmAnd Telegram-Sitzung. + Um den Zugriff auf die Standortfreigabe zu widerrufen, öffnen Sie Telegram, gehen zu Einstellungen → Datenschutz und Sicherheit → Sitzungen und beenden die OsmAnd Tracker-Sitzung. So deaktivieren Sie OsmAnd Tracker von Telegram aus So deaktivieren Sie OsmAnd Tracker von Telegram aus Keine Bewegung @@ -198,7 +198,6 @@ Telegram (die Messaging-App) wird verwendet, um sich mit Menschen zu verbinden und mit ihnen zu kommunizieren. OK Standortaufzeichnung aktiviert - Online-Tracker OsmAnd-Tracker Akzeptieren Telegram-Datenschutzerklärung diff --git a/OsmAnd-telegram/res/values-es-rUS/strings.xml b/OsmAnd-telegram/res/values-es-rUS/strings.xml index 25bbb46249..5b42a0ac43 100644 --- a/OsmAnd-telegram/res/values-es-rUS/strings.xml +++ b/OsmAnd-telegram/res/values-es-rUS/strings.xml @@ -39,7 +39,7 @@ Grupo Conéctese a Internet para cerrar sesión en Telegram correctamente. Cerrar - Para revocar el acceso a la ubicación compartida. Abra Telegram, vaya a «Ajustes → Privacidad y Seguridad → Sesiones» y cierre sesión de OsmAnd Telegram. + Para revocar el acceso a la ubicación compartida. Abra Telegram, vaya a «Ajustes → Privacidad y Seguridad → Sesiones» y cierre sesión de OsmAnd Tracker. Cómo desactivar el rastreador de OsmAnd desde Telegram Cómo desactivar el rastreador de OsmAnd (en inglés como «OsmAnd Tracker») desde Telegram Cuenta conectada @@ -210,7 +210,6 @@ Desactivar la monitorización Grabación de ubicación activada Activa la monitorización para guardar todas las ubicaciones en el historial. - Rastreador en línea Rastreador de OsmAnd Buscar contactos Busca en todos tus grupos y contactos. diff --git a/OsmAnd-telegram/res/values-es/strings.xml b/OsmAnd-telegram/res/values-es/strings.xml index e3f5a282f7..29649f4c44 100644 --- a/OsmAnd-telegram/res/values-es/strings.xml +++ b/OsmAnd-telegram/res/values-es/strings.xml @@ -38,7 +38,7 @@ Grupo Conéctese a Internet para cerrar sesión en Telegram correctamente. Cerrar - Para revocar el acceso a la ubicación compartida. Abra Telegram, vaya a «Ajustes → Privacidad y Seguridad → Sesiones» y cierre sesión de OsmAnd Telegram. + Para revocar el acceso a la ubicación compartida. Abra Telegram, vaya a «Ajustes → Privacidad y Seguridad → Sesiones» y cierre sesión de OsmAnd Tracker. Cómo desactivar el rastreador de OsmAnd desde Telegram Cómo desactivar el rastreador de OsmAnd (en inglés como «OsmAnd Tracker») desde Telegram Cuenta conectada @@ -198,7 +198,6 @@ Desactivar la monitorización Grabación de ubicación activada Active la monitorización para guardar todas las ubicaciones en el historial. - Rastreador en línea Rastreador de OsmAnd Telegram Telegram (la aplicación de mensajería) se utiliza para conectar y comunicar a las personas. diff --git a/OsmAnd-telegram/res/values-eu/strings.xml b/OsmAnd-telegram/res/values-eu/strings.xml index 68942a11d2..f168b35819 100644 --- a/OsmAnd-telegram/res/values-eu/strings.xml +++ b/OsmAnd-telegram/res/values-eu/strings.xml @@ -11,7 +11,6 @@ Desgaitu kontrola Kokapen grabaketa gaituta Gaitu kontrola zure kokapen guztiak historian gordetzeko. - Online Aztarnaria OsmAnd Aztarnaria Telegram Telegram (mezularitza aplikazioa) jendearekin konektatzeko eta komunikatzeko erabiltzen da. @@ -78,7 +77,7 @@ Atzera Partekatu kokapena Erakutsi mapan - OsmAnd Telegram + OsmAnd Online GPS Tracker Telefono zenbakia Telefono zenbakia formatu internazionalean Pasahitza @@ -101,7 +100,7 @@ Distantzia Partekatu kokapena Partekatzen kokapena - OsmAnd Telegram zebitzua + OsmAnd Tracker zebitzua OsmAnd logoa OsmAnd doako edo ordainpeko bertsioa instalatu behar duzu lehenik Instalatu OsmAnd diff --git a/OsmAnd-telegram/res/values-gl/strings.xml b/OsmAnd-telegram/res/values-gl/strings.xml index 6ba5c12eb7..56fdf4ccdd 100644 --- a/OsmAnd-telegram/res/values-gl/strings.xml +++ b/OsmAnd-telegram/res/values-gl/strings.xml @@ -19,8 +19,8 @@ Engadir dispositivo Compartillar ubicación coma Contactos e grupos que están a compartilla-la túa ubicación para ti. - Estás na certeza de que desexas desconectarte do OsmAnd Telegram para non poder compartilla-la ubicación ou olla-la ubicación doutros\? - Pecha-la sesión do OsmAnd Telegram\? + Estás na certeza de que desexas desconectarte do OsmAnd Tracker para non poder compartilla-la ubicación ou olla-la ubicación doutros\? + Pecha-la sesión do OsmAnd Tracker\? Nome Pola distancia Polo nome @@ -91,7 +91,7 @@ Estase a conectar á Internet Desactiva-la optimización da batería para o OsmAnd Tracker de xeito que non se desconecte de xeito súbito cando esté no segundo plano. Conéctate á Internet para pecha-la sesión no Telegram de xeito correcto. - Para revoga-lo acceso á ubicación compartillada. Abre o Telegram, vai cara ós «Axustes → Privacidade e Seguranza → Sesións» e pecha a sesión do OsmAnd Telegram. + Para revoga-lo acceso á ubicación compartillada. Abre o Telegram, vai cara ós «Axustes → Privacidade e Seguranza → Sesións» e pecha a sesión do OsmAnd Tracker. De que xeito desactivar o rastrexador do OsmAnd (OsmAnd Tracker) dende o Telegram De que xeito desactivar o rastrexador do OsmAnd (OsmAnd Tracker) dende o Telegram Escolle a versión do OsmAnd na cal o rastrexador do OsmAnd (OsmAnd Tracker) empregará para amosa-las ubicacións. @@ -117,7 +117,7 @@ Procurar: Grupo ou contacto Compartillar ubicación Amosar no mapa - OsmAnd Telegram + OsmAnd Online GPS Tracker Número do teléfono móbil Número do teléfono móbil no formato internacional Contrasinal @@ -139,11 +139,11 @@ Activar «Ubicación» nos axustes do sistema Escolle un dos fornecedores da ubicación para compartilla-la túa ubicación. Modo no segundo plano - O OsmAnd Telegram execútase no modo en segundo plano ca pantalla apagada. + O OsmAnd Tracker execútase no modo en segundo plano ca pantalla apagada. Distancia Compartillar ubicación Estase a compartilla-la ubicación - Servizo do OsmAnd Telegram + Servizo do OsmAnd Tracker Logotipo do OsmAnd Precísase instalar primeiro a versión de balde ou de pagamento do OsmAnd Instala-lo OsmAnd @@ -190,7 +190,6 @@ Desactivar o monitoramento Gravación da ubicación activada Activa o monitoramento para gardar tódalas ubicacións no historial. - Rastrexador en liña Rastrexador do OsmAnd Telegram O Telegram (a aplicación de mensaxaría) emprégase para conectar e comunicar ás persoas. diff --git a/OsmAnd-telegram/res/values-he/strings.xml b/OsmAnd-telegram/res/values-he/strings.xml index 113303b6a5..26fc8867e0 100644 --- a/OsmAnd-telegram/res/values-he/strings.xml +++ b/OsmAnd-telegram/res/values-he/strings.xml @@ -210,7 +210,6 @@ ציר הזמן היא תכונה שמעתה זמינה בחינם. השבתת מעקב הופעלה הקלטת מיקום - עוקב בזמן אמת עוקב OsmAnd חיפוש באנשי קשר חיפוש בין כל הקבוצות ואנשי הקשר שלך. diff --git a/OsmAnd-telegram/res/values-hu/strings.xml b/OsmAnd-telegram/res/values-hu/strings.xml index 841c75fe89..84725892ea 100644 --- a/OsmAnd-telegram/res/values-hu/strings.xml +++ b/OsmAnd-telegram/res/values-hu/strings.xml @@ -49,7 +49,6 @@ Figyelemmel kísérés letiltása Tartózkodási hely rögzítésének engedélyezve A figyelemmel kísérés engedélyezése az előzményekben található összes tartózkodási hely mentéséhez. - Online Tracker OsmAnd Tracker Ha egy Telegram-fiókhoz több eszközt szeretne csatlakoztatni, akkor tartózkodási helyének megosztásához egy másik eszközt kell használnia. Utoljára frissített tartózkodási hely: @@ -71,8 +70,8 @@ Eszköz hozzáadása Tartózkodási hely megosztása mint Tartózkodási helyüket Önnel megosztó partnerek és csoportok. - Biztosan kilép az OsmAnd Telegramból\? Így nem tudja megosztani másokkal tartózkodási helyét, és mások sem látják az Önét. - Kilép az OsmAnd Telegramból\? + Biztosan kilép az OsmAnd Trackerból\? Így nem tudja megosztani másokkal tartózkodási helyét, és mások sem látják az Önét. + Kilép az OsmAnd Trackerból\? Név Távolság szerint Név szerint @@ -122,7 +121,7 @@ Keresés: csoport vagy partner Tartózkodási hely megosztása Megjelenítés a térképen - OsmAnd Telegram + OsmAnd Online GPS Tracker Telefonszám Telefonszám nemzetközi formában Jelszó @@ -143,7 +142,7 @@ Távolság Tartózkodási hely megosztása Tartózkodási hely megosztása folyamatban - OsmAnd Telegram szolgáltatás + OsmAnd Tracker szolgáltatás OsmAnd logó Isten hozta yard @@ -180,7 +179,7 @@ Indítás Pozíció meghatározása… Kapcsolódás az internethez - Az OsmAnd Telegram esetében kapcsolja ki az akkumulátor optimalizálását, nehogy hirtelen kikapcsoljon, miközben a háttérben fut. + Az OsmAnd Tracker esetében kapcsolja ki az akkumulátor optimalizálását, nehogy hirtelen kikapcsoljon, miközben a háttérben fut. Megosztás a háttérben Beállítások megnyitása Később @@ -196,7 +195,7 @@ Keresés az összes csoportban és kapcsolatban. Gépelje be a kapcsolat vagy a csoport nevét Keresés - Válassza ki, melyik OsmAnd verziót használja a az OsmAnd Telegram a pozíciók megjelenítéséhez. + Válassza ki, melyik OsmAnd verziót használja a az OsmAnd Tracker a pozíciók megjelenítéséhez. Kapcsolódás az OsmAndhoz Regisztrált Telegram fiók és telefonszám szükséges Nincs Telegram fiókom @@ -209,7 +208,7 @@ A rendszerbeállításoknál kapcsolja be a „Tartózkodási helyet” Tartózkodási helyének megosztásához jelölje ki az egyik tartózkodásihely-szolgáltatót. Háttérmód - Az OsmAnd Telegram a háttérben fut, kikapcsolt képernyővel. + Az OsmAnd Tracker a háttérben fut, kikapcsolt képernyővel. Először telepítenie kell az OsmAnd ingyenes vagy fizetős verzióját OsmAnd telepítése Felhasználók megjelenítése a térképen diff --git a/OsmAnd-telegram/res/values-it/strings.xml b/OsmAnd-telegram/res/values-it/strings.xml index 0c0b385f0d..f1c2cf8293 100644 --- a/OsmAnd-telegram/res/values-it/strings.xml +++ b/OsmAnd-telegram/res/values-it/strings.xml @@ -58,7 +58,7 @@ Gruppo Connettiti a Internet per uscire correttamente dall\'account di Telegram. Chiudi - Per revocare l\'accesso alla condivisione della posizione, apri Telegram, vai a Impostazioni → Privacy e Sicurezza → Sessioni, e termina la sessione di OsmAnd Telegram. + Per revocare l\'accesso alla condivisione della posizione, apri Telegram, vai a Impostazioni → Privacy e Sicurezza → Sessioni, e termina la sessione di OsmAnd Tracker. Come disattivare il OsmAnd Tracker da Telegram Come disattivare OsmAnd Tracker da Telegram Account connesso @@ -191,7 +191,6 @@ Disattivare il monitoraggio Registrazione della posizione abilitata Attivare il monitoraggio per salvare lo storico delle locazioni. - Tracker online Tracker OsmAnd Telegram Telegram (l\'applicazione di messaggistica) viene usato per connettersi e comunicare con le persone. diff --git a/OsmAnd-telegram/res/values-nb/strings.xml b/OsmAnd-telegram/res/values-nb/strings.xml index 80c7dd64b1..a8c12bd2cb 100644 --- a/OsmAnd-telegram/res/values-nb/strings.xml +++ b/OsmAnd-telegram/res/values-nb/strings.xml @@ -2,7 +2,7 @@ Endre batterioptimiseringsinnstillinger for mer stabil posisjonsdeling. Bakgrunnsarbeid - Skru av batterioptimisering for OsmAnd Telegram slik at det ikke plutselig skrur seg av når det er i bakgrunnen. + Skru av batterioptimisering for OsmAnd Tracker slik at det ikke plutselig skrur seg av når det er i bakgrunnen. Deling i bakgrunnen Gå til innstillinger Senere @@ -19,8 +19,8 @@ Legg til enhet Del posisjon som Kontakter og grupper som deler sin posisjon med deg. - Er du sikker på at du vil logge ut av OsmAnd Telegram slik at du ikke kan sende din posisjon, eller se andres\? - Logg ut av OsmAnd Telegram\? + Er du sikker på at du vil logge ut av OsmAnd Tracker slik at du ikke kan sende din posisjon, eller se andres\? + Logg ut av OsmAnd Tracker\? Navn Etter distanse Etter navn @@ -38,13 +38,13 @@ Gruppe Koble til Internett for å logge ut av Telegram ordentlig. Lukk - For å tilbakekalle posisjonsdelingstilgang. Åpne Telegram, gå til Innstillinger - Personvern og sikkerhet - Økter, og sluttfør OsmAnd Telegram-økta. + For å tilbakekalle posisjonsdelingstilgang. Åpne Telegram, gå til Innstillinger - Personvern og sikkerhet - Økter, og sluttfør OsmAnd Tracker-økta. Hvordan koble fra OsmAnd-sporeren fra Telegram Hvordan koble fra OsmAnd-sporeren fra Telegram Tilkoblet konto Konto i %1$s - Velg OsmAnd-versjonen OsmAnd Telegram bruker for å vise posisjoner på kartet. + Velg OsmAnd-versjonen OsmAnd Tracker bruker for å vise posisjoner på kartet. OsmAnd connect Skjul kontaktene som ikke har oppdatert sin plassering etter et gitt tidsintervall. Posisjonshistorikk @@ -83,7 +83,7 @@ Søk: Gruppe eller kontakt Del posisjon Vis på kartet - OsmAnd Telegram + OsmAnd Online GPS Tracker Telefonnummer Telefonnummer i internasjonalt format Passord @@ -102,11 +102,11 @@ Skru på «Posisjon» i systeminnstillingene Velg en av posisjonstilbyderne for å dele din posisjon. Bakgrunnsmodus - OsmAnd Telegram kjører som nisse med skjermen av. + OsmAnd Tracker kjører som nisse med skjermen av. Distanse Del posisjon Deler posisjon - OsmAnd Telegram-tjeneste + OsmAnd Tracker-tjeneste OsmAnd-logo Du må installere gratis- eller betalt versjon av OsmAnd først Installer OsmAnd @@ -207,7 +207,6 @@ Tidslinjefunksjonen er nå gratis. Skru av overvåkning Plasseringsregistrering påskrudd - Nettbasert sporer OsmAnd-sporer Telegram (meldingsprogrammet) brukes til å komme i kontakt og snakke med folk. OsmAnd-personvernspraksis diff --git a/OsmAnd-telegram/res/values-nl/strings.xml b/OsmAnd-telegram/res/values-nl/strings.xml index 6a01a61f01..aa316ff263 100644 --- a/OsmAnd-telegram/res/values-nl/strings.xml +++ b/OsmAnd-telegram/res/values-nl/strings.xml @@ -5,7 +5,6 @@ Schakel monitoring uit Locatie opname ingeschakeld Schakel monitoring in om alle locaties in de geschiedenis op te slaan. - Online Tracker OsmAnd Tracker Telegram Telegram (de berichten-app) wordt gebruikt om mensen te verbinden en te communiceren met mensen. @@ -59,7 +58,7 @@ Positie bepalen… Verbinden met Internet Wijzig batterij optimalisatie om het delen van uw locatie te verbeteren. - Schakel batterij optimalisatie uit voor OsmAnd Telegram zodat het niet uitgeschakeld wordt in de achtergrond. + Schakel batterij optimalisatie uit voor OsmAnd Tracker zodat het niet uitgeschakeld wordt in de achtergrond. Delen in de achtergrond Open Instellingen Later @@ -77,8 +76,8 @@ Voeg apparaat toe Deel locatie als Contacten en groepen die hun locatie delen met jou. - Weet u zeker dat u uit wilt loggen uit Osmand Telegram en daarmee uw locatie niet meer deelt en de locatie van anderen niet meer kunt zien\? - Uitloggen uit OsmAnd Telegram\? + Weet u zeker dat u uit wilt loggen uit OsmAnd Tracker en daarmee uw locatie niet meer deelt en de locatie van anderen niet meer kunt zien\? + Uitloggen uit OsmAnd Tracker\? Naam Op afstand Op naam @@ -95,13 +94,13 @@ Groep Verbind met Internet om correct uit te loggen uit Telegram. Sluit - Om locatie delen toegang uit te schakelen: Open Telegram, gaan naar Instellingen -> Privacy en veiligheid -> Active sessies, en beeindig the OsmAnd Telegram sessie. + Om locatie delen toegang uit te schakelen: Open Telegram, gaan naar Instellingen -> Privacy en veiligheid -> Active sessies, en beeindig the OsmAnd Tracker sessie. Hoe zet je de OsmAnd Tracker uit in Telegram Hoe zet je de OsmAnd Tracker uit in Telegram Verbonden account Account in %1$s - Kies de OsmAnd versie die door OsmAnd Telegram gebruikt wordt om posities te tonen. + Kies de OsmAnd versie die door OsmAnd Tracker gebruikt wordt om posities te tonen. Verberg contacten die zich een bepaalde tijd niet verplaatsten. Locatie geschiedenis De laatste keer dat een contact zich verplaatste. @@ -132,7 +131,7 @@ Zoek: Groep of contact Deel locatie Toon op de kaart - OsmAnd Telegram + OsmAnd Online GPS Tracker Telefoonnummer Telefoonnummer in internationaal formaat Wachtwoord @@ -173,7 +172,7 @@ Afstand Deel locatie Locatie wordt gedeeld - OsmAnd Telegram service + OsmAnd Tracker service OsmAnd logo U dient eerst de gratis of betaalde versie van OsmAnd te installeren Installeer OsmAnd diff --git a/OsmAnd-telegram/res/values-pl/strings.xml b/OsmAnd-telegram/res/values-pl/strings.xml index ac76ae2ca1..8216fda37e 100644 --- a/OsmAnd-telegram/res/values-pl/strings.xml +++ b/OsmAnd-telegram/res/values-pl/strings.xml @@ -167,7 +167,7 @@ Wystartuj Pozycjonowanie… Łączenie z internetem - Aby anulować dostęp do udostępniania lokalizacji. Otwórz Telegram, przejdź do Ustawienia → Prywatność i bezpieczeństwo → Sesje i zakończ sesję OsmAnd Telegram. + Aby anulować dostęp do udostępniania lokalizacji. Otwórz Telegram, przejdź do Ustawienia → Prywatność i bezpieczeństwo → Sesje i zakończ sesję OsmAnd Tracker. Nie porusza się Ostatnia aktualizacja z Telegram Udostępnianie jest włączone (wyłącz) @@ -200,7 +200,6 @@ Wyłącz monitorowanie Zapis położenia włączony Włącz monitorowanie, by zapisać wszystkie lokalizacje w historii. - Nadajnik online Nadajnik OsmAnd Telegram Telegram (aplikacji do wysyłania wiadomości) jest używana do łączenia i komunikowania się z ludźmi. diff --git a/OsmAnd-telegram/res/values-pt-rBR/strings.xml b/OsmAnd-telegram/res/values-pt-rBR/strings.xml index a9e4e34f68..eeadad2fb2 100644 --- a/OsmAnd-telegram/res/values-pt-rBR/strings.xml +++ b/OsmAnd-telegram/res/values-pt-rBR/strings.xml @@ -64,7 +64,7 @@ Grupo Conecte-se à Internet para efetuar a saída do Telegram corretamente. Fechar - Para revogar o acesso ao compartilhamento de local. Abra o Telegram, vá para Configurações → Privacidade e Segurança → Sessões e termine a sessão do OsmAnd Telegram. + Para revogar o acesso ao compartilhamento de local. Abra o Telegram, vá para Configurações → Privacidade e Segurança → Sessões e termine a sessão do OsmAnd Tracker. Como desativar o OsmAnd Tracker para Telegram Como desativar o OsmAnd Tracker para Telegram Conta conectada @@ -211,7 +211,6 @@ Desativar monitoramento Gravação de localização ativada Ative o monitoramento para salvar todos os locais no histórico. - Rastreador online Rastreador OsmAnd Pesquisar contatos Pesquise em todos os seus grupos e contatos. diff --git a/OsmAnd-telegram/res/values-ru/strings.xml b/OsmAnd-telegram/res/values-ru/strings.xml index b964f33197..9d7d9ad89a 100644 --- a/OsmAnd-telegram/res/values-ru/strings.xml +++ b/OsmAnd-telegram/res/values-ru/strings.xml @@ -151,7 +151,6 @@ Показать точки GPS ОК Отключить мониторинг - Online Tracker OsmAnd Tracker Telegram Принять @@ -183,11 +182,11 @@ Карта и текст Совместное использование включено (выключено) Поиск: группа или контакт - OsmAnd Telegram + OsmAnd Online GPS Tracker Выход Закрытие Включить \"Местоположение\"\? - Служба OsmAnd Telegram + Служба OsmAnd Tracker Логотип OsmAnd ярд фут diff --git a/OsmAnd-telegram/res/values-sc/strings.xml b/OsmAnd-telegram/res/values-sc/strings.xml index cbe2ef47a2..d5ba1363bd 100644 --- a/OsmAnd-telegram/res/values-sc/strings.xml +++ b/OsmAnd-telegram/res/values-sc/strings.xml @@ -88,7 +88,7 @@ Ùrtima risposta Grupu Collega·ti a ìnternet pro essire in manera curreta dae Telegram. - Pro bogare s\'atzessu a sa cumpartzidura de sa positzione. Aberi Telegram, bae a Cunfiguratziones → Riservadesa e Seguresa → Sessiones ativas, e acaba sa sessione de OsmAnd Telegram. + Pro bogare s\'atzessu a sa cumpartzidura de sa positzione. Aberi Telegram, bae a Cunfiguratziones → Riservadesa e Seguresa → Sessiones ativas, e acaba sa sessione de OsmAnd Tracker. Comente istudare s\'arrastadore de OsmAnd dae Telegram Comente istudare s\'arrastadore de OsmAnd dae Telegram Contu connessu @@ -210,7 +210,6 @@ Disabìlita su monitoràgiu Registratzione de sa positzione abilitada Abìlita su monitoràgiu pro sarvare totu sas positziones in sa cronologia. - Arrastadore in lìnia Arrastadore de OsmAnd Chirca cuntatos Chirca intre totu sos grupos e sos cuntatos tuos. diff --git a/OsmAnd-telegram/res/values-uk/strings.xml b/OsmAnd-telegram/res/values-uk/strings.xml index a92af38efc..e0fb179596 100644 --- a/OsmAnd-telegram/res/values-uk/strings.xml +++ b/OsmAnd-telegram/res/values-uk/strings.xml @@ -58,7 +58,7 @@ Група Зʼєднайтеся із інтернетом, аби коректно вийти з Telegram. Закрити - Скасування дозволу до трансляції позиції. Відкрийте Telegram, перейдіть до пункту Налаштування → Конфіденційність та безпека → Активні сесії, та завершіть сеанс OsmAnd Telegram. + Скасування дозволу до трансляції позиції. Відкрийте Telegram, перейдіть до пункту Налаштування → Конфіденційність та безпека → Активні сесії, та завершіть сеанс OsmAnd Tracker. Як вимкнути відслідковування OsmAnd з Telegram Як відключити OsmAnd трекер від Telegram Повʼязаний обліковий запис @@ -185,7 +185,7 @@ Карта Текст Карта та текст - Сервіс OsmAnd Telegram + Сервіс OsmAnd Tracker OsmAnd логотип Активно зараз Запис позиціювання увімкнуто diff --git a/OsmAnd-telegram/res/values-zh-rTW/strings.xml b/OsmAnd-telegram/res/values-zh-rTW/strings.xml index a02096a7df..ecd7fbc7ff 100644 --- a/OsmAnd-telegram/res/values-zh-rTW/strings.xml +++ b/OsmAnd-telegram/res/values-zh-rTW/strings.xml @@ -212,7 +212,6 @@ 停用監視 位置記錄已啟用 啟用監視以儲存所有歷史中的位置。 - 線上追蹤器 OsmAnd 追蹤器 搜尋聯絡人 搜尋您所有的群組與聯絡人。 diff --git a/OsmAnd-telegram/res/values/strings.xml b/OsmAnd-telegram/res/values/strings.xml index 290f78ae03..be7c8b5454 100644 --- a/OsmAnd-telegram/res/values/strings.xml +++ b/OsmAnd-telegram/res/values/strings.xml @@ -35,7 +35,6 @@ Disable monitoring Location recording enabled Enable monitoring to save all locations in history. - Online Tracker OsmAnd Tracker Telegram Telegram (the messaging app) is used to connect and communicate with people. @@ -92,7 +91,7 @@ Connecting to the Internet Change battery optimization settings to stabilize location sharing. Background work - Turn off battery optimization for OsmAnd Telegram so that it isn\'t suddenly turned off when in the background. + Turn off battery optimization for OsmAnd Tracker so that it isn\'t suddenly turned off when in the background. Sharing in the background Go to settings Later @@ -110,8 +109,8 @@ Add device Share location as Contacts and groups sharing location to you. - Are you sure you want to log out of OsmAnd Telegram so you can\'t share location or see the location of others? - Log out of OsmAnd Telegram? + Are you sure you want to log out of OsmAnd Tracker so you can\'t share location or see the location of others? + Log out of OsmAnd Tracker? Name By distance By name @@ -129,13 +128,13 @@ Group Connect to the Internet to properly log out of Telegram. Close - To revoke location sharing access. Open Telegram, go to Settings → Privacy and Security → Sessions, and terminate the OsmAnd Telegram session. + To revoke location sharing access. Open Telegram, go to Settings → Privacy and Security → Sessions, and terminate the OsmAnd Tracker session. How to turn off OsmAnd Tracker from Telegram How to turn off OsmAnd Tracker from Telegram Connected account Account in %1$s - Choose the OsmAnd version OsmAnd Telegram uses to display positions. + Choose the OsmAnd version OsmAnd Tracker uses to display positions. OsmAnd connect Hide contacts that have not moved in a given time. Location history @@ -176,7 +175,7 @@ Search: Group or contact Share location Show on map - OsmAnd Telegram + OsmAnd Online GPS Tracker Phone number Phone number in international format Password @@ -199,11 +198,11 @@ Please turn on \"Location\" in the system settings Select one of the location providers to share your location. Background mode - OsmAnd Telegram runs in the background with the screen off. + OsmAnd Tracker runs in the background with the screen off. Distance Share location Sharing location - OsmAnd Telegram service + OsmAnd Tracker service OsmAnd logo You need to install the free or paid version of OsmAnd first Install OsmAnd diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt index eaa389b2ad..ef0b2ec87d 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt @@ -47,7 +47,7 @@ class TelegramApplication : Application(), OsmandHelperListener { if (connected) { osmandAidlHelper.setNavDrawerItems( applicationContext.packageName, - listOf(getString(R.string.app_name_short_online)), + listOf(getString(R.string.app_name_short)), listOf("osmand_telegram://main_activity"), listOf("ic_action_location_sharing_app"), listOf(-1) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt index df17329c60..b45a185757 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt @@ -230,6 +230,7 @@ class ShareLocationHelper(private val app: TelegramApplication) { if (shareInfo.pendingTdLibText >= MAX_MESSAGES_IN_TDLIB_PER_CHAT || shareInfo.pendingTdLibMap >= MAX_MESSAGES_IN_TDLIB_PER_CHAT) { bufferedMessagesFull = true } + checkAndSendBufferMessagesToChat(shareInfo.chatId) when (app.settings.shareTypeValue) { SHARE_TYPE_MAP -> { val message = BufferMessage(shareInfo.chatId, latitude, longitude, altitude, speed, accuracy, bearing, time, LocationMessages.TYPE_MAP, deviceName) @@ -246,7 +247,6 @@ class ShareLocationHelper(private val app: TelegramApplication) { prepareTextMessage(shareInfo, messageText, isBot) } } - checkAndSendBufferMessagesToChat(shareInfo.chatId) } if (bufferedMessagesFull) { checkNetworkType() diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt index e4d7d5a7a2..d7bb3054b7 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt @@ -19,6 +19,7 @@ import net.osmand.telegram.utils.OsmandLocationUtils.MessageUserLocation import org.drinkless.td.libcore.telegram.TdApi import java.io.File import java.util.* +import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.Executors class ShowLocationHelper(private val app: TelegramApplication) { @@ -37,8 +38,8 @@ class ShowLocationHelper(private val app: TelegramApplication) { private val osmandAidlHelper = app.osmandAidlHelper private val executor = Executors.newSingleThreadExecutor() - private val points = mutableMapOf() - private val markers = mutableMapOf() + private val points = ConcurrentHashMap() + private val markers = ConcurrentHashMap() var showingLocation: Boolean = false private set @@ -49,7 +50,7 @@ class ShowLocationHelper(private val app: TelegramApplication) { app.osmandAidlHelper.setContextMenuButtonsListener(object : ContextMenuButtonsListener { override fun onContextMenuButtonClicked(buttonId: Int, pointId: String, layerId: String) { - updateDirectionMarker(pointId) + updateDirectionMarker(pointId, true) } }) @@ -61,7 +62,7 @@ class ShowLocationHelper(private val app: TelegramApplication) { } } - private fun updateDirectionMarker(pointId: String) { + private fun updateDirectionMarker(pointId: String, forceAdd: Boolean = false) { val message = points[pointId] if (message != null) { val aLatLon = getALatLonFromMessage(message.content) @@ -73,8 +74,12 @@ class ShowLocationHelper(private val app: TelegramApplication) { if (markerPrev != null) { markerUpdated = app.osmandAidlHelper.updateMapMarker(markerPrev, marker) if (!markerUpdated) { - app.osmandAidlHelper.removeMapMarker(markerPrev.latLon.latitude, markerPrev.latLon.longitude, name) - markerUpdated = app.osmandAidlHelper.addMapMarker(marker) + if (forceAdd) { + app.osmandAidlHelper.removeMapMarker(markerPrev.latLon.latitude, markerPrev.latLon.longitude, name) + markerUpdated = app.osmandAidlHelper.addMapMarker(marker) + } else { + markers.remove(pointId) + } } } else { markerUpdated = app.osmandAidlHelper.addMapMarker(marker) @@ -92,17 +97,14 @@ class ShowLocationHelper(private val app: TelegramApplication) { } setupMapLayer() osmandAidlHelper.execOsmandApi { - osmandAidlHelper.showMapPoint( - MAP_LAYER_ID, - item.getMapPointId(), - item.getVisibleName(), - item.getVisibleName(), - item.chatTitle, - Color.WHITE, - ALatLon(item.latLon!!.latitude, item.latLon!!.longitude), - generatePointDetails(item.bearing?.toFloat(), item.altitude?.toFloat(), item.precision?.toFloat()), - generatePointParams(if (stale) item.grayscalePhotoPath else item.photoPath, stale, item.speed?.toFloat(), item.bearing?.toFloat()) - ) + val pointId = item.getMapPointId() + val name = item.getVisibleName() + val aLatLon = ALatLon(item.latLon!!.latitude, item.latLon!!.longitude) + val details = generatePointDetails(item.bearing?.toFloat(), item.altitude?.toFloat(), item.precision?.toFloat()) + val params = generatePointParams(if (stale) item.grayscalePhotoPath else item.photoPath, stale, item.speed?.toFloat(), item.bearing?.toFloat()) + + osmandAidlHelper.addMapPoint(MAP_LAYER_ID, pointId, name, name, item.chatTitle, Color.WHITE, aLatLon, details, params) + osmandAidlHelper.showMapPoint(MAP_LAYER_ID, pointId, name, name, item.chatTitle, Color.WHITE, aLatLon, details, params) } } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt index 63659c5c56..59e222e375 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramHelper.kt @@ -413,7 +413,7 @@ class TelegramHelper private constructor() { } TdApi.File.CONSTRUCTOR -> { val file = obj as TdApi.File - client!!.send(TdApi.DownloadFile(file.id, 10), defaultHandler) + client!!.send(TdApi.DownloadFile(file.id, 10, 0, 0, true), defaultHandler) } else -> listener?.onTelegramError(-1, "Receive wrong response from TDLib: $obj") } @@ -524,7 +524,7 @@ class TelegramHelper private constructor() { } resultArticles.forEach { client?.send(TdApi.SendInlineQueryResultMessage(shareInfo.chatId, 0, true, - true, inlineQueryResults.inlineQueryId, it.id)) { obj -> + true, inlineQueryResults.inlineQueryId, it.id, false)) { obj -> handleTextLocationMessageUpdate(obj, shareInfo) } } @@ -1342,7 +1342,7 @@ class TelegramHelper private constructor() { } TdApi.File.CONSTRUCTOR -> { val file = obj as TdApi.File - client!!.send(TdApi.DownloadFile(file.id, 10), defaultHandler) + client!!.send(TdApi.DownloadFile(file.id, 10, 0, 0, true), defaultHandler) } else -> listener?.onTelegramError(-1, "Receive wrong response from TDLib: $obj") } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt b/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt index 99a48f8bc5..dd346e7896 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/utils/OsmandLocationUtils.kt @@ -94,8 +94,13 @@ object OsmandLocationUtils { fun getSenderMessageId(message: TdApi.Message): Int { val forwardInfo = message.forwardInfo - return if (forwardInfo != null && forwardInfo is TdApi.MessageForwardedFromUser) { - forwardInfo.senderUserId + return if (forwardInfo != null) { + val origin: TdApi.MessageForwardOrigin? = forwardInfo.origin + if (origin != null && origin is TdApi.MessageForwardOriginUser) { + origin.senderUserId + } else { + message.senderUserId + } } else { message.senderUserId } diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 02776da9a6..0ff1017482 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -901,5 +901,8 @@ android:name=".profiles.EditProfileActivity" android:label="Application profiles"/> - + + + diff --git a/OsmAnd/res/drawable-hdpi/img_get_feedback.webp b/OsmAnd/res/drawable-hdpi/img_get_feedback.webp new file mode 100644 index 0000000000..54275e2b39 Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/img_get_feedback.webp differ diff --git a/OsmAnd/res/drawable-mdpi/img_get_feedback.webp b/OsmAnd/res/drawable-mdpi/img_get_feedback.webp new file mode 100644 index 0000000000..c7f9d51f9f Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/img_get_feedback.webp differ diff --git a/OsmAnd/res/drawable-xhdpi/img_get_feedback.webp b/OsmAnd/res/drawable-xhdpi/img_get_feedback.webp new file mode 100644 index 0000000000..7619d802b5 Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/img_get_feedback.webp differ diff --git a/OsmAnd/res/drawable-xxhdpi/img_get_feedback.webp b/OsmAnd/res/drawable-xxhdpi/img_get_feedback.webp new file mode 100644 index 0000000000..07c1552604 Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/img_get_feedback.webp differ diff --git a/OsmAnd/res/drawable-xxxhdpi/img_get_feedback.webp b/OsmAnd/res/drawable-xxxhdpi/img_get_feedback.webp new file mode 100644 index 0000000000..73dfce7b57 Binary files /dev/null and b/OsmAnd/res/drawable-xxxhdpi/img_get_feedback.webp differ diff --git a/OsmAnd/res/drawable/ripple_solid_dark.xml b/OsmAnd/res/drawable/ripple_solid_dark.xml index 45178468da..9e9e6a0cce 100644 --- a/OsmAnd/res/drawable/ripple_solid_dark.xml +++ b/OsmAnd/res/drawable/ripple_solid_dark.xml @@ -1,5 +1,5 @@ + android:color="@color/active_buttons_and_links_pressed_dark"> diff --git a/OsmAnd/res/drawable/ripple_solid_light.xml b/OsmAnd/res/drawable/ripple_solid_light.xml index 69270d496e..b390b7cce7 100644 --- a/OsmAnd/res/drawable/ripple_solid_light.xml +++ b/OsmAnd/res/drawable/ripple_solid_light.xml @@ -1,5 +1,5 @@ + android:color="@color/active_buttons_and_links_pressed_light"> diff --git a/OsmAnd/res/layout/bottom_sheet_item_description_long.xml b/OsmAnd/res/layout/bottom_sheet_item_description_long.xml index 72c2da3171..d841ca0430 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_description_long.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_description_long.xml @@ -11,4 +11,5 @@ android:paddingRight="@dimen/content_padding" android:textColor="?android:textColorSecondary" android:textSize="@dimen/default_desc_text_size" + android:linksClickable="true" tools:text="Some long description"/> diff --git a/OsmAnd/res/layout/crash_title.xml b/OsmAnd/res/layout/crash_title.xml new file mode 100644 index 0000000000..7dea5a337d --- /dev/null +++ b/OsmAnd/res/layout/crash_title.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/dislike_title.xml b/OsmAnd/res/layout/dislike_title.xml new file mode 100644 index 0000000000..a5fb49608b --- /dev/null +++ b/OsmAnd/res/layout/dislike_title.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/make_better_title.xml b/OsmAnd/res/layout/make_better_title.xml new file mode 100644 index 0000000000..bd3d57e129 --- /dev/null +++ b/OsmAnd/res/layout/make_better_title.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/privacy_settings_layout.xml b/OsmAnd/res/layout/privacy_settings_layout.xml new file mode 100644 index 0000000000..a6587a6919 --- /dev/null +++ b/OsmAnd/res/layout/privacy_settings_layout.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/rate_us_title.xml b/OsmAnd/res/layout/rate_us_title.xml new file mode 100644 index 0000000000..9090a10b45 --- /dev/null +++ b/OsmAnd/res/layout/rate_us_title.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index e0d24ee9d8..cc70bf2be5 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -491,7 +491,6 @@ #dcdcdc #EFEFEF #ababab - #505050 #727272 #727272 diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 1451e2a4d7..42aeeb46f2 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,23 @@ --> + Please give us 30 seconds, share feedback and rate our work on Google Play. + Rate + Privacy Policy + Help us make OsmAnd better! + Allow OsmAnd to collect and process anonymous application usage data. We do not collect or store data about your location, or about the locations that you view on the map.\n\nYou can always change your selection in Settings > Privacy and Security. + Choose what type of data you want to share: + Downloaded Maps + Visited screens + Colleted Data + List of data you want to share with OsmAnd. + We collect this data to understand the maps of which regions and countries are the most popular. + We collect this data to understand the most popular features of OsmAnd. + By clicking \"Allow\" you agree with our %1$s + Privacy and Security + Choose your data for sharing with us + No, thank you + Allow Profile Name Navigation Type Taxi diff --git a/OsmAnd/res/xml/settings_pref.xml b/OsmAnd/res/xml/settings_pref.xml index 8f9e0c2fcc..22e47e3773 100644 --- a/OsmAnd/res/xml/settings_pref.xml +++ b/OsmAnd/res/xml/settings_pref.xml @@ -4,5 +4,6 @@ + diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index 4f9fe0e953..d27b1da4e4 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -71,6 +71,8 @@ import net.osmand.aidl.navigation.NavigateSearchParams; import net.osmand.aidl.customization.SetWidgetsParams; import net.osmand.aidl.customization.OsmandSettingsParams; +import net.osmand.aidl.customization.OsmandSettingsInfoParams; +import net.osmand.aidl.customization.CustomizationInfoParams; import net.osmand.aidl.gpx.AGpxFile; import net.osmand.aidl.gpx.AGpxFileDetails; @@ -699,4 +701,8 @@ interface IOsmAndAidlInterface { long addContextMenuButtons(in ContextMenuButtonsParams params, IOsmAndAidlCallback callback); boolean removeContextMenuButtons(in RemoveContextMenuButtonsParams params); boolean updateContextMenuButtons(in UpdateContextMenuButtonsParams params); + + boolean areOsmandSettingsCustomized(in OsmandSettingsInfoParams params); + + boolean setCustomization(in CustomizationInfoParams params); } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index babb41e87d..12178937c2 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -23,7 +23,6 @@ import android.support.annotation.Nullable; import android.support.v7.app.AlertDialog; import android.text.TextUtils; import android.view.View; -import android.widget.ArrayAdapter; import net.osmand.CallbackWithObject; import net.osmand.GPXUtilities; @@ -33,6 +32,7 @@ import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.aidl.contextmenu.ContextMenuButtonsParams; import net.osmand.aidl.copyfile.CopyFileParams; +import net.osmand.aidl.customization.CustomizationInfoParams; import net.osmand.aidl.favorite.AFavorite; import net.osmand.aidl.favorite.group.AFavoriteGroup; import net.osmand.aidl.gpx.AGpxBitmap; @@ -58,7 +58,6 @@ import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.AppInitializer.InitEvents; import net.osmand.plus.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; -import net.osmand.plus.ContextMenuItem; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GpxSelectionHelper; @@ -109,8 +108,6 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -126,7 +123,6 @@ import static net.osmand.aidl.OsmandAidlConstants.COPY_FILE_WRITE_LOCK_ERROR; import static net.osmand.aidl.OsmandAidlConstants.OK_RESPONSE; import static net.osmand.aidl.OsmandAidlService.KEY_ON_CONTEXT_MENU_BUTTONS_CLICK; import static net.osmand.aidl.OsmandAidlService.KEY_ON_NAV_DATA_UPDATE; -import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_ITEM_ID_SCHEME; public class OsmandAidlApi { @@ -194,8 +190,6 @@ public class OsmandAidlApi { private static final int DEFAULT_ZOOM = 15; - private static final int MAX_NAV_DRAWER_ITEMS_PER_APP = 3; - private OsmandApplication app; private Map widgets = new ConcurrentHashMap<>(); private Map widgetControls = new ConcurrentHashMap<>(); @@ -1738,123 +1732,11 @@ public class OsmandAidlApi { } boolean setNavDrawerItems(String appPackage, List items) { - if (!TextUtils.isEmpty(appPackage) && items != null) { - clearNavDrawerItems(appPackage); - if (items.isEmpty()) { - return true; - } - List newItems = new ArrayList<>(MAX_NAV_DRAWER_ITEMS_PER_APP); - boolean success = true; - for (int i = 0; i < items.size() && i <= MAX_NAV_DRAWER_ITEMS_PER_APP; i++) { - net.osmand.aidl.navdrawer.NavDrawerItem item = items.get(i); - String name = item.getName(); - String uri = item.getUri(); - if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(uri)) { - newItems.add(new NavDrawerItem(name, uri, item.getIconName(), item.getFlags())); - } else { - success = false; - break; - } - } - if (success) { - saveNavDrawerItems(appPackage, newItems); - } - return success; - } - return false; + return app.getAppCustomization().setNavDrawerItems(appPackage, items); } public void registerNavDrawerItems(final Activity activity, ContextMenuAdapter adapter) { - PackageManager pm = activity.getPackageManager(); - for (Map.Entry> entry : getNavDrawerItems().entrySet()) { - String appPackage = entry.getKey(); - for (NavDrawerItem item : entry.getValue()) { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(item.uri)); - if (intent.resolveActivity(pm) == null) { - intent = pm.getLaunchIntentForPackage(appPackage); - } - if (intent != null) { - if (item.flags != -1) { - intent.addFlags(item.flags); - } - final Intent finalIntent = intent; - adapter.addItem(new ContextMenuItem.ItemBuilder() - .setId(item.getId()) - .setTitle(item.name) - .setIcon(getIconId(item.iconName)) - .setListener(new ContextMenuAdapter.ItemClickListener() { - @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) { - activity.startActivity(finalIntent); - return true; - } - }) - .createItem()); - } - } - } - } - - private int getIconId(@Nullable String iconName) { - if (!TextUtils.isEmpty(iconName)) { - int id = app.getResources().getIdentifier(iconName, "drawable", app.getPackageName()); - return id == 0 ? -1 : id; - } - return -1; - } - - private void clearNavDrawerItems(String appPackage) { - try { - JSONObject allItems = new JSONObject(app.getSettings().API_NAV_DRAWER_ITEMS_JSON.get()); - allItems.put(appPackage, new JSONArray()); - app.getSettings().API_NAV_DRAWER_ITEMS_JSON.set(allItems.toString()); - } catch (JSONException e) { - e.printStackTrace(); - } - } - - private void saveNavDrawerItems(String appPackage, List items) { - try { - JSONArray jArray = new JSONArray(); - for (NavDrawerItem item : items) { - JSONObject obj = new JSONObject(); - obj.put(NavDrawerItem.NAME_KEY, item.name); - obj.put(NavDrawerItem.URI_KEY, item.uri); - obj.put(NavDrawerItem.ICON_NAME_KEY, item.iconName); - obj.put(NavDrawerItem.FLAGS_KEY, item.flags); - jArray.put(obj); - } - JSONObject allItems = new JSONObject(app.getSettings().API_NAV_DRAWER_ITEMS_JSON.get()); - allItems.put(appPackage, jArray); - app.getSettings().API_NAV_DRAWER_ITEMS_JSON.set(allItems.toString()); - } catch (JSONException e) { - e.printStackTrace(); - } - } - - private Map> getNavDrawerItems() { - Map> res = new LinkedHashMap<>(); - try { - JSONObject allItems = new JSONObject(app.getSettings().API_NAV_DRAWER_ITEMS_JSON.get()); - for (Iterator it = allItems.keys(); it.hasNext(); ) { - String appPackage = (String) it.next(); - JSONArray jArray = allItems.getJSONArray(appPackage); - List list = new ArrayList<>(); - for (int i = 0; i < jArray.length(); i++) { - JSONObject obj = jArray.getJSONObject(i); - list.add(new NavDrawerItem( - obj.optString(NavDrawerItem.NAME_KEY), - obj.optString(NavDrawerItem.URI_KEY), - obj.optString(NavDrawerItem.ICON_NAME_KEY), - obj.optInt(NavDrawerItem.FLAGS_KEY, -1) - )); - } - res.put(appPackage, list); - } - } catch (JSONException e) { - e.printStackTrace(); - } - return res; + app.getAppCustomization().registerNavDrawerItems(activity, adapter); } public List getConnectedApps() { @@ -2062,6 +1944,15 @@ public class OsmandAidlApi { } } + boolean areOsmandSettingsCustomized(String sharedPreferencesName) { + return app.getAppCustomization().areSettingsCustomizedForPreference(sharedPreferencesName); + } + + boolean setCustomization(CustomizationInfoParams params) { + app.getAppCustomization().setCustomization(params); + return true; + } + private void addContextMenuButtonListener(ContextMenuButtonsParams buttonsParams, long callbackId) { IContextMenuButtonListener listener = new IContextMenuButtonListener() { @@ -2325,30 +2216,6 @@ public class OsmandAidlApi { } } - private static class NavDrawerItem { - - static final String NAME_KEY = "name"; - static final String URI_KEY = "uri"; - static final String ICON_NAME_KEY = "icon_name"; - static final String FLAGS_KEY = "flags"; - - private String name; - private String uri; - private String iconName; - private int flags; - - NavDrawerItem(String name, String uri, String iconName, int flags) { - this.name = name; - this.uri = uri; - this.iconName = iconName; - this.flags = flags; - } - - public String getId() { - return DRAWER_ITEM_ID_SCHEME + name; - } - } - public interface SearchCompleteCallback { void onSearchComplete(List resultSet); } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 0d6259ae65..3260e1ef2d 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -10,7 +10,6 @@ import android.os.IBinder; import android.os.RemoteException; import android.support.annotation.Nullable; -import java.util.concurrent.ConcurrentHashMap; import net.osmand.PlatformUtil; import net.osmand.aidl.OsmandAidlApi.GpxBitmapCreatedCallback; import net.osmand.aidl.OsmandAidlApi.OsmandAppInitCallback; @@ -19,6 +18,9 @@ import net.osmand.aidl.calculateroute.CalculateRouteParams; import net.osmand.aidl.contextmenu.ContextMenuButtonsParams; import net.osmand.aidl.contextmenu.RemoveContextMenuButtonsParams; import net.osmand.aidl.contextmenu.UpdateContextMenuButtonsParams; +import net.osmand.aidl.copyfile.CopyFileParams; +import net.osmand.aidl.customization.CustomizationInfoParams; +import net.osmand.aidl.customization.OsmandSettingsInfoParams; import net.osmand.aidl.customization.OsmandSettingsParams; import net.osmand.aidl.customization.SetWidgetsParams; import net.osmand.aidl.favorite.AddFavoriteParams; @@ -71,7 +73,6 @@ import net.osmand.aidl.plugins.PluginParams; import net.osmand.aidl.search.SearchParams; import net.osmand.aidl.search.SearchResult; import net.osmand.aidl.tiles.ASqliteDbFile; -import net.osmand.aidl.copyfile.CopyFileParams; import net.osmand.plus.OsmandApplication; import net.osmand.util.Algorithms; @@ -80,6 +81,7 @@ import org.apache.commons.logging.Log; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; import static net.osmand.aidl.OsmandAidlConstants.CANNOT_ACCESS_API_ERROR; @@ -131,7 +133,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { public void onCreate() { super.onCreate(); OsmandAidlApi api = getApi("setting_listener"); - if(api != null) { + if (api != null) { api.aidlCallbackListener = this; } } @@ -142,7 +144,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { callbacks.clear(); OsmandAidlApi api = getApi("clear_listener"); - if(api != null) { + if (api != null) { api.aidlCallbackListener = null; } mHandlerThread.quit(); @@ -1044,7 +1046,7 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { public long registerForNavigationUpdates(ANavigationUpdateParams params, final IOsmAndAidlCallback callback) { try { OsmandAidlApi api = getApi("registerForNavUpdates"); - if (api != null ) { + if (api != null) { if (!params.isSubscribeToUpdates() && params.getCallbackId() != -1) { api.unregisterFromUpdates(params.getCallbackId()); removeAidlCallback(params.getCallbackId()); @@ -1113,6 +1115,28 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { return false; } } + + @Override + public boolean areOsmandSettingsCustomized(OsmandSettingsInfoParams params) { + try { + OsmandAidlApi api = getApi("areOsmandSettingsCustomized"); + return api != null && api.areOsmandSettingsCustomized(params.getSharedPreferencesName()); + } catch (Exception e) { + handleException(e); + return false; + } + } + + @Override + public boolean setCustomization(CustomizationInfoParams params) { + try { + OsmandAidlApi api = getApi("setCustomization"); + return api != null && params != null && api.setCustomization(params); + } catch (Exception e) { + handleException(e); + return false; + } + } }; public static class AidlCallbackParams { @@ -1141,6 +1165,4 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { this.key = key; } } - - -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/customization/CustomizationInfoParams.aidl b/OsmAnd/src/net/osmand/aidl/customization/CustomizationInfoParams.aidl new file mode 100644 index 0000000000..e72d2d47dc --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/customization/CustomizationInfoParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.customization; + +parcelable CustomizationInfoParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/customization/CustomizationInfoParams.java b/OsmAnd/src/net/osmand/aidl/customization/CustomizationInfoParams.java new file mode 100644 index 0000000000..0e83f7f41c --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/customization/CustomizationInfoParams.java @@ -0,0 +1,172 @@ +package net.osmand.aidl.customization; + +import android.annotation.SuppressLint; +import android.os.Parcel; +import android.os.Parcelable; + +import net.osmand.aidl.navdrawer.NavDrawerFooterParams; +import net.osmand.aidl.navdrawer.NavDrawerHeaderParams; +import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams; +import net.osmand.aidl.plugins.PluginParams; + +import java.util.ArrayList; +import java.util.List; + +public class CustomizationInfoParams implements Parcelable { + + private OsmandSettingsParams settingsParams; + + private NavDrawerHeaderParams navDrawerHeaderParams; + private NavDrawerFooterParams navDrawerFooterParams; + private SetNavDrawerItemsParams navDrawerItemsParams; + + private ArrayList visibilityWidgetsParams = new ArrayList<>(); + private ArrayList availabilityWidgetsParams = new ArrayList<>(); + + private ArrayList pluginsParams = new ArrayList<>(); + + private List featuresEnabledIds = new ArrayList<>(); + private List featuresDisabledIds = new ArrayList<>(); + private List featuresEnabledPatterns = new ArrayList<>(); + private List featuresDisabledPatterns = new ArrayList<>(); + + public CustomizationInfoParams(OsmandSettingsParams settingsParams, + NavDrawerHeaderParams navDrawerHeaderParams, + NavDrawerFooterParams navDrawerFooterParams, + SetNavDrawerItemsParams navDrawerItemsParams, + ArrayList visibilityWidgetsParams, + ArrayList availabilityWidgetsParams, + ArrayList pluginsParams, + List featuresEnabledIds, + List featuresDisabledIds, + List featuresEnabledPatterns, + List featuresDisabledPatterns) { + this.settingsParams = settingsParams; + this.navDrawerHeaderParams = navDrawerHeaderParams; + this.navDrawerFooterParams = navDrawerFooterParams; + this.navDrawerItemsParams = navDrawerItemsParams; + + if (visibilityWidgetsParams != null) { + this.visibilityWidgetsParams.addAll(visibilityWidgetsParams); + } + if (availabilityWidgetsParams != null) { + this.availabilityWidgetsParams.addAll(availabilityWidgetsParams); + } + if (pluginsParams != null) { + this.pluginsParams.addAll(pluginsParams); + } + if (featuresEnabledIds != null) { + this.featuresEnabledIds.addAll(featuresEnabledIds); + } + if (featuresDisabledIds != null) { + this.featuresDisabledIds.addAll(featuresDisabledIds); + } + if (featuresEnabledPatterns != null) { + this.featuresEnabledPatterns.addAll(featuresEnabledPatterns); + } + if (featuresDisabledPatterns != null) { + this.featuresDisabledPatterns.addAll(featuresDisabledPatterns); + } + } + + public CustomizationInfoParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public CustomizationInfoParams createFromParcel(Parcel in) { + return new CustomizationInfoParams(in); + } + + @Override + public CustomizationInfoParams[] newArray(int size) { + return new CustomizationInfoParams[size]; + } + }; + + public OsmandSettingsParams getSettingsParams() { + return settingsParams; + } + + public NavDrawerHeaderParams getNavDrawerHeaderParams() { + return navDrawerHeaderParams; + } + + public NavDrawerFooterParams getNavDrawerFooterParams() { + return navDrawerFooterParams; + } + + public SetNavDrawerItemsParams getNavDrawerItemsParams() { + return navDrawerItemsParams; + } + + public ArrayList getVisibilityWidgetsParams() { + return visibilityWidgetsParams; + } + + public ArrayList getAvailabilityWidgetsParams() { + return availabilityWidgetsParams; + } + + public ArrayList getPluginsParams() { + return pluginsParams; + } + + public List getFeaturesEnabledIds() { + return featuresEnabledIds; + } + + public List getFeaturesDisabledIds() { + return featuresDisabledIds; + } + + public List getFeaturesEnabledPatterns() { + return featuresEnabledPatterns; + } + + public List getFeaturesDisabledPatterns() { + return featuresDisabledPatterns; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeParcelable(settingsParams, flags); + + out.writeParcelable(navDrawerHeaderParams, flags); + out.writeParcelable(navDrawerFooterParams, flags); + out.writeParcelable(navDrawerItemsParams, flags); + + out.writeTypedList(visibilityWidgetsParams); + out.writeTypedList(availabilityWidgetsParams); + out.writeTypedList(pluginsParams); + + out.writeStringList(featuresEnabledIds); + out.writeStringList(featuresDisabledIds); + out.writeStringList(featuresEnabledPatterns); + out.writeStringList(featuresDisabledPatterns); + } + + @SuppressLint("ParcelClassLoader") + private void readFromParcel(Parcel in) { + settingsParams = in.readParcelable(OsmandSettingsParams.class.getClassLoader()); + + navDrawerHeaderParams = in.readParcelable(NavDrawerHeaderParams.class.getClassLoader()); + navDrawerFooterParams = in.readParcelable(NavDrawerFooterParams.class.getClassLoader()); + navDrawerItemsParams = in.readParcelable(SetNavDrawerItemsParams.class.getClassLoader()); + + in.readTypedList(visibilityWidgetsParams, SetWidgetsParams.CREATOR); + in.readTypedList(availabilityWidgetsParams, SetWidgetsParams.CREATOR); + in.readTypedList(pluginsParams, PluginParams.CREATOR); + + in.readStringList(featuresEnabledIds); + in.readStringList(featuresDisabledIds); + in.readStringList(featuresEnabledPatterns); + in.readStringList(featuresDisabledPatterns); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.aidl b/OsmAnd/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.aidl new file mode 100644 index 0000000000..80d0fa56ed --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.customization; + +parcelable OsmandSettingsInfoParams; \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.java b/OsmAnd/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.java new file mode 100644 index 0000000000..ba4285af1d --- /dev/null +++ b/OsmAnd/src/net/osmand/aidl/customization/OsmandSettingsInfoParams.java @@ -0,0 +1,50 @@ +package net.osmand.aidl.customization; + +import android.annotation.SuppressLint; +import android.os.Parcel; +import android.os.Parcelable; +import android.support.annotation.NonNull; + +public class OsmandSettingsInfoParams implements Parcelable { + + private String sharedPreferencesName; + + public OsmandSettingsInfoParams(@NonNull String sharedPreferencesName) { + this.sharedPreferencesName = sharedPreferencesName; + } + + public OsmandSettingsInfoParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @Override + public OsmandSettingsInfoParams createFromParcel(Parcel in) { + return new OsmandSettingsInfoParams(in); + } + + @Override + public OsmandSettingsInfoParams[] newArray(int size) { + return new OsmandSettingsInfoParams[size]; + } + }; + + public String getSharedPreferencesName() { + return sharedPreferencesName; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeString(sharedPreferencesName); + } + + @SuppressLint("ParcelClassLoader") + private void readFromParcel(Parcel in) { + sharedPreferencesName = in.readString(); + } + + @Override + public int describeContents() { + return 0; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/AnalyticsHelper.java b/OsmAnd/src/net/osmand/plus/AnalyticsHelper.java index 9bbba55b9b..e906d7b9bb 100644 --- a/OsmAnd/src/net/osmand/plus/AnalyticsHelper.java +++ b/OsmAnd/src/net/osmand/plus/AnalyticsHelper.java @@ -49,10 +49,14 @@ public class AnalyticsHelper extends SQLiteOpenHelper { private final static String DATABASE_NAME = "analytics"; private final static int DATABASE_VERSION = 1; - private final static String TABLE_NAME = "events"; + private final static String TABLE_NAME = "app_events"; private final static String COL_DATE = "date"; + private final static String COL_TYPE = "event_type"; private final static String COL_EVENT = "event"; + public final static int EVENT_TYPE_APP_USAGE = 1; + public final static int EVENT_TYPE_MAP_DOWNLOAD = 2; + private OsmandApplication ctx; private String insertEventScript; private long lastSubmittedTime; @@ -62,6 +66,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper { private static class AnalyticsItem { long date; + int type; String event; } @@ -74,7 +79,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper { AnalyticsHelper(OsmandApplication ctx) { super(ctx, DATABASE_NAME, null, DATABASE_VERSION); this.ctx = ctx; - insertEventScript = "INSERT INTO " + TABLE_NAME + " VALUES (?, ?)"; + insertEventScript = "INSERT INTO " + TABLE_NAME + " VALUES (?, ?, ?)"; submitCollectedDataAsync(); } @@ -84,7 +89,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper { } private void createTable(SQLiteDatabase db) { - db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + COL_DATE + " long, " + COL_EVENT + " text )"); + db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + COL_DATE + " long, " + COL_TYPE + " int, " + COL_EVENT + " text )"); } @Override @@ -108,7 +113,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper { return res; } - private void clearDB( long finishDate) { + private void clearDB(long finishDate) { SQLiteDatabase db = getWritableDatabase(); if (db != null && db.isOpen()) { try { @@ -123,11 +128,18 @@ public class AnalyticsHelper extends SQLiteOpenHelper { if (ctx.getSettings().isInternetConnectionAvailable()) { long collectedRowsCount = getCollectedRowsCount(); if (collectedRowsCount > DATA_PARCEL_SIZE) { - if (submittingTask == null || submittingTask.isDone()) { + final List allowedTypes = new ArrayList<>(); + if (ctx.getSettings().SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get()) { + allowedTypes.add(EVENT_TYPE_MAP_DOWNLOAD); + } + if (ctx.getSettings().SEND_ANONYMOUS_APP_USAGE_DATA.get()) { + allowedTypes.add(EVENT_TYPE_APP_USAGE); + } + if ((submittingTask == null || submittingTask.isDone()) && allowedTypes.size() > 0) { submittingTask = executor.submit(new Runnable() { @Override public void run() { - submitCollectedData(); + submitCollectedData(allowedTypes); } }); return true; @@ -139,17 +151,19 @@ public class AnalyticsHelper extends SQLiteOpenHelper { @SuppressLint("HardwareIds") - private boolean submitCollectedData() { + private void submitCollectedData(List allowedTypes) { List data = collectRecordedData(); for (AnalyticsData d : data) { if (d.items != null && d.items.size() > 0) { try { JSONArray jsonItemsArray = new JSONArray(); for (AnalyticsItem item : d.items) { - JSONObject jsonItem = new JSONObject(); - jsonItem.put(JSON_DATE, item.date); - jsonItem.put(JSON_EVENT, item.event); - jsonItemsArray.put(jsonItem); + if (allowedTypes.contains(item.type)) { + JSONObject jsonItem = new JSONObject(); + jsonItem.put(JSON_DATE, item.date); + jsonItem.put(JSON_EVENT, item.event); + jsonItemsArray.put(jsonItem); + } } Map additionalData = new LinkedHashMap(); @@ -172,16 +186,15 @@ public class AnalyticsHelper extends SQLiteOpenHelper { InputStream inputStream = new ByteArrayInputStream(jsonStr.getBytes()); String res = AndroidNetworkUtils.uploadFile(ANALYTICS_UPLOAD_URL, inputStream, ANALYTICS_FILE_NAME, true, additionalData); if (res != null) { - return false; + return; } } catch (Exception e) { LOG.error(e); - return false; + return; } clearDB(d.finishDate); } } - return true; } private List collectRecordedData() { @@ -198,7 +211,7 @@ public class AnalyticsHelper extends SQLiteOpenHelper { } private void collectDBData(SQLiteDatabase db, List data) { - Cursor query = db.rawQuery("SELECT " + COL_DATE + "," + COL_EVENT + " FROM " + TABLE_NAME + " ORDER BY " + COL_DATE + " ASC", null); + Cursor query = db.rawQuery("SELECT " + COL_DATE + "," + COL_TYPE + "," + COL_EVENT + " FROM " + TABLE_NAME + " ORDER BY " + COL_DATE + " ASC", null); List items = new ArrayList<>(); int itemsCounter = 0; long startDate = Long.MAX_VALUE; @@ -208,7 +221,8 @@ public class AnalyticsHelper extends SQLiteOpenHelper { AnalyticsItem item = new AnalyticsItem(); long date = query.getLong(0); item.date = date; - item.event = query.getString(1); + item.type = query.getInt(1); + item.event = query.getString(2); items.add(item); itemsCounter++; @@ -244,11 +258,11 @@ public class AnalyticsHelper extends SQLiteOpenHelper { query.close(); } - public void addEvent(String event) { + public void addEvent(String event, int type) { SQLiteDatabase db = getWritableDatabase(); if (db != null && db.isOpen()) { try { - db.execSQL(insertEventScript, new Object[]{System.currentTimeMillis(), event}); + db.execSQL(insertEventScript, new Object[]{System.currentTimeMillis(), type, event}); } finally { db.close(); } diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 36af56140b..64d43a3b97 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -60,10 +60,12 @@ public class GpxSelectionHelper { savingTrackHelper = trackHelper; } - public void clearAllGpxFileToShow() { + public void clearAllGpxFilesToShow(boolean backupSelection) { selectedGpxFilesBackUp.clear(); - for(SelectedGpxFile s : selectedGPXFiles) { - selectedGpxFilesBackUp.put(s.gpxFile, s.modifiedTime); + if (backupSelection) { + for(SelectedGpxFile s : selectedGPXFiles) { + selectedGpxFilesBackUp.put(s.gpxFile, s.modifiedTime); + } } selectedGPXFiles = new ArrayList<>(); saveCurrentSelections(); diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java index a47ca5dade..8c8a26f542 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java @@ -1,8 +1,8 @@ package net.osmand.plus; -import static net.osmand.plus.osmedit.OpenstreetmapLocalUtil.LOG; - import android.app.Activity; +import android.content.Intent; +import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; @@ -11,11 +11,16 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; +import android.widget.ArrayAdapter; import net.osmand.IProgress; import net.osmand.IndexConstants; +import net.osmand.aidl.customization.CustomizationInfoParams; +import net.osmand.aidl.customization.OsmandSettingsParams; +import net.osmand.aidl.customization.SetWidgetsParams; import net.osmand.aidl.navdrawer.NavDrawerFooterParams; import net.osmand.aidl.navdrawer.NavDrawerHeaderParams; +import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams; import net.osmand.aidl.plugins.PluginParams; import net.osmand.data.LocationPoint; import net.osmand.plus.activities.MapActivity; @@ -28,6 +33,10 @@ import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.views.OsmandMapTileView; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -36,13 +45,18 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; +import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_ITEM_ID_SCHEME; + public class OsmAndAppCustomization { + private static final int MAX_NAV_DRAWER_ITEMS_PER_APP = 3; + protected OsmandApplication app; protected OsmandSettings osmandSettings; @@ -209,7 +223,9 @@ public class OsmAndAppCustomization { } @Nullable - public ArrayList getNavDrawerLogoParams() {return navDrawerParams; } + public ArrayList getNavDrawerLogoParams() { + return navDrawerParams; + } public boolean setNavDrawerLogo(String uri, @Nullable String packageName, @Nullable String intent) { if (TextUtils.isEmpty(uri)) { @@ -283,6 +299,89 @@ public class OsmAndAppCustomization { return set; } + public void regWidgetsVisibility(@NonNull ArrayList visibilityWidgetsParams) { + for (SetWidgetsParams setWidgetsParams : visibilityWidgetsParams) { + regWidgetVisibility(setWidgetsParams.getWidgetKey(), setWidgetsParams.getAppModesKeys()); + } + } + + public void regWidgetsAvailability(@NonNull ArrayList availabilityWidgetsParams) { + for (SetWidgetsParams setWidgetsParams : availabilityWidgetsParams) { + regWidgetAvailability(setWidgetsParams.getWidgetKey(), setWidgetsParams.getAppModesKeys()); + } + } + + public void setCustomization(CustomizationInfoParams params) { + OsmandSettingsParams settingsParams = params.getSettingsParams(); + if (settingsParams != null) { + customizeOsmandSettings(settingsParams.getSharedPreferencesName(), settingsParams.getBundle()); + } + NavDrawerHeaderParams navDrawerHeaderParams = params.getNavDrawerHeaderParams(); + NavDrawerFooterParams navDrawerFooterParams = params.getNavDrawerFooterParams(); + SetNavDrawerItemsParams navDrawerItemsParams = params.getNavDrawerItemsParams(); + + setNavDrawerParams(navDrawerHeaderParams, navDrawerFooterParams, navDrawerItemsParams); + + ArrayList visibilityWidgetsParams = params.getVisibilityWidgetsParams(); + ArrayList availabilityWidgetsParams = params.getAvailabilityWidgetsParams(); + + setWidgetsParams(visibilityWidgetsParams, availabilityWidgetsParams); + + ArrayList pluginsParams = params.getPluginsParams(); + if (pluginsParams != null) { + changePluginsStatus(pluginsParams); + } + + List enabledIds = params.getFeaturesEnabledIds(); + List disabledIds = params.getFeaturesDisabledIds(); + + setFeaturesIds(enabledIds, disabledIds); + + List enabledPatterns = params.getFeaturesEnabledPatterns(); + List disabledPatterns = params.getFeaturesDisabledPatterns(); + + setFeaturesPatterns(enabledPatterns, disabledPatterns); + } + + public void setNavDrawerParams(NavDrawerHeaderParams navDrawerHeaderParams, NavDrawerFooterParams navDrawerFooterParams, SetNavDrawerItemsParams navDrawerItemsParams) { + if (navDrawerHeaderParams != null) { + setNavDrawerLogoWithParams(navDrawerHeaderParams.getImageUri(), navDrawerHeaderParams.getPackageName(), navDrawerHeaderParams.getIntent()); + } + if (navDrawerFooterParams != null) { + setNavDrawerFooterParams(navDrawerFooterParams); + } + if (navDrawerItemsParams != null) { + setNavDrawerItems(navDrawerItemsParams.getAppPackage(), navDrawerItemsParams.getItems()); + } + } + + public void setWidgetsParams(ArrayList visibilityWidgetsParams, ArrayList availabilityWidgetsParams) { + if (visibilityWidgetsParams != null) { + regWidgetsVisibility(visibilityWidgetsParams); + } + if (availabilityWidgetsParams != null) { + regWidgetsAvailability(availabilityWidgetsParams); + } + } + + public void setFeaturesIds(List enabledIds, List disabledIds) { + if (enabledIds != null) { + setFeaturesEnabledIds(enabledIds); + } + if (disabledIds != null) { + setFeaturesDisabledIds(disabledIds); + } + } + + public void setFeaturesPatterns(List enabledPatterns, List disabledPatterns) { + if (enabledPatterns != null) { + setFeaturesEnabledPatterns(enabledPatterns); + } + if (disabledPatterns != null) { + setFeaturesDisabledPatterns(disabledPatterns); + } + } + public boolean isWidgetVisible(@NonNull String key, ApplicationMode appMode) { Set set = widgetsVisibilityMap.get(key); if (set == null) { @@ -300,10 +399,16 @@ public class OsmAndAppCustomization { } public boolean setNavDrawerLogoWithParams(String imageUri, @Nullable String packageName, - @Nullable String intent) { + @Nullable String intent) { return setNavDrawerLogo(imageUri, packageName, intent); } + public void changePluginsStatus(List pluginsParams) { + for (PluginParams pluginParams : pluginsParams) { + changePluginStatus(pluginParams); + } + } + public boolean changePluginStatus(PluginParams params) { if (params.getNewState() == 0) { for (OsmandPlugin plugin : OsmandPlugin.getEnabledPlugins()) { @@ -326,6 +431,126 @@ public class OsmAndAppCustomization { return false; } + public boolean setNavDrawerItems(String appPackage, List items) { + if (!TextUtils.isEmpty(appPackage) && items != null) { + clearNavDrawerItems(appPackage); + if (items.isEmpty()) { + return true; + } + List newItems = new ArrayList<>(MAX_NAV_DRAWER_ITEMS_PER_APP); + boolean success = true; + for (int i = 0; i < items.size() && i <= MAX_NAV_DRAWER_ITEMS_PER_APP; i++) { + net.osmand.aidl.navdrawer.NavDrawerItem item = items.get(i); + String name = item.getName(); + String uri = item.getUri(); + if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(uri)) { + newItems.add(new NavDrawerItem(name, uri, item.getIconName(), item.getFlags())); + } else { + success = false; + break; + } + } + if (success) { + saveNavDrawerItems(appPackage, newItems); + } + return success; + } + return false; + } + + private void clearNavDrawerItems(String appPackage) { + try { + JSONObject allItems = new JSONObject(app.getSettings().API_NAV_DRAWER_ITEMS_JSON.get()); + allItems.put(appPackage, new JSONArray()); + app.getSettings().API_NAV_DRAWER_ITEMS_JSON.set(allItems.toString()); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private void saveNavDrawerItems(String appPackage, List items) { + try { + JSONArray jArray = new JSONArray(); + for (NavDrawerItem item : items) { + JSONObject obj = new JSONObject(); + obj.put(NavDrawerItem.NAME_KEY, item.name); + obj.put(NavDrawerItem.URI_KEY, item.uri); + obj.put(NavDrawerItem.ICON_NAME_KEY, item.iconName); + obj.put(NavDrawerItem.FLAGS_KEY, item.flags); + jArray.put(obj); + } + JSONObject allItems = new JSONObject(app.getSettings().API_NAV_DRAWER_ITEMS_JSON.get()); + allItems.put(appPackage, jArray); + app.getSettings().API_NAV_DRAWER_ITEMS_JSON.set(allItems.toString()); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + public void registerNavDrawerItems(final Activity activity, ContextMenuAdapter adapter) { + PackageManager pm = activity.getPackageManager(); + for (Map.Entry> entry : getNavDrawerItems().entrySet()) { + String appPackage = entry.getKey(); + for (NavDrawerItem item : entry.getValue()) { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(item.uri)); + if (intent.resolveActivity(pm) == null) { + intent = pm.getLaunchIntentForPackage(appPackage); + } + if (intent != null) { + if (item.flags != -1) { + intent.addFlags(item.flags); + } + final Intent finalIntent = intent; + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setId(item.getId()) + .setTitle(item.name) + .setIcon(getIconId(item.iconName)) + .setListener(new ContextMenuAdapter.ItemClickListener() { + @Override + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) { + activity.startActivity(finalIntent); + return true; + } + }) + .createItem()); + } + } + } + } + + private Map> getNavDrawerItems() { + Map> res = new LinkedHashMap<>(); + try { + JSONObject allItems = new JSONObject(app.getSettings().API_NAV_DRAWER_ITEMS_JSON.get()); + for (Iterator it = allItems.keys(); it.hasNext(); ) { + String appPackage = (String) it.next(); + JSONArray jArray = allItems.getJSONArray(appPackage); + List list = new ArrayList<>(); + for (int i = 0; i < jArray.length(); i++) { + JSONObject obj = jArray.getJSONObject(i); + list.add(new NavDrawerItem( + obj.optString(NavDrawerItem.NAME_KEY), + obj.optString(NavDrawerItem.URI_KEY), + obj.optString(NavDrawerItem.ICON_NAME_KEY), + obj.optInt(NavDrawerItem.FLAGS_KEY, -1) + )); + } + res.put(appPackage, list); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return res; + } + + private int getIconId(@Nullable String iconName) { + if (!TextUtils.isEmpty(iconName)) { + int id = app.getResources().getIdentifier(iconName, "drawable", app.getPackageName()); + return id == 0 ? -1 : id; + } + return -1; + } + @NonNull private HashSet getAppModesSet(@Nullable List appModeKeys) { HashSet set = new HashSet<>(); @@ -365,10 +590,29 @@ public class OsmAndAppCustomization { return !isMatchesPattern(id, featuresDisabledPatterns); } + public boolean isOsmandCustomized() { + return areWidgetsCustomized() || areFeaturesCustomized() || areSettingsCustomized(); + } + public boolean areWidgetsCustomized() { return widgetsCustomized; } + public boolean areFeaturesCustomized() { + return featuresCustomized; + } + + public boolean areSettingsCustomized() { + return customOsmandSettings != null; + } + + public boolean areSettingsCustomizedForPreference(String sharedPreferencesName) { + if (customOsmandSettings != null && customOsmandSettings.sharedPreferencesName.equals(sharedPreferencesName)) { + return true; + } + return OsmandSettings.areSettingsCustomizedForPreference(sharedPreferencesName, app); + } + private void setFeaturesCustomized() { featuresCustomized = true; } @@ -405,4 +649,28 @@ public class OsmAndAppCustomization { public void removeListener(OsmAndAppCustomizationListener listener) { this.listeners.remove(listener); } -} + + private static class NavDrawerItem { + + static final String NAME_KEY = "name"; + static final String URI_KEY = "uri"; + static final String ICON_NAME_KEY = "icon_name"; + static final String FLAGS_KEY = "flags"; + + private String name; + private String uri; + private String iconName; + private int flags; + + NavDrawerItem(String name, String uri, String iconName, int flags) { + this.name = name; + this.uri = uri; + this.iconName = iconName; + this.flags = flags; + } + + public String getId() { + return DRAWER_ITEM_ID_SCHEME + name; + } + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index e1c69f6e9e..6edecd3a5b 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -47,7 +47,7 @@ import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.api.SQLiteAPI; import net.osmand.plus.api.SQLiteAPIImpl; import net.osmand.plus.base.MapViewTrackingUtilities; -import net.osmand.plus.dialogs.ErrorBottomSheetDialog; +import net.osmand.plus.dialogs.CrashBottomSheetDialogFragment; import net.osmand.plus.dialogs.RateUsBottomSheetDialog; import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.download.IndexItem; @@ -85,7 +85,8 @@ import btools.routingapp.BRouterServiceConnection; import btools.routingapp.IBRouterService; public class OsmandApplication extends MultiDexApplication { - public static final String EXCEPTION_PATH = "exception.log"; + public static final String EXCEPTION_PATH = "exception.log"; + public static final String OSMAND_PRIVACY_POLICY_URL = "https://osmand.net/help-online/privacy-policy"; private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(OsmandApplication.class); final AppInitializer appInitializer = new AppInitializer(this); @@ -281,6 +282,7 @@ public class OsmandApplication extends MultiDexApplication { public void setOsmandSettings(OsmandSettings osmandSettings) { //android.os.Process.killProcess(android.os.Process.myPid()); this.osmandSettings = osmandSettings; + resourceManager.getRenderer().updateSettings(); OsmandPlugin.initPlugins(this); } @@ -942,9 +944,7 @@ public class OsmandApplication extends MultiDexApplication { public void logEvent(String event) { try { - if (osmandSettings.SEND_ANONYMOUS_APP_USAGE_DATA.get()) { - analyticsHelper.addEvent(event); - } + analyticsHelper.addEvent(event, AnalyticsHelper.EVENT_TYPE_APP_USAGE); } catch (Exception e) { LOG.error(e); } @@ -952,9 +952,7 @@ public class OsmandApplication extends MultiDexApplication { public void logMapDownloadEvent(String event, IndexItem item) { try { - if (osmandSettings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get()) { - analyticsHelper.addEvent("map_download_" + event + ": " + item.getFileName()); - } + analyticsHelper.addEvent("map_download_" + event + ": " + item.getFileName(), AnalyticsHelper.EVENT_TYPE_MAP_DOWNLOAD); } catch (Exception e) { LOG.error(e); } @@ -962,9 +960,7 @@ public class OsmandApplication extends MultiDexApplication { public void logMapDownloadEvent(String event, IndexItem item, long time) { try { - if (osmandSettings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get()) { - analyticsHelper.addEvent("map_download_" + event + ": " + item.getFileName() + " in " + time + " msec"); - } + analyticsHelper.addEvent("map_download_" + event + ": " + item.getFileName() + " in " + time + " msec", AnalyticsHelper.EVENT_TYPE_MAP_DOWNLOAD); } catch (Exception e) { LOG.error(e); } @@ -1009,7 +1005,7 @@ public class OsmandApplication extends MultiDexApplication { text.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode); } } catch (PackageManager.NameNotFoundException e) { - PlatformUtil.getLog(ErrorBottomSheetDialog.class).error("", e); + PlatformUtil.getLog(CrashBottomSheetDialogFragment.class).error("", e); } intent.putExtra(Intent.EXTRA_TEXT, text.toString()); Intent chooserIntent = Intent.createChooser(intent, getString(R.string.send_report)); diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index dde6144c54..49df65dd53 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -4,6 +4,7 @@ package net.osmand.plus; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; +import android.content.SharedPreferences; import android.content.res.Configuration; import android.hardware.Sensor; import android.hardware.SensorManager; @@ -28,6 +29,7 @@ import net.osmand.plus.access.AccessibilityMode; import net.osmand.plus.access.RelativeDirectionStyle; import net.osmand.plus.api.SettingsAPI; import net.osmand.plus.api.SettingsAPI.SettingsEditor; +import net.osmand.plus.api.SettingsAPIImpl; import net.osmand.plus.dialogs.RateUsBottomSheetDialog; import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.mapillary.MapillaryPlugin; @@ -120,6 +122,7 @@ public class OsmandSettings { } // These settings are stored in SharedPreferences + private static final String CUSTOM_SHARED_PREFERENCES_PREFIX = "net.osmand.customsettings."; private static final String SHARED_PREFERENCES_NAME = "net.osmand.settings"; private static String CUSTOM_SHARED_PREFERENCES_NAME; @@ -148,8 +151,9 @@ public class OsmandSettings { protected OsmandSettings(OsmandApplication clientContext, SettingsAPI settinsAPI, String sharedPreferencesName) { ctx = clientContext; this.settingsAPI = settinsAPI; - CUSTOM_SHARED_PREFERENCES_NAME = "net.osmand.customsettings." + sharedPreferencesName; + CUSTOM_SHARED_PREFERENCES_NAME = CUSTOM_SHARED_PREFERENCES_PREFIX + sharedPreferencesName; initPrefs(); + setCustomized(); } private void initPrefs() { @@ -160,6 +164,12 @@ public class OsmandSettings { registeredPreferences.put(APPLICATION_MODE.getId(), APPLICATION_MODE); } + private static final String SETTING_CUSTOMIZED_ID = "settings_customized"; + + private void setCustomized() { + settingsAPI.edit(globalPreferences).putBoolean(SETTING_CUSTOMIZED_ID, true).commit(); + } + public OsmandApplication getContext() { return ctx; } @@ -182,6 +192,14 @@ public class OsmandSettings { } } + public static boolean areSettingsCustomizedForPreference(String sharedPreferencesName, OsmandApplication app) { + String customPrefName = CUSTOM_SHARED_PREFERENCES_PREFIX + sharedPreferencesName; + SettingsAPIImpl settingsAPI = new net.osmand.plus.api.SettingsAPIImpl(app); + SharedPreferences globalPreferences = (SharedPreferences) settingsAPI.getPreferenceObject(customPrefName); + + return globalPreferences != null && globalPreferences.getBoolean(SETTING_CUSTOMIZED_ID, false); + } + public Object getProfilePreferences(ApplicationMode mode) { return settingsAPI.getPreferenceObject(getSharedPreferencesName(mode)); } @@ -1042,6 +1060,9 @@ public class OsmandSettings { public final OsmandPreference DO_NOT_USE_ANIMATIONS = new BooleanPreference("do_not_use_animations", false).makeGlobal().cache(); public final OsmandPreference SEND_ANONYMOUS_MAP_DOWNLOADS_DATA = new BooleanPreference("send_anonymous_map_downloads_data", false).makeGlobal().cache(); public final OsmandPreference SEND_ANONYMOUS_APP_USAGE_DATA = new BooleanPreference("send_anonymous_app_usage_data", false).makeGlobal().cache(); + public final OsmandPreference SEND_ANONYMOUS_DATA_REQUEST_PROCESSED = new BooleanPreference("send_anonymous_data_request_processed", false).makeGlobal().cache(); + public final OsmandPreference SEND_ANONYMOUS_DATA_REQUESTS_COUNT = new IntPreference("send_anonymous_data_requests_count", 0).makeGlobal().cache(); + public final OsmandPreference SEND_ANONYMOUS_DATA_LAST_REQUEST_NS = new IntPreference("send_anonymous_data_last_request_ns", -1).makeGlobal().cache(); public final OsmandPreference MAP_EMPTY_STATE_ALLOWED = new BooleanPreference("map_empty_state_allowed", true).makeGlobal().cache(); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index d89ef1e4b9..3f56a6fac6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -83,7 +83,9 @@ import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.chooseplan.OsmLiveCancelledDialog; import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; -import net.osmand.plus.dialogs.ErrorBottomSheetDialog; +import net.osmand.plus.dialogs.CrashBottomSheetDialogFragment; +import net.osmand.plus.dialogs.RateUsBottomSheetDialogFragment; +import net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment; import net.osmand.plus.dialogs.RateUsBottomSheetDialog; import net.osmand.plus.dialogs.WhatsNewDialogFragment; import net.osmand.plus.dialogs.XMasDialogFragment; @@ -680,12 +682,12 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (settings.SHOW_DASHBOARD_ON_START.get()) { dashboardOnMap.setDashboardVisibility(true, DashboardOnMap.staticVisibleType); } else { - if (ErrorBottomSheetDialog.shouldShow(settings, this)) { + if (CrashBottomSheetDialogFragment.shouldShow(settings, this)) { SecondSplashScreenFragment.SHOW = false; - new ErrorBottomSheetDialog().show(getSupportFragmentManager(), "dialog"); - } else if (RateUsBottomSheetDialog.shouldShow(app)) { + CrashBottomSheetDialogFragment.showInstance(getSupportFragmentManager()); + } else if (RateUsBottomSheetDialogFragment.shouldShow(app)) { SecondSplashScreenFragment.SHOW = false; - new RateUsBottomSheetDialog().show(getSupportFragmentManager(), "dialog"); + RateUsBottomSheetDialogFragment.showInstance(getSupportFragmentManager()); } } } else { @@ -860,6 +862,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven FirstUsageWelcomeFragment.TAG).commitAllowingStateLoss(); } else if (!isFirstScreenShowing() && OsmLiveCancelledDialog.shouldShowDialog(app)) { OsmLiveCancelledDialog.showInstance(getSupportFragmentManager()); + } else if (SendAnalyticsBottomSheetDialogFragment.shouldShowDialog(app)) { + SendAnalyticsBottomSheetDialogFragment.showInstance(app, getSupportFragmentManager()); } FirstUsageWelcomeFragment.SHOW = false; if (isFirstScreenShowing() && (!settings.SHOW_OSMAND_WELCOME_SCREEN.get() || !showOsmAndWelcomeScreen)) { @@ -1588,6 +1592,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } ((MapActivity) activity).readLocationToShow(); } else { + int additionalFlags = 0; if (activity instanceof Activity) { Intent intent = ((Activity) activity).getIntent(); if (intent != null) { @@ -1598,11 +1603,12 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } } else { prevActivityIntent = null; + additionalFlags = Intent.FLAG_ACTIVITY_NEW_TASK; } Intent newIntent = new Intent(activity, ((OsmandApplication) activity.getApplicationContext()) .getAppCustomization().getMapActivity()); - newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_CLEAR_TOP); + newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_CLEAR_TOP | additionalFlags); if (intentExtraActionName != null) { newIntent.putExtra(intentExtraActionName, intentExtraActionValue); } diff --git a/OsmAnd/src/net/osmand/plus/activities/PrivacyAndSecurityActivity.java b/OsmAnd/src/net/osmand/plus/activities/PrivacyAndSecurityActivity.java new file mode 100644 index 0000000000..ce8e1da09c --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/activities/PrivacyAndSecurityActivity.java @@ -0,0 +1,90 @@ +package net.osmand.plus.activities; + +import android.app.Activity; +import android.os.Bundle; +import android.support.v7.widget.SwitchCompat; +import android.support.v7.widget.Toolbar; +import android.util.TypedValue; +import android.view.MenuItem; +import android.view.View; +import android.widget.CompoundButton; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; + +public class PrivacyAndSecurityActivity extends OsmandActionBarActivity { + + @Override + public void onCreate(Bundle savedInstanceState) { + OsmandApplication app = getMyApplication(); + int themeId = !app.getSettings().isLightContent() ? R.style.OsmandDarkTheme_NoActionbar : R.style.OsmandLightTheme_NoActionbar; + setTheme(themeId); + super.onCreate(savedInstanceState); + setContentView(R.layout.privacy_settings_layout); + Toolbar tb = (Toolbar) findViewById(R.id.toolbar); + tb.setTitle(R.string.settings_privacy_and_security); + + tb.setClickable(true); + tb.setNavigationIcon(((OsmandApplication) getApplication()).getUIUtilities().getIcon(R.drawable.ic_arrow_back)); + tb.setNavigationContentDescription(R.string.access_shared_string_navigate_up); + tb.setBackgroundColor(getResources().getColor(resolveResourceId(this, R.attr.pstsTabBackground))); + tb.setTitleTextColor(getResources().getColor(resolveResourceId(this, R.attr.pstsTextColor))); + tb.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(final View v) { + finish(); + } + }); + + View downloadedMapsContainer = findViewById(R.id.downloaded_maps_container); + final SwitchCompat downloadedMapsButton = (SwitchCompat) findViewById(R.id.downloaded_maps_button); + downloadedMapsButton.setChecked(app.getSettings().SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get()); + downloadedMapsButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + OsmandApplication app = getMyApplication(); + app.getSettings().SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.set(isChecked); + } + }); + downloadedMapsContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + downloadedMapsButton.setChecked(!downloadedMapsButton.isChecked()); + } + }); + + View visitedScreensContainer = findViewById(R.id.visited_screens_container); + final SwitchCompat visitedScreensButton = (SwitchCompat) findViewById(R.id.visited_screens_button); + visitedScreensButton.setChecked(app.getSettings().SEND_ANONYMOUS_APP_USAGE_DATA.get()); + visitedScreensButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + OsmandApplication app = getMyApplication(); + app.getSettings().SEND_ANONYMOUS_APP_USAGE_DATA.set(isChecked); + } + }); + visitedScreensContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + visitedScreensButton.setChecked(!visitedScreensButton.isChecked()); + } + }); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int itemId = item.getItemId(); + switch (itemId) { + case android.R.id.home: + finish(); + return true; + } + return false; + } + + private int resolveResourceId(final Activity activity, final int attr) { + final TypedValue typedvalueattr = new TypedValue(); + activity.getTheme().resolveAttribute(attr, typedvalueattr, true); + return typedvalueattr.resourceId; + } +} diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java index db7df49a1c..7fc3caab0b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java @@ -30,6 +30,7 @@ public class SettingsActivity extends SettingsBaseActivity { private Preference routing; private Preference subscription; private Preference profiles; + private Preference privacy; @Override @@ -46,6 +47,8 @@ public class SettingsActivity extends SettingsBaseActivity { profiles.setOnPreferenceClickListener(this); subscription = (Preference) screen.findPreference("subscription_settings"); subscription.setOnPreferenceClickListener(this); + privacy = (Preference) screen.findPreference("privacy_and_security"); + privacy.setOnPreferenceClickListener(this); getToolbar().setTitle(Version.getFullVersion(getMyApplication())); @@ -103,6 +106,10 @@ public class SettingsActivity extends SettingsBaseActivity { intent.putExtra(OsmLiveActivity.SHOW_SETTINGS_ONLY_INTENT_PARAM, true); startActivity(intent); return true; + } else if (preference == privacy) { + Intent intent = new Intent(this, PrivacyAndSecurityActivity.class); + startActivity(intent); + return true; } else { super.onPreferenceClick(preference); } diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index 35bd35a350..c6ff3339ab 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -43,6 +43,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra protected boolean nightMode; protected int themeRes; + protected View dismissButton; + protected View rightButton; private LinearLayout itemsContainer; @@ -85,8 +87,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra inflateMenuItems(); - View dismissButton = mainView.findViewById(R.id.dismiss_button); - setupDialogButton(dismissButton, DialogButtonType.STROKED, getDismissButtonTextId()); + dismissButton = mainView.findViewById(R.id.dismiss_button); + setupDialogButton(dismissButton, getDismissByttonType(), getDismissButtonTextId()); dismissButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -100,8 +102,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra int rightBottomButtonTextId = getRightBottomButtonTextId(); if (rightBottomButtonTextId != DEFAULT_VALUE) { mainView.findViewById(R.id.buttons_divider).setVisibility(View.VISIBLE); - View rightButton = mainView.findViewById(R.id.right_bottom_button); - setupDialogButton(rightButton, DialogButtonType.PRIMARY, rightBottomButtonTextId); + rightButton = mainView.findViewById(R.id.right_bottom_button); + setupDialogButton(rightButton, getRightBottomByttonType(), rightBottomButtonTextId); rightButton.setVisibility(View.VISIBLE); rightButton.setOnClickListener(new View.OnClickListener() { @Override @@ -111,6 +113,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra }); } } + updateBottomButtons(); setupHeightAndBackground(mainView); return mainView; } @@ -283,6 +286,10 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra dismissButtonStringRes = stringRes; } + protected DialogButtonType getDismissByttonType() { + return DialogButtonType.SECONDARY; + } + protected void onDismissButtonClickAction() { } @@ -292,10 +299,35 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra return DEFAULT_VALUE; } + protected DialogButtonType getRightBottomByttonType() { + return DialogButtonType.PRIMARY; + } + protected void onRightBottomButtonClick() { } + protected boolean isDismissButtonEnabled() { + return true; + } + + protected boolean isRightBottomButtonEnabled() { + return true; + } + + protected void updateBottomButtons() { + if (dismissButton != null) { + boolean enabled = isDismissButtonEnabled(); + dismissButton.setEnabled(enabled); + dismissButton.findViewById(R.id.button_text).setEnabled(enabled); + } + if (rightButton != null) { + boolean enabled = isRightBottomButtonEnabled(); + rightButton.setEnabled(enabled); + rightButton.findViewById(R.id.button_text).setEnabled(enabled); + } + } + @ColorRes protected int getBgColorId() { return nightMode ? R.color.bg_color_dark : R.color.bg_color_light; diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemTitleWithDescrAndButton.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemTitleWithDescrAndButton.java index fc347554fd..9b17400b29 100644 --- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemTitleWithDescrAndButton.java +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemTitleWithDescrAndButton.java @@ -35,6 +35,7 @@ public class BottomSheetItemTitleWithDescrAndButton extends BottomSheetItemWithD CharSequence description, @ColorRes int descriptionColorId, int descriptionMaxLines, + boolean descriptionLinksClickable, String buttonTitle, View.OnClickListener onButtonClickListener, Drawable leftCompoundDrawable, @@ -51,7 +52,8 @@ public class BottomSheetItemTitleWithDescrAndButton extends BottomSheetItemWithD titleColorId, description, descriptionColorId, - descriptionMaxLines); + descriptionMaxLines, + descriptionLinksClickable); this.buttonTitle = buttonTitle; this.onButtonClickListener = onButtonClickListener; this.leftCompoundDrawable = leftCompoundDrawable; @@ -125,6 +127,7 @@ public class BottomSheetItemTitleWithDescrAndButton extends BottomSheetItemWithD description, descriptionColorId, descriptionMaxLines, + descriptionLinksClickable, buttonTitle, onButtonClickListener, leftCompoundDrawable, diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java index 7722438cdb..4ad4613034 100644 --- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java @@ -37,6 +37,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri CharSequence description, @ColorRes int descriptionColorId, int descriptionMaxLines, + boolean descriptionLinksClickable, boolean checked, ColorStateList buttonTintList, OnCheckedChangeListener onCheckedChangeListener) { @@ -51,7 +52,8 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri titleColorId, description, descriptionColorId, - descriptionMaxLines); + descriptionMaxLines, + descriptionLinksClickable); this.checked = checked; this.buttonTintList = buttonTintList; this.onCheckedChangeListener = onCheckedChangeListener; @@ -109,6 +111,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri description, descriptionColorId, descriptionMaxLines, + descriptionLinksClickable, checked, buttonTintList, onCheckedChangeListener); diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java index fa26be10e7..ae08050abf 100644 --- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java @@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable; import android.support.annotation.ColorRes; import android.support.annotation.LayoutRes; import android.support.v4.content.ContextCompat; +import android.text.method.LinkMovementMethod; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @@ -17,6 +18,7 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { @ColorRes private int descriptionColorId = INVALID_ID; private int descriptionMaxLines = INVALID_VALUE; + private boolean descriptionLinksClickable = false; private TextView descriptionTv; @@ -31,11 +33,13 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { @ColorRes int titleColorId, CharSequence description, @ColorRes int descriptionColorId, - int descriptionMaxLines) { + int descriptionMaxLines, + boolean descriptionLinksClickable) { super(customView, layoutId, tag, disabled, onClickListener, position, icon, title, titleColorId); this.description = description; this.descriptionColorId = descriptionColorId; this.descriptionMaxLines = descriptionMaxLines; + this.descriptionLinksClickable = descriptionLinksClickable; } protected BottomSheetItemWithDescription() { @@ -52,6 +56,17 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { descriptionTv.setMaxLines(maxLines); } + public void setDescriptionLinksClickable(boolean descriptionLinksClickable) { + this.descriptionLinksClickable = descriptionLinksClickable; + if (descriptionTv != null) { + if (descriptionLinksClickable) { + descriptionTv.setMovementMethod(LinkMovementMethod.getInstance()); + } else { + descriptionTv.setMovementMethod(null); + } + } + } + @Override public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) { super.inflate(app, container, nightMode); @@ -64,6 +79,9 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { if (descriptionMaxLines != INVALID_VALUE) { descriptionTv.setMaxLines(descriptionMaxLines); } + if (descriptionLinksClickable) { + descriptionTv.setMovementMethod(LinkMovementMethod.getInstance()); + } } } @@ -73,6 +91,7 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { @ColorRes protected int descriptionColorId = INVALID_ID; protected int descriptionMaxLines = INVALID_POSITION; + protected boolean descriptionLinksClickable = false; public Builder setDescription(CharSequence description) { this.description = description; @@ -89,6 +108,10 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { return this; } + public void setDescriptionLinksClickable(boolean descriptionLinksClickable) { + this.descriptionLinksClickable = descriptionLinksClickable; + } + public BottomSheetItemWithDescription create() { return new BottomSheetItemWithDescription(customView, layoutId, @@ -101,7 +124,8 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { titleColorId, description, descriptionColorId, - descriptionMaxLines); + descriptionMaxLines, + descriptionLinksClickable); } } } diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/SubtitmeListDividerItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/SubtitmeListDividerItem.java new file mode 100644 index 0000000000..f429795bf1 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/SubtitmeListDividerItem.java @@ -0,0 +1,31 @@ +package net.osmand.plus.base.bottomsheetmenu.simpleitems; + +import android.content.Context; +import android.support.annotation.ColorRes; + +import net.osmand.plus.R; + +public class SubtitmeListDividerItem extends DividerItem { + + public SubtitmeListDividerItem(Context context) { + super(context); + } + + public SubtitmeListDividerItem(Context context, @ColorRes int colorId) { + super(context, colorId); + } + + public SubtitmeListDividerItem(Context context, @ColorRes int colorId, int position) { + super(context, colorId, position); + } + + @Override + protected int getBottomMargin(Context context) { + return 0; + } + + @Override + protected int getLeftMargin(Context context) { + return context.getResources().getDimensionPixelSize(R.dimen.list_content_padding); + } +} diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java index 478c26b466..136e50deab 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java @@ -1,10 +1,6 @@ package net.osmand.plus.dashboard; -import android.content.Intent; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; import android.graphics.Typeface; -import android.os.Build; import android.os.Bundle; import android.support.design.widget.Snackbar; import android.support.v4.view.ViewCompat; @@ -15,19 +11,15 @@ import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; -import net.osmand.AndroidUtils; -import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; -import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmandActionBarActivity; import net.osmand.plus.dashboard.tools.DashFragmentData; -import net.osmand.plus.dialogs.ErrorBottomSheetDialog; +import net.osmand.plus.dialogs.CrashBottomSheetDialogFragment; import net.osmand.plus.helpers.FontCache; -import java.io.File; import java.text.MessageFormat; public class DashErrorFragment extends DashBaseFragment { @@ -38,7 +30,7 @@ public class DashErrorFragment extends DashBaseFragment { // If settings null. No changes in setting will be made. @Override public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) { - return ErrorBottomSheetDialog.shouldShow(settings, activity); + return CrashBottomSheetDialogFragment.shouldShow(settings, activity); } }; private DismissListener dismissCallback; diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 6be252d98d..09bb1d93e7 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -219,7 +219,7 @@ public class ConfigureMapMenu { } else if (itemId == R.string.layer_gpx_layer) { final GpxSelectionHelper selectedGpxHelper = ma.getMyApplication().getSelectedGpxHelper(); if (selectedGpxHelper.isShowingAnyGpxFiles()) { - selectedGpxHelper.clearAllGpxFileToShow(); + selectedGpxHelper.clearAllGpxFilesToShow(true); adapter.getItem(pos).setDescription(selectedGpxHelper.getGpxDescription()); } else { showGpxSelectionDialog(adapter, adapter.getItem(pos)); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/CrashBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/CrashBottomSheetDialogFragment.java new file mode 100644 index 0000000000..ded8574cf3 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/CrashBottomSheetDialogFragment.java @@ -0,0 +1,68 @@ +package net.osmand.plus.dialogs; + +import android.content.Context; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.FragmentManager; +import android.view.ContextThemeWrapper; +import android.view.View; + +import net.osmand.PlatformUtil; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem; + +import org.apache.commons.logging.Log; + +public class CrashBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { + public static final String TAG = "CrashBottomSheetDialogFragment"; + private static final Log LOG = PlatformUtil.getLog(CrashBottomSheetDialogFragment.class); + + @Override + public void createMenuItems(Bundle savedInstanceState) { + Context context = getContext(); + if (context == null) { + return; + } + + final View titleView = View.inflate(new ContextThemeWrapper(context, themeRes), R.layout.crash_title, null); + final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() + .setCustomView(titleView) + .create(); + items.add(titleItem); + } + + @Override + protected int getRightBottomButtonTextId() { + return R.string.shared_string_send; + } + + @Override + protected void onRightBottomButtonClick() { + OsmandApplication app = getMyApplication(); + if (app != null) { + app.sendCrashLog(); + } + dismiss(); + } + + public static boolean shouldShow(OsmandSettings settings, MapActivity activity) { + return activity.getMyApplication().getAppInitializer() + .checkPreviousRunsForExceptions(activity, settings != null); + } + + public static void showInstance(@NonNull FragmentManager fm) { + try { + if (fm.findFragmentByTag(CrashBottomSheetDialogFragment.TAG) == null) { + CrashBottomSheetDialogFragment fragment = new CrashBottomSheetDialogFragment(); + fragment.show(fm, CrashBottomSheetDialogFragment.TAG); + } + } catch (RuntimeException e) { + LOG.error("showInstance", e); + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/dialogs/DislikeOsmAndBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/DislikeOsmAndBottomSheetDialogFragment.java new file mode 100644 index 0000000000..4e39a67038 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/DislikeOsmAndBottomSheetDialogFragment.java @@ -0,0 +1,85 @@ +package net.osmand.plus.dialogs; + +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.FragmentManager; +import android.support.v7.view.ContextThemeWrapper; +import android.view.View; + +import net.osmand.PlatformUtil; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; + +import org.apache.commons.logging.Log; + +public class DislikeOsmAndBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { + public static final String TAG = "DislikeOsmAndBottomSheetDialogFragment"; + private static final Log LOG = PlatformUtil.getLog(DislikeOsmAndBottomSheetDialogFragment.class); + + @Override + public void createMenuItems(Bundle savedInstanceState) { + Context context = getContext(); + if (context == null) { + return; + } + + final View titleView = View.inflate(new ContextThemeWrapper(context, themeRes), R.layout.dislike_title, null); + final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() + .setCustomView(titleView) + .create(); + items.add(titleItem); + } + + @Override + protected int getDismissButtonTextId() { + return R.string.shared_string_cancel; + } + + @Override + protected void onDismissButtonClickAction() { + OsmandApplication app = getMyApplication(); + if (app != null) { + app.getSettings().RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITHOUT_MESSAGE); + } + } + + @Override + protected int getRightBottomButtonTextId() { + return R.string.shared_string_send; + } + + @Override + protected void onRightBottomButtonClick() { + OsmandApplication app = getMyApplication(); + if (app != null) { + OsmandSettings settings = app.getSettings(); + String email = getString(R.string.support_email); + settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITH_MESSAGE); + settings.NUMBER_OF_APPLICATION_STARTS.set(0); + settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis()); + Intent sendEmail = new Intent(Intent.ACTION_SENDTO); + sendEmail.setType("text/plain"); + sendEmail.setData(Uri.parse("mailto:" + email)); + sendEmail.putExtra(Intent.EXTRA_EMAIL, email); + startActivity(sendEmail); + dismiss(); + } + } + + public static void showInstance(@NonNull FragmentManager fm) { + try { + if (fm.findFragmentByTag(DislikeOsmAndBottomSheetDialogFragment.TAG) == null) { + DislikeOsmAndBottomSheetDialogFragment fragment = new DislikeOsmAndBottomSheetDialogFragment(); + fragment.show(fm, DislikeOsmAndBottomSheetDialogFragment.TAG); + } + } catch (RuntimeException e) { + LOG.error("showInstance", e); + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ErrorBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/dialogs/ErrorBottomSheetDialog.java deleted file mode 100644 index 4d812da350..0000000000 --- a/OsmAnd/src/net/osmand/plus/dialogs/ErrorBottomSheetDialog.java +++ /dev/null @@ -1,70 +0,0 @@ -package net.osmand.plus.dialogs; - -import android.graphics.Typeface; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.FragmentActivity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.TextView; - -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.OsmandActionBarActivity; -import net.osmand.plus.base.BottomSheetDialogFragment; -import net.osmand.plus.helpers.FontCache; - -import java.text.MessageFormat; - -public class ErrorBottomSheetDialog extends BottomSheetDialogFragment { - @Nullable - @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - FragmentActivity activity = requireActivity(); - OsmandApplication app = (OsmandApplication) activity.getApplication(); - View view = activity.getLayoutInflater().inflate(R.layout.dash_error_fragment, container, false); - String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH); - Typeface typeface = FontCache.getRobotoMedium(activity); - ImageView iv = ((ImageView) view.findViewById(R.id.error_icon)); - iv.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_crashlog)); - TextView message = ((TextView) view.findViewById(R.id.error_header)); - message.setTypeface(typeface); - message.setText(msg); - Button errorBtn = ((Button) view.findViewById(R.id.error_btn)); - errorBtn.setTypeface(typeface); - errorBtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - OsmandApplication app = getMyApplication(); - if (app != null) { - app.sendCrashLog(); - } - dismiss(); - } - }); - - Button cancelBtn = ((Button) view.findViewById(R.id.error_cancel)); - cancelBtn.setTypeface(typeface); - cancelBtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - OsmandActionBarActivity dashboardActivity = ((OsmandActionBarActivity) getActivity()); - if (dashboardActivity != null) { - dismiss(); - } - } - }); - return view; - } - - public static boolean shouldShow(OsmandSettings settings, MapActivity activity) { - return activity.getMyApplication().getAppInitializer() - .checkPreviousRunsForExceptions(activity, settings != null); - } -} diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java index c5663d87df..bd70893c37 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java @@ -83,7 +83,7 @@ public class RateUsBottomSheetDialog extends BottomSheetDialogFragment { } } // Initial state now - modifiedTime.add(Calendar.HOUR, -72); + modifiedTime.add(Calendar.MONTH, -1); bannerFreeRuns = 3; return modifiedTime.after(lastDisplayTime) && numberOfApplicationRuns >= bannerFreeRuns; } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialogFragment.java new file mode 100644 index 0000000000..51b46fc143 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialogFragment.java @@ -0,0 +1,87 @@ +package net.osmand.plus.dialogs; + +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.FragmentManager; +import android.view.ContextThemeWrapper; +import android.view.View; + +import net.osmand.PlatformUtil; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.Version; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem; + +import org.apache.commons.logging.Log; + +import java.util.Calendar; + +public class RateUsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { + public static final String TAG = "RateUsBottomSheetDialogFragment"; + private static final Log LOG = PlatformUtil.getLog(SendAnalyticsBottomSheetDialogFragment.class); + + @Override + public void createMenuItems(Bundle savedInstanceState) { + Context context = getContext(); + if (context == null) { + return; + } + + final View titleView = View.inflate(new ContextThemeWrapper(context, themeRes), R.layout.rate_us_title, null); + final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() + .setCustomView(titleView) + .create(); + items.add(titleItem); + } + + @Override + protected int getDismissButtonTextId() { + return R.string.shared_string_no; + } + + @Override + protected void onDismissButtonClickAction() { + FragmentManager fm = getFragmentManager(); + if (fm != null) { + DislikeOsmAndBottomSheetDialogFragment.showInstance(fm); + } + } + + @Override + protected int getRightBottomButtonTextId() { + return R.string.button_rate; + } + + @Override + protected void onRightBottomButtonClick() { + OsmandApplication app = getMyApplication(); + if (app != null) { + app.getSettings().RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.LIKED); + Uri uri = Uri.parse(Version.getUrlWithUtmRef(app, app.getPackageName())); + Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); + startActivity(goToMarket); + dismiss(); + } + } + + public static boolean shouldShow(OsmandApplication app) { + return RateUsBottomSheetDialog.shouldShow(app); + } + + public static void showInstance(@NonNull FragmentManager fm) { + try { + if (fm.findFragmentByTag(RateUsBottomSheetDialogFragment.TAG) == null) { + RateUsBottomSheetDialogFragment fragment = new RateUsBottomSheetDialogFragment(); + fragment.show(fm, RateUsBottomSheetDialogFragment.TAG); + } + } catch (RuntimeException e) { + LOG.error("showInstance", e); + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java new file mode 100644 index 0000000000..5de0ee13ca --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java @@ -0,0 +1,193 @@ +package net.osmand.plus.dialogs; + +import android.content.Context; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.FragmentManager; +import android.support.v4.content.ContextCompat; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.TextPaint; +import android.text.style.ForegroundColorSpan; +import android.text.style.URLSpan; +import android.view.ContextThemeWrapper; +import android.view.View; + +import net.osmand.PlatformUtil; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.OsmandSettings.OsmandPreference; +import net.osmand.plus.R; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitmeListDividerItem; +import net.osmand.plus.chooseplan.OsmLiveCancelledDialog; + +import org.apache.commons.logging.Log; + +public class SendAnalyticsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { + + public static final String TAG = "SendAnalyticsBottomSheetDialogFragment"; + private static final Log LOG = PlatformUtil.getLog(SendAnalyticsBottomSheetDialogFragment.class); + + private boolean sendAnonymousMapDownloadsData; + private boolean sendAnonymousAppUsageData; + + @Override + public void createMenuItems(Bundle savedInstanceState) { + OsmandApplication app = getMyApplication(); + Context context = getContext(); + if (context == null || app == null) { + return; + } + + final View titleView = View.inflate(new ContextThemeWrapper(context, themeRes), R.layout.make_better_title, null); + final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() + .setCustomView(titleView) + .create(); + items.add(titleItem); + + items.add(new SubtitleDividerItem(context)); + + sendAnonymousMapDownloadsData = app.getSettings().SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get(); + sendAnonymousAppUsageData = app.getSettings().SEND_ANONYMOUS_APP_USAGE_DATA.get(); + final BottomSheetItemWithCompoundButton[] downloadedMapsItem = new BottomSheetItemWithCompoundButton[1]; + downloadedMapsItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() + .setChecked(sendAnonymousMapDownloadsData) + .setTitle(getString(R.string.downloaded_maps)) + .setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean checked = !downloadedMapsItem[0].isChecked(); + downloadedMapsItem[0].setChecked(checked); + sendAnonymousMapDownloadsData = checked; + updateBottomButtons(); + } + }) + .setTag("downloaded_maps") + .create(); + items.add(downloadedMapsItem[0]); + + items.add(new LongDescriptionItem(getString(R.string.downloaded_maps_collect_descr))); + + items.add(new SubtitmeListDividerItem(context)); + + final BottomSheetItemWithCompoundButton[] visitedScreensItem = new BottomSheetItemWithCompoundButton[1]; + visitedScreensItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() + .setChecked(sendAnonymousAppUsageData) + .setTitle(getString(R.string.visited_screens)) + .setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean checked = !visitedScreensItem[0].isChecked(); + visitedScreensItem[0].setChecked(checked); + sendAnonymousAppUsageData = checked; + updateBottomButtons(); + } + }) + .setTag("visited_screens") + .create(); + items.add(visitedScreensItem[0]); + + items.add(new LongDescriptionItem(getString(R.string.visited_screens_collect_descr))); + + items.add(new DividerItem(context)); + + String privacyPolicyText = getString(R.string.shared_string_privacy_policy); + String text = getString(R.string.privacy_and_security_change_descr, privacyPolicyText); + + SpannableString spannable = new SpannableString(text); + int start = text.indexOf(privacyPolicyText); + int end = start + privacyPolicyText.length(); + spannable.setSpan(new URLSpan(OsmandApplication.OSMAND_PRIVACY_POLICY_URL) { + @Override + public void updateDrawState(@NonNull TextPaint ds) { + super.updateDrawState(ds); + ds.setUnderlineText(false); + } + }, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + int linkTextColor = ContextCompat.getColor(context, !nightMode ? R.color.ctx_menu_bottom_view_url_color_light : R.color.ctx_menu_bottom_view_url_color_dark); + spannable.setSpan(new ForegroundColorSpan(linkTextColor), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + + LongDescriptionItem descriptionItem = new LongDescriptionItem(spannable); + descriptionItem.setDescriptionLinksClickable(true); + items.add(descriptionItem); + } + + @Override + protected boolean isRightBottomButtonEnabled() { + return sendAnonymousMapDownloadsData || sendAnonymousAppUsageData; + } + + @Override + protected int getDismissButtonTextId() { + return R.string.shared_string_no_thank_you; + } + + @Override + protected int getRightBottomButtonTextId() { + return R.string.shared_string_allow; + } + + @Override + protected void onDismissButtonClickAction() { + OsmandApplication app = requiredMyApplication(); + OsmandSettings settings = app.getSettings(); + settings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.set(false); + settings.SEND_ANONYMOUS_APP_USAGE_DATA.set(false); + settings.SEND_ANONYMOUS_DATA_REQUEST_PROCESSED.set(true); + } + + @Override + protected void onRightBottomButtonClick() { + OsmandApplication app = requiredMyApplication(); + OsmandSettings settings = app.getSettings(); + settings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.set(sendAnonymousMapDownloadsData); + settings.SEND_ANONYMOUS_APP_USAGE_DATA.set(sendAnonymousAppUsageData); + settings.SEND_ANONYMOUS_DATA_REQUEST_PROCESSED.set(true); + dismiss(); + } + + public static boolean shouldShowDialog(@NonNull OsmandApplication app) { + OsmandSettings settings = app.getSettings(); + int requestsCount = settings.SEND_ANONYMOUS_DATA_REQUESTS_COUNT.get(); + long firstInstalledDays = app.getAppInitializer().getFirstInstalledDays(); + boolean requestProcessed = settings.SEND_ANONYMOUS_DATA_REQUEST_PROCESSED.get(); + if (!requestProcessed && firstInstalledDays >= 5 && firstInstalledDays <= 30 && requestsCount < 3) { + if (requestsCount == 0) { + return true; + } else { + int numberOfStarts = app.getAppInitializer().getNumberOfStarts(); + int lastRequestNS = settings.SEND_ANONYMOUS_DATA_LAST_REQUEST_NS.get(); + return numberOfStarts - lastRequestNS > 2; + } + } + return false; + } + + public static void showInstance(@NonNull OsmandApplication app, @NonNull FragmentManager fm) { + try { + if (fm.findFragmentByTag(SendAnalyticsBottomSheetDialogFragment.TAG) == null) { + SendAnalyticsBottomSheetDialogFragment fragment = new SendAnalyticsBottomSheetDialogFragment(); + fragment.show(fm, SendAnalyticsBottomSheetDialogFragment.TAG); + + OsmandSettings settings = app.getSettings(); + int numberOfStarts = app.getAppInitializer().getNumberOfStarts(); + OsmandPreference lastRequestNS = settings.SEND_ANONYMOUS_DATA_LAST_REQUEST_NS; + if (numberOfStarts != lastRequestNS.get()) { + OsmandPreference counter = settings.SEND_ANONYMOUS_DATA_REQUESTS_COUNT; + counter.set(counter.get() + 1); + lastRequestNS.set(numberOfStarts); + } + } + } catch (RuntimeException e) { + LOG.error("showInstance", e); + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index c3f5976c4a..c0a7701a81 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -613,7 +613,7 @@ public class GpxUiHelper { //clear all previously selected files before adding new one OsmandApplication app = (OsmandApplication) activity.getApplication(); if (app != null && app.getSelectedGpxHelper() != null) { - app.getSelectedGpxHelper().clearAllGpxFileToShow(); + app.getSelectedGpxHelper().clearAllGpxFilesToShow(false); } if (app != null && showCurrentGpx && adapter.getItem(0).getSelected()) { currentGPX = app.getSavingTrackHelper().getCurrentGpx(); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideGpxTracksAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideGpxTracksAction.java index a37d883b52..b63f6eff2a 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideGpxTracksAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/ShowHideGpxTracksAction.java @@ -36,7 +36,7 @@ public class ShowHideGpxTracksAction extends QuickAction { final GpxSelectionHelper selectedGpxHelper = activity.getMyApplication() .getSelectedGpxHelper(); if (selectedGpxHelper.isShowingAnyGpxFiles()) { - selectedGpxHelper.clearAllGpxFileToShow(); + selectedGpxHelper.clearAllGpxFilesToShow(true); } else { selectedGpxHelper.restoreSelectedGpxFiles(); } diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index 17b4da9d4b..5f5e63e700 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -154,6 +154,11 @@ public class MapRenderRepositories { return prevBmpLocation; } + public void updateSettings() { + prefs = context.getSettings(); + clearCache(); + } + public synchronized void closeConnection(String file) { LinkedHashMap cpfiles = new LinkedHashMap(files); BinaryMapIndexReader bmir = cpfiles.remove(file);