Skip to content

Commit 36153f8

Browse files
committed
some debug
1 parent 9d769aa commit 36153f8

File tree

3 files changed

+58
-42
lines changed

3 files changed

+58
-42
lines changed

Denna/Core/Service/Notifications/BackgroundService.cs

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public BackgroundService()
1919
{
2020
_service = new TodoService();
2121
}
22+
public BackgroundService(TodoService service)
23+
{
24+
_service = service;
25+
}
2226
public async void GenerateQuickAction()
2327
{
2428

@@ -50,30 +54,38 @@ public async void GenerateQuickAction()
5054

5155
public async void GenerateLiveTile()
5256
{
53-
var tasks = _service.GetMustDoList();
54-
if (tasks.Count == 0)
55-
return;
56-
var counter = tasks.Count;
57-
58-
59-
var xmlDoc = new XmlDocument();
60-
xmlDoc.LoadXml(await FileIO.ReadTextAsync(await StorageFile.GetFileFromApplicationUriAsync(
61-
new Uri("ms-appx:///XMLs/LiveTile.xml"))));
62-
Random rnd = new Random();
63-
int r = rnd.Next(tasks.Count);
64-
xmlDoc.LoadXml(xmlDoc.GetXml().Replace("TaskName", tasks[r].Subject));
65-
xmlDoc.LoadXml(xmlDoc.GetXml().Replace("Detail", tasks[r].Detail));
66-
xmlDoc.LoadXml(xmlDoc.GetXml().Replace("Time", Convert(tasks[r].StartTime)));
67-
xmlDoc.LoadXml(xmlDoc.GetXml().Replace("Date", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Month) + " " + DateTime.Now.Day));
68-
var tup = TileUpdateManager.CreateTileUpdaterForApplication();
6957
try
7058
{
71-
tup.Update(new TileNotification(xmlDoc));
59+
var tasks = _service.GetMustDoList();
60+
if (tasks.Count == 0)
61+
return;
62+
var counter = tasks.Count;
63+
64+
65+
var xmlDoc = new XmlDocument();
66+
xmlDoc.LoadXml(await FileIO.ReadTextAsync(await StorageFile.GetFileFromApplicationUriAsync(
67+
new Uri("ms-appx:///XMLs/LiveTile.xml"))));
68+
Random rnd = new Random();
69+
int r = rnd.Next(tasks.Count);
70+
xmlDoc.LoadXml(xmlDoc.GetXml().Replace("TaskName", tasks[r].Subject));
71+
xmlDoc.LoadXml(xmlDoc.GetXml().Replace("Detail", tasks[r].Detail));
72+
xmlDoc.LoadXml(xmlDoc.GetXml().Replace("Time", Convert(tasks[r].StartTime)));
73+
xmlDoc.LoadXml(xmlDoc.GetXml().Replace("Date", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Month) + " " + DateTime.Now.Day));
74+
var tup = TileUpdateManager.CreateTileUpdaterForApplication();
75+
try
76+
{
77+
tup.Update(new TileNotification(xmlDoc));
78+
}
79+
catch (Exception ex)
80+
{
81+
82+
}
7283
}
73-
catch (Exception ex)
84+
catch
7485
{
7586

7687
}
88+
7789

7890
}
7991
string Convert(DateTimeOffset Value)
@@ -101,18 +113,22 @@ string Convert(DateTimeOffset Value)
101113
}
102114
public void UpdateBadge()
103115
{
116+
try
117+
{
118+
var type = BadgeTemplateType.BadgeNumber;
119+
var xml = BadgeUpdateManager.GetTemplateContent(type);
104120

105-
var type = BadgeTemplateType.BadgeNumber;
106-
var xml = BadgeUpdateManager.GetTemplateContent(type);
107-
108-
var elements = xml.GetElementsByTagName("badge");
109-
var element = elements[0] as Windows.Data.Xml.Dom.XmlElement;
110-
var val = _service.GetMustDoList().Count;
111-
element.SetAttribute("value", val.ToString());
121+
var elements = xml.GetElementsByTagName("badge");
122+
var element = elements[0] as Windows.Data.Xml.Dom.XmlElement;
123+
var val = _service.GetMustDoList().Count;
124+
element.SetAttribute("value", val.ToString());
112125

113-
var updator = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
114-
var notification = new BadgeNotification(xml);
115-
updator.Update(notification);
126+
var updator = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
127+
var notification = new BadgeNotification(xml);
128+
updator.Update(notification);
129+
}
130+
catch { }
131+
116132
}
117133

118134
public void UpdateTiles()

Denna/Denna.Services.Background/QuickAction.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Core.Domain;
22
using Core.Service.Notifications;
33
using Core.Todos.Tasks;
4+
using Core.Utils;
45
using System;
56
using System.Collections.Generic;
67
using System.Linq;
@@ -18,8 +19,8 @@ public sealed class QuickAction : IBackgroundTask
1819
BackgroundService _bgService;
1920
public QuickAction()
2021
{
21-
_bgService = new BackgroundService();
2222
_service = new TodoService();
23+
_bgService = new BackgroundService(_service);
2324
}
2425
public void Run(IBackgroundTaskInstance taskInstance)
2526
{
@@ -94,8 +95,16 @@ public void Run(IBackgroundTaskInstance taskInstance)
9495
}
9596
private void Update()
9697
{
98+
9799
_bgService.GenerateLiveTile();
98100
_bgService.UpdateBadge();
101+
if (AppSettings.OpenGet("Showtoast") != null)
102+
{
103+
if (AppSettings.Get<bool>("Showtoast") == true)
104+
{
105+
_bgService.GenerateQuickAction();
106+
}
107+
}
99108
}
100109
private void Task_Completed(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args) => _deferal.Complete();
101110

Denna/Denna/Views/ExtendedSplash.xaml.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public sealed partial class ExtendedSplash : Page
2020
SplashScreen splash; // Variable to hold the splash screen object.
2121
internal bool dismissed = false; // Variable to track splash screen dismissal status.
2222
internal Frame rootFrame;
23-
23+
bool IsLoggedIn = false;
2424
public ExtendedSplash(SplashScreen splashscreen, bool loadState)
2525
{
2626
InitializeComponent();
27-
27+
IsLoggedIn = UserService.IsUserLoggenIn();
2828
// Listen for window resize events to reposition the extended splash screen image accordingly.
2929
// This ensures that the extended splash screen formats properly in response to window resizing.
3030
Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize);
@@ -42,13 +42,6 @@ public ExtendedSplash(SplashScreen splashscreen, bool loadState)
4242
// Create a Frame to act as the navigation context
4343
rootFrame = new Frame();
4444

45-
Diss();
46-
}
47-
48-
async void Diss()
49-
{
50-
await Task.Delay(500);
51-
DismissExtendedSplash();
5245
}
5346

5447
void ExtendedSplash_OnResize(object sender, WindowSizeChangedEventArgs e)
@@ -66,7 +59,7 @@ void DismissedEventHandler(SplashScreen sender, object e)
6659

6760
void DismissExtendedSplash()
6861
{
69-
if (UserService.IsUserLoggenIn())
62+
if (IsLoggedIn)
7063
rootFrame.Navigate(typeof(PageMaster));
7164
else
7265
rootFrame.Navigate(typeof(Welcome));
@@ -83,8 +76,6 @@ async void RestoreStateAsync(bool loadState)
8376
}
8477
}
8578

86-
void Media_MediaEnded(object sender, RoutedEventArgs e)
87-
{
88-
}
79+
void Media_MediaEnded(object sender, RoutedEventArgs e) => DismissExtendedSplash();
8980
}
9081
}

0 commit comments

Comments
 (0)