diff --git a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj
index d2f740a2..008e1262 100644
--- a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj
+++ b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj
@@ -484,6 +484,12 @@
+
+
+
+
+
+
diff --git a/BookAStar/BookAStar.Droid/Helpers/SimpleJsonPostMethod.cs b/BookAStar/BookAStar.Droid/Helpers/SimpleJsonPostMethod.cs
index dd826232..afc40072 100644
--- a/BookAStar/BookAStar.Droid/Helpers/SimpleJsonPostMethod.cs
+++ b/BookAStar/BookAStar.Droid/Helpers/SimpleJsonPostMethod.cs
@@ -84,7 +84,6 @@ namespace Yavsc.Helpers
public async Task InvokeJson(object query)
{
-
JsonValue jsonDoc=null;
using (Stream streamQuery = request.GetRequestStream()) {
using (StreamWriter writer = new StreamWriter(streamQuery)) {
diff --git a/BookAStar/BookAStar.Droid/Resources/Resource.Designer.cs b/BookAStar/BookAStar.Droid/Resources/Resource.Designer.cs
index 0e9e68a0..7be6d2f1 100644
--- a/BookAStar/BookAStar.Droid/Resources/Resource.Designer.cs
+++ b/BookAStar/BookAStar.Droid/Resources/Resource.Designer.cs
@@ -4160,310 +4160,316 @@ namespace BookAStar.Droid
public const int design_snackbar_background = 2130837625;
// aapt resource value: 0x7f02007a
- public const int glyphish_07_map_marker = 2130837626;
+ public const int exclam = 2130837626;
// aapt resource value: 0x7f02007b
- public const int glyphish_103_map = 2130837627;
+ public const int glyphish_07_map_marker = 2130837627;
// aapt resource value: 0x7f02007c
- public const int glyphish_13_target = 2130837628;
+ public const int glyphish_103_map = 2130837628;
// aapt resource value: 0x7f02007d
- public const int glyphish_74_location = 2130837629;
+ public const int glyphish_13_target = 2130837629;
// aapt resource value: 0x7f02007e
- public const int gmf_icon = 2130837630;
+ public const int glyphish_74_location = 2130837630;
// aapt resource value: 0x7f02007f
- public const int ic_action_full_screen = 2130837631;
+ public const int gmf_icon = 2130837631;
// aapt resource value: 0x7f020080
- public const int ic_action_overflow = 2130837632;
+ public const int ic_action_full_screen = 2130837632;
// aapt resource value: 0x7f020081
- public const int ic_action_pause = 2130837633;
+ public const int ic_action_overflow = 2130837633;
// aapt resource value: 0x7f020082
- public const int ic_action_pause_large = 2130837634;
+ public const int ic_action_pause = 2130837634;
// aapt resource value: 0x7f020083
- public const int ic_action_play = 2130837635;
+ public const int ic_action_pause_large = 2130837635;
// aapt resource value: 0x7f020084
- public const int ic_action_play_large = 2130837636;
+ public const int ic_action_play = 2130837636;
// aapt resource value: 0x7f020085
- public const int ic_action_return_from_full_screen = 2130837637;
+ public const int ic_action_play_large = 2130837637;
// aapt resource value: 0x7f020086
- public const int ic_audiotrack = 2130837638;
+ public const int ic_action_return_from_full_screen = 2130837638;
// aapt resource value: 0x7f020087
- public const int ic_audiotrack_light = 2130837639;
+ public const int ic_audiotrack = 2130837639;
// aapt resource value: 0x7f020088
- public const int ic_bluetooth_grey = 2130837640;
+ public const int ic_audiotrack_light = 2130837640;
// aapt resource value: 0x7f020089
- public const int ic_bluetooth_white = 2130837641;
+ public const int ic_bluetooth_grey = 2130837641;
// aapt resource value: 0x7f02008a
- public const int ic_cast_dark = 2130837642;
+ public const int ic_bluetooth_white = 2130837642;
// aapt resource value: 0x7f02008b
- public const int ic_cast_disabled_light = 2130837643;
+ public const int ic_cast_dark = 2130837643;
// aapt resource value: 0x7f02008c
- public const int ic_cast_grey = 2130837644;
+ public const int ic_cast_disabled_light = 2130837644;
// aapt resource value: 0x7f02008d
- public const int ic_cast_light = 2130837645;
+ public const int ic_cast_grey = 2130837645;
// aapt resource value: 0x7f02008e
- public const int ic_cast_off_light = 2130837646;
+ public const int ic_cast_light = 2130837646;
// aapt resource value: 0x7f02008f
- public const int ic_cast_on_0_light = 2130837647;
+ public const int ic_cast_off_light = 2130837647;
// aapt resource value: 0x7f020090
- public const int ic_cast_on_1_light = 2130837648;
+ public const int ic_cast_on_0_light = 2130837648;
// aapt resource value: 0x7f020091
- public const int ic_cast_on_2_light = 2130837649;
+ public const int ic_cast_on_1_light = 2130837649;
// aapt resource value: 0x7f020092
- public const int ic_cast_on_light = 2130837650;
+ public const int ic_cast_on_2_light = 2130837650;
// aapt resource value: 0x7f020093
- public const int ic_cast_white = 2130837651;
+ public const int ic_cast_on_light = 2130837651;
// aapt resource value: 0x7f020094
- public const int ic_close_dark = 2130837652;
+ public const int ic_cast_white = 2130837652;
// aapt resource value: 0x7f020095
- public const int ic_close_light = 2130837653;
+ public const int ic_close_dark = 2130837653;
// aapt resource value: 0x7f020096
- public const int ic_collapse = 2130837654;
+ public const int ic_close_light = 2130837654;
// aapt resource value: 0x7f020097
- public const int ic_collapse_00000 = 2130837655;
+ public const int ic_collapse = 2130837655;
// aapt resource value: 0x7f020098
- public const int ic_collapse_00001 = 2130837656;
+ public const int ic_collapse_00000 = 2130837656;
// aapt resource value: 0x7f020099
- public const int ic_collapse_00002 = 2130837657;
+ public const int ic_collapse_00001 = 2130837657;
// aapt resource value: 0x7f02009a
- public const int ic_collapse_00003 = 2130837658;
+ public const int ic_collapse_00002 = 2130837658;
// aapt resource value: 0x7f02009b
- public const int ic_collapse_00004 = 2130837659;
+ public const int ic_collapse_00003 = 2130837659;
// aapt resource value: 0x7f02009c
- public const int ic_collapse_00005 = 2130837660;
+ public const int ic_collapse_00004 = 2130837660;
// aapt resource value: 0x7f02009d
- public const int ic_collapse_00006 = 2130837661;
+ public const int ic_collapse_00005 = 2130837661;
// aapt resource value: 0x7f02009e
- public const int ic_collapse_00007 = 2130837662;
+ public const int ic_collapse_00006 = 2130837662;
// aapt resource value: 0x7f02009f
- public const int ic_collapse_00008 = 2130837663;
+ public const int ic_collapse_00007 = 2130837663;
// aapt resource value: 0x7f0200a0
- public const int ic_collapse_00009 = 2130837664;
+ public const int ic_collapse_00008 = 2130837664;
// aapt resource value: 0x7f0200a1
- public const int ic_collapse_00010 = 2130837665;
+ public const int ic_collapse_00009 = 2130837665;
// aapt resource value: 0x7f0200a2
- public const int ic_collapse_00011 = 2130837666;
+ public const int ic_collapse_00010 = 2130837666;
// aapt resource value: 0x7f0200a3
- public const int ic_collapse_00012 = 2130837667;
+ public const int ic_collapse_00011 = 2130837667;
// aapt resource value: 0x7f0200a4
- public const int ic_collapse_00013 = 2130837668;
+ public const int ic_collapse_00012 = 2130837668;
// aapt resource value: 0x7f0200a5
- public const int ic_collapse_00014 = 2130837669;
+ public const int ic_collapse_00013 = 2130837669;
// aapt resource value: 0x7f0200a6
- public const int ic_collapse_00015 = 2130837670;
+ public const int ic_collapse_00014 = 2130837670;
// aapt resource value: 0x7f0200a7
- public const int ic_corp_icon = 2130837671;
+ public const int ic_collapse_00015 = 2130837671;
// aapt resource value: 0x7f0200a8
- public const int ic_expand = 2130837672;
+ public const int ic_corp_icon = 2130837672;
// aapt resource value: 0x7f0200a9
- public const int ic_expand_00000 = 2130837673;
+ public const int ic_expand = 2130837673;
// aapt resource value: 0x7f0200aa
- public const int ic_expand_00001 = 2130837674;
+ public const int ic_expand_00000 = 2130837674;
// aapt resource value: 0x7f0200ab
- public const int ic_expand_00002 = 2130837675;
+ public const int ic_expand_00001 = 2130837675;
// aapt resource value: 0x7f0200ac
- public const int ic_expand_00003 = 2130837676;
+ public const int ic_expand_00002 = 2130837676;
// aapt resource value: 0x7f0200ad
- public const int ic_expand_00004 = 2130837677;
+ public const int ic_expand_00003 = 2130837677;
// aapt resource value: 0x7f0200ae
- public const int ic_expand_00005 = 2130837678;
+ public const int ic_expand_00004 = 2130837678;
// aapt resource value: 0x7f0200af
- public const int ic_expand_00006 = 2130837679;
+ public const int ic_expand_00005 = 2130837679;
// aapt resource value: 0x7f0200b0
- public const int ic_expand_00007 = 2130837680;
+ public const int ic_expand_00006 = 2130837680;
// aapt resource value: 0x7f0200b1
- public const int ic_expand_00008 = 2130837681;
+ public const int ic_expand_00007 = 2130837681;
// aapt resource value: 0x7f0200b2
- public const int ic_expand_00009 = 2130837682;
+ public const int ic_expand_00008 = 2130837682;
// aapt resource value: 0x7f0200b3
- public const int ic_expand_00010 = 2130837683;
+ public const int ic_expand_00009 = 2130837683;
// aapt resource value: 0x7f0200b4
- public const int ic_expand_00011 = 2130837684;
+ public const int ic_expand_00010 = 2130837684;
// aapt resource value: 0x7f0200b5
- public const int ic_expand_00012 = 2130837685;
+ public const int ic_expand_00011 = 2130837685;
// aapt resource value: 0x7f0200b6
- public const int ic_expand_00013 = 2130837686;
+ public const int ic_expand_00012 = 2130837686;
// aapt resource value: 0x7f0200b7
- public const int ic_expand_00014 = 2130837687;
+ public const int ic_expand_00013 = 2130837687;
// aapt resource value: 0x7f0200b8
- public const int ic_expand_00015 = 2130837688;
+ public const int ic_expand_00014 = 2130837688;
// aapt resource value: 0x7f0200b9
- public const int ic_launcher = 2130837689;
+ public const int ic_expand_00015 = 2130837689;
// aapt resource value: 0x7f0200ba
- public const int ic_media_pause = 2130837690;
+ public const int ic_launcher = 2130837690;
// aapt resource value: 0x7f0200bb
- public const int ic_media_play = 2130837691;
+ public const int ic_media_pause = 2130837691;
// aapt resource value: 0x7f0200bc
- public const int ic_media_route_disabled_mono_dark = 2130837692;
+ public const int ic_media_play = 2130837692;
// aapt resource value: 0x7f0200bd
- public const int ic_media_route_off_mono_dark = 2130837693;
+ public const int ic_media_route_disabled_mono_dark = 2130837693;
// aapt resource value: 0x7f0200be
- public const int ic_media_route_on_0_mono_dark = 2130837694;
+ public const int ic_media_route_off_mono_dark = 2130837694;
// aapt resource value: 0x7f0200bf
- public const int ic_media_route_on_1_mono_dark = 2130837695;
+ public const int ic_media_route_on_0_mono_dark = 2130837695;
// aapt resource value: 0x7f0200c0
- public const int ic_media_route_on_2_mono_dark = 2130837696;
+ public const int ic_media_route_on_1_mono_dark = 2130837696;
// aapt resource value: 0x7f0200c1
- public const int ic_media_route_on_mono_dark = 2130837697;
+ public const int ic_media_route_on_2_mono_dark = 2130837697;
// aapt resource value: 0x7f0200c2
- public const int ic_pause_dark = 2130837698;
+ public const int ic_media_route_on_mono_dark = 2130837698;
// aapt resource value: 0x7f0200c3
- public const int ic_pause_light = 2130837699;
+ public const int ic_pause_dark = 2130837699;
// aapt resource value: 0x7f0200c4
- public const int ic_play_dark = 2130837700;
+ public const int ic_pause_light = 2130837700;
// aapt resource value: 0x7f0200c5
- public const int ic_play_light = 2130837701;
+ public const int ic_play_dark = 2130837701;
// aapt resource value: 0x7f0200c6
- public const int ic_speaker_dark = 2130837702;
+ public const int ic_play_light = 2130837702;
// aapt resource value: 0x7f0200c7
- public const int ic_speaker_group_dark = 2130837703;
+ public const int ic_speaker_dark = 2130837703;
// aapt resource value: 0x7f0200c8
- public const int ic_speaker_group_light = 2130837704;
+ public const int ic_speaker_group_dark = 2130837704;
// aapt resource value: 0x7f0200c9
- public const int ic_speaker_light = 2130837705;
+ public const int ic_speaker_group_light = 2130837705;
// aapt resource value: 0x7f0200ca
- public const int ic_tv_dark = 2130837706;
+ public const int ic_speaker_light = 2130837706;
// aapt resource value: 0x7f0200cb
- public const int ic_tv_light = 2130837707;
+ public const int ic_tv_dark = 2130837707;
// aapt resource value: 0x7f0200cc
- public const int icon = 2130837708;
+ public const int ic_tv_light = 2130837708;
// aapt resource value: 0x7f0200cd
- public const int icon_anon = 2130837709;
+ public const int icon = 2130837709;
// aapt resource value: 0x7f0200ce
- public const int mr_dialog_material_background_dark = 2130837710;
+ public const int icon_anon = 2130837710;
// aapt resource value: 0x7f0200cf
- public const int mr_dialog_material_background_light = 2130837711;
+ public const int mr_dialog_material_background_dark = 2130837711;
// aapt resource value: 0x7f0200d0
- public const int mr_ic_audiotrack_light = 2130837712;
+ public const int mr_dialog_material_background_light = 2130837712;
// aapt resource value: 0x7f0200d1
- public const int mr_ic_cast_dark = 2130837713;
+ public const int mr_ic_audiotrack_light = 2130837713;
// aapt resource value: 0x7f0200d2
- public const int mr_ic_cast_light = 2130837714;
+ public const int mr_ic_cast_dark = 2130837714;
// aapt resource value: 0x7f0200d3
- public const int mr_ic_close_dark = 2130837715;
+ public const int mr_ic_cast_light = 2130837715;
// aapt resource value: 0x7f0200d4
- public const int mr_ic_close_light = 2130837716;
+ public const int mr_ic_close_dark = 2130837716;
// aapt resource value: 0x7f0200d5
- public const int mr_ic_media_route_connecting_mono_dark = 2130837717;
+ public const int mr_ic_close_light = 2130837717;
// aapt resource value: 0x7f0200d6
- public const int mr_ic_media_route_connecting_mono_light = 2130837718;
+ public const int mr_ic_media_route_connecting_mono_dark = 2130837718;
// aapt resource value: 0x7f0200d7
- public const int mr_ic_media_route_mono_dark = 2130837719;
+ public const int mr_ic_media_route_connecting_mono_light = 2130837719;
// aapt resource value: 0x7f0200d8
- public const int mr_ic_media_route_mono_light = 2130837720;
+ public const int mr_ic_media_route_mono_dark = 2130837720;
// aapt resource value: 0x7f0200d9
- public const int mr_ic_pause_dark = 2130837721;
+ public const int mr_ic_media_route_mono_light = 2130837721;
// aapt resource value: 0x7f0200da
- public const int mr_ic_pause_light = 2130837722;
+ public const int mr_ic_pause_dark = 2130837722;
// aapt resource value: 0x7f0200db
- public const int mr_ic_play_dark = 2130837723;
+ public const int mr_ic_pause_light = 2130837723;
// aapt resource value: 0x7f0200dc
- public const int mr_ic_play_light = 2130837724;
+ public const int mr_ic_play_dark = 2130837724;
// aapt resource value: 0x7f0200dd
- public const int nfqrcode = 2130837725;
+ public const int mr_ic_play_light = 2130837725;
+
+ // aapt resource value: 0x7f0200de
+ public const int nfqrcode = 2130837726;
+
+ // aapt resource value: 0x7f0200e1
+ public const int notification_template_icon_bg = 2130837729;
// aapt resource value: 0x7f0200df
- public const int notification_template_icon_bg = 2130837727;
+ public const int peer_to_peer = 2130837727;
- // aapt resource value: 0x7f0200de
- public const int visuel_sexion = 2130837726;
+ // aapt resource value: 0x7f0200e0
+ public const int visuel_sexion = 2130837728;
static Drawable()
{
diff --git a/BookAStar/BookAStar.Droid/Resources/drawable/nicubunu-Peer-to-peer.png b/BookAStar/BookAStar.Droid/Resources/drawable/peer_to_peer.png
similarity index 100%
rename from BookAStar/BookAStar.Droid/Resources/drawable/nicubunu-Peer-to-peer.png
rename to BookAStar/BookAStar.Droid/Resources/drawable/peer_to_peer.png
diff --git a/BookAStar/BookAStar/App.xaml.cs b/BookAStar/BookAStar/App.xaml.cs
index 7c40f614..e3e7dec3 100644
--- a/BookAStar/BookAStar/App.xaml.cs
+++ b/BookAStar/BookAStar/App.xaml.cs
@@ -21,6 +21,7 @@ namespace BookAStar
using Plugin.Connectivity;
using ViewModels;
using Microsoft.AspNet.SignalR.Client;
+ using Model.Social.Messaging;
public partial class App : Application // superclass new in 1.3
{
@@ -56,6 +57,14 @@ namespace BookAStar
app.Rotation += OnRotation;
app.Startup += OnStartup;
app.Suspended += OnSuspended;
+ MainSettings.UserChanged += MainSettings_UserChanged;
+ CrossConnectivity.Current.ConnectivityChanged += (conSender, args) =>
+ {
+ App.IsConnected = args.IsConnected;
+ };
+ SetupHubConnection();
+ if (CrossConnectivity.Current.IsConnected)
+ StartHubConnection();
}
// omg
@@ -70,13 +79,10 @@ namespace BookAStar
}
- // Called Once, at app init
+ // FIXME Never called.
private void OnInitialize(object sender, EventArgs e)
{
- CrossConnectivity.Current.ConnectivityChanged += (conSender, args) =>
- {
- App.IsConnected = args.IsConnected;
- };
+
}
// called on app startup, not on rotation
@@ -243,23 +249,33 @@ namespace BookAStar
// TODO Start all cloud related stuff
CurrentApp.StartHubConnection();
}
+
}
}
}
-
+ private HubConnection chatHubConnection = null;
+ public HubConnection ChatHubConnection
+ {
+ get
+ {
+ return chatHubConnection;
+ }
+ }
// Start the Hub connection
public async void StartHubConnection ()
{
- if (chatHubConnection != null)
- chatHubConnection.Dispose();
+ await chatHubConnection.Start();
+ }
+
+ public void SetupHubConnection()
+ {
chatHubConnection = new HubConnection(Constants.SignalRHubsUrl);
- if (MainSettings.CurrentUser != null)
- chatHubConnection.Headers.Add("Bearer", MainSettings.CurrentUser.YavscTokens.AccessToken);
-
+ chatHubConnection.Error += ChatHubConnection_Error;
+
chatHubProxy = chatHubConnection.CreateHubProxy("ChatHub");
chatHubProxy.On("PV", (n, m) => {
DataManager.Current.PrivateMessages.Add(
- new Model.Social.PrivateMessage
+ new UserMessage
{
Message = m,
SenderId = n,
@@ -267,11 +283,32 @@ namespace BookAStar
}
);
});
- await chatHubConnection.Start();
-
}
- private HubConnection chatHubConnection=null;
+
+ private void MainSettings_UserChanged(object sender, EventArgs e)
+ {
+ if (MainSettings.CurrentUser != null)
+ {
+ if (chatHubConnection.Headers.ContainsKey("Bearer"))
+ chatHubConnection.Headers.Remove("Bearer");
+ chatHubConnection.Headers.Add("Bearer", MainSettings.CurrentUser.YavscTokens.AccessToken);
+ }
+ else chatHubConnection.Headers.Remove("Bearer");
+ }
+
+ private void ChatHubConnection_Error(Exception obj)
+ {
+ // TODO log in debug binaries
+ }
+
private IHubProxy chatHubProxy = null;
+ public IHubProxy ChatHubProxy
+ {
+ get
+ {
+ return chatHubProxy;
+ }
+ }
public static Task HasSomeCloud {
get
{
@@ -281,9 +318,9 @@ namespace BookAStar
public void PostDeviceInfo()
{
- var res = PlatformSpecificInstance.InvokeApi(
- "gcm/register",
- PlatformSpecificInstance.GetDeviceInfo());
+ var info = PlatformSpecificInstance.GetDeviceInfo();
+ if (!string.IsNullOrWhiteSpace(info.GCMRegistrationId))
+ PlatformSpecificInstance.InvokeApi("gcm/register", info);
}
public static void ShowBookQuery (BookQueryData query)
diff --git a/BookAStar/BookAStar/BookAStar.csproj b/BookAStar/BookAStar/BookAStar.csproj
index 588e1398..9a7cf243 100644
--- a/BookAStar/BookAStar/BookAStar.csproj
+++ b/BookAStar/BookAStar/BookAStar.csproj
@@ -50,7 +50,7 @@
-
+
@@ -169,6 +169,9 @@
RatingView.xaml
+
+ UserListView.xaml
+
@@ -367,6 +370,12 @@
+
+
+ MSBuild:UpdateDesignTimeXaml
+ Designer
+
+
diff --git a/BookAStar/BookAStar/Data/DataManager.cs b/BookAStar/BookAStar/Data/DataManager.cs
index 4c67559e..a6c752ff 100644
--- a/BookAStar/BookAStar/Data/DataManager.cs
+++ b/BookAStar/BookAStar/Data/DataManager.cs
@@ -5,7 +5,7 @@
using Model.Workflow;
using Model.UI;
using ViewModels;
- using Model.Social;
+ using Model.Social.Messaging;
public class DataManager
{
@@ -20,7 +20,7 @@
///
internal LocalEntity EstimationCache { get; set; }
internal LocalEntity EstimateLinesTemplates { get; set; }
- internal LocalEntity PrivateMessages { get; set; }
+ internal LocalEntity PrivateMessages { get; set; }
protected static DataManager current ;
public static DataManager Current
@@ -42,7 +42,7 @@
AppState = new LocalEntity(s => s.Position);
EstimationCache = new LocalEntity(e => e.Query.Id);
EstimateLinesTemplates = new LocalEntity(l => l.Description);
- PrivateMessages = new LocalEntity(m=> m.GetHashCode());
+ PrivateMessages = new LocalEntity(m=> m.GetHashCode());
PrivateMessages.Load();
BookQueries.Load();
diff --git a/BookAStar/BookAStar/Model/ClientProviderInfo.cs b/BookAStar/BookAStar/Model/ClientProviderInfo.cs
index 21991bfa..07a04dc0 100644
--- a/BookAStar/BookAStar/Model/ClientProviderInfo.cs
+++ b/BookAStar/BookAStar/Model/ClientProviderInfo.cs
@@ -25,5 +25,9 @@ namespace BookAStar.Model
return UserHelpers.Avatar(Avatar);
}
}
+ public override string ToString()
+ {
+ return UserName;
+ }
}
}
diff --git a/BookAStar/BookAStar/Model/Social/PrivateMessage.cs b/BookAStar/BookAStar/Model/Social/Messaging/PrivateMessage.cs
similarity index 78%
rename from BookAStar/BookAStar/Model/Social/PrivateMessage.cs
rename to BookAStar/BookAStar/Model/Social/Messaging/PrivateMessage.cs
index 1fa633fd..8133a1f4 100644
--- a/BookAStar/BookAStar/Model/Social/PrivateMessage.cs
+++ b/BookAStar/BookAStar/Model/Social/Messaging/PrivateMessage.cs
@@ -4,9 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace BookAStar.Model.Social
+namespace BookAStar.Model.Social.Messaging
{
- class PrivateMessage
+ public class UserMessage
{
public DateTime Date { get; set; }
public string SenderId { get; set; }
diff --git a/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs b/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs
index 57173a3c..dbc0377f 100644
--- a/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs
+++ b/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs
@@ -70,6 +70,7 @@ namespace BookAStar.Pages
if (estimateToEdit == null)
{
DataManager.Current.Contacts.Merge(BookQuery.Client);
+ DataManager.Current.Contacts.SaveCollection();
estimateToEdit = new Estimate()
{
ClientId = BookQuery.Client.UserId,
diff --git a/BookAStar/BookAStar/Pages/ChatPage.xaml b/BookAStar/BookAStar/Pages/ChatPage.xaml
index 0a15c6b3..adbb5844 100644
--- a/BookAStar/BookAStar/Pages/ChatPage.xaml
+++ b/BookAStar/BookAStar/Pages/ChatPage.xaml
@@ -2,28 +2,95 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/BookAStar/BookAStar/Pages/ChatPage.xaml.cs b/BookAStar/BookAStar/Pages/ChatPage.xaml.cs
index 0d4ecc76..214a14f9 100644
--- a/BookAStar/BookAStar/Pages/ChatPage.xaml.cs
+++ b/BookAStar/BookAStar/Pages/ChatPage.xaml.cs
@@ -1,56 +1,83 @@
-using Microsoft.AspNet.SignalR.Client;
+using BookAStar.Data;
+using BookAStar.Model.Social.Messaging;
+using Microsoft.AspNet.SignalR.Client;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using Xamarin.Forms;
+using XLabs.Caching;
+using XLabs.Forms.Controls;
+using XLabs.Ioc;
namespace BookAStar.Pages
{
public partial class ChatPage : TabbedPage
{
- public ObservableCollection Messages { get; set; }
+ public ObservableCollection Messages { get; set; }
public string ChatUser { get; set; }
- private HubConnection chatHubConnection;
- private IHubProxy chatHubProxy;
-
public ChatPage()
{
InitializeComponent();
Title = "Chat";
- sendButton.Clicked += async (sender, args) => {
+ sendButton.Clicked += async (sender, args) =>
+ {
IsBusy = true;
try
{
- await chatHubProxy.Invoke("Send", ChatUser, messageEntry.Text);
+ await App.CurrentApp.ChatHubProxy.Invoke("Send", ChatUser, messageEntry.Text);
+ messageEntry.Text = null;
}
catch (Exception ex)
{
-
Debug.WriteLine(ex);
}
IsBusy = false;
};
- messageList.ItemsSource = Messages = new ObservableCollection();
+ // contactPicker.DisplayProperty = "UserName";
+
+ messageList.ItemsSource = Messages = new ObservableCollection();
+ PVList.ItemsSource = DataManager.Current.PrivateMessages;
+ App.CurrentApp.ChatHubConnection.StateChanged += ChatHubConnection_StateChanged;
+ // DataManager.Current.Contacts
+
+ MainSettings.UserChanged += MainSettings_UserChanged;
+ MainSettings_UserChanged(this, null);
+
+ App.CurrentApp.ChatHubProxy.On("addMessage", (n, m) =>
+ {
+ Messages.Add(new UserMessage
+ {
+ Message = m,
+ SenderId = n,
+ Date = DateTime.Now
+ });
+ });
+
+ App.CurrentApp.ChatHubProxy.On("addMessage", (n, m) =>
+ {
+ Messages.Add(new UserMessage
+ {
+ Message = m,
+ SenderId = n,
+ Date = DateTime.Now
+ });
+ });
}
- protected override async void OnAppearing()
+ private void MainSettings_UserChanged(object sender, EventArgs e)
{
- IsBusy = true;
- chatHubConnection = new HubConnection(Constants.SignalRHubsUrl);
-
- chatHubProxy = chatHubConnection.CreateHubProxy("ChatHub");
-
- chatHubProxy.On("AddMessage", (n, m) => {
- Messages.Add(string.Format("{0} says: {1}", n, m));
- });
- await chatHubConnection.Start();
- IsBusy = false;
- sendButton.IsEnabled = true;
+ ChatUser = MainSettings.UserName;
+ contactPicker.ItemsSource = DataManager.Current.Contacts;
+ }
+
+ private void ChatHubConnection_StateChanged(StateChange obj)
+ {
+ sendButton.IsEnabled = obj.NewState == ConnectionState.Connected;
}
}
}
diff --git a/BookAStar/BookAStar/Views/UserListView.xaml b/BookAStar/BookAStar/Views/UserListView.xaml
new file mode 100644
index 00000000..348aa1e3
--- /dev/null
+++ b/BookAStar/BookAStar/Views/UserListView.xaml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BookAStar/BookAStar/Views/UserListView.xaml.cs b/BookAStar/BookAStar/Views/UserListView.xaml.cs
new file mode 100644
index 00000000..18f5daac
--- /dev/null
+++ b/BookAStar/BookAStar/Views/UserListView.xaml.cs
@@ -0,0 +1,37 @@
+using BookAStar.Model;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+
+namespace BookAStar.Views
+{
+ public partial class UserListView : ContentView
+ {
+ public BindableProperty ItemsSourceProperty = BindableProperty.Create(
+ "ItemsSource", typeof(IEnumerable), typeof(UserListView));
+
+ public IEnumerable ItemsSource
+ {
+ get { return list.ItemsSource; }
+ set { list.ItemsSource = value; }
+ }
+
+ /* public IEnumerable ItemsSource
+ {
+ get { return GetValue(ItemsSourceProperty) as IEnumerable; }
+ set { SetValue(ItemsSourceProperty, value); }
+ }
+ */
+ public UserListView()
+ {
+ InitializeComponent();
+ }
+
+ }
+}