diff --git a/res/layout-land/message_list_item.xml b/res/layout-land/message_list_item.xml index 0e518c7c1..90eb8221b 100644 --- a/res/layout-land/message_list_item.xml +++ b/res/layout-land/message_list_item.xml @@ -35,6 +35,10 @@ android:focusable="false" android:visibility="gone" /> + - + Compose Debug Choose Folder + Choose a Color %s%s%s diff --git a/res/xml/account_settings_preferences.xml b/res/xml/account_settings_preferences.xml index ea0a88fd2..610dc6179 100644 --- a/res/xml/account_settings_preferences.xml +++ b/res/xml/account_settings_preferences.xml @@ -40,6 +40,12 @@ android:entries="@array/account_settings_display_count_entries" android:entryValues="@array/account_settings_display_count_values" android:dialogTitle="@string/account_settings_mail_display_count_label" /> + diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java index cc7e70c39..e4d53cf63 100644 --- a/src/com/fsck/k9/Account.java +++ b/src/com/fsck/k9/Account.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Random; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -59,6 +60,7 @@ public class Account implements BaseAccount private String mAlwaysBcc; private int mAutomaticCheckIntervalMinutes; private int mDisplayCount; + private int mChipColor; private long mLastAutomaticCheckTime; private boolean mNotifyNewMail; private boolean mNotifySelfNewMail; @@ -126,6 +128,8 @@ public class Account implements BaseAccount mExpungePolicy = EXPUNGE_IMMEDIATELY; mAutoExpandFolderName = "INBOX"; mMaxPushFolders = 10; + mChipColor = (new Random()).nextInt(); + searchableFolders = Searchable.ALL; identities = new ArrayList(); @@ -178,7 +182,9 @@ public class Account implements BaseAccount mExpungePolicy = preferences.getPreferences().getString(mUuid + ".expungePolicy", EXPUNGE_IMMEDIATELY); mMaxPushFolders = preferences.getPreferences().getInt(mUuid + ".maxPushFolders", 10); - + + mChipColor = preferences.getPreferences().getInt(mUuid+".chipColor", 0xff000000); + for (String type : networkTypes) { Boolean useCompression = preferences.getPreferences().getBoolean(mUuid + ".useCompression." + type, @@ -408,6 +414,8 @@ public class Account implements BaseAccount editor.putString(mUuid + ".expungePolicy", mExpungePolicy); editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders); editor.putString(mUuid + ".searchableFolders", searchableFolders.name()); + editor.putInt(mUuid + ".chipColor", mChipColor); + for (String type : networkTypes) { Boolean useCompression = compressionMap.get(type); @@ -489,6 +497,15 @@ public class Account implements BaseAccount return stats; } + + public void setChipColor(int color) { + mChipColor = color; + } + + public int getChipColor() { + return mChipColor; + } + public String getUuid() { return mUuid; diff --git a/src/com/fsck/k9/ColorPickerDialog.java b/src/com/fsck/k9/ColorPickerDialog.java index 9fb25b09b..114039b79 100644 --- a/src/com/fsck/k9/ColorPickerDialog.java +++ b/src/com/fsck/k9/ColorPickerDialog.java @@ -18,11 +18,13 @@ package com.fsck.k9; import android.os.Bundle; import android.app.Dialog; + import android.content.Context; import android.graphics.*; import android.view.MotionEvent; import android.view.View; + public class ColorPickerDialog extends Dialog { public interface OnColorChangedListener { @@ -202,6 +204,8 @@ public class ColorPickerDialog extends Dialog { mTrackingCenter = false; // so we draw w/o halo invalidate(); } + // Hack to _Always change the center color for now + mListener.colorChanged(mCenterPaint.getColor()); break; } return true; @@ -228,6 +232,6 @@ public class ColorPickerDialog extends Dialog { }; setContentView(new ColorPickerView(getContext(), l, mInitialColor)); - setTitle("Pick a Color"); + setTitle(getContext().getString(R.string.choose_color_title)); } } diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index ac64fce1e..65ba1ad93 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -854,7 +854,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC if (account instanceof Account) { Account realAccount = (Account)account; - holder.chip.setBackgroundResource(K9.COLOR_CHIP_RES_IDS[realAccount.getAccountNumber() % K9.COLOR_CHIP_RES_IDS.length]); + + holder.chip.setBackgroundColor(realAccount.getChipColor()); if (unreadMessageCount == null) { holder.chip.getBackground().setAlpha(0); @@ -871,7 +872,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC } else { - holder.chip.getBackground().setAlpha(0); + holder.chip.setBackgroundColor(0x00000000); } holder.description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getAccountName()); diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java index 215424859..903454e82 100644 --- a/src/com/fsck/k9/activity/FolderList.java +++ b/src/com/fsck/k9/activity/FolderList.java @@ -1271,8 +1271,7 @@ public class FolderList extends K9ListActivity } ); - holder.chip.setBackgroundResource(K9.COLOR_CHIP_RES_IDS[mAccount.getAccountNumber() % K9.COLOR_CHIP_RES_IDS.length]); - + holder.chip.setBackgroundColor(mAccount.getChipColor()); holder.chip.getBackground().setAlpha(folder.unreadMessageCount == 0 ? 127 : 255); holder.folderName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getFolderName()); diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index d4a42a4dc..99d634106 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -2000,7 +2000,7 @@ public class MessageList holder.selected.setVisibility(View.GONE); } } - holder.chip.setBackgroundResource(K9.COLOR_CHIP_RES_IDS[message.account.getAccountNumber() % K9.COLOR_CHIP_RES_IDS.length]); + holder.chip.setBackgroundColor(message.account.getChipColor()); holder.chip.getBackground().setAlpha(message.read ? 127 : 255); if (message.downloaded) diff --git a/src/com/fsck/k9/activity/setup/AccountSettings.java b/src/com/fsck/k9/activity/setup/AccountSettings.java index 2603294af..fa353da72 100644 --- a/src/com/fsck/k9/activity/setup/AccountSettings.java +++ b/src/com/fsck/k9/activity/setup/AccountSettings.java @@ -15,6 +15,7 @@ import com.fsck.k9.activity.ChooseIdentity; import com.fsck.k9.activity.ManageIdentities; import com.fsck.k9.mail.Store; import com.fsck.k9.service.MailService; +import com.fsck.k9.ColorPickerDialog; public class AccountSettings extends K9PreferenceActivity { @@ -48,6 +49,7 @@ public class AccountSettings extends K9PreferenceActivity private static final String PREFERENCE_EXPUNGE_POLICY = "expunge_policy"; 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 Account mAccount; @@ -71,6 +73,7 @@ public class AccountSettings extends K9PreferenceActivity private ListPreference mExpungePolicy; private ListPreference mSearchableFolders; private Preference mAutoExpandFolder; + private Preference mChipColor; private boolean mIncomingChanged = false; @@ -322,14 +325,29 @@ public class AccountSettings extends K9PreferenceActivity mAutoExpandFolder.setSummary(translateFolder(mAccount.getAutoExpandFolderName())); mAutoExpandFolder.setOnPreferenceClickListener( - new Preference.OnPreferenceClickListener() - { + new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { onChooseAutoExpandFolder(); return false; } - }); + } + ); + + + mChipColor = (Preference)findPreference(PREFERENCE_CHIP_COLOR); + + mChipColor.setOnPreferenceClickListener( + new Preference.OnPreferenceClickListener() { + public boolean onPreferenceClick(Preference preference) + { + onChooseChipColor(); + return false; + } + } + ); + + findPreference(PREFERENCE_COMPOSITION).setOnPreferenceClickListener( new Preference.OnPreferenceClickListener() @@ -489,6 +507,13 @@ public class AccountSettings extends K9PreferenceActivity AccountSetupOutgoing.actionEditOutgoingSettings(this, mAccount); } + public void onChooseChipColor() + { + new ColorPickerDialog(this, new ColorPickerDialog.OnColorChangedListener () { + public void colorChanged (int color) { mAccount.setChipColor(color); } }, + mAccount.getChipColor()).show(); + } + public void onChooseAutoExpandFolder() { Intent selectIntent = new Intent(this, ChooseFolder.class);