Skip to content

Commit

Permalink
Merge pull request #63 from johnjore/Fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
johnjore authored Oct 2, 2024
2 parents 7bbe4f5 + ba22f49 commit 4d00ecd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
17 changes: 13 additions & 4 deletions Fragments/Fragment_preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public override void OnCreatePreferences(Bundle? savedInstanceState, string? roo
SetPreferencesFromResource(Resource.Xml.Preferences, rootKey);

//Populate the ListPreference's
CreateArrayList((ListPreference)FindPreference(Platform.CurrentActivity?.GetString(Resource.String.OSM_Browse_Source)));
CreateArrayList((ListPreference)FindPreference(Platform.CurrentActivity?.GetString(Resource.String.OSM_BulkDownload_Source)));
CreateArrayList((ListPreference)FindPreference(Platform.CurrentActivity?.GetString(Resource.String.OSM_Browse_Source)), false);
CreateArrayList((ListPreference)FindPreference(Platform.CurrentActivity?.GetString(Resource.String.OSM_BulkDownload_Source)), true);

//Set Summary to "Not Set" or "Hidden" for sensitive fields
SetSummary((EditTextPreference)FindPreference(Platform.CurrentActivity?.GetString(Resource.String.MapboxToken)));
Expand All @@ -103,14 +103,23 @@ public override void OnCreatePreferences(Bundle? savedInstanceState, string? roo
PreferenceManager.GetDefaultSharedPreferences(Platform.AppContext)?.RegisterOnSharedPreferenceChangeListener(this);
}

private static void CreateArrayList(ListPreference? lp)
private static void CreateArrayList(ListPreference? lp, bool FilterOpenStreetMap)
{
if (lp == null)
{
return;
}

string[] entries = MapSources.Select(x => x.Name).ToArray();
string[] entries = [];
if (FilterOpenStreetMap)
{
//Remove OpenStreetMap entry, it can't be used for bulk downloads
entries = MapSources.Where(x => x.Name != "OpenStreetMap").Select(x => x.Name).ToArray();
}
else
{
entries = MapSources.Select(x => x.Name).ToArray();
}

lp.SetEntries(entries);
lp.SetEntryValues(entries);
Expand Down
3 changes: 3 additions & 0 deletions GPX/GPXAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ private void gpx_menu_showonmap(GPXViewHolder vh, ViewGroup parent)
{
Log.Information($"Show route on map '{vh.Name.Text}'");

//Enumerate route/tracks on Layer, and only add if not already displayed
/**/

//Get the route
var routetrack_2 = RouteDatabase.GetRouteAsync(vh.Id).Result;
GpxClass gpx_2 = GpxClass.FromXml(routetrack_2.GPX);
Expand Down
19 changes: 12 additions & 7 deletions Utils/DisplayMapItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void AddPOIToMap()
}
catch (Exception ex)
{
Serilog.Log.Fatal(ex, $"MapItems - AddPOIToMap");
Serilog.Log.Fatal(ex, $"DisplayMapItems - AddPOIToMap");
}
}

Expand All @@ -93,7 +93,7 @@ public static void AddRouteToMap(string mapRoute, GPXType gpxtype, bool UpdateMe
}
catch (Exception ex)
{
Serilog.Log.Fatal(ex, $"MapItems - AddRouteToMap()");
Serilog.Log.Fatal(ex, $"DisplayMapItems - AddRouteToMap()");
}

//Enable menu
Expand Down Expand Up @@ -127,19 +127,24 @@ public static void AddTracksToMap()
{
GpxClass gpx = GpxClass.FromXml(track.GPX);

//Reduce the number of waypoints before drawing on map
gpx = GPX.GPXOptimize.Optimize(gpx);

if (track.GPXType == GPXType.Track)
{
gpx.Routes.Add(gpx.Tracks[0].ToRoutes()[0]);
}
string? mapRouteTrack = Import.ParseGPXtoRoute(gpx.Routes[0]).Item1;

//Menus etc not yet created as app not fully initialized. Dirty workaround
AddRouteToMap(mapRouteTrack, GPXType.Track, false);
if (mapRouteTrack != null)
{
//Menus etc not yet created as app not fully initialized. Dirty workaround
AddRouteToMap(mapRouteTrack, GPXType.Track, false);
}
}
}
catch (Exception ex)
{
Serilog.Log.Fatal(ex, $"Import - AddTracksToMap()");
Serilog.Log.Fatal(ex, $"DisplayMapItems - AddTracksToMap()");
}
}

Expand Down Expand Up @@ -232,7 +237,7 @@ private static ILayer CreateRouteandTrackLayer(string strRoute, Mapsui.Styles.Co
}
catch (Exception ex)
{
Serilog.Log.Fatal(ex, $"MapItems - CreateRouteAndTrackLayer()");
Serilog.Log.Fatal(ex, $"DisplayMapItems - CreateRouteAndTrackLayer()");
}

return new MemoryLayer
Expand Down
6 changes: 3 additions & 3 deletions hajk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@
<PackageReference Include="Mapsui.Extensions" Version="4.1.7" />
<PackageReference Include="Mapsui.Nts" Version="4.1.7" />
<PackageReference Include="Microcharts.Android" Version="1.0.0-preview1" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.90" />
<PackageReference Include="Microsoft.Maui.Essentials" Version="8.0.90" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.91" />
<PackageReference Include="Microsoft.Maui.Essentials" Version="8.0.91" />
<PackageReference Include="Sentry" Version="4.11.0" />
<PackageReference Include="Sentry.Maui" Version="4.11.0" />
<PackageReference Include="Sentry.Serilog" Version="4.11.0" />
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Xamarin" Version="1.0.0" />
<PackageReference Include="SkiaSharp.Extended" Version="2.0.0" />
Expand Down

0 comments on commit 4d00ecd

Please sign in to comment.