Commit a0a6a19b authored by Sylvain Berfini's avatar Sylvain Berfini

New tile + fix for native mesage callback

parent 6203419f
......@@ -50,7 +50,6 @@ namespace Linphone.Agents
{
Debug.WriteLine("[IncomingCallAgent] Incoming call processing is now complete.");
BackgroundManager.Instance.OopServer.CallController.IncomingCallViewDismissed = null;
TileManager.Instance.UpdateTileWithMissedCalls(BackgroundManager.Instance.OopServer.LinphoneCore.GetMissedCallsCount());
base.NotifyComplete();
}
......
......@@ -36,23 +36,26 @@ namespace Linphone.Agents
}
/// <summary>
/// Displays the number of missed call on the live tile and on the lock screen
/// Displays the number of missed call and unread messages on the live tile and on the lock screen
/// </summary>
/// <param name="missedCalls">Number of missed calls</param>
public void UpdateTileWithMissedCalls(int missedCalls)
/// <param name="missedCalls">Number of missed calls + number of unread messages</param>
public void UpdateTileWithMissedCallsAndUnreadMessages(int count)
{
ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault();
var data = new StandardTileData();
data.Count = missedCalls;
tile.Update(data);
if (tile != null)
{
var data = new IconicTileData();
data.Count = count;
tile.Update(data);
}
}
/// <summary>
/// Delete the missed call display from the live tile and the lock screen
/// </summary>
public void RemoveMissedCallsTile()
public void RemoveCountOnTile()
{
UpdateTileWithMissedCalls(0);
UpdateTileWithMissedCallsAndUnreadMessages(0);
}
}
}
......@@ -1522,6 +1522,7 @@ void call_stats_updated(LinphoneCore *lc, LinphoneCall *call, const LinphoneCall
void message_received(LinphoneCore *lc, LinphoneChatRoom* chat_room, LinphoneChatMessage* message)
{
Linphone::Core::gApiLock.EnterListener();
Linphone::Core::LinphoneCoreListener^ listener = Linphone::Core::Globals::Instance->LinphoneCore->CoreListener;
if (listener != nullptr)
{
......@@ -1533,6 +1534,7 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom* chat_room, LinphoneCha
listener->MessageReceived(lMessage);
}
Linphone::Core::gApiLock.LeaveListener();
}
Linphone::Core::LinphoneCore::LinphoneCore(LinphoneCoreListener^ coreListener) :
......
......@@ -196,6 +196,8 @@
<Content Include="Assets\linphonerc-factory" />
<Content Include="Assets\rootca.pem" />
<Content Include="Assets\Sounds\toy-mono.wav" />
<Content Include="Assets\tile_logo_large.png" />
<Content Include="Assets\tile_logo_small.png" />
<Content Include="Toolkit.Content\ApplicationBar.Cancel.png" />
<Content Include="Toolkit.Content\ApplicationBar.Check.png" />
<Content Include="Toolkit.Content\ApplicationBar.Delete.png" />
......
......@@ -681,7 +681,8 @@ namespace Linphone.Model
Logger.Msg("[LinphoneManager] Call released");
BaseModel.UIDispatcher.BeginInvoke(() =>
{
TileManager.Instance.UpdateTileWithMissedCalls(LinphoneCore.GetMissedCallsCount());
//Update tile
UpdateLiveTile();
});
}
else if (state == LinphoneCallState.UpdatedByRemote)
......@@ -793,6 +794,9 @@ namespace Linphone.Model
DatabaseManager.Instance.Messages.InsertOnSubmit(msg);
DatabaseManager.Instance.SubmitChanges();
//Update tile
UpdateLiveTile();
//Displays the message as a popup
BaseModel.UIDispatcher.BeginInvoke(() =>
{
......@@ -818,6 +822,16 @@ namespace Linphone.Model
}
#endregion
/// <summary>
/// Updates the app tile to display the number of missed calls and unread chats.
/// </summary>
public void UpdateLiveTile()
{
int missedCalls = LinphoneCore.GetMissedCallsCount();
int unreadChats = (from message in DatabaseManager.Instance.Messages where message.MarkedAsRead == false select message).ToList().Count;
TileManager.Instance.UpdateTileWithMissedCallsAndUnreadMessages(missedCalls + unreadChats);
}
#region Contact Lookup
private ContactManager ContactManager
{
......
......@@ -26,20 +26,25 @@
</Tasks>
<Tokens>
<PrimaryToken TokenID="LinphoneToken" TaskName="_default">
<TemplateFlip>
<SmallImageURI IsRelative="true" IsResource="false">Assets\AppIcon.png</SmallImageURI>
<TemplateIconic>
<SmallImageURI IsRelative="true" IsResource="false">Assets\tile_logo_small.png</SmallImageURI>
<Count>0</Count>
<BackgroundImageURI IsRelative="true" IsResource="false">Assets\AppIcon.png</BackgroundImageURI>
<IconImageURI IsRelative="true" IsResource="false">Assets\tile_logo_large.png</IconImageURI>
<Title>Linphone</Title>
<BackContent>
</BackContent>
<BackBackgroundImageURI>
</BackBackgroundImageURI>
<BackTitle>
</BackTitle>
<DeviceLockImageURI IsRelative="true" IsResource="false">Assets\pnicon.png</DeviceLockImageURI>
<HasLarge>False</HasLarge>
</TemplateFlip>
<Message>
</Message>
<BackgroundColor>
</BackgroundColor>
<HasLarge>True</HasLarge>
<LargeContent1>
</LargeContent1>
<LargeContent2>
</LargeContent2>
<LargeContent3>
</LargeContent3>
<DeviceLockImageURI IsRelative="true" IsResource="false">
</DeviceLockImageURI>
</TemplateIconic>
</PrimaryToken>
</Tokens>
<Extensions>
......
......@@ -134,6 +134,8 @@ namespace Linphone.Views
{
foreach (var message in messages)
{
message.MarkedAsRead = true;
DateTime date = new DateTime(message.Timestamp * TimeSpan.TicksPerSecond);
if (message.IsIncoming)
{
......@@ -158,6 +160,9 @@ namespace Linphone.Views
}
}
scrollToBottom();
DatabaseManager.Instance.SubmitChanges();
LinphoneManager.Instance.UpdateLiveTile();
}
/// <summary>
......
......@@ -124,6 +124,7 @@ namespace Linphone.Views
ClearApplicationBar();
SetupAppBarForEmptySelection();
LinphoneManager.Instance.UpdateLiveTile();
}
private void newChat_Click_1(object sender, EventArgs e)
......
......@@ -42,9 +42,8 @@ namespace Linphone.Views
// Create LinphoneCore if not created yet, otherwise do nothing
await LinphoneManager.Instance.InitLinphoneCore();
TileManager tileManager = TileManager.Instance;
tileManager.RemoveMissedCallsTile();
LinphoneManager.Instance.LinphoneCore.ResetMissedCallsCount();
LinphoneManager.Instance.UpdateLiveTile();
List<CallLog> callsHistory = LinphoneManager.Instance.GetCallsHistory();
Calls.ItemsSource = callsHistory;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment