public static BaseArguments CreateArgumentsForView(DataItemMegaItem item, Guid localAccountId, LaunchSurface launchSurface = LaunchSurface.Normal) { BaseArgumentsWithAccountAndItem args; if (item.MegaItemType == PowerPlannerSending.MegaItemType.Homework) { args = new ViewTaskArguments(); } else if (item.MegaItemType == PowerPlannerSending.MegaItemType.Exam) { args = new ViewEventArguments(); } else { return new OpenAccountArguments() { LocalAccountId = localAccountId } }; args.LocalAccountId = localAccountId; args.ItemId = item.Identifier; args.LaunchSurface = launchSurface; return(args); }
public static BaseArguments CreateArgumentsForView(ViewItemTaskOrEvent item, Guid localAccountId) { BaseArgumentsWithAccountAndItem args; if (item.Type == TaskOrEventType.Task) { args = new ViewTaskArguments(); } else if (item.Type == TaskOrEventType.Event) { args = new ViewEventArguments(); } else { return new OpenAccountArguments() { LocalAccountId = localAccountId } }; args.LocalAccountId = localAccountId; args.ItemId = item.Identifier; return(args); } }
public static BaseArguments Parse(string queryString) { QueryString qs = QueryString.Parse(queryString); string val; ArgumentsAction action = ArgumentsAction.Unknown; if (!(qs.TryGetValue(KEY_ACTION, out val) && Enum.TryParse(val, out action))) { return(null); } BaseArguments answer = null; switch (action) { case ArgumentsAction.ViewPage: answer = new ViewPageArguments(); break; case ArgumentsAction.ViewSchedule: answer = new ViewScheduleArguments(); break; case ArgumentsAction.ViewClass: answer = new ViewClassArguments(); break; case ArgumentsAction.QuickAdd: answer = new QuickAddArguments(); break; case ArgumentsAction.QuickAddToCurrentAccount: answer = new QuickAddToCurrentAccountArguments(); break; case ArgumentsAction.QuickAddHomeworkToCurrentAccount: answer = new QuickAddTaskToCurrentAccountArguments(); break; case ArgumentsAction.QuickAddExamToCurrentAccount: answer = new QuickAddEventToCurrentAccountArguments(); break; case ArgumentsAction.OpenAccount: answer = new OpenAccountArguments(); break; case ArgumentsAction.ViewHomework: answer = new ViewTaskArguments(); break; case ArgumentsAction.ViewExam: answer = new ViewEventArguments(); break; case ArgumentsAction.ViewHoliday: answer = new ViewHolidayArguments(); break; } if (answer != null) { if (answer.TryParse(qs)) { return(answer); } } return(null); }
private static void UpdateDayOfNotification(Guid localAccountId, ViewItemTaskOrEvent item, DateTime dayOfReminderTime, Context context, NotificationManager notificationManager, List <StatusBarNotification> existingNotifs, bool fromForeground) { ViewItemClass c = item.Class; if (c == null) { return; } string tag = localAccountId.ToString() + ";" + item.Identifier.ToString(); var existing = existingNotifs.FirstOrDefault(i => i.Tag == tag); // If the reminder has already been sent and the notification doesn't exist, // that means the user dismissed it, so don't show it again if (item.HasSentReminder && existing == null) { return; } // If there's no existing notification, and the updated time is greater than the desired reminder time, // then it was edited after the notification should have been sent, so don't notify, since user was already // aware of this item (by the fact that they were editing it) if (existing == null && item.Updated.ToLocalTime() > dayOfReminderTime) { return; } if (existing == null && fromForeground) { return; } const string EXTRA_UNIQUE_ID = "UniqueId"; string extraUniqueId = (item.Name + ";" + c.Name).GetHashCode().ToString(); // If there's an existing, and it hasn't changed, do nothing if (existing != null && existing.Notification.Extras.GetString(EXTRA_UNIQUE_ID).Equals(extraUniqueId)) { return; } BaseArguments launchArgs; if (item.Type == TaskOrEventType.Task) { launchArgs = new ViewTaskArguments() { LocalAccountId = localAccountId, ItemId = item.Identifier, LaunchSurface = LaunchSurface.Toast }; } else { launchArgs = new ViewEventArguments() { LocalAccountId = localAccountId, ItemId = item.Identifier, LaunchSurface = LaunchSurface.Toast }; } var builder = CreateReminderBuilder(context, localAccountId, launchArgs); Bundle b = new Bundle(); b.PutString(EXTRA_UNIQUE_ID, extraUniqueId); builder.SetExtras(b); builder.SetContentTitle(item.Name); builder.SetChannelId(GetChannelIdForDayOf(localAccountId)); string subtitle = item.Subtitle; if (subtitle != null) { builder.SetContentText(subtitle); } notificationManager.Notify(tag, NotificationIds.DAY_OF_NOTIFICATIONS, BuildReminder(builder)); }