This commit is contained in:
GaidamakUA 2015-09-29 16:02:50 +03:00
commit 857f525a44
31 changed files with 590 additions and 120 deletions

View file

@ -12,8 +12,10 @@
<!-- Not translatable -->
<string name="last_release">
- 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
</string>
<string name="ga_api_key">UA-28342846-2</string>
<string name="ga_dispatchPeriod">10</string>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/dialog_content_bottom_margin"
android:paddingLeft="@dimen/dialog_content_margin"
android:paddingRight="@dimen/dialog_content_margin"
android:paddingTop="@dimen/dialog_content_bottom_margin">
<LinearLayout
android:id="@+id/list_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="44dp"
android:layout_height="50dp">
<ImageView
android:id="@+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:scaleType="center"
android:src="@drawable/ic_action_folder"/>
</LinearLayout>
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_transparent"
android:text="Restaurant"
android:gravity="left|center_vertical"
android:textSize="@dimen/default_list_text_size"
android:textAllCaps="false"/>
</LinearLayout>

View file

@ -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"/>
</LinearLayout>

View file

@ -758,7 +758,7 @@
<string name="si_km_m">Kilometer/meter</string>
<string name="yard">yd</string>
<string name="foot">fod</string>
<string name="mile_per_hour">mi/t</string>
<string name="mile_per_hour">mph</string>
<string name="mile">mil</string>
<string name="send_location_way_choose_title">Del placering ved hjælp af</string>
<string name="send_location_sms_pattern">Placering: %1$s
@ -2143,4 +2143,21 @@
<string name="shared_string_trip_recording">Optag ture</string>
<string name="shared_string_navigation">Navigation</string>
<string name="osmand_running_in_background">Kører i baggrunden</string>
<string name="default_speed_system">Hastighedsmåling</string>
<string name="nm">nm</string>
<string name="si_nm">Sømil</string>
<string name="si_kmh">Kilometer i timen</string>
<string name="si_mph">Mil i timen</string>
<string name="si_m_s">Meter i sekundet</string>
<string name="si_min_km">Minutter pr. kilometer</string>
<string name="si_min_m">Minutter pr. mil</string>
<string name="si_nm_h">Sømil i timen (knob)</string>
<string name="nm_h">nmh</string>
<string name="min_mile">min/mil</string>
<string name="min_km">min/km</string>
<string name="m_s">m/s</string>
<string name="default_speed_system_descr">Vælg enheder</string>
<string name="favorite_category_add_new">Tilføj ny</string>
<string name="favorite_category_select">Vælg kategori</string>
</resources>

View file

@ -2060,10 +2060,25 @@
<string name="simulate_your_location_stop_descr">Parar simulación de ubicación</string>
<string name="simulate_your_location_descr">Simular usando grabación GPX o ruta calculada</string>
<string name="downloads_left_template">Quedan %1$s descargas</string>
<string name="shared_string_trip_recording">Grabando viaje</string>
<string name="shared_string_trip_recording">Grabación de viaje</string>
<string name="shared_string_navigation">Navegación</string>
<string name="osmand_running_in_background">Ejecutando en segundo plano</string>
<string name="favourites_edit_dialog_title">Información del favorito</string>
<string name="favourites_context_menu_add">Añadir favorito</string>
<string name="roads">Caminos</string>
<string name="default_speed_system_descr">Define el sistema de medición de velocidad</string>
<string name="default_speed_system">Medición de la velocidad</string>
<string name="nm">nm</string>
<string name="si_nm">Millas náuticas</string>
<string name="si_kmh">Kilómetros por hora</string>
<string name="si_mph">Millas por hora</string>
<string name="si_m_s">Metros por segundo</string>
<string name="si_min_km">Minutos por kilómetro</string>
<string name="si_min_m">Minutos por milla</string>
<string name="si_nm_h">Millas náuticas por hora (nudos)</string>
<string name="nm_h">nmh</string>
<string name="min_mile">min/m</string>
<string name="min_km">min/km</string>
<string name="m_s">m/s</string>
</resources>

View file

@ -2197,4 +2197,25 @@
<string name="simulate_your_location_stop_descr">Parar simulación de posición</string>
<string name="simulate_your_location_descr">Simular utilizando grabación GPX o ruta calculada</string>
<string name="downloads_left_template">Quedan %$1s descargas</string>
<string name="default_speed_system_descr">Define el sistema de medición de velocidad</string>
<string name="default_speed_system">Medición de la velocidad</string>
<string name="nm">nm</string>
<string name="si_nm">Millas náuticas</string>
<string name="si_kmh">Kilómetros por hora</string>
<string name="si_mph">Millas por hora</string>
<string name="si_m_s">Metros por segundo</string>
<string name="si_min_km">Minutos por kilómetro</string>
<string name="si_min_m">Minutos por milla</string>
<string name="si_nm_h">Millas náuticas por hora (nudos)</string>
<string name="nm_h">nmh</string>
<string name="min_mile">min/m</string>
<string name="min_km">min/km</string>
<string name="m_s">m/s</string>
<string name="shared_string_trip_recording">Grabación de viaje</string>
<string name="shared_string_navigation">Navegación</string>
<string name="osmand_running_in_background">Ejecutando en segundo plano</string>
<string name="favourites_edit_dialog_title">Información del favorito</string>
<string name="favourites_context_menu_add">Añadir favorito</string>
<string name="roads">Carreteras</string>
</resources>

View file

@ -2166,4 +2166,19 @@ Afghanistan, Albanie, Algérie, Allemagne, Andorre, Angola, Anguilla, Antigua-et
<string name="shared_string_trip_recording">Enregistrement de l\'itinéraire</string>
<string name="shared_string_navigation">Navigation</string>
<string name="osmand_running_in_background">Exécution en tâche de fond</string>
<string name="default_speed_system_descr">Système de mesure de la vitesse</string>
<string name="default_speed_system">Mesure de vitesse</string>
<string name="nm">mn</string>
<string name="si_nm">Miles nautiques</string>
<string name="si_kmh">Kilomètres par heure</string>
<string name="si_mph">Miles par heure</string>
<string name="si_m_s">Mètres par seconde</string>
<string name="si_min_km">Minutes par kilomètre</string>
<string name="si_min_m">Minutes par mile</string>
<string name="si_nm_h">Nœuds (miles nautiques par heure)</string>
<string name="nm_h">noeuds</string>
<string name="min_mile">min/m</string>
<string name="min_km">min/km</string>
<string name="m_s">m/s</string>
</resources>

View file

@ -2187,4 +2187,19 @@ Si consiglia di aggiungere uno o più punti intermedi per migliorarne le prestaz
<string name="shared_string_trip_recording">Registrazione viaggio</string>
<string name="shared_string_navigation">Navigazione</string>
<string name="osmand_running_in_background">Avviato in backgroung</string>
<string name="default_speed_system_descr">Definsci l\'unità di misura della velocità</string>
<string name="default_speed_system">Misurazione della velocità</string>
<string name="nm">nm</string>
<string name="si_nm">Miglia nautiche</string>
<string name="si_kmh">Chilometri all\'ora</string>
<string name="si_mph">Miglia per ora</string>
<string name="si_m_s">Metri al secondo</string>
<string name="si_min_km">Minuti al chilometro</string>
<string name="si_min_m">Minuti per miglia</string>
<string name="si_nm_h">Miglia nautiche per ora (knot)</string>
<string name="nm_h">nmh</string>
<string name="min_mile">min/m</string>
<string name="min_km">min/km</string>
<string name="m_s">m/s</string>
</resources>

View file

@ -895,10 +895,10 @@
<string name="poi_cutline">Tablica wyjaśniająca</string>
<string name="poi_tree">Drzewo</string>
<string name="poi_kent_carriage_gap">Bramka (szerokość powozu)</string>
<string name="poi_icn_ref">Sieć węzłów międzynarodowej sieci rowerowej</string>
<string name="poi_ncn_ref">Sieć węzłów krajowej sieci rowerowej</string>
<string name="poi_rcn_ref">Sieć węzłów regionalnej sieci rowerowej</string>
<string name="poi_lcn_ref">Sieć węzłów lokalnej sieci rowerowej</string>
<string name="poi_icn_ref">Międzynarodowa trasa rowerowa</string>
<string name="poi_ncn_ref">Krajowa trasa rowerowa</string>
<string name="poi_rcn_ref">Regionalna trasa rowerowa</string>
<string name="poi_lcn_ref">Lokalna trasa rowerowa</string>
<string name="poi_iwn_ref">Sieć węzłów międzynarodowej sieci pieszej</string>
<string name="poi_nwn_ref">Sieć węzłów krajowej sieci pieszej</string>
<string name="poi_rwn_ref">Sieć węzłów regionalnej sieci pieszej</string>

View file

@ -2241,4 +2241,9 @@ Afganistan, Afryka Południowa, Albania, Algieria, Andora, Angola, Anguilla, Ant
<string name="address_unknown">Adres nie jest jeszcze znany</string>
<string name="unsaved_changes_will_be_lost">Wszelkie niezapisane zmiany zostaną utracone. Kontynuować?</string>
<string name="are_you_sure">Czy na pewno?</string>
<string name="shared_string_navigation">Nawigacja</string>
<string name="osmand_running_in_background">Uruchomiona w tle</string>
<string name="simulate_your_location_stop_descr">Zatrzymaj symulację pozycji</string>
<string name="favourites_context_menu_add">Dodaj do ulubionych</string>
<string name="roads">Drogi</string>
</resources>

View file

@ -1995,4 +1995,21 @@
<string name="osmand_running_in_background">Delovanje v ozadju</string>
<string name="favourites_edit_dialog_title">Podrobnosti o točki</string>
<string name="favourites_context_menu_add">Dodaj priljubljeno</string>
<string name="favorite_category_add_new">Dodaj novo</string>
<string name="favorite_category_select">Izberi kategorijo</string>
<string name="default_speed_system_descr">Določi sistem merjenja hitrosti</string>
<string name="default_speed_system">Merjenje hitrosti</string>
<string name="nm">nmi</string>
<string name="si_nm">Morske milje</string>
<string name="si_kmh">Kilometri na uro</string>
<string name="si_mph">Milje na uro</string>
<string name="si_m_s">Metri na sekundo</string>
<string name="si_min_km">Minute na kilometer</string>
<string name="si_min_m">Minute na miljo</string>
<string name="si_nm_h">Morske milje na uro (vozli)</string>
<string name="nm_h">nmi/h</string>
<string name="min_mile">min/m</string>
<string name="min_km">min/km</string>
<string name="m_s">m/s</string>
</resources>

View file

@ -2005,4 +2005,16 @@
<string name="favourites_edit_dialog_title">Information om favoriter</string>
<string name="roads">Vägar</string>
<string name="favourites_context_menu_add">Lägg till favorit</string>
<string name="default_speed_system_descr">Ange system för hastighetsmätning</string>
<string name="default_speed_system">Hastighetsmätning</string>
<string name="si_nm">Sjömil</string>
<string name="si_kmh">Kilometer i timmen</string>
<string name="si_mph">Engelska mil i timmen</string>
<string name="si_m_s">Meter i sekunden</string>
<string name="si_min_km">Minuter per kilometer</string>
<string name="si_min_m">Minuter per engelsk mil</string>
<string name="si_nm_h">Sjömil i timmen (knop)</string>
<string name="shared_string_trip_recording">Trippinspelning</string>
<string name="shared_string_navigation">Navigering</string>
<string name="osmand_running_in_background">Körs i bakgrunden</string>
</resources>

View file

@ -2122,4 +2122,21 @@
<string name="shared_string_trip_recording">旅程錄製</string>
<string name="shared_string_navigation">導航</string>
<string name="osmand_running_in_background">在背景執行</string>
<string name="default_speed_system_descr">定義速度測定系統</string>
<string name="default_speed_system">測定速度</string>
<string name="si_nm">海浬</string>
<string name="nm"></string>
<string name="si_kmh">公里每小時</string>
<string name="si_mph">英里每小時</string>
<string name="si_m_s">公尺每秒</string>
<string name="si_min_km">分鐘每公里</string>
<string name="si_min_m">分鐘每英里</string>
<string name="si_nm_h">海浬每小時 (節)</string>
<string name="min_mile">分/公尺</string>
<string name="min_km">分/公里</string>
<string name="m_s">秒/公尺</string>
<string name="nm_h">浬時</string>
<string name="favorite_category_add_new">增加新的</string>
<string name="favorite_category_select">選擇類別</string>
</resources>

View file

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='utf-8'?>
<resources>
<!--
Disclaimer:
@ -9,6 +9,23 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="favorite_category_add_new">Add new</string>
<string name="favorite_category_select">Select category</string>
<string name="default_speed_system_descr">Define speed measurement system</string>
<string name="default_speed_system">Speed measurement</string>
<string name="nm">nm</string>
<string name="si_nm">Nautical miles</string>
<string name="si_kmh">Kilometers per hour</string>
<string name="si_mph">Miles per hour</string>
<string name="si_m_s">Meters per second</string>
<string name="si_min_km">Minutes per kilometer</string>
<string name="si_min_m">Minutes per mile</string>
<string name="si_nm_h">Nautical miles per hour (knot)</string>
<string name="nm_h">nmh</string>
<string name="min_mile">min/m</string>
<string name="min_km">min/km</string>
<string name="m_s">m/s</string>
<string name="shared_string_trip_recording">Trip recording</string>
<string name="shared_string_navigation">Navigation</string>
<string name="osmand_running_in_background">Running in background</string>

View file

@ -23,6 +23,11 @@
android:key="arrival_distance_factor"
android:title="@string/arrival_distance"
android:summary="@string/arrival_distance_descr" />
<ListPreference
android:key="default_speed_system"
android:title="@string/default_speed_system"
android:summary="@string/default_speed_system_descr" />
<ListPreference
android:key="speed_limit_exceed"
android:title="@string/speed_limit_exceed"

View file

@ -435,6 +435,14 @@ public class FavouritesDbHelper {
}
}
public FavoriteGroup getGroup(String name) {
if (flatGroups.containsKey(name)) {
return flatGroups.get(name);
} else {
return null;
}
}
private FavouritePoint findFavoriteByAllProperties(String category, String name, double lat, double lon){
if (flatGroups.containsKey(category)) {
FavoriteGroup fg = flatGroups.get(category);

View file

@ -142,16 +142,16 @@ public class GPXUtilities {
public List<WptPt> points = new ArrayList<WptPt>();
public List<GPXTrackAnalysis> splitByDistance(double meters) {
return split(getDistanceMetric(), meters);
return split(getDistanceMetric(), getTimeSplit(), meters);
}
public List<GPXTrackAnalysis> splitByTime(int seconds) {
return split(getTimeSplit(), seconds);
return split(getTimeSplit(), getDistanceMetric(), seconds);
}
private List<GPXTrackAnalysis> split(SplitMetric metric, double metricLimit) {
private List<GPXTrackAnalysis> split(SplitMetric metric, SplitMetric secondaryMetric, double metricLimit) {
List<SplitSegment> splitSegments = new ArrayList<GPXUtilities.SplitSegment>();
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<SplitSegment> splitSegments,
private static void splitSegment(SplitMetric metric, SplitMetric secondaryMetric,
double metricLimit, List<SplitSegment> 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);
}

View file

@ -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);
@ -235,6 +237,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()) {
MetricsConstants mc = app.getSettings().METRIC_SYSTEM.get();
@ -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;

View file

@ -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);
}
}

View file

@ -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<SpeedConstants> SPEED_SYSTEM = new EnumIntPreference<SpeedConstants>(
"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;

View file

@ -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();

View file

@ -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];

View file

@ -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) {

View file

@ -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) {

View file

@ -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<FavouritesDbHelper.FavoriteGroup> 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;

View file

@ -1,5 +0,0 @@
package net.osmand.plus.mapcontextmenu.editors.dialogs;
public class CategoryDialogs {
}

View file

@ -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<FavouritesDbHelper.FavoriteGroup> 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;
}
}

View file

@ -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<String> list = new ArrayList<String>();
for(SelectedGpxFile sg : app.getSelectedGpxHelper().getSelectedGPXFiles() ) {

View file

@ -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 {

View file

@ -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();