mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-21 21:46:27 +02:00
Version 3.0.346
This commit is contained in:
parent
1ba809dd59
commit
47c03f43fb
43 changed files with 609 additions and 117 deletions
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading;
|
||||
|
@ -6,6 +6,7 @@ using Serilog.Events;
|
|||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.Services.CopriApi.ServerUris;
|
||||
using TINK.Model.Settings;
|
||||
using TINK.Model.Station;
|
||||
using TINK.Services;
|
||||
using TINK.Services.BluetoothLock;
|
||||
|
@ -65,6 +66,9 @@ namespace TINK.Model
|
|||
/// <summary> Holds the filters loaded from settings. </summary>
|
||||
IGroupFilterSettings FilterGroupSetting { get; set; }
|
||||
|
||||
/// <summary>Settings determining the startup behavior of the app.</summary>
|
||||
IStartupSettings StartupSettings { get; }
|
||||
|
||||
/// <summary> Value indicating whether map is centerted to current position or not. </summary>
|
||||
bool CenterMapToCurrentLocation { get; set; }
|
||||
|
||||
|
@ -84,10 +88,9 @@ namespace TINK.Model
|
|||
/// <summary> Gets a value indicating whether reporting level is verbose or not.</summary>
|
||||
bool IsReportLevelVerbose { get; set; }
|
||||
|
||||
|
||||
/// <summary> Updates logging level. </summary>
|
||||
/// <param name="p_oNewLevel">New level to set.</param>
|
||||
void UpdateLoggingLevel(LogEventLevel p_oNewLevel);
|
||||
/// <param name="newLogLevel">New level to set.</param>
|
||||
void UpdateLoggingLevel(LogEventLevel newLogLevel);
|
||||
|
||||
/// <summary>Holds uris of copri servers. </summary>
|
||||
CopriServerUriList Uris { get; }
|
||||
|
@ -113,7 +116,7 @@ namespace TINK.Model
|
|||
/// <summary> Holds the stations availalbe. </summary>
|
||||
IEnumerable<IStation> Stations { get; set; }
|
||||
|
||||
|
||||
/// <summary> Holds the Urs to query resources from. </summary>
|
||||
IResourceUrls ResourceUrls { get; set; }
|
||||
}
|
||||
|
||||
|
|
9
TINKLib/Model/Settings/IStartupSettings.cs
Normal file
9
TINKLib/Model/Settings/IStartupSettings.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
namespace TINK.Model.Settings
|
||||
{
|
||||
/// <summary> Settings determining the startup behavior of the app. </summary>
|
||||
public interface IStartupSettings
|
||||
{
|
||||
/// <summary> Holds the page to show when apps starts. </summary>
|
||||
ViewTypes StartupPage { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Foundation;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Serilog.Events;
|
||||
|
@ -39,6 +40,9 @@ namespace TINK.Model.Settings
|
|||
/// <summary> Key of the center to ... entry. </summary>
|
||||
public const string CENTERMAPTOCURRENTLOCATION = "CenterMapToCurrentLocation";
|
||||
|
||||
/// <summary> Key of the center to ... entry. </summary>
|
||||
public const string STARTUPSETTINGS = "StartupSettings";
|
||||
|
||||
public const string LOGTOEXTERNALFOLDER = "LogToExternalFolder";
|
||||
|
||||
public const string THEMEKEY = "Theme";
|
||||
|
@ -49,7 +53,7 @@ namespace TINK.Model.Settings
|
|||
/// <param name="settingsJSON">Dictionary to get value from.</param>
|
||||
public static T? GetNullableEntry<T>(
|
||||
string keyName,
|
||||
Dictionary<string, string> settingsJSON) where T : struct
|
||||
IDictionary<string, string> settingsJSON) where T : struct
|
||||
{
|
||||
if (!settingsJSON.TryGetValue(keyName, out string boolText)
|
||||
|| string.IsNullOrEmpty(boolText))
|
||||
|
@ -65,7 +69,7 @@ namespace TINK.Model.Settings
|
|||
/// <param name="settingsJSON">Dictionary to get value from.</param>
|
||||
public static T GetEntry<T>(
|
||||
string keyName,
|
||||
Dictionary<string, string> settingsJSON,
|
||||
IDictionary<string, string> settingsJSON,
|
||||
Func<string, string> legacyValueConverter = null) where T : class
|
||||
{
|
||||
if (string.IsNullOrEmpty(keyName)
|
||||
|
@ -465,7 +469,7 @@ namespace TINK.Model.Settings
|
|||
public static bool? GetIsSiteCachingOn(Dictionary<string, string> settingsJSON) => GetNullableEntry<bool>(ISSITECACHINGON, settingsJSON);
|
||||
|
||||
/// <summary> Sets whether to store logging data on SD card or not.</summary>
|
||||
/// <param name="settingsJSON">Dictionary to get value from.</param>
|
||||
/// <param name="settingsJSON">Dictionary to write value to.</param>
|
||||
public static Dictionary<string, string> SetLogToExternalFolder(this IDictionary<string, string> targetDictionary, bool useSdCard) => SetEntry(useSdCard, LOGTOEXTERNALFOLDER, targetDictionary);
|
||||
|
||||
/// <summary> Sets active theme.</summary>
|
||||
|
@ -550,5 +554,28 @@ namespace TINK.Model.Settings
|
|||
settings["FilterCollection"] = JsonConvert.SerializeObject(p_oFilterCollection);
|
||||
return settings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the startup settings from dictionary.
|
||||
/// </summary>
|
||||
/// <param name="settings">Settings objet to load from.</param>
|
||||
public static StartupSettings GetStartupSettings(this IDictionary<string, string> settingsJSON)
|
||||
=> GetEntry<StartupSettings>(STARTUPSETTINGS, settingsJSON) ?? new StartupSettings();
|
||||
|
||||
/// <summary> Sets the startup settings.</summary>
|
||||
/// <param name="settingsJSON">Dictionary to write value to.</param>
|
||||
public static IDictionary<string, string> SetStartupSettings(
|
||||
this IDictionary<string, string> settingsJSON,
|
||||
IStartupSettings startupSettings)
|
||||
{
|
||||
if (settingsJSON == null
|
||||
|| startupSettings == null)
|
||||
{
|
||||
return settingsJSON;
|
||||
}
|
||||
|
||||
settingsJSON[STARTUPSETTINGS] = JsonConvert.SerializeObject(startupSettings);
|
||||
return settingsJSON;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using Serilog.Events;
|
||||
using TINK.Services.BluetoothLock;
|
||||
using TINK.Services.CopriApi.ServerUris;
|
||||
|
@ -27,6 +27,7 @@ namespace TINK.Model.Settings
|
|||
/// <summary> Constructs settings object. </summary>
|
||||
/// <param name="groupFilterMapPage">filter which is applied on the map view. Either TINK or Konrad stations are displayed.</param>
|
||||
/// <param name="groupFilterSettings"></param>
|
||||
/// <param name="startupSettings">Settings determining the startup behavior of the app.</param>
|
||||
/// <param name="activeUri"></param>
|
||||
/// <param name="pollingParameters"></param>
|
||||
/// <param name="minimumLogEventLevel">Minimum logging level to be applied.</param>
|
||||
|
@ -38,6 +39,7 @@ namespace TINK.Model.Settings
|
|||
public Settings(
|
||||
IGroupFilterMapPage groupFilterMapPage = null,
|
||||
IGroupFilterSettings groupFilterSettings = null,
|
||||
IStartupSettings startupSettings = null,
|
||||
Uri activeUri = null,
|
||||
PollingParameters pollingParameters = null,
|
||||
LogEventLevel? minimumLogEventLevel = null,
|
||||
|
@ -54,6 +56,7 @@ namespace TINK.Model.Settings
|
|||
{
|
||||
GroupFilterMapPage = groupFilterMapPage ?? new GroupFilterMapPage(); // Default behaviour: No filtering.
|
||||
GroupFilterSettings = groupFilterSettings ?? new GroupFilterSettings(); // Default behaviour: No filtering.
|
||||
StartupSettings = startupSettings ?? new StartupSettings();
|
||||
ActiveUri = GetActiveUri(activeUri);
|
||||
PollingParameters = pollingParameters ?? PollingParameters.Default;
|
||||
MinimumLogEventLevel = minimumLogEventLevel ?? DEFAULTLOGGINLEVEL;
|
||||
|
@ -75,6 +78,9 @@ namespace TINK.Model.Settings
|
|||
/// <summary> Holds the filters loaded from settings. </summary>
|
||||
public IGroupFilterSettings GroupFilterSettings { get; }
|
||||
|
||||
/// <summary> Holds the stettings determining app startup behavior. </summary>
|
||||
public IStartupSettings StartupSettings { get; }
|
||||
|
||||
/// <summary> Holds the uri to connect to. </summary>
|
||||
public Uri ActiveUri { get; }
|
||||
|
||||
|
|
11
TINKLib/Model/Settings/StartupSettings.cs
Normal file
11
TINKLib/Model/Settings/StartupSettings.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
namespace TINK.Model.Settings
|
||||
{
|
||||
/// <summary> Settings determining the startup behavior of the app. </summary>
|
||||
public class StartupSettings : IStartupSettings
|
||||
{
|
||||
public static ViewTypes DefaultStartupPage => ViewTypes.MapPage;
|
||||
|
||||
/// <summary> Holds the page to show when apps starts. </summary>
|
||||
public ViewTypes StartupPage { get; set; } = DefaultStartupPage;
|
||||
}
|
||||
}
|
|
@ -52,6 +52,9 @@ namespace TINK.Model
|
|||
/// <summary> Holds the filters loaded from settings. </summary>
|
||||
public IGroupFilterSettings FilterGroupSetting { get; set; }
|
||||
|
||||
/// <summary> Settings determining the startup behavior of the app.</summary>
|
||||
public IStartupSettings StartupSettings { get; private set; }
|
||||
|
||||
/// <summary> Holds the filter which is applied on the map view. Either TINK or Konrad stations are displayed. </summary>
|
||||
private IGroupFilterMapPage m_oFilterDictionaryMapPage;
|
||||
|
||||
|
@ -73,9 +76,17 @@ namespace TINK.Model
|
|||
|
||||
/// <summary> Holds the map span to display either default span or span centered to current position depending on option <see cref="CenterMapToCurrentLocation"/>.</summary>
|
||||
public Xamarin.Forms.GoogleMaps.MapSpan ActiveMapSpan
|
||||
=> CenterMapToCurrentLocation
|
||||
? UserMapSpan ?? HomeMapSpan
|
||||
: HomeMapSpan;
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CenterMapToCurrentLocation == false)
|
||||
{
|
||||
return HomeMapSpan;
|
||||
}
|
||||
|
||||
return UserMapSpan ?? HomeMapSpan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the minimum logging level. </summary>
|
||||
public LogEventLevel MinimumLogEventLevel { get; set; }
|
||||
|
@ -95,6 +106,7 @@ namespace TINK.Model
|
|||
.SetCopriHostUri(NextActiveUri.AbsoluteUri)
|
||||
.SetPollingParameters(Polling)
|
||||
.SetGroupFilterSettings(FilterGroupSetting)
|
||||
.SetStartupSettings(StartupSettings)
|
||||
.SetAppVersion(AppVersion)
|
||||
.SetMinimumLoggingLevel(MinimumLogEventLevel)
|
||||
.SetIsReportLevelVerbose(IsReportLevelVerbose)
|
||||
|
@ -238,6 +250,8 @@ namespace TINK.Model
|
|||
FilterGroupSetting = settings.GroupFilterSettings;
|
||||
GroupFilterMapPage = settings.GroupFilterMapPage;
|
||||
|
||||
StartupSettings = settings.StartupSettings;
|
||||
|
||||
CenterMapToCurrentLocation = settings.CenterMapToCurrentLocation;
|
||||
|
||||
HomeMapSpan = settings.MapSpan;
|
||||
|
|
|
@ -614,7 +614,17 @@ namespace TINK.Model
|
|||
new Version(3, 0, 345),
|
||||
AppResources.ChangeLog_3_0_345_LB,
|
||||
new List<AppFlavor> { AppFlavor.LastenradBayern }
|
||||
}
|
||||
},
|
||||
{
|
||||
new Version(3, 0, 346),
|
||||
AppResources.ChangeLog_3_0_346_LB_MK,
|
||||
new List<AppFlavor> { AppFlavor.LastenradBayern, AppFlavor.MeinKonrad }
|
||||
},
|
||||
{
|
||||
new Version(3, 0, 346),
|
||||
AppResources.ChangeLog_3_0_346_SB,
|
||||
new List<AppFlavor> { AppFlavor.ShareeBike }
|
||||
},
|
||||
};
|
||||
|
||||
/// <summary> Manges the whats new information.</summary>
|
||||
|
|
|
@ -668,6 +668,30 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <i>Select Bike</i> page revised..
|
||||
/// </summary>
|
||||
public static string ChangeLog_3_0_346_LB_MK {
|
||||
get {
|
||||
return ResourceManager.GetString("ChangeLog_3_0_346_LB_MK", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <i>Select Bike</i>- page revised.<br/>
|
||||
///Setting added to select whether the app starts up showing either
|
||||
///<ul>
|
||||
///<li/><i>Bike Locations</i> or
|
||||
///<li/><i>Select Bike</i>
|
||||
///</ul>
|
||||
///page..
|
||||
/// </summary>
|
||||
public static string ChangeLog_3_0_346_SB {
|
||||
get {
|
||||
return ResourceManager.GetString("ChangeLog_3_0_346_SB", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to We have fixed some bugs. Enjoy the ride!.
|
||||
/// </summary>
|
||||
|
@ -2113,6 +2137,15 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Startup page.
|
||||
/// </summary>
|
||||
public static string MarkingStartupPage {
|
||||
get {
|
||||
return ResourceManager.GetString("MarkingStartupPage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to App.
|
||||
/// </summary>
|
||||
|
|
|
@ -1063,4 +1063,19 @@ Sie können nun auf einen Blick sehen, welche App-Version Sie installiert haben:
|
|||
- Einstellungen sind auch ohne Anmeldung verfügbar.
|
||||
- Die Reihenfolge der Karteikarten auf der Seite Bedienung wurde getauscht.</value>
|
||||
</data>
|
||||
<data name="MarkingStartupPage" xml:space="preserve">
|
||||
<value>Startseite</value>
|
||||
</data>
|
||||
<data name="ChangeLog_3_0_346_LB_MK" xml:space="preserve">
|
||||
<value><i>Rad auswählen</i> Seite überarbeitet.</value>
|
||||
</data>
|
||||
<data name="ChangeLog_3_0_346_SB" xml:space="preserve">
|
||||
<value><i>Rad auswählen</i>- Seite überarbeitet.<br/>
|
||||
Einstellung hinzugefügt mit der festgelegt werden kann, ob die App mit der Seite
|
||||
<ul>
|
||||
<li/><i>Radstandorte</i> oder
|
||||
<li/><i>Rad auswählen</i>
|
||||
</ul>
|
||||
gestartet wird.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1155,4 +1155,19 @@ You can now see at a glance which app version you have installed: in the menu at
|
|||
- Settings are available even if no user is logged in.
|
||||
- Order of tabs on instructions page were switched.</value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="MarkingStartupPage" xml:space="preserve">
|
||||
<value>Startup page</value>
|
||||
</data>
|
||||
<data name="ChangeLog_3_0_346_LB_MK" xml:space="preserve">
|
||||
<value><i>Select Bike</i> page revised.</value>
|
||||
</data>
|
||||
<data name="ChangeLog_3_0_346_SB" xml:space="preserve">
|
||||
<value><i>Select Bike</i>- page revised.<br/>
|
||||
Setting added to select whether the app starts up showing either
|
||||
<ul>
|
||||
<li/><i>Bike Locations</i> or
|
||||
<li/><i>Select Bike</i>
|
||||
</ul>
|
||||
page.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -1446,6 +1446,30 @@ Sie können nun auf einen Blick sehen, welche App-Version Sie installiert haben:
|
|||
- Einstellungen sind auch ohne Anmeldung verfügbar.
|
||||
- Die Reihenfolge der Karteikarten auf der Seite Bedienung wurde getauscht.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MarkingStartupPage" translate="yes" xml:space="preserve">
|
||||
<source>Startup page</source>
|
||||
<target state="translated">Startseite</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ChangeLog_3_0_346_LB_MK" translate="yes" xml:space="preserve">
|
||||
<source><bpt id="1"><i></bpt>Select Bike<ept id="1"></i></ept> page revised.</source>
|
||||
<target state="translated"><bpt id="1"><i></bpt>Rad auswählen<ept id="1"></i></ept> Seite überarbeitet.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ChangeLog_3_0_346_SB" translate="yes" xml:space="preserve">
|
||||
<source><bpt id="1"><i></bpt>Select Bike<ept id="1"></i></ept>- page revised.<br/>
|
||||
Setting added to select whether the app starts up showing either
|
||||
<bpt id="2"><ul></bpt>
|
||||
<li/><bpt id="3"><i></bpt>Bike Locations<ept id="3"></i></ept> or
|
||||
<li/><bpt id="4"><i></bpt>Select Bike<ept id="4"></i></ept>
|
||||
<ept id="2"></ul></ept>
|
||||
page.</source>
|
||||
<target state="translated"><bpt id="1"><i></bpt>Rad auswählen<ept id="1"></i></ept>- Seite überarbeitet.<br/>
|
||||
Einstellung hinzugefügt mit der festgelegt werden kann, ob die App mit der Seite
|
||||
<bpt id="2"><ul></bpt>
|
||||
<li/><bpt id="3"><i></bpt>Radstandorte<ept id="3"></i></ept> oder
|
||||
<li/><bpt id="4"><i></bpt>Rad auswählen<ept id="4"></i></ept>
|
||||
<ept id="2"></ul></ept>
|
||||
gestartet wird.</target>
|
||||
</trans-unit>
|
||||
</group>
|
||||
</body>
|
||||
</file>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
|
@ -218,6 +218,12 @@ namespace TINK.ViewModel.Bikes
|
|||
}
|
||||
|
||||
break;
|
||||
|
||||
case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
|
||||
// Empty collection.
|
||||
// Occurs in context of find bike page when searching for second, third, ... bike (reopen of page via flyout).
|
||||
ClearItems();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,11 +448,17 @@ namespace TINK.ViewModel.Bikes
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when page is shown.
|
||||
/// Starts update process.
|
||||
/// Invoked when page is shown and starts update process.
|
||||
/// </summary>
|
||||
/// <param name="updateAction"> Update fuction passed as argument by child class.</param>
|
||||
protected async Task OnAppearing(Action updateAction)
|
||||
=> await StartUpdateTask(updateAction);
|
||||
|
||||
/// <summary>
|
||||
/// Starts update process.
|
||||
/// </summary>
|
||||
/// <param name="updateAction"> Update fuction passed as argument by child class.</param>
|
||||
public async Task StartUpdateTask(Action updateAction)
|
||||
{
|
||||
m_oViewUpdateManager = new PollingUpdateTaskManager(updateAction);
|
||||
|
||||
|
@ -465,10 +477,7 @@ namespace TINK.ViewModel.Bikes
|
|||
/// Invoked when page is shutdown.
|
||||
/// Currently invoked by code behind, would be nice if called by XAML in future versions.
|
||||
/// </summary>
|
||||
public async Task OnDisappearing()
|
||||
{
|
||||
|
||||
await m_oViewUpdateManager.StopUpdatePeridically();
|
||||
}
|
||||
public virtual async Task OnDisappearing()
|
||||
=> await m_oViewUpdateManager.StopUpdatePeridically();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,11 @@ using TINK.Model.Bikes;
|
|||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.Services.CopriApi;
|
||||
using TINK.Model.Station;
|
||||
using TINK.Model.User;
|
||||
using TINK.MultilingualResources;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Services.BluetoothLock;
|
||||
using TINK.Services.BluetoothLock.Tdo;
|
||||
using TINK.Services.Geolocation;
|
||||
|
@ -43,6 +45,7 @@ namespace TINK.ViewModel.FindBike
|
|||
}
|
||||
|
||||
bikeIdUserInput = value;
|
||||
base.OnPropertyChanged(new PropertyChangedEventArgs(nameof(BikeIdUserInput)));
|
||||
base.OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelectBikeEnabled)));
|
||||
}
|
||||
}
|
||||
|
@ -123,14 +126,29 @@ namespace TINK.ViewModel.FindBike
|
|||
/// </summary>
|
||||
public async Task OnAppearing()
|
||||
{
|
||||
IsIdle = false;
|
||||
|
||||
Log.ForContext<FindBikePageViewModel>().Information("User request to show page FindBike- page re-appearing");
|
||||
|
||||
ActionText = AppResources.ActivityTextFindBikeLoadingBikes;
|
||||
if (string.IsNullOrEmpty(BikeIdUserInput) /* Find bike page flyout was taped */
|
||||
&& BikeCollection.Count > 0 /* Bike was successfully selected */)
|
||||
{
|
||||
// Find bike page flyout was taped and page was already opened before and bike has been selected.
|
||||
// Clear bike collection to allow user to enter bike id and search for bike.
|
||||
BikeCollection.Clear();
|
||||
}
|
||||
|
||||
var bikes = await ConnectorFactory(IsConnected).Query.GetBikesAsync();
|
||||
if (BikeCollection.Count > 0)
|
||||
{
|
||||
// Page is appearing not because page flyout was taped.
|
||||
// Bike has already been selected.
|
||||
// Restart update.
|
||||
await StartUpdateTask(() => UpdateTask());
|
||||
|
||||
Exception = bikes.Exception; // Update communication error from query for bikes occupied.
|
||||
Bikes = bikes.Response;
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
|
@ -142,6 +160,48 @@ namespace TINK.ViewModel.FindBike
|
|||
/// <summary> Select a bike by ID</summary>
|
||||
public async Task SelectBike()
|
||||
{
|
||||
// Get List of bike to be able to connect to.
|
||||
ActionText = AppResources.ActivityTextFindBikeLoadingBikes;
|
||||
IsIdle = false;
|
||||
|
||||
Result<BikeCollection> bikes = null;
|
||||
try
|
||||
{
|
||||
bikes = await ConnectorFactory(IsConnected).Query.GetBikesAsync();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (exception is WebConnectFailureException)
|
||||
{
|
||||
// Copri server is not reachable.
|
||||
Log.ForContext<FindBikePageViewModel>().Information("Getting bikes failed failed (Copri server not reachable).");
|
||||
|
||||
await ViewService.DisplayAdvancedAlert(
|
||||
AppResources.ErrorReturnBikeNoWebTitle,
|
||||
string.Format("{0}\r\n{1}", AppResources.ErrorReturnBikeNoWebMessage, WebConnectFailureException.GetHintToPossibleExceptionsReasons),
|
||||
exception.Message,
|
||||
AppResources.MessageAnswerOk);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext<FindBikePageViewModel>().Error("Getting bikes failed. {Exception}", exception);
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
exception.Message,
|
||||
AppResources.MessageAnswerOk);
|
||||
}
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Exception = bikes?.Exception ?? null; // Update communication error from query for bikes occupied.
|
||||
Bikes = bikes.Response;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var selectedBike = Bikes.FirstOrDefault(x => x.Id.Equals(BikeIdUserInput.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||
|
@ -152,6 +212,9 @@ namespace TINK.ViewModel.FindBike
|
|||
AppResources.MessageTitleHint,
|
||||
string.Format(AppResources.MessageErrorSelectBikeNoBikeFound, BikeIdUserInput),
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -193,7 +256,7 @@ namespace TINK.ViewModel.FindBike
|
|||
// User decided not to give access to locations permissions.
|
||||
BikeCollection.Update(bikeCollection, Stations);
|
||||
|
||||
//await OnAppearing(() => UpdateTask());
|
||||
await StartUpdateTask(() => UpdateTask());
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
|
@ -215,7 +278,7 @@ namespace TINK.ViewModel.FindBike
|
|||
|
||||
BikeCollection.Update(bikeCollection, Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
await StartUpdateTask(() => UpdateTask());
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
|
@ -232,7 +295,7 @@ namespace TINK.ViewModel.FindBike
|
|||
|
||||
BikeCollection.Update(bikeCollection, Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
await StartUpdateTask(() => UpdateTask());
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
|
@ -259,7 +322,7 @@ namespace TINK.ViewModel.FindBike
|
|||
|
||||
BikeCollection.Update(bikeCollection.UpdateLockInfo(locksInfo), Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
await StartUpdateTask(() => UpdateTask());
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
|
@ -272,6 +335,9 @@ namespace TINK.ViewModel.FindBike
|
|||
AppResources.MessageAnswerOk);
|
||||
|
||||
Log.ForContext<FindBikePageViewModel>().Error("Running command to select bike failed. {Exception}", exception);
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms;
|
||||
using TINK.View;
|
||||
using TINK.Model.Station;
|
||||
using System;
|
||||
|
@ -1028,4 +1028,4 @@ namespace TINK.ViewModel.Map
|
|||
|
||||
public bool IsToggleVisible => tinkKonradToggleViewModel.IsToggleVisible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
18
TINKLib/ViewModel/Settings/PickerViewModel.cs
Normal file
18
TINKLib/ViewModel/Settings/PickerViewModel.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace TINK.ViewModel.Settings
|
||||
{
|
||||
/// <summary> Manages data to be shown by a picker. </summary>
|
||||
public class PickerViewModel : ServicesViewModel
|
||||
{
|
||||
/// <summary>Constructs view model ensuring consistency. </summary>
|
||||
/// <param name="serviceToText"> Dictionary holding values and display text to mange and display by picker.</param>
|
||||
/// <param name="active">Value of entry for which the display text has to be shown.</param>
|
||||
public PickerViewModel(
|
||||
IDictionary<string, string> serviceToText,
|
||||
string active) : base(serviceToText.Select(x => x.Key), serviceToText, active)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
@ -8,6 +8,7 @@ using Serilog.Events;
|
|||
using TINK.Model;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.User.Account;
|
||||
using TINK.MultilingualResources;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Services;
|
||||
using TINK.Services.BluetoothLock;
|
||||
|
@ -44,6 +45,9 @@ namespace TINK.ViewModel
|
|||
/// <summary> Manages selection of locks services.</summary>
|
||||
public LocksServicesViewModel LocksServices { get; }
|
||||
|
||||
/// <summary>Settings determining the startup behavior of the app.</summary>
|
||||
public ServicesViewModel StartupSettings { get; }
|
||||
|
||||
/// <summary> Manages selection of geolocation services.</summary>
|
||||
public ServicesViewModel GeolocationServices { get; }
|
||||
|
||||
|
@ -155,6 +159,13 @@ namespace TINK.ViewModel
|
|||
{ typeof(GeolocationAccuracyBestService).FullName, "Best Accuracy" },
|
||||
{ typeof(SimulatedGeolocationService).FullName, "Simulation-AlwaysSamePosition" } },
|
||||
GeoloctionServicesContainer.Active.GetType().FullName);
|
||||
|
||||
StartupSettings = new PickerViewModel(
|
||||
new Dictionary<string, string> {
|
||||
{ ViewTypes.MapPage.ToString(), AppResources.MarkingMapPage },
|
||||
{ ViewTypes.FindBikePage.ToString(), AppResources.MarkingFindBike },
|
||||
},
|
||||
tinkApp.StartupSettings.StartupPage.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -259,6 +270,8 @@ namespace TINK.ViewModel
|
|||
TinkApp.GroupFilterMapPage,
|
||||
TinkApp.ActiveUser.DoFilter(TinkApp.FilterGroupSetting.DoFilter()));
|
||||
|
||||
TinkApp.StartupSettings.StartupPage = Enum.TryParse(StartupSettings.Active, out ViewTypes startupPage) ? startupPage : Model.Settings.StartupSettings.DefaultStartupPage;
|
||||
|
||||
TinkApp.CenterMapToCurrentLocation = CenterMapToCurrentLocation;
|
||||
|
||||
if (IsLogToExternalFolderVisible)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace TINK
|
||||
namespace TINK
|
||||
{
|
||||
/// <summary> Holds a entry for each page of the TINK app.</summary>
|
||||
public enum ViewTypes
|
||||
|
@ -18,6 +18,7 @@
|
|||
BikesAtStation,
|
||||
ContactPage,
|
||||
SelectStationPage,
|
||||
MiniSurvey
|
||||
MiniSurvey,
|
||||
FindBikePage
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue