Commit 786fe244 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added contact view (displayed when click on a contact in list)

parent a6fa5f81
No preview for this file type
<UserControl x:Class="Linphone.Controls.ContactAction"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="100" d:DesignWidth="480">
<Grid x:Name="LayoutRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel
Grid.Column="0"
Orientation="Vertical">
<TextBlock
x:Name="label"
FontSize="30"
VerticalAlignment="Center"
HorizontalAlignment="Left"/>
<TextBlock
x:Name="phone"
FontSize="35"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Foreground="{StaticResource PhoneAccentBrush}"/>
</StackPanel>
<Button
Grid.Column="1"
BorderThickness="0"
HorizontalAlignment="Right"
HorizontalContentAlignment="Right"
VerticalAlignment="Center">
<Image
x:Name="action"
Stretch="None"
Margin="5,0,5,0" />
</Button>
</Grid>
</UserControl>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
namespace Linphone.Controls
{
public partial class ContactAction : UserControl
{
private String _action;
public String Action
{
get
{
return _action;
}
set
{
_action = value;
action.Source = new BitmapImage(new Uri(value, UriKind.RelativeOrAbsolute)); ;
}
}
private String _label;
public String Label
{
get
{
return _label;
}
set
{
_label = value;
label.Text = value;
}
}
private String _phone;
public String Phone
{
get
{
return _phone;
}
set
{
_phone = value;
phone.Text = value;
}
}
public ContactAction()
{
InitializeComponent();
}
}
}
......@@ -100,6 +100,9 @@
<Compile Include="Controls\AddressBox.xaml.cs">
<DependentUpon>AddressBox.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ContactAction.xaml.cs">
<DependentUpon>ContactAction.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\Digit.xaml.cs">
<DependentUpon>Digit.xaml</DependentUpon>
</Compile>
......@@ -128,6 +131,9 @@
<Compile Include="Views\CodecsSettings.xaml.cs">
<DependentUpon>CodecsSettings.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Contact.xaml.cs">
<DependentUpon>Contact.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Contacts.xaml.cs">
<DependentUpon>Contacts.xaml</DependentUpon>
</Compile>
......@@ -159,6 +165,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\ContactAction.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\Digit.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......@@ -179,6 +189,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Contact.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Contacts.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
......@@ -37,6 +37,7 @@ namespace Linphone.Model
private List<AlphaKeyGroup<Contact>> _contacts;
private String tempNumberForContactLookup;
public Contact TempContact;
public delegate void ContactFoundEventHandler(object sender, ContactFoundEventArgs e);
public event ContactFoundEventHandler ContactFound;
......@@ -55,11 +56,19 @@ namespace Linphone.Model
(Contact c) => { return c.DisplayName; }, true);
}
/// <summary>
/// Gets a list of contacts ordered alphabetically
/// </summary>
/// <returns>A list of AlphaKeyGroup, where each one contains the contacts starting by the letter represented by the group</returns>
public List<AlphaKeyGroup<Contact>> GetContactsGroupedByLetters()
{
return _contacts;
}
/// <summary>
/// Searches if a there is a contact for whom the phone number is stored
/// </summary>
/// <param name="number">phone number to use to filter the contacts</param>
public void FindContactByNumber(String number)
{
Microsoft.Phone.UserData.Contacts contacts = new Microsoft.Phone.UserData.Contacts();
......
......@@ -26,6 +26,9 @@ namespace Linphone.Model
private List<CallLogs> _history;
private bool BackgroundProcessConnected;
/// <summary>
/// Starts and connects the LinphoneManager to the background process (linphonecore)
/// </summary>
public void ConnectBackgroundProcessToInterface()
{
if (BackgroundProcessConnected)
......@@ -49,6 +52,9 @@ namespace Linphone.Model
Debug.WriteLine("[LinphoneManager] Background process connected to interface");
}
/// <summary>
/// disconnects the LinphoneManager from the background process (linphonecore)
/// </summary>
public void DisconnectBackgroundProcessFromInterface()
{
if (!BackgroundProcessConnected)
......@@ -81,27 +87,6 @@ namespace Linphone.Model
ObservableCollection<CallLog> calls = new ObservableCollection<CallLog>();
ObservableCollection<CallLog> missedCalls = new ObservableCollection<CallLog>();
CallLog logA = new CallLog("sip:cotcot@sip.linphone.org", "sip:miaou@sip.linphone.org", true, false);
CallLog logB = new CallLog("sip:cotcot@sip.linphone.org", "sip:miaou@sip.linphone.org", true, true);
CallLog logC = new CallLog("sip:cotcot@sip.linphone.org", "sip:miaou@sip.linphone.org", false, false);
CallLog logD = new CallLog("sip:cotcot@sip.linphone.org", "sip:miaou@sip.linphone.org", true, true);
CallLog logE = new CallLog("sip:cotcot@sip.linphone.org", "sip:miaou@sip.linphone.org", false, false);
CallLog logF = new CallLog("sip:cotcot@sip.linphone.org", "sip:miaou@sip.linphone.org", false, false);
CallLog logG = new CallLog("sip:cotcot@sip.linphone.org", "sip:miaou@sip.linphone.org", true, true);
CallLog logH = new CallLog("sip:cotcot@sip.linphone.org", "sip:miaou@sip.linphone.org", false, false);
calls.Add(logA);
calls.Add(logB);
calls.Add(logC);
calls.Add(logD);
calls.Add(logE);
calls.Add(logF);
calls.Add(logG);
calls.Add(logH);
missedCalls.Add(logB);
missedCalls.Add(logD);
missedCalls.Add(logG);
CallLogs all = new CallLogs("All", calls);
_history.Add(all);
......
......@@ -26,6 +26,10 @@ namespace Linphone.Model
}
/// <summary>
/// Displays the number of missed call on the live tile and on the lock screen
/// </summary>
/// <param name="missedCalls">Number of missed calls</param>
public void UpdateTileWithMissedCalls(int missedCalls)
{
ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault();
......@@ -34,6 +38,9 @@ namespace Linphone.Model
tile.Update(data);
}
/// <summary>
/// Delete the missed call display from the live tile and the lock screen
/// </summary>
public void RemoveMissedCallsTile()
{
UpdateTileWithMissedCalls(0);
......
......@@ -138,6 +138,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Contact.
/// </summary>
public static string ContactMenu {
get {
return ResourceManager.GetString("ContactMenu", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Contacts.
/// </summary>
......
......@@ -227,4 +227,7 @@ http://www.linphone.org/m/help
<data name="Speaker" xml:space="preserve">
<value>speaker</value>
</data>
<data name="ContactMenu" xml:space="preserve">
<value>Contact</value>
</data>
</root>
\ No newline at end of file
......@@ -26,6 +26,9 @@ namespace Linphone.Views
int i = 0;
string text = resourceManager.GetString("AboutText", CultureInfo.CurrentCulture);
Paragraph paragraph = new Paragraph();
// Parse the text to insert clickable links when a line start with http://
// And replace #version# tag by actual version name
foreach (var line in text.Split('\n'))
{
String textLine = line;
......
......@@ -32,6 +32,7 @@ namespace Linphone.Views
SILK16.IsChecked = _appSettings.SILK16;
GSM.IsChecked = _appSettings.GSM;
}
private void cancel_Click_1(object sender, EventArgs e)
{
NavigationService.GoBack();
......@@ -53,6 +54,7 @@ namespace Linphone.Views
NavigationService.GoBack();
}
private void BuildLocalizedApplicationBar()
{
ApplicationBar = new ApplicationBar();
......
<phone:PhoneApplicationPage
x:Class="Linphone.Views.Contact"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<!--<TextBlock Text="" Style="{StaticResource PhoneTextNormalStyle}"/>-->
<TextBlock x:Name="contactName" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer>
<StackPanel x:Name="actions" Orientation="Vertical" Margin="20,0,0,0">
</StackPanel>
</ScrollViewer>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
using Microsoft.Phone;
using System.IO;
using Microsoft.Phone.UserData;
using Linphone.Model;
using Linphone.Controls;
namespace Linphone.Views
{
public partial class Contact : PhoneApplicationPage
{
private Microsoft.Phone.UserData.Contact contact { get; set; }
public Contact()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
contact = ContactManager.Instance.TempContact;
contactName.Text = contact.DisplayName;
Stream imgStream = contact.GetPicture();
if (imgStream != null)
{
Image contactPicture = new Image();
contactPicture.Width = 150;
contactPicture.Height = 150;
contactPicture.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
contactPicture.Source = PictureDecoder.DecodeJpeg(imgStream);
actions.Children.Add(contactPicture);
}
foreach (ContactPhoneNumber phone in contact.PhoneNumbers)
{
ContactAction entry = new ContactAction();
entry.Action = "/Assets/AppBar/feature.phone.png";
entry.Label = phone.Kind.ToString();
entry.Phone = phone.PhoneNumber;
actions.Children.Add(entry);
}
}
}
}
\ No newline at end of file
......@@ -84,9 +84,9 @@
</phone:LongListSelector.GroupHeaderTemplate>
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0, 5, 0, 5">
<StackPanel Orientation="Horizontal" Margin="0,5,0,5">
<Image Source="{Binding Converter={StaticResource ContactPictureConverter}}" Width="72" Height="72" Stretch="Fill" />
<TextBlock Text="{Binding DisplayName}" FontSize="35" Margin="10, 0, 0, 0"></TextBlock>
<TextBlock Text="{Binding DisplayName}" FontSize="35" Margin="10,0,0,0"></TextBlock>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
......
......@@ -9,6 +9,7 @@ using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.UserData;
using Linphone.Model;
using System.Diagnostics;
namespace Linphone.Views
{
......@@ -23,7 +24,9 @@ namespace Linphone.Views
private void contactsList_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
Contact selectedContact = ((sender as LongListSelector).SelectedItem as Contact);
Microsoft.Phone.UserData.Contact selectedContact = ((sender as LongListSelector).SelectedItem as Microsoft.Phone.UserData.Contact);
ContactManager.Instance.TempContact = selectedContact;
NavigationService.Navigate(new Uri("/Views/Contact.xaml", UriKind.RelativeOrAbsolute));
}
}
}
\ No newline at end of file
......@@ -43,8 +43,11 @@ namespace Linphone
private void NewOutgoingCall(String address)
{
NavigationService.Navigate(new Uri("/Views/InCall.xaml?sip=" + address, UriKind.RelativeOrAbsolute));
LinphoneManager.Instance.NewOutgoingCall(numpad.Address.Text);
if (address != null && address.Length > 0)
{
NavigationService.Navigate(new Uri("/Views/InCall.xaml?sip=" + address, UriKind.RelativeOrAbsolute));
LinphoneManager.Instance.NewOutgoingCall(numpad.Address.Text);
}
}
private void call_Click_1(object sender, EventArgs e)
......
......@@ -35,6 +35,10 @@ namespace Linphone.Views
}
}
/// <summary>
/// Callback called when the search on a phone number for a contact has a match
/// </summary>
/// <param name="e">The result of the search</param>
private void cm_ContactFound(object sender, ContactFoundEventArgs e)
{
Contact.Text = e.ContactFound.DisplayName;
......
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