Commit 2daa5590 authored by Margaux Clerc's avatar Margaux Clerc

Add selection list in history/chats

Fix back behavior when the application receive a chat push notification
parent c9349228
......@@ -733,4 +733,10 @@ To enjoy the best experience with Linphone WP8, we recommend that you use the SI
<data name="SelectItem.Label" xml:space="preserve">
<value>Select</value>
</data>
<data name="DeselectAll.Label" xml:space="preserve">
<value>Deselect all</value>
</data>
<data name="SelectAll.Label" xml:space="preserve">
<value>Select all</value>
</data>
</root>
\ No newline at end of file
......@@ -55,6 +55,20 @@ namespace Linphone.Views
this.InitializeComponent();
MessageBox.SendFileClick += send_file;
MessageBox.SendMessageClick += send_message;
SystemNavigationManager.GetForCurrentView().BackRequested += Back_requested;
}
private void Back_requested(object sender, BackRequestedEventArgs e)
{
if (Frame.CanGoBack)
{
Frame.GoBack();
} else
{
Frame.Navigate(typeof(Views.Chats), null);
}
e.Handled = true;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
......
......@@ -78,8 +78,12 @@
<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>
<CommandBar.SecondaryCommands>
<AppBarButton Visibility="Collapsed" x:Name="SelectAll" x:Uid="SelectAll" Click="SelectAll_Click"/>
<AppBarButton Visibility="Collapsed" x:Name="DeselectAll" x:Uid="DeselectAll" Click="DeselectAll_Click"/>
</CommandBar.SecondaryCommands>
</CommandBar>
</Grid>
</Page>
\ No newline at end of file
......@@ -20,6 +20,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
......@@ -52,6 +53,7 @@ namespace Linphone.Views
this.InitializeComponent();
SetCommandsVisibility(Conversations);
SystemNavigationManager.GetForCurrentView().BackRequested += Back_requested;
Conversations.SelectionChanged += OnSelectionChanged;
}
......@@ -181,18 +183,14 @@ namespace Linphone.Views
Frame.Navigate(typeof(Views.Chat), null);
}
private void back_Click(object sender, RoutedEventArgs e)
private void Back_requested(object sender, BackRequestedEventArgs e)
{
if (Frame.CanGoBack)
{
Frame.GoBack();
} else
{
if (Frame.BackStack.Count == 0)
{
Frame.Navigate(typeof(Views.Dialer), null);
}
Frame.Navigate(typeof(Views.Dialer), null);
Frame.BackStack.Clear();
}
e.Handled = true;
}
private void SelectItmesBtn_Click(object sender, RoutedEventArgs e)
......@@ -209,6 +207,8 @@ namespace Linphone.Views
CancelBtn.Visibility = Visibility.Visible;
NewConversation.Visibility = Visibility.Collapsed;
DeleteItem.Visibility = Visibility.Visible;
SelectAll.Visibility = Visibility.Visible;
DeselectAll.Visibility = Visibility.Collapsed;
}
else
{
......@@ -216,6 +216,8 @@ namespace Linphone.Views
CancelBtn.Visibility = Visibility.Collapsed;
NewConversation.Visibility = Visibility.Visible;
DeleteItem.Visibility = Visibility.Collapsed;
SelectAll.Visibility = Visibility.Collapsed;
DeselectAll.Visibility = Visibility.Collapsed;
}
}
......@@ -240,6 +242,20 @@ namespace Linphone.Views
SetCommandsVisibility(Conversations);
}
private void SelectAll_Click(object sender, RoutedEventArgs e)
{
Conversations.SelectAll();
DeselectAll.Visibility = Visibility.Visible;
SelectAll.Visibility = Visibility.Collapsed;
}
private void DeselectAll_Click(object sender, RoutedEventArgs e)
{
Conversations.SelectedItems.Clear();
DeselectAll.Visibility = Visibility.Collapsed;
SelectAll.Visibility = Visibility.Visible;
}
private void Conversations_ItemClick(object sender, ItemClickEventArgs e)
{
if(Conversations.SelectionMode == ListViewSelectionMode.Multiple || Conversations.SelectedItems.Count > 1)
......
......@@ -22,6 +22,7 @@ using BelledonneCommunications.Linphone.Native;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
using System.ComponentModel;
using System.Diagnostics;
namespace Linphone.Views
{
......@@ -166,17 +167,6 @@ namespace Linphone.Views
BugReportUploadPopup.Visibility = Visibility.Collapsed;
}
}*/
if (e.Parameter is String && (e.Parameter as String)?.Length > 0 && e.NavigationMode != NavigationMode.Back)
{
try {
Address address = LinphoneManager.Instance.Core.InterpretURL(e.Parameter as String);
String sipAddressToCall = address.AsStringUriOnly();
addressBox.Text = sipAddressToCall;
} catch(Exception exception)
{ }
}
if (LinphoneManager.Instance.Core.CallsNb > 0)
{
......@@ -189,6 +179,19 @@ namespace Linphone.Views
{
UnreadMessageCount = LinphoneManager.Instance.GetUnreadMessageCount();
}
if (e.Parameter is String && (e.Parameter as String)?.Length > 0 && e.NavigationMode != NavigationMode.Back)
{
String arguments = e.Parameter as String;
try
{
Address address = LinphoneManager.Instance.Core.InterpretURL(e.Parameter as String);
String sipAddressToCall = address.AsStringUriOnly();
addressBox.Text = sipAddressToCall;
}
catch (Exception exception)
{ }
}
}
protected override void OnNavigatedFrom(NavigationEventArgs nee)
......
......@@ -74,16 +74,14 @@
ItemsSource="{Binding}"
ItemTemplate="{StaticResource CallLogListViewTemplate}"
IsItemClickEnabled="True"
SelectionChanged="calls_SelectionChanged_1"
IsMultiSelectCheckBoxEnabled="True"
ItemClick="Calls_ItemClick" UseLayoutRounding="True">
</ListView>
</PivotItem>
<PivotItem Header="Missed" x:Uid="HistoryMissedTitle">
<ListView x:Name="MissedCalls"
Margin="-12,0,-12,0"
SelectionChanged="calls_SelectionChanged_1"
ItemTemplate="{StaticResource CallLogListViewTemplate}"
ItemClick="Calls_ItemClick">
</ListView>
......@@ -92,9 +90,18 @@
</Grid>
<CommandBar Grid.Row="2" VerticalAlignment="Bottom" >
<AppBarButton Label="Delete All" Icon="Delete" x:Name="Delete_button"/>
</CommandBar>
<AppBarButton x:Name="SelectItems" FontFamily="OverflowCheckGlyph" x:Uid="SelectItem" Label="Select Items" Click="SelectItems_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="CancelBtn_Click" x:Name="CancelBtn"/>
<CommandBar.SecondaryCommands>
<AppBarButton x:Name="SelectAll" x:Uid="SelectAll" Click="SelectAll_Click"/>
<AppBarButton Visibility="Collapsed" x:Name="DeselectAll" x:Uid="DeselectAll" Click="DeselectAll_Click"/>
</CommandBar.SecondaryCommands>
</CommandBar>
</Grid>
</Page>
\ No newline at end of file
......@@ -54,6 +54,8 @@ namespace Linphone.Views
Calls.Visibility = Visibility.Collapsed;
EmptyText.Visibility = Visibility.Visible;
}
SetCommandsVisibility(Calls);
}
private void deleteAll_Click_1(object sender, RoutedEventArgs e)
......@@ -72,40 +74,31 @@ namespace Linphone.Views
List<CallLogModel> callsHistory = LinphoneManager.Instance.GetCallsHistory();
Calls.ItemsSource = callsHistory;
MissedCalls.ItemsSource = (from log in callsHistory where (log.IsMissed) select log).ToList();
SetupAppBarForEmptySelection();
}
private void SetupAppBarForEmptySelection()
{
Delete_button.Click += deleteAll_Click_1;
_usingSelectionAppBar = false;
}
private void SetupAppBarForSelectedItems()
{
Delete_button.Click += deleteSelection_Click_1;
_usingSelectionAppBar = true;
}
private void calls_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
ListView list = (ListView)sender;
if (list.SelectedItems.Count == 0)
if (_selection.Count() == 0)
{
Calls.Visibility = Visibility.Collapsed;
EmptyText.Visibility = Visibility.Visible;
SetupAppBarForEmptySelection();
}
else if (list.SelectedItems.Count >= 1 && !_usingSelectionAppBar) // Do it only once, when selection was empty and isn't anymore
else if (_selection.Count() >= 1)
{
Calls.Visibility = Visibility.Visible;
EmptyText.Visibility = Visibility.Collapsed;
_selection = list.SelectedItems.Cast<CallLogModel>();
SetupAppBarForSelectedItems();
}
}
private void updateCallList()
{
List<CallLogModel> callsHistory = LinphoneManager.Instance.GetCallsHistory();
Calls.ItemsSource = callsHistory;
MissedCalls.ItemsSource = (from log in callsHistory where (log.IsMissed) select log).ToList();
}
private void SetAddressGoToDialerAndCall(String address)
{
Frame.Navigate(typeof(Views.Dialer), address);
......@@ -113,16 +106,81 @@ namespace Linphone.Views
private void Calls_ItemClick(object sender, ItemClickEventArgs e)
{
CallLogModel log = e.ClickedItem as CallLogModel;
CallLog nativeLog = (CallLog)log.NativeLog;
if (Calls.SelectionMode == ListViewSelectionMode.None || Calls.SelectedItems.Count == 0)
{
CallLogModel log = e.ClickedItem as CallLogModel;
CallLog nativeLog = (CallLog)log.NativeLog;
String address;
if (log.IsIncoming)
address = nativeLog.FromAddress.AsStringUriOnly();
else
address = nativeLog.ToAddress.AsStringUriOnly();
SetAddressGoToDialerAndCall(address);
}
}
private void SelectItems_Click(object sender, RoutedEventArgs e)
{
Calls.SelectionMode = ListViewSelectionMode.Multiple;
SetCommandsVisibility(Calls);
}
String address;
if (log.IsIncoming)
address = nativeLog.FromAddress.AsStringUriOnly();
private void SetCommandsVisibility(ListView listView)
{
if (listView.SelectionMode == ListViewSelectionMode.Multiple || listView.SelectedItems.Count > 1)
{
SelectItems.Visibility = Visibility.Collapsed;
CancelBtn.Visibility = Visibility.Visible;
DeleteItem.Visibility = Visibility.Visible;
SelectAll.Visibility = Visibility.Visible;
DeselectAll.Visibility = Visibility.Collapsed;
}
else
address = nativeLog.ToAddress.AsStringUriOnly();
{
SelectItems.Visibility = Visibility.Visible;
CancelBtn.Visibility = Visibility.Collapsed;
DeleteItem.Visibility = Visibility.Collapsed;
SelectAll.Visibility = Visibility.Collapsed;
DeselectAll.Visibility = Visibility.Collapsed;
}
}
SetAddressGoToDialerAndCall(address);
private void DeleteItem_Click(object sender, RoutedEventArgs e)
{
List<CallLogModel> _selectItem = new List<CallLogModel>();
foreach (CallLogModel item in Calls.SelectedItems)
{
_selectItem.Add(item);
}
foreach (CallLogModel item in _selectItem)
{
LinphoneManager.Instance.Core.RemoveCallLog((CallLog)item.NativeLog);
}
Calls.SelectionMode = ListViewSelectionMode.None;
updateCallList();
}
private void CancelBtn_Click(object sender, RoutedEventArgs e)
{
Calls.SelectionMode = ListViewSelectionMode.None;
SetCommandsVisibility(Calls);
}
private void SelectAll_Click(object sender, RoutedEventArgs e)
{
Calls.SelectAll();
DeselectAll.Visibility = Visibility.Visible;
SelectAll.Visibility = Visibility.Collapsed;
}
private void DeselectAll_Click(object sender, RoutedEventArgs e)
{
Calls.SelectedItems.Clear();
DeselectAll.Visibility = Visibility.Collapsed;
SelectAll.Visibility = Visibility.Visible;
}
}
}
\ No newline at end of file
......@@ -116,7 +116,6 @@ namespace Linphone.Views
private void Answer_Click(object sender, RoutedEventArgs e)
{
LinphoneManager.Instance.Core.AcceptCall(LinphoneManager.Instance.Core.CurrentCall);
Debug.WriteLine(_callingNumber);
Frame.Navigate(typeof(Views.InCall), _callingNumber);
}
......
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