mirror of
https://github.com/usatiuk/PomoTime.git
synced 2025-10-29 00:47:48 +01:00
v1.0.6.0
fixed bug when clicking on a notification would reset timer if app wasn't suspended before better notifications
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Microsoft.QueryStringDotNET;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -84,6 +85,8 @@ namespace PomoTime
|
|||||||
}
|
}
|
||||||
if (e is ToastNotificationActivatedEventArgs)
|
if (e is ToastNotificationActivatedEventArgs)
|
||||||
{
|
{
|
||||||
|
var toastActivationArgs = e as ToastNotificationActivatedEventArgs;
|
||||||
|
|
||||||
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
|
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
|
||||||
if (localSettings.Values["MinutesLeft"] != null)
|
if (localSettings.Values["MinutesLeft"] != null)
|
||||||
{
|
{
|
||||||
@@ -94,6 +97,22 @@ namespace PomoTime
|
|||||||
RunningState.CurrentPeriod = (Period)localSettings.Values["CurrentPeriod"];
|
RunningState.CurrentPeriod = (Period)localSettings.Values["CurrentPeriod"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QueryString args = QueryString.Parse(toastActivationArgs.Argument);
|
||||||
|
if (args.Contains("action"))
|
||||||
|
{
|
||||||
|
localSettings.Values["SuspendTime"] = (DateTime.Now + new TimeSpan(1, 0, 0)).Ticks;
|
||||||
|
switch (args["action"])
|
||||||
|
{
|
||||||
|
case "continue":
|
||||||
|
RunningState.IsRunning = true;
|
||||||
|
break;
|
||||||
|
case "5minutes":
|
||||||
|
RunningState.MinutesLeft += 5;
|
||||||
|
RunningState.IsRunning = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rootFrame.Navigate(typeof(MainPage), RunningState);
|
rootFrame.Navigate(typeof(MainPage), RunningState);
|
||||||
Window.Current.Activate();
|
Window.Current.Activate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ namespace PomoTime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_Tick()
|
void TimerTick()
|
||||||
{
|
{
|
||||||
if (!MainViewRunningState.IsRunning)
|
if (!MainViewRunningState.IsRunning)
|
||||||
{
|
{
|
||||||
@@ -167,25 +167,12 @@ namespace PomoTime
|
|||||||
{
|
{
|
||||||
MainViewRunningState.SecondsLeft--;
|
MainViewRunningState.SecondsLeft--;
|
||||||
}
|
}
|
||||||
|
SaveLocalState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SchedulePeriodOverNotification()
|
void SchedulePeriodOverNotification()
|
||||||
{
|
{
|
||||||
string header;
|
string header = $"{MainViewRunningState.CurrentPeriod.Name()} is over!";
|
||||||
switch (MainViewRunningState.CurrentPeriod)
|
|
||||||
{
|
|
||||||
case Period.LongBreak:
|
|
||||||
header = "Long break time over!";
|
|
||||||
break;
|
|
||||||
case Period.ShortBreak:
|
|
||||||
header = "Short break time over!";
|
|
||||||
break;
|
|
||||||
case Period.Work:
|
|
||||||
header = "Work time over!";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException();
|
|
||||||
}
|
|
||||||
ToastVisual visual = new ToastVisual()
|
ToastVisual visual = new ToastVisual()
|
||||||
{
|
{
|
||||||
BindingGeneric = new ToastBindingGeneric()
|
BindingGeneric = new ToastBindingGeneric()
|
||||||
@@ -206,9 +193,27 @@ namespace PomoTime
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ToastActionsCustom actions = new ToastActionsCustom()
|
||||||
|
{
|
||||||
|
Buttons =
|
||||||
|
{
|
||||||
|
new ToastButton("Continue", "action=continue")
|
||||||
|
{
|
||||||
|
ActivationType = ToastActivationType.Foreground
|
||||||
|
},
|
||||||
|
|
||||||
|
new ToastButton("Add 5 minutes", "action=5minutes")
|
||||||
|
{
|
||||||
|
ActivationType = ToastActivationType.Foreground
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ToastContent toastContent = new ToastContent()
|
ToastContent toastContent = new ToastContent()
|
||||||
{
|
{
|
||||||
Visual = visual,
|
Visual = visual,
|
||||||
|
Actions = actions,
|
||||||
|
Scenario = ToastScenario.Alarm,
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeSpan WaitTime = new TimeSpan(0, MainViewRunningState.MinutesLeft, MainViewRunningState.SecondsLeft);
|
TimeSpan WaitTime = new TimeSpan(0, MainViewRunningState.MinutesLeft, MainViewRunningState.SecondsLeft);
|
||||||
@@ -231,6 +236,8 @@ namespace PomoTime
|
|||||||
{
|
{
|
||||||
AppBarButton b = sender as AppBarButton;
|
AppBarButton b = sender as AppBarButton;
|
||||||
MainViewRunningState.IsRunning = true;
|
MainViewRunningState.IsRunning = true;
|
||||||
|
MainViewRunningState.StartTime = DateTime.Now;
|
||||||
|
SaveLocalState();
|
||||||
|
|
||||||
if (MainViewRunningState.MinutesLeft != 0 || MainViewRunningState.SecondsLeft != 0)
|
if (MainViewRunningState.MinutesLeft != 0 || MainViewRunningState.SecondsLeft != 0)
|
||||||
{
|
{
|
||||||
@@ -291,21 +298,31 @@ namespace PomoTime
|
|||||||
minutes["LongBreakMinutes"] = LongBreakMinutes;
|
minutes["LongBreakMinutes"] = LongBreakMinutes;
|
||||||
roamingSettings.Values["Minutes"] = minutes;
|
roamingSettings.Values["Minutes"] = minutes;
|
||||||
|
|
||||||
|
SaveLocalState();
|
||||||
|
|
||||||
|
deferral.Complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveLocalState()
|
||||||
|
{
|
||||||
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
|
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
|
||||||
SuspendTime = DateTime.Now;
|
SuspendTime = DateTime.Now;
|
||||||
localSettings.Values["SuspendTime"] = SuspendTime.Ticks;
|
localSettings.Values["SuspendTime"] = SuspendTime.Ticks;
|
||||||
|
localSettings.Values["StartTime"] = MainViewRunningState.StartTime.Ticks;
|
||||||
localSettings.Values["MinutesLeft"] = MainViewRunningState.MinutesLeft;
|
localSettings.Values["MinutesLeft"] = MainViewRunningState.MinutesLeft;
|
||||||
localSettings.Values["SecondsLeft"] = MainViewRunningState.SecondsLeft;
|
localSettings.Values["SecondsLeft"] = MainViewRunningState.SecondsLeft;
|
||||||
localSettings.Values["IsRunning"] = MainViewRunningState.IsRunning;
|
localSettings.Values["IsRunning"] = MainViewRunningState.IsRunning;
|
||||||
localSettings.Values["PreviousShortBreaks"] = MainViewRunningState.PreviousShortBreaks;
|
localSettings.Values["PreviousShortBreaks"] = MainViewRunningState.PreviousShortBreaks;
|
||||||
localSettings.Values["CurrentPeriod"] = (int)MainViewRunningState.CurrentPeriod;
|
localSettings.Values["CurrentPeriod"] = (int)MainViewRunningState.CurrentPeriod;
|
||||||
|
|
||||||
deferral.Complete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FastForwardTime(DateTime since)
|
private void FastForwardTime(DateTime since)
|
||||||
{
|
{
|
||||||
TimeSpan TimeFromSuspend = DateTime.Now - since;
|
TimeSpan TimeFromSuspend = DateTime.Now - since;
|
||||||
|
if(TimeFromSuspend.TotalMilliseconds < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!MainViewRunningState.IsRunning)
|
if (!MainViewRunningState.IsRunning)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -349,7 +366,7 @@ namespace PomoTime
|
|||||||
await Dispatcher.RunAsync(CoreDispatcherPriority.High,
|
await Dispatcher.RunAsync(CoreDispatcherPriority.High,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
timer_Tick();
|
TimerTick();
|
||||||
});
|
});
|
||||||
}, TimeSpan.FromSeconds(1));
|
}, TimeSpan.FromSeconds(1));
|
||||||
}
|
}
|
||||||
@@ -375,6 +392,7 @@ namespace PomoTime
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
|
SaveLocalState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.5.0" />
|
Version="1.0.6.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"/>
|
||||||
|
|
||||||
|
|||||||
@@ -19,24 +19,7 @@ namespace PomoTime
|
|||||||
{
|
{
|
||||||
// The value parameter is the data from the source object.
|
// The value parameter is the data from the source object.
|
||||||
Period period = (Period)value;
|
Period period = (Period)value;
|
||||||
string output;
|
return period.Name();
|
||||||
switch (period)
|
|
||||||
{
|
|
||||||
case Period.LongBreak:
|
|
||||||
output = "Long break";
|
|
||||||
break;
|
|
||||||
case Period.ShortBreak:
|
|
||||||
output = "Short break";
|
|
||||||
break;
|
|
||||||
case Period.Work:
|
|
||||||
output = "Work";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the month value to pass to the target.
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertBack is not implemented for a OneWay binding.
|
// ConvertBack is not implemented for a OneWay binding.
|
||||||
|
|||||||
@@ -222,6 +222,9 @@
|
|||||||
<PackageReference Include="Microsoft.UI.Xaml">
|
<PackageReference Include="Microsoft.UI.Xaml">
|
||||||
<Version>2.3.200213001</Version>
|
<Version>2.3.200213001</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="QueryString.NET">
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||||
|
|||||||
@@ -8,6 +8,29 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace PomoTime
|
namespace PomoTime
|
||||||
{
|
{
|
||||||
|
public static class PeriodExtensions
|
||||||
|
{
|
||||||
|
public static string Name(this Period period)
|
||||||
|
{
|
||||||
|
string output;
|
||||||
|
switch (period)
|
||||||
|
{
|
||||||
|
case Period.LongBreak:
|
||||||
|
output = "Long break";
|
||||||
|
break;
|
||||||
|
case Period.ShortBreak:
|
||||||
|
output = "Short break";
|
||||||
|
break;
|
||||||
|
case Period.Work:
|
||||||
|
output = "Work";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
public enum Period
|
public enum Period
|
||||||
{
|
{
|
||||||
Work, ShortBreak, LongBreak
|
Work, ShortBreak, LongBreak
|
||||||
@@ -69,6 +92,18 @@ namespace PomoTime
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DateTime _start_time;
|
||||||
|
|
||||||
|
public DateTime StartTime
|
||||||
|
{
|
||||||
|
get { return _start_time; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_start_time = value;
|
||||||
|
NotifyPropertyChanged("StartTime");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int _previous_short_breaks;
|
public int _previous_short_breaks;
|
||||||
|
|
||||||
public int PreviousShortBreaks
|
public int PreviousShortBreaks
|
||||||
@@ -80,6 +115,11 @@ namespace PomoTime
|
|||||||
NotifyPropertyChanged("PreviousShortBreaks");
|
NotifyPropertyChanged("PreviousShortBreaks");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string CurrentPeriodName()
|
||||||
|
{
|
||||||
|
return CurrentPeriod.Name();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user