Version 3.0.356

This commit is contained in:
Oliver Hauff 2022-12-27 21:08:09 +01:00
parent d23aff6daf
commit 5980410182
48 changed files with 242 additions and 362 deletions

View file

@ -858,98 +858,6 @@ namespace TINK.ViewModel.Map
}
}
/// <summary> Command object to bind CurrentLocation Button to view model.</summary>
public System.Windows.Input.ICommand OnCurrentLocationButtonClicked => new Xamarin.Forms.Command(async () => await CenterToCurrentLocation());
/// <summary> User request to center to currentLocation. </summary>
public async Task CenterToCurrentLocation()
{
try
{
ActionText = AppResources.ActivityTextCenterMap;
IsMapPageEnabled = false;
Log.ForContext<MapPageViewModel>().Information($"Request to center to current position.");
// Stop polling.
//ActionText = AppResources.ActivityTextOneMomentPlease;
await m_oViewUpdateManager.StopUpdatePeridically();
// Clear error info.
Exception = null;
ActiveFilterMap = tinkKonradToggleViewModel.FilterDictionary;
TinkApp.GroupFilterMapPage = ActiveFilterMap;
TinkApp.Save();
TinkApp.UpdateConnector();
// Check location permission
var status = await RequestLocationPermission();
if (status == Status.Granted)
{
// Move and scale.
Location currentLocation = null;
try
{
currentLocation = await GeolocationService.GetAsync();
}
catch (Exception ex)
{
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
}
if (currentLocation != null)
{
ActionText = AppResources.ActivityTextCenterMap;
TinkApp.UserMapSpan = MapSpan.FromCenterAndRadius(
new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
TinkApp.ActiveMapSpan.Radius);
TinkApp.Save();
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.ActiveMapSpan);
try
{
// Update bikes at station or my bikes depending on context.
await m_oViewUpdateManager.StartUpdateAyncPeridically(Polling);
}
catch (Exception)
{
// Excpetions are handled insde update task;
}
}
else
{
await ViewService.DisplayAlert(
AppResources.MessageTitleHint,
AppResources.MessageErrorLocationIsOff,
AppResources.MessageAnswerOk);
}
}
IsMapPageEnabled = true;
Log.ForContext<MapPageViewModel>().Information($"Center to current Position done.");
ActionText = String.Empty;
}
catch (Exception l_oException)
{
Log.ForContext<MapPageViewModel>().Error("An error occurred while centering to current position.");
ActionText = String.Empty;
await ViewService.DisplayAlert(
"Fehler",
AppResources.MessageMapPageErrorSwitch,
String.Format(AppResources.MessageErrorQueryLocationMessage, l_oException.Message),
AppResources.MessageAnswerOk);
IsMapPageEnabled = true;
}
}
/// <summary> Command object to bind login button to view model.</summary>
public System.Windows.Input.ICommand OnToggleTinkToKonrad => new Xamarin.Forms.Command(async () => await ToggleTinkToKonrad());
@ -1015,43 +923,6 @@ namespace TINK.ViewModel.Map
Pins.Clear();
//// Move and scale before getting stations and bikes which takes some time.
//if (TinkApp.CenterMapToCurrentLocation)
//{
// // Check location permission
// //ActionText = AppResources.ActivityTextRequestingLocationPermissions;
// var status = await RequestLocationPermission();
// if (status == Status.Granted)
// {
// //ActionText = AppResources.ActivityTextCenterMap;
// Location currentLocation = null;
// try
// {
// currentLocation = await GeolocationService.GetAsync();
// }
// catch (Exception ex)
// {
// Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
// }
// if (currentLocation != null)
// {
// TinkApp.UserMapSpan = MapSpan.FromCenterAndRadius(
// new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
// TinkApp.ActiveMapSpan.Radius);
// TinkApp.Save();
// //MoveAndScale(m_oMoveToRegionDelegate, TinkApp.ActiveMapSpan);
// }
// else
// {
// ActionText = AppResources.ActivityTextErrorQueryLocationWhenAny;
// }
// }
//}
// Update stations
ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
IsConnected = TinkApp.GetIsConnected();