Version 3.0.337

This commit is contained in:
Anja Müller-Meißner 2022-08-30 15:42:25 +02:00
parent fd0e63cf10
commit 573fe77e12
2336 changed files with 33688 additions and 86082 deletions

View file

@ -14,7 +14,7 @@ namespace TINK.ViewModel.Settings
FilterDictionary = filterDictionary ?? new Dictionary<string, FilterState>();
Filter = filterDictionary != null
? (IGroupFilter) new IntersectGroupFilter(FilterDictionary.Where(x => x.Value == FilterState.On).Select(x => x.Key))
? (IGroupFilter)new IntersectGroupFilter(FilterDictionary.Where(x => x.Value == FilterState.On).Select(x => x.Key))
: new NullGroupFilter();
}
@ -23,7 +23,7 @@ namespace TINK.ViewModel.Settings
private IGroupFilter Filter { get; }
/// <summary> Performs filtering on response -group. </summary>
public IEnumerable<string> DoFilter(IEnumerable<string> filter = null) => Filter.DoFilter(filter);
public IEnumerable<string> DoFilter(IEnumerable<string> filter = null) => Filter.DoFilter(filter);
public FilterState this[string key] { get => FilterDictionary[key]; set => FilterDictionary[key] = value; }

View file

@ -1,11 +1,11 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Serilog.Events;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using TINK.Services.BluetoothLock;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Serilog.Events;
using TINK.Model.Services.CopriApi.ServerUris;
using TINK.Services.BluetoothLock;
using TINK.Services.Geolocation;
using TINK.Settings;
using TINK.ViewModel.Map;
@ -65,16 +65,21 @@ namespace TINK.Model.Settings
/// <param name="settingsJSON">Dictionary to get value from.</param>
public static T GetEntry<T>(
string keyName,
Dictionary<string, string> settingsJSON) where T : class
Dictionary<string, string> settingsJSON,
Func<string, string> legacyValueConverter = null) where T : class
{
if (!settingsJSON.TryGetValue(keyName, out string boolText)
|| string.IsNullOrEmpty(boolText))
if (string.IsNullOrEmpty(keyName)
|| settingsJSON == null
|| !settingsJSON.TryGetValue(keyName, out string valueJSON)
|| string.IsNullOrEmpty(valueJSON))
{
// File holds no entry.
return null;
}
return JsonConvert.DeserializeObject<T>(boolText);
return JsonConvert.DeserializeObject<T>(legacyValueConverter != null
? legacyValueConverter(valueJSON)
: valueJSON);
}
/// <summary> Sets a nullable.</summary>
@ -97,7 +102,7 @@ namespace TINK.Model.Settings
/// <param name="targetDictionary">Dictionary to write information to.</param>
/// <param name="connectTimeout">Connect timeout value.</param>
public static Dictionary<string, string> SetConnectTimeout(
this IDictionary<string, string> targetDictionary,
this IDictionary<string, string> targetDictionary,
TimeSpan connectTimeout)
{
if (targetDictionary == null)
@ -154,10 +159,12 @@ namespace TINK.Model.Settings
/// <summary> Sets the version of the app. </summary>
/// <param name="settingsJSON">Dictionary holding parameters from JSON.</param>
public static Dictionary<string, string> SetAppVersion(this IDictionary<string, string> targetDictionary, Version appVersion)
public static Dictionary<string, string> SetAppVersion(
this IDictionary<string, string> targetDictionary,
Version appVersion)
{
if (targetDictionary == null)
throw new Exception("Writing copri host uri to dictionary failed. Dictionary must not be null.");
throw new Exception("Writing app version to dictionary failed. Dictionary must not be null.");
return targetDictionary.Union(new Dictionary<string, string>
{
@ -204,15 +211,14 @@ namespace TINK.Model.Settings
public static PollingParameters GetPollingParameters(this IDictionary<string, string> settingsJSON)
{
// Check if dictionary contains entry for periode.
if (settingsJSON.TryGetValue($"{typeof(PollingParameters).Name}_{typeof(TimeSpan).Name}", out string l_strPeriode)
&& settingsJSON.TryGetValue($"{typeof(PollingParameters).Name}_{typeof(bool).Name}", out string l_strIsActive)
&& !string.IsNullOrEmpty(l_strPeriode)
&& !string.IsNullOrEmpty(l_strIsActive))
if (settingsJSON.TryGetValue($"{typeof(PollingParameters).Name}_{typeof(TimeSpan).Name}", out string periode)
&& settingsJSON.TryGetValue($"{typeof(PollingParameters).Name}_{typeof(bool).Name}", out string active)
&& !string.IsNullOrEmpty(periode)
&& !string.IsNullOrEmpty(active))
{
return new PollingParameters(
JsonConvert.DeserializeObject<TimeSpan>(l_strPeriode),
JsonConvert.DeserializeObject<bool>(l_strIsActive));
JsonConvert.DeserializeObject<TimeSpan>(periode),
JsonConvert.DeserializeObject<bool>(active));
}
return null;
@ -260,14 +266,14 @@ namespace TINK.Model.Settings
Dictionary<string, string> settingsJSON)
{
// Get logging level.
if (!settingsJSON.TryGetValue(MINLOGGINGLEVELKEY, out string l_strLevel)
|| string.IsNullOrEmpty(l_strLevel))
if (!settingsJSON.TryGetValue(MINLOGGINGLEVELKEY, out string level)
|| string.IsNullOrEmpty(level))
{
// File holds no entry.
return null;
}
return (LogEventLevel)int.Parse(JsonConvert.DeserializeObject<string>(l_strLevel));
return (LogEventLevel)int.Parse(JsonConvert.DeserializeObject<string>(level));
}
/// <summary> Gets a value indicating whether report level is verbose or not.</summary>
@ -300,14 +306,14 @@ namespace TINK.Model.Settings
public static Version GetWhatsNew(Dictionary<string, string> settingsJSON)
{
// Get logging level.
if (!settingsJSON.TryGetValue(SHOWWHATSNEWKEY, out string l_strWhatsNewVersion)
|| string.IsNullOrEmpty(l_strWhatsNewVersion))
if (!settingsJSON.TryGetValue(SHOWWHATSNEWKEY, out string whatsNewVersion)
|| string.IsNullOrEmpty(whatsNewVersion))
{
// File holds no entry.
return null;
}
return JsonConvert.DeserializeObject<Version>(l_strWhatsNewVersion, new VersionConverter());
return JsonConvert.DeserializeObject<Version>(whatsNewVersion, new VersionConverter());
}
/// <summary> Sets the version of app when whats new was shown.</summary>
@ -354,7 +360,7 @@ namespace TINK.Model.Settings
/// <summary> Sets the active lock service name. </summary>
/// <param name="targetDictionary">Dictionary holding parameters from JSON.</param>
public static Dictionary<string, string> SetActiveLockService(this IDictionary<string, string> targetDictionary, string activeLockService)
public static Dictionary<string, string> SetActiveLockService(this IDictionary<string, string> targetDictionary, string activeLockService)
{
if (targetDictionary == null)
throw new Exception("Writing active lock service name to dictionary failed. Dictionary must not be null.");
@ -433,7 +439,26 @@ namespace TINK.Model.Settings
/// <summary> Gets full class name of active theme.</summary>
/// <param name="settingsJSON">Dictionary to get value from.</param>
public static string GetActiveTheme(Dictionary<string, string> settingsJSON) => GetEntry<string>(THEMEKEY, settingsJSON);
public static string GetActiveTheme(Dictionary<string, string> settingsJSON)
=> GetEntry<string>(THEMEKEY, settingsJSON, (value) =>
{
if (value == JsonConvert.SerializeObject(typeof(Themes.Konrad).FullName))
{
return JsonConvert.SerializeObject(TINK.Services.ThemeNS.ThemeSet.Konrad.ToString());
}
else if (value == JsonConvert.SerializeObject(typeof(Themes.LastenradBayern).FullName))
{
return JsonConvert.SerializeObject(TINK.Services.ThemeNS.ThemeSet.LastenradBayern.ToString());
}
else if (value == JsonConvert.SerializeObject(typeof(Themes.ShareeBike).FullName))
{
return JsonConvert.SerializeObject(TINK.Services.ThemeNS.ThemeSet.ShareeBike.ToString());
}
else
{
return value;
}
});
/// <summary> Gets a value indicating whether site caching is on or off.</summary>
/// <param name="settingsJSON">Dictionary to get value from.</param>
@ -445,23 +470,26 @@ namespace TINK.Model.Settings
/// <summary> Sets active theme.</summary>
/// <param name="targetDictionary">Dictionary to set value to.</param>
public static Dictionary<string, string> SetActiveTheme(this IDictionary<string, string> targetDictionary, string theme) => SetEntry(theme, THEMEKEY, targetDictionary);
public static Dictionary<string, string> SetActiveTheme(
this IDictionary<string, string> targetDictionary,
string theme)
=> SetEntry(theme, THEMEKEY, targetDictionary);
/// <summary> Sets whether site caching is on or off.</summary>
/// <param name="settingsJSON">Dictionary to get value from.</param>
public static Dictionary<string, string> SetIsSiteCachingOn(this IDictionary<string, string> targetDictionary, bool useSdCard) => SetEntry(useSdCard, ISSITECACHINGON, targetDictionary);
/// <summary> Gets the map page filter. </summary>
/// <param name="settings">Settings objet to load from.</param>
public static IGroupFilterMapPage GetGroupFilterMapPage(this IDictionary<string, string> settings)
{
var l_oKeyName = "FilterCollection_MapPageFilter";
if (settings == null || !settings.ContainsKey(l_oKeyName))
var keyName = "FilterCollection_MapPageFilter";
if (settings == null || !settings.ContainsKey(keyName))
{
return null;
}
return new GroupFilterMapPage(JsonConvert.DeserializeObject<IDictionary<string, FilterState>>(settings[l_oKeyName]));
return new GroupFilterMapPage(JsonConvert.DeserializeObject<IDictionary<string, FilterState>>(settings[keyName]));
}
public static IDictionary<string, string> SetGroupFilterMapPage(
@ -483,13 +511,13 @@ namespace TINK.Model.Settings
/// <param name="settings">Settings objet to load from.</param>
public static IGroupFilterSettings GetGoupFilterSettings(this IDictionary<string, string> settings)
{
var l_oKeyName = "FilterCollection";
if (settings == null || !settings.ContainsKey(l_oKeyName))
var keyName = "FilterCollection";
if (settings == null || !settings.ContainsKey(keyName))
{
return null;
}
var legacyFilterCollection = new GroupFilterSettings(JsonConvert.DeserializeObject<IDictionary<string, FilterState>>(settings[l_oKeyName]));
var legacyFilterCollection = new GroupFilterSettings(JsonConvert.DeserializeObject<IDictionary<string, FilterState>>(settings[keyName]));
// Process legacy entries.
var updatedFilterCollection = legacyFilterCollection.Where(x => x.Key.ToUpper() != "TINK.SMS" && x.Key.ToUpper() != "TINK.COPRI").ToDictionary(x => x.Key, x => x.Value);

View file

@ -4,7 +4,7 @@ namespace TINK.Settings
{
/// <summary> Holds polling parameters.</summary>
public sealed class PollingParameters : IEquatable<PollingParameters>
{
{
/// <summary> Holds default polling parameters. </summary>
public static PollingParameters Default { get; } = new PollingParameters(
new TimeSpan(0, 0, 0, 10 /*secs*/, 0),// Default polling interval.
@ -28,7 +28,7 @@ namespace TINK.Settings
public TimeSpan Periode { get; }
/// <summary> Holds value whether polling is activated or not.</summary>
public bool IsActivated { get; }
public bool IsActivated { get; }
/// <summary> Checks equallity.</summary>
/// <param name="other">Object to compare with.</param>

View file

@ -1,8 +1,8 @@
using Serilog.Events;
using System;
using TINK.Services.Geolocation;
using System;
using Serilog.Events;
using TINK.Services.BluetoothLock;
using TINK.Services.CopriApi.ServerUris;
using TINK.Services.Geolocation;
using TINK.Settings;
using TINK.ViewModel.Map;
using TINK.ViewModel.Settings;
@ -20,7 +20,7 @@ namespace TINK.Model.Settings
/// <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);
@ -66,7 +66,7 @@ namespace TINK.Model.Settings
MapSpan = mapSpan;
LogToExternalFolder = logToExternalFolder ?? false;
IsSiteCachingOn = isSiteCachingOn ?? true;
ActiveTheme = activeTheme ?? typeof(Themes.ShareeBike).FullName;
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>