mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-30 14:50:14 -05:00
Added ability to disable LED notification for new messages (new account setting)
Extracted notification related settings in separate class (see Issue 2268) Update issue 371 Status: Fixed Added ability to disable LED notification for new messages
This commit is contained in:
parent
92a2cd7cde
commit
e28e6d8817
@ -654,6 +654,10 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
|||||||
<string name="account_settings_vibrate_pattern_5">pattern 5</string>
|
<string name="account_settings_vibrate_pattern_5">pattern 5</string>
|
||||||
<string name="account_settings_vibrate_times">Number of vibrates</string>
|
<string name="account_settings_vibrate_times">Number of vibrates</string>
|
||||||
<string name="account_settings_ringtone">New mail ringtone</string>
|
<string name="account_settings_ringtone">New mail ringtone</string>
|
||||||
|
<string name="account_settings_led_label">Blink LED</string>
|
||||||
|
<string name="account_settings_led_summary">Blink LED when mail arrives</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="account_settings_servers">Server settings</string>
|
<string name="account_settings_servers">Server settings</string>
|
||||||
|
|
||||||
<string name="account_settings_composition_title">Message composition options</string>
|
<string name="account_settings_composition_title">Message composition options</string>
|
||||||
|
@ -280,6 +280,14 @@
|
|||||||
android:entryValues="@array/account_settings_vibrate_times_label"
|
android:entryValues="@array/account_settings_vibrate_times_label"
|
||||||
android:dialogTitle="@string/account_settings_vibrate_times" />
|
android:dialogTitle="@string/account_settings_vibrate_times" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="account_led"
|
||||||
|
android:dependency="account_notify"
|
||||||
|
android:title="@string/account_settings_led_label"
|
||||||
|
android:summary="@string/account_settings_led_summary"
|
||||||
|
android:defaultValue="true"
|
||||||
|
/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="account_notify_sync"
|
android:key="account_notify_sync"
|
||||||
android:title="@string/account_settings_notify_sync_label"
|
android:title="@string/account_settings_notify_sync_label"
|
||||||
|
@ -69,7 +69,6 @@ public class Account implements BaseAccount
|
|||||||
private int mAutomaticCheckIntervalMinutes;
|
private int mAutomaticCheckIntervalMinutes;
|
||||||
private int mDisplayCount;
|
private int mDisplayCount;
|
||||||
private int mChipColor;
|
private int mChipColor;
|
||||||
private int mLedColor;
|
|
||||||
private long mLastAutomaticCheckTime;
|
private long mLastAutomaticCheckTime;
|
||||||
private boolean mNotifyNewMail;
|
private boolean mNotifyNewMail;
|
||||||
private boolean mNotifySelfNewMail;
|
private boolean mNotifySelfNewMail;
|
||||||
@ -85,13 +84,8 @@ public class Account implements BaseAccount
|
|||||||
private FolderMode mFolderPushMode;
|
private FolderMode mFolderPushMode;
|
||||||
private FolderMode mFolderTargetMode;
|
private FolderMode mFolderTargetMode;
|
||||||
private int mAccountNumber;
|
private int mAccountNumber;
|
||||||
private boolean mVibrate;
|
|
||||||
private int mVibratePattern;
|
|
||||||
private int mVibrateTimes;
|
|
||||||
private boolean mRing;
|
|
||||||
private boolean mSaveAllHeaders;
|
private boolean mSaveAllHeaders;
|
||||||
private boolean mPushPollOnConnect;
|
private boolean mPushPollOnConnect;
|
||||||
private String mRingtoneUri;
|
|
||||||
private boolean mNotifySync;
|
private boolean mNotifySync;
|
||||||
private HideButtons mHideMessageViewButtons;
|
private HideButtons mHideMessageViewButtons;
|
||||||
private HideButtons mHideMessageViewMoveButtons;
|
private HideButtons mHideMessageViewMoveButtons;
|
||||||
@ -128,6 +122,8 @@ public class Account implements BaseAccount
|
|||||||
|
|
||||||
private List<Identity> identities;
|
private List<Identity> identities;
|
||||||
|
|
||||||
|
private NotificationSetting mNotificationSetting = new NotificationSetting();
|
||||||
|
|
||||||
public enum FolderMode
|
public enum FolderMode
|
||||||
{
|
{
|
||||||
NONE, ALL, FIRST_CLASS, FIRST_AND_SECOND_CLASS, NOT_SECOND_CLASS;
|
NONE, ALL, FIRST_CLASS, FIRST_AND_SECOND_CLASS, NOT_SECOND_CLASS;
|
||||||
@ -161,10 +157,6 @@ public class Account implements BaseAccount
|
|||||||
mAccountNumber = -1;
|
mAccountNumber = -1;
|
||||||
mNotifyNewMail = true;
|
mNotifyNewMail = true;
|
||||||
mNotifySync = true;
|
mNotifySync = true;
|
||||||
mVibrate = false;
|
|
||||||
mVibratePattern = 0;
|
|
||||||
mVibrateTimes = 5;
|
|
||||||
mRing = true;
|
|
||||||
mNotifySelfNewMail = true;
|
mNotifySelfNewMail = true;
|
||||||
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
||||||
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
||||||
@ -174,13 +166,11 @@ public class Account implements BaseAccount
|
|||||||
mHideMessageViewMoveButtons = HideButtons.NEVER;
|
mHideMessageViewMoveButtons = HideButtons.NEVER;
|
||||||
mShowPictures = ShowPictures.NEVER;
|
mShowPictures = ShowPictures.NEVER;
|
||||||
mEnableMoveButtons = false;
|
mEnableMoveButtons = false;
|
||||||
mRingtoneUri = "content://settings/system/notification_sound";
|
|
||||||
mIsSignatureBeforeQuotedText = false;
|
mIsSignatureBeforeQuotedText = false;
|
||||||
mExpungePolicy = EXPUNGE_IMMEDIATELY;
|
mExpungePolicy = EXPUNGE_IMMEDIATELY;
|
||||||
mAutoExpandFolderName = "INBOX";
|
mAutoExpandFolderName = "INBOX";
|
||||||
mMaxPushFolders = 10;
|
mMaxPushFolders = 10;
|
||||||
mChipColor = (new Random()).nextInt(0xffffff) + 0xff000000;
|
mChipColor = (new Random()).nextInt(0xffffff) + 0xff000000;
|
||||||
mLedColor = mChipColor;
|
|
||||||
goToUnreadMessageSearch = false;
|
goToUnreadMessageSearch = false;
|
||||||
subscribedFoldersOnly = false;
|
subscribedFoldersOnly = false;
|
||||||
maximumPolledMessageAge = -1;
|
maximumPolledMessageAge = -1;
|
||||||
@ -200,6 +190,14 @@ public class Account implements BaseAccount
|
|||||||
identity.setSignature(context.getString(R.string.default_signature));
|
identity.setSignature(context.getString(R.string.default_signature));
|
||||||
identity.setDescription(context.getString(R.string.default_identity_description));
|
identity.setDescription(context.getString(R.string.default_identity_description));
|
||||||
identities.add(identity);
|
identities.add(identity);
|
||||||
|
|
||||||
|
mNotificationSetting = new NotificationSetting();
|
||||||
|
mNotificationSetting.setVibrate(false);
|
||||||
|
mNotificationSetting.setVibratePattern(0);
|
||||||
|
mNotificationSetting.setVibrateTimes(5);
|
||||||
|
mNotificationSetting.setRing(true);
|
||||||
|
mNotificationSetting.setRingtone("content://settings/system/notification_sound");
|
||||||
|
mNotificationSetting.setLedColor(mChipColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Account(Preferences preferences, String uuid)
|
protected Account(Preferences preferences, String uuid)
|
||||||
@ -290,13 +288,6 @@ public class Account implements BaseAccount
|
|||||||
(random.nextInt(0x70) * 0xff) +
|
(random.nextInt(0x70) * 0xff) +
|
||||||
(random.nextInt(0x70) * 0xffff) +
|
(random.nextInt(0x70) * 0xffff) +
|
||||||
0xff000000);
|
0xff000000);
|
||||||
mLedColor = prefs.getInt(mUuid+".ledColor", mChipColor);
|
|
||||||
|
|
||||||
mVibrate = prefs.getBoolean(mUuid + ".vibrate", false);
|
|
||||||
mVibratePattern = prefs.getInt(mUuid + ".vibratePattern", 0);
|
|
||||||
mVibrateTimes = prefs.getInt(mUuid + ".vibrateTimes", 5);
|
|
||||||
|
|
||||||
mRing = prefs.getBoolean(mUuid + ".ring", true);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -330,8 +321,15 @@ public class Account implements BaseAccount
|
|||||||
|
|
||||||
mEnableMoveButtons = prefs.getBoolean(mUuid + ".enableMoveButtons", false);
|
mEnableMoveButtons = prefs.getBoolean(mUuid + ".enableMoveButtons", false);
|
||||||
|
|
||||||
mRingtoneUri = prefs.getString(mUuid + ".ringtone",
|
mNotificationSetting.setVibrate(prefs.getBoolean(mUuid + ".vibrate", false));
|
||||||
"content://settings/system/notification_sound");
|
mNotificationSetting.setVibratePattern(prefs.getInt(mUuid + ".vibratePattern", 0));
|
||||||
|
mNotificationSetting.setVibrateTimes(prefs.getInt(mUuid + ".vibrateTimes", 5));
|
||||||
|
mNotificationSetting.setRing(prefs.getBoolean(mUuid + ".ring", true));
|
||||||
|
mNotificationSetting.setRingtone(prefs.getString(mUuid + ".ringtone",
|
||||||
|
"content://settings/system/notification_sound"));
|
||||||
|
mNotificationSetting.setLed(prefs.getBoolean(mUuid + ".led", true));
|
||||||
|
mNotificationSetting.setLedColor(prefs.getInt(mUuid+".ledColor", mChipColor));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mFolderDisplayMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderDisplayMode",
|
mFolderDisplayMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderDisplayMode",
|
||||||
@ -449,6 +447,7 @@ public class Account implements BaseAccount
|
|||||||
editor.remove(mUuid + ".maxPushFolders");
|
editor.remove(mUuid + ".maxPushFolders");
|
||||||
editor.remove(mUuid + ".searchableFolders");
|
editor.remove(mUuid + ".searchableFolders");
|
||||||
editor.remove(mUuid + ".chipColor");
|
editor.remove(mUuid + ".chipColor");
|
||||||
|
editor.remove(mUuid + ".led");
|
||||||
editor.remove(mUuid + ".ledColor");
|
editor.remove(mUuid + ".ledColor");
|
||||||
editor.remove(mUuid + ".goToUnreadMessageSearch");
|
editor.remove(mUuid + ".goToUnreadMessageSearch");
|
||||||
editor.remove(mUuid + ".subscribedFoldersOnly");
|
editor.remove(mUuid + ".subscribedFoldersOnly");
|
||||||
@ -525,15 +524,10 @@ public class Account implements BaseAccount
|
|||||||
editor.putString(mUuid + ".outboxFolderName", mOutboxFolderName);
|
editor.putString(mUuid + ".outboxFolderName", mOutboxFolderName);
|
||||||
editor.putString(mUuid + ".autoExpandFolderName", mAutoExpandFolderName);
|
editor.putString(mUuid + ".autoExpandFolderName", mAutoExpandFolderName);
|
||||||
editor.putInt(mUuid + ".accountNumber", mAccountNumber);
|
editor.putInt(mUuid + ".accountNumber", mAccountNumber);
|
||||||
editor.putBoolean(mUuid + ".vibrate", mVibrate);
|
|
||||||
editor.putInt(mUuid + ".vibratePattern", mVibratePattern);
|
|
||||||
editor.putInt(mUuid + ".vibrateTimes", mVibrateTimes);
|
|
||||||
editor.putBoolean(mUuid + ".ring", mRing);
|
|
||||||
editor.putString(mUuid + ".hideButtonsEnum", mHideMessageViewButtons.name());
|
editor.putString(mUuid + ".hideButtonsEnum", mHideMessageViewButtons.name());
|
||||||
editor.putString(mUuid + ".hideMoveButtonsEnum", mHideMessageViewMoveButtons.name());
|
editor.putString(mUuid + ".hideMoveButtonsEnum", mHideMessageViewMoveButtons.name());
|
||||||
editor.putString(mUuid + ".showPicturesEnum", mShowPictures.name());
|
editor.putString(mUuid + ".showPicturesEnum", mShowPictures.name());
|
||||||
editor.putBoolean(mUuid + ".enableMoveButtons", mEnableMoveButtons);
|
editor.putBoolean(mUuid + ".enableMoveButtons", mEnableMoveButtons);
|
||||||
editor.putString(mUuid + ".ringtone", mRingtoneUri);
|
|
||||||
editor.putString(mUuid + ".folderDisplayMode", mFolderDisplayMode.name());
|
editor.putString(mUuid + ".folderDisplayMode", mFolderDisplayMode.name());
|
||||||
editor.putString(mUuid + ".folderSyncMode", mFolderSyncMode.name());
|
editor.putString(mUuid + ".folderSyncMode", mFolderSyncMode.name());
|
||||||
editor.putString(mUuid + ".folderPushMode", mFolderPushMode.name());
|
editor.putString(mUuid + ".folderPushMode", mFolderPushMode.name());
|
||||||
@ -544,7 +538,6 @@ public class Account implements BaseAccount
|
|||||||
editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders);
|
editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders);
|
||||||
editor.putString(mUuid + ".searchableFolders", searchableFolders.name());
|
editor.putString(mUuid + ".searchableFolders", searchableFolders.name());
|
||||||
editor.putInt(mUuid + ".chipColor", mChipColor);
|
editor.putInt(mUuid + ".chipColor", mChipColor);
|
||||||
editor.putInt(mUuid + ".ledColor", mLedColor);
|
|
||||||
editor.putBoolean(mUuid + ".goToUnreadMessageSearch", goToUnreadMessageSearch);
|
editor.putBoolean(mUuid + ".goToUnreadMessageSearch", goToUnreadMessageSearch);
|
||||||
editor.putBoolean(mUuid + ".subscribedFoldersOnly", subscribedFoldersOnly);
|
editor.putBoolean(mUuid + ".subscribedFoldersOnly", subscribedFoldersOnly);
|
||||||
editor.putInt(mUuid + ".maximumPolledMessageAge", maximumPolledMessageAge);
|
editor.putInt(mUuid + ".maximumPolledMessageAge", maximumPolledMessageAge);
|
||||||
@ -553,6 +546,14 @@ public class Account implements BaseAccount
|
|||||||
editor.putString(mUuid + ".cryptoApp", mCryptoApp);
|
editor.putString(mUuid + ".cryptoApp", mCryptoApp);
|
||||||
editor.putBoolean(mUuid + ".cryptoAutoSignature", mCryptoAutoSignature);
|
editor.putBoolean(mUuid + ".cryptoAutoSignature", mCryptoAutoSignature);
|
||||||
|
|
||||||
|
editor.putBoolean(mUuid + ".vibrate", mNotificationSetting.isVibrate());
|
||||||
|
editor.putInt(mUuid + ".vibratePattern", mNotificationSetting.getVibratePattern());
|
||||||
|
editor.putInt(mUuid + ".vibrateTimes", mNotificationSetting.getVibrateTimes());
|
||||||
|
editor.putBoolean(mUuid + ".ring", mNotificationSetting.shouldRing());
|
||||||
|
editor.putString(mUuid + ".ringtone", mNotificationSetting.getRingtone());
|
||||||
|
editor.putBoolean(mUuid + ".led", mNotificationSetting.isLed());
|
||||||
|
editor.putInt(mUuid + ".ledColor", mNotificationSetting.getLedColor());
|
||||||
|
|
||||||
for (String type : networkTypes)
|
for (String type : networkTypes)
|
||||||
{
|
{
|
||||||
Boolean useCompression = compressionMap.get(type);
|
Boolean useCompression = compressionMap.get(type);
|
||||||
@ -648,16 +649,6 @@ public class Account implements BaseAccount
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public synchronized void setLedColor(int color)
|
|
||||||
{
|
|
||||||
mLedColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized int getLedColor()
|
|
||||||
{
|
|
||||||
return mLedColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUuid()
|
public String getUuid()
|
||||||
{
|
{
|
||||||
return mUuid;
|
return mUuid;
|
||||||
@ -748,38 +739,6 @@ public class Account implements BaseAccount
|
|||||||
this.mAlwaysBcc = alwaysBcc;
|
this.mAlwaysBcc = alwaysBcc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean isVibrate()
|
|
||||||
{
|
|
||||||
return mVibrate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void setVibrate(boolean vibrate)
|
|
||||||
{
|
|
||||||
mVibrate = vibrate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized int getVibratePattern()
|
|
||||||
{
|
|
||||||
return mVibratePattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void setVibratePattern(int pattern)
|
|
||||||
{
|
|
||||||
mVibratePattern = pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized int getVibrateTimes()
|
|
||||||
{
|
|
||||||
return mVibrateTimes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void setVibrateTimes(int times)
|
|
||||||
{
|
|
||||||
mVibrateTimes = times;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Have we sent a new mail notification on this account */
|
/* Have we sent a new mail notification on this account */
|
||||||
public boolean isRingNotified()
|
public boolean isRingNotified()
|
||||||
{
|
{
|
||||||
@ -791,16 +750,6 @@ public class Account implements BaseAccount
|
|||||||
mRingNotified = ringNotified;
|
mRingNotified = ringNotified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized String getRingtone()
|
|
||||||
{
|
|
||||||
return mRingtoneUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void setRingtone(String ringtoneUri)
|
|
||||||
{
|
|
||||||
mRingtoneUri = ringtoneUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized String getLocalStoreUri()
|
public synchronized String getLocalStoreUri()
|
||||||
{
|
{
|
||||||
return mLocalStoreUri;
|
return mLocalStoreUri;
|
||||||
@ -1096,16 +1045,6 @@ public class Account implements BaseAccount
|
|||||||
return oldMaxPushFolders != maxPushFolders;
|
return oldMaxPushFolders != maxPushFolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean shouldRing()
|
|
||||||
{
|
|
||||||
return mRing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void setRing(boolean ring)
|
|
||||||
{
|
|
||||||
mRing = ring;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalStore getLocalStore() throws MessagingException
|
public LocalStore getLocalStore() throws MessagingException
|
||||||
{
|
{
|
||||||
return Store.getLocalInstance(this, K9.app);
|
return Store.getLocalInstance(this, K9.app);
|
||||||
@ -1514,4 +1453,10 @@ public class Account implements BaseAccount
|
|||||||
}
|
}
|
||||||
return mCryptoProvider;
|
return mCryptoProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized NotificationSetting getNotificationSetting()
|
||||||
|
{
|
||||||
|
return mNotificationSetting;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
115
src/com/fsck/k9/NotificationSetting.java
Normal file
115
src/com/fsck/k9/NotificationSetting.java
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
package com.fsck.k9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes how a notification should behave.
|
||||||
|
*/
|
||||||
|
public class NotificationSetting
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ring notification kill switch. Allow disabling ringtones without losing
|
||||||
|
* ringtone selection.
|
||||||
|
*/
|
||||||
|
private boolean mRing;
|
||||||
|
|
||||||
|
private String mRingtoneUri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LED kill switch.
|
||||||
|
*/
|
||||||
|
private boolean mLed;
|
||||||
|
|
||||||
|
private int mLedColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vibration kill switch.
|
||||||
|
*/
|
||||||
|
private boolean mVibrate;
|
||||||
|
|
||||||
|
private int mVibratePattern;
|
||||||
|
|
||||||
|
private int mVibrateTimes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the ringtone kill switch. Allow to disable ringtone without losing
|
||||||
|
* ringtone selection.
|
||||||
|
*
|
||||||
|
* @param ring
|
||||||
|
* <code>true</code> to allow ringtones, <code>false</code>
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
public synchronized void setRing(boolean ring)
|
||||||
|
{
|
||||||
|
mRing = ring;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return <code>true</code> if ringtone is allowed to play,
|
||||||
|
* <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public synchronized boolean shouldRing()
|
||||||
|
{
|
||||||
|
return mRing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized String getRingtone()
|
||||||
|
{
|
||||||
|
return mRingtoneUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setRingtone(String ringtoneUri)
|
||||||
|
{
|
||||||
|
mRingtoneUri = ringtoneUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isLed()
|
||||||
|
{
|
||||||
|
return mLed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setLed(final boolean led)
|
||||||
|
{
|
||||||
|
mLed = led;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized int getLedColor()
|
||||||
|
{
|
||||||
|
return mLedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setLedColor(int color)
|
||||||
|
{
|
||||||
|
mLedColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isVibrate()
|
||||||
|
{
|
||||||
|
return mVibrate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setVibrate(boolean vibrate)
|
||||||
|
{
|
||||||
|
mVibrate = vibrate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized int getVibratePattern()
|
||||||
|
{
|
||||||
|
return mVibratePattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized int getVibrateTimes()
|
||||||
|
{
|
||||||
|
return mVibrateTimes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setVibratePattern(int pattern)
|
||||||
|
{
|
||||||
|
mVibratePattern = pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setVibrateTimes(int times)
|
||||||
|
{
|
||||||
|
mVibrateTimes = times;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -55,6 +55,7 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
private static final String PREFERENCE_VIBRATE_PATTERN = "account_vibrate_pattern";
|
private static final String PREFERENCE_VIBRATE_PATTERN = "account_vibrate_pattern";
|
||||||
private static final String PREFERENCE_VIBRATE_TIMES = "account_vibrate_times";
|
private static final String PREFERENCE_VIBRATE_TIMES = "account_vibrate_times";
|
||||||
private static final String PREFERENCE_RINGTONE = "account_ringtone";
|
private static final String PREFERENCE_RINGTONE = "account_ringtone";
|
||||||
|
private static final String PREFERENCE_NOTIFICATION_LED = "account_led";
|
||||||
private static final String PREFERENCE_INCOMING = "incoming";
|
private static final String PREFERENCE_INCOMING = "incoming";
|
||||||
private static final String PREFERENCE_OUTGOING = "outgoing";
|
private static final String PREFERENCE_OUTGOING = "outgoing";
|
||||||
private static final String PREFERENCE_DISPLAY_MODE = "folder_display_mode";
|
private static final String PREFERENCE_DISPLAY_MODE = "folder_display_mode";
|
||||||
@ -92,6 +93,7 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
private CheckBoxPreference mAccountEnableMoveButtons;
|
private CheckBoxPreference mAccountEnableMoveButtons;
|
||||||
private CheckBoxPreference mAccountNotifySync;
|
private CheckBoxPreference mAccountNotifySync;
|
||||||
private CheckBoxPreference mAccountVibrate;
|
private CheckBoxPreference mAccountVibrate;
|
||||||
|
private CheckBoxPreference mAccountLed;
|
||||||
private ListPreference mAccountVibratePattern;
|
private ListPreference mAccountVibratePattern;
|
||||||
private ListPreference mAccountVibrateTimes;
|
private ListPreference mAccountVibrateTimes;
|
||||||
private RingtonePreference mAccountRingtone;
|
private RingtonePreference mAccountRingtone;
|
||||||
@ -420,14 +422,14 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
// XXX: The following two lines act as a workaround for the RingtonePreference
|
// XXX: The following two lines act as a workaround for the RingtonePreference
|
||||||
// which does not let us set/get the value programmatically
|
// which does not let us set/get the value programmatically
|
||||||
SharedPreferences prefs = mAccountRingtone.getPreferenceManager().getSharedPreferences();
|
SharedPreferences prefs = mAccountRingtone.getPreferenceManager().getSharedPreferences();
|
||||||
String currentRingtone = (!mAccount.shouldRing() ? null : mAccount.getRingtone());
|
String currentRingtone = (!mAccount.getNotificationSetting().shouldRing() ? null : mAccount.getNotificationSetting().getRingtone());
|
||||||
prefs.edit().putString(PREFERENCE_RINGTONE, currentRingtone).commit();
|
prefs.edit().putString(PREFERENCE_RINGTONE, currentRingtone).commit();
|
||||||
|
|
||||||
mAccountVibrate = (CheckBoxPreference) findPreference(PREFERENCE_VIBRATE);
|
mAccountVibrate = (CheckBoxPreference) findPreference(PREFERENCE_VIBRATE);
|
||||||
mAccountVibrate.setChecked(mAccount.isVibrate());
|
mAccountVibrate.setChecked(mAccount.getNotificationSetting().isVibrate());
|
||||||
|
|
||||||
mAccountVibratePattern = (ListPreference) findPreference(PREFERENCE_VIBRATE_PATTERN);
|
mAccountVibratePattern = (ListPreference) findPreference(PREFERENCE_VIBRATE_PATTERN);
|
||||||
mAccountVibratePattern.setValue(String.valueOf(mAccount.getVibratePattern()));
|
mAccountVibratePattern.setValue(String.valueOf(mAccount.getNotificationSetting().getVibratePattern()));
|
||||||
mAccountVibratePattern.setSummary(mAccountVibratePattern.getEntry());
|
mAccountVibratePattern.setSummary(mAccountVibratePattern.getEntry());
|
||||||
mAccountVibratePattern.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
mAccountVibratePattern.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||||
{
|
{
|
||||||
@ -443,8 +445,8 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
});
|
});
|
||||||
|
|
||||||
mAccountVibrateTimes = (ListPreference) findPreference(PREFERENCE_VIBRATE_TIMES);
|
mAccountVibrateTimes = (ListPreference) findPreference(PREFERENCE_VIBRATE_TIMES);
|
||||||
mAccountVibrateTimes.setValue(String.valueOf(mAccount.getVibrateTimes()));
|
mAccountVibrateTimes.setValue(String.valueOf(mAccount.getNotificationSetting().getVibrateTimes()));
|
||||||
mAccountVibrateTimes.setSummary(String.valueOf(mAccount.getVibrateTimes()));
|
mAccountVibrateTimes.setSummary(String.valueOf(mAccount.getNotificationSetting().getVibrateTimes()));
|
||||||
mAccountVibrateTimes.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
mAccountVibrateTimes.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -458,6 +460,9 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mAccountLed = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFICATION_LED);
|
||||||
|
mAccountLed.setChecked(mAccount.getNotificationSetting().isLed());
|
||||||
|
|
||||||
mNotificationOpensUnread = (CheckBoxPreference)findPreference(PREFERENCE_NOTIFICATION_OPENS_UNREAD);
|
mNotificationOpensUnread = (CheckBoxPreference)findPreference(PREFERENCE_NOTIFICATION_OPENS_UNREAD);
|
||||||
mNotificationOpensUnread.setChecked(mAccount.goToUnreadMessageSearch());
|
mNotificationOpensUnread.setChecked(mAccount.goToUnreadMessageSearch());
|
||||||
|
|
||||||
@ -616,9 +621,10 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
|
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
|
||||||
mAccount.setMaximumPolledMessageAge(Integer.parseInt(mMessageAge.getValue()));
|
mAccount.setMaximumPolledMessageAge(Integer.parseInt(mMessageAge.getValue()));
|
||||||
mAccount.setMaximumAutoDownloadMessageSize(Integer.parseInt(mMessageSize.getValue()));
|
mAccount.setMaximumAutoDownloadMessageSize(Integer.parseInt(mMessageSize.getValue()));
|
||||||
mAccount.setVibrate(mAccountVibrate.isChecked());
|
mAccount.getNotificationSetting().setVibrate(mAccountVibrate.isChecked());
|
||||||
mAccount.setVibratePattern(Integer.parseInt(mAccountVibratePattern.getValue()));
|
mAccount.getNotificationSetting().setVibratePattern(Integer.parseInt(mAccountVibratePattern.getValue()));
|
||||||
mAccount.setVibrateTimes(Integer.parseInt(mAccountVibrateTimes.getValue()));
|
mAccount.getNotificationSetting().setVibrateTimes(Integer.parseInt(mAccountVibrateTimes.getValue()));
|
||||||
|
mAccount.getNotificationSetting().setLed(mAccountLed.isChecked());
|
||||||
mAccount.setGoToUnreadMessageSearch(mNotificationOpensUnread.isChecked());
|
mAccount.setGoToUnreadMessageSearch(mNotificationOpensUnread.isChecked());
|
||||||
mAccount.setFolderTargetMode(Account.FolderMode.valueOf(mTargetMode.getValue()));
|
mAccount.setFolderTargetMode(Account.FolderMode.valueOf(mTargetMode.getValue()));
|
||||||
mAccount.setDeletePolicy(Integer.parseInt(mDeletePolicy.getValue()));
|
mAccount.setDeletePolicy(Integer.parseInt(mDeletePolicy.getValue()));
|
||||||
@ -646,14 +652,14 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
String newRingtone = prefs.getString(PREFERENCE_RINGTONE, null);
|
String newRingtone = prefs.getString(PREFERENCE_RINGTONE, null);
|
||||||
if (newRingtone != null)
|
if (newRingtone != null)
|
||||||
{
|
{
|
||||||
mAccount.setRing(true);
|
mAccount.getNotificationSetting().setRing(true);
|
||||||
mAccount.setRingtone(newRingtone);
|
mAccount.getNotificationSetting().setRingtone(newRingtone);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mAccount.shouldRing())
|
if (mAccount.getNotificationSetting().shouldRing())
|
||||||
{
|
{
|
||||||
mAccount.setRingtone(null);
|
mAccount.getNotificationSetting().setRingtone(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -743,10 +749,10 @@ public class AccountSettings extends K9PreferenceActivity
|
|||||||
{
|
{
|
||||||
public void colorChanged(int color)
|
public void colorChanged(int color)
|
||||||
{
|
{
|
||||||
mAccount.setLedColor(color);
|
mAccount.getNotificationSetting().setLedColor(color);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mAccount.getLedColor()).show();
|
mAccount.getNotificationSetting().getLedColor()).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onChooseAutoExpandFolder()
|
public void onChooseAutoExpandFolder()
|
||||||
|
@ -39,6 +39,7 @@ import android.util.Log;
|
|||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
import com.fsck.k9.AccountStats;
|
import com.fsck.k9.AccountStats;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
|
import com.fsck.k9.NotificationSetting;
|
||||||
import com.fsck.k9.Preferences;
|
import com.fsck.k9.Preferences;
|
||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.SearchSpecification;
|
import com.fsck.k9.SearchSpecification;
|
||||||
@ -4221,7 +4222,7 @@ public class MessagingController implements Runnable
|
|||||||
if (K9.NOTIFICATION_LED_WHILE_SYNCING)
|
if (K9.NOTIFICATION_LED_WHILE_SYNCING)
|
||||||
{
|
{
|
||||||
notif.flags |= Notification.FLAG_SHOW_LIGHTS;
|
notif.flags |= Notification.FLAG_SHOW_LIGHTS;
|
||||||
notif.ledARGB = account.getLedColor();
|
notif.ledARGB = account.getNotificationSetting().getLedColor();
|
||||||
notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME;
|
notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME;
|
||||||
notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME;
|
notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME;
|
||||||
}
|
}
|
||||||
@ -4327,7 +4328,7 @@ public class MessagingController implements Runnable
|
|||||||
if (K9.NOTIFICATION_LED_WHILE_SYNCING)
|
if (K9.NOTIFICATION_LED_WHILE_SYNCING)
|
||||||
{
|
{
|
||||||
notif.flags |= Notification.FLAG_SHOW_LIGHTS;
|
notif.flags |= Notification.FLAG_SHOW_LIGHTS;
|
||||||
notif.ledARGB = account.getLedColor();
|
notif.ledARGB = account.getNotificationSetting().getLedColor();
|
||||||
notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME;
|
notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME;
|
||||||
notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME;
|
notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME;
|
||||||
}
|
}
|
||||||
@ -4637,31 +4638,54 @@ public class MessagingController implements Runnable
|
|||||||
|
|
||||||
// Only ring or vibrate if we have not done so already on this
|
// Only ring or vibrate if we have not done so already on this
|
||||||
// account and fetch
|
// account and fetch
|
||||||
|
boolean ringAndVibrate = false;
|
||||||
if (!account.isRingNotified())
|
if (!account.isRingNotified())
|
||||||
{
|
{
|
||||||
account.setRingNotified(true);
|
account.setRingNotified(true);
|
||||||
if (account.shouldRing())
|
ringAndVibrate = true;
|
||||||
{
|
|
||||||
String ringtone = account.getRingtone();
|
|
||||||
notif.sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone);
|
|
||||||
}
|
|
||||||
if (account.isVibrate())
|
|
||||||
{
|
|
||||||
long[] pattern = getVibratePattern(account.getVibratePattern(), account.getVibrateTimes());
|
|
||||||
notif.vibrate = pattern;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notif.flags |= Notification.FLAG_SHOW_LIGHTS;
|
configureNotification(account.getNotificationSetting(), notif, ringAndVibrate);
|
||||||
notif.ledARGB = account.getLedColor();
|
|
||||||
notif.ledOnMS = K9.NOTIFICATION_LED_ON_TIME;
|
|
||||||
notif.ledOffMS = K9.NOTIFICATION_LED_OFF_TIME;
|
|
||||||
notif.audioStreamType = AudioManager.STREAM_NOTIFICATION;
|
|
||||||
|
|
||||||
notifMgr.notify(account.getAccountNumber(), notif);
|
notifMgr.notify(account.getAccountNumber(), notif);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param setting
|
||||||
|
* Configuration template. Never <code>null</code>.
|
||||||
|
* @param notification
|
||||||
|
* Object to configure. Never <code>null</code>.
|
||||||
|
* @param ringAndVibrate
|
||||||
|
* <code>true</code> if ringtone/vibration are allowed,
|
||||||
|
* <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
private void configureNotification(final NotificationSetting setting, final Notification notification, final boolean ringAndVibrate)
|
||||||
|
{
|
||||||
|
if (ringAndVibrate)
|
||||||
|
{
|
||||||
|
if (setting.shouldRing())
|
||||||
|
{
|
||||||
|
String ringtone = setting.getRingtone();
|
||||||
|
notification.sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone);
|
||||||
|
notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
|
||||||
|
}
|
||||||
|
if (setting.isVibrate())
|
||||||
|
{
|
||||||
|
long[] pattern = getVibratePattern(setting.getVibratePattern(), setting.getVibrateTimes());
|
||||||
|
notification.vibrate = pattern;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setting.isLed())
|
||||||
|
{
|
||||||
|
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
|
||||||
|
notification.ledARGB = setting.getLedColor();
|
||||||
|
notification.ledOnMS = K9.NOTIFICATION_LED_ON_TIME;
|
||||||
|
notification.ledOffMS = K9.NOTIFICATION_LED_OFF_TIME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch a vibration pattern.
|
* Fetch a vibration pattern.
|
||||||
*
|
*
|
||||||
|
@ -105,11 +105,11 @@ public class RemoteControlService extends CoreService
|
|||||||
}
|
}
|
||||||
if (ringEnabled != null)
|
if (ringEnabled != null)
|
||||||
{
|
{
|
||||||
account.setRing(Boolean.parseBoolean(ringEnabled));
|
account.getNotificationSetting().setRing(Boolean.parseBoolean(ringEnabled));
|
||||||
}
|
}
|
||||||
if (vibrateEnabled != null)
|
if (vibrateEnabled != null)
|
||||||
{
|
{
|
||||||
account.setVibrate(Boolean.parseBoolean(vibrateEnabled));
|
account.getNotificationSetting().setVibrate(Boolean.parseBoolean(vibrateEnabled));
|
||||||
}
|
}
|
||||||
if (pushClasses != null)
|
if (pushClasses != null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user