public override void OnReceive(Context context, Intent intent) { bool bootCompleted; string action = intent.Action; //TODO Switch to UserManagerCompat, BuildCompat Log.Info(TAG, $"Recieved action {action}, user unlocked: "); //{UserManagerCompat.IsUserUnlocked (context))}"); if (Build.VERSION.SdkInt > BuildVersionCodes.M) { bootCompleted = Intent.ActionLockedBootCompleted == action; } else { bootCompleted = Intent.ActionBootCompleted == action; } if (!bootCompleted) { return; } var util = new AlarmUtil(context); var alarmStorage = new AlarmStorage(context); foreach (Alarm alarm in alarmStorage.GetAlarms()) { util.ScheduleAlarm(alarm); } }
protected override void OnHandleIntent (Intent intent) { Context context = ApplicationContext; // var alarm = (Alarm)intent.GetParcelableExtra (ALARM_KEY); // TODO - workaround https://github.com/googlesamples/android-DirectBoot/issues/4 Bundle bundle = intent.Extras; var alarm = new Alarm { Id = bundle.GetInt ("id"), Year = bundle.GetInt ("year"), Month = bundle.GetInt ("month"), Day = bundle.GetInt ("day"), Hour = bundle.GetInt ("hour"), Minute = bundle.GetInt ("minute") }; var manager = context.GetSystemService (NotificationService).JavaCast<NotificationManager> (); var builder = new NotificationCompat.Builder (context) .SetSmallIcon (Resource.Drawable.ic_fbe_notification) .SetCategory (Notification.CategoryAlarm) .SetSound (Settings.System.DefaultAlarmAlertUri) .SetContentTitle (context.GetString (Resource.String.alarm_went_off, alarm.Hour, alarm.Minute)); manager.Notify (alarm.Id, builder.Build ()); var alarmStorage = new AlarmStorage (context); alarmStorage.DeleteAlarm (alarm); var wentoffIntent = new Intent (ALARM_WENT_OFF_ACTION); wentoffIntent.PutExtra (ALARM_KEY, alarm); LocalBroadcastManager.GetInstance (context).SendBroadcast (wentoffIntent); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); var fab = (FloatingActionButton)view.FindViewById(Resource.Id.fab_add_alarm); fab.Click += delegate { var fragment = TimePickerFragment.NewInstance(); fragment.SetAlarmAddListener(new AlarmAddListenerImpl(this)); fragment.Show(FragmentManager, FRAGMENT_TIME_PICKER_TAG); }; TextViewIntroMessage = (TextView)view.FindViewById(Resource.Id.text_intro_message); var alarmStorage = new AlarmStorage(Activity); AlarmAdapter = new AlarmAdapter(Activity, alarmStorage.GetAlarms()); if (AlarmAdapter.ItemCount == 0) { TextViewIntroMessage.Visibility = ViewStates.Visible; } var recyclerView = (RecyclerView)view.FindViewById(Resource.Id.recycler_view_alarms); recyclerView.SetLayoutManager(new LinearLayoutManager(Activity)); recyclerView.SetAdapter(AlarmAdapter); recyclerView.AddItemDecoration(new DividerItemDecorrection(Activity)); AlarmUtil = new AlarmUtil(Activity); }
protected override void OnHandleIntent(Intent intent) { Context context = ApplicationContext; // var alarm = (Alarm)intent.GetParcelableExtra (ALARM_KEY); // TODO - workaround https://github.com/googlesamples/android-DirectBoot/issues/4 Bundle bundle = intent.Extras; var alarm = new Alarm { Id = bundle.GetInt("id"), Year = bundle.GetInt("year"), Month = bundle.GetInt("month"), Day = bundle.GetInt("day"), Hour = bundle.GetInt("hour"), Minute = bundle.GetInt("minute") }; var manager = context.GetSystemService(NotificationService).JavaCast <NotificationManager> (); var builder = new NotificationCompat.Builder(context) .SetSmallIcon(Resource.Drawable.ic_fbe_notification) .SetCategory(Notification.CategoryAlarm) .SetSound(Settings.System.DefaultAlarmAlertUri) .SetContentTitle(context.GetString(Resource.String.alarm_went_off, alarm.Hour, alarm.Minute)); manager.Notify(alarm.Id, builder.Build()); var alarmStorage = new AlarmStorage(context); alarmStorage.DeleteAlarm(alarm); var wentoffIntent = new Intent(ALARM_WENT_OFF_ACTION); wentoffIntent.PutExtra(ALARM_KEY, alarm); LocalBroadcastManager.GetInstance(context).SendBroadcast(wentoffIntent); }
public AlarmAdapter (Context context, List<Alarm> alarms) { Context = context; Alarmlist = new List<Alarm> (); Alarmlist.AddRange (alarms); Alarmlist.Sort (); AlarmStorage = new AlarmStorage (context); AlarmUtil = new AlarmUtil (context); }
public AlarmAdapter(Context context, List <Alarm> alarms) { Context = context; Alarmlist = new List <Alarm> (); Alarmlist.AddRange(alarms); Alarmlist.Sort(); AlarmStorage = new AlarmStorage(context); AlarmUtil = new AlarmUtil(context); }
public override void OnReceive(Context context, Intent intent) { bool bootCompleted; string action = intent.Action; //TODO Switch to UserManagerCompat, BuildCompat Log.Info (TAG, $"Recieved action {action}, user unlocked: "); //{UserManagerCompat.IsUserUnlocked (context))}"); if (Build.VERSION.SdkInt > BuildVersionCodes.M) bootCompleted = Intent.ActionLockedBootCompleted == action; else bootCompleted = Intent.ActionBootCompleted == action; if (!bootCompleted) return; var util = new AlarmUtil (context); var alarmStorage = new AlarmStorage (context); foreach (Alarm alarm in alarmStorage.GetAlarms ()) util.ScheduleAlarm (alarm); }
public override void OnViewCreated (View view, Bundle savedInstanceState) { base.OnViewCreated (view, savedInstanceState); var fab = (FloatingActionButton)view.FindViewById (Resource.Id.fab_add_alarm); fab.Click += delegate { var fragment = TimePickerFragment.NewInstance (); fragment.SetAlarmAddListener (new AlarmAddListenerImpl (this)); fragment.Show (FragmentManager, FRAGMENT_TIME_PICKER_TAG); }; TextViewIntroMessage = (TextView)view.FindViewById (Resource.Id.text_intro_message); var alarmStorage = new AlarmStorage (Activity); AlarmAdapter = new AlarmAdapter (Activity, alarmStorage.GetAlarms ()); if (AlarmAdapter.ItemCount == 0) TextViewIntroMessage.Visibility = ViewStates.Visible; var recyclerView = (RecyclerView)view.FindViewById (Resource.Id.recycler_view_alarms); recyclerView.SetLayoutManager (new LinearLayoutManager (Activity)); recyclerView.SetAdapter (AlarmAdapter); recyclerView.AddItemDecoration (new DividerItemDecorrection (Activity)); AlarmUtil = new AlarmUtil (Activity); }
public override void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); alarmStorage = new AlarmStorage(Activity); alarmUtil = new AlarmUtil(Activity); }
public override void OnActivityCreated (Bundle savedInstanceState) { base.OnActivityCreated (savedInstanceState); alarmStorage = new AlarmStorage (Activity); alarmUtil = new AlarmUtil (Activity); }