mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
unify all our beeping, buzzing and flashing codepaths
This commit is contained in:
parent
70922989d3
commit
2b8f7c0bbc
@ -255,19 +255,21 @@ public class K9 extends Application
|
|||||||
public static final int BOOT_RECEIVER_WAKE_LOCK_TIMEOUT = 60000;
|
public static final int BOOT_RECEIVER_WAKE_LOCK_TIMEOUT = 60000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time the LED is on when blinking on new email notification
|
* Time the LED is on/off when blinking on new email notification
|
||||||
*/
|
*/
|
||||||
public static final int NOTIFICATION_LED_ON_TIME = 500;
|
public static final int NOTIFICATION_LED_ON_TIME = 500;
|
||||||
|
|
||||||
/**
|
|
||||||
* Time the LED is off when blicking on new email notification
|
|
||||||
*/
|
|
||||||
public static final int NOTIFICATION_LED_OFF_TIME = 2000;
|
public static final int NOTIFICATION_LED_OFF_TIME = 2000;
|
||||||
|
|
||||||
public static final boolean NOTIFICATION_LED_WHILE_SYNCING = false;
|
public static final boolean NOTIFICATION_LED_WHILE_SYNCING = false;
|
||||||
public static final int NOTIFICATION_LED_FAST_ON_TIME = 100;
|
public static final int NOTIFICATION_LED_FAST_ON_TIME = 100;
|
||||||
public static final int NOTIFICATION_LED_FAST_OFF_TIME = 100;
|
public static final int NOTIFICATION_LED_FAST_OFF_TIME = 100;
|
||||||
|
|
||||||
|
|
||||||
|
public static final int NOTIFICATION_LED_BLINK_SLOW = 0;
|
||||||
|
public static final int NOTIFICATION_LED_BLINK_FAST = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final int NOTIFICATION_LED_SENDING_FAILURE_COLOR = 0xffff0000;
|
public static final int NOTIFICATION_LED_SENDING_FAILURE_COLOR = 0xffff0000;
|
||||||
|
|
||||||
// Must not conflict with an account number
|
// Must not conflict with an account number
|
||||||
|
@ -3433,10 +3433,7 @@ public class MessagingController implements Runnable
|
|||||||
|
|
||||||
if (K9.NOTIFICATION_LED_WHILE_SYNCING)
|
if (K9.NOTIFICATION_LED_WHILE_SYNCING)
|
||||||
{
|
{
|
||||||
notif.flags |= Notification.FLAG_SHOW_LIGHTS;
|
configureNotification(notif, null, null, account.getNotificationSetting().getLedColor(), K9.NOTIFICATION_LED_BLINK_FAST, true);
|
||||||
notif.ledARGB = account.getNotificationSetting().getLedColor();
|
|
||||||
notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME;
|
|
||||||
notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notifMgr.notify(K9.FETCHING_EMAIL_NOTIFICATION - account.getAccountNumber(), notif);
|
notifMgr.notify(K9.FETCHING_EMAIL_NOTIFICATION - account.getAccountNumber(), notif);
|
||||||
@ -3453,11 +3450,8 @@ public class MessagingController implements Runnable
|
|||||||
|
|
||||||
notif.setLatestEventInfo(mApplication, mApplication.getString(R.string.send_failure_subject), lastFailure.getMessage(), pi);
|
notif.setLatestEventInfo(mApplication, mApplication.getString(R.string.send_failure_subject), lastFailure.getMessage(), pi);
|
||||||
|
|
||||||
notif.flags |= Notification.FLAG_SHOW_LIGHTS;
|
configureNotification(notif, null, null, K9.NOTIFICATION_LED_SENDING_FAILURE_COLOR, K9.NOTIFICATION_LED_BLINK_FAST, true);
|
||||||
notif.flags |= Notification.FLAG_AUTO_CANCEL;
|
notif.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||||
notif.ledARGB = K9.NOTIFICATION_LED_SENDING_FAILURE_COLOR;
|
|
||||||
notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME;
|
|
||||||
notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME;
|
|
||||||
notifMgr.notify(-1500 - account.getAccountNumber(), notif);
|
notifMgr.notify(-1500 - account.getAccountNumber(), notif);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3476,12 +3470,10 @@ public class MessagingController implements Runnable
|
|||||||
notif.setLatestEventInfo(mApplication, mApplication.getString(R.string.notification_bg_sync_title), account.getDescription()
|
notif.setLatestEventInfo(mApplication, mApplication.getString(R.string.notification_bg_sync_title), account.getDescription()
|
||||||
+ mApplication.getString(R.string.notification_bg_title_separator) + folder.getName(), pi);
|
+ mApplication.getString(R.string.notification_bg_title_separator) + folder.getName(), pi);
|
||||||
notif.flags = Notification.FLAG_ONGOING_EVENT;
|
notif.flags = Notification.FLAG_ONGOING_EVENT;
|
||||||
|
|
||||||
if (K9.NOTIFICATION_LED_WHILE_SYNCING)
|
if (K9.NOTIFICATION_LED_WHILE_SYNCING)
|
||||||
{
|
{
|
||||||
notif.flags |= Notification.FLAG_SHOW_LIGHTS;
|
configureNotification(notif, null, null, account.getNotificationSetting().getLedColor(), K9.NOTIFICATION_LED_BLINK_FAST, true);
|
||||||
notif.ledARGB = account.getNotificationSetting().getLedColor();
|
|
||||||
notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME;
|
|
||||||
notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notifMgr.notify(K9.FETCHING_EMAIL_NOTIFICATION - account.getAccountNumber(), notif);
|
notifMgr.notify(K9.FETCHING_EMAIL_NOTIFICATION - account.getAccountNumber(), notif);
|
||||||
@ -4716,7 +4708,7 @@ public class MessagingController implements Runnable
|
|||||||
|
|
||||||
NotificationSetting n = account.getNotificationSetting();
|
NotificationSetting n = account.getNotificationSetting();
|
||||||
|
|
||||||
configureNotification(notif, ( n.shouldRing() ? n.getRingtone() : null), (n.shouldVibrate() ? n.getVibration() : null), (n.isLed() ? n.getLedColor() : null), ringAndVibrate);
|
configureNotification(notif, ( n.shouldRing() ? n.getRingtone() : null), (n.shouldVibrate() ? n.getVibration() : null), (n.isLed() ? n.getLedColor() : null), K9.NOTIFICATION_LED_BLINK_SLOW, ringAndVibrate);
|
||||||
|
|
||||||
notifMgr.notify(account.getAccountNumber(), notif);
|
notifMgr.notify(account.getAccountNumber(), notif);
|
||||||
return true;
|
return true;
|
||||||
@ -4731,17 +4723,19 @@ public class MessagingController implements Runnable
|
|||||||
* <code>long[]</code> vibration pattern. <code>null</code> if no vibration should be played
|
* <code>long[]</code> vibration pattern. <code>null</code> if no vibration should be played
|
||||||
* @param ledColor
|
* @param ledColor
|
||||||
* <code>Integer</code> Color to flash LED. <code>null</code> if no LED flash should happen
|
* <code>Integer</code> Color to flash LED. <code>null</code> if no LED flash should happen
|
||||||
|
* @param ledSpeed
|
||||||
|
* <code>int</code> should LEDs flash K9.NOTIFICATION_LED_BLINK_SLOW or K9.NOTIFICATION_LED_BLINK_FAST
|
||||||
* @param ringAndVibrate
|
* @param ringAndVibrate
|
||||||
* <code>true</code> if ringtone/vibration are allowed,
|
* <code>true</code> if ringtone/vibration are allowed,
|
||||||
* <code>false</code> otherwise.
|
* <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
private void configureNotification(final Notification notification,
|
private void configureNotification(final Notification notification,
|
||||||
final String ringtone,
|
final String ringtone,
|
||||||
final long[] vibrationPattern,
|
final long[] vibrationPattern,
|
||||||
final Integer ledColor,
|
final Integer ledColor,
|
||||||
|
final int ledSpeed,
|
||||||
|
|
||||||
|
final boolean ringAndVibrate)
|
||||||
final boolean ringAndVibrate)
|
|
||||||
{
|
{
|
||||||
if (ringAndVibrate)
|
if (ringAndVibrate)
|
||||||
{
|
{
|
||||||
@ -4760,8 +4754,16 @@ public class MessagingController implements Runnable
|
|||||||
{
|
{
|
||||||
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
|
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
|
||||||
notification.ledARGB = ledColor;
|
notification.ledARGB = ledColor;
|
||||||
notification.ledOnMS = K9.NOTIFICATION_LED_ON_TIME;
|
if (ledSpeed == K9.NOTIFICATION_LED_BLINK_SLOW)
|
||||||
notification.ledOffMS = K9.NOTIFICATION_LED_OFF_TIME;
|
{
|
||||||
|
notification.ledOnMS = K9.NOTIFICATION_LED_ON_TIME;
|
||||||
|
notification.ledOffMS = K9.NOTIFICATION_LED_OFF_TIME;
|
||||||
|
}
|
||||||
|
else if (ledSpeed == K9.NOTIFICATION_LED_BLINK_FAST)
|
||||||
|
{
|
||||||
|
notification.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME;
|
||||||
|
notification.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user