diff --git a/res/values/strings.xml b/res/values/strings.xml index ad3cd20aa..bc3edc73f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -477,6 +477,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin Account color Choose the color of the account used in folder and account list + Notification LED color + Choose the color your your phone LED should blink for this account + Number of messages to display Folders to display diff --git a/res/xml/account_settings_preferences.xml b/res/xml/account_settings_preferences.xml index afde7338d..0b52e8b5e 100644 --- a/res/xml/account_settings_preferences.xml +++ b/res/xml/account_settings_preferences.xml @@ -46,6 +46,12 @@ android:title="@string/account_settings_color_label" android:summary="@string/account_settings_color_summary" /> + diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java index 354dda91b..61b8ffa04 100644 --- a/src/com/fsck/k9/Account.java +++ b/src/com/fsck/k9/Account.java @@ -61,6 +61,7 @@ public class Account implements BaseAccount private int mAutomaticCheckIntervalMinutes; private int mDisplayCount; private int mChipColor; + private int mLedColor; private long mLastAutomaticCheckTime; private boolean mNotifyNewMail; private boolean mNotifySelfNewMail; @@ -134,6 +135,7 @@ public class Account implements BaseAccount mAutoExpandFolderName = "INBOX"; mMaxPushFolders = 10; mChipColor = (new Random()).nextInt(0xffffff) + 0xff000000; + mLedColor = mChipColor; goToUnreadMessageSearch = false; searchableFolders = Searchable.ALL; @@ -235,6 +237,8 @@ public class Account implements BaseAccount (random.nextInt(0x70) * 0xffff) + 0xff000000); + mLedColor = preferences.getPreferences().getInt(mUuid+".chipColor", mChipColor); + mVibrate = preferences.getPreferences().getBoolean(mUuid + ".vibrate", false); mRing = preferences.getPreferences().getBoolean(mUuid + ".ring", true); @@ -438,6 +442,7 @@ public class Account implements BaseAccount editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders); editor.putString(mUuid + ".searchableFolders", searchableFolders.name()); editor.putInt(mUuid + ".chipColor", mChipColor); + editor.putInt(mUuid + ".ledColor", mLedColor); editor.putBoolean(mUuid + ".goToUnreadMessageSearch", goToUnreadMessageSearch); for (String type : networkTypes) @@ -532,6 +537,17 @@ public class Account implements BaseAccount return mChipColor; } + + public void setLedColor(int color) + { + mLedColor = color; + } + + public int getLedColor() + { + return mLedColor; + } + public String getUuid() { return mUuid; diff --git a/src/com/fsck/k9/MessagingController.java b/src/com/fsck/k9/MessagingController.java index b8c925b75..d812ababf 100644 --- a/src/com/fsck/k9/MessagingController.java +++ b/src/com/fsck/k9/MessagingController.java @@ -4148,7 +4148,7 @@ public class MessagingController implements Runnable if (K9.NOTIFICATION_LED_WHILE_SYNCING) { notif.flags |= Notification.FLAG_SHOW_LIGHTS; - notif.ledARGB = account.getChipColor(); + notif.ledARGB = account.getLedColor(); notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME; notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME; } @@ -4254,7 +4254,7 @@ public class MessagingController implements Runnable if (K9.NOTIFICATION_LED_WHILE_SYNCING) { notif.flags |= Notification.FLAG_SHOW_LIGHTS; - notif.ledARGB = account.getChipColor(); + notif.ledARGB = account.getLedColor(); notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME; notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME; } @@ -4577,7 +4577,7 @@ public class MessagingController implements Runnable } notif.flags |= Notification.FLAG_SHOW_LIGHTS; - notif.ledARGB = account.getChipColor(); + notif.ledARGB = account.getLedColor(); notif.ledOnMS = K9.NOTIFICATION_LED_ON_TIME; notif.ledOffMS = K9.NOTIFICATION_LED_OFF_TIME; notif.audioStreamType = AudioManager.STREAM_NOTIFICATION; diff --git a/src/com/fsck/k9/activity/setup/AccountSettings.java b/src/com/fsck/k9/activity/setup/AccountSettings.java index 320a9b91d..22bf67440 100644 --- a/src/com/fsck/k9/activity/setup/AccountSettings.java +++ b/src/com/fsck/k9/activity/setup/AccountSettings.java @@ -49,6 +49,7 @@ public class AccountSettings extends K9PreferenceActivity private static final String PREFERENCE_AUTO_EXPAND_FOLDER = "account_setup_auto_expand_folder"; private static final String PREFERENCE_SEARCHABLE_FOLDERS = "searchable_folders"; private static final String PREFERENCE_CHIP_COLOR = "chip_color"; + private static final String PREFERENCE_LED_COLOR = "led_color"; private static final String PREFERENCE_NOTIFICATION_OPENS_UNREAD = "notification_opens_unread"; @@ -74,6 +75,7 @@ public class AccountSettings extends K9PreferenceActivity private ListPreference mSearchableFolders; private Preference mAutoExpandFolder; private Preference mChipColor; + private Preference mLedColor; private boolean mIncomingChanged = false; private CheckBoxPreference mNotificationOpensUnread; @@ -338,6 +340,19 @@ public class AccountSettings extends K9PreferenceActivity } ); + mLedColor = (Preference)findPreference(PREFERENCE_LED_COLOR); + + mLedColor.setOnPreferenceClickListener( + new Preference.OnPreferenceClickListener() + { + public boolean onPreferenceClick(Preference preference) + { + onChooseLedColor(); + return false; + } + } + ); + findPreference(PREFERENCE_COMPOSITION).setOnPreferenceClickListener( @@ -510,6 +525,18 @@ public class AccountSettings extends K9PreferenceActivity mAccount.getChipColor()).show(); } + public void onChooseLedColor() + { + new ColorPickerDialog(this, new ColorPickerDialog.OnColorChangedListener() + { + public void colorChanged(int color) + { + mAccount.setLedColor(color); + } + }, + mAccount.getLedColor()).show(); + } + public void onChooseAutoExpandFolder() { Intent selectIntent = new Intent(this, ChooseFolder.class);