Skip to content

Commit

Permalink
#36 Added Basic Notification
Browse files Browse the repository at this point in the history
Still uses MPN so it's limited. Plan to switch to WNS so the updates can
be silent.
  • Loading branch information
cpmcgrath committed Apr 20, 2014
1 parent 6248549 commit 975f01d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Bankr.Agent/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public bool Update(Action afterUpdate)

public bool Refresh(DataStoreContext store, Action afterUpdate)
{
var retriever = new DataRetriever { Status = new AppStatus() };
var retriever = new DataRetriever { Status = new AppStatus { UseToast = true } };
retriever.Callback = () =>
{
UpdateLiveTile();
Expand Down
17 changes: 16 additions & 1 deletion Bankr.Logic/Logic/AppStatus.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using System;
using System.Linq;
using Microsoft.Phone.Shell;
using System.Windows.Threading;
using Windows.UI.Notifications;

namespace CMcG.Bankr.Logic
{
public class AppStatus : Data.NotifyBase
{
public bool AutoRemove { get; set; }
public bool IsBusy { get; set; }
public bool UseToast { get; set; }
public string Action { get; set; }

public void FireChanged()
Expand All @@ -32,5 +35,17 @@ public void SetAction(string action, bool isState = false)
};
timer.Start();
}

public void SetImportantAction(string action, string moreDetails, bool isState = false)
{
if (UseToast)
new ShellToast
{
Title = action,
Content = moreDetails
}.Show();

SetAction(action, isState);
}
}
}
}
13 changes: 12 additions & 1 deletion Bankr.Logic/Logic/Queries/GetTransactionsQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Net;
using CMcG.Bankr.Data;
using System.Collections.Generic;
using Windows.UI.Notifications;

namespace CMcG.Bankr.Logic.Queries
{
Expand Down Expand Up @@ -59,7 +60,17 @@ protected override void ProcessResult(string response, bool hasError)
account.TransactionList.Add(transaction);

store.SubmitChanges();
Status.SetAction(transactions.Count() + " new transactions found.", true);
var action = transactions.Length + " new transactions found.";
string more;
if (transactions.Length == 1)
more = string.Format("${0:0.00} {1}", transactions[0].AbsAmount, transactions[0].Summary);
else
{
decimal amount = transactions.Sum(x => x.Amount);
more = string.Format("Totalling ${0:0.00} {1}.", Math.Abs(amount), amount > 0 ? "in" : "out");
}
Status.SetImportantAction(action, more, true);
var template = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
}
}

Expand Down
17 changes: 11 additions & 6 deletions Bankr/Properties/WMAppManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@
<SmallImageURI IsRelative="true" IsResource="false">Images\SmallTile.png</SmallImageURI>
<Count>0</Count>
<IconImageURI IsRelative="true" IsResource="false">Images\Tile.png</IconImageURI>
<Title>Commbank Unofficial</Title>
<Message></Message>
<BackgroundColor></BackgroundColor>
<Title>Bankr</Title>
<Message>
</Message>
<BackgroundColor>
</BackgroundColor>
<HasLarge>True</HasLarge>
<LargeContent1></LargeContent1>
<LargeContent2></LargeContent2>
<LargeContent3></LargeContent3>
<LargeContent1>
</LargeContent1>
<LargeContent2>
</LargeContent2>
<LargeContent3>
</LargeContent3>
<DeviceLockImageURI IsRelative="true" IsResource="false">Images\LockTile.png</DeviceLockImageURI>
</TemplateIconic>
</PrimaryToken>
Expand Down

0 comments on commit 975f01d

Please sign in to comment.