Version 3.0.337

This commit is contained in:
Anja Müller-Meißner 2022-08-30 15:42:25 +02:00
parent fd0e63cf10
commit 573fe77e12
2336 changed files with 33688 additions and 86082 deletions

View file

@ -1,6 +1,4 @@
using System.Collections.Generic;
using TINK.Model;
using Xamarin.Forms;
using Xamarin.Forms;
namespace TINK.ViewModel.Map
{
@ -18,10 +16,14 @@ namespace TINK.ViewModel.Map
public Color TinkColor => Color.Default;
public Color NoTinkColor => Color.Default;
public bool IsKonradEnabled => false;
public Color KonradColor => Color.Default;
public Color NoKonradColor => Color.Default;
public bool IsToggleVisible => false;
public string CurrentFilter => string.Empty;

View file

@ -22,7 +22,7 @@ namespace TINK.ViewModel.Map
/// <param name="filterCollection">Filter collection to get group from.</param>
/// <returns>List of active filters.</returns>
/// <todo>Rename to ToFilterList</todo>
public IList<string> GetGroup()
public IList<string> GetGroup()
{
return this.Where(x => x.Value == FilterState.On).Select(x => x.Key).ToList();
}
@ -32,7 +32,7 @@ namespace TINK.ViewModel.Map
private IDictionary<string, FilterState> FilterDictionary { get; }
public FilterState this[string key] { get => FilterDictionary[key]; set => FilterDictionary[key] = value ; }
public FilterState this[string key] { get => FilterDictionary[key]; set => FilterDictionary[key] = value; }
public ICollection<string> Keys => FilterDictionary.Keys;
@ -43,7 +43,7 @@ namespace TINK.ViewModel.Map
public bool IsReadOnly => true;
public void Add(string key, FilterState value) => throw new System.NotImplementedException();
public void Add(KeyValuePair<string, FilterState> item) => throw new System.NotImplementedException();
public void Clear() => throw new System.NotImplementedException();
@ -52,7 +52,7 @@ namespace TINK.ViewModel.Map
public bool ContainsKey(string key) => FilterDictionary.ContainsKey(key);
public void CopyTo(KeyValuePair<string, FilterState>[] array, int arrayIndex) => FilterDictionary.CopyTo(array, arrayIndex);
public void CopyTo(KeyValuePair<string, FilterState>[] array, int arrayIndex) => FilterDictionary.CopyTo(array, arrayIndex);
public IEnumerator<KeyValuePair<string, FilterState>> GetEnumerator() => FilterDictionary.GetEnumerator();

View file

@ -4,7 +4,7 @@ namespace TINK.ViewModel.Map
{
public interface ITinkKonradToggleViewModel
{
IGroupFilterMapPage FilterDictionary { get; }
IGroupFilterMapPage FilterDictionary { get; }
string CurrentFilter { get; }
@ -12,10 +12,14 @@ namespace TINK.ViewModel.Map
Color TinkColor { get; }
Color NoTinkColor { get; }
bool IsKonradEnabled { get; }
Color KonradColor { get; }
Color NoKonradColor { get; }
bool IsToggleVisible { get; }
}
}

View file

@ -3,7 +3,7 @@ using TINK.View;
using TINK.Model.Station;
using System;
using System.Linq;
using TINK.Model.Bike;
using TINK.Model.Bikes;
using TINK.Repository.Exception;
using TINK.Model;
using Serilog;
@ -26,6 +26,7 @@ using TINK.Services.BluetoothLock;
using TINK.ViewModel.Info;
using TINK.Repository;
using TINK.Services.Geolocation;
using TINK.Model.State;
#if !TRYNOTBACKSTYLE
#endif
@ -103,7 +104,8 @@ namespace TINK.ViewModel.Map
IGeolocation GeolocationService { get; }
/// <summary> False if user tabed on station marker to show bikes at a given station.</summary>
public bool IsMapPageEnabled {
public bool IsMapPageEnabled
{
get => isMapPageEnabled;
private set
{
@ -173,6 +175,8 @@ namespace TINK.ViewModel.Map
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(TinkColor)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(KonradColor)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(NoTinkColor)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(NoKonradColor)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsToggleVisible)));
}
}
@ -210,7 +214,7 @@ namespace TINK.ViewModel.Map
var l_oPin = new Pin
{
Position = new Xamarin.Forms.GoogleMaps.Position(station.Position.Latitude, station.Position.Longitude),
Label = long.TryParse(station.Id, out long stationId) && stationId > CUSTOM_ICONS_COUNT
? station.GetStationName()
@ -234,13 +238,13 @@ namespace TINK.ViewModel.Map
for (int pinIndex = 0; pinIndex < stationsColorList.Count; pinIndex++)
{
var indexPartPrefix = int.TryParse(Pins[pinIndex].Tag.ToString(), out int stationId)
var indexPartPrefix = int.TryParse(Pins[pinIndex].Tag.ToString(), out int stationId)
&& stationId <= CUSTOM_ICONS_COUNT
? $"{stationId}" // there is a station marker with index letter for given station id
: "Open"; // there is no station marker. Use open marker.
var colorPartPrefix = GetRessourceNameColorPart(stationsColorList[pinIndex]);
var l_iName = $"{indexPartPrefix.ToString().PadLeft(2, '0')}_{colorPartPrefix}{(DeviceInfo.Platform == DevicePlatform.Android ? ".png" : string.Empty)}";
try
{
@ -307,7 +311,7 @@ namespace TINK.ViewModel.Map
Polling = TinkApp.Polling;
Log.ForContext<MapPageViewModel>().Information(
$"{(Polling != null && Polling.IsActivated ? $"Map page is appearing. Update periode is {Polling.Periode.TotalSeconds} sec." : "Map page is appearing. Polling is off.")}" +
$"{(Polling != null && Polling.IsActivated ? $"Map page is appearing. Update periode is {Polling.Periode.TotalSeconds} sec." : "Map page is appearing. Polling is off.")}" +
$"Current UI language is {Thread.CurrentThread.CurrentUICulture.Name}.");
// Update map page filter
@ -329,7 +333,7 @@ namespace TINK.ViewModel.Map
await ViewService.DisplayAlert(
"Information",
resultStationsAndBikes.GeneralData.MerchantMessage,
AppResources.MessageAnswerOk);
AppResources.MessageAnswerOk);
WasMerchantMessageAlreadyShown = true;
}
@ -424,6 +428,7 @@ namespace TINK.ViewModel.Map
AppResources.MessageMapPageErrorAuthcookieUndefined,
AppResources.MessageAnswerOk);
IsConnected = TinkApp.GetIsConnected();
await TinkApp.GetConnector(IsConnected).Command.DoLogout();
TinkApp.ActiveUser.Logout();
}
@ -496,9 +501,9 @@ namespace TINK.ViewModel.Map
if (currentLocation == null)
return null;
return Model.Map.MapSpanFactory.Create(
PositionFactory.Create(currentLocation.Latitude, currentLocation.Longitude),
TinkApp.ActiveMapSpan.Radius.Kilometers);
return Model.Map.MapSpanFactory.Create(
PositionFactory.Create(currentLocation.Latitude, currentLocation.Longitude),
TinkApp.ActiveMapSpan.Radius.Kilometers);
}
/// <summary>
@ -645,7 +650,7 @@ namespace TINK.ViewModel.Map
// Lock action to prevent multiple instances of "BikeAtStation" being opened.
IsMapPageEnabled = false;
TinkApp.SelectedStation = TinkApp.Stations.FirstOrDefault(x => x.Id == selectedStationId)
TinkApp.SelectedStation = TinkApp.Stations.FirstOrDefault(x => x.Id == selectedStationId)
?? new Station(selectedStationId, new List<string>(), null); // Station might not be in list StationDictinaly because this list is not updatd in background task.
#if TRYNOTBACKSTYLE
@ -701,7 +706,7 @@ namespace TINK.ViewModel.Map
{
// Get color of given station.
var bikesAtStation = bikesAll.Where(x => x.StationId == stationId).ToList();
if (bikesAtStation.FirstOrDefault(x => x.State.Value != Model.State.InUseStateEnum.Disposable) != null)
if (bikesAtStation.FirstOrDefault(x => x.State.Value.IsOccupied()) != null)
{
// There is at least one requested or booked bike
colors.Add(Color.LightBlue);
@ -865,14 +870,14 @@ namespace TINK.ViewModel.Map
}
/// <summary> User request to toggle from TINK to Konrad. </summary>
private async Task ActivateFilter(string p_strSelectedFilter)
private async Task ActivateFilter(string selectedFilter)
{
try
{
IsMapPageEnabled = false;
IsRunning = true;
Log.ForContext<MapPageViewModel>().Information($"Request to toggle to \"{p_strSelectedFilter}\".");
Log.ForContext<MapPageViewModel>().Information($"Request to toggle to \"{selectedFilter}\".");
// Stop polling.
ActionText = AppResources.ActivityTextOneMomentPlease;
@ -927,7 +932,7 @@ namespace TINK.ViewModel.Map
{
await ViewService.DisplayAlert(
AppResources.MessageTitleHint,
AppResources.MessageBikesManagementBluetoothActivation,
AppResources.MessageBikesManagementBluetoothActivation,
AppResources.MessageAnswerOk);
ActionText = "";
IsRunning = false;
@ -996,7 +1001,7 @@ namespace TINK.ViewModel.Map
ActionText = "";
IsRunning = false;
IsMapPageEnabled = true;
Log.ForContext<MapPageViewModel>().Information($"Toggle to \"{p_strSelectedFilter}\" done.");
Log.ForContext<MapPageViewModel>().Information($"Toggle to \"{selectedFilter}\" done.");
}
catch (Exception l_oException)
{
@ -1018,6 +1023,10 @@ namespace TINK.ViewModel.Map
public Color KonradColor => tinkKonradToggleViewModel.KonradColor;
public Color NoTinkColor => tinkKonradToggleViewModel.NoTinkColor;
public Color NoKonradColor => tinkKonradToggleViewModel.NoKonradColor;
public bool IsToggleVisible => tinkKonradToggleViewModel.IsToggleVisible;
}
}

View file

@ -21,7 +21,8 @@ namespace TINK.ViewModel.Map
public IGroupFilterMapPage FilterDictionary { get; }
/// <summary> Gets the activated filter.</summary>
public string CurrentFilter {
public string CurrentFilter
{
get
{
return FilterDictionary.FirstOrDefault(x => x.Value == FilterState.On).Key ?? string.Empty;
@ -32,17 +33,18 @@ namespace TINK.ViewModel.Map
public bool IsTinkEnabled => !string.IsNullOrEmpty(CurrentFilter) && CurrentFilter.GetBikeCategory() != FilterHelper.CARGOBIKE;
/// <summary> Gets color of the TINK button. </summary>
public Color TinkColor => CurrentFilter.GetBikeCategory() == FilterHelper.CARGOBIKE ? Color.Blue : Color.Gray;
public Color TinkColor => CurrentFilter.GetBikeCategory() == FilterHelper.CARGOBIKE ? Color.White : Color.FromRgba(0, 0, 0, 0);
public Color NoTinkColor => CurrentFilter.GetBikeCategory() == FilterHelper.CARGOBIKE ? Color.FromRgb(210, 17, 20) : Color.White;
/// <summary> Gets value whether Konrad is enabled or not. </summary>
public bool IsKonradEnabled => !string.IsNullOrEmpty(CurrentFilter) && CurrentFilter.GetBikeCategory() != FilterHelper.CITYBIKE;
/// <summary> Gets color of the Konrad button. </summary>
public Color KonradColor => CurrentFilter.GetBikeCategory() == FilterHelper.CITYBIKE ? Color.Red : Color.Gray;
public Color KonradColor => CurrentFilter.GetBikeCategory() == FilterHelper.CITYBIKE ? Color.White : Color.FromRgba(0, 0, 0, 0);
public Color NoKonradColor => CurrentFilter.GetBikeCategory() == FilterHelper.CITYBIKE ? Color.FromRgb(210, 17, 20) : Color.White;
/// <summary> Gets whether toggle functionality is visible or not. </summary>
public bool IsToggleVisible =>
FilterDictionary.Select(x => x.Key).ContainsGroupId(FilterHelper.CITYBIKE)
public bool IsToggleVisible =>
FilterDictionary.Select(x => x.Key).ContainsGroupId(FilterHelper.CITYBIKE)
&& FilterDictionary.Select(x => x.Key).ContainsGroupId(FilterHelper.CARGOBIKE)
&& (IsTinkEnabled || IsKonradEnabled);
@ -56,27 +58,27 @@ namespace TINK.ViewModel.Map
/// <returns></returns>
public TinkKonradToggleViewModel DoToggle()
{
var l_oCurrentFilterSet = FilterDictionary.ToArray();
var currentFilterSet = FilterDictionary.ToArray();
if (l_oCurrentFilterSet.Length < 2)
if (currentFilterSet.Length < 2)
{
// There is nothing to toggle because filter set contains only one element.
return new TinkKonradToggleViewModel(FilterDictionary);
}
var l_oCurrentState = l_oCurrentFilterSet[l_oCurrentFilterSet.Length - 1].Value == FilterState.On
var currentState = currentFilterSet[currentFilterSet.Length - 1].Value == FilterState.On
? FilterState.On
: FilterState.Off;
var l_oToggledFilterSet = new Dictionary<string, FilterState>();
var toggledFilterSet = new Dictionary<string, FilterState>();
foreach (var l_oFilterElement in l_oCurrentFilterSet)
foreach (var filterElement in currentFilterSet)
{
l_oToggledFilterSet.Add(l_oFilterElement.Key, l_oCurrentState);
l_oCurrentState = l_oFilterElement.Value;
toggledFilterSet.Add(filterElement.Key, currentState);
currentState = filterElement.Value;
}
return new TinkKonradToggleViewModel(new GroupFilterMapPage(l_oToggledFilterSet));
return new TinkKonradToggleViewModel(new GroupFilterMapPage(toggledFilterSet));
}
}
}