mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-19 03:27:29 +02:00
Version 3.0.356
This commit is contained in:
parent
d23aff6daf
commit
5980410182
48 changed files with 242 additions and 362 deletions
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
|
@ -127,7 +127,7 @@ namespace TINK.Model.Connector
|
|||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task DoBook(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike)
|
||||
public async Task DoBookAsync(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike, LockingAction? nextAction = null)
|
||||
{
|
||||
Log.ForContext<Command>().Error("Unexpected booking request detected. No user logged in.");
|
||||
await Task.CompletedTask;
|
||||
|
@ -184,4 +184,4 @@ namespace TINK.Model.Connector
|
|||
public Task CloseLockAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike)
|
||||
=> throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,8 @@ namespace TINK.Model.Connector
|
|||
|
||||
/// <summary> Request to book a bike. </summary>
|
||||
/// <param name="bike">Bike to book.</param>
|
||||
public async Task DoBook(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike)
|
||||
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
|
||||
public async Task DoBookAsync(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike, LockingAction? nextAction = null)
|
||||
{
|
||||
if (bike == null)
|
||||
{
|
||||
|
@ -251,10 +252,11 @@ namespace TINK.Model.Connector
|
|||
double batteryPercentage = btBike != null ? btBike.LockInfo.BatteryPercentage : double.NaN;
|
||||
|
||||
response = (await CopriServer.DoBookAsync(
|
||||
bike.OperatorUri,
|
||||
bike.Id,
|
||||
guid,
|
||||
batteryPercentage,
|
||||
bike.OperatorUri)).GetIsBookingResponseOk(bike.Id);
|
||||
nextAction)).GetIsBookingResponseOk(bike.Id);
|
||||
|
||||
bike.Load(
|
||||
response,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
|
@ -49,7 +49,8 @@ namespace TINK.Model.Connector
|
|||
|
||||
/// <summary> Request to book a bike.</summary>
|
||||
/// <param name="bike">Bike to book.</param>
|
||||
Task DoBook(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike);
|
||||
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
|
||||
Task DoBookAsync(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike, LockingAction? nextAction = null);
|
||||
|
||||
/// <summary> Request to book a bike and open its lock.</summary>
|
||||
/// <param name="bike">Bike to book and to open lock for.</param>
|
||||
|
@ -163,4 +164,14 @@ namespace TINK.Model.Connector
|
|||
|
||||
public string Mail { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes a action to be performed with an lock.
|
||||
/// </summary>
|
||||
public enum LockingAction
|
||||
{
|
||||
Close,
|
||||
Open,
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -662,6 +662,16 @@ namespace TINK.Model
|
|||
AppResources.ChangeLog_PackageUpdates,
|
||||
new List<AppFlavor> { AppFlavor.MeinKonrad, AppFlavor.ShareeBike }
|
||||
},
|
||||
{
|
||||
new Version(3, 0, 355),
|
||||
AppResources.ChangeLog_3_0_355_MK_SB_iOS,
|
||||
new List<AppFlavor> { AppFlavor.MeinKonrad, AppFlavor.ShareeBike },
|
||||
new List<DevicePlatform> { DevicePlatform.iOS }
|
||||
},
|
||||
{
|
||||
new Version(3, 0, 356),
|
||||
AppResources.ChangeLog3_0_231
|
||||
},
|
||||
};
|
||||
|
||||
/// <summary> Manges the whats new information.</summary>
|
||||
|
|
|
@ -738,6 +738,15 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bluetooth communication improved..
|
||||
/// </summary>
|
||||
public static string ChangeLog_3_0_355_MK_SB_iOS {
|
||||
get {
|
||||
return ResourceManager.GetString("ChangeLog_3_0_355_MK_SB_iOS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to We have fixed some bugs. Enjoy the ride!.
|
||||
/// </summary>
|
||||
|
|
|
@ -1111,4 +1111,7 @@ Probieren Sie es aus!</value>
|
|||
<data name="ChangeLog_PackageUpdates" xml:space="preserve">
|
||||
<value>Softwarepakete wurden aktualisiert.</value>
|
||||
</data>
|
||||
<data name="ChangeLog_3_0_355_MK_SB_iOS" xml:space="preserve">
|
||||
<value>Bluetooth-Kommunikation verbessert.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1201,4 +1201,7 @@ Try it out!</value>
|
|||
<data name="ChangeLog_PackageUpdates" xml:space="preserve">
|
||||
<value>Software packages were updated.</value>
|
||||
</data>
|
||||
<data name="ChangeLog_3_0_355_MK_SB_iOS" xml:space="preserve">
|
||||
<value>Bluetooth communication improved.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1520,6 +1520,10 @@ Probieren Sie es aus!</target>
|
|||
<source>Software packages were updated.</source>
|
||||
<target state="translated">Softwarepakete wurden aktualisiert.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ChangeLog_3_0_355_MK_SB_iOS" translate="yes" xml:space="preserve">
|
||||
<source>Bluetooth communication improved.</source>
|
||||
<target state="translated">Bluetooth-Kommunikation verbessert.</target>
|
||||
</trans-unit>
|
||||
</group>
|
||||
</body>
|
||||
</file>
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.Logging;
|
||||
using TINK.Repository.Exception;
|
||||
|
@ -181,19 +182,21 @@ namespace TINK.Repository
|
|||
UserAgent);
|
||||
|
||||
/// <summary> Gets booking request request. </summary>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
|
||||
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
|
||||
/// <returns>Requst on booking request.</returns>
|
||||
public async Task<ReservationBookingResponse> DoBookAsync(
|
||||
Uri operatorUri,
|
||||
string bikeId,
|
||||
Guid guid,
|
||||
double batteryPercentage,
|
||||
Uri operatorUri)
|
||||
double batteryPercentage,
|
||||
LockingAction? nextAction = null)
|
||||
=> await DoBookAsync(
|
||||
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
|
||||
requestBuilder.DoBook(bikeId, guid, batteryPercentage),
|
||||
requestBuilder.DoBook(bikeId, guid, batteryPercentage, nextAction),
|
||||
UserAgent);
|
||||
|
||||
/// <summary> Books a bike and starts opening bike. </summary>
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Repository.Response;
|
||||
|
@ -1640,7 +1641,7 @@ namespace TINK.Repository
|
|||
double batteryLevel,
|
||||
IVersionInfo versionInfo) => null;
|
||||
|
||||
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
public Task<ReservationBookingResponse> DoBookAsync(Uri operatorUri, string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
|
||||
=> null;
|
||||
|
||||
public Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Threading.Tasks;
|
||||
using MonkeyCache.FileStore;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.Services.CopriApi;
|
||||
using TINK.Repository.Request;
|
||||
|
@ -176,7 +177,7 @@ namespace TINK.Repository
|
|||
IVersionInfo versionInfo)
|
||||
=> throw new System.Exception("Aktualisierung des Schlossstatuses im Offlinemodus nicht möglich!");
|
||||
|
||||
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
public Task<ReservationBookingResponse> DoBookAsync(Uri operatorUri, string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
|
||||
=> throw new System.Exception("Buchung im Offlinemodus nicht möglich!");
|
||||
|
||||
/// <summary> Books a bike and starts opening bike. </summary>
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Repository.Response;
|
||||
|
@ -74,16 +75,18 @@ namespace TINK.Repository
|
|||
IVersionInfo versionInfo = null);
|
||||
|
||||
/// <summary> Books a bluetooth bike. </summary>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
|
||||
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
|
||||
/// <returns>Response on booking request.</returns>
|
||||
Task<ReservationBookingResponse> DoBookAsync(
|
||||
Uri operatorUri,
|
||||
string bikeId,
|
||||
Guid guid,
|
||||
double batteryPercentage,
|
||||
Uri operatorUri);
|
||||
double batteryPercentage,
|
||||
LockingAction? nextAction = null);
|
||||
|
||||
/// <summary> Books a bike and starts opening bike. </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
|
||||
namespace TINK.Repository.Request
|
||||
|
@ -79,8 +80,9 @@ namespace TINK.Repository.Request
|
|||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
|
||||
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
|
||||
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
|
||||
/// <returns>Request to booking bike.</returns>
|
||||
string DoBook(string bikeId, Guid guid, double batteryPercentage);
|
||||
string DoBook(string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null);
|
||||
|
||||
/// <summary> Gets the request to book and start opening the bike (synonym: booking == renting == mieten). </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
|
||||
|
@ -109,7 +110,7 @@ namespace TINK.Repository.Request
|
|||
public string UpateLockingState(string bikeId, lock_state state, LocationDto geolocation, double batteryPercentage, IVersionInfo versionInfo)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <summary> Gets the request to book and start opening the bike (synonym: booking == renting == mieten). </summary>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
|
||||
using TINK.Model.Connector;
|
||||
|
||||
namespace TINK.Repository.Request
|
||||
{
|
||||
public static class RequestBuilderHelper
|
||||
|
@ -12,5 +14,20 @@ namespace TINK.Repository.Request
|
|||
=> !string.IsNullOrEmpty(uiIsoLangugageName)
|
||||
? $"&lang={uiIsoLangugageName}"
|
||||
: string.Empty;
|
||||
|
||||
public static lock_state? GetLockState(this LockingAction? action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case LockingAction.Open:
|
||||
return lock_state.unlocking;
|
||||
|
||||
case LockingAction.Close:
|
||||
return lock_state.locking;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Globalization;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Services.Logging;
|
||||
|
@ -153,14 +154,15 @@ namespace TINK.Repository.Request
|
|||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
|
||||
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
|
||||
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
|
||||
/// <returns>Request to booking bike.</returns>
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
$"&Ilockit_GUID={guid}" +
|
||||
"&state=occupied" +
|
||||
GetLockStateParameter(lock_state.unlocked) +
|
||||
GetLockStateParameter(nextAction.GetLockState()) +
|
||||
GetBatteryPercentageParameters(batteryPercentage) +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
|
@ -269,9 +271,12 @@ namespace TINK.Repository.Request
|
|||
private static string GetBikeIdParameter(string bikeId)
|
||||
=> $"&bike={bikeId}";
|
||||
|
||||
private static string GetLockStateParameter(lock_state lockState)
|
||||
=> $"&lock_state={lockState}";
|
||||
private static string GetLockStateParameter(lock_state? lockState)
|
||||
=> lockState.HasValue ? $"&lock_state={lockState}" : string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the battery level percentage parameter if percentage is not NaN an empty string otherwise.
|
||||
/// </summary>
|
||||
private static string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
? $"&voltage={batteryPercentage.ToString(CultureInfo.InvariantCulture)}"
|
||||
: string.Empty;
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Connector.Updater;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository;
|
||||
|
@ -243,12 +244,14 @@ namespace TINK.Model.Services.CopriApi
|
|||
versionInfo);
|
||||
|
||||
/// <summary> Books a bike. </summary>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
|
||||
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
|
||||
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
|
||||
/// <returns>Response on booking request.</returns>
|
||||
public async Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
=> await HttpsServer.DoBookAsync(bikeId, guid, batteryPercentage, operatorUri);
|
||||
public async Task<ReservationBookingResponse> DoBookAsync(Uri operatorUri, string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
|
||||
=> await HttpsServer.DoBookAsync(operatorUri, bikeId, guid, batteryPercentage, nextAction);
|
||||
|
||||
/// <summary> Books a bike and starts opening bike. </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository;
|
||||
using TINK.Repository.Request;
|
||||
|
@ -65,8 +66,8 @@ namespace TINK.Model.Services.CopriApi
|
|||
batteryLevel,
|
||||
versionInfo);
|
||||
|
||||
public async Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
=> await monkeyStore.DoBookAsync(bikeId, guid, batteryPercentage, operatorUri);
|
||||
public async Task<ReservationBookingResponse> DoBookAsync(Uri operatorUri, string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
|
||||
=> await monkeyStore.DoBookAsync(operatorUri, bikeId, guid, batteryPercentage, nextAction);
|
||||
|
||||
public async Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(
|
||||
string bikeId,
|
||||
|
|
|
@ -222,7 +222,7 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
IsConnected = IsConnectedDelegate();
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(IsConnected).Command.DoBook(SelectedBike);
|
||||
await ConnectorFactory(IsConnected).Command.DoBookAsync(SelectedBike, LockingAction.Open);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
IsConnected = IsConnectedDelegate();
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(IsConnected).Command.DoBook(SelectedBike);
|
||||
await ConnectorFactory(IsConnected).Command.DoBookAsync(SelectedBike);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
|
|
|
@ -187,7 +187,7 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
IsConnected = IsConnectedDelegate();
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(IsConnected).Command.DoBook(SelectedBike);
|
||||
await ConnectorFactory(IsConnected).Command.DoBookAsync(SelectedBike, LockingAction.Open);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
|
|
|
@ -350,7 +350,7 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
IsConnected = IsConnectedDelegate();
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(IsConnected).Command.DoBook(SelectedBike);
|
||||
await ConnectorFactory(IsConnected).Command.DoBookAsync(SelectedBike, LockingAction.Open);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
IsConnected = IsConnectedDelegate();
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(IsConnected).Command.DoBook(SelectedBike);
|
||||
await ConnectorFactory(IsConnected).Command.DoBookAsync(SelectedBike);
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
|
|
|
@ -858,98 +858,6 @@ namespace TINK.ViewModel.Map
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary> Command object to bind CurrentLocation Button to view model.</summary>
|
||||
public System.Windows.Input.ICommand OnCurrentLocationButtonClicked => new Xamarin.Forms.Command(async () => await CenterToCurrentLocation());
|
||||
|
||||
/// <summary> User request to center to currentLocation. </summary>
|
||||
public async Task CenterToCurrentLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
|
||||
IsMapPageEnabled = false;
|
||||
|
||||
Log.ForContext<MapPageViewModel>().Information($"Request to center to current position.");
|
||||
|
||||
// Stop polling.
|
||||
//ActionText = AppResources.ActivityTextOneMomentPlease;
|
||||
await m_oViewUpdateManager.StopUpdatePeridically();
|
||||
|
||||
// Clear error info.
|
||||
Exception = null;
|
||||
|
||||
ActiveFilterMap = tinkKonradToggleViewModel.FilterDictionary;
|
||||
TinkApp.GroupFilterMapPage = ActiveFilterMap;
|
||||
TinkApp.Save();
|
||||
|
||||
TinkApp.UpdateConnector();
|
||||
|
||||
// Check location permission
|
||||
var status = await RequestLocationPermission();
|
||||
if (status == Status.Granted)
|
||||
{
|
||||
// Move and scale.
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
if (currentLocation != null)
|
||||
{
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
|
||||
TinkApp.UserMapSpan = MapSpan.FromCenterAndRadius(
|
||||
new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
|
||||
TinkApp.ActiveMapSpan.Radius);
|
||||
|
||||
TinkApp.Save();
|
||||
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.ActiveMapSpan);
|
||||
|
||||
try
|
||||
{
|
||||
// Update bikes at station or my bikes depending on context.
|
||||
await m_oViewUpdateManager.StartUpdateAyncPeridically(Polling);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Excpetions are handled insde update task;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageErrorLocationIsOff,
|
||||
AppResources.MessageAnswerOk);
|
||||
}
|
||||
}
|
||||
|
||||
IsMapPageEnabled = true;
|
||||
Log.ForContext<MapPageViewModel>().Information($"Center to current Position done.");
|
||||
ActionText = String.Empty;
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("An error occurred while centering to current position.");
|
||||
ActionText = String.Empty;
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
"Fehler",
|
||||
AppResources.MessageMapPageErrorSwitch,
|
||||
String.Format(AppResources.MessageErrorQueryLocationMessage, l_oException.Message),
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
IsMapPageEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Command object to bind login button to view model.</summary>
|
||||
public System.Windows.Input.ICommand OnToggleTinkToKonrad => new Xamarin.Forms.Command(async () => await ToggleTinkToKonrad());
|
||||
|
||||
|
@ -1015,43 +923,6 @@ namespace TINK.ViewModel.Map
|
|||
|
||||
Pins.Clear();
|
||||
|
||||
//// Move and scale before getting stations and bikes which takes some time.
|
||||
//if (TinkApp.CenterMapToCurrentLocation)
|
||||
//{
|
||||
// // Check location permission
|
||||
// //ActionText = AppResources.ActivityTextRequestingLocationPermissions;
|
||||
// var status = await RequestLocationPermission();
|
||||
// if (status == Status.Granted)
|
||||
// {
|
||||
// //ActionText = AppResources.ActivityTextCenterMap;
|
||||
|
||||
// Location currentLocation = null;
|
||||
// try
|
||||
// {
|
||||
// currentLocation = await GeolocationService.GetAsync();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
// }
|
||||
|
||||
// if (currentLocation != null)
|
||||
// {
|
||||
// TinkApp.UserMapSpan = MapSpan.FromCenterAndRadius(
|
||||
// new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
|
||||
// TinkApp.ActiveMapSpan.Radius);
|
||||
|
||||
// TinkApp.Save();
|
||||
|
||||
// //MoveAndScale(m_oMoveToRegionDelegate, TinkApp.ActiveMapSpan);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ActionText = AppResources.ActivityTextErrorQueryLocationWhenAny;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
// Update stations
|
||||
ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
|
||||
IsConnected = TinkApp.GetIsConnected();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue