Commit a013f9cc authored by Sylvain Berfini's avatar Sylvain Berfini

Using custom incoming call view

parent ee7217c4
......@@ -22,6 +22,7 @@ namespace Linphone.Agents
AgentHost.OnAgentStarted();
//Force the callController to be initialized now to avoid creating it at the last moment (workaroud outgoing call crash after app started)
Globals.Instance.CallController.IncomingCallViewDismissed = null;
Globals.Instance.CallController.CustomIncomingCallView = true;
}
/// <summary>
......
......@@ -40,6 +40,7 @@ VoipPhoneCall^ CallController::OnIncomingCallReceived(Linphone::Core::LinphoneCa
this->voipServiceName,
media,
&incomingCall);
incomingCall->NotifyCallActive();
} else {
TimeSpan ringingTimeout;
ringingTimeout.Duration = 90 * 10 * 1000 * 1000; // in 100ns units
......
......@@ -184,6 +184,9 @@
<Compile Include="Views\InCall.xaml.cs">
<DependentUpon>InCall.xaml</DependentUpon>
</Compile>
<Compile Include="Views\IncomingCall.xaml.cs">
<DependentUpon>IncomingCall.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Settings.xaml.cs">
<DependentUpon>Settings.xaml</DependentUpon>
</Compile>
......@@ -372,6 +375,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\IncomingCall.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Settings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
......@@ -104,15 +104,9 @@ namespace Linphone
{
Logger.Msg("[CallListener] Call ended, can go back ? " + this.Page.NavigationService.CanGoBack);
if (this.Page.NavigationService.CanGoBack)
this.Page.NavigationService.GoBack();
else
{
//If incall view directly accessed from home page, backstack is empty
//If so, instead of keeping the incall view, launch the Dialer and remove the incall view from the backstack
this.Page.NavigationService.Navigate(new Uri("/Views/Dialer.xaml", UriKind.RelativeOrAbsolute));
this.Page.NavigationService.RemoveBackEntry();
}
//Launch the Dialer and remove the incall view from the backstack
this.Page.NavigationService.Navigate(new Uri("/Views/Dialer.xaml", UriKind.RelativeOrAbsolute));
this.Page.NavigationService.RemoveBackEntry();
}
/// <summary>
......
......@@ -642,6 +642,11 @@ namespace Linphone.Model
Logger.Msg("[LinphoneManager] Incoming received");
BaseModel.UIDispatcher.BeginInvoke(() =>
{
BaseModel.CurrentPage.NavigationService.Navigate(new Uri("/Views/IncomingCall.xaml?sip=" + call.GetRemoteAddress().AsStringUriOnly(), UriKind.RelativeOrAbsolute));
//Remove the current page from the back stack to avoid duplicating him after
BaseModel.CurrentPage.NavigationService.RemoveBackEntry();
LookupForContact(call);
});
}
......@@ -714,6 +719,9 @@ namespace Linphone.Model
/// </summary>
public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
{
if (config == null)
return;
BaseModel.UIDispatcher.BeginInvoke(() =>
{
Logger.Msg("[LinphoneManager] Registration state changed: " + state.ToString() + ", message=" + message + " for identity " + config.GetIdentity());
......
......@@ -129,6 +129,24 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to answer.
/// </summary>
public static string Answer {
get {
return ResourceManager.GetString("Answer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to answer with video.
/// </summary>
public static string AnswerVideo {
get {
return ResourceManager.GetString("AnswerVideo", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Linphone.
/// </summary>
......@@ -327,6 +345,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to decline.
/// </summary>
public static string Decline {
get {
return ResourceManager.GetString("Decline", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete All.
/// </summary>
......@@ -543,6 +570,15 @@ namespace Linphone.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to INCOMING CALL.
/// </summary>
public static string IncomingCall {
get {
return ResourceManager.GetString("IncomingCall", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to LockScreen settings.
/// </summary>
......
......@@ -452,4 +452,16 @@ http://www.linphone.org/m/help
<data name="ContextMenuSave" xml:space="preserve">
<value>Save in library</value>
</data>
<data name="Answer" xml:space="preserve">
<value>answer</value>
</data>
<data name="AnswerVideo" xml:space="preserve">
<value>answer with video</value>
</data>
<data name="Decline" xml:space="preserve">
<value>decline</value>
</data>
<data name="IncomingCall" xml:space="preserve">
<value>INCOMING CALL</value>
</data>
</root>
\ No newline at end of file
......@@ -13,12 +13,6 @@
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources>
<Style TargetType="Button" x:Key="AccentButton">
</Style>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid
......@@ -209,9 +203,6 @@
Content="{Binding Path=LocalizedResources.HangUp, Source={StaticResource LocalizedStrings}}"
Click="hangUp_Click"
ClickMode="Release">
<Button.Style>
<StaticResource ResourceKey="AccentColorButton"/>
</Button.Style>
</Button>
<ToggleButton
......
<phone:PhoneApplicationPage
x:Class="Linphone.Views.IncomingCall"
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="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="0,25,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Status text -->
<TextBlock
Grid.Row="0"
x:Name="Status"
Style="{StaticResource PhoneTextAccentStyle}"
Text="{Binding Path=LocalizedResources.IncomingCall, Source={StaticResource LocalizedStrings}}"
Margin="12,0,12,0"
FontSize="40" />
<!-- Contact text -->
<TextBlock
Grid.Row="1"
x:Name="Contact"
Margin="12,0,12,0"
FontSize="80"
TextWrapping="Wrap"/>
<!-- Number text -->
<TextBlock
Grid.Row="2"
x:Name="Number"
Margin="12,0,12,0"
FontSize="30"
TextWrapping="NoWrap"/>
<!-- Buttons -->
<Grid Grid.Row="4" Margin="0,50,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition MinHeight="80" Height="Auto"/>
<RowDefinition MinHeight="80" Height="Auto"/>
</Grid.RowDefinitions>
<Button
x:Name="Answer"
Grid.Row="0"
Grid.Column="0"
BorderThickness="0"
Margin="-10"
Background="{StaticResource PhoneAccentBrush}"
Content="{Binding Path=LocalizedResources.Answer, Source={StaticResource LocalizedStrings}}"
Click="Answer_Click"
ClickMode="Release">
</Button>
<Button
x:Name="Decline"
Grid.Row="0"
Grid.Column="1"
BorderThickness="0"
Margin="-10"
Background="{StaticResource PhoneChromeBrush}"
Content="{Binding Path=LocalizedResources.Decline, Source={StaticResource LocalizedStrings}}"
Click="Decline_Click"
ClickMode="Release">
</Button>
<Button
x:Name="AnswerVidoe"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
BorderThickness="0"
Margin="-10"
Background="{StaticResource PhoneAccentBrush}"
Content="{Binding Path=LocalizedResources.AnswerVideo, Source={StaticResource LocalizedStrings}}"
Click="Answer_Click"
ClickMode="Release">
</Button>
</Grid>
</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 Linphone.Model;
using System.Threading.Tasks;
namespace Linphone.Views
{
/// <summary>
/// View to use instead of Windows Phone 8 VoIP incoming call view
/// </summary>
public partial class IncomingCall : PhoneApplicationPage
{
private String _callingNumber;
/// <summary>
/// Public constructor.
/// </summary>
public IncomingCall()
{
InitializeComponent();
}
/// <summary>
/// Forbid the user to back when this view is visible
/// </summary>
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
base.OnBackKeyPress(e);
}
/// <summary>
/// Remove this entry from the back stack to ensure the user won't navigate to it with the back button
/// </summary>
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
NavigationService.RemoveBackEntry(); //To prevent a new click on back button to start again the incoming call view (simulate a back click)
}
/// <summary>
/// Method called when the page is displayed.
/// Searches for a matching contact using the current call address or number and display information if found.
/// </summary>
protected override async void OnNavigatedTo(NavigationEventArgs nee)
{
// Create LinphoneCore if not created yet, otherwise do nothing
Task t = LinphoneManager.Instance.InitLinphoneCore();
base.OnNavigatedTo(nee);
if (NavigationContext.QueryString.ContainsKey("sip"))
{
_callingNumber = NavigationContext.QueryString["sip"];
if (_callingNumber.StartsWith("sip:"))
{
_callingNumber = _callingNumber.Substring(4);
}
// While we dunno if the number matches a contact one, we consider it won't and we display the phone number as username
Contact.Text = _callingNumber;
if (_callingNumber != null && _callingNumber.Length > 0)
{
ContactManager cm = ContactManager.Instance;
cm.ContactFound += cm_ContactFound;
cm.FindContact(_callingNumber);
}
}
await t;
}
/// <summary>
/// Callback called when the search on a phone number for a contact has a match
/// </summary>
private void cm_ContactFound(object sender, ContactFoundEventArgs e)
{
if (e.ContactFound != null)
{
Contact.Text = e.ContactFound.DisplayName;
if (e.PhoneLabel != null)
{
Number.Text = e.PhoneLabel + " : " + e.PhoneNumber;
}
else
{
Number.Text = e.PhoneNumber;
}
}
}
private void Answer_Click(object sender, RoutedEventArgs e)
{
LinphoneManager.Instance.LinphoneCore.AcceptCall(LinphoneManager.Instance.LinphoneCore.GetCurrentCall());
NavigationService.Navigate(new Uri("/Views/InCall.xaml?sip=" + _callingNumber, UriKind.RelativeOrAbsolute));
}
private void AnswerVideo_Click(object sender, RoutedEventArgs e)
{
}
private void Decline_Click(object sender, RoutedEventArgs e)
{
LinphoneManager.Instance.EndCurrentCall();
if (NavigationService.CanGoBack)
{
NavigationService.GoBack();
}
}
}
}
\ No newline at end of file
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