diff --git a/OsmAnd/no_translate.xml b/OsmAnd/no_translate.xml
index 9a499ff9d8..ceaa3a3ca8 100644
--- a/OsmAnd/no_translate.xml
+++ b/OsmAnd/no_translate.xml
@@ -12,8 +12,10 @@
- - New road indexes (including)
- -
+ - New road indexes (including map data, poi, address)
+ - New speed system (knots and minutes per km)
+ - New context menu
+ - Drawer and start with the map
UA-28342846-2
10
diff --git a/OsmAnd/res/layout/favorite_categories_dialog.xml b/OsmAnd/res/layout/favorite_categories_dialog.xml
new file mode 100644
index 0000000000..cbe0b3625f
--- /dev/null
+++ b/OsmAnd/res/layout/favorite_categories_dialog.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/favorite_category_dialog_item.xml b/OsmAnd/res/layout/favorite_category_dialog_item.xml
new file mode 100644
index 0000000000..f8fdc8fd67
--- /dev/null
+++ b/OsmAnd/res/layout/favorite_category_dialog_item.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/point_editor_fragment.xml b/OsmAnd/res/layout/point_editor_fragment.xml
index 4a4a49050f..12a7cef4c2 100644
--- a/OsmAnd/res/layout/point_editor_fragment.xml
+++ b/OsmAnd/res/layout/point_editor_fragment.xml
@@ -114,6 +114,7 @@
android:layout_marginLeft="8dp"
android:textColor="?android:textColorPrimary"
android:textColorHint="?android:textColorSecondary"
+ android:text="Name"
android:inputType="text"/>
@@ -167,7 +168,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginRight="16dp"
- android:layout_marginLeft="8dp"/>
+ android:layout_marginLeft="8dp"
+ android:completionThreshold="1"
+ android:drawableRight="@drawable/ic_action_arrow_drop_down"/>
diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml
index e42411059f..b50e40cc0c 100644
--- a/OsmAnd/res/values-da/strings.xml
+++ b/OsmAnd/res/values-da/strings.xml
@@ -758,7 +758,7 @@
Kilometer/meter
yd
fod
- mi/t
+ mph
mil
Del placering ved hjælp af
Placering: %1$s
@@ -2143,4 +2143,21 @@
Optag ture
Navigation
Kører i baggrunden
+ Hastighedsmåling
+ nm
+ Sømil
+ Kilometer i timen
+ Mil i timen
+ Meter i sekundet
+ Minutter pr. kilometer
+ Minutter pr. mil
+ Sømil i timen (knob)
+ nmh
+ min/mil
+ min/km
+ m/s
+
+ Vælg enheder
+ Tilføj ny
+ Vælg kategori
diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml
index 98e0060242..43e99edefa 100644
--- a/OsmAnd/res/values-es-rAR/strings.xml
+++ b/OsmAnd/res/values-es-rAR/strings.xml
@@ -2060,10 +2060,25 @@
Parar simulación de ubicación
Simular usando grabación GPX o ruta calculada
Quedan %1$s descargas
-Grabando viaje
+Grabación de viaje
Navegación
Ejecutando en segundo plano
Información del favorito
Añadir favorito
Caminos
-
+Define el sistema de medición de velocidad
+ Medición de la velocidad
+ nm
+ Millas náuticas
+ Kilómetros por hora
+ Millas por hora
+ Metros por segundo
+ Minutos por kilómetro
+ Minutos por milla
+ Millas náuticas por hora (nudos)
+ nmh
+ min/m
+ min/km
+ m/s
+
+
diff --git a/OsmAnd/res/values-es/strings.xml b/OsmAnd/res/values-es/strings.xml
index 20c867ec2d..9cc0441375 100644
--- a/OsmAnd/res/values-es/strings.xml
+++ b/OsmAnd/res/values-es/strings.xml
@@ -2197,4 +2197,25 @@
Parar simulación de posición
Simular utilizando grabación GPX o ruta calculada
Quedan %$1s descargas
+Define el sistema de medición de velocidad
+ Medición de la velocidad
+ nm
+ Millas náuticas
+ Kilómetros por hora
+ Millas por hora
+ Metros por segundo
+ Minutos por kilómetro
+ Minutos por milla
+ Millas náuticas por hora (nudos)
+ nmh
+ min/m
+ min/km
+ m/s
+
+ Grabación de viaje
+ Navegación
+ Ejecutando en segundo plano
+ Información del favorito
+ Añadir favorito
+ Carreteras
diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml
index 7115a58147..5d91d811f0 100644
--- a/OsmAnd/res/values-fr/strings.xml
+++ b/OsmAnd/res/values-fr/strings.xml
@@ -2166,4 +2166,19 @@ Afghanistan, Albanie, Algérie, Allemagne, Andorre, Angola, Anguilla, Antigua-et
Enregistrement de l\'itinéraire
Navigation
Exécution en tâche de fond
+ Système de mesure de la vitesse
+ Mesure de vitesse
+ mn
+ Miles nautiques
+ Kilomètres par heure
+ Miles par heure
+ Mètres par seconde
+ Minutes par kilomètre
+ Minutes par mile
+ Nœuds (miles nautiques par heure)
+ noeuds
+ min/m
+ min/km
+ m/s
+
diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml
index 508e6474be..bc8a13af56 100644
--- a/OsmAnd/res/values-it/strings.xml
+++ b/OsmAnd/res/values-it/strings.xml
@@ -2187,4 +2187,19 @@ Si consiglia di aggiungere uno o più punti intermedi per migliorarne le prestaz
Registrazione viaggio
Navigazione
Avviato in backgroung
+ Definsci l\'unità di misura della velocità
+ Misurazione della velocità
+ nm
+ Miglia nautiche
+ Chilometri all\'ora
+ Miglia per ora
+ Metri al secondo
+ Minuti al chilometro
+ Minuti per miglia
+ Miglia nautiche per ora (knot)
+ nmh
+ min/m
+ min/km
+ m/s
+
diff --git a/OsmAnd/res/values-pl/phrases.xml b/OsmAnd/res/values-pl/phrases.xml
index e3dcbaf417..ec76fec83b 100644
--- a/OsmAnd/res/values-pl/phrases.xml
+++ b/OsmAnd/res/values-pl/phrases.xml
@@ -895,10 +895,10 @@
Tablica wyjaśniająca
Drzewo
Bramka (szerokość powozu)
- Sieć węzłów międzynarodowej sieci rowerowej
- Sieć węzłów krajowej sieci rowerowej
- Sieć węzłów regionalnej sieci rowerowej
- Sieć węzłów lokalnej sieci rowerowej
+ Międzynarodowa trasa rowerowa
+ Krajowa trasa rowerowa
+ Regionalna trasa rowerowa
+ Lokalna trasa rowerowa
Sieć węzłów międzynarodowej sieci pieszej
Sieć węzłów krajowej sieci pieszej
Sieć węzłów regionalnej sieci pieszej
diff --git a/OsmAnd/res/values-pl/strings.xml b/OsmAnd/res/values-pl/strings.xml
index dfdb06c24f..883a1d033d 100644
--- a/OsmAnd/res/values-pl/strings.xml
+++ b/OsmAnd/res/values-pl/strings.xml
@@ -2241,4 +2241,9 @@ Afganistan, Afryka Południowa, Albania, Algieria, Andora, Angola, Anguilla, Ant
Adres nie jest jeszcze znany
Wszelkie niezapisane zmiany zostaną utracone. Kontynuować?
Czy na pewno?
-
+ Nawigacja
+ Uruchomiona w tle
+ Zatrzymaj symulację pozycji
+ Dodaj do ulubionych
+ Drogi
+
diff --git a/OsmAnd/res/values-sl/strings.xml b/OsmAnd/res/values-sl/strings.xml
index 047fbf9b17..a4f90d6815 100644
--- a/OsmAnd/res/values-sl/strings.xml
+++ b/OsmAnd/res/values-sl/strings.xml
@@ -1995,4 +1995,21 @@
Delovanje v ozadju
Podrobnosti o točki
Dodaj priljubljeno
-
+ Dodaj novo
+ Izberi kategorijo
+ Določi sistem merjenja hitrosti
+ Merjenje hitrosti
+ nmi
+ Morske milje
+ Kilometri na uro
+ Milje na uro
+ Metri na sekundo
+ Minute na kilometer
+ Minute na miljo
+ Morske milje na uro (vozli)
+ nmi/h
+ min/m
+ min/km
+ m/s
+
+
diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml
index f8834fdb8f..55d94ba509 100644
--- a/OsmAnd/res/values-sv/strings.xml
+++ b/OsmAnd/res/values-sv/strings.xml
@@ -2005,4 +2005,16 @@
Information om favoriter
Vägar
Lägg till favorit
-
+ Ange system för hastighetsmätning
+ Hastighetsmätning
+ Sjömil
+ Kilometer i timmen
+ Engelska mil i timmen
+ Meter i sekunden
+ Minuter per kilometer
+ Minuter per engelsk mil
+ Sjömil i timmen (knop)
+ Trippinspelning
+ Navigering
+ Körs i bakgrunden
+
diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml
index ad6bfbedc5..2e34022fcf 100644
--- a/OsmAnd/res/values-zh-rTW/strings.xml
+++ b/OsmAnd/res/values-zh-rTW/strings.xml
@@ -2122,4 +2122,21 @@
旅程錄製
導航
在背景執行
+ 定義速度測定系統
+ 測定速度
+ 海浬
+ 浬
+ 公里每小時
+ 英里每小時
+ 公尺每秒
+ 分鐘每公里
+ 分鐘每英里
+ 海浬每小時 (節)
+ 分/公尺
+ 分/公里
+ 秒/公尺
+
+ 浬時
+ 增加新的
+ 選擇類別
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 7bb36f80d2..295ad10e00 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -1,4 +1,4 @@
-
+
+ Add new
+ Select category
+ Define speed measurement system
+ Speed measurement
+ nm
+ Nautical miles
+ Kilometers per hour
+ Miles per hour
+ Meters per second
+ Minutes per kilometer
+ Minutes per mile
+ Nautical miles per hour (knot)
+ nmh
+ min/m
+ min/km
+ m/s
+
Trip recording
Navigation
Running in background
diff --git a/OsmAnd/res/xml/navigation_settings.xml b/OsmAnd/res/xml/navigation_settings.xml
index 0311d493b2..8330ea05ff 100644
--- a/OsmAnd/res/xml/navigation_settings.xml
+++ b/OsmAnd/res/xml/navigation_settings.xml
@@ -23,6 +23,11 @@
android:key="arrival_distance_factor"
android:title="@string/arrival_distance"
android:summary="@string/arrival_distance_descr" />
+
+
points = new ArrayList();
public List splitByDistance(double meters) {
- return split(getDistanceMetric(), meters);
+ return split(getDistanceMetric(), getTimeSplit(), meters);
}
public List splitByTime(int seconds) {
- return split(getTimeSplit(), seconds);
+ return split(getTimeSplit(), getDistanceMetric(), seconds);
}
- private List split(SplitMetric metric, double metricLimit) {
+ private List split(SplitMetric metric, SplitMetric secondaryMetric, double metricLimit) {
List splitSegments = new ArrayList();
- splitSegment(metric, metricLimit, splitSegments, this);
+ splitSegment(metric, secondaryMetric, metricLimit, splitSegments, this);
return convert(splitSegments);
}
@@ -193,6 +193,7 @@ public class GPXUtilities {
public int wptPoints = 0;
public double metricEnd;
+ public double secondaryMetricEnd;
public WptPt locationStart;
public WptPt locationEnd;
@@ -242,6 +243,7 @@ public class GPXUtilities {
channelThres = channelThresMin;
metricEnd += s.metricEnd;
+ secondaryMetricEnd += s.secondaryMetricEnd;
points += numberOfPoints;
for (int j = 0; j < numberOfPoints; j++) {
WptPt point = s.get(j);
@@ -390,6 +392,7 @@ public class GPXUtilities {
double endCoeff = 0;
int endPointInd;
double metricEnd;
+ double secondaryMetricEnd;
public SplitSegment(TrkSegment s) {
startPointInd = 0;
@@ -497,9 +500,11 @@ public class GPXUtilities {
}
- private static void splitSegment(SplitMetric metric, double metricLimit, List splitSegments,
+ private static void splitSegment(SplitMetric metric, SplitMetric secondaryMetric,
+ double metricLimit, List splitSegments,
TrkSegment segment) {
double currentMetricEnd = metricLimit;
+ double secondaryMetricEnd = 0;
SplitSegment sp = new SplitSegment(segment, 0, 0);
double total = 0;
WptPt prev = null ;
@@ -507,11 +512,13 @@ public class GPXUtilities {
WptPt point = segment.points.get(k);
if (k > 0) {
double currentSegment = metric.metric(prev, point);
+ secondaryMetricEnd += secondaryMetric.metric(prev, point);
while (total + currentSegment > currentMetricEnd) {
double p = currentMetricEnd - total;
double cf = (p / currentSegment);
sp.setLastPoint(k - 1, cf);
sp.metricEnd = currentMetricEnd;
+ sp.secondaryMetricEnd = secondaryMetricEnd;
splitSegments.add(sp);
sp = new SplitSegment(segment, k - 1, cf);
@@ -525,6 +532,7 @@ public class GPXUtilities {
if (segment.points.size() > 0
&& !(sp.endPointInd == segment.points.size() - 1 && sp.startCoeff == 1)) {
sp.metricEnd = total;
+ sp.secondaryMetricEnd = secondaryMetricEnd;
sp.setLastPoint(segment.points.size() - 2, 1);
splitSegments.add(sp);
}
diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
index 6a0bf34452..0036c70416 100644
--- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
+++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
@@ -180,7 +180,9 @@ public class GpxSelectionHelper {
item.group = group;
if(split) {
item.splitMetric = analysis.metricEnd;
+ item.secondarySplitMetric = analysis.secondaryMetricEnd;
item.splitName = formatSplitName(analysis.metricEnd, group, app);
+ item.splitName += " ("+formatSecondarySplitName(analysis.secondaryMetricEnd, group, app) +") ";
}
item.description = GpxUiHelper.getDescription(app, analysis, true);
@@ -234,6 +236,14 @@ public class GpxSelectionHelper {
}
}
}
+
+ private static String formatSecondarySplitName(double metricEnd, GpxDisplayGroup group, OsmandApplication app) {
+ if (group.isSplitDistance()) {
+ return Algorithms.formatDuration((int) metricEnd);
+ } else {
+ return OsmAndFormatter.getFormattedDistance((float) metricEnd, app);
+ }
+ }
private static String formatSplitName(double metricEnd, GpxDisplayGroup group, OsmandApplication app) {
if (group.isSplitDistance()) {
@@ -607,6 +617,7 @@ public class GpxSelectionHelper {
public WptPt locationStart;
public WptPt locationEnd;
public double splitMetric = -1;
+ public double secondarySplitMetric = -1;
public String splitName;
public String name;
public String description;
diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java
index c2034ed1ee..a8eecf693c 100644
--- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java
+++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java
@@ -11,12 +11,15 @@ import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandSettings.MetricsConstants;
+import net.osmand.plus.OsmandSettings.SpeedConstants;
import net.osmand.util.Algorithms;
import android.content.Context;
public class OsmAndFormatter {
public final static float METERS_IN_KILOMETER = 1000f;
public final static float METERS_IN_ONE_MILE = 1609.344f; // 1609.344
+ public final static float METERS_IN_ONE_NAUTICALMILE = 1852f; // 1852
+
public final static float YARDS_IN_ONE_METER = 1.0936f;
public final static float FOOTS_IN_ONE_METER = YARDS_IN_ONE_METER * 3f;
private static final DecimalFormat fixed2 = new DecimalFormat("0.00");
@@ -36,6 +39,9 @@ public class OsmAndFormatter {
if (mc == MetricsConstants.MILES_AND_FOOTS) {
mainUnitInMeter = FOOTS_IN_ONE_METER;
metersInSecondUnit = METERS_IN_ONE_MILE;
+ } else if (mc == MetricsConstants.NAUTICAL_MILES) {
+ mainUnitInMeter = 1;
+ metersInSecondUnit = METERS_IN_ONE_NAUTICALMILE;
} else if (mc == MetricsConstants.MILES_AND_YARDS) {
mainUnitInMeter = YARDS_IN_ONE_METER;
metersInSecondUnit = METERS_IN_ONE_MILE;
@@ -84,6 +90,9 @@ public class OsmAndFormatter {
if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
mainUnitStr = R.string.km;
mainUnitInMeters = METERS_IN_KILOMETER;
+ } else if (mc == MetricsConstants.NAUTICAL_MILES) {
+ mainUnitStr = R.string.nm;
+ mainUnitInMeters = METERS_IN_ONE_NAUTICALMILE;
} else {
mainUnitStr = R.string.mile;
mainUnitInMeters = METERS_IN_ONE_MILE;
@@ -95,6 +104,8 @@ public class OsmAndFormatter {
return MessageFormat.format("{0,number,#.#} " + ctx.getString(mainUnitStr), ((float) meters) / mainUnitInMeters).replace('\n', ' '); //$NON-NLS-1$
} else if (meters > 0.999f * mainUnitInMeters) {
return MessageFormat.format("{0,number,#.##} " + ctx.getString(mainUnitStr), ((float) meters) / mainUnitInMeters).replace('\n', ' '); //$NON-NLS-1$
+ } else if (mc == MetricsConstants.NAUTICAL_MILES && meters > 0.09f * mainUnitInMeters) {
+ return MessageFormat.format("{0,number,.##} " + ctx.getString(mainUnitStr), ((float) meters) / mainUnitInMeters).replace('\n', ' '); //$NON-NLS-1$
} else {
if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
return ((int) (meters + 0.5)) + " " + ctx.getString(R.string.m); //$NON-NLS-1$
@@ -121,25 +132,62 @@ public class OsmAndFormatter {
public static String getFormattedSpeed(float metersperseconds, OsmandApplication ctx) {
OsmandSettings settings = ctx.getSettings();
- MetricsConstants mc = settings.METRIC_SYSTEM.get();
+ SpeedConstants mc = settings.SPEED_SYSTEM.get();
ApplicationMode am = settings.getApplicationMode();
float kmh = metersperseconds * 3.6f;
- if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
+ if (mc == SpeedConstants.KILOMETERS_PER_HOUR) {
// e.g. car case and for high-speeds: Display rounded to 1 km/h (5% precision at 20 km/h)
if (kmh >= 20 || am.hasFastSpeed()) {
- return ((int) Math.round(kmh)) + " " + ctx.getString(R.string.km_h);
+ return ((int) Math.round(kmh)) + " " + mc.toShortString(ctx);
}
// for smaller values display 1 decimal digit x.y km/h, (0.5% precision at 20 km/h)
int kmh10 = (int) Math.round(kmh * 10f);
- return (kmh10 / 10f) + " " + ctx.getString(R.string.km_h);
- } else {
+ return (kmh10 / 10f) + " " + mc.toShortString(ctx);
+ } else if (mc == SpeedConstants.MILES_PER_HOUR) {
float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE;
if (mph >= 20 || am.hasFastSpeed()) {
- return ((int) Math.round(mph)) + " " + ctx.getString(R.string.mile_per_hour);
+ return ((int) Math.round(mph)) + " " + mc.toShortString(ctx);
} else {
int mph10 = (int) Math.round(mph * 10f);
- return (mph10 / 10f) + " " + ctx.getString(R.string.mile_per_hour);
+ return (mph10 / 10f) + " " + mc.toShortString(ctx);
}
+ } else if (mc == SpeedConstants.NAUTICALMILES_PER_HOUR) {
+ float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_NAUTICALMILE;
+ if (mph >= 20 || am.hasFastSpeed()) {
+ return ((int) Math.round(mph)) + " " + mc.toShortString(ctx);
+ } else {
+ int mph10 = (int) Math.round(mph * 10f);
+ return (mph10 / 10f) + " " + mc.toShortString(ctx);
+ }
+ } else if (mc == SpeedConstants.MINUTES_PER_KILOMETER) {
+ if (metersperseconds < 0.111111111) {
+ return "-" + mc.toShortString(ctx);
+ }
+ float minperkm = METERS_IN_KILOMETER / (metersperseconds * 60);
+ if (minperkm >= 10) {
+ return ((int) Math.round(minperkm)) + " " + mc.toShortString(ctx);
+ } else {
+ int mph10 = (int) Math.round(minperkm * 10f);
+ return (mph10 / 10f) + " " + mc.toShortString(ctx);
+ }
+ } else if (mc == SpeedConstants.MINUTES_PER_MILE) {
+ if (metersperseconds < 0.111111111) {
+ return "-" + mc.toShortString(ctx);
+ }
+ float minperm = (METERS_IN_ONE_MILE) / (metersperseconds * 60);
+ if (minperm >= 10) {
+ return ((int) Math.round(minperm)) + " " + mc.toShortString(ctx);
+ } else {
+ int mph10 = (int) Math.round(minperm * 10f);
+ return (mph10 / 10f) + " " + mc.toShortString(ctx);
+ }
+ } else /*if (mc == SpeedConstants.METERS_PER_SECOND) */ {
+ if (metersperseconds >= 10) {
+ return ((int) Math.round(metersperseconds)) + " " + SpeedConstants.METERS_PER_SECOND.toShortString(ctx);
+ }
+ // for smaller values display 1 decimal digit x.y km/h, (0.5% precision at 20 km/h)
+ int kmh10 = (int) Math.round(metersperseconds * 10f);
+ return (kmh10 / 10f) + " " + SpeedConstants.METERS_PER_SECOND.toShortString(ctx);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index cd1cefaba6..d8f6d57849 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -1,15 +1,21 @@
package net.osmand.plus;
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.Configuration;
-import android.hardware.Sensor;
-import android.hardware.SensorManager;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Build;
-import android.os.Environment;
+import java.io.File;
+import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
import net.osmand.IndexConstants;
import net.osmand.StateChangedListener;
@@ -28,22 +34,15 @@ import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.render.RenderingRulesStorage;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.hardware.Sensor;
+import android.hardware.SensorManager;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Build;
+import android.os.Environment;
public class OsmandSettings {
@@ -312,22 +311,12 @@ public class OsmandSettings {
return ch;
}
- public T getProfileDefaultValue(){
+ public T getProfileDefaultValue(ApplicationMode mode){
if(global){
return defaultValue;
}
- if(defaultValues != null && defaultValues.containsKey(currentMode)){
- return defaultValues.get(currentMode);
- }
- return defaultValue;
- }
-
- protected T getDefaultValue(){
- if(global){
- return defaultValue;
- }
- if(defaultValues != null && defaultValues.containsKey(currentMode)){
- return defaultValues.get(currentMode);
+ if(defaultValues != null && defaultValues.containsKey(mode)){
+ return defaultValues.get(mode);
}
if(settingsAPI.contains(defaultProfilePreferences, getId())) {
return getValue(defaultProfilePreferences, defaultValue);
@@ -336,6 +325,10 @@ public class OsmandSettings {
}
}
+ protected T getDefaultValue(){
+ return getProfileDefaultValue(currentMode);
+ }
+
@Override
public void overrideDefaultValue(T newDefaultValue) {
this.defaultValue = newDefaultValue;
@@ -351,10 +344,7 @@ public class OsmandSettings {
if(global) {
return get();
}
- T defaultV = defaultValue;
- if(defaultValues != null && defaultValues.containsKey(currentMode)){
- defaultV = defaultValues.get(currentMode);
- }
+ T defaultV = getProfileDefaultValue(mode);
return getValue(getProfilePreferences(mode), defaultV);
}
@@ -364,7 +354,7 @@ public class OsmandSettings {
return cachedValue;
}
cachedPreference = getPreferences();
- cachedValue = getValue(cachedPreference, getDefaultValue());
+ cachedValue = getValue(cachedPreference, getProfileDefaultValue(currentMode));
return cachedValue;
}
@@ -375,10 +365,7 @@ public class OsmandSettings {
@Override
public void resetToDefault(){
- T o = defaultValue;
- if(defaultValues != null && defaultValues.containsKey(currentMode)){
- o = defaultValues.get(currentMode);
- }
+ T o = getProfileDefaultValue(currentMode);
set(o);
}
@@ -708,6 +695,34 @@ public class OsmandSettings {
}.makeGlobal().cache();
+ public final OsmandPreference SPEED_SYSTEM = new EnumIntPreference(
+ "default_speed_system", SpeedConstants.KILOMETERS_PER_HOUR, SpeedConstants.values()) {
+
+ @Override
+ public SpeedConstants getProfileDefaultValue(ApplicationMode mode) {
+ MetricsConstants mc = METRIC_SYSTEM.get();
+ if(mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
+ if(mc == MetricsConstants.KILOMETERS_AND_METERS) {
+ return SpeedConstants.MINUTES_PER_KILOMETER;
+ } else {
+ return SpeedConstants.MILES_PER_HOUR;
+ }
+ }
+ if(mode.isDerivedRoutingFrom(ApplicationMode.BOAT) ||
+ mode.isDerivedRoutingFrom(ApplicationMode.AIRCRAFT)) {
+ return SpeedConstants.NAUTICALMILES_PER_HOUR;
+ }
+ if(mc == MetricsConstants.NAUTICAL_MILES) {
+ return SpeedConstants.NAUTICALMILES_PER_HOUR;
+ } else if(mc == MetricsConstants.KILOMETERS_AND_METERS) {
+ return SpeedConstants.KILOMETERS_PER_HOUR;
+ } else {
+ return SpeedConstants.MILES_PER_HOUR;
+ }
+ };
+
+ }.makeProfile().cache();
+
// this value string is synchronized with settings_pref.xml preference name
// cache of metrics constants as they are used very often
@@ -1926,9 +1941,38 @@ public class OsmandSettings {
}
+
+ public enum SpeedConstants {
+ KILOMETERS_PER_HOUR(R.string.km_h, R.string.si_kmh),
+ MILES_PER_HOUR(R.string.mile_per_hour, R.string.si_mph),
+ METERS_PER_SECOND(R.string.m_s, R.string.si_m_s),
+ MINUTES_PER_MILE(R.string.min_mile, R.string.si_min_m),
+ MINUTES_PER_KILOMETER(R.string.min_km, R.string.si_min_km),
+ NAUTICALMILES_PER_HOUR(R.string.nm_h, R.string.si_nm_h);
+
+ private final int key;
+ private int descr;
+
+ SpeedConstants(int key, int descr) {
+ this.key = key;
+ this.descr = descr;
+ }
+
+ public String toHumanString(Context ctx){
+ return ctx.getString(descr);
+ }
+
+ public String toShortString(Context ctx){
+ return ctx.getString(key);
+ }
+
+
+ }
+
public enum MetricsConstants {
KILOMETERS_AND_METERS(R.string.si_km_m,"km-m"),
MILES_AND_FOOTS(R.string.si_mi_foots,"mi-f"),
+ NAUTICAL_MILES(R.string.si_nm,"nm"),
MILES_AND_YARDS(R.string.si_mi_yard,"mi-y");
private final int key;
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index dea1643ea7..f0a11418f2 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -660,6 +660,9 @@ public class MapActivity extends AccessibleActivity {
}
}
wakeLockHelper.onStop(this);
+ if(getMyApplication().getNavigationService() == null) {
+ getMyApplication().getNotificationHelper().removeServiceNotificationCompletely();
+ }
super.onStop();
}
@@ -671,9 +674,6 @@ public class MapActivity extends AccessibleActivity {
getMyApplication().unsubscribeInitListener(initListener);
mapViewTrackingUtilities.setMapView(null);
cancelNotification();
- if(getMyApplication().getNavigationService() == null) {
- getMyApplication().getNotificationHelper().removeServiceNotificationCompletely();
- }
app.getResourceManager().getMapTileDownloader().removeDownloaderCallback(mapView);
if (atlasMapRendererView != null) {
atlasMapRendererView.handleOnDestroy();
diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
index dc3b8235f6..59c81683d2 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
@@ -11,6 +11,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.AutoZoomMap;
import net.osmand.plus.OsmandSettings.OsmandPreference;
+import net.osmand.plus.OsmandSettings.SpeedConstants;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.routing.RouteProvider.RouteService;
@@ -136,6 +137,14 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
}
registerListPreference(settings.KEEP_INFORMING, screen, keepInformingNames, keepInformingValues);
+
+ SpeedConstants[] speedValues = SpeedConstants.values();
+ String[] speedNamesVls = new String[speedValues.length];
+ for(int i = 0; i < speedValues.length; i++) {
+ speedNamesVls[i] = speedValues[i].toHumanString(this);
+ };
+ registerListPreference(settings.SPEED_SYSTEM, screen, speedNamesVls, speedValues);
+
// screen power save option:
Integer[] screenPowerSaveValues = new Integer[] { 0, 5, 10, 15, 20, 30, 45, 60 };
String[] screenPowerSaveNames = new String[screenPowerSaveValues.length];
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java
index a0a992e825..53a2430db5 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java
@@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu.details;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.text.Html;
+import android.text.TextUtils;
import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.Gravity;
@@ -79,9 +80,10 @@ public class AmenityMenuBuilder extends MenuBuilder {
textView.setAutoLinkMask(Linkify.ALL);
textView.setLinksClickable(true);
+ textView.setEllipsize(TextUtils.TruncateAt.END);
if (isWiki) {
textView.setMinLines(1);
- textView.setMaxLines(5);
+ textView.setMaxLines(15);
}
textView.setText(text);
if (textColor > 0) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java
index 8cab303e8f..a2ec16bd13 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java
@@ -3,7 +3,6 @@ package net.osmand.plus.mapcontextmenu.editors;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
-import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@@ -11,6 +10,7 @@ import android.os.Bundle;
import net.osmand.data.FavouritePoint;
import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper;
+import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@@ -21,9 +21,11 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
private FavoritePointEditor editor;
private FavouritePoint favorite;
+ private FavoriteGroup group;
FavouritesDbHelper helper;
private boolean saved;
+ private int defaultColor;
@Override
public void onAttach(Activity activity) {
@@ -35,7 +37,12 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ boolean light = getMyApplication().getSettings().isLightContent();
+ defaultColor = light ? R.color.icon_color : R.color.icon_color_light;
+
favorite = editor.getFavorite();
+ group = helper.getGroup(favorite);
}
@Override
@@ -52,6 +59,12 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
}
}
+ @Override
+ public void setCategory(String name) {
+ group = helper.getGroup(name);
+ super.setCategory(name);
+ }
+
public static void showInstance(final MapActivity mapActivity) {
FavoritePointEditor editor = mapActivity.getFavoritePointEditor();
//int slideInAnim = editor.getSlideInAnimation();
@@ -71,8 +84,8 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
@Override
protected void save(final boolean needDismiss) {
- final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), getName(), getCategory());
- point.setDescription(getDescription());
+ final FavouritePoint point = new FavouritePoint(favorite.getLatitude(), favorite.getLongitude(), getNameTextValue(), getCategoryTextValue());
+ point.setDescription(getDescriptionTextValue());
AlertDialog.Builder builder = FavouritesDbHelper.checkDuplicates(point, helper, getMapActivity());
if (favorite.getName().equals(point.getName()) &&
@@ -125,7 +138,6 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
@Override
protected void delete(final boolean needDismiss) {
- final Resources resources = this.getResources();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.favourites_remove_dialog_msg, favorite.getName()));
builder.setNegativeButton(R.string.shared_string_no, null);
@@ -143,39 +155,41 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
}
@Override
- public String getHeaderText() {
+ public String getHeaderCaption() {
return getMapActivity().getResources().getString(R.string.favourites_edit_dialog_title);
}
@Override
- public String getNameValue() {
+ public String getNameInitValue() {
return favorite.getName();
}
@Override
- public String getCategoryValue() {
+ public String getCategoryInitValue() {
return favorite.getCategory();
}
@Override
- public String getDescriptionValue() {
+ public String getDescriptionInitValue() {
return favorite.getDescription();
}
@Override
public Drawable getNameIcon() {
- return FavoriteImageDrawable.getOrCreate(getMapActivity(), favorite.getColor(), getMapActivity().getMapView().getCurrentRotatedTileBox().getDensity());
+ int color = defaultColor;
+ if (group != null) {
+ color = group.color;
+ }
+ return FavoriteImageDrawable.getOrCreate(getMapActivity(), color, getMapActivity().getMapView().getCurrentRotatedTileBox().getDensity());
}
@Override
public Drawable getCategoryIcon() {
- FavouritesDbHelper helper = getMyApplication().getFavorites();
- FavouritesDbHelper.FavoriteGroup group = helper.getGroup(favorite);
+ int color = defaultColor;
if (group != null) {
- return getIcon(R.drawable.ic_action_folder_stroke, group.color);
- } else {
- return null;
+ color = group.color;
}
+ return getIcon(R.drawable.ic_action_folder_stroke, color);
}
public Drawable getIcon(int resId, int color) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java
index 6c1ecee87b..129922fcf4 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragment.java
@@ -1,27 +1,25 @@
package net.osmand.plus.mapcontextmenu.editors;
import android.annotation.TargetApi;
-import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
-import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.ScrollView;
import android.widget.TextView;
import net.osmand.plus.FavouritesDbHelper;
@@ -29,7 +27,7 @@ import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
-import net.osmand.plus.helpers.AndroidUiHelper;
+import net.osmand.plus.mapcontextmenu.editors.dialogs.SelectCategoryDialogFragment;
import net.osmand.plus.widgets.AutoCompleteTextViewEx;
import net.osmand.util.Algorithms;
@@ -99,16 +97,16 @@ public abstract class PointEditorFragment extends Fragment {
}
TextView headerCaption = (TextView) view.findViewById(R.id.header_caption);
- headerCaption.setText(getHeaderText());
+ headerCaption.setText(getHeaderCaption());
TextView nameCaption = (TextView) view.findViewById(R.id.name_caption);
- nameCaption.setText(getNameText());
+ nameCaption.setText(getNameCaption());
TextView categoryCaption = (TextView) view.findViewById(R.id.category_caption);
- categoryCaption.setText(getCategoryText());
+ categoryCaption.setText(getCategoryCaption());
EditText nameEdit = (EditText) view.findViewById(R.id.name_edit);
- nameEdit.setText(getNameValue());
+ nameEdit.setText(getNameInitValue());
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
- categoryEdit.setText(getCategoryValue());
+ categoryEdit.setText(getCategoryInitValue());
categoryEdit.setThreshold(1);
final FavouritesDbHelper helper = getMyApplication().getFavorites();
List gs = helper.getFavoriteGroups();
@@ -117,10 +115,29 @@ public abstract class PointEditorFragment extends Fragment {
list[i] =gs.get(i).name;
}
categoryEdit.setAdapter(new ArrayAdapter<>(getMapActivity(), R.layout.list_textview, list));
+ categoryEdit.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(final View v, MotionEvent event) {
+ final EditText editText = (EditText) v;
+ final int DRAWABLE_RIGHT = 2;
+ if (event.getAction() == MotionEvent.ACTION_UP) {
+ if (event.getX() >= (editText.getRight()
+ - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width()
+ - editText.getPaddingRight())) {
+
+ DialogFragment dialogFragment =
+ SelectCategoryDialogFragment.createInstance();
+ dialogFragment.show(getChildFragmentManager(), "SelectCategoryDialogFragment");
+ return true;
+ }
+ }
+ return false;
+ }
+ });
EditText descriptionEdit = (EditText) view.findViewById(R.id.description_edit);
- if (getDescriptionValue() != null) {
- descriptionEdit.setText(getDescriptionValue());
+ if (getDescriptionInitValue() != null) {
+ descriptionEdit.setText(getDescriptionInitValue());
}
ImageView nameImage = (ImageView) view.findViewById(R.id.name_image);
@@ -172,9 +189,15 @@ public abstract class PointEditorFragment extends Fragment {
}
public abstract PointEditor getEditor();
-
public abstract String getToolbarTitle();
+ public void setCategory(String name) {
+ AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) getView().findViewById(R.id.category_edit);
+ categoryEdit.setText(name);
+ ImageView categoryImage = (ImageView) getView().findViewById(R.id.category_image);
+ categoryImage.setImageDrawable(getCategoryIcon());
+ }
+
protected MapActivity getMapActivity() {
return (MapActivity)getActivity();
}
@@ -201,33 +224,33 @@ public abstract class PointEditorFragment extends Fragment {
}
}
- public abstract String getHeaderText();
+ public abstract String getHeaderCaption();
- public String getNameText() {
+ public String getNameCaption() {
return getMapActivity().getResources().getString(R.string.favourites_edit_dialog_name);
}
- public String getCategoryText() {
+ public String getCategoryCaption() {
return getMapActivity().getResources().getString(R.string.favourites_edit_dialog_category);
}
- public abstract String getNameValue();
- public abstract String getCategoryValue();
- public abstract String getDescriptionValue();
+ public abstract String getNameInitValue();
+ public abstract String getCategoryInitValue();
+ public abstract String getDescriptionInitValue();
public abstract Drawable getNameIcon();
public abstract Drawable getCategoryIcon();
- public String getName() {
+ public String getNameTextValue() {
EditText nameEdit = (EditText) getView().findViewById(R.id.name_edit);
return nameEdit.getText().toString().trim();
}
- public String getCategory() {
+ public String getCategoryTextValue() {
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) getView().findViewById(R.id.category_edit);
return categoryEdit.getText().toString().trim();
}
- public String getDescription() {
+ public String getDescriptionTextValue() {
EditText descriptionEdit = (EditText) getView().findViewById(R.id.description_edit);
String res = descriptionEdit.getText().toString().trim();
return Algorithms.isEmpty(res) ? null : res;
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/dialogs/CategoryDialogs.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/dialogs/CategoryDialogs.java
deleted file mode 100644
index 0f4c8ad517..0000000000
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/dialogs/CategoryDialogs.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package net.osmand.plus.mapcontextmenu.editors.dialogs;
-
-public class CategoryDialogs {
-
-}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/dialogs/SelectCategoryDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/dialogs/SelectCategoryDialogFragment.java
new file mode 100644
index 0000000000..e5622c5fa3
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/dialogs/SelectCategoryDialogFragment.java
@@ -0,0 +1,95 @@
+package net.osmand.plus.mapcontextmenu.editors.dialogs;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.DialogFragment;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+
+import net.osmand.plus.FavouritesDbHelper;
+import net.osmand.plus.IconsCache;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+import net.osmand.plus.mapcontextmenu.editors.PointEditorFragment;
+
+import java.util.List;
+
+public class SelectCategoryDialogFragment extends DialogFragment {
+
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ builder.setTitle(R.string.favorite_category_select);
+ final View v = getActivity().getLayoutInflater().inflate(R.layout.favorite_categories_dialog, null, false);
+
+ LinearLayout ll = (LinearLayout) v.findViewById(R.id.list_container);
+
+ final FavouritesDbHelper helper = ((OsmandApplication) getActivity().getApplication()).getFavorites();
+ List gs = helper.getFavoriteGroups();
+ for (final FavouritesDbHelper.FavoriteGroup category : gs) {
+ View itemView = getActivity().getLayoutInflater().inflate(R.layout.favorite_category_dialog_item, null);
+ ImageView icon = (ImageView)itemView.findViewById(R.id.image_view);
+ if (category.color != 0) {
+ icon.setImageDrawable(getIcon(getActivity(), R.drawable.ic_action_folder, category.color));
+ } else {
+ icon.setImageDrawable(getIcon(getActivity(), R.drawable.ic_action_folder));
+ }
+ Button button = (Button)itemView.findViewById(R.id.button);
+ button.setText(category.name);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ((PointEditorFragment) getParentFragment()).setCategory(category.name);
+ dismiss();
+ }
+ });
+ ll.addView(itemView);
+ }
+ View itemView = getActivity().getLayoutInflater().inflate(R.layout.favorite_category_dialog_item, null);
+ ImageView icon = (ImageView)itemView.findViewById(R.id.image_view);
+ icon.setImageDrawable(getIcon(getActivity(), R.drawable.map_zoom_in));
+ Button button = (Button)itemView.findViewById(R.id.button);
+ button.setText(getActivity().getResources().getText(R.string.favorite_category_add_new));
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //((PointEditorFragment) getParentFragment()).setCategory(null);
+ //dismiss();
+ }
+ });
+ ll.addView(itemView);
+
+ builder.setView(v);
+ builder.setNegativeButton(R.string.shared_string_cancel, null);
+
+ return builder.create();
+ }
+
+ public static SelectCategoryDialogFragment createInstance() {
+ return new SelectCategoryDialogFragment();
+ }
+
+ private static Drawable getIcon(final Activity activity, int iconId) {
+ OsmandApplication app = (OsmandApplication)activity.getApplication();
+ IconsCache iconsCache = app.getIconsCache();
+ boolean light = app.getSettings().isLightContent();
+ return iconsCache.getIcon(iconId,
+ light ? R.color.icon_color : R.color.icon_color_light);
+ }
+
+ private static Drawable getIcon(final Activity activity, int resId, int color) {
+ OsmandApplication app = (OsmandApplication)activity.getApplication();
+ Drawable d = app.getResources().getDrawable(resId).mutate();
+ d.clearColorFilter();
+ d.setColorFilter(color, PorterDuff.Mode.SRC_IN);
+ return d;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java
index d6bd672edc..7559a2da5a 100644
--- a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java
+++ b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java
@@ -80,6 +80,9 @@ public class DashTrackFragment extends DashBaseFragment {
View mainView = getView();
final File dir = getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
final OsmandApplication app = getMyApplication();
+ if(app == null) {
+ return;
+ }
final List list = new ArrayList();
for(SelectedGpxFile sg : app.getSelectedGpxHelper().getSelectedGPXFiles() ) {
diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
index d320c44a28..d37db39c1e 100644
--- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
@@ -247,7 +247,8 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
items.add(R.string.gpx_start_new_segment);
if(settings.LIVE_MONITORING.get()) {
items.add(R.string.live_monitoring_stop);
- } else if(!settings.LIVE_MONITORING_URL.getProfileDefaultValue().equals(settings.LIVE_MONITORING_URL.get())){
+ } else if(!settings.LIVE_MONITORING_URL.getProfileDefaultValue(settings.APPLICATION_MODE.get()).
+ equals(settings.LIVE_MONITORING_URL.get())){
items.add(R.string.live_monitoring_start);
}
} else {
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java
index fa33ba1346..c3931b7f77 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java
@@ -183,7 +183,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) {
return;
}
- if (v == null) {
+ if (v == null || ctx == null || app == null) {
return;
}
final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get();