diff --git a/Component.DB/ViewModels/AboutViewModel.cs b/Component.DB/ViewModels/AboutViewModel.cs index b0e1c68..4f6aeb1 100644 --- a/Component.DB/ViewModels/AboutViewModel.cs +++ b/Component.DB/ViewModels/AboutViewModel.cs @@ -4,7 +4,7 @@ */ using System; using System.Windows.Input; - +using Xamarin.Essentials; using Xamarin.Forms; namespace Component.DB.ViewModels @@ -15,8 +15,8 @@ public AboutViewModel() { Title = "About"; - OpenWebCommand = new Command(() => Device.OpenUri(new Uri("https://xamarin.com/platform"))); - OpenLicenseCommand = new Command(() => Device.OpenUri(new Uri("https://raw.githubusercontent.com/AdvancedPhotonSource/ComponentDB-Mobile/master/LICENSE"))); + OpenWebCommand = new Command(() => Launcher.OpenAsync(new Uri("https://xamarin.com/platform"))); + OpenLicenseCommand = new Command(() => Launcher.OpenAsync(new Uri("https://raw.githubusercontent.com/AdvancedPhotonSource/ComponentDB-Mobile/master/LICENSE"))); } public ICommand OpenWebCommand { get; } diff --git a/Component.DB/ViewModels/ItemDetailEditViewModel.cs b/Component.DB/ViewModels/ItemDetailEditViewModel.cs index 2e3d4be..9135d99 100644 --- a/Component.DB/ViewModels/ItemDetailEditViewModel.cs +++ b/Component.DB/ViewModels/ItemDetailEditViewModel.cs @@ -3,13 +3,9 @@ * See LICENSE file. */ using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Diagnostics; using System.Threading.Tasks; -using Component.DB.Utilities; using Gov.ANL.APS.CDB.Model; -using Stormlion.PhotoBrowser; namespace Component.DB.ViewModels { @@ -38,23 +34,23 @@ public async Task UpdateItem() } } - public async Task UpdateItemLocationAsync() + public ItemLocationInformation UpdateItemLocation() { if (this.ItemLocationInformation == null) { - throw new Exception("The location was never loaded so it cannot be modified"); - } + throw new Exception("The location was never loaded so it cannot be modified"); + } var dbLocationInformation = itemApi.GetItemLocation(Item.Id); - if (ItemLocationInformation.LocationDetails == null) + if (ItemLocationInformation.LocationDetails == null) ItemLocationInformation.LocationDetails = ""; - if (dbLocationInformation.LocationDetails == null) + if (dbLocationInformation.LocationDetails == null) dbLocationInformation.LocationDetails = ""; // -1 means null int curLocationd = -1; - int origLocationId = -1; + int origLocationId = -1; if (ItemLocationInformation.LocationItem != null) { curLocationd = (int)ItemLocationInformation.LocationItem.Id; @@ -87,7 +83,7 @@ public async Task UpdateItemLocationAsync() var locationDetails = ItemLocationInformation.LocationDetails; var args = new SimpleLocationInformation(Item.Id, locationId, locationDetails); - itemApi.UpdateItemLocation(args); + itemApi.UpdateItemLocation(args); } return this.ItemLocationInformation; @@ -139,6 +135,7 @@ public string QrIdEntry Item.QrId = result; } catch (Exception ex) { + Debug.WriteLine(ex); Item.QrId = null; } diff --git a/Component.DB/ViewModels/ItemDetailViewModel.cs b/Component.DB/ViewModels/ItemDetailViewModel.cs index d3a97fb..357afdc 100644 --- a/Component.DB/ViewModels/ItemDetailViewModel.cs +++ b/Component.DB/ViewModels/ItemDetailViewModel.cs @@ -4,7 +4,6 @@ */ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Diagnostics; using System.Threading.Tasks; using System.Windows.Input; @@ -12,6 +11,7 @@ using Component.DB.Utilities; using Gov.ANL.APS.CDB.Model; using Stormlion.PhotoBrowser; +using Xamarin.Essentials; using Xamarin.Forms; namespace Component.DB.ViewModels @@ -40,7 +40,7 @@ public void OpenViewInPortalCommand() var portalUrl = address + Constants.ItemViewPath + Item.Id; - Device.OpenUri(new Uri(portalUrl)); + Launcher.OpenAsync(new Uri(portalUrl)); } public void loadFromQrId(int qrId) diff --git a/Component.DB/Views/ItemDetailPages/ItemDetailPage.xaml.cs b/Component.DB/Views/ItemDetailPages/ItemDetailPage.xaml.cs index de1cf24..b8a09d3 100644 --- a/Component.DB/Views/ItemDetailPages/ItemDetailPage.xaml.cs +++ b/Component.DB/Views/ItemDetailPages/ItemDetailPage.xaml.cs @@ -169,7 +169,15 @@ async void HandleUploadImageClicked(object sender, System.EventArgs e) DefaultCamera = CameraDevice.Rear }; - var photo = await CrossMedia.Current.TakePhotoAsync(config); + MediaFile photo = null; + try + { + photo = await CrossMedia.Current.TakePhotoAsync(config); + } catch(Exception ex) + { + HandleException(ex); + } + if (photo != null) { diff --git a/Component.DB/Views/QrScannerPage.xaml.cs b/Component.DB/Views/QrScannerPage.xaml.cs index 98bdacd..3c863f2 100644 --- a/Component.DB/Views/QrScannerPage.xaml.cs +++ b/Component.DB/Views/QrScannerPage.xaml.cs @@ -24,7 +24,7 @@ public QrScannerPage() itemApi = CdbApiFactory.Instance.itemApi; } - public async void Handle_OnScanResult(Result result) + public void Handle_OnScanResult(Result result) { var v = CrossVibrate.Current; v.Vibration(TimeSpan.FromSeconds(0.5)); @@ -33,7 +33,7 @@ public async void Handle_OnScanResult(Result result) var topic = QrMessage.MESSAGE_SCANNED_TOPIC; QrMessage message = new QrMessage(result.BarcodeFormat.ToString(), result.Text); - MessagingCenter.Send(message, topic); + MessagingCenter.Send(message, topic); } } diff --git a/Component.DB/Views/itemEditPages/EditItemDetailPage.xaml.cs b/Component.DB/Views/itemEditPages/EditItemDetailPage.xaml.cs index ab55779..476869a 100644 --- a/Component.DB/Views/itemEditPages/EditItemDetailPage.xaml.cs +++ b/Component.DB/Views/itemEditPages/EditItemDetailPage.xaml.cs @@ -183,7 +183,7 @@ async void HandleSaveClicked(object sender, System.EventArgs e) try { - await viewModel.UpdateItemLocationAsync(); + viewModel.UpdateItemLocation(); } catch (Exception ex) { diff --git a/Component.DB/Views/itemEditPages/MultiItemRelocatePage.xaml.cs b/Component.DB/Views/itemEditPages/MultiItemRelocatePage.xaml.cs index fab9970..4e0ba46 100644 --- a/Component.DB/Views/itemEditPages/MultiItemRelocatePage.xaml.cs +++ b/Component.DB/Views/itemEditPages/MultiItemRelocatePage.xaml.cs @@ -90,7 +90,7 @@ async void HandleRelocateItemsClicked(object sender, System.EventArgs e) locInfo.LocationItem = locationItem; locInfo.LocationDetails = viewModel.LocationDetails; - await item.UpdateItemLocationAsync(); + item.UpdateItemLocation(); } catch (Exception ex) {