Commit dac4e4e1 authored by Erwan Croze's avatar Erwan Croze 👋🏻

Some fix on UI

parent 632255f2
......@@ -18,11 +18,9 @@ using Linphone.Model;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml;
namespace Linphone.Controls
{
namespace Linphone.Controls {
public partial class CallControlsP : UserControl
{
public partial class CallControlsP : UserControl {
public delegate void HangUpClickEventHandler(object sender);
public event HangUpClickEventHandler HangUpClick;
......@@ -50,96 +48,80 @@ namespace Linphone.Controls
public delegate void BluetoothClickEventHandler(object sender, bool isBluetoothOn);
public event DialpadClickEventHandler BluetoothClick;
public CallControlsP()
{
public CallControlsP() {
InitializeComponent();
microphone.IsChecked = LinphoneManager.Instance.Core.IsMicEnabled;
camera.IsEnabled = LinphoneManager.Instance.IsVideoAvailable && LinphoneManager.Instance.NumberOfCameras > 1;
}
#region Button enabled/disabled
public void enabledDialpad(bool isDialpadShown)
{
public void enabledDialpad(bool isDialpadShown) {
dialpad.Visibility = isDialpadShown ? Visibility.Visible : Visibility.Collapsed;
}
public void enabledVideo(bool isVideoEnabled)
{
public void enabledVideo(bool isVideoEnabled) {
video.IsEnabled = isVideoEnabled;
}
public void checkedVideo(bool isVideoChecked)
{
public void checkedVideo(bool isVideoChecked) {
video.IsChecked = isVideoChecked;
}
public void enabledPause(bool isPauseEnabled)
{
public void enabledPause(bool isPauseEnabled) {
pause.IsEnabled = isPauseEnabled;
}
#endregion
#region Click Event
private void hangUp_Click(object sender, RoutedEventArgs e)
{
private void hangUp_Click(object sender, RoutedEventArgs e) {
HangUpClick(this);
}
private void bluetooth_Click_1(object sender, RoutedEventArgs e)
{
private void bluetooth_Click_1(object sender, RoutedEventArgs e) {
bool isBluetoothToggled = (bool)bluetooth.IsChecked;
BluetoothClick(this, isBluetoothToggled);
}
private void speaker_Click_1(object sender, RoutedEventArgs e)
{
private void speaker_Click_1(object sender, RoutedEventArgs e) {
bool isSpeakerToggled = (bool)speaker.IsChecked;
SpeakerClick(this, isSpeakerToggled);
}
private void microphone_Click_1(object sender, RoutedEventArgs e)
{
private void microphone_Click_1(object sender, RoutedEventArgs e) {
bool isMicToggled = (bool)microphone.IsChecked;
MuteClick(this, isMicToggled);
}
private void stats_Click_1(object sender, RoutedEventArgs e)
{
private void stats_Click_1(object sender, RoutedEventArgs e) {
bool areStatsVisible = (bool)stats.IsChecked;
stats.IsChecked = areStatsVisible;
statsPanel.Visibility = areStatsVisible ? Visibility.Visible : Visibility.Collapsed;
StatsClick(this, areStatsVisible);
}
private void video_Click_1(object sender, RoutedEventArgs e)
{
private void video_Click_1(object sender, RoutedEventArgs e) {
bool isVideoToggled = (bool)video.IsChecked;
if (!isVideoToggled)
{
if (!isVideoToggled) {
video.IsEnabled = false;
} else
{
} else {
video.IsChecked = isVideoToggled;
}
VideoClick(this, isVideoToggled);
}
private void camera_Click_1(object sender, RoutedEventArgs e)
{
private void camera_Click_1(object sender, RoutedEventArgs e) {
CameraClick(this);
}
private void dialpad_Click_1(object sender, RoutedEventArgs e)
{
private void dialpad_Click_1(object sender, RoutedEventArgs e) {
bool isDialpadChecked = (bool)dialpad.IsChecked;
dialpad.IsChecked = isDialpadChecked;
numpad.Visibility = isDialpadChecked ? Visibility.Visible : Visibility.Collapsed;
DialpadClick(this, isDialpadChecked);
}
private void pause_Click_1(object sender, RoutedEventArgs e)
{
private void pause_Click_1(object sender, RoutedEventArgs e) {
bool isPauseToggled = (bool)pause.IsChecked;
PauseClick(this, isPauseToggled);
}
......
......@@ -22,30 +22,24 @@ using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Input;
namespace Linphone.Controls
{
public partial class IncomingChatBubble : UserControl
{
namespace Linphone.Controls {
public partial class IncomingChatBubble : UserControl {
public delegate void ImageTappedEventHandler(object sender, String appData);
public event ImageTappedEventHandler ImageTapped;
private ChatMessage _message;
public ChatMessage ChatMessage
{
get
{
public ChatMessage ChatMessage {
get {
return _message;
}
set
{
set {
_message = value;
}
}
public IncomingChatBubble(ChatMessage message)
{
public IncomingChatBubble(ChatMessage message) {
InitializeComponent();
ChatMessage = message;
Timestamp.Text = HumanFriendlyTimeStamp;
......@@ -54,61 +48,49 @@ namespace Linphone.Controls
string fileName = message.FileTransferName;
string filePath = message.AppData;
bool isImageMessage = fileName != null && fileName.Length > 0;
if (isImageMessage)
{
if (isImageMessage) {
Message.Visibility = Visibility.Collapsed;
//Copy.Visibility = Visibility.Collapsed;
if (filePath != null && filePath.Length > 0)
{
if (filePath != null && filePath.Length > 0) {
// Image already downloaded
Image.Visibility = Visibility.Visible;
// Save.Visibility = Visibility.Visible;
SetImage(filePath);
}
else
{
} else {
// Image needs to be downloaded
Download.Visibility = Visibility.Visible;
}
}
else
{
} else {
Message.Visibility = Visibility.Visible;
Image.Visibility = Visibility.Collapsed;
Message.Blocks.Add(Utils.FormatText(message.Text));
}
}
private async void SetImage(string name)
{
private async void SetImage(string name) {
BitmapImage image = await Utils.ReadImageFromTempStorage(name);
Image.Source = image;
}
private void Delete_Click(object sender, RoutedEventArgs e)
{
if (MessageDeleted != null)
{
MessageDeleted(this, ChatMessage);
private void Delete_Click(object sender, RoutedEventArgs e) {
if (MessageDeleted != null) {
MessageDeleted(this, ChatMessage);
}
}
private void Bubble_Holding(object sender, HoldingRoutedEventArgs e)
{
private void Bubble_Holding(object sender, HoldingRoutedEventArgs e) {
FrameworkElement senderElement = sender as FrameworkElement;
FlyoutMenu.ShowAt(senderElement);
}
private void Copy_Click(object sender, RoutedEventArgs e)
{
// Clipboard.SetText(ChatMessage.Text);
private void Copy_Click(object sender, RoutedEventArgs e) {
// Clipboard.SetText(ChatMessage.Text);
}
private void Save_Click(object sender, RoutedEventArgs e)
{
// bool result = await Utils.SavePictureInMediaLibrary(ChatMessage.AppData);
private void Save_Click(object sender, RoutedEventArgs e) {
// bool result = await Utils.SavePictureInMediaLibrary(ChatMessage.AppData);
// MessageBox.Show(result ? AppResources.FileSavingSuccess : AppResources.FileSavingFailure, AppResources.FileSaving, MessageBoxButton.OK);
}
......@@ -132,26 +114,21 @@ namespace Linphone.Controls
/// </summary>
public event DownloadImageEventHandler DownloadImage;
private void DownloadImage_Click(object sender, RoutedEventArgs e)
{
if (DownloadImage != null)
{
private void DownloadImage_Click(object sender, RoutedEventArgs e) {
if (DownloadImage != null) {
Download.Visibility = Visibility.Collapsed;
ProgressBar.Visibility = Visibility.Visible;
DownloadImage(this, ChatMessage);
}
}
public string HumanFriendlyTimeStamp
{
get
{
public string HumanFriendlyTimeStamp {
get {
return Utils.FormatDate(ChatMessage.Time);
}
}
private string FormatDate(DateTime date)
{
private string FormatDate(DateTime date) {
DateTime now = DateTime.Now;
if (now.Year == date.Year && now.Month == date.Month && now.Day == date.Day)
return String.Format("{0:HH:mm}", date);
......@@ -164,27 +141,22 @@ namespace Linphone.Controls
/// <summary>
/// Displays the image in the bubble
/// </summary>
public async void RefreshImage()
{
public async void RefreshImage() {
string filePath = ChatMessage.AppData;
ProgressBar.Visibility = Visibility.Collapsed;
if (filePath != null && filePath.Length > 0)
{
if (filePath != null && filePath.Length > 0) {
Download.Visibility = Visibility.Collapsed;
Image.Visibility = Visibility.Visible;
// Save.Visibility = Visibility.Visible;
// Save.Visibility = Visibility.Visible;
BitmapImage image = await Utils.ReadImageFromTempStorage(filePath);
Image.Source = image;
}
else
{
} else {
Download.Visibility = Visibility.Visible;
}
}
private void Image_Tap(object sender, TappedRoutedEventArgs e)
{
private void Image_Tap(object sender, TappedRoutedEventArgs e) {
ImageTapped(this, ChatMessage.AppData);
}
}
......
......@@ -21,42 +21,33 @@ using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
namespace Linphone.Controls
{
public partial class OutgoingChatBubble : UserControl, ChatMessageListener
{
namespace Linphone.Controls {
public partial class OutgoingChatBubble : UserControl, ChatMessageListener {
private ChatMessage _message;
public ChatMessage ChatMessage
{
get
{
public ChatMessage ChatMessage {
get {
return _message;
}
set
{
set {
_message = value;
}
}
public OutgoingChatBubble(ChatMessage message)
{
public OutgoingChatBubble(ChatMessage message) {
InitializeComponent();
ChatMessage = message;
this.Holding += Bubble_Holding;
string filePath = message.AppData;
bool isImageMessage = filePath != null && filePath.Length > 0;
if (isImageMessage)
{
Message.Visibility = Visibility.Collapsed;
//Copy.Visibility = Visibility.Collapsed;
Image.Visibility = Visibility.Visible;
//Save.Visibility = Visibility.Visible;
SetImage(filePath);
}
else
{
if (isImageMessage) {
Message.Visibility = Visibility.Collapsed;
//Copy.Visibility = Visibility.Collapsed;
Image.Visibility = Visibility.Visible;
//Save.Visibility = Visibility.Visible;
SetImage(filePath);
} else {
Message.Visibility = Visibility.Visible;
Message.Blocks.Add(Utils.FormatText(message.Text));
Image.Visibility = Visibility.Collapsed;
......@@ -65,70 +56,56 @@ namespace Linphone.Controls
Timestamp.Text = HumanFriendlyTimeStamp;
}
private async void SetImage(string name)
{
private async void SetImage(string name) {
BitmapImage image = await Utils.ReadImageFromTempStorage(name);
Image.Source = image;
}
public string HumanFriendlyTimeStamp
{
get
{
public string HumanFriendlyTimeStamp {
get {
return Utils.FormatDate(ChatMessage.Time);
}
}
public void UpdateStatus(ChatMessageState state)
{
if (state == ChatMessageState.InProgress)
{
public void UpdateStatus(ChatMessageState state) {
if (state == ChatMessageState.InProgress) {
Status.Glyph = "\uE72A";
}
else if (state == ChatMessageState.NotDelivered)
{
} else if (state == ChatMessageState.NotDelivered) {
Status.Glyph = "\uE711";
} else
{
} else {
Status.Visibility = Visibility.Collapsed;
}
}
private void Bubble_Holding(object sender, HoldingRoutedEventArgs e)
{
private void Bubble_Holding(object sender, HoldingRoutedEventArgs e) {
FrameworkElement senderElement = sender as FrameworkElement;
FlyoutMenu.ShowAt(senderElement);
}
private void Delete_Click(object sender, RoutedEventArgs e)
{
if (MessageDeleted != null)
{
private void Delete_Click(object sender, RoutedEventArgs e) {
if (MessageDeleted != null) {
MessageDeleted(this, ChatMessage);
}
}
private void Copy_Click(object sender, RoutedEventArgs e)
{
// Clipboard.SetText(ChatMessage.Text);
private void Copy_Click(object sender, RoutedEventArgs e) {
// Clipboard.SetText(ChatMessage.Text);
}
private void Save_Click(object sender, RoutedEventArgs e)
{
// bool result = Utils.SavePictureInMediaLibrary(ChatMessage.AppData);
// MessageBox.Show(result ? AppResources.FileSavingSuccess : AppResources.FileSavingFailure, AppResources.FileSaving, MessageBoxButton.OK);
private void Save_Click(object sender, RoutedEventArgs e) {
// bool result = Utils.SavePictureInMediaLibrary(ChatMessage.AppData);
// MessageBox.Show(result ? AppResources.FileSavingSuccess : AppResources.FileSavingFailure, AppResources.FileSaving, MessageBoxButton.OK);
}
public void MessageStateChanged(ChatMessage message, ChatMessageState state)
{
public void MessageStateChanged(ChatMessage message, ChatMessageState state) {
}
public delegate void MessageDeletedEventHandler(object sender, ChatMessage message);
public event MessageDeletedEventHandler MessageDeleted;
/* private void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
BaseModel.CurrentPage.NavigationService.Navigate(new Uri("/Views/FullScreenPicture.xaml?uri=" + ChatMessage.AppData, UriKind.RelativeOrAbsolute));
}*/
/* private void Image_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
BaseModel.CurrentPage.NavigationService.Navigate(new Uri("/Views/FullScreenPicture.xaml?uri=" + ChatMessage.AppData, UriKind.RelativeOrAbsolute));
}*/
}
}
......@@ -21,19 +21,15 @@ using BelledonneCommunications.Linphone.Native;
using Windows.UI.Xaml.Media.Imaging;
using Windows.ApplicationModel.Resources;
namespace Linphone.Controls
{
namespace Linphone.Controls {
public partial class StatusBar : UserControl
{
public partial class StatusBar : UserControl {
public StatusBar()
{
public StatusBar() {
InitializeComponent();
}
public void RefreshStatus()
{
public void RefreshStatus() {
RegistrationState state;
if (LinphoneManager.Instance.Core.DefaultProxyConfig == null)
state = RegistrationState.None;
......@@ -43,36 +39,27 @@ namespace Linphone.Controls
RefreshStatus(state);
}
public void RefreshStatus(RegistrationState state)
{
public void RefreshStatus(RegistrationState state) {
if (state == RegistrationState.Ok)
{
if (state == RegistrationState.Ok) {
StatusLed.Source = new BitmapImage(new Uri(this.BaseUri, "/Assets/led_connected.png"));
StatusText.Text = ResourceLoader.GetForCurrentView().GetString("Registered");
}
else if (state == RegistrationState.Progress)
{
} else if (state == RegistrationState.Progress) {
StatusLed.Source = new BitmapImage(new Uri(this.BaseUri, "/Assets/led_inprogress.png"));
StatusText.Text = ResourceLoader.GetForCurrentView().GetString("RegistrationInProgress");
}
else if (state == RegistrationState.Failed)
{
} else if (state == RegistrationState.Failed) {
StatusLed.Source = new BitmapImage(new Uri(this.BaseUri, "/Assets/led_error.png"));
if(LinphoneManager.Instance.Core.DefaultProxyConfig.Error == Reason.Forbidden)
{
if (LinphoneManager.Instance.Core.DefaultProxyConfig.Error == Reason.Forbidden) {
StatusText.Text = ResourceLoader.GetForCurrentView().GetString("RegistrationFailedForbidden");
} else
{
} else {
StatusText.Text = ResourceLoader.GetForCurrentView().GetString("RegistrationFailed");
}
}
else {
} else {
StatusLed.Source = new BitmapImage(new Uri(this.BaseUri, "/Assets/led_disconnected.png"));
StatusText.Text = ResourceLoader.GetForCurrentView().GetString("Disconnected");
}
}
}
}
......@@ -17,16 +17,20 @@ using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Imaging;
namespace Linphone.Controls
{
public partial class TextBoxChatBubble : UserControl
{
public string Text { get; set; }
namespace Linphone.Controls {
public string ImageName { get; set; }
public partial class TextBoxChatBubble : UserControl {
public string Text {
get; set;
}
public string ImageLocalPath { get; set; }
public string ImageName {
get; set;
}
public string ImageLocalPath {
get; set;
}
public delegate void SendFileClickEventHandler(object sender);
public event SendFileClickEventHandler SendFileClick;
......@@ -34,13 +38,12 @@ namespace Linphone.Controls
public delegate void SendMessageClickEventHandler(object sender);
public event SendMessageClickEventHandler SendMessageClick;
public TextBoxChatBubble()
{
InitializeComponent(); SendMessage.IsEnabled = true;
public TextBoxChatBubble() {
InitializeComponent();
SendMessage.IsEnabled = true;
}
public void Reset()
{
public void Reset() {
Message.Text = "";
Text = null;
ImageName = null;
......@@ -50,18 +53,15 @@ namespace Linphone.Controls
Image.Visibility = Visibility.Collapsed;
}
private void Message_TextChanged(object sender, TextChangedEventArgs e)
{
private void Message_TextChanged(object sender, TextChangedEventArgs e) {
Text = Message.Text;
SendMessage.IsEnabled = (Text.Length > 0 ? true : false || Image.Visibility == Visibility.Visible);
if (TextChanged != null)
{
if (TextChanged != null) {
TextChanged(this, Message.Text);
}
}
public void SetImage(BitmapImage image)
{
public void SetImage(BitmapImage image) {
Image.Source = image;
Image.Visibility = Visibility.Visible;
Message.Visibility = Visibility.Collapsed;
......@@ -69,8 +69,7 @@ namespace Linphone.Controls
SendMessage.IsEnabled = true;
}
private void Delete_Click(object sender, RoutedEventArgs e)
{
private void Delete_Click(object sender, RoutedEventArgs e) {
string previousText = Text;
Reset();
Text = previousText;
......@@ -81,13 +80,11 @@ namespace Linphone.Controls
public event TextChangedEventHandler TextChanged;
private void SendFile_Click(object sender, RoutedEventArgs e)
{
private void SendFile_Click(object sender, RoutedEventArgs e) {
SendFileClick(this);
}
private void SendMessage_Click(object sender, RoutedEventArgs e)
{
private void SendMessage_Click(object sender, RoutedEventArgs e) {
SendMessageClick(this);
}
}
......
......@@ -18,35 +18,32 @@ using System;
using System.Collections.Generic;
using Windows.Globalization.Collation;
namespace Linphone.Model
{
namespace Linphone.Model {
public class AlphaKeyGroup<T>
{
public class AlphaKeyGroup<T> {
const string GlobeGroupKey = "\uD83C\uDF10";
public string Key { get; private set; }
public List<T> InternalList { get; private set; }
public string Key {
get; private set;
}
public List<T> InternalList {
get; private set;
}
public AlphaKeyGroup(string key)
{
public AlphaKeyGroup(string key) {
Key = key;
InternalList = new List<T>();
}
private static List<AlphaKeyGroup<T>> CreateDefaultGroups(CharacterGroupings slg)
{
private static List<AlphaKeyGroup<T>> CreateDefaultGroups(CharacterGroupings slg) {
List<AlphaKeyGroup<T>> list = new List<AlphaKeyGroup<T>>();
foreach (CharacterGrouping cg in slg)
{
if (cg.Label == "") continue;
if (cg.Label == "...")
{
foreach (CharacterGrouping cg in slg) {
if (cg.Label == "")
continue;
if (cg.Label == "...") {
list.Add(new AlphaKeyGroup<T>(GlobeGroupKey));
}
else
{
} else {
list.Add(new AlphaKeyGroup<T>(cg.Label));
}
}
......@@ -54,30 +51,27 @@ namespace Linphone.Model
return list;
}
public static List<AlphaKeyGroup<T>> CreateGroups(IEnumerable<T> items, Func<T, string> keySelector, bool sort)
{
public static List<AlphaKeyGroup<T>> CreateGroups(IEnumerable<T> items, Func<T, string> keySelector, bool sort) {
CharacterGroupings slg = new CharacterGroupings();
List<AlphaKeyGroup<T>> list = CreateDefaultGroups(slg);
foreach (T item in items)
{
foreach (T item in items) {
int index = 0;
{
string label = slg.Lookup(keySelector(item));
index = list.FindIndex(alphakeygroup => (alphakeygroup.Key.Equals(label, StringComparison.CurrentCulture)));
}
if (index >= 0 && index < list.Count)
{
if (index >= 0 && index < list.Count) {
list[index].InternalList.Add(item);
}
}
if (sort)
{
foreach (AlphaKeyGroup<T> group in list)
{
group.InternalList.Sort((c0, c1) => { return keySelector(c0).CompareTo(keySelector(c0)); });
if (sort) {
foreach (AlphaKeyGroup<T> group in list) {
group.InternalList.Sort((c0, c1) => {
return keySelector(c0).CompareTo(keySelector(c0));
});
}
}