un positionnement de paramètre workflow des pros

This commit is contained in:
Paul Schneider 2017-01-13 16:31:40 +01:00
commit 96746fcc0b
322 changed files with 25893 additions and 3844 deletions

View file

@ -0,0 +1,41 @@
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.OAuth;
namespace BookAStar.Droid.Services
{
[Service(
Name = "fr.pschneider.bas.AccountChooserService",
Label = "Yavsc accounts service",
Icon = "@drawable/icon",
Exported = true,
Enabled = true
)]
[IntentFilter(new String[] { "android.accounts.AccountAuthenticator" })]
class AccountChooserService : Service
{
public static YaOAuth2Authenticator authenticator;
public override void OnCreate()
{
base.OnCreate();
}
public override IBinder OnBind(Intent intent)
{
throw new NotImplementedException();
}
}
}

View file

@ -9,6 +9,9 @@ namespace BookAStar.Droid.Services
using Model.Social;
using Newtonsoft.Json;
using Model;
using Model.Social;
using Data;
using System.Linq;
namespace ClientApp
{
@ -44,18 +47,27 @@ namespace BookAStar.Droid.Services
if (topic == "BookQuery")
{
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 bq = new BookQueryData
var clientJson = data.GetString("Client");
var client = JsonConvert.DeserializeObject<ClientProviderInfo>(clientJson);
var bq = new BookQuery
{
Id = cid,
Location = location
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);
}
@ -82,14 +94,17 @@ namespace BookAStar.Droid.Services
notificationManager.Notify(0, notificationBuilder.Build());
}
void SendBookQueryNotification(BookQueryData bquery)
void SendBookQueryNotification(BookQuery bquery)
{
var bookquerynotifications = MainSettings.AddBookQueryNotification(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}";
var message = $"{bquery.EventDate} {bquery.Client.UserName} {bquery.Location.Address}\n {bquery.Reason}";
var intent = new Intent(this, typeof(MainActivity));
intent.AddFlags(ActivityFlags.ClearTop);

View file

@ -7,7 +7,6 @@ using Android.Widget;
namespace BookAStar.Droid
{
[Service]
public class MyGcmIntentService : IntentService
{
@ -31,6 +30,7 @@ namespace BookAStar.Droid
intent.SetClass(context, typeof(MyGcmIntentService));
context.StartService(intent);
}
static object locker = new object();
protected override void OnHandleIntent(Intent intent)
@ -74,16 +74,28 @@ namespace BookAStar.Droid
void SendNotification (string message)
{
var intent = new Intent (this, typeof(MainActivity));
/* Bundle valuesForActivity = new Bundle();
valuesForActivity.PutInt("count", count); */
var intent = new Intent (this, typeof(MainActivity));
intent.AddFlags (ActivityFlags.ClearTop);
var pendingIntent = PendingIntent.GetActivity (this, 0, intent, PendingIntentFlags.OneShot);
// Construct a back stack for cross-task navigation:
TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);
stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
stackBuilder.AddNextIntent(intent);
var notificationBuilder = new Notification.Builder(this)
// Create the PendingIntent with the back stack:
PendingIntent resultPendingIntent =
stackBuilder.GetPendingIntent(0, PendingIntentFlags.UpdateCurrent);
var notificationBuilder = new Notification.Builder(this)
.SetAutoCancel(true)
.SetSmallIcon (Resource.Drawable.icon)
.SetContentTitle ("GCM Message")
.SetContentText (message)
.SetAutoCancel (true)
.SetContentIntent (pendingIntent);
.SetContentIntent(resultPendingIntent) // Start 2nd activity when the intent is clicked.
;
var notificationManager = (NotificationManager) GetSystemService(Context.NotificationService);
notificationManager.Notify (0, notificationBuilder.Build());