Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1145 from cocoa-mhlw/feature/splash-transition
Browse files Browse the repository at this point in the history
起動時にサービス終了画面へ遷移するようにする
  • Loading branch information
cocoa-dev004 authored Sep 19, 2022
2 parents d5485de + df690d0 commit 30da086
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 28 deletions.
6 changes: 3 additions & 3 deletions Covid19Radar/Covid19Radar.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Covid19Radar/Covid19Radar.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()));
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Covid19Radar/Covid19Radar/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
using Covid19Radar.Services.Migration;
using Covid19Radar.Repository;
using DryIoc;
using Covid19Radar.Views.EndOfService;
using Covid19Radar.Model;

/*
* Our mission...is
Expand Down Expand Up @@ -187,6 +189,10 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
containerRegistry.RegisterForNavigation<HowToReceiveProcessingNumberPage>();
containerRegistry.RegisterForNavigation<WebAccessibilityPolicyPage>();
containerRegistry.RegisterForNavigation<TroubleshootingPage>();

// End of service
containerRegistry.RegisterForNavigation<EndOfServiceNoticePage>();
containerRegistry.RegisterForNavigation<EndOfServicePage>();
}

private static void RegisterCommonTypes(IContainer container)
Expand Down
2 changes: 2 additions & 0 deletions Covid19Radar/Covid19Radar/Covid19Radar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<None Remove="Controls\**" />
<None Remove="ViewModels\ExposureCheckPage\" />
<None Remove="Polly" />
<None Remove="Views\EndOfService\" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -141,6 +142,7 @@
<Folder Include="Controls\" />
<Folder Include="Services\Migration\" />
<Folder Include="Repository\" />
<Folder Include="Views\EndOfService\" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Compile Remove="ViewModels/Settings/DebugPageViewModel.cs" />
Expand Down
15 changes: 8 additions & 7 deletions Covid19Radar/Covid19Radar/Destination.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@
* 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
{
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()
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task<INavigationResult> NavigateNextAsync(bool isSetupLaterEventLog
}
else
{
name = $"/{nameof(TutorialPage1)}";
name = Destination.EndOfService.ToPath();
parameters = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Destination>(SplashPage.DestinationKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ INavigationService navigationService

public Command OnToHomeButton => new Command(async () =>
{
_ = await NavigationService.NavigateAsync(Destination.HomePage.ToPath());
//_ = await NavigationService.NavigateAsync(Destination.HomePage.ToPath());
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Covid19Radar.Views.EndOfService.EndOfServiceNoticePage">
<ContentPage.Content>
<Label Text="EndOfServiceNoticePage" />
</ContentPage.Content>
</ContentPage>

Original file line number Diff line number Diff line change
@@ -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();
}
}
}

10 changes: 10 additions & 0 deletions Covid19Radar/Covid19Radar/Views/EndOfService/EndOfServicePage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Covid19Radar.Views.EndOfService.EndOfServicePage">
<ContentPage.Content>
<Label Text="EndOfServicePage" />
</ContentPage.Content>
</ContentPage>

Original file line number Diff line number Diff line change
@@ -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();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ public class SplashNavigationServiceTests
private readonly Mock<IUserDataRepository> mockUserDataRepository;
private readonly Mock<ILoggerService> 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);
Expand All @@ -45,27 +39,27 @@ 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);

await unitUnderTest.NavigateNextAsync();

mockUserDataRepository.Verify(x => x.IsAllAgreed(), Times.Once());
mockNavigatoinService.Verify(x => x.NavigateAsync("/TutorialPage1", It.IsAny<INavigationParameters>()), Times.Once());
mockNavigatoinService.Verify(x => x.NavigateAsync("/EndOfServicePage", It.IsAny<INavigationParameters>()), Times.Once());
}

[Fact]
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);
Expand All @@ -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<INavigationParameters>(x =>
x.ContainsKey("test-key") &&
x.GetValue<string>("test-key") == "test-value")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down

0 comments on commit 30da086

Please sign in to comment.