Version 3.0.347

This commit is contained in:
ohauff 2022-10-26 20:53:18 +02:00
parent a018f21fea
commit 7f49fb0ac5
41 changed files with 292 additions and 187 deletions

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Serilog;
using TINK.Model.Connector;
@ -7,6 +7,7 @@ using TINK.Model.State;
using TINK.Model.User;
using TINK.MultilingualResources;
using TINK.Repository.Exception;
using TINK.Services.CopriApi.Exception;
using TINK.View;
using BikeInfoMutable = TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable;
@ -59,20 +60,21 @@ namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
{
await ConnectorFactory(IsConnected).Command.DoReserve(SelectedBike);
}
catch (Exception l_oException)
catch (Exception exception)
{
if (l_oException is BookingDeclinedException)
if (exception is BookingDeclinedException)
{
// Too many bikes booked.
Log.ForContext<Disposable>().Information("Request declined because maximum count of bikes {l_oException.MaxBikesCount} already requested/ booked.", (l_oException as BookingDeclinedException).MaxBikesCount);
Log.ForContext<Disposable>().Information("Request declined because maximum count of bikes {l_oException.MaxBikesCount} already requested/ booked.", (exception as BookingDeclinedException).MaxBikesCount);
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(
AppResources.MessageTitleHint,
string.Format(AppResources.MessageReservationBikeErrorTooManyReservationsRentals, SelectedBike.Id, (l_oException as BookingDeclinedException).MaxBikesCount),
string.Format(AppResources.MessageReservationBikeErrorTooManyReservationsRentals, SelectedBike.Id, (exception as BookingDeclinedException).MaxBikesCount),
AppResources.MessageAnswerOk);
}
else if (l_oException is WebConnectFailureException)
else if (exception is WebConnectFailureException
|| exception is RequestNotCachableException)
{
// Copri server is not reachable.
Log.ForContext<Disposable>().Information("User selected availalbe bike {l_oId} but reserving failed (Copri server not reachable).", SelectedBike.Id);
@ -80,15 +82,15 @@ namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(
AppResources.MessageReservingBikeErrorConnectionTitle,
string.Format("{0}\r\n{1}", l_oException.Message, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
string.Format("{0}\r\n{1}", exception.Message, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
AppResources.MessageAnswerOk);
}
else
{
Log.ForContext<Disposable>().Error("User selected availalbe bike {l_oId} but reserving failed. {@l_oException}", SelectedBike.Id, l_oException);
Log.ForContext<Disposable>().Error("User selected availalbe bike {l_oId} but reserving failed. {@l_oException}", SelectedBike.Id, exception);
BikesViewModel.ActionText = string.Empty;
await ViewService.DisplayAlert(AppResources.MessageReservingBikeErrorGeneralTitle, l_oException.Message, AppResources.MessageAnswerOk);
await ViewService.DisplayAlert(AppResources.MessageReservingBikeErrorGeneralTitle, exception.Message, AppResources.MessageAnswerOk);
}
BikesViewModel.ActionText = string.Empty; // Todo: Remove this statement because in catch block ActionText is already set to empty above.

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Serilog;
using TINK.Model.Connector;
@ -6,6 +6,7 @@ using TINK.Model.Device;
using TINK.Model.User;
using TINK.MultilingualResources;
using TINK.Repository.Exception;
using TINK.Services.CopriApi.Exception;
using TINK.View;
using BikeInfoMutable = TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable;
@ -63,34 +64,35 @@ namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
// If canceling bike succedes remove bike because it is not ready to be booked again
IsRemoveBikeRequired = true;
}
catch (Exception l_oException)
catch (Exception exception)
{
if (l_oException is InvalidAuthorizationResponseException)
if (exception is InvalidAuthorizationResponseException)
{
// Copri response is invalid.
Log.ForContext<Reserved>().Error("User selected reserved bike {l_oId} but canceling reservation failed (Invalid auth. response).", SelectedBike.Id);
BikesViewModel.ActionText = String.Empty;
await ViewService.DisplayAlert("Fehler beim Stornieren der Buchung!", l_oException.Message, "OK");
await ViewService.DisplayAlert("Fehler beim Stornieren der Buchung!", exception.Message, "OK");
BikesViewModel.IsIdle = true;
return this;
}
else if (l_oException is WebConnectFailureException)
else if (exception is WebConnectFailureException
|| exception is RequestNotCachableException)
{
// Copri server is not reachable.
Log.ForContext<Reserved>().Information("User selected reserved bike {l_oId} but cancel reservation failed (Copri server not reachable).", SelectedBike.Id);
BikesViewModel.ActionText = String.Empty;
await ViewService.DisplayAlert(
"Verbingungsfehler beim Stornieren der Buchung!",
string.Format("{0}\r\n{1}", l_oException.Message, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
string.Format("{0}\r\n{1}", exception.Message, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
"OK");
BikesViewModel.IsIdle = true;
return this;
}
else
{
Log.ForContext<Reserved>().Error("User selected reserved bike {l_oId} but cancel reservation failed. {@l_oException}.", SelectedBike.Id, l_oException);
Log.ForContext<Reserved>().Error("User selected reserved bike {l_oId} but cancel reservation failed. {@l_oException}.", SelectedBike.Id, exception);
BikesViewModel.ActionText = String.Empty;
await ViewService.DisplayAlert("Fehler beim Stornieren der Buchung!", l_oException.Message, "OK");
await ViewService.DisplayAlert("Fehler beim Stornieren der Buchung!", exception.Message, "OK");
BikesViewModel.IsIdle = true;
return this;
}

View file

@ -57,7 +57,6 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
/// <summary> Open bike and update COPRI lock state. </summary>
public async Task<IRequestHandler> HandleRequestOption2() => await OpenLock();
/// <summary> Return bike. </summary>
public async Task<IRequestHandler> ReturnBike()
{

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Serilog;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
@ -10,6 +10,7 @@ using TINK.Repository.Exception;
using TINK.Services.BluetoothLock;
using TINK.Services.BluetoothLock.Exception;
using TINK.Services.BluetoothLock.Tdo;
using TINK.Services.CopriApi.Exception;
using TINK.Services.Geolocation;
using TINK.View;
@ -85,7 +86,8 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
{
BikesViewModel.ActionText = string.Empty;
if (exception is WebConnectFailureException)
if (exception is WebConnectFailureException
|| exception is RequestNotCachableException)
{
// Copri server is not reachable.
Log.ForContext<BookedDisconnected>().Information("User selected booked bike {l_oId} to connect to lock. (Copri server not reachable).", SelectedBike.Id);

View file

@ -11,6 +11,7 @@ using TINK.Repository.Exception;
using TINK.Services.BluetoothLock;
using TINK.Services.BluetoothLock.Exception;
using TINK.Services.BluetoothLock.Tdo;
using TINK.Services.CopriApi.Exception;
using TINK.Services.Geolocation;
using TINK.View;
@ -101,7 +102,8 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
string.Format(AppResources.MessageReservationBikeErrorTooManyReservationsRentals, SelectedBike.Id, (exception as BookingDeclinedException).MaxBikesCount),
AppResources.MessageAnswerOk);
}
else if (exception is WebConnectFailureException)
else if (exception is WebConnectFailureException
|| exception is RequestNotCachableException)
{
// Copri server is not reachable.
Log.ForContext<DisposableDisconnected>().Information("User selected availalbe bike {bike} but reserving failed (Copri server not reachable).", SelectedBike);

View file

@ -9,6 +9,7 @@ using TINK.MultilingualResources;
using TINK.Repository.Exception;
using TINK.Services.BluetoothLock;
using TINK.Services.BluetoothLock.Exception;
using TINK.Services.CopriApi.Exception;
using TINK.Services.Geolocation;
using TINK.View;
using IBikeInfoMutable = TINK.Model.Bikes.BikeInfoNS.BluetoothLock.IBikeInfoMutable;
@ -93,35 +94,36 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
// If canceling bike succedes remove bike because it is not ready to be booked again
IsRemoveBikeRequired = true;
}
catch (Exception l_oException)
catch (Exception exception)
{
BikesViewModel.ActionText = string.Empty;
if (l_oException is InvalidAuthorizationResponseException)
if (exception is InvalidAuthorizationResponseException)
{
// Copri response is invalid.
Log.ForContext<BikesViewModel>().Error("User selected reserved bike {l_oId} but canceling reservation failed (Invalid auth. response).", SelectedBike.Id);
await ViewService.DisplayAlert(
AppResources.MessageCancelReservationBikeErrorGeneralTitle,
l_oException.Message,
exception.Message,
AppResources.MessageAnswerOk);
}
else if (l_oException is WebConnectFailureException)
else if (exception is WebConnectFailureException
|| exception is RequestNotCachableException)
{
// Copri server is not reachable.
Log.ForContext<BikesViewModel>().Information("User selected reserved bike {l_oId} but cancel reservation failed (Copri server not reachable).", SelectedBike.Id);
await ViewService.DisplayAlert(
AppResources.MessageCancelReservationBikeErrorConnectionTitle,
string.Format("{0}\r\n{1}", l_oException.Message, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
string.Format("{0}\r\n{1}", exception.Message, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
AppResources.MessageAnswerOk);
}
else
{
Log.ForContext<BikesViewModel>().Error("User selected reserved bike {l_oId} but cancel reservation failed. {@l_oException}.", SelectedBike.Id, l_oException);
Log.ForContext<BikesViewModel>().Error("User selected reserved bike {l_oId} but cancel reservation failed. {@l_oException}.", SelectedBike.Id, exception);
await ViewService.DisplayAlert(
AppResources.MessageCancelReservationBikeErrorGeneralTitle,
l_oException.Message,
exception.Message,
AppResources.MessageAnswerOk);
}

View file

@ -10,6 +10,7 @@ using TINK.Repository.Exception;
using TINK.Services.BluetoothLock;
using TINK.Services.BluetoothLock.Exception;
using TINK.Services.BluetoothLock.Tdo;
using TINK.Services.CopriApi.Exception;
using TINK.Services.Geolocation;
using TINK.View;
@ -88,33 +89,34 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
// If canceling bike succedes remove bike because it is not ready to be booked again
IsRemoveBikeRequired = true;
}
catch (Exception l_oException)
catch (Exception exception)
{
BikesViewModel.ActionText = string.Empty;
if (l_oException is InvalidAuthorizationResponseException)
if (exception is InvalidAuthorizationResponseException)
{
// Copri response is invalid.
Log.ForContext<ReservedDisconnected>().Error("User selected reserved bike {l_oId} but canceling reservation failed (Invalid auth. response).", SelectedBike.Id);
await ViewService.DisplayAlert(
AppResources.MessageCancelReservationBikeErrorGeneralTitle,
l_oException.Message,
exception.Message,
AppResources.MessageAnswerOk);
}
else if (l_oException is WebConnectFailureException)
else if (exception is WebConnectFailureException
|| exception is RequestNotCachableException)
{
// Copri server is not reachable.
Log.ForContext<ReservedDisconnected>().Information("User selected reserved bike {l_oId} but cancel reservation failed (Copri server not reachable).", SelectedBike.Id);
await ViewService.DisplayAlert(
AppResources.MessageCancelReservationBikeErrorConnectionTitle,
string.Format("{0}\r\n{1}", l_oException.Message, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
string.Format("{0}\r\n{1}", exception.Message, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
AppResources.MessageAnswerOk);
}
else
{
Log.ForContext<ReservedDisconnected>().Error("User selected reserved bike {l_oId} but cancel reservation failed. {@l_oException}.", SelectedBike.Id, l_oException);
Log.ForContext<ReservedDisconnected>().Error("User selected reserved bike {l_oId} but cancel reservation failed. {@l_oException}.", SelectedBike.Id, exception);
await ViewService.DisplayAlert(
AppResources.MessageCancelReservationBikeErrorGeneralTitle,
l_oException.Message,
exception.Message,
"OK");
}
@ -156,7 +158,8 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
{
BikesViewModel.ActionText = string.Empty;
if (exception is WebConnectFailureException)
if (exception is WebConnectFailureException
|| exception is RequestNotCachableException)
{
// Copri server is not reachable.
Log.ForContext<ReservedDisconnected>().Information("User selected requested bike {l_oId} to connect to lock. (Copri server not reachable).", SelectedBike.Id);

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Serilog;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
@ -9,6 +9,7 @@ using TINK.MultilingualResources;
using TINK.Repository.Exception;
using TINK.Services.BluetoothLock;
using TINK.Services.BluetoothLock.Exception;
using TINK.Services.CopriApi.Exception;
using TINK.Services.Geolocation;
using TINK.View;
@ -231,34 +232,35 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
// If canceling bike succedes remove bike because it is not ready to be booked again
IsRemoveBikeRequired = true;
}
catch (Exception l_oException)
catch (Exception exception)
{
BikesViewModel.ActionText = String.Empty;
if (l_oException is InvalidAuthorizationResponseException)
if (exception is InvalidAuthorizationResponseException)
{
// Copri response is invalid.
Log.ForContext<ReservedOpen>().Error("User selected reserved bike {l_oId} but canceling reservation failed (Invalid auth. response).", SelectedBike.Id);
await ViewService.DisplayAlert(
AppResources.MessageCancelReservationBikeErrorGeneralTitle,
l_oException.Message,
exception.Message,
AppResources.MessageAnswerOk);
}
else if (l_oException is WebConnectFailureException)
else if (exception is WebConnectFailureException
|| exception is RequestNotCachableException)
{
// Copri server is not reachable.
Log.ForContext<ReservedOpen>().Information("User selected reserved bike {l_oId} but cancel reservation failed (Copri server not reachable).", SelectedBike.Id);
await ViewService.DisplayAlert(
AppResources.MessageCancelReservationBikeErrorConnectionTitle,
string.Format("{0}\r\n{1}", l_oException.Message, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
string.Format("{0}\r\n{1}", exception.Message, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
AppResources.MessageAnswerOk);
}
else
{
Log.ForContext<ReservedOpen>().Error("User selected reserved bike {l_oId} but cancel reservation failed. {@l_oException}.", SelectedBike.Id, l_oException);
Log.ForContext<ReservedOpen>().Error("User selected reserved bike {l_oId} but cancel reservation failed. {@l_oException}.", SelectedBike.Id, exception);
await ViewService.DisplayAlert(
AppResources.MessageCancelReservationBikeErrorGeneralTitle,
l_oException.Message,
exception.Message,
"OK");
}

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Serilog;
using TINK.Model.Bikes.BikeInfoNS.CopriLock;
@ -8,6 +8,7 @@ using TINK.Model.State;
using TINK.Model.User;
using TINK.MultilingualResources;
using TINK.Repository.Exception;
using TINK.Services.CopriApi.Exception;
using TINK.View;
namespace TINK.ViewModel.Bikes.Bike.CopriLock.RequestHandler
@ -170,7 +171,8 @@ namespace TINK.ViewModel.Bikes.Bike.CopriLock.RequestHandler
string.Format(AppResources.MessageReservationBikeErrorTooManyReservationsRentals, SelectedBike.GetFullDisplayName(), (exception as BookingDeclinedException).MaxBikesCount),
AppResources.MessageAnswerOk);
}
else if (exception is WebConnectFailureException)
else if (exception is WebConnectFailureException
|| exception is RequestNotCachableException)
{
// Copri server is not reachable.
Log.ForContext<DisposableClosed>().Information("User selected availalbe bike {bike} but reserving failed (Copri server not reachable).", SelectedBike);

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Serilog;
using TINK.Model.Bikes.BikeInfoNS.CopriLock;
@ -7,6 +7,7 @@ using TINK.Model.Device;
using TINK.Model.User;
using TINK.MultilingualResources;
using TINK.Repository.Exception;
using TINK.Services.CopriApi.Exception;
using TINK.View;
namespace TINK.ViewModel.Bikes.Bike.CopriLock.RequestHandler
@ -101,7 +102,8 @@ namespace TINK.ViewModel.Bikes.Bike.CopriLock.RequestHandler
exception.Message,
AppResources.MessageAnswerOk);
}
else if (exception is WebConnectFailureException)
else if (exception is WebConnectFailureException
|| exception is RequestNotCachableException)
{
// Copri server is not reachable.
Log.ForContext<BikesViewModel>().Information("User selected reserved bike {Id} but cancel reservation failed (Copri server not reachable).", SelectedBike.Id);

View file

@ -1,10 +1,13 @@
using TINK.Model;
using System.ComponentModel;
using TINK.Model;
namespace TINK.ViewModel.Settings
{
/// <summary>Holds filter item incluting full state (avaialble, activated, name, ...). </summary>
public class FilterItemMutable
public class FilterItemMutable : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/// <summary> Switch value</summary>
private bool m_bIsActivatedSwitch;
@ -42,6 +45,12 @@ namespace TINK.ViewModel.Settings
set
{
if (m_bIsActivatedSwitch == value)
{
// Nothing to do.
return;
}
m_bIsActivatedSwitch = value;
if (!IsEnabled)
{
@ -50,6 +59,7 @@ namespace TINK.ViewModel.Settings
}
State = m_bIsActivatedSwitch ? FilterState.On : FilterState.Off;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsActivated)));
}
}
@ -58,5 +68,6 @@ namespace TINK.ViewModel.Settings
/// <summary> State of the filter.</summary>
public FilterState State { get; private set; }
}
}

View file

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using TINK.Model;
using TINK.Model.Connector;
@ -9,8 +10,10 @@ namespace TINK.ViewModel.Settings
{
/// <summary> Holds the filters to display..</summary>
/// <remarks> Former name: FilterCollectionMutable.</remarks>
public class SettingsBikeFilterViewModel : ObservableCollection<FilterItemMutable>
public class SettingsBikeFilterViewModel : ObservableCollection<FilterItemMutable>, INotifyPropertyChanged
{
public new event PropertyChangedEventHandler PropertyChanged;
/// <summary> Constructs a filter collection object.</summary>
/// <param name="filterSettings">All available filters.</param>
/// <param name="filterGroupUser">Filters which apply to logged in user.</param>
@ -22,28 +25,35 @@ namespace TINK.ViewModel.Settings
{
if (filter.Key == FilterHelper.CARGOBIKE)
{
Add(new FilterItemMutable(
var cargo = new FilterItemMutable(
filter.Key,
filter.Value,
(filterGroupUser != null && filterGroupUser.Count() > 0) ? filterGroupUser.Contains(filter.Key) : true,
AppResources.MarkingCargoBike));
AppResources.MarkingCargoBike);
Add(cargo);
cargo.PropertyChanged += (sender, ev) => PropertyChanged?.Invoke(sender, ev);
continue;
}
if (filter.Key == FilterHelper.CITYBIKE)
{
Add(new FilterItemMutable(
var city = new FilterItemMutable(
filter.Key,
filter.Value,
(filterGroupUser != null && filterGroupUser.Count() > 0) ? filterGroupUser.Contains(filter.Key) : true,
AppResources.MarkingCityBike));
AppResources.MarkingCityBike);
Add(city);
city.PropertyChanged += (sender, ev) => PropertyChanged?.Invoke(sender, ev);
continue;
}
Add(new FilterItemMutable(
var item = new FilterItemMutable(
filter.Key,
filter.Value,
filterGroupUser != null ? filterGroupUser.Contains(filter.Key) : true,
filter.Key));
filter.Key);
Add(item);
item.PropertyChanged += (sender, ev) => PropertyChanged?.Invoke(sender, ev);
}
}

View file

@ -114,6 +114,30 @@ namespace TINK.ViewModel
TinkApp.FilterGroupSetting,
TinkApp.ActiveUser.IsLoggedIn ? TinkApp.ActiveUser.Group : null);
GroupFilter.PropertyChanged += (s, e) =>
{
// Serialize on value changed. On iOS OnDisappearing might not be invoked (when app is directly closed before leaving settings page).
try
{
var filterGroup = GroupFilter.ToDictionary(x => x.Key, x => x.State);
TinkApp.FilterGroupSetting = new GroupFilterSettings(filterGroup.Count > 0 ? filterGroup : null);
// Update map page filter.
// Reasons for which map page filter has to be updated:
// - user activated/ deactivated a group (cargo/ city bikes)
TinkApp.GroupFilterMapPage =
GroupFilterMapPageHelper.CreateUpdated(
TinkApp.GroupFilterMapPage,
TinkApp.ActiveUser.DoFilter(TinkApp.FilterGroupSetting.DoFilter()));
TinkApp.Save();
}
catch (Exception ex)
{
Log.ForContext<SettingsPageViewModel>().Error(ex, "Serializing startup page failed.");
}
};
m_oViewUpdateManager = new IdlePollingUpdateTaskManager();
Polling = new PollingViewModel(TinkApp.Polling);
@ -166,6 +190,22 @@ namespace TINK.ViewModel
{ ViewTypes.FindBikePage.ToString(), AppResources.MarkingFindBike },
},
tinkApp.StartupSettings.StartupPage.ToString());
StartupSettings.PropertyChanged += (s, e) =>
{
// Serialize on value changed. On iOS OnDisappearing might not be invoked (when app is directly closed before leaving settings page).
try
{
TinkApp.StartupSettings.StartupPage = Enum.TryParse(StartupSettings.Active, out ViewTypes startupPage)
? startupPage
: Model.Settings.StartupSettings.DefaultStartupPage;
TinkApp.Save();
} catch (Exception ex)
{
Log.ForContext<SettingsPageViewModel>().Error(ex, "Serializing startup page failed.");
}
};
}
/// <summary>
@ -234,10 +274,7 @@ namespace TINK.ViewModel
/// <summary>
/// Gets the value of device identifier (for debugging purposes).
/// </summary>
public string DeviceIdentifier
{
get { return TinkApp.SmartDevice.Identifier; }
}
public string DeviceIdentifier => TinkApp.SmartDevice.Identifier;
/// <summary>
/// Invoked when page is shutdown.
@ -258,22 +295,6 @@ namespace TINK.ViewModel
TinkApp.ExpiresAfter = TimeSpan.FromSeconds(ExpiresAfterTotalSeconds);
var filterGroup = GroupFilter.ToDictionary(x => x.Key, x => x.State);
TinkApp.FilterGroupSetting = new GroupFilterSettings(filterGroup.Count > 0 ? filterGroup : null);
// Update map page filter.
// Reasons for which map page filter has to be updated:
// - user activated/ deactivated a group (TINKCorpi/ TINKSms/ Konrad)
// - user logged off
TinkApp.GroupFilterMapPage =
GroupFilterMapPageHelper.CreateUpdated(
TinkApp.GroupFilterMapPage,
TinkApp.ActiveUser.DoFilter(TinkApp.FilterGroupSetting.DoFilter()));
TinkApp.StartupSettings.StartupPage = Enum.TryParse(StartupSettings.Active, out ViewTypes startupPage) ? startupPage : Model.Settings.StartupSettings.DefaultStartupPage;
TinkApp.CenterMapToCurrentLocation = CenterMapToCurrentLocation;
if (IsLogToExternalFolderVisible)
{
// If no external folder is available do not update model value.
@ -356,7 +377,25 @@ namespace TINK.ViewModel
}
}
public bool CenterMapToCurrentLocation { get; set; }
bool _CenterMapToCurrentLocation = true;
public bool CenterMapToCurrentLocation
{
get => _CenterMapToCurrentLocation;
set
{
if (value == _CenterMapToCurrentLocation)
{
// Nothing to do.
return;
}
_CenterMapToCurrentLocation = value;
// Serialize on value changed. On iOS OnDisappearing might not be invoked (when app is directly closed before leaving settings page).
TinkApp.CenterMapToCurrentLocation = CenterMapToCurrentLocation;
TinkApp.Save();
}
}
/// <summary> Holds either
/// - a value indicating whether to use external folder (e.g. SD card)/ or internal folder for storing log-files or
@ -408,8 +447,6 @@ namespace TINK.ViewModel
public string ExpiresAfterTotalSecondsText
{
get => expiresAfterTotalSeconds.ToString("0");
}
}
}
}