2022-10-17 18:45:38 +02:00
|
|
|
using System;
|
2022-08-30 15:42:25 +02:00
|
|
|
using Serilog.Events;
|
2021-05-13 20:03:07 +02:00
|
|
|
using TINK.Services.BluetoothLock;
|
|
|
|
using TINK.Services.CopriApi.ServerUris;
|
2022-08-30 15:42:25 +02:00
|
|
|
using TINK.Services.Geolocation;
|
2021-05-13 20:03:07 +02:00
|
|
|
using TINK.Settings;
|
|
|
|
using TINK.ViewModel.Map;
|
|
|
|
using TINK.ViewModel.Settings;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TINK.Model.Settings
|
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
/// <summary> Holds settings which are persisted.</summary>
|
|
|
|
public class Settings
|
|
|
|
{
|
|
|
|
public const LogEventLevel DEFAULTLOGGINLEVEL = LogEventLevel.Error;
|
|
|
|
|
|
|
|
public const bool DEFAULTREPOTLEVEL = false;
|
|
|
|
|
|
|
|
/// <summary> Gets the type of the default geolocation service. </summary>
|
|
|
|
/// <remarks> Swtiched from GeolocationService (GeolocationAccuracyMediumService) to GeolocationAccuracyHighService in app version 3.0.290.</remarks>
|
|
|
|
public static Type DefaultLocationService => typeof(GeolocationAccuracyHighService);
|
|
|
|
|
|
|
|
// Default value of the expires after entry. Controls the expiration time of the cache values.
|
|
|
|
private TimeSpan DEFAULTEXPIRESAFTER = TimeSpan.FromSeconds(1);
|
|
|
|
|
|
|
|
/// <summary> Constructs settings object. </summary>
|
|
|
|
/// <param name="groupFilterMapPage">filter which is applied on the map view. Either TINK or Konrad stations are displayed.</param>
|
|
|
|
/// <param name="groupFilterSettings"></param>
|
2022-10-17 18:45:38 +02:00
|
|
|
/// <param name="startupSettings">Settings determining the startup behavior of the app.</param>
|
2022-09-06 16:08:19 +02:00
|
|
|
/// <param name="activeUri"></param>
|
|
|
|
/// <param name="pollingParameters"></param>
|
|
|
|
/// <param name="minimumLogEventLevel">Minimum logging level to be applied.</param>
|
|
|
|
/// <param name="isReportLevelVerbose">True if logging level is verbose.</param>
|
|
|
|
/// <param name="expiresAfter">Holds the expires after value.</param>
|
|
|
|
/// <param name="activeLockService">Gets the name of the lock service to use.</param>
|
|
|
|
/// <param name="connectTimeout">Timeout to apply when connecting to bluetooth lock</param>
|
|
|
|
/// <param name="activeTheme">Full class name of active app theme.</param>
|
|
|
|
public Settings(
|
|
|
|
IGroupFilterMapPage groupFilterMapPage = null,
|
|
|
|
IGroupFilterSettings groupFilterSettings = null,
|
2022-10-17 18:45:38 +02:00
|
|
|
IStartupSettings startupSettings = null,
|
2022-09-06 16:08:19 +02:00
|
|
|
Uri activeUri = null,
|
|
|
|
PollingParameters pollingParameters = null,
|
|
|
|
LogEventLevel? minimumLogEventLevel = null,
|
|
|
|
bool? isReportLevelVerbose = null,
|
|
|
|
TimeSpan? expiresAfter = null,
|
|
|
|
string activeLockService = null,
|
|
|
|
TimeSpan? connectTimeout = null,
|
|
|
|
string activeGeolocationService = null,
|
|
|
|
bool? centerMapToCurrentLocation = null,
|
|
|
|
Xamarin.Forms.GoogleMaps.MapSpan mapSpan = null,
|
|
|
|
bool? logToExternalFolder = null,
|
|
|
|
bool? isSiteCachingOn = null,
|
|
|
|
string activeTheme = null)
|
|
|
|
{
|
|
|
|
GroupFilterMapPage = groupFilterMapPage ?? new GroupFilterMapPage(); // Default behaviour: No filtering.
|
|
|
|
GroupFilterSettings = groupFilterSettings ?? new GroupFilterSettings(); // Default behaviour: No filtering.
|
2022-10-17 18:45:38 +02:00
|
|
|
StartupSettings = startupSettings ?? new StartupSettings();
|
2022-09-06 16:08:19 +02:00
|
|
|
ActiveUri = GetActiveUri(activeUri);
|
|
|
|
PollingParameters = pollingParameters ?? PollingParameters.Default;
|
|
|
|
MinimumLogEventLevel = minimumLogEventLevel ?? DEFAULTLOGGINLEVEL;
|
|
|
|
IsReportLevelVerbose = isReportLevelVerbose ?? DEFAULTREPOTLEVEL;
|
|
|
|
ExpiresAfter = expiresAfter ?? DEFAULTEXPIRESAFTER;
|
|
|
|
ActiveLockService = activeLockService ?? LocksServicesContainerMutable.DefaultLocksservice;
|
|
|
|
ConnectTimeout = connectTimeout ?? new TimeSpan(0, 0, TimeOutProvider.DEFAULT_BLUETOOTHCONNECT_TIMEOUTSECONDS); // Try one sec. to connect.
|
|
|
|
ActiveGeolocationService = activeGeolocationService ?? DefaultLocationService.Name;
|
|
|
|
CenterMapToCurrentLocation = centerMapToCurrentLocation ?? GetCenterMapToCurrentLocation(activeUri);
|
|
|
|
MapSpan = mapSpan;
|
|
|
|
LogToExternalFolder = logToExternalFolder ?? false;
|
|
|
|
IsSiteCachingOn = isSiteCachingOn ?? true;
|
|
|
|
ActiveTheme = activeTheme ?? typeof(Themes.ShareeBike).Name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary> Holds the filter which is applied on the map view. Either TINK or Konrad stations are displayed. </summary>
|
|
|
|
public IGroupFilterMapPage GroupFilterMapPage { get; }
|
|
|
|
|
|
|
|
/// <summary> Holds the filters loaded from settings. </summary>
|
|
|
|
public IGroupFilterSettings GroupFilterSettings { get; }
|
|
|
|
|
2022-10-17 18:45:38 +02:00
|
|
|
/// <summary> Holds the stettings determining app startup behavior. </summary>
|
|
|
|
public IStartupSettings StartupSettings { get; }
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
/// <summary> Holds the uri to connect to. </summary>
|
|
|
|
public Uri ActiveUri { get; }
|
|
|
|
|
|
|
|
/// <summary> Holds the polling parameters. </summary>
|
|
|
|
public PollingParameters PollingParameters { get; }
|
|
|
|
|
|
|
|
/// <summary> Gets the minimum logging level. </summary>
|
|
|
|
public LogEventLevel MinimumLogEventLevel { get; }
|
|
|
|
|
|
|
|
/// <summary> Gets the expires after value.</summary>
|
|
|
|
public TimeSpan ExpiresAfter { get; }
|
|
|
|
|
|
|
|
/// <summary> Gets the lock service to use.</summary>
|
|
|
|
public string ActiveLockService { get; private set; }
|
|
|
|
|
|
|
|
/// <summary> Timeout to apply when connecting to bluetooth lock.</summary>
|
|
|
|
public TimeSpan ConnectTimeout { get; }
|
|
|
|
|
|
|
|
/// <summary> Gets the geolocation service to use.</summary>
|
|
|
|
public string ActiveGeolocationService { get; }
|
|
|
|
|
|
|
|
/// <summary> True if map is centered to current positon, false if not to center map.</summary>
|
|
|
|
public bool CenterMapToCurrentLocation { get; }
|
|
|
|
|
|
|
|
/// <summary> Holds the map area to display. </summary>
|
|
|
|
public Xamarin.Forms.GoogleMaps.MapSpan MapSpan { get; }
|
|
|
|
|
|
|
|
public bool LogToExternalFolder { get; }
|
|
|
|
|
|
|
|
public bool IsSiteCachingOn { get; }
|
|
|
|
|
|
|
|
public string ActiveTheme { get; }
|
|
|
|
|
|
|
|
/// <summary> Gets a value indicating whether reporting level is verbose or not.</summary>
|
|
|
|
public bool IsReportLevelVerbose { get; }
|
|
|
|
|
|
|
|
public static Uri GetActiveUri(Uri activeUri) => activeUri ?? Services.CopriApi.ServerUris.CopriServerUriList.DefaultActiveUri;
|
|
|
|
|
|
|
|
public static bool GetCenterMapToCurrentLocation(Uri activeUri)
|
|
|
|
{
|
|
|
|
// TINK does not require acess to current location. Deactivate center map to current location for this reason.
|
|
|
|
return !GetActiveUri(activeUri).Host.GetIsCopri();
|
|
|
|
}
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
}
|