Version 3.0.346

This commit is contained in:
Oliver Hauff 2022-10-17 18:45:38 +02:00
parent 1ba809dd59
commit 47c03f43fb
43 changed files with 609 additions and 117 deletions

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading;
@ -6,6 +6,7 @@ using Serilog.Events;
using TINK.Model.Connector;
using TINK.Model.Device;
using TINK.Model.Services.CopriApi.ServerUris;
using TINK.Model.Settings;
using TINK.Model.Station;
using TINK.Services;
using TINK.Services.BluetoothLock;
@ -65,6 +66,9 @@ namespace TINK.Model
/// <summary> Holds the filters loaded from settings. </summary>
IGroupFilterSettings FilterGroupSetting { get; set; }
/// <summary>Settings determining the startup behavior of the app.</summary>
IStartupSettings StartupSettings { get; }
/// <summary> Value indicating whether map is centerted to current position or not. </summary>
bool CenterMapToCurrentLocation { get; set; }
@ -84,10 +88,9 @@ namespace TINK.Model
/// <summary> Gets a value indicating whether reporting level is verbose or not.</summary>
bool IsReportLevelVerbose { get; set; }
/// <summary> Updates logging level. </summary>
/// <param name="p_oNewLevel">New level to set.</param>
void UpdateLoggingLevel(LogEventLevel p_oNewLevel);
/// <param name="newLogLevel">New level to set.</param>
void UpdateLoggingLevel(LogEventLevel newLogLevel);
/// <summary>Holds uris of copri servers. </summary>
CopriServerUriList Uris { get; }
@ -113,7 +116,7 @@ namespace TINK.Model
/// <summary> Holds the stations availalbe. </summary>
IEnumerable<IStation> Stations { get; set; }
/// <summary> Holds the Urs to query resources from. </summary>
IResourceUrls ResourceUrls { get; set; }
}

View file

@ -0,0 +1,9 @@
namespace TINK.Model.Settings
{
/// <summary> Settings determining the startup behavior of the app. </summary>
public interface IStartupSettings
{
/// <summary> Holds the page to show when apps starts. </summary>
ViewTypes StartupPage { get; set; }
}
}

View file

@ -1,6 +1,7 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Serilog.Events;
@ -39,6 +40,9 @@ namespace TINK.Model.Settings
/// <summary> Key of the center to ... entry. </summary>
public const string CENTERMAPTOCURRENTLOCATION = "CenterMapToCurrentLocation";
/// <summary> Key of the center to ... entry. </summary>
public const string STARTUPSETTINGS = "StartupSettings";
public const string LOGTOEXTERNALFOLDER = "LogToExternalFolder";
public const string THEMEKEY = "Theme";
@ -49,7 +53,7 @@ namespace TINK.Model.Settings
/// <param name="settingsJSON">Dictionary to get value from.</param>
public static T? GetNullableEntry<T>(
string keyName,
Dictionary<string, string> settingsJSON) where T : struct
IDictionary<string, string> settingsJSON) where T : struct
{
if (!settingsJSON.TryGetValue(keyName, out string boolText)
|| string.IsNullOrEmpty(boolText))
@ -65,7 +69,7 @@ namespace TINK.Model.Settings
/// <param name="settingsJSON">Dictionary to get value from.</param>
public static T GetEntry<T>(
string keyName,
Dictionary<string, string> settingsJSON,
IDictionary<string, string> settingsJSON,
Func<string, string> legacyValueConverter = null) where T : class
{
if (string.IsNullOrEmpty(keyName)
@ -465,7 +469,7 @@ namespace TINK.Model.Settings
public static bool? GetIsSiteCachingOn(Dictionary<string, string> settingsJSON) => GetNullableEntry<bool>(ISSITECACHINGON, settingsJSON);
/// <summary> Sets whether to store logging data on SD card or not.</summary>
/// <param name="settingsJSON">Dictionary to get value from.</param>
/// <param name="settingsJSON">Dictionary to write value to.</param>
public static Dictionary<string, string> SetLogToExternalFolder(this IDictionary<string, string> targetDictionary, bool useSdCard) => SetEntry(useSdCard, LOGTOEXTERNALFOLDER, targetDictionary);
/// <summary> Sets active theme.</summary>
@ -550,5 +554,28 @@ namespace TINK.Model.Settings
settings["FilterCollection"] = JsonConvert.SerializeObject(p_oFilterCollection);
return settings;
}
/// <summary>
/// Gets the startup settings from dictionary.
/// </summary>
/// <param name="settings">Settings objet to load from.</param>
public static StartupSettings GetStartupSettings(this IDictionary<string, string> settingsJSON)
=> GetEntry<StartupSettings>(STARTUPSETTINGS, settingsJSON) ?? new StartupSettings();
/// <summary> Sets the startup settings.</summary>
/// <param name="settingsJSON">Dictionary to write value to.</param>
public static IDictionary<string, string> SetStartupSettings(
this IDictionary<string, string> settingsJSON,
IStartupSettings startupSettings)
{
if (settingsJSON == null
|| startupSettings == null)
{
return settingsJSON;
}
settingsJSON[STARTUPSETTINGS] = JsonConvert.SerializeObject(startupSettings);
return settingsJSON;
}
}
}

View file

@ -1,4 +1,4 @@
using System;
using System;
using Serilog.Events;
using TINK.Services.BluetoothLock;
using TINK.Services.CopriApi.ServerUris;
@ -27,6 +27,7 @@ namespace TINK.Model.Settings
/// <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>
/// <param name="startupSettings">Settings determining the startup behavior of the app.</param>
/// <param name="activeUri"></param>
/// <param name="pollingParameters"></param>
/// <param name="minimumLogEventLevel">Minimum logging level to be applied.</param>
@ -38,6 +39,7 @@ namespace TINK.Model.Settings
public Settings(
IGroupFilterMapPage groupFilterMapPage = null,
IGroupFilterSettings groupFilterSettings = null,
IStartupSettings startupSettings = null,
Uri activeUri = null,
PollingParameters pollingParameters = null,
LogEventLevel? minimumLogEventLevel = null,
@ -54,6 +56,7 @@ namespace TINK.Model.Settings
{
GroupFilterMapPage = groupFilterMapPage ?? new GroupFilterMapPage(); // Default behaviour: No filtering.
GroupFilterSettings = groupFilterSettings ?? new GroupFilterSettings(); // Default behaviour: No filtering.
StartupSettings = startupSettings ?? new StartupSettings();
ActiveUri = GetActiveUri(activeUri);
PollingParameters = pollingParameters ?? PollingParameters.Default;
MinimumLogEventLevel = minimumLogEventLevel ?? DEFAULTLOGGINLEVEL;
@ -75,6 +78,9 @@ namespace TINK.Model.Settings
/// <summary> Holds the filters loaded from settings. </summary>
public IGroupFilterSettings GroupFilterSettings { get; }
/// <summary> Holds the stettings determining app startup behavior. </summary>
public IStartupSettings StartupSettings { get; }
/// <summary> Holds the uri to connect to. </summary>
public Uri ActiveUri { get; }

View file

@ -0,0 +1,11 @@
namespace TINK.Model.Settings
{
/// <summary> Settings determining the startup behavior of the app. </summary>
public class StartupSettings : IStartupSettings
{
public static ViewTypes DefaultStartupPage => ViewTypes.MapPage;
/// <summary> Holds the page to show when apps starts. </summary>
public ViewTypes StartupPage { get; set; } = DefaultStartupPage;
}
}

View file

@ -52,6 +52,9 @@ namespace TINK.Model
/// <summary> Holds the filters loaded from settings. </summary>
public IGroupFilterSettings FilterGroupSetting { get; set; }
/// <summary> Settings determining the startup behavior of the app.</summary>
public IStartupSettings StartupSettings { get; private set; }
/// <summary> Holds the filter which is applied on the map view. Either TINK or Konrad stations are displayed. </summary>
private IGroupFilterMapPage m_oFilterDictionaryMapPage;
@ -73,9 +76,17 @@ namespace TINK.Model
/// <summary> Holds the map span to display either default span or span centered to current position depending on option <see cref="CenterMapToCurrentLocation"/>.</summary>
public Xamarin.Forms.GoogleMaps.MapSpan ActiveMapSpan
=> CenterMapToCurrentLocation
? UserMapSpan ?? HomeMapSpan
: HomeMapSpan;
{
get
{
if (CenterMapToCurrentLocation == false)
{
return HomeMapSpan;
}
return UserMapSpan ?? HomeMapSpan;
}
}
/// <summary> Gets the minimum logging level. </summary>
public LogEventLevel MinimumLogEventLevel { get; set; }
@ -95,6 +106,7 @@ namespace TINK.Model
.SetCopriHostUri(NextActiveUri.AbsoluteUri)
.SetPollingParameters(Polling)
.SetGroupFilterSettings(FilterGroupSetting)
.SetStartupSettings(StartupSettings)
.SetAppVersion(AppVersion)
.SetMinimumLoggingLevel(MinimumLogEventLevel)
.SetIsReportLevelVerbose(IsReportLevelVerbose)
@ -238,6 +250,8 @@ namespace TINK.Model
FilterGroupSetting = settings.GroupFilterSettings;
GroupFilterMapPage = settings.GroupFilterMapPage;
StartupSettings = settings.StartupSettings;
CenterMapToCurrentLocation = settings.CenterMapToCurrentLocation;
HomeMapSpan = settings.MapSpan;

View file

@ -614,7 +614,17 @@ namespace TINK.Model
new Version(3, 0, 345),
AppResources.ChangeLog_3_0_345_LB,
new List<AppFlavor> { AppFlavor.LastenradBayern }
}
},
{
new Version(3, 0, 346),
AppResources.ChangeLog_3_0_346_LB_MK,
new List<AppFlavor> { AppFlavor.LastenradBayern, AppFlavor.MeinKonrad }
},
{
new Version(3, 0, 346),
AppResources.ChangeLog_3_0_346_SB,
new List<AppFlavor> { AppFlavor.ShareeBike }
},
};
/// <summary> Manges the whats new information.</summary>