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

@ -1,28 +1,28 @@
using TINK.Model.Bike;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using TINK.Model.User;
using System.Threading.Tasks;
using TINK.Model.Connector;
using TINK.Settings;
using System;
using Serilog;
using System.Threading;
using TINK.Model;
using TINK.View;
using Xamarin.Forms;
using System.Linq;
using TINK.Model.Bike.BluetoothLock;
using System.Collections.Generic;
using TINK.Services.BluetoothLock;
using TINK.Services.Geolocation;
using TINK.ViewModel.Bikes;
using TINK.Services.BluetoothLock.Tdo;
using System.Threading;
using System.Threading.Tasks;
using Plugin.BLE.Abstractions.Contracts;
using TINK.MultilingualResources;
using TINK.Services.Permissions;
using TINK.Model.Station;
using Serilog;
using TINK.Model;
using TINK.Model.Bikes;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Connector;
using TINK.Model.Device;
using TINK.Model.Station;
using TINK.Model.User;
using TINK.MultilingualResources;
using TINK.Services.BluetoothLock;
using TINK.Services.BluetoothLock.Tdo;
using TINK.Services.Geolocation;
using TINK.Services.Permissions;
using TINK.Settings;
using TINK.View;
using TINK.ViewModel.Bikes;
using Xamarin.Forms;
namespace TINK.ViewModel.BikesAtStation
{
@ -34,21 +34,19 @@ namespace TINK.ViewModel.BikesAtStation
/// <summary>
/// Holds the selected station;
/// </summary>
private readonly IStation m_oStation;
private IStation Station { get; }
/// <summary>
/// Constructs bike collection view model.
/// </summary>
/// <param name="user">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>
/// <param name="isConnectedDelegate">Returns if mobile is connected to web or not.</param>
/// <param name="p_oConnector">Connects system to copri.</param>
/// <param name="connectorFactory">Connects system to copri.</param>
/// <param name="lockService">Service to control lock retrieve info.</param>
/// <param name="polling"> Holds whether to poll or not and the periode leght is polling is on. </param>
/// <param name="l_oBikesAll">All bikes at given station.</param>
/// <param name="openUrlInExternalBrowser">Action to open an external browser.</param>
/// <param name="postAction">Executes actions on GUI thread.</param>
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
@ -67,17 +65,15 @@ namespace TINK.ViewModel.BikesAtStation
Action<string> openUrlInExternalBrowser,
Action<SendOrPostCallback, object> postAction,
ISmartDevice smartDevice,
IViewService viewService) : base(user, permissions, bluetoothLE, runtimPlatform, isConnectedDelegate, connectorFactory, geolocation, lockService, polling, postAction, smartDevice, viewService, openUrlInExternalBrowser, () => new BikeAtStationInUseStateInfoProvider())
IViewService viewService) : base(user, permissions, bluetoothLE, runtimPlatform, isConnectedDelegate, connectorFactory, geolocation, lockService, polling, postAction, smartDevice, viewService, openUrlInExternalBrowser, () => new BikeAtStationInUseStateInfoProvider())
{
m_oStation = selectedStation;
Station = selectedStation ?? new NullStation();
Title = string.Format(m_oStation?.StationName != null
? m_oStation.StationName
: string.Empty);
StationDetailText = string.Format(m_oStation?.Id != null
? string.Format(AppResources.MarkingBikesAtStationStationId, m_oStation.Id)
: string.Empty); ;
Title = Station.StationName;
StationDetailText = Station.Id != null
? string.Format(AppResources.MarkingBikesAtStationStationId, Station.Id)
: string.Empty;
CollectionChanged += (sender, eventargs) =>
{
@ -102,7 +98,7 @@ namespace TINK.ViewModel.BikesAtStation
{
get
{
return Count > 0
return Count > 0
&& !ActiveUser.IsLoggedIn;
}
}
@ -111,12 +107,12 @@ namespace TINK.ViewModel.BikesAtStation
/// Informs about need to log in before requesting an bike.
/// </summary>
public string LoginRequiredHintText
=> ActiveUser.IsLoggedIn
=> ActiveUser.IsLoggedIn
? string.Empty
: AppResources.MarkingLoginRequiredToRerserve;
public string ContactSupportHintText
=> string.Format(AppResources.MarkingContactSupport, m_oStation?.OperatorData?.Name ?? "Operator");
=> string.Format(AppResources.MarkingContactSupport, Station.OperatorData?.Name ?? "Operator");
/// <summary>
/// Returns if info about the fact that user did not request or book any bikes is visible or not.
@ -213,7 +209,7 @@ namespace TINK.ViewModel.BikesAtStation
/// </summary>
public async Task OnAppearing()
{
Log.ForContext<BikesAtStationPageViewModel>().Information($"Bikes at station {m_oStation?.StationName} is appearing, either due to tap on a station or to app being shown again.");
Log.ForContext<BikesAtStationPageViewModel>().Information($"Bikes at station {Station.StationName} is appearing, either due to tap on a station or to app being shown again.");
ActionText = "Einen Moment bitte...";
@ -223,13 +219,13 @@ namespace TINK.ViewModel.BikesAtStation
ActionText = AppResources.ActivityTextBikesAtStationGetBikes;
var bikesAll = await ConnectorFactory(IsConnected).Query.GetBikesAsync();
Exception = bikesAll.Exception; // Update communication error from query for bikes at station.
var bikesAtStation = bikesAll.Response.GetAtStation(m_oStation.Id);
var bikesAtStation = bikesAll.Response.GetAtStation(Station.Id);
var lockIdList = bikesAtStation
.GetLockIt()
.Cast<BikeInfo>()
.Cast<Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo>()
.Select(x => x.LockInfo)
.ToList();
@ -260,7 +256,7 @@ namespace TINK.ViewModel.BikesAtStation
if (!dialogResult)
{
// User decided not to give access to locations permissions.
BikeCollection.Update(bikesAtStation, new List<IStation> { m_oStation});
BikeCollection.Update(bikesAtStation, new List<IStation> { Station });
await OnAppearing(() => UpdateTask());
@ -281,7 +277,7 @@ namespace TINK.ViewModel.BikesAtStation
AppResources.MessageBikesManagementLocationActivation,
AppResources.MessageAnswerOk);
BikeCollection.Update(bikesAtStation, new List<IStation> { m_oStation });
BikeCollection.Update(bikesAtStation, new List<IStation> { Station });
await OnAppearing(() => UpdateTask());
@ -297,7 +293,7 @@ namespace TINK.ViewModel.BikesAtStation
AppResources.MessageBikesManagementBluetoothActivation,
AppResources.MessageAnswerOk);
BikeCollection.Update(bikesAtStation, new List<IStation> { m_oStation });
BikeCollection.Update(bikesAtStation, new List<IStation> { Station });
await OnAppearing(() => UpdateTask());
@ -324,7 +320,7 @@ namespace TINK.ViewModel.BikesAtStation
var locksInfo = lockIdList.UpdateById(locksInfoTdo);
BikeCollection.Update(bikesAtStation.UpdateLockInfo(locksInfo), new List<IStation> { m_oStation });
BikeCollection.Update(bikesAtStation.UpdateLockInfo(locksInfo), new List<IStation> { Station });
// Backup GUI synchronization context.
await OnAppearing(() => UpdateTask());
@ -339,6 +335,7 @@ namespace TINK.ViewModel.BikesAtStation
PostAction(
unused =>
{
Log.ForContext<BikesAtStationPageViewModel>().Debug("Updating action text...");
ActionText = AppResources.ActivityTextUpdating;
IsConnected = IsConnectedDelegate();
},
@ -346,7 +343,7 @@ namespace TINK.ViewModel.BikesAtStation
var result = ConnectorFactory(IsConnected).Query.GetBikesAsync().Result;
BikeCollection bikes = result.Response.GetAtStation(m_oStation.Id);
BikeCollection bikes = result.Response.GetAtStation(Station.Id);
var exception = result.Exception;
if (exception != null)
@ -357,11 +354,12 @@ namespace TINK.ViewModel.BikesAtStation
PostAction(
unused =>
{
BikeCollection.Update(bikes, new List<IStation> { m_oStation });
Log.ForContext<BikesAtStationPageViewModel>().Debug("Updating bikes at station...");
BikeCollection.Update(bikes, new List<IStation> { Station });
Exception = result.Exception;
ActionText = string.Empty;
},
null);
null);
}
/// <summary>