fix notification activation

This commit is contained in:
2020-05-02 20:07:19 +03:00
parent ce57bf069c
commit c4c904ddb4
2 changed files with 28 additions and 5 deletions

View File

@@ -39,8 +39,7 @@ namespace PomoTime
/// Invoked when the application is launched normally by the end user. Other entry points /// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file. /// will be used such as when the application is launched to open a specific file.
/// </summary> /// </summary>
/// <param name="e">Details about the launch request and process.</param> private void OnLaunchedOrActivated(IActivatedEventArgs e)
protected override void OnLaunched(LaunchActivatedEventArgs e)
{ {
Frame rootFrame = Window.Current.Content as Frame; Frame rootFrame = Window.Current.Content as Frame;
@@ -53,7 +52,7 @@ namespace PomoTime
rootFrame.NavigationFailed += OnNavigationFailed; rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated if (e.PreviousExecutionState == ApplicationExecutionState.Terminated
|| e.PreviousExecutionState == ApplicationExecutionState.ClosedByUser) || e.PreviousExecutionState == ApplicationExecutionState.ClosedByUser)
{ {
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
@@ -71,7 +70,7 @@ namespace PomoTime
Window.Current.Content = rootFrame; Window.Current.Content = rootFrame;
} }
if (e.PrelaunchActivated == false) if (e is LaunchActivatedEventArgs && ((LaunchActivatedEventArgs)e).PrelaunchActivated == false)
{ {
if (rootFrame.Content == null) if (rootFrame.Content == null)
{ {
@@ -83,6 +82,30 @@ namespace PomoTime
// Ensure the current window is active // Ensure the current window is active
Window.Current.Activate(); Window.Current.Activate();
} }
if (e is ToastNotificationActivatedEventArgs)
{
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
if (localSettings.Values["MinutesLeft"] != null)
{
RunningState.MinutesLeft = (int)localSettings.Values["MinutesLeft"];
RunningState.SecondsLeft = (int)localSettings.Values["SecondsLeft"];
RunningState.IsRunning = (bool)localSettings.Values["IsRunning"];
RunningState.PreviousShortBreaks = (int)localSettings.Values["PreviousShortBreaks"];
RunningState.CurrentPeriod = (Period)localSettings.Values["CurrentPeriod"];
}
rootFrame.Navigate(typeof(MainPage), RunningState);
Window.Current.Activate();
}
}
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
OnLaunchedOrActivated(e);
}
protected override void OnActivated(IActivatedEventArgs e)
{
OnLaunchedOrActivated(e);
} }
/// <summary> /// <summary>

View File

@@ -9,7 +9,7 @@
<Identity <Identity
Name="44844StepanUsatyuk.PomoTime" Name="44844StepanUsatyuk.PomoTime"
Publisher="CN=D7EE55C2-4D4B-40F8-8EE5-CC4CEBCE2133" Publisher="CN=D7EE55C2-4D4B-40F8-8EE5-CC4CEBCE2133"
Version="1.0.2.0" /> Version="1.0.3.0" />
<mp:PhoneIdentity PhoneProductId="4d8bddac-8ab7-4c19-b3c7-7b5a27b87594" PhonePublisherId="00000000-0000-0000-0000-000000000000"/> <mp:PhoneIdentity PhoneProductId="4d8bddac-8ab7-4c19-b3c7-7b5a27b87594" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>