Decad3nce / Aegis

Remote SMS control app for android devices > API 14
GNU General Public License v3.0
97 stars 28 forks source link

Alarm repeat frequency #69

Open ciwchris opened 11 years ago

ciwchris commented 11 years ago

I was thinking about adding more preferences for the alarm. One setting to control how many times to execute the alarm and another setting to control the time between them. I was thinking of using a ListPreference for each setting from which the user could select a value. Thoughts?

Decad3nce commented 11 years ago

The feature has been requested quite a couple of times and I really do want to implement it. Problem is how to do the logic.

Currently the receiver, once getting the sms trigger, triggers a notification with sound.

In > Android 4.0, this is the only way to trigger a sound without using a service, so it's the easy route.

Anyway, to have such an option I'd have to create that said service, then spawn it from the receiver. The service would host a handler for the intervals that you mention in the list preference. A click on the notification(ideally) would do a removeCallbacksAndMessages call.

ciwchris commented 11 years ago

I was looking into this some. I was planning on using a Runnable with a Handler. Call it like so:

Handler handler = new Handler();
Runnable runnable = new AlarmNotificationRunnable(mManager, notification, repeat, delay);
handler.post(runnable);

And use it like so

@Override
public void run() {
  mManager.notify(1336, notification);
  if (++alarmCount < alarmTimes) {
    handler.postDelayed(this, alarmDelay);
  }
}

I'm not entirely sure what the consquences would be of implementing it like this though. I'm also not sure how to cancel it if it was implemented like this, but I have some ideas. I'm not sure I would want to be able to cancel it though. If someone had my phone, and for some reason it wasn't locked, I wouldn't want them to be able to cancel it.

Decad3nce commented 11 years ago

I've reimplemented alarm duration. Is repetition a necessity?