Commit 15e980a4 authored by Margaux Clerc's avatar Margaux Clerc
Browse files

Fix ui problems

Add delete chats room
Rework config file installation
Fix toast when receiving chat notifications
parent 83f224a8
......@@ -41,7 +41,7 @@ namespace Linphone
public App()
{
this.InitializeComponent();
//SettingsManager.InstallConfigFile();
SettingsManager.InstallConfigFile();
this.Suspending += OnSuspending;
}
......@@ -111,8 +111,7 @@ namespace Linphone
this.DebugSettings.EnableFrameRateCounter = false;
}
#endif
//Start linphone
//Start linphone
var currentView = SystemNavigationManager.GetForCurrentView();
currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
......@@ -153,6 +152,44 @@ namespace Linphone
Window.Current.Activate();
}
protected override void OnActivated(IActivatedEventArgs args)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content
if (rootFrame == null)
{
// Create a Frame to act as the navigation context
rootFrame = new Frame();
//rootFrame.NavigationFailed += OnNavigationFailed;
//if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
// {
//TODO: Load state from previously suspended application
// }
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if(args.Kind == ActivationKind.ToastNotification)
{
//Get the pre-defined arguments and user inputs from the eventargs;
var toastArgs = args as ToastNotificationActivatedEventArgs;
var arguments = toastArgs.Argument;
if(arguments.StartsWith("chat"))
{
var sipAddrr = arguments.Split('=')[1];
rootFrame.Navigate(typeof(Views.Chat), sipAddrr);
} else
{
rootFrame.Navigate(typeof(Views.IncomingCall), arguments);
}
Window.Current.Activate();
}
}
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
......
......@@ -19,4 +19,4 @@ display=1
size=qvga
[proxy_default_values]
reg_expires=28800
reg_expires=28800
\ No newline at end of file
......@@ -38,12 +38,15 @@
Grid.Row="1"
Orientation="Horizontal"
HorizontalAlignment="Right">
<Image
x:Name="Status"
Source="/Assets/AppBar/next.png"
Height="15"
Stretch="Uniform"/>
<FontIcon
x:Name="Status"
Foreground="White"
FontFamily="Segoe MDL2 Assets"
Glyph="&#xE72A;"
FontSize="10"
Margin="0,0,3,0"/>
<TextBlock
x:Name="Timestamp"
Style="{StaticResource TimestampStyle}"
......
......@@ -22,7 +22,7 @@ using Windows.UI.Xaml.Controls;
namespace Linphone.Controls
{
public partial class OutgoingChatBubble : UserControl
public partial class OutgoingChatBubble : UserControl, ChatMessageListener
{
private ChatMessage _message;
......@@ -75,16 +75,16 @@ namespace Linphone.Controls
public void UpdateStatus(ChatMessageState state)
{
//string delivered = "/Assets/AppBar/check.png";
//string notdelivered = "/Assets/AppBar/stop.png";
if (state == ChatMessageState.InProgress)
{
// Status.Source = new BitmapImage(new Uri(delivered, UriKind.RelativeOrAbsolute));
Status.Glyph = "\uE72A";
}
else if (state == ChatMessageState.NotDelivered)
{
// Status.Source = new BitmapImage(new Uri(notdelivered, UriKind.RelativeOrAbsolute));
Status.Glyph = "\uE711";
} else
{
Status.Visibility = Visibility.Collapsed;
}
}
......@@ -107,6 +107,10 @@ namespace Linphone.Controls
// MessageBox.Show(result ? AppResources.FileSavingSuccess : AppResources.FileSavingFailure, AppResources.FileSaving, MessageBoxButton.OK);
}
public void MessageStateChanged(ChatMessage message, ChatMessageState state)
{
}
public delegate void MessageDeletedEventHandler(object sender, ChatMessage message);
public event MessageDeletedEventHandler MessageDeleted;
......
......@@ -5,8 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:linphone="using:Linphone.Controls"
xmlns:controls="Linphone.Controls"
mc:Ignorable="d"
d:DesignHeight="150" d:DesignWidth="420">
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
......@@ -44,6 +43,7 @@
x:Uid="ChatMessageHint"
TextAlignment="Left"
TextWrapping="Wrap"
MaxHeight="80"
AcceptsReturn="True"
BorderThickness="0"
Grid.Column="1"/>
......
......@@ -37,9 +37,7 @@ namespace Linphone.Controls
public TextBoxChatBubble()
{
InitializeComponent();
SendMessage.IsEnabled = true;
Message.Text = "./flexisip_pusher --pntype wp --appid db5.notify.windows.com --key XUKRFi6vmn0hhuESdAAvx5i --sid ms-app://s-1-15-2-1651060753-3098445494-746237450-1823971881-1920600302-2358223438-102324794 --pntok " + LinphoneManager.Instance.Core.DefaultProxyConfig.ContactUriParameters;
InitializeComponent(); SendMessage.IsEnabled = true;
}
public void Reset()
......
......@@ -37,6 +37,8 @@ namespace Linphone.Model
private static LinphoneManager _instance = new LinphoneManager();
public static LinphoneManager Instance { get { return _instance; } }
private String filePath;
public delegate void ChangedEventHandler(object sender, EventArgs e);
public delegate void CallStateChangedEventHandler(Call call, CallState state);
......@@ -100,7 +102,14 @@ namespace Linphone.Model
public String GetConfigPath()
{
return Path.Combine(ApplicationData.Current.LocalFolder.Path, "linphonerc");
FileInfo fInfo = new FileInfo(Path.Combine(ApplicationData.Current.LocalFolder.Path, "linphonerc"));
if(fInfo.Exists)
{
return Path.Combine(ApplicationData.Current.LocalFolder.Path, "linphonerc");
} else
{
return null;
}
}
public String GetFactoryConfigPath()
......@@ -148,14 +157,14 @@ namespace Linphone.Model
if (host == null || token == null)
{
Debug.WriteLine("no push channel uri");
return;
}
if (Core.DefaultProxyConfig != null)
{
Core.DefaultProxyConfig.Edit();
Core.DefaultProxyConfig.ContactUriParameters = "app-id=" + host + ";pn-type=wp;pn-tok=" + token;
Core.DefaultProxyConfig.ContactUriParameters = "app-id=" + host + ";pn-type=w10;pn-tok=" + token;
Debug.WriteLine(Core.DefaultProxyConfig.ContactUriParameters);
Core.DefaultProxyConfig.Done();
}
}
......
......@@ -19,9 +19,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.IsolatedStorage;
using System.Threading;
using System.Threading.Tasks;
using Windows.ApplicationModel.Resources;
using Windows.Storage;
......@@ -64,15 +61,20 @@ namespace Linphone.Model
/// <summary>
/// Install the default config file from the package to the Isolated Storage
/// </summary>
public static void InstallConfigFile()
public static async void InstallConfigFile()
{
FileInfo fInfo = new FileInfo(LinphoneManager.Instance.GetConfigPath());
FileInfo fInfo = new FileInfo(Path.Combine(ApplicationData.Current.LocalFolder.Path, "linphonerc"));
if (!fInfo.Exists)
{
fInfo = new FileInfo(LinphoneManager.Instance.GetDefaultConfigPath());
if(fInfo.Exists)
try
{
StorageFile file1 = await StorageFile.GetFileFromPathAsync(Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "Assets", "linphonerc"));
await file1.CopyAsync(ApplicationData.Current.LocalFolder, "linphonerc");
}
catch (Exception e)
{
fInfo.MoveTo(LinphoneManager.Instance.GetConfigPath());
Debug.WriteLine(e.Message);
}
}
}
......@@ -163,7 +165,7 @@ namespace Linphone.Model
{
if (LinphoneManager.Instance.Core == null)
{
// Config = new LpConfig(InitManager.GetConfigPath(), InitManager.GetFactoryConfigPath());
Config = new LpConfig(LinphoneManager.Instance.GetConfigPath(), LinphoneManager.Instance.GetFactoryConfigPath());
}
else
{
......
......@@ -131,7 +131,7 @@
<data name="AboutMenu" xml:space="preserve">
<value>About</value>
</data>
<data name="CancelChanges" xml:space="preserve">
<data name="Cancel.Label" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="DebugSetting.Header" xml:space="preserve">
......@@ -149,8 +149,8 @@
<data name="SettingsMenu.Text" xml:space="preserve">
<value>SETTINGS</value>
</data>
<data name="DeleteSelectionMenu" xml:space="preserve">
<value>Delete Selection</value>
<data name="Delete.Label" xml:space="preserve">
<value>Delete</value>
</data>
<data name="AddressHint.PlaceholderText" xml:space="preserve">
<value>Number or address</value>
......@@ -724,4 +724,13 @@ To enjoy the best experience with Linphone WP8, we recommend that you use the SI
<data name="Dismiss" xml:space="preserve">
<value>Dismiss</value>
</data>
<data name="EmptyChat.Text" xml:space="preserve">
<value>No conversations</value>
</data>
<data name="EmptyHistory.Text" xml:space="preserve">
<value>No call in your history</value>
</data>
<data name="SelectItem.Label" xml:space="preserve">
<value>Select</value>
</data>
</root>
\ No newline at end of file
......@@ -63,9 +63,9 @@
<ScrollViewer x:Name="MessagesScroll">
<StackPanel
x:Name="MessagesList"
Orientation="Vertical"
VerticalAlignment="Bottom"/>
x:Name="MessagesList"
Orientation="Vertical"
VerticalAlignment="Bottom"/>
</ScrollViewer>
<TextBlock x:Name="RemoteComposing" Grid.Row="1" Visibility="Collapsed"/>
......
......@@ -26,7 +26,6 @@ using Windows.UI.Xaml.Navigation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Core;
using Windows.UI.Popups;
namespace Linphone.Views
{
......@@ -182,7 +181,6 @@ namespace Linphone.Views
public void MessageStateChanged(ChatMessage message, ChatMessageState state)
{
if (LinphoneManager.Instance.CoreDispatcher == null) return;
#pragma warning disable CS4014 // Dans la mesure où cet appel n'est pas attendu, l'exécution de la méthode actuelle continue avant la fin de l'appel
LinphoneManager.Instance.CoreDispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
......@@ -191,7 +189,7 @@ namespace Linphone.Views
{
ProgressPopup.Visibility = Visibility.Collapsed;
MessageBox.Visibility = Visibility.Visible;
}
}
if (state == ChatMessageState.InProgress)
{
......@@ -206,7 +204,7 @@ namespace Linphone.Views
try
{
message.AppData = message.FileTransferFilepath;
IncomingChatBubble bubble = (IncomingChatBubble)MessagesList.Children.Where(b => message.Equals(((IncomingChatBubble)b).ChatMessage)).Last();
IncomingChatBubble bubble = (IncomingChatBubble)MessagesList.Children.Where(b => message.Equals(((IncomingChatBubble)b).ChatMessage)).Last();
if (bubble != null)
{
((IncomingChatBubble)bubble).RefreshImage();
......@@ -220,14 +218,16 @@ namespace Linphone.Views
// Update the outgoing status of the message
try
{
OutgoingChatBubble bubble = (OutgoingChatBubble)MessagesList.Children.Where(b => message.Equals(((OutgoingChatBubble)b).ChatMessage)).Last();
if (bubble != null)
{
((OutgoingChatBubble)bubble).UpdateStatus(state);
}
foreach (OutgoingChatBubble bubble in MessagesList.Children.OfType<OutgoingChatBubble>())
{
if(bubble.ChatMessage.Equals(message))
{
bubble.UpdateStatus(state);
}
}
}
catch { }
}
catch { }
}
if (chatRoom != null)
{
......@@ -268,7 +268,6 @@ namespace Linphone.Views
{
if (MessageBox.Text != null && MessageBox.Text.Length > 0)
{
Debug.WriteLine(MessageBox.Text);
SendMessage(MessageBox.Text);
}
else if (MessageBox.ImageName != null && MessageBox.ImageLocalPath != null)
......
......@@ -17,6 +17,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="12,12,12,0">
......@@ -24,8 +25,15 @@
</StackPanel>
<Grid x:Name="ContentPanel" Grid.Row="1">
<ListView Grid.Row="0" x:Name="Conversations" ItemsSource="{Binding ChatList}"
IsHoldingEnabled="True" Holding="Conversations_Holding"
<TextBlock
x:Name="EmptyText"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Visibility="Collapsed"
x:Uid="EmptyChat"/>
<ListView Grid.Row="0" x:Name="Conversations" ItemsSource="{Binding ChatList}"
SelectionMode="None"
IsItemClickEnabled="True" ItemClick="Conversations_ItemClick">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
......@@ -34,7 +42,7 @@
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate >
<Grid Tapped="conversation_Click_1" Margin="0,10,0,0">
<Grid Margin="0,5,0,5" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
......@@ -61,8 +69,15 @@
</ListView>
</Grid>
<CommandBar Grid.Row="1" VerticalAlignment="Bottom">
<AppBarButton Icon="Add" Label="New" x:Uid="New" Click="newChat_Click_1"/>
<CommandBar Grid.Row="2" VerticalAlignment="Bottom">
<AppBarButton x:Name="SelectItems" FontFamily="OverflowCheckGlyph" x:Uid="SelectItem" Label="Select Items" Click="SelectItmesBtn_Click">
<AppBarButton.Icon>
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xe762;" />
</AppBarButton.Icon>
</AppBarButton>
<AppBarButton Label="Delete" Icon="Delete" x:Uid="Delete" Click="DeleteItem_Click" x:Name="DeleteItem" />
<AppBarButton Label="Cancel" Icon="Cancel" x:Uid="Cancel" Click="Cancel_Click" x:Name="CancelBtn"/>
<AppBarButton Icon="Add" Label="New" x:Uid="New" Click="newChat_Click_1" x:Name="NewConversation"/>
</CommandBar>
</Grid>
......
......@@ -19,11 +19,10 @@ using Linphone.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;
namespace Linphone.Views
......@@ -44,21 +43,23 @@ namespace Linphone.Views
}
}
/// <summary>
/// Public constructor.
/// </summary>
public Chats()
// :base(new ChatsModel())
{
_conversations = new ObservableCollection<Conversation>();
_sortedConversations = new ObservableCollection<Conversation>();
this.InitializeComponent();
SetCommandsVisibility(Conversations);
Conversations.SelectionChanged += OnSelectionChanged;
}
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
/// <summary>
/// Method called when the page is displayed.
/// Fetches the conversations from the LinphoneManager and displays them.
/// </summary>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
/*ContactManager cm = ContactManager.Instance;
......@@ -68,15 +69,12 @@ namespace Linphone.Views
*/
LinphoneManager.Instance.MessageReceived += MessageReceived;
GetMessagesAndDisplayConversationsList();
Conversations.ItemsSource = _conversations;
base.OnNavigatedTo(e);
}
/// <summary>
/// Method called when the page is hidden.
/// </summary>
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
/* ContactManager cm = ContactManager.Instance;
......@@ -87,7 +85,7 @@ namespace Linphone.Views
private void MessageReceived(object sender, EventArgs e)
{
//GetMessagesAndDisplayConversationsList();
GetMessagesAndDisplayConversationsList();
}
/// <summary>
......@@ -146,12 +144,26 @@ namespace Linphone.Views
}
}
if(_conversations.Count() == 0)
{
EmptyText.Visibility = Visibility.Visible;
Conversations.Visibility = Visibility.Collapsed;
SelectItems.IsEnabled = false;
} else
{
EmptyText.Visibility = Visibility.Collapsed;
Conversations.Visibility = Visibility.Visible;
SelectItems.IsEnabled = true;
}
_sortedConversations = new ObservableCollection<Conversation>();
foreach (var i in _conversations.OrderByDescending(g => g.Messages.Last().Time).ToList())
{
_sortedConversations.Add(i);
}
// ((ChatsModel)ViewModel).Conversations = _sortedConversations;*/
// ((ChatsModel)ViewModel).Conversations = _sortedConversations;*/
SetCommandsVisibility(Conversations);
}
private void Delete_Click(object sender, RoutedEventArgs e)
......@@ -164,19 +176,6 @@ namespace Linphone.Views
}*/
}
private void deleteSelection_Click_1(object sender, EventArgs e)
{
/* foreach (var c in _selection)
{
LinphoneManager.Instance.LinphoneCore.GetChatRoomFromUri(c.SipAddress).DeleteHistory();
}
GetMessagesAndDisplayConversationsList();
ClearApplicationBar();
SetupAppBarForEmptySelection();*/
}
private void newChat_Click_1(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(Views.Chat), null);
......@@ -187,75 +186,69 @@ namespace Linphone.Views
if (Frame.CanGoBack)
{
Frame.GoBack();
} else
{
if (Frame.BackStack.Count == 0)
{
Frame.Navigate(typeof(Views.Dialer), null);
}
}
}
/* private void SetupAppBarForEmptySelection()
{
Del
appBarNewChatSelection.Click += newChat_Click_1;
_usingSelectionAppBar = false;
}
private void SetupAppBarForSelectedItems()
{
ApplicationBarIconButton appBarDeleteSelection = new ApplicationBarIconButton(new Uri("/Assets/AppBar/delete.png", UriKind.Relative));
appBarDeleteSelection.Text = AppResources.DeleteSelectionMenu;
ApplicationBar.Buttons.Add(appBarDeleteSelection);
appBarDeleteSelection.Click += deleteSelection_Click_1;
_usingSelectionAppBar = true;
}
private void conversations_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
LongListMultiSelector list = (LongListMultiSelector)sender;
if (list.SelectedItems.Count == 0)
{
ClearApplicationBar();
SetupAppBarForEmptySelection();
}
else if (list.SelectedItems.Count >= 1 && !_usingSelectionAppBar) // Do it only once, when selection was empty and isn't anymore
{
_selection = list.SelectedItems.Cast<Conversation>();
ClearApplicationBar();
SetupAppBarForSelectedItems();
}
}*/
private void SelectItmesBtn_Click(object sender, RoutedEventArgs e)
{
Conversations.SelectionMode = ListViewSelectionMode.Multiple;
SetCommandsVisibility(Conversations);
}
private void conversation_Click_1(object sender, RoutedEventArgs e)
{
Conversation chat = ((sender as StackPanel).Tag as Conversation);
if (chat != null)
private void SetCommandsVisibility(ListView listView)
{
if (listView.SelectionMode == ListViewSelectionMode.Multiple || listView.SelectedItems.Count > 1)
{
Frame.Navigate(typeof(Views.Chat), chat.SipAddress);
SelectItems.Visibility = Visibility.Collapsed;
CancelBtn.Visibility = Visibility.Visible;
NewConversation.Visibility = Visibility.Collapsed;
DeleteItem.Visibility = Visibility.Visible;
}
}
else
{
SelectItems.Visibility = Visibility.Visible;
CancelBtn.Visibility = Visibility.Collapsed;
NewConversation.Visibility = Visibility.Visible;
DeleteItem.Visibility = Visibility.Collapsed;
}
}
private void Conversations_Holding(object sender, Windows.UI.Xaml.Input.HoldingRoutedEventArgs e)
private void DeleteItem_Click(object sender, RoutedEventArgs e)
{
List<Conversation> _selectItem = new List<Conversation>();
foreach (Conversation item in Conversations.SelectedItems)
{
_selectItem.Add(item);
}
foreach (Conversation item in _selectItem)
{
LinphoneManager.Instance.Core.GetChatRoomFromUri(item.SipAddress).DeleteHistory();
}