Version 3.0.362

This commit is contained in:
Anja 2023-04-05 15:02:10 +02:00
parent cba4da9357
commit 4ff3307997
128 changed files with 3954 additions and 3193 deletions

View file

@ -27,13 +27,6 @@ using TINK.Repository;
using TINK.Services.Geolocation;
using TINK.Model.State;
using TINK.ViewModel.Bikes;
using Location = Xamarin.Essentials.Location;
#if !TRYNOTBACKSTYLE
#endif
@ -63,8 +56,6 @@ namespace TINK.ViewModel.Map
/// </summary>
private ILocationPermission PermissionsService { get; }
private IGeolocation Geolocation { get; }
/// <summary>
/// Service to manage bluetooth stack.
/// </summary>
@ -110,7 +101,7 @@ namespace TINK.ViewModel.Map
/// <summary> False if user tabed on station marker to show bikes at a given station.</summary>
private bool isMapPageEnabled = false;
IGeolocation GeolocationService { get; }
IGeolocationService GeolocationService { get; }
/// <summary> False if user tabed on station marker to show bikes at a given station.</summary>
public bool IsMapPageEnabled
@ -135,7 +126,7 @@ namespace TINK.ViewModel.Map
ITinkApp tinkApp,
ILocationPermission permissionsService,
Plugin.BLE.Abstractions.Contracts.IBluetoothLE bluetoothService,
IGeolocation geolocationService,
IGeolocationService geolocationService,
Action<MapSpan> moveToRegionDelegate,
IViewService viewService,
INavigation navigation)
@ -197,6 +188,27 @@ namespace TINK.ViewModel.Map
set { m_oNavigationMasterDetail = value; }
}
#endif
/// <summary>
/// Counts the number of reserved or occupied bikes -> visualized in MyBikes-Icon
/// </summary>
public void GetMyBikesCount(BikeCollection bikesAll)
{
int MyBikesCount = 0;
Log.ForContext<MapPageViewModel>().Debug($"Number of reserved or rented bikes is extracted.");
if (bikesAll != null)
{
foreach (var bike in bikesAll)
{
if (bike.State.Value.IsOccupied())
{
MyBikesCount = MyBikesCount + 1;
continue;
}
}
}
MyBikesCountText = MyBikesCount > 0 ? string.Format(MyBikesCount.ToString()) : string.Empty;
}
public Command<PinClickedEventArgs> PinClickedCommand => new Command<PinClickedEventArgs>(
args =>
@ -243,7 +255,6 @@ namespace TINK.ViewModel.Map
{
Log.ForContext<MapPageViewModel>().Debug($"Starting update of stations pins color for {stationsColorList.Count} stations...");
int MyBikesCount = 0;
// Update colors of pins.
for (int pinIndex = 0; pinIndex < stationsColorList.Count; pinIndex++)
{
@ -253,11 +264,6 @@ namespace TINK.ViewModel.Map
: "Open"; // there is no station marker. Use open marker.
var colorPartPrefix = GetRessourceNameColorPart(stationsColorList[pinIndex]);
if (colorPartPrefix == "Blue" || colorPartPrefix == "LightBlue")
{
MyBikesCount = MyBikesCount + 1;
};
var name = $"{indexPartPrefix.ToString().PadLeft(2, '0')}_{colorPartPrefix}{(DeviceInfo.Platform == DevicePlatform.Android ? ".png" : string.Empty)}";
try
{
@ -273,8 +279,6 @@ namespace TINK.ViewModel.Map
Pins[pinIndex].IsVisible = true;
}
MyBikesCountText = MyBikesCount > 0 ? string.Format(MyBikesCount.ToString()) : string.Empty;
var pinsCount = Pins.Count;
for (int pinIndex = stationsColorList.Count; pinIndex < pinsCount; pinIndex++)
{
@ -343,6 +347,10 @@ namespace TINK.ViewModel.Map
IsProcessWithRunningProcessView = true;
IsNavBarVisible = false;
// Get and expose status of location permission
GetLocationPermissionStatus();
// Process map page.
Polling = TinkApp.Polling;
@ -350,7 +358,7 @@ namespace TINK.ViewModel.Map
$"{(Polling != null && Polling.IsActivated ? $"Map page is appearing. Update periode is {Polling.Periode.TotalSeconds} sec." : "Map page is appearing. Polling is off.")}" +
$"Current UI language is {Thread.CurrentThread.CurrentUICulture.Name}.");
// Update map page filter
// Update map page filter
ActiveFilterMap = TinkApp.GroupFilterMapPage;
ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
@ -393,6 +401,9 @@ namespace TINK.ViewModel.Map
Log.ForContext<MapPageViewModel>().Verbose("Update pins color done.");
// Load MyBikes Count -> MyBikes Icon/Button
GetMyBikesCount(resultStationsAndBikes.Response.Bikes);
// Move and scale before getting stations and bikes which takes some time.
ActionText = AppResources.ActivityTextCenterMap;
@ -460,6 +471,22 @@ namespace TINK.ViewModel.Map
}
}
/// <summary>
/// IsLocationPermissionGranted = true, if Location Permissions granted.
/// </summary>
private async void GetLocationPermissionStatus()
{
Log.ForContext<MapPageViewModel>().Verbose("Check Location permissions.");
var status = await PermissionsService.CheckStatusAsync();
IsLocationPermissionGranted = status == Status.Granted ? true : false;
Log.ForContext<MapPageViewModel>().Verbose("Location permissions: {0}.", status);
}
/// <summary>
/// Exposes IsLocationPermissionGranted.
/// </summary>
public bool IsLocationPermissionGranted{ get; set;}
/// <summary>
/// Invoked when the auth cookie is not defined.
/// </summary>
@ -536,7 +563,7 @@ namespace TINK.ViewModel.Map
/// </summary>
private async Task<Model.Map.IMapSpan> GetFromLocationService(Status status)
{
Location currentLocation = null;
IGeolocation currentLocation = null;
try
{
currentLocation = await GeolocationService.GetAsync();
@ -627,6 +654,9 @@ namespace TINK.ViewModel.Map
Log.ForContext<MapPageViewModel>().Error("Getting bikes and stations in polling context failed with exception {Exception}.", exception);
}
// Load MyBikes Count -> MyBikes Icon/Button
GetMyBikesCount(resultStationsAndBikes.Response.Bikes);
// Check if there are alreay any pins to the map.
// If no initialze pins.
if (Pins.Count <= 0)