This commit is contained in:
Oliver Hauff 2022-01-22 18:30:23 +01:00
parent 578fcee611
commit 6ed1579494
34 changed files with 357 additions and 89 deletions

View file

@ -333,7 +333,7 @@ namespace TINK.ViewModel.Map
await ViewService.DisplayAlert(
"Information",
resultStationsAndBikes.GeneralData.MerchantMessage,
"OK");
AppResources.MessageAnswerOk);
WasMerchantMessageAlreadyShown = true;
}
@ -876,9 +876,13 @@ namespace TINK.ViewModel.Map
{
try
{
IsMapPageEnabled = false;
IsRunning = true;
Log.ForContext<MapPageViewModel>().Information($"Request to toggle to \"{p_strSelectedFilter}\".");
// Stop polling.
ActionText = AppResources.ActivityTextOneMomentPlease;
await m_oViewUpdateManager.StopUpdatePeridically();
// Clear error info.
@ -896,27 +900,29 @@ namespace TINK.ViewModel.Map
Pins.Clear();
// Check location permission
ActionText = AppResources.ActivityTextRequestingLocationPermissions;
var status = await PermissionsService.CheckStatusAsync();
if (TinkApp.CenterMapToCurrentLocation
&& !GeolocationService.IsSimulation
&& status != Status.Granted)
{
var permissionResult = await PermissionsService.RequestAsync();
status = await PermissionsService.RequestAsync();
if (permissionResult != Status.Granted)
if (status != Status.Granted)
{
var dialogResult = await ViewService.DisplayAlert(
AppResources.MessageTitleHint,
AppResources.MessageBikesManagementLocationPermission,
"Ja",
"Nein");
AppResources.MessageTitleHint,
AppResources.MessageCenterMapLocationPermissionOpenDialog,
AppResources.MessageAnswerYes,
AppResources.MessageAnswerNo);
if (dialogResult)
{
// User decided to give access to locations permissions.
PermissionsService.OpenAppSettings();
IsMapPageEnabled = true;
ActionText = "";
IsRunning = false;
IsMapPageEnabled = true;
return;
}
}
@ -930,13 +936,16 @@ namespace TINK.ViewModel.Map
AppResources.MessageTitleHint,
AppResources.MessageBikesManagementBluetoothActivation,
AppResources.MessageAnswerOk);
IsMapPageEnabled = true;
ActionText = "";
IsRunning = false;
IsMapPageEnabled = true;
return;
}
}
// Move and scale before getting stations and bikes which takes some time.
ActionText = AppResources.ActivityTextCenterMap;
if (TinkApp.CenterMapToCurrentLocation)
{
Location currentLocation = null;
@ -962,6 +971,7 @@ namespace TINK.ViewModel.Map
// Update stations
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.ActiveMapSpan);
ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
IsConnected = TinkApp.GetIsConnected();
var resultStationsAndBikes = await TinkApp.GetConnector(IsConnected).Query.GetBikesAndStationsAsync();
@ -990,16 +1000,24 @@ namespace TINK.ViewModel.Map
// Excpetions are handled insde update task;
}
ActionText = "";
IsRunning = false;
IsMapPageEnabled = true;
Log.ForContext<MapPageViewModel>().Information($"Toggle to \"{p_strSelectedFilter}\" done.");
}
catch (Exception l_oException)
{
Log.ForContext<MapPageViewModel>().Error("An error occurred switching view Cargobike/ Citybike.{}");
ActionText = "";
IsRunning = false;
await ViewService.DisplayAlert(
"Fehler",
$"Beim Umschalten TINK/ Konrad ist ein Fehler aufgetreten.\r\n{l_oException.Message}",
"OK");
AppResources.MessageMapPageErrorSwitch,
String.Format(AppResources.MessageMapPageErrorSwitch, l_oException.Message),
AppResources.MessageAnswerOk);
IsMapPageEnabled = true;
}
}