Merge branch 'vnext' of github.com:pazof/yavsc into vnext

vnext
Paul Schneider 8 years ago
commit 16afaad765
33 changed files with 701 additions and 221 deletions

@ -484,6 +484,12 @@
<ItemGroup> <ItemGroup>
<AndroidResource Include="Resources\drawable\chat_icon_s.png" /> <AndroidResource Include="Resources\drawable\chat_icon_s.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\exclam.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\peer_to_peer.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>

@ -84,7 +84,6 @@ namespace Yavsc.Helpers
public async Task<JsonValue> InvokeJson(object query) public async Task<JsonValue> InvokeJson(object query)
{ {
JsonValue jsonDoc=null; JsonValue jsonDoc=null;
using (Stream streamQuery = request.GetRequestStream()) { using (Stream streamQuery = request.GetRequestStream()) {
using (StreamWriter writer = new StreamWriter(streamQuery)) { using (StreamWriter writer = new StreamWriter(streamQuery)) {

@ -21,7 +21,7 @@
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<!-- <data android:mimeType="text/plain" /> --> <data android:mimeType="*/*" />
</intent-filter> </intent-filter>
<meta-data android:name="android.service.chooser.chooser_target_service" android:value="fr.pschneider.bas.YavscChooserTargetService" /> <meta-data android:name="android.service.chooser.chooser_target_service" android:value="fr.pschneider.bas.YavscChooserTargetService" />
</activity> </activity>

@ -4160,310 +4160,316 @@ namespace BookAStar.Droid
public const int design_snackbar_background = 2130837625; public const int design_snackbar_background = 2130837625;
// aapt resource value: 0x7f02007a // aapt resource value: 0x7f02007a
public const int glyphish_07_map_marker = 2130837626; public const int exclam = 2130837626;
// aapt resource value: 0x7f02007b // aapt resource value: 0x7f02007b
public const int glyphish_103_map = 2130837627; public const int glyphish_07_map_marker = 2130837627;
// aapt resource value: 0x7f02007c // aapt resource value: 0x7f02007c
public const int glyphish_13_target = 2130837628; public const int glyphish_103_map = 2130837628;
// aapt resource value: 0x7f02007d // aapt resource value: 0x7f02007d
public const int glyphish_74_location = 2130837629; public const int glyphish_13_target = 2130837629;
// aapt resource value: 0x7f02007e // aapt resource value: 0x7f02007e
public const int gmf_icon = 2130837630; public const int glyphish_74_location = 2130837630;
// aapt resource value: 0x7f02007f // aapt resource value: 0x7f02007f
public const int ic_action_full_screen = 2130837631; public const int gmf_icon = 2130837631;
// aapt resource value: 0x7f020080 // aapt resource value: 0x7f020080
public const int ic_action_overflow = 2130837632; public const int ic_action_full_screen = 2130837632;
// aapt resource value: 0x7f020081 // aapt resource value: 0x7f020081
public const int ic_action_pause = 2130837633; public const int ic_action_overflow = 2130837633;
// aapt resource value: 0x7f020082 // aapt resource value: 0x7f020082
public const int ic_action_pause_large = 2130837634; public const int ic_action_pause = 2130837634;
// aapt resource value: 0x7f020083 // aapt resource value: 0x7f020083
public const int ic_action_play = 2130837635; public const int ic_action_pause_large = 2130837635;
// aapt resource value: 0x7f020084 // aapt resource value: 0x7f020084
public const int ic_action_play_large = 2130837636; public const int ic_action_play = 2130837636;
// aapt resource value: 0x7f020085 // 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 // aapt resource value: 0x7f020086
public const int ic_audiotrack = 2130837638; public const int ic_action_return_from_full_screen = 2130837638;
// aapt resource value: 0x7f020087 // aapt resource value: 0x7f020087
public const int ic_audiotrack_light = 2130837639; public const int ic_audiotrack = 2130837639;
// aapt resource value: 0x7f020088 // aapt resource value: 0x7f020088
public const int ic_bluetooth_grey = 2130837640; public const int ic_audiotrack_light = 2130837640;
// aapt resource value: 0x7f020089 // aapt resource value: 0x7f020089
public const int ic_bluetooth_white = 2130837641; public const int ic_bluetooth_grey = 2130837641;
// aapt resource value: 0x7f02008a // aapt resource value: 0x7f02008a
public const int ic_cast_dark = 2130837642; public const int ic_bluetooth_white = 2130837642;
// aapt resource value: 0x7f02008b // aapt resource value: 0x7f02008b
public const int ic_cast_disabled_light = 2130837643; public const int ic_cast_dark = 2130837643;
// aapt resource value: 0x7f02008c // aapt resource value: 0x7f02008c
public const int ic_cast_grey = 2130837644; public const int ic_cast_disabled_light = 2130837644;
// aapt resource value: 0x7f02008d // aapt resource value: 0x7f02008d
public const int ic_cast_light = 2130837645; public const int ic_cast_grey = 2130837645;
// aapt resource value: 0x7f02008e // aapt resource value: 0x7f02008e
public const int ic_cast_off_light = 2130837646; public const int ic_cast_light = 2130837646;
// aapt resource value: 0x7f02008f // 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 // 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 // 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 // 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 // aapt resource value: 0x7f020093
public const int ic_cast_white = 2130837651; public const int ic_cast_on_light = 2130837651;
// aapt resource value: 0x7f020094 // aapt resource value: 0x7f020094
public const int ic_close_dark = 2130837652; public const int ic_cast_white = 2130837652;
// aapt resource value: 0x7f020095 // aapt resource value: 0x7f020095
public const int ic_close_light = 2130837653; public const int ic_close_dark = 2130837653;
// aapt resource value: 0x7f020096 // aapt resource value: 0x7f020096
public const int ic_collapse = 2130837654; public const int ic_close_light = 2130837654;
// aapt resource value: 0x7f020097 // aapt resource value: 0x7f020097
public const int ic_collapse_00000 = 2130837655; public const int ic_collapse = 2130837655;
// aapt resource value: 0x7f020098 // aapt resource value: 0x7f020098
public const int ic_collapse_00001 = 2130837656; public const int ic_collapse_00000 = 2130837656;
// aapt resource value: 0x7f020099 // aapt resource value: 0x7f020099
public const int ic_collapse_00002 = 2130837657; public const int ic_collapse_00001 = 2130837657;
// aapt resource value: 0x7f02009a // aapt resource value: 0x7f02009a
public const int ic_collapse_00003 = 2130837658; public const int ic_collapse_00002 = 2130837658;
// aapt resource value: 0x7f02009b // aapt resource value: 0x7f02009b
public const int ic_collapse_00004 = 2130837659; public const int ic_collapse_00003 = 2130837659;
// aapt resource value: 0x7f02009c // aapt resource value: 0x7f02009c
public const int ic_collapse_00005 = 2130837660; public const int ic_collapse_00004 = 2130837660;
// aapt resource value: 0x7f02009d // aapt resource value: 0x7f02009d
public const int ic_collapse_00006 = 2130837661; public const int ic_collapse_00005 = 2130837661;
// aapt resource value: 0x7f02009e // aapt resource value: 0x7f02009e
public const int ic_collapse_00007 = 2130837662; public const int ic_collapse_00006 = 2130837662;
// aapt resource value: 0x7f02009f // aapt resource value: 0x7f02009f
public const int ic_collapse_00008 = 2130837663; public const int ic_collapse_00007 = 2130837663;
// aapt resource value: 0x7f0200a0 // aapt resource value: 0x7f0200a0
public const int ic_collapse_00009 = 2130837664; public const int ic_collapse_00008 = 2130837664;
// aapt resource value: 0x7f0200a1 // aapt resource value: 0x7f0200a1
public const int ic_collapse_00010 = 2130837665; public const int ic_collapse_00009 = 2130837665;
// aapt resource value: 0x7f0200a2 // aapt resource value: 0x7f0200a2
public const int ic_collapse_00011 = 2130837666; public const int ic_collapse_00010 = 2130837666;
// aapt resource value: 0x7f0200a3 // aapt resource value: 0x7f0200a3
public const int ic_collapse_00012 = 2130837667; public const int ic_collapse_00011 = 2130837667;
// aapt resource value: 0x7f0200a4 // aapt resource value: 0x7f0200a4
public const int ic_collapse_00013 = 2130837668; public const int ic_collapse_00012 = 2130837668;
// aapt resource value: 0x7f0200a5 // aapt resource value: 0x7f0200a5
public const int ic_collapse_00014 = 2130837669; public const int ic_collapse_00013 = 2130837669;
// aapt resource value: 0x7f0200a6 // aapt resource value: 0x7f0200a6
public const int ic_collapse_00015 = 2130837670; public const int ic_collapse_00014 = 2130837670;
// aapt resource value: 0x7f0200a7 // aapt resource value: 0x7f0200a7
public const int ic_corp_icon = 2130837671; public const int ic_collapse_00015 = 2130837671;
// aapt resource value: 0x7f0200a8 // aapt resource value: 0x7f0200a8
public const int ic_expand = 2130837672; public const int ic_corp_icon = 2130837672;
// aapt resource value: 0x7f0200a9 // aapt resource value: 0x7f0200a9
public const int ic_expand_00000 = 2130837673; public const int ic_expand = 2130837673;
// aapt resource value: 0x7f0200aa // aapt resource value: 0x7f0200aa
public const int ic_expand_00001 = 2130837674; public const int ic_expand_00000 = 2130837674;
// aapt resource value: 0x7f0200ab // aapt resource value: 0x7f0200ab
public const int ic_expand_00002 = 2130837675; public const int ic_expand_00001 = 2130837675;
// aapt resource value: 0x7f0200ac // aapt resource value: 0x7f0200ac
public const int ic_expand_00003 = 2130837676; public const int ic_expand_00002 = 2130837676;
// aapt resource value: 0x7f0200ad // aapt resource value: 0x7f0200ad
public const int ic_expand_00004 = 2130837677; public const int ic_expand_00003 = 2130837677;
// aapt resource value: 0x7f0200ae // aapt resource value: 0x7f0200ae
public const int ic_expand_00005 = 2130837678; public const int ic_expand_00004 = 2130837678;
// aapt resource value: 0x7f0200af // aapt resource value: 0x7f0200af
public const int ic_expand_00006 = 2130837679; public const int ic_expand_00005 = 2130837679;
// aapt resource value: 0x7f0200b0 // aapt resource value: 0x7f0200b0
public const int ic_expand_00007 = 2130837680; public const int ic_expand_00006 = 2130837680;
// aapt resource value: 0x7f0200b1 // aapt resource value: 0x7f0200b1
public const int ic_expand_00008 = 2130837681; public const int ic_expand_00007 = 2130837681;
// aapt resource value: 0x7f0200b2 // aapt resource value: 0x7f0200b2
public const int ic_expand_00009 = 2130837682; public const int ic_expand_00008 = 2130837682;
// aapt resource value: 0x7f0200b3 // aapt resource value: 0x7f0200b3
public const int ic_expand_00010 = 2130837683; public const int ic_expand_00009 = 2130837683;
// aapt resource value: 0x7f0200b4 // aapt resource value: 0x7f0200b4
public const int ic_expand_00011 = 2130837684; public const int ic_expand_00010 = 2130837684;
// aapt resource value: 0x7f0200b5 // aapt resource value: 0x7f0200b5
public const int ic_expand_00012 = 2130837685; public const int ic_expand_00011 = 2130837685;
// aapt resource value: 0x7f0200b6 // aapt resource value: 0x7f0200b6
public const int ic_expand_00013 = 2130837686; public const int ic_expand_00012 = 2130837686;
// aapt resource value: 0x7f0200b7 // aapt resource value: 0x7f0200b7
public const int ic_expand_00014 = 2130837687; public const int ic_expand_00013 = 2130837687;
// aapt resource value: 0x7f0200b8 // aapt resource value: 0x7f0200b8
public const int ic_expand_00015 = 2130837688; public const int ic_expand_00014 = 2130837688;
// aapt resource value: 0x7f0200b9 // aapt resource value: 0x7f0200b9
public const int ic_launcher = 2130837689; public const int ic_expand_00015 = 2130837689;
// aapt resource value: 0x7f0200ba // aapt resource value: 0x7f0200ba
public const int ic_media_pause = 2130837690; public const int ic_launcher = 2130837690;
// aapt resource value: 0x7f0200bb // aapt resource value: 0x7f0200bb
public const int ic_media_play = 2130837691; public const int ic_media_pause = 2130837691;
// aapt resource value: 0x7f0200bc // 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 // 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 // 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 // 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 // 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 // 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 // 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 // aapt resource value: 0x7f0200c3
public const int ic_pause_light = 2130837699; public const int ic_pause_dark = 2130837699;
// aapt resource value: 0x7f0200c4 // aapt resource value: 0x7f0200c4
public const int ic_play_dark = 2130837700; public const int ic_pause_light = 2130837700;
// aapt resource value: 0x7f0200c5 // aapt resource value: 0x7f0200c5
public const int ic_play_light = 2130837701; public const int ic_play_dark = 2130837701;
// aapt resource value: 0x7f0200c6 // aapt resource value: 0x7f0200c6
public const int ic_speaker_dark = 2130837702; public const int ic_play_light = 2130837702;
// aapt resource value: 0x7f0200c7 // aapt resource value: 0x7f0200c7
public const int ic_speaker_group_dark = 2130837703; public const int ic_speaker_dark = 2130837703;
// aapt resource value: 0x7f0200c8 // aapt resource value: 0x7f0200c8
public const int ic_speaker_group_light = 2130837704; public const int ic_speaker_group_dark = 2130837704;
// aapt resource value: 0x7f0200c9 // aapt resource value: 0x7f0200c9
public const int ic_speaker_light = 2130837705; public const int ic_speaker_group_light = 2130837705;
// aapt resource value: 0x7f0200ca // aapt resource value: 0x7f0200ca
public const int ic_tv_dark = 2130837706; public const int ic_speaker_light = 2130837706;
// aapt resource value: 0x7f0200cb // aapt resource value: 0x7f0200cb
public const int ic_tv_light = 2130837707; public const int ic_tv_dark = 2130837707;
// aapt resource value: 0x7f0200cc // aapt resource value: 0x7f0200cc
public const int icon = 2130837708; public const int ic_tv_light = 2130837708;
// aapt resource value: 0x7f0200cd // aapt resource value: 0x7f0200cd
public const int icon_anon = 2130837709; public const int icon = 2130837709;
// aapt resource value: 0x7f0200ce // aapt resource value: 0x7f0200ce
public const int mr_dialog_material_background_dark = 2130837710; public const int icon_anon = 2130837710;
// aapt resource value: 0x7f0200cf // 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 // 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 // aapt resource value: 0x7f0200d1
public const int mr_ic_cast_dark = 2130837713; public const int mr_ic_audiotrack_light = 2130837713;
// aapt resource value: 0x7f0200d2 // aapt resource value: 0x7f0200d2
public const int mr_ic_cast_light = 2130837714; public const int mr_ic_cast_dark = 2130837714;
// aapt resource value: 0x7f0200d3 // aapt resource value: 0x7f0200d3
public const int mr_ic_close_dark = 2130837715; public const int mr_ic_cast_light = 2130837715;
// aapt resource value: 0x7f0200d4 // aapt resource value: 0x7f0200d4
public const int mr_ic_close_light = 2130837716; public const int mr_ic_close_dark = 2130837716;
// aapt resource value: 0x7f0200d5 // 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 // 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 // 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 // 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 // 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 // aapt resource value: 0x7f0200da
public const int mr_ic_pause_light = 2130837722; public const int mr_ic_pause_dark = 2130837722;
// aapt resource value: 0x7f0200db // aapt resource value: 0x7f0200db
public const int mr_ic_play_dark = 2130837723; public const int mr_ic_pause_light = 2130837723;
// aapt resource value: 0x7f0200dc // aapt resource value: 0x7f0200dc
public const int mr_ic_play_light = 2130837724; public const int mr_ic_play_dark = 2130837724;
// aapt resource value: 0x7f0200dd // 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 // aapt resource value: 0x7f0200df
public const int notification_template_icon_bg = 2130837727; public const int peer_to_peer = 2130837727;
// aapt resource value: 0x7f0200de // aapt resource value: 0x7f0200e0
public const int visuel_sexion = 2130837726; public const int visuel_sexion = 2130837728;
static Drawable() static Drawable()
{ {

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

@ -32,7 +32,7 @@ namespace BookAStar.Droid
Resource.Drawable.icon); Resource.Drawable.icon);
ChooserTarget t = new ChooserTarget( ChooserTarget t = new ChooserTarget(
new Java.Lang.String( new Java.Lang.String(
"BookingStar"), i, Constants.ApplicationName), i,
.5f, new ComponentName(this, "BookAStar.SendFilesActivity"), .5f, new ComponentName(this, "BookAStar.SendFilesActivity"),
null); null);
var res = new List<ChooserTarget>(); var res = new List<ChooserTarget>();

@ -12,12 +12,16 @@ using XLabs.Enums;
namespace BookAStar namespace BookAStar
{ {
using System.Threading.Tasks;
using Data; using Data;
using Interfaces; using Interfaces;
using Model; using Model;
using Model.UI; using Model.UI;
using Pages; using Pages;
using Plugin.Connectivity;
using ViewModels; using ViewModels;
using Microsoft.AspNet.SignalR.Client;
using Model.Social.Messaging;
public partial class App : Application // superclass new in 1.3 public partial class App : Application // superclass new in 1.3
{ {
@ -53,6 +57,14 @@ namespace BookAStar
app.Rotation += OnRotation; app.Rotation += OnRotation;
app.Startup += OnStartup; app.Startup += OnStartup;
app.Suspended += OnSuspended; app.Suspended += OnSuspended;
MainSettings.UserChanged += MainSettings_UserChanged;
CrossConnectivity.Current.ConnectivityChanged += (conSender, args) =>
{
App.IsConnected = args.IsConnected;
};
SetupHubConnection();
if (CrossConnectivity.Current.IsConnected)
StartHubConnection();
} }
// omg // omg
@ -67,7 +79,7 @@ namespace BookAStar
} }
// Called Once, at app init // FIXME Never called.
private void OnInitialize(object sender, EventArgs e) private void OnInitialize(object sender, EventArgs e)
{ {
@ -225,11 +237,90 @@ namespace BookAStar
} }
public static INavigationService NavigationService { protected set; get; } public static INavigationService NavigationService { protected set; get; }
public static bool isConnected;
public static bool IsConnected { get { return isConnected; }
private set
{
if (isConnected != value)
{
isConnected = value;
if (isConnected)
{
// 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 ()
{
await chatHubConnection.Start();
}
public void SetupHubConnection()
{
chatHubConnection = new HubConnection(Constants.SignalRHubsUrl);
chatHubConnection.Error += ChatHubConnection_Error;
chatHubProxy = chatHubConnection.CreateHubProxy("ChatHub");
chatHubProxy.On<string, string>("PV", (n, m) => {
DataManager.Current.PrivateMessages.Add(
new UserMessage
{
Message = m,
SenderId = n,
Date = DateTime.Now
}
);
});
}
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<bool> HasSomeCloud {
get
{
return CrossConnectivity.Current.IsReachable(Constants.YavscHomeUrl, Constants.CloudTimeout);
}
}
public void PostDeviceInfo() public void PostDeviceInfo()
{ {
var res = PlatformSpecificInstance.InvokeApi( var info = PlatformSpecificInstance.GetDeviceInfo();
"gcm/register", if (!string.IsNullOrWhiteSpace(info.GCMRegistrationId))
PlatformSpecificInstance.GetDeviceInfo()); PlatformSpecificInstance.InvokeApi("gcm/register", info);
} }
public static void ShowBookQuery (BookQueryData query) public static void ShowBookQuery (BookQueryData query)

@ -26,8 +26,8 @@ namespace BookAStar.Behaviors
private void bindable_TextChanged(object sender, TextChangedEventArgs e) private void bindable_TextChanged(object sender, TextChangedEventArgs e)
{ {
IsValid = e.NewTextValue.Length <= 0 || e.NewTextValue.Length <= MaxLength; IsValid = e.NewTextValue == null? false : ( e.NewTextValue.Length > 0 && e.NewTextValue.Length <= MaxLength ) ;
if (!IsValid && e.NewTextValue.Length > MaxLength) if (!IsValid) if (e.NewTextValue!=null) if (e.NewTextValue.Length > MaxLength)
((Editor)sender).Text = e.NewTextValue.Substring(0, MaxLength); ((Editor)sender).Text = e.NewTextValue.Substring(0, MaxLength);
} }

@ -49,7 +49,10 @@
<Compile Include="Behaviors\StarBehavior.cs" /> <Compile Include="Behaviors\StarBehavior.cs" />
<Compile Include="Constants.cs" /> <Compile Include="Constants.cs" />
<Compile Include="Data\LocalState.cs" /> <Compile Include="Data\LocalState.cs" />
<Compile Include="Model\Social\Messaging\ChatStatus.cs" />
<Compile Include="Model\Social\Messaging\PrivateMessage.cs" />
<Compile Include="Model\UI\PageState.cs" /> <Compile Include="Model\UI\PageState.cs" />
<Compile Include="Settings\ChatSettings.cs" />
<Compile Include="ViewModels\EditingViewModel.cs" /> <Compile Include="ViewModels\EditingViewModel.cs" />
<Compile Include="Views\EnumPicker.cs" /> <Compile Include="Views\EnumPicker.cs" />
<Compile Include="Converters\BooleanToObjectConverter.cs" /> <Compile Include="Converters\BooleanToObjectConverter.cs" />
@ -97,7 +100,7 @@
<Compile Include="Pages\EventDetail.xaml.cs"> <Compile Include="Pages\EventDetail.xaml.cs">
<DependentUpon>EventDetail.xaml</DependentUpon> <DependentUpon>EventDetail.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Helpers\MainSettings.cs" /> <Compile Include="Settings\MainSettings.cs" />
<Compile Include="Data\RemoteEntity.cs" /> <Compile Include="Data\RemoteEntity.cs" />
<Compile Include="Interfaces\IPlatform.cs" /> <Compile Include="Interfaces\IPlatform.cs" />
<Compile Include="Model\Blog\Blog.cs" /> <Compile Include="Model\Blog\Blog.cs" />
@ -166,6 +169,9 @@
<Compile Include="Views\RatingView.xaml.cs"> <Compile Include="Views\RatingView.xaml.cs">
<DependentUpon>RatingView.xaml</DependentUpon> <DependentUpon>RatingView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\UserListView.xaml.cs">
<DependentUpon>UserListView.xaml</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="App.xaml"> <EmbeddedResource Include="App.xaml">
@ -218,6 +224,12 @@
<Reference Include="Newtonsoft.Json"> <Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath> <HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="Plugin.Connectivity">
<HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.12\lib\MonoAndroid10\Plugin.Connectivity.dll</HintPath>
</Reference>
<Reference Include="Plugin.Connectivity.Abstractions">
<HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.12\lib\MonoAndroid10\Plugin.Connectivity.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Plugin.Settings, Version=2.5.1.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Plugin.Settings, Version=2.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Xam.Plugins.Settings.2.5.1.0\lib\portable-net45+wp80+win8+wpa81\Plugin.Settings.dll</HintPath> <HintPath>..\..\packages\Xam.Plugins.Settings.2.5.1.0\lib\portable-net45+wp80+win8+wpa81\Plugin.Settings.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -358,6 +370,12 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Images\Chat\chat_icon_s.png" /> <EmbeddedResource Include="Images\Chat\chat_icon_s.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\UserListView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" /> <Import Project="..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

@ -19,11 +19,13 @@ namespace BookAStar
public static readonly string UserInfoUrl = YavscApiUrl + "/me"; public static readonly string UserInfoUrl = YavscApiUrl + "/me";
public static readonly string BlogUrl = YavscApiUrl + "/blogs"; public static readonly string BlogUrl = YavscApiUrl + "/blogs";
public static readonly string FsUrl = YavscApiUrl + "/fs"; public static readonly string FsUrl = YavscApiUrl + "/fs";
public static readonly string SignalRHubsUrl = YavscHomeUrl + "/signalr/hubs"; public static readonly string SignalRHubsUrl = YavscHomeUrl + "/api/signalr/hubs";
#endregion #endregion
#region Permissions ids #region Permissions ids
public static int AllowBeATarget = 1; public static int AllowBeATarget = 1;
#endregion #endregion
public static int CloudTimeout = 400;
} }
} }

@ -5,6 +5,7 @@
using Model.Workflow; using Model.Workflow;
using Model.UI; using Model.UI;
using ViewModels; using ViewModels;
using Model.Social.Messaging;
public class DataManager public class DataManager
{ {
@ -19,7 +20,7 @@
/// </summary> /// </summary>
internal LocalEntity<EditEstimateViewModel, long> EstimationCache { get; set; } internal LocalEntity<EditEstimateViewModel, long> EstimationCache { get; set; }
internal LocalEntity<BillingLine, string> EstimateLinesTemplates { get; set; } internal LocalEntity<BillingLine, string> EstimateLinesTemplates { get; set; }
internal LocalEntity<UserMessage, int> PrivateMessages { get; set; }
protected static DataManager current ; protected static DataManager current ;
public static DataManager Current public static DataManager Current
@ -34,18 +35,16 @@
public DataManager() public DataManager()
{ {
BookQueries = new RemoteEntityRO<BookQueryData, long>("bookquery", BookQueries = new RemoteEntityRO<BookQueryData, long>("bookquery", q => q.Id);
q => q.Id); Estimates = new RemoteEntity<Estimate, long>("estimate", x => x.Id);
Estimates = new RemoteEntity<Estimate, long>("estimate", Blogspot = new RemoteEntity<Blog, long>("blog", x=>x.Id);
x => x.Id);
Blogspot = new RemoteEntity<Blog, long>("blog",
x=>x.Id);
Contacts = new LocalEntity<ClientProviderInfo, string>(c => c.UserId); Contacts = new LocalEntity<ClientProviderInfo, string>(c => c.UserId);
AppState = new LocalEntity<PageState, int>(s => s.Position); AppState = new LocalEntity<PageState, int>(s => s.Position);
EstimationCache = new LocalEntity<EditEstimateViewModel, long>( EstimationCache = new LocalEntity<EditEstimateViewModel, long>(e => e.Query.Id);
e => e.Query.Id); EstimateLinesTemplates = new LocalEntity<BillingLine, string>(l => l.Description);
EstimateLinesTemplates = new LocalEntity<BillingLine, string>( PrivateMessages = new LocalEntity<UserMessage, int>(m=> m.GetHashCode());
l => l.Description);
PrivateMessages.Load();
BookQueries.Load(); BookQueries.Load();
Estimates.Load(); Estimates.Load();
Blogspot.Load(); Blogspot.Load();

@ -14,7 +14,9 @@ namespace BookAStar.Data
public LocalEntity(Func<V, K> getKey) : base() public LocalEntity(Func<V, K> getKey) : base()
{ {
if (getKey == null) throw new InvalidOperationException(); if (getKey == null)
// choose please, because of the genesis
throw new InvalidOperationException ("A key must be defined");
GetKey = getKey; GetKey = getKey;
IList<V> l = this; IList<V> l = this;
} }

@ -9,6 +9,7 @@ using System.Net;
namespace BookAStar.Data namespace BookAStar.Data
{ {
using Helpers; using Helpers;
using System.Diagnostics;
using System.Text; using System.Text;
public class RemoteEntity<V, K> : LocalEntity<V, K>, ICommand where K : IEquatable<K> public class RemoteEntity<V, K> : LocalEntity<V, K>, ICommand where K : IEquatable<K>
@ -79,7 +80,7 @@ namespace BookAStar.Data
private void AfterExecuting() private void AfterExecuting()
{ {
IsExecuting = false; IsExecuting = false;
if (CanExecuteChanged!=null) if (CanExecuteChanged != null)
CanExecuteChanged.Invoke(this, new EventArgs()); CanExecuteChanged.Invoke(this, new EventArgs());
} }
@ -134,19 +135,24 @@ namespace BookAStar.Data
{ {
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
var errcontent = await response.Content.ReadAsStringAsync();
// TODO throw custom exception, and catch to inform user // TODO throw custom exception, and catch to inform user
throw new Exception($"Create failed posting {stringContent} @ {controllerUri.AbsoluteUri}"); var errcontent = await response.Content.ReadAsStringAsync();
Debug.WriteLine($"Create failed posting {stringContent} @ {controllerUri.AbsoluteUri}");
}
else
{
var recontent = await response.Content.ReadAsStringAsync();
JsonSerializerSettings sett = new JsonSerializerSettings();
JsonConvert.PopulateObject(recontent, item);
} }
var recontent = await response.Content.ReadAsStringAsync();
JsonConvert.PopulateObject(recontent, item);
} }
} }
CurrentItem = item; CurrentItem = item;
AfterExecuting(); AfterExecuting();
} }
public async void Update (V item) public async void Update(V item)
{ {
BeforeExecute(); BeforeExecute();
@ -154,13 +160,27 @@ namespace BookAStar.Data
using (HttpClient client = UserHelpers.CreateClient()) using (HttpClient client = UserHelpers.CreateClient())
{ {
HttpContent content = new StringContent( HttpContent content = new StringContent(
JsonConvert.SerializeObject(item) JsonConvert.SerializeObject(item), Encoding.UTF8, "application/json"
); );
using (var response = await client.PutAsync(uri, content)) using (var response = await client.PutAsync(uri, content))
{ {
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
// TODO throw custom exception, and catch to inform user {// TODO throw custom exception, and catch to inform user
throw new Exception($"Update failed puting {item} @ {uri.AbsolutePath}"); if (response.StatusCode == HttpStatusCode.BadRequest)
{
var recontent = await response.Content.ReadAsStringAsync();
}
else Debug.WriteLine($"Update failed ({item} @ {uri.AbsolutePath} )");
}
else
{
// TODO implement an handler of string content (json)
// in most of cases, nothing to do
var recontent = await response.Content.ReadAsStringAsync();
JsonConvert.PopulateObject(recontent, item);
}
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

@ -25,5 +25,9 @@ namespace BookAStar.Model
return UserHelpers.Avatar(Avatar); return UserHelpers.Avatar(Avatar);
} }
} }
public override string ToString()
{
return UserName;
}
} }
} }

@ -0,0 +1,10 @@
namespace BookAStar.Model.Workflow.Messaging
{
public enum ChatStatus
{
OnLine,
Away,
OffLine
}
}

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BookAStar.Model.Social.Messaging
{
public class UserMessage
{
public DateTime Date { get; set; }
public string SenderId { get; set; }
public string Message { get; set; }
}
}

@ -6,6 +6,7 @@ namespace BookAStar.Model.Workflow
{ {
public class BillingLine : IBillingLine public class BillingLine : IBillingLine
{ {
public long Id { get; set; }
public string Description { get; set; } public string Description { get; set; }
public TimeSpan Duration { get; set; } public TimeSpan Duration { get; set; }
public int Count { get; set; } = 1; public int Count { get; set; } = 1;

@ -26,9 +26,8 @@
<Label Text="{Binding Previsional}" /> <Label Text="{Binding Previsional}" />
</StackLayout> </StackLayout>
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" > <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
<maps:Map x:Name="map" VerticalOptions="FillAndExpand"></maps:Map> <maps:Map x:Name="map" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"></maps:Map>
<Button Text="{Binding EditEstimateButtonText}" Clicked="OnEditEstimate" VerticalOptions="End"/>
<Button Text="{Binding EditEstimateButtonText}" Clicked="OnEditEstimate" />
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>
</ContentPage> </ContentPage>

@ -7,6 +7,7 @@ namespace BookAStar.Pages
using Data; using Data;
using Model; using Model;
using Model.Workflow; using Model.Workflow;
using System.Linq;
using ViewModels; using ViewModels;
public partial class BookQueryPage : ContentPage public partial class BookQueryPage : ContentPage
@ -57,23 +58,36 @@ namespace BookAStar.Pages
private void OnEditEstimate(object sender, EventArgs ev) private void OnEditEstimate(object sender, EventArgs ev)
{ {
var viewModel = ((BookQueryViewModel)BindingContext).DraftEstimate; var bookQueryViewModel = (BookQueryViewModel)BindingContext;
if (viewModel == null)
var editEstimateViewModel = bookQueryViewModel.DraftEstimate;
if (editEstimateViewModel == null)
{ {
DataManager.Current.Contacts.Merge(BookQuery.Client); // First search for an existing estimate
var e = new Estimate() var estimateToEdit = DataManager.Current.Estimates.FirstOrDefault(
estimate=> estimate.CommandId == bookQueryViewModel.Id
);
if (estimateToEdit == null)
{ {
ClientId = BookQuery.Client.UserId, DataManager.Current.Contacts.Merge(BookQuery.Client);
CommandId = BookQuery.Id, DataManager.Current.Contacts.SaveCollection();
OwnerId = MainSettings.CurrentUser.Id, estimateToEdit = new Estimate()
Id = 0, {
Description = "# **Hello Estimate!**" ClientId = BookQuery.Client.UserId,
}; CommandId = BookQuery.Id,
viewModel = new EditEstimateViewModel(e, LocalState.New); OwnerId = MainSettings.CurrentUser.Id,
DataManager.Current.EstimationCache.Add(viewModel); Id = 0,
Description = "# **Hello Estimate!**"
};
editEstimateViewModel = new EditEstimateViewModel(estimateToEdit, LocalState.New);
}
else
editEstimateViewModel = new EditEstimateViewModel(estimateToEdit, LocalState.UpToDate);
DataManager.Current.EstimationCache.Add(editEstimateViewModel);
} }
App.NavigationService.NavigateTo<EditEstimatePage>(true, App.NavigationService.NavigateTo<EditEstimatePage>(true,
viewModel); editEstimateViewModel);
} }
protected override void OnSizeAllocated(double width, double height) protected override void OnSizeAllocated(double width, double height)

@ -1,22 +1,96 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Pages.ChatPage" x:Class="BookAStar.Pages.ChatPage"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
xmlns:toolkit="clr-namespace:XLabs.Forms.Mvvm;assembly=XLabs.Forms"
> >
<TabbedPage.Children>
<StackLayout Padding="5, 5, 5, 5"> <ContentPage Title="Public" Icon="chat_icon_s.png" >
<StackLayout Spacing = "12" <StackLayout Padding="5, 5, 5, 5">
Orientation = "Horizontal" <StackLayout Spacing = "12"
Padding="5, 0, 5, 0"> Orientation = "Horizontal"
<Entry x:Name="messageEntry" Placeholder = "enter your Message" Padding="5, 0, 5, 0">
VerticalOptions = "Center" <Entry x:Name="messageEntry" Placeholder = "enter your Message"
HorizontalOptions = "FillAndExpand"></Entry> VerticalOptions = "Center"
<Button x:Name="sendButton" Text = "Send" HorizontalOptions = "End" HorizontalOptions = "FillAndExpand"></Entry>
VerticalOptions = "Center"></Button> <Button x:Name="sendButton" Text = "Send" HorizontalOptions = "End"
VerticalOptions = "Center"></Button>
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" /> </StackLayout>
<ListView x:Name="messageList" HasUnevenRows="true">
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand">
<Label Text="{Binding Date, StringFormat='{0:HH:mm}'}" FontAttributes="Italic" />
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
<BoxView WidthRequest="1" HeightRequest="15" Color="#000090"/>
<Label Text="{Binding Message}" FontFamily="monospace" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
<ContentPage Title="Notifications" Icon="exclam.png" >
<StackLayout Padding="5, 5, 5, 5">
<ListView x:Name="notifList" HasUnevenRows="true">
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand">
<Label Text="{Binding Date, StringFormat='{0:hh:mm}'}" FontAttributes="Italic" />
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
<BoxView Color="#000090" WidthRequest="1" HeightRequest="15" />
<Label Text="{Binding Message}" FontFamily="monospace" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
<ContentPage Title="Contacts" Icon="peer_to_peer.png" >
<StackLayout Padding="5, 5, 5, 5">
<StackLayout Spacing = "12"
Orientation = "Horizontal"
Padding="5, 0, 5, 0">
<Entry x:Name="pvEntry" Placeholder = "enter your private message"
VerticalOptions = "Center"
HorizontalOptions = "FillAndExpand"></Entry>
<!--
<controls:ExtendedPicker x:Name="contactPicker" Display="{Binding UserName}"></controls:ExtendedPicker>
-->
<controls:ExtendedPicker x:Name="contactPicker" />
<Button x:Name="sendPVButton" Text = "Send" HorizontalOptions = "End"
VerticalOptions = "Center"></Button>
</StackLayout>
<ListView x:Name="PVList" HasUnevenRows="true">
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand">
<Label Text="{Binding Date, StringFormat='{0:hh:mm}'}" FontAttributes="Italic" />
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
<BoxView Color="#000090" WidthRequest="1" HeightRequest="15" />
<Label Text="{Binding Message}" FontFamily="monospace" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!-- <views:UserListView ItemsSource="" /> -->
</StackLayout> </StackLayout>
<ListView x:Name="messageList"></ListView>
</StackLayout> </ContentPage>
</ContentPage> </TabbedPage.Children>
</TabbedPage>

@ -1,54 +1,83 @@
using Microsoft.AspNet.SignalR.Client; using BookAStar.Data;
using BookAStar.Model.Social.Messaging;
using Microsoft.AspNet.SignalR.Client;
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Caching;
using XLabs.Forms.Controls;
using XLabs.Ioc;
namespace BookAStar.Pages namespace BookAStar.Pages
{ {
public partial class ChatPage : ContentPage public partial class ChatPage : TabbedPage
{ {
public ObservableCollection<string> Messages { get; set; } public ObservableCollection<UserMessage> Messages { get; set; }
public string ChatUser { get; set; } public string ChatUser { get; set; }
private HubConnection chatHubConnection;
private IHubProxy chatHubProxy;
public ChatPage() public ChatPage()
{ {
InitializeComponent(); InitializeComponent();
Title = "Chat"; Title = "Chat";
sendButton.Clicked += async (sender, args) => { sendButton.Clicked += async (sender, args) =>
{
IsBusy = true; IsBusy = true;
try try
{ {
await chatHubProxy.Invoke<string>("Send", ChatUser, messageEntry.Text); await App.CurrentApp.ChatHubProxy.Invoke<string>("Send", ChatUser, messageEntry.Text);
messageEntry.Text = null;
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine(ex); Debug.WriteLine(ex);
} }
IsBusy = false; IsBusy = false;
}; };
messageList.ItemsSource = Messages = new ObservableCollection<string>(); // contactPicker.DisplayProperty = "UserName";
messageList.ItemsSource = Messages = new ObservableCollection<UserMessage>();
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<string, string>("addMessage", (n, m) =>
{
Messages.Add(new UserMessage
{
Message = m,
SenderId = n,
Date = DateTime.Now
});
});
App.CurrentApp.ChatHubProxy.On<string, string>("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; ChatUser = MainSettings.UserName;
chatHubConnection = new HubConnection(Constants.SignalRHubsUrl); contactPicker.ItemsSource = DataManager.Current.Contacts;
chatHubProxy = chatHubConnection.CreateHubProxy("ChatHub"); }
chatHubProxy.On<string, string>("AddMessage", (n, m) => {
Messages.Add(string.Format("{0} says: {1}", n, m)); private void ChatHubConnection_StateChanged(StateChange obj)
}); {
await chatHubConnection.Start(); sendButton.IsEnabled = obj.NewState == ConnectionState.Connected;
IsBusy = false;
sendButton.IsEnabled = true;
} }
} }
} }

@ -93,8 +93,10 @@
Path=IsValid, Path=IsValid,
Converter={StaticResource boolToStyleImage}}" /> Converter={StaticResource boolToStyleImage}}" />
</StackLayout> </StackLayout>
<Button Text="Términé"
<Button Text="Valider cette ligne de devis" Command="{Binding DeleteCommand}"
Clicked="OnValidateClicked"></Button>
<Button Text="Términé"
Command="{Binding ValidateCommand}" Command="{Binding ValidateCommand}"
Clicked="OnValidateClicked"></Button> Clicked="OnValidateClicked"></Button>
</StackLayout> </StackLayout>

@ -21,5 +21,11 @@ namespace BookAStar.Pages
{ {
this.Navigation.PopAsync(); this.Navigation.PopAsync();
} }
protected override bool OnBackButtonPressed()
{
var bvm = (BillingLineViewModel)BindingContext;
bvm.ValidateCommand?.Execute(null);
return base.OnBackButtonPressed();
}
} }
} }

@ -40,7 +40,7 @@
<StackLayout x:Name="biAnVaLayout"> <StackLayout x:Name="biAnVaLayout">
<ListView x:Name="BillListView" ItemsSource="{Binding Bill}" <ListView x:Name="BillListView" ItemsSource="{Binding Bill}"
MinimumHeightRequest="40" HasUnevenRows="true" VerticalOptions="FillAndExpand" MinimumHeightRequest="40" HasUnevenRows="true" VerticalOptions="FillAndExpand"
HeightRequest="40"> HeightRequest="40" ItemTapped="OnEditLine">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate > <DataTemplate >
<ViewCell> <ViewCell>

@ -14,6 +14,7 @@ namespace BookAStar.Pages
InitializeComponent(); InitializeComponent();
BindingContext = model; BindingContext = model;
} }
protected override void OnBindingContextChanged() protected override void OnBindingContextChanged()
{ {
base.OnBindingContextChanged(); base.OnBindingContextChanged();
@ -41,17 +42,36 @@ namespace BookAStar.Pages
protected void OnNewCommanLine(object sender, EventArgs e) protected void OnNewCommanLine(object sender, EventArgs e)
{ {
var com = new BillingLine() { Count = 1, UnitaryCost = 0.01m }; var com = new BillingLine() { Count = 1, UnitaryCost = 0.01m };
var lineView = new BillingLineViewModel(com); var bill = ((EditEstimateViewModel)BindingContext).Bill;
var bill = var lineView = new BillingLineViewModel(com)
((EditEstimateViewModel)BindingContext).Bill; { ValidateCommand = new Command(() => {
bill.Add(com); bill.Add(com);
bill.SaveCollection(); bill.SaveCollection();
lineView.PropertyChanged += (s,f) => bill.SaveCollection(); })};
App.NavigationService.NavigateTo<EditBillingLinePage>( App.NavigationService.NavigateTo<EditBillingLinePage>(
true, true,
new object[] { lineView } ); new object[] { lineView } );
} }
protected void OnEditLine(object sender, ItemTappedEventArgs e)
{
var line = (BillingLine)e.Item;
var bill = ((EditEstimateViewModel)BindingContext).Bill;
var lineView = new BillingLineViewModel(line)
{
ValidateCommand = new Command(() => {
bill.SaveCollection();
})
};
lineView.PropertyChanged += LineView_PropertyChanged;
App.NavigationService.NavigateTo<EditBillingLinePage>(
true,
new object[] { lineView });
}
private void LineView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
DataManager.Current.EstimationCache.SaveCollection();
}
protected void OnEstimateValidated(object sender, EventArgs e) protected void OnEstimateValidated(object sender, EventArgs e)
{ {
@ -68,7 +88,9 @@ namespace BookAStar.Pages
DataManager.Current.Estimates.Update(evm.Data); DataManager.Current.Estimates.Update(evm.Data);
} }
DataManager.Current.Estimates.SaveCollection(); DataManager.Current.Estimates.SaveCollection();
evm.State = LocalState.UpToDate; DataManager.Current.EstimationCache.Remove(evm);
DataManager.Current.EstimationCache.SaveCollection();
Navigation.PopAsync();
} }
} }
} }

@ -0,0 +1,80 @@
using BookAStar.Model.Workflow.Messaging;
using Plugin.Settings;
using Plugin.Settings.Abstractions;
using System.Collections.Generic;
namespace BookAStar.Settings
{
public static class ChatSettings
{
public static ISettings AppSettings
{
get
{
return CrossSettings.Current;
}
}
private const string statusKey = "chat.status";
private const string ignoreListKey = "chat.ignoreList";
private const string denyAnonymousAccessKey = "chat.denyAnonymousAccess";
private const string denyTouristAccessKey = "chat.denyTouristAccess";
public static ChatStatus Status
{
get
{
return AppSettings.GetValueOrDefault<ChatStatus>(statusKey, ChatStatus.OffLine);
}
set
{
AppSettings.AddOrUpdateValue<ChatStatus>(statusKey, value);
}
}
public static List<string> IgnoreList
{
get
{
return AppSettings.GetValueOrDefault<List<string>>(ignoreListKey);
}
}
public static void Ignore(string userId)
{
var ignoreList = IgnoreList;
ignoreList.Add(userId);
AppSettings.AddOrUpdateValue(ignoreListKey, ignoreList);
}
public static void UnIgnore(string userId)
{
var ignoreList = IgnoreList;
ignoreList.Remove(userId);
AppSettings.AddOrUpdateValue(ignoreListKey, ignoreList);
}
public static void UnIgnoreAll()
{
var ignoreList = new List<string>();
AppSettings.AddOrUpdateValue(ignoreListKey, ignoreList);
}
public static bool DenyAnonymousAccess
{
get
{
return AppSettings.GetValueOrDefault<bool>(denyAnonymousAccessKey);
}
set
{
AppSettings.AddOrUpdateValue<bool>(denyAnonymousAccessKey, value);
}
}
public static bool DenyTouristAccess
{
get
{
return AppSettings.GetValueOrDefault<bool>(denyTouristAccessKey);
}
set
{
AppSettings.AddOrUpdateValue<bool>(denyTouristAccessKey, value);
}
}
}
}

@ -13,48 +13,57 @@ namespace BookAStar.ViewModels
{ {
BillingLine data; BillingLine data;
public BillingLineViewModel( BillingLine data) public BillingLineViewModel(BillingLine data)
{ {
this.data = data ?? new BillingLine(); this.data = data ?? new BillingLine();
// sets durationValue & durationUnit // sets durationValue & durationUnit
count = data.Count;
description = data.Description;
Duration = data.Duration; Duration = data.Duration;
unitaryCostText = data.UnitaryCost.ToString("G",CultureInfo.InvariantCulture); unitaryCostText = data.UnitaryCost.ToString("G", CultureInfo.InvariantCulture);
} }
private int count;
public int Count public int Count
{ {
get get
{ {
return data.Count; return count;
} }
set set
{ {
data.Count = value; SetProperty<int>(ref count, value);
data.Count = count;
} }
} }
private string description;
public string Description public string Description
{ {
get get
{ {
return data.Description; return description;
} }
set set
{ {
data.Description = value; SetProperty<string>(ref description, value);
data.Description = description;
} }
} }
decimal unitaryCost;
public decimal UnitaryCost public decimal UnitaryCost
{ {
get get
{ {
return data.UnitaryCost; return unitaryCost;
} }
set set
{ {
data.UnitaryCost = value; SetProperty<decimal>(ref unitaryCost, value);
data.UnitaryCost = unitaryCost;
} }
} }
@ -72,12 +81,12 @@ namespace BookAStar.ViewModels
data.Duration = this.Duration; data.Duration = this.Duration;
} }
} }
public enum DurationUnits:int public enum DurationUnits : int
{ {
Jours=0, Jours = 0,
Heures=1, Heures = 1,
Minutes=2 Minutes = 2
} }
private DurationUnits durationUnit; private DurationUnits durationUnit;
@ -85,17 +94,17 @@ namespace BookAStar.ViewModels
pour décrire la quantité de travail associée à ce type de service")] pour décrire la quantité de travail associée à ce type de service")]
public DurationUnits DurationUnit public DurationUnits DurationUnit
{ {
get { get
{
return durationUnit; return durationUnit;
} }
set set
{ {
SetProperty<DurationUnits>(ref durationUnit, value, "DurationUnit"); SetProperty<DurationUnits>(ref durationUnit, value, "DurationUnit");
data.Duration = this.Duration; data.Duration = this.Duration;
} }
} }
protected decimal unitaryCost;
public static readonly string unitCostFormat = "0,.00"; public static readonly string unitCostFormat = "0,.00";
string unitaryCostText; string unitaryCostText;
public string UnitaryCostText public string UnitaryCostText
@ -129,7 +138,7 @@ pour décrire la quantité de travail associée à ce type de service")]
case DurationUnits.Heures: case DurationUnits.Heures:
return new TimeSpan(DurationValue, 0, 0); return new TimeSpan(DurationValue, 0, 0);
case DurationUnits.Jours: case DurationUnits.Jours:
return new TimeSpan(DurationValue*24, 0, 0); return new TimeSpan(DurationValue * 24, 0, 0);
case DurationUnits.Minutes: case DurationUnits.Minutes:
return new TimeSpan(0, DurationValue, 0); return new TimeSpan(0, DurationValue, 0);
// Assert(false); since all units are treated bellow // Assert(false); since all units are treated bellow
@ -143,21 +152,21 @@ pour décrire la quantité de travail associée à ce type de service")]
double days = value.TotalDays; double days = value.TotalDays;
if (days >= 1.0) if (days >= 1.0)
{ {
DurationValue = (int) days; DurationValue = (int)days;
DurationUnit = DurationUnits.Jours; DurationUnit = DurationUnits.Jours;
return; return;
} }
double hours = value.TotalHours; double hours = value.TotalHours;
if (hours >= 1.0) if (hours >= 1.0)
{ {
DurationValue = (int) hours; DurationValue = (int)hours;
DurationUnit = DurationUnits.Jours; DurationUnit = DurationUnits.Jours;
return; return;
} }
DurationValue = (int) value.TotalMinutes; DurationValue = (int)value.TotalMinutes;
DurationUnit = DurationUnits.Minutes; DurationUnit = DurationUnits.Minutes;
} }
} }
} }
} }

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Views.UserListView"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar">
<ContentView.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</ContentView.Resources>
<ContentView.Content>
<ListView x:Name="list" ItemTapped="OnViewDetail" HasUnevenRows="true" RowHeight="80">
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" Padding="10,10,10,10" VerticalOptions="StartAndExpand">
<Image Source="{Binding AvatarOrNot}" Aspect="AspectFit" />
<Label Text="{Binding UserName}" />
<Label Text="{Binding EMail}" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentView.Content>
</ContentView>

@ -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();
}
}
}
Loading…