From 13bcb2c1291faaf8e5f05acac162201f20912a03 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Fri, 27 Jan 2017 15:32:25 +0100 Subject: [PATCH] An avatar, one or two --- ZicMoove/ZicMoove.Droid/MainActivity.cs | 2 +- ZicMoove/ZicMoove/App.xaml | 2 +- ZicMoove/ZicMoove/App.xaml.cs | 2 + ZicMoove/ZicMoove/Constants.cs | 23 +------- ZicMoove/ZicMoove/Helpers/UserHelpers.cs | 6 +- ZicMoove/ZicMoove/Model/Auth/User.cs | 2 +- ZicMoove/ZicMoove/Pages/Chat/ChatPage.xaml | 57 ++++++++++++++++--- ZicMoove/ZicMoove/Pages/Chat/ChatPage.xaml.cs | 17 +++++- ZicMoove/ZicMoove/Settings/MainSettings.cs | 5 +- .../EstimateAndBilling/BookQueryViewModel.cs | 2 +- .../Messaging/ChatUserCollection.cs | 2 +- .../ViewModels/Messaging/ChatViewModel.cs | 2 +- .../UserProfile/DashboardViewModel.cs | 3 +- .../UserProfile/UserProfileViewModel.cs | 2 +- ZicMoove/ZicMoove/ZicMoove.csproj | 2 + 15 files changed, 85 insertions(+), 44 deletions(-) diff --git a/ZicMoove/ZicMoove.Droid/MainActivity.cs b/ZicMoove/ZicMoove.Droid/MainActivity.cs index 7eff1a20..8210cad1 100644 --- a/ZicMoove/ZicMoove.Droid/MainActivity.cs +++ b/ZicMoove/ZicMoove.Droid/MainActivity.cs @@ -324,7 +324,7 @@ namespace ZicMoove.Droid public void AddAccount() { var auth = new YaOAuth2Authenticator( - clientId: "d9be5e97-c19d-42e4-b444-0e65863b19e1", + clientId: Constants.APIKey, clientSecret: "blouh", scope: "profile", authorizeUrl: new Uri(Constants.AuthorizeUrl), diff --git a/ZicMoove/ZicMoove/App.xaml b/ZicMoove/ZicMoove/App.xaml index 6360cac3..ad7a7cc8 100644 --- a/ZicMoove/ZicMoove/App.xaml +++ b/ZicMoove/ZicMoove/App.xaml @@ -8,7 +8,7 @@ - #FFAAAAFF + #20AAAAFF #FFCCCCFF #80FFFFFF diff --git a/ZicMoove/ZicMoove/App.xaml.cs b/ZicMoove/ZicMoove/App.xaml.cs index 6bb86972..98a82fbc 100644 --- a/ZicMoove/ZicMoove/App.xaml.cs +++ b/ZicMoove/ZicMoove/App.xaml.cs @@ -382,7 +382,9 @@ namespace ZicMoove }; DataManager.Instance.PrivateMessages.Add( msg + ); + DataManager.Instance.PrivateMessages.SaveEntity(); DataManager.Instance.ChatUsers.OnPrivateMessage(msg); }); } diff --git a/ZicMoove/ZicMoove/Constants.cs b/ZicMoove/ZicMoove/Constants.cs index c6041249..2ba194cb 100644 --- a/ZicMoove/ZicMoove/Constants.cs +++ b/ZicMoove/ZicMoove/Constants.cs @@ -7,30 +7,9 @@ using Xamarin.Forms; namespace ZicMoove { - public static class Constants + public static partial class Constants { -#if DEV - public const string ApplicationName = "yadev"; - public const string YavscHomeUrl = "http://dev.pschneider.fr"; -#endif -#if WDEV - // against a Windows local API - public const string ApplicationName = "yawindev"; - public const string YavscHomeUrl = "http://192.168.0.29:5000"; -#endif -#if YAVSC - public const string ApplicationName = "yavsc"; - public const string YavscHomeUrl = "https://yavsc.pschneider.fr"; -#endif -#if LUA - public const string ApplicationName = "Luap"; - public const string YavscHomeUrl = "https://lua.pschneider.fr"; -#endif -#if ZICMOOVE - public const string ApplicationName = "ZicMoove"; - public const string YavscHomeUrl = "https://zicmoove.pschneider.fr"; -#endif public static readonly string AuthorizeUrl = YavscHomeUrl + "/authorize"; public static readonly string RedirectUrl = YavscHomeUrl + "/oauth/success"; public static readonly string AccessTokenUrl = YavscHomeUrl + "/token"; diff --git a/ZicMoove/ZicMoove/Helpers/UserHelpers.cs b/ZicMoove/ZicMoove/Helpers/UserHelpers.cs index 1940ac70..eb3addb4 100644 --- a/ZicMoove/ZicMoove/Helpers/UserHelpers.cs +++ b/ZicMoove/ZicMoove/Helpers/UserHelpers.cs @@ -13,11 +13,11 @@ namespace ZicMoove.Helpers public static class UserHelpers { - public static ImageSource Avatar(string avatarPath) + public static ImageSource Avatar(string username) { - var result = avatarPath == null ? + var result = username == null ? ImageSource.FromResource( "ZicMoove.Images.Users.icon_user.png") : - ImageSource.FromUri(new Uri(Constants.YavscHomeUrl+"/Avatars/"+avatarPath)) ; + ImageSource.FromUri(new Uri(Constants.YavscHomeUrl+ $"/Avatars/{username}.png")) ; return result; } diff --git a/ZicMoove/ZicMoove/Model/Auth/User.cs b/ZicMoove/ZicMoove/Model/Auth/User.cs index 2489032f..2fc8d44d 100644 --- a/ZicMoove/ZicMoove/Model/Auth/User.cs +++ b/ZicMoove/ZicMoove/Model/Auth/User.cs @@ -95,7 +95,7 @@ namespace ZicMoove.Model.Auth.Account { get { - return UserHelpers.Avatar(avatar); + return UserHelpers.Avatar(UserName); } } private Tokens yavscTokens; diff --git a/ZicMoove/ZicMoove/Pages/Chat/ChatPage.xaml b/ZicMoove/ZicMoove/Pages/Chat/ChatPage.xaml index 1fac4a21..bbff4bba 100644 --- a/ZicMoove/ZicMoove/Pages/Chat/ChatPage.xaml +++ b/ZicMoove/ZicMoove/Pages/Chat/ChatPage.xaml @@ -11,6 +11,13 @@ Style="{StaticResource PageStyle}" > + + @@ -46,6 +53,17 @@ + + + + + + @@ -63,10 +81,13 @@ - @@ -77,16 +98,27 @@ + + + + + + - @@ -106,7 +138,18 @@ - + + + + + + + diff --git a/ZicMoove/ZicMoove/Pages/Chat/ChatPage.xaml.cs b/ZicMoove/ZicMoove/Pages/Chat/ChatPage.xaml.cs index 4b158c5f..d2ee05ed 100644 --- a/ZicMoove/ZicMoove/Pages/Chat/ChatPage.xaml.cs +++ b/ZicMoove/ZicMoove/Pages/Chat/ChatPage.xaml.cs @@ -63,12 +63,27 @@ namespace ZicMoove.Pages.Chat IsBusy = true; try { + bool sent = false; foreach (var cx in dest.ObservableConnections) { if (cx.Connected) + { App.ChatHubProxy.Invoke("SendPV", cx.ConnectionId, pvEntry.Text); + sent = true; + } + } + if (sent) + { + chatUserList.SelectedUser.PrivateMessages.Add( + new Model.Social.Messaging.ChatMessage + { + Date = DateTime.Now, + Message = pvEntry.Text, + Read = true, + SenderId = MainSettings.CurrentUser.UserName + }); + pvEntry.Text = null; } - pvEntry.Text = null; } catch (Exception ex) { diff --git a/ZicMoove/ZicMoove/Settings/MainSettings.cs b/ZicMoove/ZicMoove/Settings/MainSettings.cs index e74be2ca..6fc5e995 100644 --- a/ZicMoove/ZicMoove/Settings/MainSettings.cs +++ b/ZicMoove/ZicMoove/Settings/MainSettings.cs @@ -7,18 +7,17 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -namespace ZicMoove +namespace ZicMoove.Settings { using Model.Social; using Model.Auth.Account; - using Data; /// /// This is the Settings static class that can be used in your Core solution or in any /// of your client applications. All settings are laid out the same exact way with getters /// and setters. /// - public static class MainSettings + public static partial class MainSettings { public static ISettings AppSettings diff --git a/ZicMoove/ZicMoove/ViewModels/EstimateAndBilling/BookQueryViewModel.cs b/ZicMoove/ZicMoove/ViewModels/EstimateAndBilling/BookQueryViewModel.cs index 5eb9a9c5..d9b919a7 100644 --- a/ZicMoove/ZicMoove/ViewModels/EstimateAndBilling/BookQueryViewModel.cs +++ b/ZicMoove/ZicMoove/ViewModels/EstimateAndBilling/BookQueryViewModel.cs @@ -47,7 +47,7 @@ namespace ZicMoove.ViewModels.EstimateAndBilling { get { - return UserHelpers.Avatar(Client.Avatar); + return UserHelpers.Avatar(Client.UserName); } } public ImageSource SmallAvatar diff --git a/ZicMoove/ZicMoove/ViewModels/Messaging/ChatUserCollection.cs b/ZicMoove/ZicMoove/ViewModels/Messaging/ChatUserCollection.cs index 85d04bcd..442c4d17 100644 --- a/ZicMoove/ZicMoove/ViewModels/Messaging/ChatUserCollection.cs +++ b/ZicMoove/ZicMoove/ViewModels/Messaging/ChatUserCollection.cs @@ -36,7 +36,7 @@ namespace ZicMoove.ViewModels.Messaging if (existent != null) { existent.UserName = item.UserName; existent.Roles = item.Roles; - existent.Avatar = item.Avatar; + existent.Avatar = item.UserName; existent.Connections = item.Connections; } else Add(item); diff --git a/ZicMoove/ZicMoove/ViewModels/Messaging/ChatViewModel.cs b/ZicMoove/ZicMoove/ViewModels/Messaging/ChatViewModel.cs index 28e29c05..8acbcde5 100644 --- a/ZicMoove/ZicMoove/ViewModels/Messaging/ChatViewModel.cs +++ b/ZicMoove/ZicMoove/ViewModels/Messaging/ChatViewModel.cs @@ -51,7 +51,7 @@ namespace ZicMoove.ViewModels.Messaging // by assigning a server side username to anonymous. if (string.IsNullOrEmpty(userName)) { - msg.SenderId = $"({cxId})"; + msg.SenderId = $"[{cxId}]"; } Notifs.Add(msg); if (eventId == "connected") diff --git a/ZicMoove/ZicMoove/ViewModels/UserProfile/DashboardViewModel.cs b/ZicMoove/ZicMoove/ViewModels/UserProfile/DashboardViewModel.cs index 3e3eac7a..fea3cce0 100644 --- a/ZicMoove/ZicMoove/ViewModels/UserProfile/DashboardViewModel.cs +++ b/ZicMoove/ZicMoove/ViewModels/UserProfile/DashboardViewModel.cs @@ -13,6 +13,7 @@ namespace ZicMoove.ViewModels.UserProfile using Helpers; using Model.Auth.Account; using Pages.UserProfile; + using Settings; using System.Threading.Tasks; internal class DashboardViewModel : ViewModel @@ -200,7 +201,7 @@ namespace ZicMoove.ViewModels.UserProfile newQueriesButtonText = newUserIsPro ? $"{newQueryCount} demandes valides en cours" : "Profile professionel non renseigné"; - newAvatar = UserHelpers.Avatar(user.Avatar); + newAvatar = UserHelpers.Avatar(user.UserName); } SetProperty(ref haveAnUser, userIsNull, "HaveAnUser"); SetProperty(ref userIsPro, newUserIsPro, "UserIsPro"); diff --git a/ZicMoove/ZicMoove/ViewModels/UserProfile/UserProfileViewModel.cs b/ZicMoove/ZicMoove/ViewModels/UserProfile/UserProfileViewModel.cs index c32e851c..d69b2d73 100644 --- a/ZicMoove/ZicMoove/ViewModels/UserProfile/UserProfileViewModel.cs +++ b/ZicMoove/ZicMoove/ViewModels/UserProfile/UserProfileViewModel.cs @@ -197,7 +197,7 @@ namespace ZicMoove.ViewModels.UserProfile newQueriesButtonText = newUserIsPro ? $"{newQueryCount} demandes valides en cours" : "Profile professionel non renseigné"; - newAvatar = UserHelpers.Avatar(user.Avatar); + newAvatar = UserHelpers.Avatar(user.UserName); } SetProperty(ref haveAnUser, newHaveAnUser, "HaveAnUser"); SetProperty(ref performerStatus, newStatusString, "PerformerStatus"); diff --git a/ZicMoove/ZicMoove/ZicMoove.csproj b/ZicMoove/ZicMoove/ZicMoove.csproj index 930b129f..e19d161d 100644 --- a/ZicMoove/ZicMoove/ZicMoove.csproj +++ b/ZicMoove/ZicMoove/ZicMoove.csproj @@ -53,6 +53,7 @@ + @@ -78,6 +79,7 @@ SearchPage.xaml +