Version 3.0.261

This commit is contained in:
ohauff 2021-11-14 23:27:29 +01:00
parent 8aa3089f32
commit 4bccfe740b
80 changed files with 2672 additions and 458 deletions

View file

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
namespace TINK.Model.Connector.Filter
{

View file

@ -14,6 +14,6 @@
/// Was "TINK" up to version 3.0.258.
/// Specified first: "KN300029" (RG).
/// </remarks>
public const string FILTERTINKGENERAL = "300102";
public const string FILTERTINKGENERAL = "300103";
}
}

View file

@ -60,6 +60,9 @@ namespace TINK.Model
/// <summary> Value indicating whether map is centerted to current position or not. </summary>
bool CenterMapToCurrentLocation { get; set; }
/// <summary> Holds the map area to display. </summary>
Xamarin.Forms.GoogleMaps.MapSpan MapSpan { get; set; }
bool LogToExternalFolder { get; set; }
bool IsSiteCachingOn { get; set; }

View file

@ -22,7 +22,7 @@ namespace TINK.ViewModel.Settings
private IGroupFilter Filter { get; }
/// <summary> Performs filtering on response-group. </summary>
/// <summary> Performs filtering on response -group. </summary>
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

@ -495,11 +495,15 @@ namespace TINK.Model.Settings
// 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);
if (legacyFilterCollection.Count() <= updatedFilterCollection.Count())
{
// No legacy entries "INK.SMS" or "TINK.COPRI" found.
return legacyFilterCollection;
}
var list = updatedFilterCollection.ToList();
updatedFilterCollection.Add(
FilterHelper.FILTERTINKGENERAL,
"TINK",
legacyFilterCollection.Any(x => x.Key.ToUpper() == "TINK.COPRI") ? legacyFilterCollection.FirstOrDefault(x => x.Key.ToUpper() == "TINK.COPRI").Value : FilterState.Off);
return new GroupFilterSettings(updatedFilterCollection);

View file

@ -46,6 +46,7 @@ namespace TINK.Model.Settings
TimeSpan? connectTimeout = null,
string activeGeolocationService = null,
bool? centerMapToCurrentLocation = null,
Xamarin.Forms.GoogleMaps.MapSpan mapSpan = null,
bool? logToExternalFolder = null,
bool? isSiteCachingOn = null,
string activeTheme = null)
@ -61,6 +62,7 @@ namespace TINK.Model.Settings
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).FullName;
@ -93,8 +95,12 @@ namespace TINK.Model.Settings
/// <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; }

View file

@ -65,6 +65,9 @@ namespace TINK.Model
/// <summary> Value indicating whether map is centerted to current position or not. </summary>
public bool CenterMapToCurrentLocation { get; set; }
/// <summary> Holds the map area to display. </summary>
public Xamarin.Forms.GoogleMaps.MapSpan MapSpan { get; set; }
/// <summary> Gets the minimum logging level. </summary>
public LogEventLevel MinimumLogEventLevel { get; set; }
@ -208,6 +211,8 @@ namespace TINK.Model
CenterMapToCurrentLocation = settings.CenterMapToCurrentLocation;
MapSpan = settings.MapSpan;
SmartDevice = device
?? throw new ArgumentException("Can not instantiate TinkApp- object. No device information provider available.");

View file

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TINK.Themes.Konrad">
<!-- Pallete -->
<!-- Red #ff0000 -->
<Color x:Key="primary-back-title-color">Red</Color>
<!-- Pallete-end -->
<Style ApplyToDerivedTypes="true" TargetType="NavigationPage">

View file

@ -158,9 +158,7 @@ namespace TINK.ViewModel.Account
return AppResources.MarkingLoggedInStateInfoNotLoggedIn;
}
return TinkApp.ActiveUser.Group.Intersect(new List<string> { FilterHelper.FILTERTINKGENERAL, FilterHelper.FILTERKONRAD }).Any()
? string.Format(AppResources.MarkingLoggedInStateInfoLoggedInGroup, TinkApp.ActiveUser.Mail, TinkApp.ActiveUser.GetUserGroupDisplayName())
: string.Format(AppResources.MarkingLoggedInStateInfoLoggedIn, TinkApp.ActiveUser.Mail);
return string.Format(AppResources.MarkingLoggedInStateInfoLoggedIn, TinkApp.ActiveUser.Mail);
}
}

View file

@ -23,7 +23,6 @@ using Xamarin.Essentials;
using System.Threading;
using TINK.MultilingualResources;
using TINK.Services.BluetoothLock;
using TINK.Model.Services.CopriApi.ServerUris;
using TINK.ViewModel.Info;
using TINK.Repository;
using TINK.Model.Services.Geolocation;
@ -420,19 +419,26 @@ namespace TINK.ViewModel.Map
// Move and scale before getting stations and bikes which takes some time.
ActionText = AppResources.ActivityTextCenterMap;
Location currentLocation = null;
try
if (TinkApp.CenterMapToCurrentLocation)
{
currentLocation = TinkApp.CenterMapToCurrentLocation
? await GeolocationService.GetAsync()
: null;
}
catch (Exception ex)
{
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
Location currentLocation = null;
try
{
currentLocation = await GeolocationService.GetAsync();
}
catch (Exception ex)
{
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
}
TinkApp.MapSpan = MapSpan.FromCenterAndRadius(
new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
TinkApp.MapSpan.Radius);
TinkApp.Save();
}
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.Uris.ActiveUri, ActiveFilterMap, currentLocation);
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.MapSpan);
m_oViewUpdateManager = CreateUpdateTask();
@ -471,44 +477,14 @@ namespace TINK.ViewModel.Map
/// <summary> Moves map and scales visible region depending on active filter. </summary>
public static void MoveAndScale(
Action<MapSpan> moveToRegionDelegate,
Uri activeUri,
IGroupFilterMapPage groupFilterMapPage,
Location currentLocation = null)
MapSpan currentMapSpan = null)
{
if (currentLocation != null)
if (currentMapSpan != null)
{
// Move to current location.
moveToRegionDelegate(MapSpan.FromCenterAndRadius(
new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
Distance.FromKilometers(1.0)));
moveToRegionDelegate(currentMapSpan);
return;
}
if (activeUri.AbsoluteUri == CopriServerUriList.SHAREE_LIVE ||
activeUri.AbsoluteUri == CopriServerUriList.SHAREE_DEVEL)
{
// Center map to Freiburg
moveToRegionDelegate(MapSpan.FromCenterAndRadius(
new Xamarin.Forms.GoogleMaps.Position(47.995865, 7.815086),
Distance.FromKilometers(2.9)));
return;
}
// Depending on whether TINK or Conrad is active set center of map and scale.
if (groupFilterMapPage.GetGroup().Contains(FilterHelper.FILTERKONRAD))
{
// Konrad is activated,
moveToRegionDelegate(MapSpan.FromCenterAndRadius(
new Xamarin.Forms.GoogleMaps.Position(47.680, 9.180),
Distance.FromKilometers(2.9)));
}
else
{
// TINK
moveToRegionDelegate(MapSpan.FromCenterAndRadius(
new Xamarin.Forms.GoogleMaps.Position(47.667, 9.172),
Distance.FromKilometers(0.9)));
}
}
/// <summary> Creates a update task object. </summary>
@ -894,21 +870,27 @@ namespace TINK.ViewModel.Map
}
// Move and scale before getting stations and bikes which takes some time.
Location currentLocation = null;
try
if (TinkApp.CenterMapToCurrentLocation)
{
currentLocation = TinkApp.CenterMapToCurrentLocation
? await GeolocationService.GetAsync()
: null;
}
catch (Exception ex)
{
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
Location currentLocation = null;
try
{
currentLocation = await GeolocationService.GetAsync();
}
catch (Exception ex)
{
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
}
TinkApp.MapSpan = MapSpan.FromCenterAndRadius(
new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
TinkApp.MapSpan.Radius);
TinkApp.Save();
}
// Update stations
// Depending on whether TINK or Conrad is active set center of map and scale.
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.Uris.ActiveUri, ActiveFilterMap, currentLocation);
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.MapSpan);
IsConnected = TinkApp.GetIsConnected();
var resultStationsAndBikes = await TinkApp.GetConnector(IsConnected).Query.GetBikesAndStationsAsync();