From 74fa019000d54ccf34e214462516143536915192 Mon Sep 17 00:00:00 2001 From: Niccari Date: Tue, 23 Jun 2020 08:24:09 +0900 Subject: [PATCH 01/26] Validating diagnosis uid in the NotifyOtherPage --- .../Covid19Radar/Common/AppConstants.cs | 4 +++ .../HomePage/NotifyOtherPageViewModel.cs | 27 ++++++++++++++----- .../Views/HomePage/NotifyOtherPage.xaml | 3 ++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Covid19Radar/Covid19Radar/Common/AppConstants.cs b/Covid19Radar/Covid19Radar/Common/AppConstants.cs index 9ae7aab8..0c03ccdc 100644 --- a/Covid19Radar/Covid19Radar/Common/AppConstants.cs +++ b/Covid19Radar/Covid19Radar/Common/AppConstants.cs @@ -19,6 +19,10 @@ public static class AppConstants /// Max Error Count /// public const int MaxErrorCount = 3; + /// + /// Max diagnosis UID Count + /// + public const int MaxDiagnosisUidCount = 8; public const string positiveRegex = @"\b[0-9]{8}\b"; diff --git a/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs b/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs index df509eea..3051cec7 100644 --- a/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs +++ b/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs @@ -15,8 +15,22 @@ namespace Covid19Radar.ViewModels { public class NotifyOtherPageViewModel : ViewModelBase { - public bool IsEnabled { get; set; } - public string DiagnosisUid { get; set; } + private string _diagnosisUid; + public string DiagnosisUid + { + get { return _diagnosisUid; } + set + { + SetProperty(ref _diagnosisUid, value); + IsEnabled = DiagnosisUid.Length == AppConstants.MaxDiagnosisUidCount; // validate + } + } + private bool _isEnabled; + public bool IsEnabled + { + get { return _isEnabled; } + set { SetProperty(ref _isEnabled, value); } + } private int errorCount { get; set; } private readonly UserDataService userDataService; @@ -28,7 +42,7 @@ public NotifyOtherPageViewModel(INavigationService navigationService, UserDataSe this.userDataService = userDataService; userData = this.userDataService.Get(); errorCount = 0; - IsEnabled = true; + DiagnosisUid = ""; } public Command OnClickRegister => (new Command(async () => @@ -72,7 +86,7 @@ await UserDialogs.Instance.AlertAsync(AppResources.NotifyOtherPageDiag3Message, // Init Dialog - if (string.IsNullOrEmpty(DiagnosisUid)) + if (string.IsNullOrEmpty(_diagnosisUid)) { await UserDialogs.Instance.AlertAsync( AppResources.NotifyOtherPageDiag4Message, @@ -86,7 +100,7 @@ await UserDialogs.Instance.AlertAsync( } Regex regex = new Regex(AppConstants.positiveRegex); - if (!regex.IsMatch(DiagnosisUid)) + if (!regex.IsMatch(_diagnosisUid)) { await UserDialogs.Instance.AlertAsync( AppResources.NotifyOtherPageDiag5Message, @@ -118,7 +132,7 @@ await UserDialogs.Instance.AlertAsync( } // Set the submitted UID - userData.AddDiagnosis(DiagnosisUid, new DateTimeOffset(DateTime.Now)); + userData.AddDiagnosis(_diagnosisUid, new DateTimeOffset(DateTime.Now)); await userDataService.SetAsync(userData); // Submit our diagnosis @@ -143,7 +157,6 @@ await UserDialogs.Instance.AlertAsync( finally { UserDialogs.Instance.HideLoading(); - IsEnabled = true; } })); } diff --git a/Covid19Radar/Covid19Radar/Views/HomePage/NotifyOtherPage.xaml b/Covid19Radar/Covid19Radar/Views/HomePage/NotifyOtherPage.xaml index 19599e8e..6e155974 100644 --- a/Covid19Radar/Covid19Radar/Views/HomePage/NotifyOtherPage.xaml +++ b/Covid19Radar/Covid19Radar/Views/HomePage/NotifyOtherPage.xaml @@ -7,6 +7,7 @@ xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core" xmlns:prism="http://prismlibrary.com" xmlns:resources="clr-namespace:Covid19Radar.Resources" + xmlns:common="clr-namespace:Covid19Radar.Common" xmlns:system="clr-namespace:System;assembly=netstandard" Title="{x:Static resources:AppResources.NotifyOtherPageTitle}" ios:Page.UseSafeArea="true" @@ -50,7 +51,7 @@ From 8eb5e41a4bfced68343947fb9c89caa036de30dd Mon Sep 17 00:00:00 2001 From: Nobuhiro Ito Date: Mon, 22 Jun 2020 02:11:04 +0900 Subject: [PATCH 02/26] use Debug.WriteLine instead Console.WriteLine # Conflicts: # Covid19Radar/Covid19Radar/Services/ExposureNotificationService.cs --- .../Services/ExposureNotificationHandler.cs | 14 +++++++------- .../Services/ExposureNotificationService.cs | 9 +++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs b/Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs index 81eeb14c..8be9c2ad 100644 --- a/Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs +++ b/Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs @@ -133,7 +133,7 @@ public async Task FetchExposureKeyBatchFilesFromServerAsync(Func lastTekTimestamp = userData.LastProcessTekTimestamp; @@ -181,8 +181,8 @@ public async Task FetchExposureKeyBatchFilesFromServerAsync(Func lastCreated || lastCreated == 0) { var tmpFile = Path.Combine(tmpDir, Guid.NewGuid().ToString() + ".zip"); - Console.WriteLine(Utils.SerializeToJson(tekItem)); - Console.WriteLine(tmpFile); + Debug.WriteLine(Utils.SerializeToJson(tekItem)); + Debug.WriteLine(tmpFile); Stream responseStream = await httpDataService.GetTemporaryExposureKey(tekItem.Url, cancellationToken); var fileStream = File.Create(tmpFile); try @@ -192,15 +192,15 @@ public async Task FetchExposureKeyBatchFilesFromServerAsync(Func Date: Tue, 23 Jun 2020 23:51:37 +0900 Subject: [PATCH 03/26] Fix MenuPage list item color --- .../Covid19Radar/Model/MainMenuModel.cs | 45 ++++++++++++++++++- .../ViewModels/MenuPageViewModel.cs | 34 +++++++++++--- Covid19Radar/Covid19Radar/Views/MenuPage.xaml | 4 +- 3 files changed, 74 insertions(+), 9 deletions(-) diff --git a/Covid19Radar/Covid19Radar/Model/MainMenuModel.cs b/Covid19Radar/Covid19Radar/Model/MainMenuModel.cs index 99228b94..6d10ac5f 100644 --- a/Covid19Radar/Covid19Radar/Model/MainMenuModel.cs +++ b/Covid19Radar/Covid19Radar/Model/MainMenuModel.cs @@ -1,9 +1,50 @@ -namespace Covid19Radar.Model +using System.ComponentModel; + +namespace Covid19Radar.Model { - public class MainMenuModel + public class MainMenuModel : INotifyPropertyChanged { + private string iconColor; + private string textColor; + public event PropertyChangedEventHandler PropertyChanged; + public string Title { get; set; } public string Icon { get; set; } public string PageName { get; set; } + public string IconColor + { + set + { + if (iconColor != value) + { + iconColor = value; + OnPropertyChanged("IconColor"); + } + } + get + { + return iconColor; + } + } + public string TextColor + { + set + { + if (textColor != value) + { + textColor = value; + OnPropertyChanged("TextColor"); + } + } + get + { + return textColor; + } + } + + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } } } diff --git a/Covid19Radar/Covid19Radar/ViewModels/MenuPageViewModel.cs b/Covid19Radar/Covid19Radar/ViewModels/MenuPageViewModel.cs index 46b042ee..37ee2536 100644 --- a/Covid19Radar/Covid19Radar/ViewModels/MenuPageViewModel.cs +++ b/Covid19Radar/Covid19Radar/ViewModels/MenuPageViewModel.cs @@ -4,6 +4,8 @@ using Xamarin.Forms; using Covid19Radar.Model; using Covid19Radar.Views; +using System.Diagnostics; +using Xamarin.Forms.Internals; namespace Covid19Radar.ViewModels { @@ -27,33 +29,43 @@ public MenuPageViewModel(INavigationService navigationService) : base(navigation { Icon = "\uf965", PageName = nameof(HomePage), - Title = Resources.AppResources.HomePageTitle + Title = Resources.AppResources.HomePageTitle, + IconColor = "#019AE8", + TextColor = "#000" }); MenuItems.Add(new MainMenuModel() { Icon = "\uf013", PageName = nameof(SettingsPage), - Title = Resources.AppResources.SettingsPageTitle + Title = Resources.AppResources.SettingsPageTitle, + IconColor = "#019AE8", + TextColor = "#000" }); MenuItems.Add(new MainMenuModel() { Icon = "\uf0e0", PageName = nameof(InqueryPage), - Title = Resources.AppResources.InqueryPageTitle + Title = Resources.AppResources.InqueryPageTitle, + IconColor = "#019AE8", + TextColor = "#000" }); MenuItems.Add(new MainMenuModel() { Icon = "\uf70e", PageName = nameof(TermsofservicePage), - Title = Resources.AppResources.TermsofservicePageTitle + Title = Resources.AppResources.TermsofservicePageTitle, + IconColor = "#019AE8", + TextColor = "#000" }); MenuItems.Add(new MainMenuModel() { Icon = "\uf70e", PageName = nameof(PrivacyPolicyPage2), - Title = Resources.AppResources.PrivacyPolicyPageTitle + Title = Resources.AppResources.PrivacyPolicyPageTitle, + IconColor = "#019AE8", + TextColor = "#000" }); /* #if DEBUG @@ -195,9 +207,21 @@ public MenuPageViewModel(INavigationService navigationService) : base(navigation async void Navigate() { + ClearSelectedItem(); + SelectedMenuItem.IconColor = "#FFF"; + SelectedMenuItem.TextColor = "#FFF"; await NavigationService.NavigateAsync(nameof(NavigationPage) + "/" + SelectedMenuItem.PageName); return; } + private void ClearSelectedItem() + { + MenuItems.ForEach(item => + { + item.IconColor = "#019AE8"; + item.TextColor = "#000"; + }); + } + } } diff --git a/Covid19Radar/Covid19Radar/Views/MenuPage.xaml b/Covid19Radar/Covid19Radar/Views/MenuPage.xaml index 3e4b3c0f..ec9e540e 100644 --- a/Covid19Radar/Covid19Radar/Views/MenuPage.xaml +++ b/Covid19Radar/Covid19Radar/Views/MenuPage.xaml @@ -44,14 +44,14 @@ FontFamily="FA-S" Glyph="{Binding Icon}" Size="30" - Color="#019AE8" /> + Color="{Binding IconColor}" />