Merge branch 'vnext' of github.com:pazof/yavsc into vnext
This commit is contained in:
@ -333,6 +333,7 @@
|
||||
<Compile Include="Helpers\SimpleJsonPostMethod.cs" />
|
||||
<Compile Include="Helpers\YavscHelpers.cs" />
|
||||
<Compile Include="Html.cs" />
|
||||
<Compile Include="Interfaces\IGCMessageHandler.cs" />
|
||||
<Compile Include="MainActivity.cs" />
|
||||
<Compile Include="Markdown\JsBridgeMarkdown.cs" />
|
||||
<Compile Include="Markdown\MarkdownEditor.cs">
|
||||
@ -351,6 +352,8 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SendFilesActivity.cs" />
|
||||
<Compile Include="Services\AccountChooserService.cs" />
|
||||
<Compile Include="Services\GCMHandlers\BookQueryGCMHandler.cs" />
|
||||
<Compile Include="Services\GCMHandlers\GCMessageHandler.cs" />
|
||||
<Compile Include="Services\YavscChooserTargetService.cs" />
|
||||
<Compile Include="Services\GcmListenerService.cs" />
|
||||
<Compile Include="Services\GcmRegistrationIntentService.cs" />
|
||||
|
19
BookAStar/BookAStar.Droid/Interfaces/IGCMessageHandler.cs
Normal file
19
BookAStar/BookAStar.Droid/Interfaces/IGCMessageHandler.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
@ -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<Location>(locationJson);
|
||||
var cid = long.Parse(data.GetString("Id"));
|
||||
var clientJson = data.GetString("Client");
|
||||
var client = JsonConvert.DeserializeObject<ClientProviderInfo>(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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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<string, IGCMessageHandler> 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<string, IGCMessageHandler>
|
||||
{
|
||||
{"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<Location>(locationJson);
|
||||
var cid = long.Parse(data.GetString("Id"));
|
||||
var clientJson = data.GetString("Client");
|
||||
var client = JsonConvert.DeserializeObject<ClientProviderInfo>(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;
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -166,7 +166,7 @@
|
||||
<Compile Include="Model\Blog\BlogTag.cs" />
|
||||
<Compile Include="Model\Booking\BookQuery.cs" />
|
||||
<Compile Include="Model\Market\BaseProduct.cs" />
|
||||
<Compile Include="Model\Workflow\BillingLine.cs" />
|
||||
<Compile Include="Pages\EstimatePages\BillingLine.cs" />
|
||||
<Compile Include="Model\Manager.cs" />
|
||||
<Compile Include="Model\Auth\MobileAppDeclaration.cs" />
|
||||
<Compile Include="Model\Auth\passwrecovery.cs" />
|
||||
|
@ -5,12 +5,38 @@ namespace BookAStar.Model.Social
|
||||
{
|
||||
public class BookQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// Client having made this book query.
|
||||
/// </summary>
|
||||
public ClientProviderInfo Client { get; set; }
|
||||
/// <summary>
|
||||
/// Location of the client event
|
||||
/// </summary>
|
||||
public Location Location { get; set; }
|
||||
/// <summary>
|
||||
/// Unique identifier
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// Date of the client event
|
||||
/// </summary>
|
||||
public DateTime EventDate { get; set; }
|
||||
/// <summary>
|
||||
/// Amount of money already available, from the site bank, for this event project.
|
||||
/// </summary>
|
||||
public decimal? Previsionnal { get; set; }
|
||||
/// <summary>
|
||||
/// Given reason from the client
|
||||
/// </summary>
|
||||
public string Reason { get; set; }
|
||||
/// <summary>
|
||||
/// True when the query has been read.
|
||||
/// </summary>
|
||||
public bool Read { get; set; }
|
||||
/// <summary>
|
||||
/// Unique identifier of the activity concerned,
|
||||
/// the context of this query.
|
||||
/// </summary>
|
||||
public string ActivityCode { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -115,8 +115,9 @@ namespace BookAStar.Pages
|
||||
Strings.CancelValidation, new string[] { Strings.Sign });
|
||||
if (response == Strings.Sign)
|
||||
{
|
||||
App.NavigationService.NavigateTo<EstimateSigningPage>(true,
|
||||
new EstimateSigningViewModel(evm.Data) { ValidationCommand = cmd });
|
||||
App.NavigationService.NavigateTo<EstimateSigningPage>(true,
|
||||
new EstimateSigningViewModel(evm.Data) { ValidationCommand = cmd,
|
||||
IsProviderView = true });
|
||||
}
|
||||
else if (response == Strings.CancelValidation)
|
||||
return;
|
||||
|
@ -9,13 +9,16 @@ namespace BookAStar.ViewModels.Signing
|
||||
public EstimateSigningViewModel(Estimate document): base(document)
|
||||
{
|
||||
}
|
||||
|
||||
public Command<bool> 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<bool>(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<bool>(ref isProviderView, value);
|
||||
if (old != value)
|
||||
{
|
||||
if (value != !isClientView)
|
||||
IsClientView = !value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user