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

@ -12,7 +12,7 @@ namespace TINK.ViewModel
/// <returns>Display text</returns>
public string GetReservedInfo(
TimeSpan? remainingTime,
int? station = null,
string station = null,
string code = null)
{
if (remainingTime == null)
@ -40,7 +40,7 @@ namespace TINK.ViewModel
/// <returns>Display text</returns>
public string GetBookedInfo(
DateTime? from,
int? station = null,
string station = null,
string code = null)
{
if (from == null)

View file

@ -22,6 +22,8 @@ using Plugin.Permissions.Abstractions;
using Plugin.BLE.Abstractions.Contracts;
using TINK.MultilingualResources;
using Plugin.Permissions;
using TINK.Model.Station;
using TINK.Model.Device;
namespace TINK.ViewModel.BikesAtStation
{
@ -31,14 +33,9 @@ namespace TINK.ViewModel.BikesAtStation
public class BikesAtStationPageViewModel : BikesViewModel, INotifyCollectionChanged, INotifyPropertyChanged
{
/// <summary>
/// Reference on view servcie to show modal notifications and to perform navigation.
/// Holds the selected station;
/// </summary>
private IViewService m_oViewService;
/// <summary>
/// Holds the Id of the selected station;
/// </summary>
private readonly int? m_oStation;
private readonly IStation m_oStation;
/// <summary> Holds a reference to the external trigger service. </summary>
private Action<string> OpenUrlInExternalBrowser { get; }
@ -47,6 +44,7 @@ namespace TINK.ViewModel.BikesAtStation
/// 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>
@ -57,13 +55,14 @@ namespace TINK.ViewModel.BikesAtStation
/// <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>
/// <param name="viewService">Interface to actuate methodes on GUI.</param>
public BikesAtStationPageViewModel(
User user,
IPermissions permissions,
IBluetoothLE bluetoothLE,
string runtimPlatform,
int? selectedStation,
IStation selectedStation,
Func<bool> isConnectedDelegate,
Func<bool, IConnector> connectorFactory,
IGeolocation geolocation,
@ -71,18 +70,16 @@ namespace TINK.ViewModel.BikesAtStation
PollingParameters polling,
Action<string> openUrlInExternalBrowser,
Action<SendOrPostCallback, object> postAction,
IViewService viewService) : base(user, permissions, bluetoothLE, runtimPlatform, isConnectedDelegate, connectorFactory, geolocation, lockService, polling, postAction, viewService, () => new BikeAtStationInUseStateInfoProvider())
ISmartDevice smartDevice,
IViewService viewService) : base(user, permissions, bluetoothLE, runtimPlatform, isConnectedDelegate, connectorFactory, geolocation, lockService, polling, postAction, smartDevice, viewService, () => new BikeAtStationInUseStateInfoProvider())
{
m_oViewService = viewService
?? throw new ArgumentException("Can not instantiate bikes at station page view model- object. No view available.");
OpenUrlInExternalBrowser = openUrlInExternalBrowser
?? throw new ArgumentException("Can not instantiate login page view model- object. No user external browse service available.");
m_oStation = selectedStation;
Title = string.Format(m_oStation != null
? string.Format(AppResources.MarkingBikesAtStationTitle, m_oStation.ToString())
Title = string.Format(m_oStation?.StationName != null
? m_oStation.StationName
: string.Empty);
CollectionChanged += (sender, eventargs) =>
@ -161,19 +158,32 @@ namespace TINK.ViewModel.BikesAtStation
{
get
{
return new Xamarin.Forms.Command(() => OpenLoginPage());
#if USEMASTERDETAIL || USEFLYOUT
return new Xamarin.Forms.Command(() => OpenLoginPageAsync());
#else
return new Xamarin.Forms.Command(async () => await OpenLoginPageAsync());
#endif
}
}
/// <summary>
/// Opens login page.
/// </summary>
public void OpenLoginPage()
#if USEMASTERDETAIL || USEFLYOUT
public void OpenLoginPageAsync()
#else
public async Task OpenLoginPageAsync()
#endif
{
try
{
// Switch to map page
m_oViewService.ShowPage(ViewTypes.LoginPage);
#if USEMASTERDETAIL || USEFLYOUT
ViewService.ShowPage(ViewTypes.LoginPage);
#else
await ViewService.ShowPage("//LoginPage");
#endif
}
catch (Exception p_oException)
{
@ -188,7 +198,7 @@ namespace TINK.ViewModel.BikesAtStation
/// </summary>
public async Task OnAppearing()
{
Log.ForContext<BikesAtStationPageViewModel>().Information($"Bikes at station {m_oStation} is appearing, either due to tap on a station or to app being shown again.");
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.");
ActionText = "Einen Moment bitte...";
@ -201,15 +211,15 @@ namespace TINK.ViewModel.BikesAtStation
Exception = bikesAll.Exception; // Update communication error from query for bikes at station.
var bikesAtStation = bikesAll.Response.GetAtStation(m_oStation);
var bikesAtStation = bikesAll.Response.GetAtStation(m_oStation.Id);
var lockIdList = bikesAtStation
.GetLockIt()
.Cast<BikeInfo>()
.Select(x => x.LockInfo)
.ToList();
Title = string.Format(m_oStation != null
? m_oStation.ToString()
Title = string.Format(m_oStation?.StationName != null
? m_oStation.StationName
: string.Empty);
if (LockService is ILocksServiceFake serviceFake)
@ -223,14 +233,14 @@ namespace TINK.ViewModel.BikesAtStation
if (bikesAtStation.GetLockIt().Count > 0
&& RuntimePlatform == Device.Android)
{
var status = await Permissions.CheckPermissionStatusAsync<LocationPermission>();
var status = await PermissionsService.CheckPermissionStatusAsync<LocationPermission>();
if (status != PermissionStatus.Granted)
{
var permissionResult = await Permissions.RequestPermissionAsync<LocationPermission>();
var permissionResult = await PermissionsService.RequestPermissionAsync<LocationPermission>();
if (permissionResult != PermissionStatus.Granted)
{
var dialogResult = await m_oViewService.DisplayAlert(
var dialogResult = await ViewService.DisplayAlert(
AppResources.MessageTitleHint,
AppResources.MessageBikesManagementLocationPermissionOpenDialog,
AppResources.MessageAnswerYes,
@ -249,13 +259,13 @@ namespace TINK.ViewModel.BikesAtStation
}
// Open permissions dialog.
Permissions.OpenAppSettings();
PermissionsService.OpenAppSettings();
}
}
if (Geolocation.IsGeolcationEnabled == false)
{
await m_oViewService.DisplayAlert(
await ViewService.DisplayAlert(
AppResources.MessageTitleHint,
AppResources.MessageBikesManagementLocationActivation,
AppResources.MessageAnswerOk);
@ -270,9 +280,9 @@ namespace TINK.ViewModel.BikesAtStation
}
// Check if bluetooth is activated.
if (await BluetoothLE.GetBluetoothState() != BluetoothState.On)
if (await BluetoothService.GetBluetoothState() != BluetoothState.On)
{
await m_oViewService.DisplayAlert(
await ViewService.DisplayAlert(
AppResources.MessageTitleHint,
AppResources.MessageBikesManagementBluetoothActivation,
AppResources.MessageAnswerOk);
@ -319,14 +329,14 @@ namespace TINK.ViewModel.BikesAtStation
PostAction(
unused =>
{
ActionText = "Aktualisiere...";
ActionText = AppResources.ActivityTextUpdating;
IsConnected = IsConnectedDelegate();
},
null);
var result = ConnectorFactory(IsConnected).Query.GetBikesAsync().Result;
BikeCollection bikes = result.Response.GetAtStation(m_oStation);
BikeCollection bikes = result.Response.GetAtStation(m_oStation.Id);
var exception = result.Exception;
if (exception != null)