Skip to content

Commit

Permalink
Replaced TaxonId with GUID for compat with web
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Stretz authored and Stefan Stretz committed Feb 15, 2023
1 parent 492a05d commit 5266a66
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" android:versionName="1.1.9.4" package="com.kbs.idoapp" android:versionCode="46">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" android:versionName="2.0.2" package="com.kbs.idoapp" android:versionCode="49">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Expand All @@ -21,4 +21,4 @@
</provider>
<uses-library android:name="org.apache.http.legacy" android:required="false" />
</application>
</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
<string>Zum Auswählen von Fotos wird die Foto-Berechtigung benötigt. Damit sollen Fotos zu Fundmeldungen hinzugefügt werden und gespeichert werden. </string>
<key>UIRequiresFullScreen</key>
<true/>
<key>CFBundleVersion</key>
<string>1.9.9</string>
<key>CFBundleShortVersionString</key>
<string>1.9.9</string>
<string>2.0.2</string>
<key>CFBundleVersion</key>
<string>2.0.2</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public object Convert(object value,
object parameter,
System.Globalization.CultureInfo culture)
{
var taxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.TaxonId == (int)value);
var taxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.Identifier == Guid.Parse(value.ToString()));
return taxon != null ? taxon.LocalName : "Unbekannte Art";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ public Task<List<PositionModel>> GetAllPositionsAsync()
rm.RecordDate = (DateTime)ajis.AdviceDate;
rm.TotalCount = ajis.AdviceCount.HasValue? ajis.AdviceCount.Value:0;
rm.HabitatName = ajis.AdviceCity;
rm.MaleCount = ajis.MaleCount;
rm.FemaleCount = ajis.FemaleCount;
rm.MaleCount = ajis.MaleCount.HasValue? ajis.MaleCount.Value:0;
rm.FemaleCount = ajis.FemaleCount.HasValue ? ajis.FemaleCount.Value : 0;
rm.StateEgg = ajis.StateEgg;
rm.StateLarva = ajis.StateLarva;
rm.StateImago = ajis.StateImago;
Expand Down Expand Up @@ -235,10 +235,10 @@ public Task<List<PositionModel>> GetAllPositionsAsync()
rm.TaxonId = ajis.TaxonId;
rm.TaxonGuid = ajis.TaxonGuid.ToString();
rm.RecordDate = (DateTime)ajis.AdviceDate;
rm.TotalCount = (int)ajis.AdviceCount;
rm.TotalCount = ajis.AdviceCount.HasValue? ajis.AdviceCount.Value:0;
rm.HabitatName = ajis.AdviceCity;
rm.MaleCount = (int)ajis.MaleCount;
rm.FemaleCount = (int)ajis.FemaleCount;
rm.MaleCount = ajis.MaleCount.HasValue? ajis.MaleCount.Value:0;
rm.FemaleCount = ajis.FemaleCount.HasValue? ajis.FemaleCount.Value:0;
rm.StateEgg = ajis.StateEgg;
rm.StateLarva = ajis.StateLarva;
rm.StateImago = ajis.StateImago;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class AdviceJsonItem
public AdviceImageJsonItem[] Images { get; set; }
[DataMember]
public int? DiagnosisTypeId { get; set; }
[DataMember]
public string TaxonGuid { get; set; }

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Position = Xamarin.Forms.Maps.Position;
using Application = Xamarin.Forms.Application;
using ListView = Xamarin.Forms.ListView;
using Xamarin.Forms.Internals;

namespace KBS.App.TaxonFinder.Views
{
Expand Down Expand Up @@ -60,6 +61,7 @@ public RecordEdit(int taxonId)
{
RecordEditViewModel.TaxonId = taxonId;
var taxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.TaxonId == taxonId);
RecordEditViewModel.TaxonGuid = taxon.Identifier.ToString();
//TaxonNameLabel.Text = taxon != null ? taxon.LocalName : "Unbekannte Art";

}
Expand Down Expand Up @@ -102,7 +104,7 @@ public RecordEdit(int localRecordId, int taxonId)
//LoadDiagnosisTypePicker();

RecordEditViewModel.SelectedRecordId = localRecordId;
var taxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.TaxonId == taxonId);
var taxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.Identifier == Guid.Parse(RecordEditViewModel.TaxonGuid));
OnPropertyChanged(nameof(RecordEditViewModel.TaxonId));
OnPropertyChanged(nameof(RecordEditViewModel.TaxonName));
//TaxonNameLabel.Text = taxon != null ? taxon.LocalName : "Unbekannte Art";
Expand Down Expand Up @@ -131,9 +133,9 @@ public RecordEdit(int localRecordId, int taxonId)

public void UpdateTaxonPicker()
{
if (RecordEditViewModel.TaxonId != null)
if (RecordEditViewModel.TaxonGuid != null)
{
var ix = RecordEditViewModel.TaxonPickerItemsSource.Select(tx => tx.TaxonId).ToList().IndexOf((int)RecordEditViewModel.TaxonId);
var ix = RecordEditViewModel.TaxonPickerItemsSource.Select(tx => tx.Identifier).ToList().IndexOf(Guid.Parse(RecordEditViewModel.TaxonGuid));
TaxonPicker.SelectedIndex = ix;
}
}
Expand Down Expand Up @@ -245,9 +247,10 @@ public async void SetDiagnosisTypePicker()

public async void SetTaxonPicker()
{
if (RecordEditViewModel.TaxonId != null)
if (RecordEditViewModel.TaxonGuid != null)
{
var ix = RecordEditViewModel.TaxonPickerItemsSource.Select(taxonPickerI => taxonPickerI.TaxonId).ToList().IndexOf((int)RecordEditViewModel.TaxonId);

var ix = RecordEditViewModel.TaxonPickerItemsSource.Select(taxonPickerI => taxonPickerI.Identifier).ToList().IndexOf(Guid.Parse(RecordEditViewModel.TaxonGuid.ToString()));
TaxonPicker.SelectedIndex = ix;
}
}
Expand All @@ -264,6 +267,7 @@ void OnTaxonPickerSelectedIndexChanged(object sender, EventArgs e)
if (result.TaxonId != 0)
{
RecordEditViewModel.TaxonId = result.TaxonId;
RecordEditViewModel.TaxonGuid = result.Identifier.ToString();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public int SelectedRecordId
LocalRecordId = value;
IsEditable = _selectedRecord.IsEditable;
TaxonId = _selectedRecord.TaxonId;
TaxonGuid = _selectedRecord.TaxonGuid;
CreationDate = _selectedRecord.CreationDate;
Identifier = _selectedRecord.Identifier;
RecordDate = _selectedRecord.RecordDate;
Expand Down Expand Up @@ -391,11 +392,12 @@ private async Task SaveRecord()
(Position != PositionOption.Pin && PositionList.Count != 0)
&& !String.IsNullOrEmpty(ReportedByName)) && TaxonId >= -1 && !string.IsNullOrEmpty(HabitatDescription))
{
Taxon tempTax = ((App)App.Current).Taxa.FirstOrDefault(i => i.TaxonId == (int)(TaxonId));
Taxon tempTax = ((App)App.Current).Taxa.FirstOrDefault(i => i.Identifier == Guid.Parse(TaxonGuid));

var recordModel = new RecordModel
{
TaxonId = TaxonId,
TaxonId = tempTax.TaxonId,
TaxonGuid = tempTax.Identifier.ToString(),
CreationDate = DateTime.Now,
Identifier = String.IsNullOrEmpty(Identifier) ? Guid.NewGuid().ToString() : Identifier,
IsSynced = false,
Expand Down Expand Up @@ -671,14 +673,15 @@ public AdviceJsonItem SaveTaxa()
baseString = fileHelper.GetBase64FromImagePath(media.Path);
baseList.Add(new AdviceImageJsonItem(baseString, media.Path));
}
var tempTaxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.TaxonId == (int)(_selectedRecord.TaxonId));
var tempTaxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.Identifier == Guid.Parse(_selectedRecord.TaxonGuid.ToString()));
var taxonName = (tempTaxon != null) ? tempTaxon.TaxonName : "";

AdviceJsonItem adviceJsonItem = new AdviceJsonItem
{
AdviceId = _selectedRecord.LocalRecordId,
Identifier = Guid.Parse(_selectedRecord.Identifier),
TaxonId = _selectedRecord.TaxonId,
TaxonId = tempTaxon.TaxonId,
TaxonGuid = _selectedRecord.TaxonGuid,
TaxonFullName = taxonName,
AdviceDate = _selectedRecord.RecordDate,
AdviceCount = _selectedRecord.TotalCount,
Expand Down Expand Up @@ -744,7 +747,7 @@ public AdviceJsonItemSync ConvertToJsonForSync(RecordModel rm)
Trace.WriteLine(ex);
}
}
var tempTaxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.TaxonId == (int)(rm.TaxonId));
var tempTaxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.Identifier == Guid.Parse(rm.TaxonGuid));

if (tempTaxon == null)
{
Expand All @@ -755,7 +758,7 @@ public AdviceJsonItemSync ConvertToJsonForSync(RecordModel rm)
{
GlobalAdviceId = rm.GlobalAdviceId,
Identifier = Guid.Parse(rm.Identifier),
TaxonId = rm.TaxonId,
TaxonId = tempTaxon.TaxonId,
TaxonFullName = tempTaxon.TaxonName,
TaxonGuid = tempTaxon.Identifier,
AdviceDate = rm.RecordDate,
Expand Down Expand Up @@ -805,15 +808,15 @@ public RecordModel ConvertToRecordModel(AdviceJsonItemSync ajis)
{
try
{
var tempTaxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.TaxonId == (int)(ajis.TaxonId));
var tempTaxon = ((App)App.Current).Taxa.FirstOrDefault(i => i.Identifier == Guid.Parse(TaxonGuid));
var taxonName = (tempTaxon != null) ? tempTaxon.TaxonName : "";

RecordModel rm = new RecordModel
{
GlobalAdviceId = ajis.GlobalAdviceId,
Identifier = ajis.Identifier.ToString(),
TaxonId = ajis.TaxonId,
TaxonGuid = ajis.TaxonGuid.ToString(),
TaxonId = tempTaxon.TaxonId,
TaxonGuid = tempTaxon.Identifier.ToString(),
RecordDate = (DateTime)ajis.AdviceDate,
TotalCount = (int)ajis.AdviceCount,
HabitatName = ajis.AdviceCity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<RowDefinition Height="25"></RowDefinition>
</Grid.RowDefinitions>
<StackLayout Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Margin="5,5,0,0">
<Label Text="{Binding TaxonId, Converter={conv:TaxonIdToTaxonNameConverter}}" TextColor="{Binding TaxonId, Converter={conv:TaxonIdToColorConverter}}" FontAttributes="Bold" FontSize="Small"></Label>
<Label Text="{Binding TaxonGuid, Converter={conv:TaxonIdToTaxonNameConverter}}" TextColor="{Binding TaxonId, Converter={conv:TaxonIdToColorConverter}}" FontAttributes="Bold" FontSize="Small"></Label>
</StackLayout>
<StackLayout Grid.Column="0"
Grid.Row="1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public static RecordDatabase Database
public bool NewRecord { get; set; }
public bool ShowSyncButton { get; set; }
public bool EnableSearch { get; set; }
private string _taxonNameSafe;
public string TaxonNameSafe { get { return _taxonNameSafe; } set { _taxonNameSafe = value; OnPropertyChanged(TaxonNameSafe); } }


public bool IsBusy
{
get { return _isBusy; }
Expand Down Expand Up @@ -337,7 +341,8 @@ public void CheckLogin()
OnPropertyChanged(nameof(Unauthorized));
OnPropertyChanged(nameof(ShowSyncButton));
}
else {
else
{
Unauthorized = false;
ShowSyncButton = true;
Result = "";
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 5266a66

Please sign in to comment.