From df690d02d609e05ebec85fe53abadee750d0886f Mon Sep 17 00:00:00 2001 From: cocoa-dev004 <66989461+cocoa-dev004@users.noreply.github.com> Date: Fri, 16 Sep 2022 14:09:55 +0900 Subject: [PATCH] Add end of service page (empty page) --- .../Covid19Radar.Android/MainActivity.cs | 6 +++--- Covid19Radar/Covid19Radar.iOS/AppDelegate.cs | 4 ++-- Covid19Radar/Covid19Radar/App.xaml.cs | 6 ++++++ Covid19Radar/Covid19Radar/Covid19Radar.csproj | 2 ++ Covid19Radar/Covid19Radar/Destination.cs | 15 ++++++++------- .../Services/SplashNavigationService.cs | 2 +- .../HomePage/NotifyOtherPageViewModel.cs | 2 +- .../HomePage/SplashPageViewModel.cs | 2 +- ...ubmitDiagnosisKeysCompletePageViewModel.cs | 2 +- .../EndOfService/EndOfServiceNoticePage.xaml | 10 ++++++++++ .../EndOfServiceNoticePage.xaml.cs | 19 +++++++++++++++++++ .../Views/EndOfService/EndOfServicePage.xaml | 10 ++++++++++ .../EndOfService/EndOfServicePage.xaml.cs | 19 +++++++++++++++++++ .../Services/SplashNavigationServiceTests.cs | 16 +++++----------- .../HomePage/NotifyOtherPageViewModelTests.cs | 2 +- 15 files changed, 89 insertions(+), 28 deletions(-) create mode 100644 Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServiceNoticePage.xaml create mode 100644 Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServiceNoticePage.xaml.cs create mode 100644 Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServicePage.xaml create mode 100644 Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServicePage.xaml.cs diff --git a/Covid19Radar/Covid19Radar.Android/MainActivity.cs b/Covid19Radar/Covid19Radar.Android/MainActivity.cs index 99afc6ef8..3fd078843 100644 --- a/Covid19Radar/Covid19Radar.Android/MainActivity.cs +++ b/Covid19Radar/Covid19Radar.Android/MainActivity.cs @@ -122,12 +122,12 @@ private async Task NavigateToDestinationFromIntent(Intent intent) else { _loggerService.Value.Error("Failed to navigate NotifyOtherPage with invalid processingNumber"); - await AppInstance?.NavigateToSplashAsync(Destination.HomePage, new NavigationParameters()); + await AppInstance?.NavigateToSplashAsync(Destination.EndOfServiceNotice, new NavigationParameters()); } } else if (intent.HasExtra(EXTRA_KEY_DESTINATION)) { - int ordinal = intent.GetIntExtra(EXTRA_KEY_DESTINATION, (int)Destination.HomePage); + int ordinal = intent.GetIntExtra(EXTRA_KEY_DESTINATION, (int)Destination.EndOfServiceNotice); var destination = (Destination)Enum.ToObject(typeof(Destination), ordinal); _loggerService.Value.Info($"Intent has destination: {destination}"); @@ -137,7 +137,7 @@ private async Task NavigateToDestinationFromIntent(Intent intent) } else { - await AppInstance?.NavigateToSplashAsync(Destination.HomePage, new NavigationParameters()); + await AppInstance?.NavigateToSplashAsync(Destination.EndOfServiceNotice, new NavigationParameters()); } _loggerService.Value.EndMethod(); diff --git a/Covid19Radar/Covid19Radar.iOS/AppDelegate.cs b/Covid19Radar/Covid19Radar.iOS/AppDelegate.cs index 47e3a5de8..e7a68d71d 100644 --- a/Covid19Radar/Covid19Radar.iOS/AppDelegate.cs +++ b/Covid19Radar/Covid19Radar.iOS/AppDelegate.cs @@ -112,7 +112,7 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary launchOpt if (!IsUniversalLinks(launchOptions) && !IsLocalNotification(launchOptions)) { - InvokeOnMainThread(async () => await AppInstance?.NavigateToSplashAsync(Destination.HomePage, new NavigationParameters())); + InvokeOnMainThread(async () => await AppInstance?.NavigateToSplashAsync(Destination.EndOfServiceNotice, new NavigationParameters())); } UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval(UIApplication.BackgroundFetchIntervalMinimum); @@ -247,7 +247,7 @@ private void NavigateUniversalLinks(NSUrl url) else { _loggerService.Value.Error("Failed to navigate NotifyOtherPage with invalid processingNumber"); - InvokeOnMainThread(async () => await AppInstance?.NavigateToSplashAsync(Destination.HomePage, new NavigationParameters())); + InvokeOnMainThread(async () => await AppInstance?.NavigateToSplashAsync(Destination.EndOfServiceNotice, new NavigationParameters())); } } } diff --git a/Covid19Radar/Covid19Radar/App.xaml.cs b/Covid19Radar/Covid19Radar/App.xaml.cs index 12f65ba89..7dd026570 100644 --- a/Covid19Radar/Covid19Radar/App.xaml.cs +++ b/Covid19Radar/Covid19Radar/App.xaml.cs @@ -17,6 +17,8 @@ using Covid19Radar.Services.Migration; using Covid19Radar.Repository; using DryIoc; +using Covid19Radar.Views.EndOfService; +using Covid19Radar.Model; /* * Our mission...is @@ -187,6 +189,10 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation(); + + // End of service + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); } private static void RegisterCommonTypes(IContainer container) diff --git a/Covid19Radar/Covid19Radar/Covid19Radar.csproj b/Covid19Radar/Covid19Radar/Covid19Radar.csproj index e8d734c14..3017f28c8 100644 --- a/Covid19Radar/Covid19Radar/Covid19Radar.csproj +++ b/Covid19Radar/Covid19Radar/Covid19Radar.csproj @@ -28,6 +28,7 @@ + @@ -141,6 +142,7 @@ + diff --git a/Covid19Radar/Covid19Radar/Destination.cs b/Covid19Radar/Covid19Radar/Destination.cs index e694b4eeb..2ead56c17 100644 --- a/Covid19Radar/Covid19Radar/Destination.cs +++ b/Covid19Radar/Covid19Radar/Destination.cs @@ -2,7 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +using System; using Covid19Radar.Views; +using Covid19Radar.Views.EndOfService; using Xamarin.Forms; namespace Covid19Radar @@ -10,26 +12,25 @@ namespace Covid19Radar public enum Destination : int { SplashPage, - HomePage, ContactedNotifyPage, NotifyOtherPage, + EndOfServiceNotice, + EndOfService, } public static class DestinationExtensions { private static string SplashPagePath = "/" + nameof(SplashPage); - private static string HomePagePath => "/" + nameof(MenuPage) + "/" + nameof(NavigationPage) + "/" + nameof(HomePage); - private static string ContactedNotifyPagePath => HomePagePath + "/" + nameof(ContactedNotifyPage); - private static string NotifyOtherPagePath => HomePagePath + "/" + nameof(NotifyOtherPage); + private static string EndOfServiceNoticePath => $"/{nameof(MenuPage)}/{nameof(NavigationPage)}/{nameof(EndOfServiceNoticePage)}"; + private static string EndOfServicePath => $"/{nameof(EndOfServicePage)}"; public static string ToPath(this Destination destination) { return destination switch { Destination.SplashPage => SplashPagePath, - Destination.HomePage => HomePagePath, - Destination.ContactedNotifyPage => ContactedNotifyPagePath, - Destination.NotifyOtherPage => NotifyOtherPagePath, + Destination.EndOfServiceNotice => EndOfServiceNoticePath, + Destination.EndOfService => EndOfServicePath, _ => throw new System.NotImplementedException() }; } diff --git a/Covid19Radar/Covid19Radar/Services/SplashNavigationService.cs b/Covid19Radar/Covid19Radar/Services/SplashNavigationService.cs index 9a9300219..2dbbfdfd7 100644 --- a/Covid19Radar/Covid19Radar/Services/SplashNavigationService.cs +++ b/Covid19Radar/Covid19Radar/Services/SplashNavigationService.cs @@ -55,7 +55,7 @@ public async Task NavigateNextAsync(bool isSetupLaterEventLog } else { - name = $"/{nameof(TutorialPage1)}"; + name = Destination.EndOfService.ToPath(); parameters = null; } diff --git a/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs b/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs index dbfa17a5d..8d50c1809 100644 --- a/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs +++ b/Covid19Radar/Covid19Radar/ViewModels/HomePage/NotifyOtherPageViewModel.cs @@ -240,7 +240,7 @@ await UserDialogs.Instance.AlertAsync( AppResources.NotifyOtherPageDialogReturnHomeTitle, AppResources.ButtonOk ); - await NavigationService.NavigateAsync(Destination.HomePage.ToPath()); + //await NavigationService.NavigateAsync(Destination.HomePage.ToPath()); loggerService.Error($"Exceeded the number of trials."); return; diff --git a/Covid19Radar/Covid19Radar/ViewModels/HomePage/SplashPageViewModel.cs b/Covid19Radar/Covid19Radar/ViewModels/HomePage/SplashPageViewModel.cs index 90205932e..e71b55956 100644 --- a/Covid19Radar/Covid19Radar/ViewModels/HomePage/SplashPageViewModel.cs +++ b/Covid19Radar/Covid19Radar/ViewModels/HomePage/SplashPageViewModel.cs @@ -36,7 +36,7 @@ public override async void OnNavigatedTo(INavigationParameters parameters) await _migrationService.MigrateAsync(); - Destination destination = Destination.HomePage; + Destination destination = Destination.EndOfServiceNotice; if (parameters.ContainsKey(SplashPage.DestinationKey)) { destination = parameters.GetValue(SplashPage.DestinationKey); diff --git a/Covid19Radar/Covid19Radar/ViewModels/HomePage/SubmitDiagnosisKeysCompletePageViewModel.cs b/Covid19Radar/Covid19Radar/ViewModels/HomePage/SubmitDiagnosisKeysCompletePageViewModel.cs index 0d51712a9..a32fad74b 100644 --- a/Covid19Radar/Covid19Radar/ViewModels/HomePage/SubmitDiagnosisKeysCompletePageViewModel.cs +++ b/Covid19Radar/Covid19Radar/ViewModels/HomePage/SubmitDiagnosisKeysCompletePageViewModel.cs @@ -17,7 +17,7 @@ INavigationService navigationService public Command OnToHomeButton => new Command(async () => { - _ = await NavigationService.NavigateAsync(Destination.HomePage.ToPath()); + //_ = await NavigationService.NavigateAsync(Destination.HomePage.ToPath()); }); } } diff --git a/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServiceNoticePage.xaml b/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServiceNoticePage.xaml new file mode 100644 index 000000000..2a46e4420 --- /dev/null +++ b/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServiceNoticePage.xaml @@ -0,0 +1,10 @@ + + + + + + diff --git a/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServiceNoticePage.xaml.cs b/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServiceNoticePage.xaml.cs new file mode 100644 index 000000000..5a8d55e61 --- /dev/null +++ b/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServiceNoticePage.xaml.cs @@ -0,0 +1,19 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +namespace Covid19Radar.Views.EndOfService +{ + public partial class EndOfServiceNoticePage : ContentPage + { + public EndOfServiceNoticePage() + { + InitializeComponent(); + } + } +} + diff --git a/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServicePage.xaml b/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServicePage.xaml new file mode 100644 index 000000000..f377933e8 --- /dev/null +++ b/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServicePage.xaml @@ -0,0 +1,10 @@ + + + + + + diff --git a/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServicePage.xaml.cs b/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServicePage.xaml.cs new file mode 100644 index 000000000..d1ce0cd25 --- /dev/null +++ b/Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServicePage.xaml.cs @@ -0,0 +1,19 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +namespace Covid19Radar.Views.EndOfService +{ + public partial class EndOfServicePage : ContentPage + { + public EndOfServicePage() + { + InitializeComponent(); + } + } +} + diff --git a/Covid19Radar/Tests/Covid19Radar.UnitTests/Services/SplashNavigationServiceTests.cs b/Covid19Radar/Tests/Covid19Radar.UnitTests/Services/SplashNavigationServiceTests.cs index a611e3aa2..eecc8aa4a 100644 --- a/Covid19Radar/Tests/Covid19Radar.UnitTests/Services/SplashNavigationServiceTests.cs +++ b/Covid19Radar/Tests/Covid19Radar.UnitTests/Services/SplashNavigationServiceTests.cs @@ -22,12 +22,6 @@ public class SplashNavigationServiceTests private readonly Mock mockUserDataRepository; private readonly Mock mockLoggerService; - private readonly TermsUpdateInfoModel _termsUpdateInfoDefault = new TermsUpdateInfoModel - { - TermsOfService = new TermsUpdateInfoModel.Detail { Text = "Test: Terms of service", UpdateDateTimeJst = DateTime.Now }, - PrivacyPolicy = new TermsUpdateInfoModel.Detail { Text = "Test: Privacy policy", UpdateDateTimeJst = DateTime.Now } - }; - public SplashNavigationServiceTests() { mockRepository = new MockRepository(MockBehavior.Default); @@ -45,11 +39,11 @@ public SplashNavigationService CreateService() } [Fact] - public async Task NavigateNextAsyncTest_Tutorial() + public async Task NavigateNextAsyncTest_EndOfServicePage() { SplashNavigationService unitUnderTest = CreateService(); - unitUnderTest.Destination = Destination.HomePage; + unitUnderTest.Destination = Destination.EndOfServiceNotice; unitUnderTest.DestinationPageParameters = new NavigationParameters(); mockUserDataRepository.Setup(x => x.IsAllAgreed()).Returns(false); @@ -57,7 +51,7 @@ public async Task NavigateNextAsyncTest_Tutorial() await unitUnderTest.NavigateNextAsync(); mockUserDataRepository.Verify(x => x.IsAllAgreed(), Times.Once()); - mockNavigatoinService.Verify(x => x.NavigateAsync("/TutorialPage1", It.IsAny()), Times.Once()); + mockNavigatoinService.Verify(x => x.NavigateAsync("/EndOfServicePage", It.IsAny()), Times.Once()); } [Fact] @@ -65,7 +59,7 @@ public async Task NavigateNextAsyncTest_Destination() { SplashNavigationService unitUnderTest = CreateService(); - unitUnderTest.Destination = Destination.HomePage; + unitUnderTest.Destination = Destination.EndOfServiceNotice; unitUnderTest.DestinationPageParameters = new NavigationParameters { { "test-key", "test-value" } }; mockUserDataRepository.Setup(x => x.IsAllAgreed()).Returns(true); @@ -74,7 +68,7 @@ public async Task NavigateNextAsyncTest_Destination() mockUserDataRepository.Verify(x => x.IsAllAgreed(), Times.Once()); mockNavigatoinService.Verify(x => x.NavigateAsync( - Destination.HomePage.ToPath(), + Destination.EndOfServiceNotice.ToPath(), It.Is(x => x.ContainsKey("test-key") && x.GetValue("test-key") == "test-value")), diff --git a/Covid19Radar/Tests/Covid19Radar.UnitTests/ViewModels/HomePage/NotifyOtherPageViewModelTests.cs b/Covid19Radar/Tests/Covid19Radar.UnitTests/ViewModels/HomePage/NotifyOtherPageViewModelTests.cs index b82404326..5062ad533 100644 --- a/Covid19Radar/Tests/Covid19Radar.UnitTests/ViewModels/HomePage/NotifyOtherPageViewModelTests.cs +++ b/Covid19Radar/Tests/Covid19Radar.UnitTests/ViewModels/HomePage/NotifyOtherPageViewModelTests.cs @@ -118,7 +118,7 @@ public void CheckRegisterButtonMaxErrorCountReturnHomeTest() null ), Times.Once()); - mockNavigationService.Verify(x => x.NavigateAsync("/MenuPage/NavigationPage/HomePage"), Times.Once()); + //mockNavigationService.Verify(x => x.NavigateAsync("/MenuPage/NavigationPage/HomePage"), Times.Once()); } }