예제 #1
0
        void SetGhafwa(int notificationId, long time, string title, string content)
        {
            now = DateTime.Now;

            Inputs.NotificationId = notificationId;
            Inputs.Title          = title;
            Inputs.Content        = content;

            ghafwaSettings.StartAlarmBroadcastReceiver(Java.Lang.JavaSystem.CurrentTimeMillis(), time, false, Inputs.NotificationId, Inputs.Title, Inputs.Content);
        }
예제 #2
0
        private void GhafwaButton_Click(object sender, System.EventArgs e)
        {
            if (ghafwaButton.Text.Equals("تشغيل"))
            {
                var alertMngr = new Android.Support.V7.App.AlertDialog.Builder(this);
                alertMngr.SetTitle("غفوة");
                alertMngr.SetMessage("سيرن هاتفك كل يوم في الساعة الثانية من بعد الظهر لتختار نوع ومدة الغفوة");
                alertMngr.SetPositiveButton("موافق",
                                            delegate
                {
                    Inputs.NotificationId = 111;
                    Inputs.Title          = "بدء الغفوة";
                    Inputs.Content        = "حان الوقت لبدء غفوتك، انقر هنا لاختيار نوع مدة الغفوة";

                    Calendar calNow = Calendar.Instance;
                    var calSet      = (Calendar)calNow.Clone();
                    calSet.Set(CalendarField.HourOfDay, 14);
                    calSet.Set(CalendarField.Minute, 00);
                    calSet.Set(CalendarField.Second, 0);
                    calSet.Set(CalendarField.Millisecond, 0);

                    if (calSet.CompareTo(calNow) <= 0)
                    {
                        //Today Set time passed, count to tomorrow
                        calSet.Add(CalendarField.Date, 1);
                    }

                    ghafwaSettings.StartAlarmBroadcastReceiver(calSet.TimeInMillis, 0, true, Inputs.NotificationId, Inputs.Title, Inputs.Content);

                    sharedPreferencesEditor = GetSharedPreferences("start", FileCreationMode.Private).Edit();
                    sharedPreferencesEditor.PutBoolean("starting", true);
                    sharedPreferencesEditor.Apply();
                    ghafwaButton.Text = "ايقاف";
                });
                alertMngr.SetNegativeButton("الغاء", delegate { });
                alertMngr.Show();
            }
            else
            {
                ghafwaSettings.StopAlarm(111);
                sharedPreferencesEditor = GetSharedPreferences("start", FileCreationMode.Private).Edit();
                sharedPreferencesEditor.PutBoolean("starting", false);
                sharedPreferencesEditor.Apply();
                ghafwaButton.Text = "تشغيل";
                Toast.MakeText(this, "تم ايقاف عمل الغفوة، سوف لن يتم تذكيرك كل يوم بعد الآن", ToastLength.Long).Show();
            }
        }