From 78a13adc700da9c921e2b2dddd5e02280bcc026d Mon Sep 17 00:00:00 2001 From: ARIYAMA Keiji Date: Thu, 20 Jan 2022 00:45:40 +0900 Subject: [PATCH 1/2] Check ExposureNotification API is enabled/activated onAppearing. --- .../HomePage/NotifyOtherPageViewModel.cs | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs b/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs index 6eba3657c..87f8a014d 100644 --- a/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs +++ b/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs @@ -159,6 +159,31 @@ public override void Initialize(INavigationParameters parameters) } } + public override async void OnAppearing() + { + base.OnAppearing(); + + // EN Enabled Check + var isEnEnabled = await exposureNotificationApiService.IsEnabledAsync(); + var enStatusCodes = await exposureNotificationApiService.GetStatusCodesAsync(); + + var isEnActivated = enStatusCodes.Contains(ExposureNotificationStatus.Code_iOS.Active) + || enStatusCodes.Contains(ExposureNotificationStatus.Code_Android.ACTIVATED); + + if (!isEnEnabled || !isEnActivated) + { + loggerService.Warning($"Exposure notification is not enabled or activated."); + + await UserDialogs.Instance.AlertAsync( + AppResources.NotifyOtherPageDiag6Message, + AppResources.NotifyOtherPageDiag6Title, + AppResources.ButtonOk + ); + await NavigationService.NavigateAsync("/" + nameof(MenuPage) + "/" + nameof(NavigationPage) + "/" + nameof(HomePage)); + return; + } + } + public Command OnInqueryTelephoneNumberClicked => new Command(() => { loggerService.StartMethod(); @@ -266,22 +291,6 @@ await UserDialogs.Instance.AlertAsync( return; } - // EN Enabled Check - var enabled = await exposureNotificationApiService.IsEnabledAsync(); - - if (!enabled) - { - await UserDialogs.Instance.AlertAsync( - AppResources.NotifyOtherPageDiag6Message, - AppResources.NotifyOtherPageDiag6Title, - AppResources.ButtonOk - ); - await NavigationService.NavigateAsync("/" + nameof(MenuPage) + "/" + nameof(NavigationPage) + "/" + nameof(HomePage)); - - loggerService.Warning($"Exposure notification is disable."); - return; - } - // UserDialogs.Instance.Loading must be executed in MainThread. UserDialogs.Instance.ShowLoading(AppResources.LoadingTextRegistering); From f1738fe9503a0e737221d6bc1068aebf43967f5b Mon Sep 17 00:00:00 2001 From: ARIYAMA Keiji Date: Thu, 20 Jan 2022 01:29:55 +0900 Subject: [PATCH 2/2] Remove activate check. --- .../ViewModels/HomePage/NotifyOtherPageViewModel.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs b/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs index 6c891c3d1..3301f7ca5 100644 --- a/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs +++ b/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs @@ -165,12 +165,8 @@ public override async void OnAppearing() // EN Enabled Check var isEnEnabled = await exposureNotificationApiService.IsEnabledAsync(); - var enStatusCodes = await exposureNotificationApiService.GetStatusCodesAsync(); - var isEnActivated = enStatusCodes.Contains(ExposureNotificationStatus.Code_iOS.Active) - || enStatusCodes.Contains(ExposureNotificationStatus.Code_Android.ACTIVATED); - - if (!isEnEnabled || !isEnActivated) + if (!isEnEnabled) { loggerService.Warning($"Exposure notification is not enabled or activated.");