This commit is contained in:
Oliver Hauff 2022-01-22 18:28:01 +01:00
parent f38b516d25
commit 578fcee611
70 changed files with 6828 additions and 9625 deletions

View file

@ -301,122 +301,12 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
// Close lock
Log.ForContext<ReservedOpen>().Information("User selected disposable bike {bike} in order to manage sound/ alarm settings.", SelectedBike);
// Check current state.
BikesViewModel.ActionText = "Schlosseinstellung abfragen...";
bool isAlarmOff;
try
{
isAlarmOff = await LockService[SelectedBike.LockInfo.Id].GetIsAlarmOffAsync();
}
catch (OutOfReachException exception)
{
Log.ForContext<ReservedOpen>().Debug("Can not get lock alarm settings. {Exception}", exception);
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(
"Fehler beim Abfragen der Alarmeinstellungen!",
"Schloss kann erst geschlossen werden, wenn Rad in der Nähe ist.",
"OK");
return this;
}
catch (Exception exception)
{
Log.ForContext<ReservedOpen>().Error("Can not get lock alarm settings. {Exception}", exception);
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(
"Fehler beim Abfragen der Alarmeinstellungen!",
exception.Message,
"OK");
return this;
}
if (isAlarmOff)
{
// Switch on sound.
BikesViewModel.ActionText = "Anschalten von Sounds...";
try
{
await LockService[SelectedBike.LockInfo.Id].SetSoundAsync(SoundSettings.AllOn);
}
catch (OutOfReachException exception)
{
Log.ForContext<ReservedOpen>().Debug("Can not turn on sounds. {Exception}", exception);
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(
"Fehler beim Anschalten der Sounds!",
"Sounds können erst angeschalten werden, wenn Rad in der Nähe ist.",
"OK");
return this;
}
catch (Exception exception)
{
Log.ForContext<ReservedOpen>().Error("Can not turn on sounds. {Exception}", exception);
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(
"Fehler beim Anschalten der Sounds!",
exception.Message,
"OK");
return this;
}
// Switch off alarm.
BikesViewModel.ActionText = "Anschalten von Alarm...";
try
{
await LockService[SelectedBike.LockInfo.Id].SetIsAlarmOffAsync(true);
}
catch (OutOfReachException exception)
{
Log.ForContext<ReservedOpen>().Debug("Can not turn on alarm settings. {Exception}", exception);
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(
"Fehler beim Anschalten des Alarms!",
"Alarm kann erst angeschalten werden, wenn Rad in der Nähe ist.",
"OK");
return this;
}
catch (Exception exception)
{
Log.ForContext<ReservedOpen>().Error("Can not turn on alarm. {Exception}", exception);
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(
"Fehler beim Anschalten des Alarms!",
exception.Message,
"OK");
return RequestHandlerFactory.Create(SelectedBike, IsConnectedDelegate, ConnectorFactory, Geolocation, LockService, ViewUpdateManager, SmartDevice, ViewService, BikesViewModel, ActiveUser);
}
finally
{
BikesViewModel.ActionText = string.Empty;
BikesViewModel.IsIdle = true; // Unlock GUI
await ViewUpdateManager().StartUpdateAyncPeridically(); // Restart polling again.
}
await ViewService.DisplayAlert(
"Hinweis",
"Alarm und Sounds erfolgreich aktiviert",
"OK");
return this;
}
// Alarm and sounds are on, toggle to off.
// Switch off sound.
BikesViewModel.ActionText = "Abschalten der Sounds...";
try
{
await LockService[SelectedBike.LockInfo.Id].SetSoundAsync(SoundSettings.AllOff);
await LockService[SelectedBike.LockInfo.Id].SetSoundAsync(SoundSettings.Warn);
}
catch (OutOfReachException exception)
{
@ -443,11 +333,42 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
return this;
}
// Lower alarm sensivity.
BikesViewModel.ActionText = "Setzen Alarm-Einstellungen...";
try
{
await LockService[SelectedBike.LockInfo.Id].SetAlarmSettingsAsync(AlarmSettings.SmallSensivitySilent);
}
catch (OutOfReachException exception)
{
Log.ForContext<ReservedOpen>().Debug("Can not set alarm settings. {Exception}", exception);
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(
"Fehler beim Setzen der Alarm-Einstellungen!",
"Alarm kann erst eingestellt werden, wenn Rad in der Nähe ist.",
"OK");
return this;
}
catch (Exception exception)
{
Log.ForContext<ReservedOpen>().Error("Can not set alarm settings. {Exception}", exception);
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(
"Fehler beim Setzen der Alarms-Einstellungen!",
exception.Message,
"OK");
return RequestHandlerFactory.Create(SelectedBike, IsConnectedDelegate, ConnectorFactory, Geolocation, LockService, ViewUpdateManager, SmartDevice, ViewService, BikesViewModel, ActiveUser);
}
// Switch off alarm.
BikesViewModel.ActionText = "Abschalten von Alarm...";
try
{
await LockService[SelectedBike.LockInfo.Id].SetIsAlarmOffAsync(false);
await LockService[SelectedBike.LockInfo.Id].SetIsAlarmOffAsync(true);
}
catch (OutOfReachException exception)
{