diff --git a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj
index 9903e7bc..84e16c22 100644
--- a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj
+++ b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj
@@ -333,6 +333,7 @@
+
@@ -351,6 +352,8 @@
+
+
diff --git a/BookAStar/BookAStar.Droid/Interfaces/IGCMessageHandler.cs b/BookAStar/BookAStar.Droid/Interfaces/IGCMessageHandler.cs
new file mode 100644
index 00000000..910347ae
--- /dev/null
+++ b/BookAStar/BookAStar.Droid/Interfaces/IGCMessageHandler.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Android.App;
+using Android.Content;
+using Android.OS;
+using Android.Runtime;
+using Android.Views;
+using Android.Widget;
+
+namespace BookAStar.Droid.Interfaces
+{
+ interface IGCMessageHandler
+ {
+ void Handle( string from, Bundle data);
+ }
+}
\ No newline at end of file
diff --git a/BookAStar/BookAStar.Droid/Services/GCMHandlers/BookQueryGCMHandler.cs b/BookAStar/BookAStar.Droid/Services/GCMHandlers/BookQueryGCMHandler.cs
new file mode 100644
index 00000000..d5168faa
--- /dev/null
+++ b/BookAStar/BookAStar.Droid/Services/GCMHandlers/BookQueryGCMHandler.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Android.App;
+using Android.Content;
+using Android.OS;
+using Android.Runtime;
+using Android.Views;
+using Android.Widget;
+using BookAStar.Droid.Interfaces;
+using Newtonsoft.Json;
+using BookAStar.Model.Social;
+using BookAStar.Data;
+using BookAStar.Model;
+
+namespace BookAStar.Droid.Services.GCMHandlers
+{
+ class BookQueryGCMHandler : GCMessageHandler
+ {
+ public BookQueryGCMHandler(Context context,
+ NotificationManager manager,
+ Notification.Builder builder) : base(context,manager,builder)
+ {
+
+ }
+
+ public override void Handle(string from, Bundle data)
+ {
+ var locationJson = data.GetString("Location");
+ var location = JsonConvert.DeserializeObject(locationJson);
+ var cid = long.Parse(data.GetString("Id"));
+ var clientJson = data.GetString("Client");
+ var client = JsonConvert.DeserializeObject(clientJson);
+ var bq = new BookQuery
+ {
+ Id = cid,
+ Location = location,
+ Client = client,
+ Reason = data.GetString("Reason")
+ };
+ var dateString = data.GetString("EventDate");
+ DateTime evDate;
+ if (DateTime.TryParse(dateString, out evDate))
+ {
+ bq.EventDate = evDate;
+ }
+ SendBookQueryNotification(bq);
+ }
+
+ void SendBookQueryNotification(BookQuery bquery)
+ {
+ DataManager.Instance.BookQueries.Merge(bquery);
+ var bookquerynotifications = DataManager.Instance.BookQueries.Where(
+ q => !q.Read && q.EventDate > DateTime.Now
+ ).ToArray();
+ var count = bookquerynotifications.Length;
+ var multiple = count > 1;
+ var title =
+ multiple ? $"{count} demandes" : bquery.Client.UserName;
+ var message = $"{bquery.EventDate} {bquery.Client.UserName} {bquery.Location.Address}\n {bquery.Reason}";
+
+ var intent = new Intent(context, typeof(MainActivity));
+ intent.AddFlags(ActivityFlags.ClearTop);
+ intent.PutExtra("BookQueryId", bquery.Id);
+
+ var pendingIntent = PendingIntent.GetActivity(context, 0, intent, PendingIntentFlags.OneShot);
+ Notification.InboxStyle inboxStyle = new Notification.InboxStyle();
+ int maxil = 5;
+ for (int cn = 0; cn < count && cn < maxil; cn++)
+ {
+ inboxStyle.AddLine(bookquerynotifications[cn].Client.UserName);
+ }
+ if (count > maxil)
+ inboxStyle.SetSummaryText($"Plus {count - maxil} autres");
+ else inboxStyle.SetSummaryText((string)null);
+ notificationBuilder.SetContentTitle(title).SetContentText(message)
+ .SetStyle(inboxStyle)
+ .SetContentIntent(pendingIntent);
+
+ var notification = notificationBuilder.Build();
+ notificationManager.Notify(bookQueryNotificationId, notification);
+ }
+
+ int bookQueryNotificationId = 1;
+ }
+}
diff --git a/BookAStar/BookAStar.Droid/Services/GCMHandlers/GCMessageHandler.cs b/BookAStar/BookAStar.Droid/Services/GCMHandlers/GCMessageHandler.cs
new file mode 100644
index 00000000..de9c0e6f
--- /dev/null
+++ b/BookAStar/BookAStar.Droid/Services/GCMHandlers/GCMessageHandler.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Android.App;
+using Android.Content;
+using Android.OS;
+using Android.Runtime;
+using Android.Views;
+using Android.Widget;
+using BookAStar.Droid.Interfaces;
+
+namespace BookAStar.Droid.Services.GCMHandlers
+{
+ abstract class GCMessageHandler : IGCMessageHandler
+ {
+ protected Context context;
+ protected NotificationManager notificationManager;
+ protected Notification.Builder notificationBuilder;
+ public GCMessageHandler(Context context,
+ NotificationManager notificationManager,
+ Notification.Builder notificationBuilder)
+ {
+ this.context = context;
+ this.notificationBuilder = notificationBuilder;
+ this.notificationManager = notificationManager;
+ }
+
+ public abstract void Handle(string from, Bundle data);
+ }
+}
\ No newline at end of file
diff --git a/BookAStar/BookAStar.Droid/Services/GcmListenerService.cs b/BookAStar/BookAStar.Droid/Services/GcmListenerService.cs
index 83df3daa..e8648d5a 100644
--- a/BookAStar/BookAStar.Droid/Services/GcmListenerService.cs
+++ b/BookAStar/BookAStar.Droid/Services/GcmListenerService.cs
@@ -1,17 +1,20 @@
+
+using Android.App;
+using Android.Content;
+using Android.OS;
+using Android.Gms.Gcm;
+using Newtonsoft.Json;
using System;
+using System.Collections.Generic;
+using System.Linq;
namespace BookAStar.Droid.Services
{
- using Android.App;
- using Android.Content;
- using Android.OS;
- using Android.Gms.Gcm;
using Model.Social;
- using Newtonsoft.Json;
using Model;
- using Model.Social;
using Data;
- using System.Linq;
+ using Interfaces;
+ using GCMHandlers;
namespace ClientApp
{
@@ -21,7 +24,7 @@ namespace BookAStar.Droid.Services
private Notification.Builder notificationBuilder;
NotificationManager notificationManager;
-
+ Dictionary Handlers;
public override void OnCreate()
{
base.OnCreate();
@@ -29,7 +32,10 @@ namespace BookAStar.Droid.Services
.SetSmallIcon(Resource.Drawable.icon)
.SetAutoCancel(true);
notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
-
+ Handlers = new Dictionary
+ {
+ {"BookQuery", new BookQueryGCMHandler(this,notificationManager,notificationBuilder) }
+ };
}
public override void OnDestroy()
@@ -44,39 +50,16 @@ namespace BookAStar.Droid.Services
public override void OnMessageReceived(string from, Bundle data)
{
var topic = data.GetString("Topic");
- if (topic == "BookQuery")
+ if (Handlers.ContainsKey(topic))
{
- DateTime eventdate;
- var sdatestr = data.GetString("EventDate");
- DateTime.TryParse(sdatestr, out eventdate);
-
- var locationJson = data.GetString("Location");
- var location = JsonConvert.DeserializeObject(locationJson);
- var cid = long.Parse(data.GetString("Id"));
- var clientJson = data.GetString("Client");
- var client = JsonConvert.DeserializeObject(clientJson);
- var bq = new BookQuery
- {
- Id = cid,
- Location = location,
- Client = client,
- Reason = data.GetString("Reason")
- };
- var dateString = data.GetString("EventDate");
- DateTime evDate;
- if (DateTime.TryParse(dateString, out evDate))
- {
- bq.EventDate = evDate;
- }
-
- SendBookQueryNotification(bq);
+ Handlers[topic].Handle(from, data);
}
else
{
throw new NotImplementedException(topic);
}
}
-
+ /* TODO cleaning
void SendNotification(string title, string message)
{
var intent = new Intent(this, typeof(MainActivity));
@@ -92,43 +75,8 @@ namespace BookAStar.Droid.Services
.SetContentIntent(pendingIntent);
notificationManager.Notify(0, notificationBuilder.Build());
- }
-
- void SendBookQueryNotification(BookQuery bquery)
- {
- DataManager.Instance.BookQueries.Merge(bquery);
- var bookquerynotifications = DataManager.Instance.BookQueries.Where(
- q=> ! q.Read && q.EventDate > DateTime.Now
- ).ToArray();
- var count = bookquerynotifications.Length;
- var multiple = count > 1;
- var title =
- multiple ? $"{count} demandes" : bquery.Client.UserName;
- var message = $"{bquery.EventDate} {bquery.Client.UserName} {bquery.Location.Address}\n {bquery.Reason}";
-
- var intent = new Intent(this, typeof(MainActivity));
- intent.AddFlags(ActivityFlags.ClearTop);
- intent.PutExtra("BookQueryId", bquery.Id);
-
- var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
- Notification.InboxStyle inboxStyle = new Notification.InboxStyle();
- int maxil = 5;
- for (int cn = 0; cn < count && cn < maxil; cn++)
- {
- inboxStyle.AddLine(bookquerynotifications[cn].Client.UserName);
- }
- if (count > maxil)
- inboxStyle.SetSummaryText($"Plus {count - maxil} autres");
- else inboxStyle.SetSummaryText((string)null);
- notificationBuilder.SetContentTitle(title).SetContentText(message)
- .SetStyle(inboxStyle)
- .SetContentIntent(pendingIntent);
-
- var notification = notificationBuilder.Build();
- notificationManager.Notify(bookQueryNotificationId, notification );
- }
-
- int bookQueryNotificationId=1;
+ }*/
}
+
}
}
\ No newline at end of file
diff --git a/BookAStar/BookAStar/BookAStar.csproj b/BookAStar/BookAStar/BookAStar.csproj
index 1687641c..a18bdd2d 100644
--- a/BookAStar/BookAStar/BookAStar.csproj
+++ b/BookAStar/BookAStar/BookAStar.csproj
@@ -166,7 +166,7 @@
-
+
diff --git a/BookAStar/BookAStar/Model/Booking/BookQuery.cs b/BookAStar/BookAStar/Model/Booking/BookQuery.cs
index 67721c49..a40eb9d7 100644
--- a/BookAStar/BookAStar/Model/Booking/BookQuery.cs
+++ b/BookAStar/BookAStar/Model/Booking/BookQuery.cs
@@ -5,12 +5,38 @@ namespace BookAStar.Model.Social
{
public class BookQuery
{
+ ///
+ /// Client having made this book query.
+ ///
public ClientProviderInfo Client { get; set; }
+ ///
+ /// Location of the client event
+ ///
public Location Location { get; set; }
+ ///
+ /// Unique identifier
+ ///
public long Id { get; set; }
+ ///
+ /// Date of the client event
+ ///
public DateTime EventDate { get; set; }
+ ///
+ /// Amount of money already available, from the site bank, for this event project.
+ ///
public decimal? Previsionnal { get; set; }
+ ///
+ /// Given reason from the client
+ ///
public string Reason { get; set; }
+ ///
+ /// True when the query has been read.
+ ///
public bool Read { get; set; }
+ ///
+ /// Unique identifier of the activity concerned,
+ /// the context of this query.
+ ///
+ public string ActivityCode { get; set; }
}
}
diff --git a/BookAStar/BookAStar/Model/Workflow/BillingLine.cs b/BookAStar/BookAStar/Pages/EstimatePages/BillingLine.cs
similarity index 100%
rename from BookAStar/BookAStar/Model/Workflow/BillingLine.cs
rename to BookAStar/BookAStar/Pages/EstimatePages/BillingLine.cs
diff --git a/BookAStar/BookAStar/Pages/EstimatePages/EditEstimatePage.xaml.cs b/BookAStar/BookAStar/Pages/EstimatePages/EditEstimatePage.xaml.cs
index 163d8b12..a8f7ef58 100644
--- a/BookAStar/BookAStar/Pages/EstimatePages/EditEstimatePage.xaml.cs
+++ b/BookAStar/BookAStar/Pages/EstimatePages/EditEstimatePage.xaml.cs
@@ -115,8 +115,9 @@ namespace BookAStar.Pages
Strings.CancelValidation, new string[] { Strings.Sign });
if (response == Strings.Sign)
{
- App.NavigationService.NavigateTo(true,
- new EstimateSigningViewModel(evm.Data) { ValidationCommand = cmd });
+ App.NavigationService.NavigateTo(true,
+ new EstimateSigningViewModel(evm.Data) { ValidationCommand = cmd,
+ IsProviderView = true });
}
else if (response == Strings.CancelValidation)
return;
diff --git a/BookAStar/BookAStar/ViewModels/Signing/EstimateSigningViewModel.cs b/BookAStar/BookAStar/ViewModels/Signing/EstimateSigningViewModel.cs
index 20989946..e615d55a 100644
--- a/BookAStar/BookAStar/ViewModels/Signing/EstimateSigningViewModel.cs
+++ b/BookAStar/BookAStar/ViewModels/Signing/EstimateSigningViewModel.cs
@@ -9,13 +9,16 @@ namespace BookAStar.ViewModels.Signing
public EstimateSigningViewModel(Estimate document): base(document)
{
}
+
public Command ValidationCommand { get; set; }
+
public ImageSource ProSignImage {
get
{
return new FileImageSource();
}
}
+
public ImageSource CliSignImage
{
get
@@ -23,5 +26,43 @@ namespace BookAStar.ViewModels.Signing
return new FileImageSource();
}
}
+
+ private bool isClientView=false;
+
+ public bool IsClientView {
+ get
+ {
+ return isClientView;
+ }
+ set {
+ bool old = isClientView;
+ SetProperty(ref isClientView, value);
+ if (old!=value)
+ {
+ if (value != !isProviderView)
+ IsProviderView = !value;
+ }
+ }
+ }
+
+ private bool isProviderView=true;
+
+ public bool IsProviderView
+ {
+ get
+ {
+ return isProviderView;
+ }
+ set
+ {
+ bool old = isProviderView;
+ SetProperty(ref isProviderView, value);
+ if (old != value)
+ {
+ if (value != !isClientView)
+ IsClientView = !value;
+ }
+ }
+ }
}
}