mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-22 12:56:29 +02:00
Version 3.0.353
This commit is contained in:
parent
5ea2e3b0ca
commit
85321580df
57 changed files with 1421 additions and 888 deletions
|
@ -652,6 +652,11 @@ namespace TINK.Model
|
|||
AppResources.ChangeLog_MinorDesignImprovements,
|
||||
new List<AppFlavor> { AppFlavor.MeinKonrad, AppFlavor.ShareeBike }
|
||||
},
|
||||
{
|
||||
new Version(3, 0, 353),
|
||||
AppResources.ChangeLog_3_0_353_MK_SB,
|
||||
new List<AppFlavor> { AppFlavor.MeinKonrad, AppFlavor.ShareeBike }
|
||||
},
|
||||
};
|
||||
|
||||
/// <summary> Manges the whats new information.</summary>
|
||||
|
|
|
@ -259,7 +259,7 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <h4><b>Lock is closing.<br/>Please visually check if it is completely closed.</b></h4>.
|
||||
/// Looks up a localized string similar to <h4><b>Lock is closing.<br/>Please wait until it is completely closed.</b></h4>.
|
||||
/// </summary>
|
||||
public static string ActivityTextClosingLock {
|
||||
get {
|
||||
|
@ -349,7 +349,7 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No location info available..
|
||||
/// Looks up a localized string similar to No location info available. Activate your device's location services..
|
||||
/// </summary>
|
||||
public static string ActivityTextErrorQueryLocationWhenAny {
|
||||
get {
|
||||
|
@ -628,7 +628,7 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Updateing.....
|
||||
/// Looks up a localized string similar to Updating.....
|
||||
/// </summary>
|
||||
public static string ActivityTextUpdating {
|
||||
get {
|
||||
|
@ -725,6 +725,19 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Improvements in
|
||||
///<ul>
|
||||
///<li/>- Management of location services
|
||||
///<li/>- Design of processes
|
||||
///</ul>.
|
||||
/// </summary>
|
||||
public static string ChangeLog_3_0_353_MK_SB {
|
||||
get {
|
||||
return ResourceManager.GetString("ChangeLog_3_0_353_MK_SB", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to We have fixed some bugs. Enjoy the ride!.
|
||||
/// </summary>
|
||||
|
@ -2524,6 +2537,15 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Turn on your device's location services to center the map on your current location..
|
||||
/// </summary>
|
||||
public static string MessageErrorLocationIsOff {
|
||||
get {
|
||||
return ResourceManager.GetString("MessageErrorLocationIsOff", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Attention: Lock is closed!
|
||||
///{0}
|
||||
|
|
|
@ -334,7 +334,7 @@ Freigabedialog öffen?</value>
|
|||
<value>Einen Moment bitte...</value>
|
||||
</data>
|
||||
<data name="ActivityTextOpeningLock" xml:space="preserve">
|
||||
<value><h4><b>Schloss öffnet.<br/>Bitte warten Sie, bis es komplett geöffnet ist.</b></h4></value>
|
||||
<value><h4><b>Schloss öffnet.<br/>Bitte warten Sie bis es komplett geöffnet ist.</b></h4></value>
|
||||
</data>
|
||||
<data name="ActivityTextStartingUpdater" xml:space="preserve">
|
||||
<value>Starte Aktualisierung...</value>
|
||||
|
@ -355,7 +355,7 @@ Freigabedialog öffen?</value>
|
|||
<value>Kein Netz beim Aktualisieren des Schlossstatusses.</value>
|
||||
</data>
|
||||
<data name="ActivityTextClosingLock" xml:space="preserve">
|
||||
<value><h4><b>Schloss schließt.<br/>Bitte überprüfen Sie visuell, ob es komplett geschlossen ist.</b></h4></value>
|
||||
<value><h4><b>Schloss schließt.<br/>Bitte warten Sie bis es komplett geschlossen ist.</b></h4></value>
|
||||
</data>
|
||||
<data name="ChangeLog3_0_203" xml:space="preserve">
|
||||
<value>Aktualisierrt auf aktuelle Schloss-Firmware.</value>
|
||||
|
@ -666,7 +666,7 @@ Kleinere Verbesserungen.</value>
|
|||
<value>Fehler beim Start der Standortabfrage!</value>
|
||||
</data>
|
||||
<data name="ActivityTextErrorQueryLocationWhenAny" xml:space="preserve">
|
||||
<value>Keine Standortinfo verfügbar.</value>
|
||||
<value>Keine Standortinfo verfügbar. Aktivieren Sie die Standortdienste Ihres Geräts.</value>
|
||||
</data>
|
||||
<data name="ActivityTextErrorQueryLocationQuery" xml:space="preserve">
|
||||
<value>Standortabfrage nicht möglich.</value>
|
||||
|
@ -1098,4 +1098,14 @@ Beim Login können Sie nun Ihr eingegebenes Passwort einsehen.<br/>
|
|||
<br/>
|
||||
Probieren Sie es aus!</value>
|
||||
</data>
|
||||
<data name="MessageErrorLocationIsOff" xml:space="preserve">
|
||||
<value>Schalten Sie die Standortdienste Ihres Geräts ein, um die Karte auf Ihren aktuellen Standort zu zentrieren.</value>
|
||||
</data>
|
||||
<data name="ChangeLog_3_0_353_MK_SB" xml:space="preserve">
|
||||
<value>Verbesserungen im
|
||||
<ul>
|
||||
<li/>- Management der Standortdienste
|
||||
<li/>- Design von Prozessen
|
||||
</ul></value>
|
||||
</data>
|
||||
</root>
|
|
@ -460,7 +460,7 @@ Open sharing dialog?</value>
|
|||
<value>No web error on updating locking status.</value>
|
||||
</data>
|
||||
<data name="ActivityTextClosingLock" xml:space="preserve">
|
||||
<value><h4><b>Lock is closing.<br/>Please visually check if it is completely closed.</b></h4></value>
|
||||
<value><h4><b>Lock is closing.<br/>Please wait until it is completely closed.</b></h4></value>
|
||||
</data>
|
||||
<data name="ChangeLog3_0_203" xml:space="preserve">
|
||||
<value>Updated to latest lock firmware.</value>
|
||||
|
@ -662,7 +662,7 @@ Please contact the support for help.</value>
|
|||
<value>Submitting feedback failed!</value>
|
||||
</data>
|
||||
<data name="ActivityTextUpdating" xml:space="preserve">
|
||||
<value>Updateing....</value>
|
||||
<value>Updating....</value>
|
||||
</data>
|
||||
<data name="ChangeLog3_0_231" xml:space="preserve">
|
||||
<value>Minor improvements.</value>
|
||||
|
@ -756,7 +756,7 @@ Minor fixes.</value>
|
|||
<value>Can not query location info.</value>
|
||||
</data>
|
||||
<data name="ActivityTextErrorQueryLocationWhenAny" xml:space="preserve">
|
||||
<value>No location info available.</value>
|
||||
<value>No location info available. Activate your device's location services.</value>
|
||||
</data>
|
||||
<data name="ActivityTextQueryLocation" xml:space="preserve">
|
||||
<value>Query location...</value>
|
||||
|
@ -1188,4 +1188,14 @@ When logging in, you can now view the password you entered. <br/>
|
|||
<br/>
|
||||
Try it out!</value>
|
||||
</data>
|
||||
<data name="MessageErrorLocationIsOff" xml:space="preserve">
|
||||
<value>Turn on your device's location services to center the map on your current location.</value>
|
||||
</data>
|
||||
<data name="ChangeLog_3_0_353_MK_SB" xml:space="preserve">
|
||||
<value>Improvements in
|
||||
<ul>
|
||||
<li/>- Management of location services
|
||||
<li/>- Design of processes
|
||||
</ul></value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -442,7 +442,7 @@ Freigabedialog öffen?</target>
|
|||
</trans-unit>
|
||||
<trans-unit id="ActivityTextOpeningLock" translate="yes" xml:space="preserve">
|
||||
<source><bpt id="1"><h4></bpt><bpt id="2"><b></bpt>Lock is opening.<br/>Please wait until it is completely open.<ept id="2"></b></ept><ept id="1"></h4></ept></source>
|
||||
<target state="translated"><bpt id="1"><h4></bpt><bpt id="2"><b></bpt>Schloss öffnet.<br/>Bitte warten Sie, bis es komplett geöffnet ist.<ept id="2"></b></ept><ept id="1"></h4></ept></target>
|
||||
<target state="translated"><bpt id="1"><h4></bpt><bpt id="2"><b></bpt>Schloss öffnet.<br/>Bitte warten Sie bis es komplett geöffnet ist.<ept id="2"></b></ept><ept id="1"></h4></ept></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ActivityTextStartingUpdater" translate="yes" xml:space="preserve">
|
||||
<source>Updating...</source>
|
||||
|
@ -469,8 +469,8 @@ Freigabedialog öffen?</target>
|
|||
<target state="translated">Kein Netz beim Aktualisieren des Schlossstatusses.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ActivityTextClosingLock" translate="yes" xml:space="preserve">
|
||||
<source><bpt id="1"><h4></bpt><bpt id="2"><b></bpt>Lock is closing.<br/>Please visually check if it is completely closed.<ept id="2"></b></ept><ept id="1"></h4></ept></source>
|
||||
<target state="translated"><bpt id="1"><h4></bpt><bpt id="2"><b></bpt>Schloss schließt.<br/>Bitte überprüfen Sie visuell, ob es komplett geschlossen ist.<ept id="2"></b></ept><ept id="1"></h4></ept></target>
|
||||
<source><bpt id="1"><h4></bpt><bpt id="2"><b></bpt>Lock is closing.<br/>Please wait until it is completely closed.<ept id="2"></b></ept><ept id="1"></h4></ept></source>
|
||||
<target state="translated"><bpt id="1"><h4></bpt><bpt id="2"><b></bpt>Schloss schließt.<br/>Bitte warten Sie bis es komplett geschlossen ist.<ept id="2"></b></ept><ept id="1"></h4></ept></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ChangeLog3_0_203" translate="yes" xml:space="preserve">
|
||||
<source>Updated to latest lock firmware.</source>
|
||||
|
@ -744,7 +744,7 @@ Bitte kontaktieren sie den Support!</target>
|
|||
<target state="translated">Übermittlung der Rückmeldung fehlgeschlagen!</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ActivityTextUpdating" translate="yes" xml:space="preserve">
|
||||
<source>Updateing....</source>
|
||||
<source>Updating....</source>
|
||||
<target state="translated">Aktualisiere....</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ChangeLog3_0_231" translate="yes" xml:space="preserve">
|
||||
|
@ -892,8 +892,8 @@ Kleinere Verbesserungen.</target>
|
|||
<target state="translated">Fehler beim Start der Standortabfrage!</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ActivityTextErrorQueryLocationWhenAny" translate="yes" xml:space="preserve">
|
||||
<source>No location info available.</source>
|
||||
<target state="translated">Keine Standortinfo verfügbar.</target>
|
||||
<source>No location info available. Activate your device's location services.</source>
|
||||
<target state="translated">Keine Standortinfo verfügbar. Aktivieren Sie die Standortdienste Ihres Geräts.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ActivityTextErrorQueryLocationQuery" translate="yes" xml:space="preserve">
|
||||
<source>Can not query location info.</source>
|
||||
|
@ -1500,6 +1500,22 @@ Beim Login können Sie nun Ihr eingegebenes Passwort einsehen.<br/>
|
|||
<br/>
|
||||
Probieren Sie es aus!</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MessageErrorLocationIsOff" translate="yes" xml:space="preserve">
|
||||
<source>Turn on your device's location services to center the map on your current location.</source>
|
||||
<target state="translated">Schalten Sie die Standortdienste Ihres Geräts ein, um die Karte auf Ihren aktuellen Standort zu zentrieren.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ChangeLog_3_0_353_MK_SB" translate="yes" xml:space="preserve">
|
||||
<source>Improvements in
|
||||
<bpt id="1"><ul></bpt>
|
||||
<li/>- Management of location services
|
||||
<li/>- Design of processes
|
||||
<ept id="1"></ul></ept></source>
|
||||
<target state="translated">Verbesserungen im
|
||||
<bpt id="1"><ul></bpt>
|
||||
<li/>- Management der Standortdienste
|
||||
<li/>- Design von Prozessen
|
||||
<ept id="1"></ul></ept></target>
|
||||
</trans-unit>
|
||||
</group>
|
||||
</body>
|
||||
</file>
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
using System.Threading.Tasks;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
namespace TINK.Services.Permissions.Essentials
|
||||
{
|
||||
using XamPermission = Xamarin.Essentials.Permissions;
|
||||
using XamPermissionStatus = PermissionStatus;
|
||||
|
||||
public class LocationPermissions : ILocationPermission
|
||||
{
|
||||
/// <summary> Checks the permission status.</summary>
|
||||
/// <returns>Current permission status.</returns>
|
||||
public async Task<Status> CheckStatusAsync()
|
||||
{
|
||||
var status = await XamPermission.CheckStatusAsync<XamPermission.LocationWhenInUse>();
|
||||
if (status == XamPermissionStatus.Granted)
|
||||
{
|
||||
return Status.Granted;
|
||||
}
|
||||
|
||||
if (status == XamPermissionStatus.Denied
|
||||
&& DeviceInfo.Platform == DevicePlatform.iOS)
|
||||
{
|
||||
// Prompt the user to turn on in settings
|
||||
// On iOS once a permission has been denied it may not be requested again from the application
|
||||
return Status.DeniedRequiresSettingsUI;
|
||||
}
|
||||
|
||||
if (XamPermission.ShouldShowRationale<XamPermission.LocationWhenInUse>())
|
||||
{
|
||||
// Prompt the user with additional information as to why the permission is needed
|
||||
return Status.Denied;
|
||||
}
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case XamPermissionStatus.Unknown:
|
||||
case XamPermissionStatus.Denied: // Map Denied to unknown because "denied means user did not allow access to location".
|
||||
return Status.Unknown;
|
||||
|
||||
default:
|
||||
// Comprises:
|
||||
// - XamPermissionStatus.Restricted:
|
||||
// - XamPermissionStatus.Disabled
|
||||
// Perission XamPermissionStatus.Granted is handled above.
|
||||
return Status.DeniedRequiresSettingsUI;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Requests location permission.</summary>
|
||||
/// <returns>Permission status after request.</returns>
|
||||
public async Task<Status> RequestAsync()
|
||||
{
|
||||
switch (await XamPermission.RequestAsync<XamPermission.LocationWhenInUse>())
|
||||
{
|
||||
case XamPermissionStatus.Unknown:
|
||||
return Status.Unknown;
|
||||
|
||||
case XamPermissionStatus.Denied:
|
||||
return Status.Denied;
|
||||
|
||||
case XamPermissionStatus.Granted:
|
||||
return Status.Granted;
|
||||
|
||||
default:
|
||||
// Comprises:
|
||||
// - XamPermissionStatus.Restricted:
|
||||
// - XamPermissionStatus.Disabled
|
||||
return Status.DeniedRequiresSettingsUI;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Opens app settings dialog.</summary>
|
||||
public bool OpenAppSettings()
|
||||
{
|
||||
AppInfo.ShowSettingsUI();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
59
TINKLib/Services/Permissions/Plugin/LocationPermissions.cs
Normal file
59
TINKLib/Services/Permissions/Plugin/LocationPermissions.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace TINK.Services.Permissions.Plugin
|
||||
{
|
||||
using global::Plugin.Permissions;
|
||||
|
||||
public class LocationPermissions : ILocationPermission
|
||||
{
|
||||
/// <summary> Checks the permission status.</summary>
|
||||
public async Task<Status> CheckStatusAsync()
|
||||
{
|
||||
switch (await CrossPermissions.Current.CheckPermissionStatusAsync<LocationPermission>())
|
||||
{
|
||||
case global::Plugin.Permissions.Abstractions.PermissionStatus.Denied:
|
||||
return Status.Denied;
|
||||
|
||||
case global::Plugin.Permissions.Abstractions.PermissionStatus.Granted:
|
||||
return Status.Granted;
|
||||
|
||||
case global::Plugin.Permissions.Abstractions.PermissionStatus.Unknown:
|
||||
return Status.Unknown;
|
||||
|
||||
default:
|
||||
// Comprises
|
||||
// - PermissionStatus.Disabled and
|
||||
// - PermissionStatus.Restricted.
|
||||
return Status.DeniedRequiresSettingsUI;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Requests location permission.</summary>
|
||||
/// <returns>Permission status after request.</returns>
|
||||
public async Task<Status> RequestAsync()
|
||||
{
|
||||
switch (await CrossPermissions.Current.RequestPermissionAsync<LocationPermission>())
|
||||
{
|
||||
case global::Plugin.Permissions.Abstractions.PermissionStatus.Denied:
|
||||
return Status.Denied;
|
||||
|
||||
case global::Plugin.Permissions.Abstractions.PermissionStatus.Granted:
|
||||
return Status.Granted;
|
||||
|
||||
case global::Plugin.Permissions.Abstractions.PermissionStatus.Unknown:
|
||||
return Status.Unknown;
|
||||
|
||||
default:
|
||||
// Comprises
|
||||
// - PermissionStatus.Disabled and
|
||||
// - PermissionStatus.Restricted.
|
||||
return Status.DeniedRequiresSettingsUI;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Opens app settings dialog.</summary>
|
||||
public bool OpenAppSettings()
|
||||
=> CrossPermissions.Current.OpenAppSettings();
|
||||
}
|
||||
}
|
|
@ -244,15 +244,12 @@ namespace TINK.ViewModel.BikesAtStation
|
|||
|
||||
// Check location permissions.
|
||||
if (bikesAtStation.GetLockIt().Count > 0
|
||||
&& RuntimePlatform == Device.Android)
|
||||
&& RuntimePlatform == Device.Android
|
||||
)
|
||||
{
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (status != Status.Granted)
|
||||
{
|
||||
var permissionResult = await PermissionsService.RequestAsync();
|
||||
|
||||
if (permissionResult != Status.Granted)
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementLocationPermissionOpenDialog,
|
||||
|
@ -270,10 +267,11 @@ namespace TINK.ViewModel.BikesAtStation
|
|||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Open permissions dialog.
|
||||
PermissionsService.OpenAppSettings();
|
||||
}
|
||||
else if (dialogResult)
|
||||
{
|
||||
// Open permissions dialog.
|
||||
PermissionsService.OpenAppSettings();
|
||||
}
|
||||
}
|
||||
|
||||
if (Geolocation.IsGeolcationEnabled == false)
|
||||
|
|
|
@ -191,28 +191,32 @@ namespace TINK.ViewModel.Contact
|
|||
}
|
||||
|
||||
//Add blue dot for showing current location of user
|
||||
Location currentLocation = null;
|
||||
try
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (status == Status.Granted)
|
||||
{
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
if (currentLocation != null)
|
||||
{
|
||||
var currentLocationPin = new Pin()
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
Position = new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
|
||||
Label = "currentLocationPin",
|
||||
Type = PinType.Place,
|
||||
Tag = "NotClickable",
|
||||
Icon = BitmapDescriptorFactory.FromBundle(currentLocationPinName)
|
||||
};
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
Pins.Add(currentLocationPin);
|
||||
if (currentLocation != null)
|
||||
{
|
||||
var currentLocationPin = new Pin()
|
||||
{
|
||||
Position = new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
|
||||
Label = "currentLocationPin",
|
||||
Type = PinType.Place,
|
||||
Tag = "NotClickable",
|
||||
Icon = BitmapDescriptorFactory.FromBundle(currentLocationPinName)
|
||||
};
|
||||
|
||||
Pins.Add(currentLocationPin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,17 +317,15 @@ namespace TINK.ViewModel.Contact
|
|||
|
||||
if (Pins.Count <= 0)
|
||||
{
|
||||
ActionText = AppResources.ActivityTextRequestingLocationPermissions;
|
||||
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (TinkApp.CenterMapToCurrentLocation
|
||||
&& !GeolocationService.IsSimulation
|
||||
&& status != Status.Granted)
|
||||
// Move and scale before getting stations and bikes which takes some time.
|
||||
if (TinkApp.CenterMapToCurrentLocation)
|
||||
{
|
||||
var permissionResult = await PermissionsService.RequestAsync();
|
||||
ActionText = AppResources.ActivityTextRequestingLocationPermissions;
|
||||
|
||||
if (permissionResult != Status.Granted)
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (!GeolocationService.IsSimulation
|
||||
&& status != Status.Granted)
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
|
@ -341,23 +343,25 @@ namespace TINK.ViewModel.Contact
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status == Status.Granted)
|
||||
{
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
|
||||
// Move and scale before getting stations and bikes which takes some time.
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = TinkApp.CenterMapToCurrentLocation
|
||||
? await GeolocationService.GetAsync()
|
||||
: null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<SelectStationPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = TinkApp.CenterMapToCurrentLocation
|
||||
? await GeolocationService.GetAsync()
|
||||
: null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<SelectStationPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.Uris.ActiveUri, currentLocation);
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.Uris.ActiveUri, currentLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
|
||||
|
|
|
@ -235,36 +235,63 @@ namespace TINK.ViewModel.FindBike
|
|||
ActionText = AppResources.ActivityTextCheckBluetoothState;
|
||||
|
||||
if (bikeCollection.FirstOrDefault(x => x is BikeInfo btBike) != null
|
||||
&& RuntimePlatform == Device.Android)
|
||||
//&& RuntimePlatform == Device.Android
|
||||
)
|
||||
{
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (status != Status.Granted)
|
||||
{
|
||||
var permissionResult = await PermissionsService.RequestAsync();
|
||||
|
||||
if (permissionResult != Status.Granted)
|
||||
if (RuntimePlatform == Device.Android)
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
var permissionResult = await PermissionsService.RequestAsync();
|
||||
|
||||
if (!dialogResult)
|
||||
if (permissionResult != Status.Granted)
|
||||
{
|
||||
// User decided not to give access to locations permissions.
|
||||
BikeCollection.Update(bikeCollection, Stations);
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
|
||||
await StartUpdateTask(() => UpdateTask());
|
||||
if (!dialogResult)
|
||||
{
|
||||
// User decided not to give access to locations permissions.
|
||||
BikeCollection.Update(bikeCollection, Stations);
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
await StartUpdateTask(() => UpdateTask());
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Open permissions dialog.
|
||||
PermissionsService.OpenAppSettings();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
|
||||
// Open permissions dialog.
|
||||
PermissionsService.OpenAppSettings();
|
||||
if (!dialogResult)
|
||||
{
|
||||
// User decided not to give access to locations permissions.
|
||||
BikeCollection.Update(bikeCollection, Stations);
|
||||
|
||||
await StartUpdateTask(() => UpdateTask());
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Open permissions dialog.
|
||||
PermissionsService.OpenAppSettings();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ using TINK.Repository;
|
|||
using TINK.Services.Geolocation;
|
||||
using TINK.Model.State;
|
||||
|
||||
|
||||
#if !TRYNOTBACKSTYLE
|
||||
#endif
|
||||
|
||||
|
@ -55,6 +56,8 @@ namespace TINK.ViewModel.Map
|
|||
/// </summary>
|
||||
private ILocationPermission PermissionsService { get; }
|
||||
|
||||
private IGeolocation Geolocation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Service to manage bluetooth stack.
|
||||
/// </summary>
|
||||
|
@ -227,28 +230,32 @@ namespace TINK.ViewModel.Map
|
|||
}
|
||||
|
||||
//Add blue dot for showing current location of user
|
||||
Location currentLocation = null;
|
||||
try
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (status == Status.Granted)
|
||||
{
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
if (currentLocation != null)
|
||||
{
|
||||
var currentLocationPin = new Pin()
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
Position = new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
|
||||
Label = "currentLocationPin",
|
||||
Type = PinType.Place,
|
||||
Tag = "NotClickable",
|
||||
Icon = BitmapDescriptorFactory.FromBundle(currentLocationPinName)
|
||||
};
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
Pins.Add(currentLocationPin);
|
||||
if (currentLocation != null)
|
||||
{
|
||||
var currentLocationPin = new Pin()
|
||||
{
|
||||
Position = new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
|
||||
Label = "currentLocationPin",
|
||||
Type = PinType.Place,
|
||||
Tag = "NotClickable",
|
||||
Icon = BitmapDescriptorFactory.FromBundle(currentLocationPinName)
|
||||
};
|
||||
|
||||
Pins.Add(currentLocationPin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,7 +350,14 @@ namespace TINK.ViewModel.Map
|
|||
{
|
||||
try
|
||||
{
|
||||
//Request Location Permission on iOS
|
||||
if(DeviceInfo.Platform == DevicePlatform.iOS)
|
||||
{
|
||||
var status = await PermissionsService.RequestAsync();
|
||||
}
|
||||
|
||||
IsRunning = true;
|
||||
IsNavBarVisible = false;
|
||||
// Process map page.
|
||||
Polling = TinkApp.Polling;
|
||||
|
||||
|
@ -354,9 +368,6 @@ namespace TINK.ViewModel.Map
|
|||
// Update map page filter
|
||||
ActiveFilterMap = TinkApp.GroupFilterMapPage;
|
||||
|
||||
ActionText = AppResources.ActivityTextRequestingLocationPermissions;
|
||||
var status = await RequestLocationPermission();
|
||||
|
||||
ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
|
||||
IsConnected = TinkApp.GetIsConnected();
|
||||
var resultStationsAndBikes = await TinkApp.GetConnector(IsConnected).Query.GetBikesAndStationsAsync();
|
||||
|
@ -394,11 +405,15 @@ namespace TINK.ViewModel.Map
|
|||
|
||||
// Get map display area
|
||||
Model.Map.IMapSpan mapSpan = null;
|
||||
if (TinkApp.CenterMapToCurrentLocation && status == Status.Granted)
|
||||
if (TinkApp.CenterMapToCurrentLocation)
|
||||
{
|
||||
// Get from smart device
|
||||
mapSpan = await GetFromLocationService(status);
|
||||
}
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (status == Status.Granted)
|
||||
{
|
||||
// Get from smart device
|
||||
mapSpan = await GetFromLocationService(status);
|
||||
}
|
||||
}
|
||||
|
||||
if (mapSpan == null)
|
||||
{
|
||||
|
@ -433,6 +448,7 @@ namespace TINK.ViewModel.Map
|
|||
Exception = resultStationsAndBikes.Exception;
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsNavBarVisible = true;
|
||||
IsMapPageEnabled = true;
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
|
@ -440,6 +456,7 @@ namespace TINK.ViewModel.Map
|
|||
Log.ForContext<MapPageViewModel>().Error($"An error occurred showing bike stations page.\r\n{l_oException.Message}");
|
||||
|
||||
IsRunning = false;
|
||||
IsNavBarVisible = true;
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
"Fehler",
|
||||
|
@ -552,19 +569,15 @@ namespace TINK.ViewModel.Map
|
|||
{
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (TinkApp.CenterMapToCurrentLocation
|
||||
&& !GeolocationService.IsSimulation
|
||||
if (!GeolocationService.IsSimulation
|
||||
// && DeviceInfo.Platform == DevicePlatform.Android
|
||||
&& status != Status.Granted)
|
||||
{
|
||||
status = await PermissionsService.RequestAsync();
|
||||
|
||||
if (status != Status.Granted)
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageCenterMapLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageCenterMapLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
|
||||
if (dialogResult)
|
||||
{
|
||||
|
@ -572,9 +585,9 @@ namespace TINK.ViewModel.Map
|
|||
PermissionsService.OpenAppSettings();
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsNavBarVisible = true;
|
||||
IsMapPageEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
@ -598,7 +611,7 @@ namespace TINK.ViewModel.Map
|
|||
{
|
||||
// Start task which periodically updates pins.
|
||||
return new PollingUpdateTaskManager(
|
||||
async () =>
|
||||
() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -660,6 +673,7 @@ namespace TINK.ViewModel.Map
|
|||
null);
|
||||
|
||||
Log.ForContext<MapPageViewModel>().Verbose("Leaving update cycle.");
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
@ -845,6 +859,21 @@ namespace TINK.ViewModel.Map
|
|||
}
|
||||
}
|
||||
|
||||
private bool isNavBarVisible = true;
|
||||
|
||||
public bool IsNavBarVisible
|
||||
{
|
||||
get => isNavBarVisible;
|
||||
set
|
||||
{
|
||||
if (value == isNavBarVisible)
|
||||
return;
|
||||
|
||||
Log.ForContext<MapPageViewModel>().Debug($"Switch value of {nameof(isNavBarVisible)} to {value}.");
|
||||
isNavBarVisible = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsNavBarVisible)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Holds information whether app is connected to web or not. </summary>
|
||||
private bool? isConnected = null;
|
||||
|
@ -895,6 +924,9 @@ namespace TINK.ViewModel.Map
|
|||
{
|
||||
try
|
||||
{
|
||||
IsRunning = true;
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
|
||||
IsMapPageEnabled = false;
|
||||
|
||||
Log.ForContext<MapPageViewModel>().Information($"Request to center to current position.");
|
||||
|
@ -913,127 +945,92 @@ namespace TINK.ViewModel.Map
|
|||
TinkApp.UpdateConnector();
|
||||
|
||||
// Check location permission
|
||||
//ActionText = AppResources.ActivityTextRequestingLocationPermissions;
|
||||
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (!GeolocationService.IsSimulation
|
||||
&& status != Status.Granted)
|
||||
var status = await RequestLocationPermission();
|
||||
if (status == Status.Granted)
|
||||
{
|
||||
status = await PermissionsService.RequestAsync();
|
||||
|
||||
if (status != Status.Granted)
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageCenterMapLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
if (dialogResult)
|
||||
{
|
||||
// User decided to give access to locations permissions.
|
||||
PermissionsService.OpenAppSettings();
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsMapPageEnabled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Do not use property .State to get bluetooth state due
|
||||
// to issue https://hausource.visualstudio.com/TINK/_workitems/edit/116 /
|
||||
// see https://github.com/xabre/xamarin-bluetooth-le/issues/112#issuecomment-380994887
|
||||
if (await BluetoothService.GetBluetoothState() != Plugin.BLE.Abstractions.Contracts.BluetoothState.On)
|
||||
{
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementBluetoothActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsMapPageEnabled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Move and scale before getting stations and bikes which takes some time.
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
if (currentLocation != null)
|
||||
{
|
||||
IsRunning = true;
|
||||
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);
|
||||
|
||||
//Pins.Clear();
|
||||
|
||||
//// Update stations
|
||||
//ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
|
||||
//IsConnected = TinkApp.GetIsConnected();
|
||||
//var resultStationsAndBikes = await TinkApp.GetConnector(IsConnected).Query.GetBikesAndStationsAsync();
|
||||
|
||||
//// Set pins to their positions on map.
|
||||
//InitializePins(resultStationsAndBikes.Response.StationsAll);
|
||||
//Log.ForContext<MapPageViewModel>().Verbose("Update of pins done...");
|
||||
|
||||
//// Update pin colors.
|
||||
//Log.ForContext<MapPageViewModel>().Verbose("Starting update pins color...");
|
||||
//var l_oColors = GetStationColors(
|
||||
// Pins.Select(x => x.Tag.ToString()).ToList(),
|
||||
// resultStationsAndBikes.Response.Bikes);
|
||||
|
||||
//// Update pins color form count of bikes located at station.
|
||||
//UpdatePinsColor(l_oColors);
|
||||
|
||||
//Log.ForContext<MapPageViewModel>().Verbose("Update pins color done.");
|
||||
|
||||
// Move and scale.
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
// Update bikes at station or my bikes depending on context.
|
||||
await m_oViewUpdateManager.StartUpdateAyncPeridically(Polling);
|
||||
currentLocation = await GeolocationService.GetAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Excpetions are handled insde update task;
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
if (currentLocation != null)
|
||||
{
|
||||
IsRunning = true;
|
||||
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);
|
||||
|
||||
Pins.Clear();
|
||||
|
||||
// Update stations
|
||||
IsConnected = TinkApp.GetIsConnected();
|
||||
var resultStationsAndBikes = await TinkApp.GetConnector(IsConnected).Query.GetBikesAndStationsAsync();
|
||||
|
||||
// Set pins to their positions on map.
|
||||
ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
|
||||
InitializePins(resultStationsAndBikes.Response.StationsAll);
|
||||
Log.ForContext<MapPageViewModel>().Verbose("Update of pins done...");
|
||||
|
||||
// Update pin colors.
|
||||
Log.ForContext<MapPageViewModel>().Verbose("Starting update pins color...");
|
||||
var l_oColors = GetStationColors(
|
||||
Pins.Select(x => x.Tag.ToString()).ToList(),
|
||||
resultStationsAndBikes.Response.Bikes);
|
||||
|
||||
// Update pins color form count of bikes located at station.
|
||||
UpdatePinsColor(l_oColors);
|
||||
|
||||
Log.ForContext<MapPageViewModel>().Verbose("Update pins color done.");
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ActionText = AppResources.ActivityTextErrorQueryLocationWhenAny;
|
||||
}
|
||||
|
||||
IsRunning = false;
|
||||
IsMapPageEnabled = true;
|
||||
Log.ForContext<MapPageViewModel>().Information($"Center to current Position done.");
|
||||
ActionText = "";
|
||||
ActionText = String.Empty;
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("An error occurred while centering to current position.");
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
ActionText = String.Empty;
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
"Fehler",
|
||||
AppResources.MessageMapPageErrorSwitch,
|
||||
String.Format(AppResources.MessageMapPageErrorSwitch, l_oException.Message),
|
||||
String.Format(AppResources.MessageErrorQueryLocationMessage, l_oException.Message),
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
IsMapPageEnabled = true;
|
||||
IsRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1080,6 +1077,7 @@ namespace TINK.ViewModel.Map
|
|||
{
|
||||
IsMapPageEnabled = false;
|
||||
IsRunning = true;
|
||||
IsNavBarVisible = false;
|
||||
|
||||
Log.ForContext<MapPageViewModel>().Information($"Request to toggle to \"{selectedFilter}\".");
|
||||
|
||||
|
@ -1101,76 +1099,42 @@ namespace TINK.ViewModel.Map
|
|||
|
||||
Pins.Clear();
|
||||
|
||||
// Check location permission
|
||||
//ActionText = AppResources.ActivityTextRequestingLocationPermissions;
|
||||
//// 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;
|
||||
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (TinkApp.CenterMapToCurrentLocation
|
||||
&& !GeolocationService.IsSimulation
|
||||
&& status != Status.Granted)
|
||||
{
|
||||
status = await PermissionsService.RequestAsync();
|
||||
// Location currentLocation = null;
|
||||
// try
|
||||
// {
|
||||
// currentLocation = await GeolocationService.GetAsync();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
// }
|
||||
|
||||
if (status != Status.Granted)
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageCenterMapLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
if (dialogResult)
|
||||
{
|
||||
// User decided to give access to locations permissions.
|
||||
PermissionsService.OpenAppSettings();
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsMapPageEnabled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if (currentLocation != null)
|
||||
// {
|
||||
// TinkApp.UserMapSpan = MapSpan.FromCenterAndRadius(
|
||||
// new Xamarin.Forms.GoogleMaps.Position(currentLocation.Latitude, currentLocation.Longitude),
|
||||
// TinkApp.ActiveMapSpan.Radius);
|
||||
|
||||
// Do not use property .State to get bluetooth state due
|
||||
// to issue https://hausource.visualstudio.com/TINK/_workitems/edit/116 /
|
||||
// see https://github.com/xabre/xamarin-bluetooth-le/issues/112#issuecomment-380994887
|
||||
if (await BluetoothService.GetBluetoothState() != Plugin.BLE.Abstractions.Contracts.BluetoothState.On)
|
||||
{
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementBluetoothActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsMapPageEnabled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// TinkApp.Save();
|
||||
|
||||
// Move and scale before getting stations and bikes which takes some time.
|
||||
if (TinkApp.CenterMapToCurrentLocation)
|
||||
{
|
||||
//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);
|
||||
}
|
||||
}
|
||||
// //MoveAndScale(m_oMoveToRegionDelegate, TinkApp.ActiveMapSpan);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ActionText = AppResources.ActivityTextErrorQueryLocationWhenAny;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
// Update stations
|
||||
ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
|
||||
|
@ -1204,6 +1168,7 @@ namespace TINK.ViewModel.Map
|
|||
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsNavBarVisible = true;
|
||||
IsMapPageEnabled = true;
|
||||
Log.ForContext<MapPageViewModel>().Information($"Toggle to \"{selectedFilter}\" done.");
|
||||
}
|
||||
|
@ -1212,6 +1177,7 @@ namespace TINK.ViewModel.Map
|
|||
Log.ForContext<MapPageViewModel>().Error("An error occurred switching view Cargobike/ Citybike.{}");
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsNavBarVisible = true;
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
"Fehler",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue