Example #1
0
        public void updateNotification(ReminderDataStructure r)
        {
            Intent alarmIntent = new Intent(Forms.Context, typeof(AlarmReciver));

            alarmIntent.PutExtra("message", r.Description);
            alarmIntent.PutExtra("title", r.Title);
            alarmIntent.PutExtra("id", r.Id);
            PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, r.Id, alarmIntent, PendingIntentFlags.UpdateCurrent);
        }
Example #2
0
        public ReminderCell()
        {
            StackLayout cellWrapper    = new StackLayout();
            StackLayout verticalLayout = new StackLayout();
            Label       top            = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };
            Label bottom = new Label()
            {
                FontSize          = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                HorizontalOptions = LayoutOptions.StartAndExpand,
                LineBreakMode     = LineBreakMode.TailTruncation
            };

            top.SetBinding(Label.TextProperty, "Title");
            bottom.SetBinding(Label.TextProperty, "Description");

            MenuItem editAction = new MenuItem {
                Text = "Edit"
            };

            editAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            editAction.Clicked += async(sender, e) =>
            {
                MenuItem mi             = ((MenuItem)sender);
                ReminderDataStructure r = ((ReminderDataStructure)mi.CommandParameter);
                var addPage             = new ReminderCreationPage(top.Text, bottom.Text, r.Time);
                HomePage.notificationManager.deleteNotification(r);
                HomePage.dataAccess.DeleteReminder(r);
                await App.Current.MainPage.Navigation.PushModalAsync(addPage);
            };

            MenuItem deleteAction = new MenuItem {
                Text = "Delete", IsDestructive = true
            };

            deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            deleteAction.Clicked += (sender, e) =>
            {
                MenuItem mi             = ((MenuItem)sender);
                ReminderDataStructure r = ((ReminderDataStructure)mi.CommandParameter);
                HomePage.notificationManager.deleteNotification(r);
                HomePage.dataAccess.DeleteReminder(r);
            };
            ContextActions.Add(editAction);
            ContextActions.Add(deleteAction);

            verticalLayout.Orientation = StackOrientation.Vertical;
            verticalLayout.Children.Add(top);
            verticalLayout.Children.Add(bottom);
            cellWrapper.Children.Add(verticalLayout);
            View = cellWrapper;
        }
Example #3
0
        public void deleteNotification(ReminderDataStructure r)
        {
            Intent alarmIntent = new Intent(Forms.Context, typeof(AlarmReciver));

            alarmIntent.PutExtra("message", r.Description);
            alarmIntent.PutExtra("title", r.Title);
            alarmIntent.PutExtra("id", r.Id);

            PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, r.Id, alarmIntent, PendingIntentFlags.UpdateCurrent);
            AlarmManager  alarmManager  = (AlarmManager)Forms.Context.GetSystemService(Context.AlarmService);

            alarmManager.Cancel(pendingIntent);
        }
 private async void onAddButton(Object sender, EventArgs e)
 {
     if (titleEntry.Text != null)
     {
         Match match = Regex.Match(titleEntry.Text, @"^\\s+$", RegexOptions.None);
         if (!match.Success && !titleEntry.Text.Equals(""))
         {
             ReminderDataStructure r = new ReminderDataStructure(titleEntry.Text, descriptionEntry.Text, date.Date.Add(time.Time));
             HomePage.notificationManager.sendNotification(r);
             HomePage.dataAccess.Reminders.Add(r);
             await Navigation.PopModalAsync();
         }
     }
 }
Example #5
0
        public void sendNotification(ReminderDataStructure r)
        {
            Intent alarmIntent = new Intent(Forms.Context, typeof(AlarmReciver));

            alarmIntent.PutExtra("message", r.Description);
            alarmIntent.PutExtra("title", r.Title);
            alarmIntent.PutExtra("id", r.Id);
            var localAlarmTime = r.Time;
            var utcAlarmTime   = TimeZoneInfo.ConvertTimeToUtc(localAlarmTime);
            var t = new DateTime(1970, 1, 1) - DateTime.MinValue;
            var epochDifferenceInSeconds = t.TotalSeconds;

            var utcAlarmTimeInMillis = utcAlarmTime.AddSeconds(-epochDifferenceInSeconds).Ticks / 10000;

            PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, r.Id, alarmIntent, PendingIntentFlags.UpdateCurrent);
            AlarmManager  alarmManager  = (AlarmManager)Forms.Context.GetSystemService(Context.AlarmService);

            alarmManager.Set(AlarmType.RtcWakeup, utcAlarmTimeInMillis, pendingIntent);
        }