Commit 25126307 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Clean unused assets + statusbar to display registration status on some pages

parent e29dc1f4
No preview for this file type
using Microsoft.Phone.Controls;
using Linphone.Controls;
using Microsoft.Phone.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -33,6 +34,11 @@ namespace Linphone
this.Loaded += BasePage_Loaded;
}
/// <summary>
/// The status bar displayed on the page if present.
/// </summary>
public static StatusBar StatusBar { get; set; }
/// <summary>
/// View model linked to the page, implements the call state listener.
/// </summary>
......@@ -62,6 +68,7 @@ namespace Linphone
protected override void OnNavigatedFrom(NavigationEventArgs nee)
{
base.OnNavigatedFrom(nee);
StatusBar = null;
this.ViewModel.OnNavigatedFrom(nee);
}
......
<UserControl x:Class="Linphone.Controls.StatusBar"
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="50" d:DesignWidth="480">
<StackPanel x:Name="LayoutRoot" Background="Transparent" Orientation="Horizontal">
<Image x:Name="Status" Source="/Assets/led_disconnected.png" Stretch="UniformToFill" Margin="10,0,0,0"></Image>
</StackPanel>
</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 Linphone.Model;
using Linphone.Core;
using System.Windows.Media.Imaging;
namespace Linphone.Controls
{
/// <summary>
/// User control to be displayed on each page, giving the state of the account registration.
/// </summary>
public partial class StatusBar : UserControl
{
/// <summary>
/// Public constructor.
/// </summary>
public StatusBar()
{
InitializeComponent();
RefreshStatusIcon(LinphoneManager.Instance.LastKnownState);
}
/// <summary>
/// Refresh the status icon reading the default proxy config state.
/// </summary>
public void RefreshStatusIcon()
{
RegistrationState state;
if (LinphoneManager.Instance.LinphoneCore.GetDefaultProxyConfig() == null)
state = RegistrationState.RegistrationNone;
else
state = LinphoneManager.Instance.LinphoneCore.GetDefaultProxyConfig().GetState();
RefreshStatusIcon(state);
}
/// <summary>
/// Refresh the status icon given the registration state in param.
/// </summary>
public void RefreshStatusIcon(RegistrationState state)
{
Dispatcher.BeginInvoke(() =>
{
if (state == RegistrationState.RegistrationOk)
Status.Source = new BitmapImage(new Uri("/Assets/led_connected.png", UriKind.Relative));
else if (state == RegistrationState.RegistrationInProgress)
Status.Source = new BitmapImage(new Uri("/Assets/led_inprogress.png", UriKind.Relative));
else if (state == RegistrationState.RegistrationFailed)
Status.Source = new BitmapImage(new Uri("/Assets/led_error.png", UriKind.Relative));
else
Status.Source = new BitmapImage(new Uri("/Assets/led_disconnected.png", UriKind.Relative));
});
}
}
}
......@@ -102,6 +102,9 @@
<Compile Include="Controls\ContactAction.xaml.cs">
<DependentUpon>ContactAction.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\StatusBar.xaml.cs">
<DependentUpon>StatusBar.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\TwoStateButton.xaml.cs">
<DependentUpon>TwoStateButton.xaml</DependentUpon>
</Compile>
......@@ -210,7 +213,6 @@
<Content Include="Assets\AppBar\transport.rew.png" />
<Content Include="Assets\AppBar\upload.png" />
<Content Include="Assets\AppIcon.png" />
<Content Include="Assets\background.png" />
<Content Include="Assets\backspace_default.png" />
<Content Include="Assets\backspace_over.png" />
<Content Include="Assets\call_answer_default.png" />
......@@ -218,32 +220,11 @@
<Content Include="Assets\call_status_incoming.png" />
<Content Include="Assets\call_status_missed.png" />
<Content Include="Assets\call_status_outgoing.png" />
<Content Include="Assets\dialer_address_background.png" />
<Content Include="Assets\led_connected.png" />
<Content Include="Assets\led_disconnected.png" />
<Content Include="Assets\led_error.png" />
<Content Include="Assets\led_inprogress.png" />
<Content Include="Assets\pnicon.png" />
<Content Include="Assets\Numpad\numpad_eight_default.png" />
<Content Include="Assets\Numpad\numpad_eight_over.png" />
<Content Include="Assets\Numpad\numpad_five_default.png" />
<Content Include="Assets\Numpad\numpad_five_over.png" />
<Content Include="Assets\Numpad\numpad_four_default.png" />
<Content Include="Assets\Numpad\numpad_four_over.png" />
<Content Include="Assets\Numpad\numpad_nine_default.png" />
<Content Include="Assets\Numpad\numpad_nine_over.png" />
<Content Include="Assets\Numpad\numpad_one_default.png" />
<Content Include="Assets\Numpad\numpad_one_over.png" />
<Content Include="Assets\Numpad\numpad_seven_default.png" />
<Content Include="Assets\Numpad\numpad_seven_over.png" />
<Content Include="Assets\Numpad\numpad_sharp_default.png" />
<Content Include="Assets\Numpad\numpad_sharp_over.png" />
<Content Include="Assets\Numpad\numpad_six_default.png" />
<Content Include="Assets\Numpad\numpad_six_over.png" />
<Content Include="Assets\Numpad\numpad_star_default.png" />
<Content Include="Assets\Numpad\numpad_star_over.png" />
<Content Include="Assets\Numpad\numpad_three_default.png" />
<Content Include="Assets\Numpad\numpad_three_over.png" />
<Content Include="Assets\Numpad\numpad_two_default.png" />
<Content Include="Assets\Numpad\numpad_two_over.png" />
<Content Include="Assets\Numpad\numpad_zero_default.png" />
<Content Include="Assets\Numpad\numpad_zero_over.png" />
<Content Include="Assets\Sounds\Ringtone.wma" />
<Content Include="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\CoreProxyStub\Linphone.CoreProxyStub.dll" />
<Content Include="Assets\unknown.png" />
......@@ -274,6 +255,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\StatusBar.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\TwoStateButton.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
......@@ -21,6 +21,11 @@ namespace Linphone.Model
/// </summary>
public sealed class LinphoneManager : LinphoneCoreListener
{
private LinphoneManager()
{
LastKnownState = Linphone.Core.RegistrationState.RegistrationNone;
}
private static LinphoneManager singleton;
/// <summary>
/// Static instance of the class.
......@@ -58,6 +63,11 @@ namespace Linphone.Model
}
}
/// <summary>
/// Used to set the default registration state on the status bar when the view is changed.
/// </summary>
public RegistrationState LastKnownState { get; set; }
/// <summary>
/// Simple listener to notify pages' viewmodel when a call ends or starts
/// </summary>
......@@ -409,9 +419,7 @@ namespace Linphone.Model
if (CallListener != null)
CallListener.NewCallStarted(call.GetRemoteAddress().AsStringUriOnly());
}
else if (state == LinphoneCallState.CallEnd ||
state == LinphoneCallState.Error ||
state == LinphoneCallState.Released)
else if (state == LinphoneCallState.CallEnd || state == LinphoneCallState.Error)
{
Debug.WriteLine("[LinphoneManager] Call ended");
((VoipPhoneCall)call.CallContext).NotifyCallEnded();
......@@ -427,6 +435,9 @@ namespace Linphone.Model
public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
{
Debug.WriteLine("[LinphoneManager] Registration state changed: " + state.ToString() + ", message=" + message);
LastKnownState = state;
if (BasePage.StatusBar != null)
BasePage.StatusBar.RefreshStatusIcon(state);
}
/// <summary>
......
......@@ -7,6 +7,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:linphone="clr-namespace:Linphone"
xmlns:controls="clr-namespace:Linphone.Controls"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
......@@ -17,18 +18,21 @@
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<controls:StatusBar x:Name="status" Grid.Row="0"></controls:StatusBar>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<StackPanel Grid.Row="1" Margin="12,17,0,28">
<!--<TextBlock Text="" Style="{StaticResource PhoneTextNormalStyle}"/>-->
<TextBlock x:Name="contactName" TextWrapping="Wrap" 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">
<Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">
<ScrollViewer>
<StackPanel x:Name="actions" Orientation="Vertical" Margin="20,0,0,0">
......
......@@ -37,6 +37,7 @@ namespace Linphone.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
StatusBar = status;
while (actions.Children.Count > 0)
{
......
......@@ -8,6 +8,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="clr-namespace:Linphone.Model"
xmlns:linphone="clr-namespace:Linphone"
xmlns:controls="clr-namespace:Linphone.Controls"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
......@@ -18,18 +19,21 @@
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<controls:StatusBar x:Name="status" Grid.Row="0"></controls:StatusBar>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,5,0,0">
<StackPanel Grid.Row="1" Margin="12,5,0,0">
<!--<TextBlock Foreground="Black" Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>-->
<TextBlock Text="{Binding Path=LocalizedResources.ContactsMenu, Source={StaticResource LocalizedStrings}}" 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">
<Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">
<Grid.Resources>
<model:ContactPictureConverter x:Key="ContactPictureConverter"/>
<phone:JumpListItemBackgroundConverter x:Key="BackgroundConverter"/>
......
......@@ -28,6 +28,16 @@ namespace Linphone.Views
contactsList.ItemsSource = ContactManager.Instance.GetContactsGroupedByLetters();
}
/// <summary>
/// Method called when the page is displayed.
/// </summary>
/// <param name="nee"></param>
protected override void OnNavigatedTo(NavigationEventArgs nee)
{
base.OnNavigatedTo(nee);
StatusBar = status;
}
private void contactsList_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
Microsoft.Phone.UserData.Contact selectedContact = ((sender as LongListSelector).SelectedItem as Microsoft.Phone.UserData.Contact);
......
......@@ -19,17 +19,20 @@
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<controls:StatusBar x:Name="status" Grid.Row="0"></controls:StatusBar>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,5,0,0">
<StackPanel x:Name="TitlePanel" Grid.Row="1" Margin="12,5,0,0">
<TextBlock Text="{Binding Path=LocalizedResources.DialerMenu, Source={StaticResource LocalizedStrings}}" 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">
<Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
......
......@@ -41,6 +41,7 @@ namespace Linphone
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
StatusBar = status;
LinphoneManager.Instance.EnableDebug(SettingsManager.isDebugEnabled);
// Create LinphoneCore if not created yet, otherwise do nothing
......
......@@ -8,6 +8,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:linphone="clr-namespace:Linphone"
xmlns:controls="clr-namespace:Linphone.Controls"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
......@@ -18,18 +19,21 @@
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<controls:StatusBar x:Name="status" Grid.Row="0"></controls:StatusBar>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,5,0,0">
<StackPanel Grid.Row="1" Margin="12,5,0,0">
<!--<TextBlock Foreground="Black" Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>-->
<TextBlock Text="{Binding Path=LocalizedResources.HistoryMenu, Source={StaticResource LocalizedStrings}}" 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">
<Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">
<phone:Pivot x:Name="history" Grid.Row="1">
<phone:Pivot.HeaderTemplate>
<DataTemplate>
......
......@@ -36,6 +36,9 @@ namespace Linphone.Views
/// <param name="e"></param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
StatusBar = status;
TileManager tileManager = TileManager.Instance;
tileManager.RemoveMissedCallsTile();
......
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