Code updated to 3.0.238

This commit is contained in:
Oliver Hauff 2021-06-26 20:57:55 +02:00
parent 3302d80678
commit 9c6a1fa92b
257 changed files with 7763 additions and 2861 deletions

View file

@ -14,11 +14,16 @@ using TINK.ViewModel.Bikes.Bike;
using TINK.ViewModel.Bikes.Bike.BC;
using Plugin.Permissions.Abstractions;
using Plugin.BLE.Abstractions.Contracts;
using TINK.MultilingualResources;
using TINK.Model.Device;
namespace TINK.ViewModel.Bikes
{
public abstract class BikesViewModel : ObservableCollection<BikeViewModelBase>, IBikesViewModel
{
/// <summary> Provides info about the smart device (phone, tablet, ...).</summary>
protected ISmartDevice SmartDevice;
/// <summary>
/// Reference on view servcie to show modal notifications and to perform navigation.
/// </summary>
@ -73,6 +78,7 @@ namespace TINK.ViewModel.Bikes
/// </summary>
/// </param>
/// <param name="p_oUser">Mail address of active user.</param>
/// <param name="isReportLevelVerbose">True if report level is verbose, false if not.</param>
/// <param name="permissions">Holds object to query location permisions.</param>
/// <param name="bluetoothLE">Holds object to query bluetooth state.</param>
/// <param name="runtimPlatform">Specifies on which platform code is run.</param>
@ -81,6 +87,7 @@ namespace TINK.ViewModel.Bikes
/// <param name="lockService">Service to control lock retrieve info.</param>
/// <param name="p_oPolling"> Holds whether to poll or not and the periode leght is polling is on. </param>
/// <param name="postAction">Executes actions on GUI thread.</param>
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...)</param>
/// <param name="p_oViewService">Interface to actuate methodes on GUI.</param>
public BikesViewModel(
User user,
@ -93,19 +100,20 @@ namespace TINK.ViewModel.Bikes
ILocksService lockService,
TINK.Settings.PollingParameters polling,
Action<SendOrPostCallback, object> postAction,
ISmartDevice smartDevice,
IViewService viewService,
Func<IInUseStateInfoProvider> itemFactory)
{
User = user
?? throw new ArgumentException("Can not instantiate bikes page view model- object. No user available.");
RuntimePlatform = runtimPlatform
?? throw new ArgumentException("Can not instantiate bikes page view model- object. No runtime platform information available.");
Permissions = permissions
PermissionsService = permissions
?? throw new ArgumentException("Can not instantiate bikes page view model- object. No permissions available.");
BluetoothLE = bluetoothLE
BluetoothService = bluetoothLE
?? throw new ArgumentException("Can not instantiate bikes page view model- object. No bluetooth available.");
ConnectorFactory = connectorFactory
@ -126,6 +134,9 @@ namespace TINK.ViewModel.Bikes
PostAction = postAction
?? throw new ArgumentException("Can not instantiate bikes page view model- object. No post action available.");
SmartDevice = smartDevice
?? throw new ArgumentException("Can not instantiate bikes page view model- object. No smart device object available.");
ViewService = viewService
?? throw new ArgumentException("Can not instantiate bikes page view model- object. No view available.");
@ -137,7 +148,7 @@ namespace TINK.ViewModel.Bikes
m_oPolling = polling;
IsConnected = IsConnectedDelegate();
isConnected = IsConnectedDelegate();
CollectionChanged += (sender, eventargs) =>
{
@ -170,6 +181,7 @@ namespace TINK.ViewModel.Bikes
LockService,
(id) => Remove(id),
() => m_oViewUpdateManager,
SmartDevice,
ViewService,
l_oBike,
User,
@ -207,12 +219,24 @@ namespace TINK.ViewModel.Bikes
protected User User { get; private set; }
#if USCSHARP9
public bool IsReportLevelVerbose { get; init; }
#else
public bool IsReportLevelVerbose { get; set; }
#endif
/// <summary> Specified whether code is run under iOS or Android.</summary>
protected string RuntimePlatform { get; private set; }
protected IPermissions Permissions { get; private set; }
/// <summary>
/// Service to manage permissions (location) of the app.
/// </summary>
protected IPermissions PermissionsService { get; private set; }
protected IBluetoothLE BluetoothLE { get; private set; }
/// <summary>
/// Service to manage bluetooth stack.
/// </summary>
protected IBluetoothLE BluetoothService { get; private set; }
/// <summary>
/// User which is logged in.
@ -349,12 +373,14 @@ namespace TINK.ViewModel.Bikes
if (Exception != null)
{
// An error occurred getting data from copri.
return Exception.GetShortErrorInfoText();
return IsReportLevelVerbose
? Exception.GetShortErrorInfoText()
: AppResources.ActivityTextException;
}
if (!IsConnected)
{
return "Offline.";
return AppResources.ActivityTextConnectionStateOffline;
}
return ActionText ?? string.Empty;
@ -364,12 +390,12 @@ namespace TINK.ViewModel.Bikes
/// <summary>
/// Removes a bike view model by id.
/// </summary>
/// <param name="p_iId">Id of bike to removed.</param>
public void Remove(int p_iId)
/// <param name="id">Id of bike to removed.</param>
public void Remove(string id)
{
foreach (var bike in BikeCollection)
{
if (bike.Id == p_iId)
if (bike.Id == id)
{
BikeCollection.Remove(bike);
return;
@ -380,13 +406,13 @@ namespace TINK.ViewModel.Bikes
/// <summary>
/// Gets whether a bike is contained in collection of bikes.
/// </summary>
/// <param name="p_iId">Id of bike to check existance.</param>
/// <param name="id">Id of bike to check existance.</param>
/// <returns>True if bike exists.</returns>
private bool Contains(int p_iId)
private bool Contains(string id)
{
foreach (var l_oBike in Items)
{
if (l_oBike.Id == p_iId)
if (l_oBike.Id == id)
{
return true;
}