1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Allow users to set the account 'Chip' color per account.

This commit is contained in:
Jesse Vincent 2010-04-25 08:47:24 +00:00
parent 6bf429fd0d
commit d6bc0765d8
12 changed files with 73 additions and 13 deletions

View File

@ -35,6 +35,10 @@
android:focusable="false" android:focusable="false"
android:visibility="gone" android:visibility="gone"
/> />
<View
android:layout_width="4dip"
android:layout_height="fill_parent"
/>
</RelativeLayout> </RelativeLayout>
<TextView <TextView
android:id="@+id/date" android:id="@+id/date"

View File

@ -8,7 +8,6 @@
android:paddingRight="6dip"> android:paddingRight="6dip">
<View <View
android:id="@+id/chip" android:id="@+id/chip"
android:background="@drawable/appointment_indicator_leftside_1"
android:layout_width="4dip" android:layout_width="4dip"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_centerVertical="true" android:layout_centerVertical="true"

View File

@ -9,7 +9,7 @@
android:paddingRight="4dip"> android:paddingRight="4dip">
<View <View
android:id="@+id/chip" android:id="@+id/chip"
android:background="@drawable/appointment_indicator_leftside_1" android:background="@android:color/transparent"
android:layout_width="4dip" android:layout_width="4dip"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_centerVertical="true" android:layout_centerVertical="true"

View File

@ -16,6 +16,10 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
> >
<View
android:layout_width="4dip"
android:layout_height="fill_parent"
/>
<CheckBox <CheckBox
android:id="@+id/selected_checkbox" android:id="@+id/selected_checkbox"
android:layout_width="24dip" android:layout_width="24dip"

View File

@ -21,6 +21,7 @@
<string name="compose_title">Compose</string> <string name="compose_title">Compose</string>
<string name="debug_title">Debug</string> <string name="debug_title">Debug</string>
<string name="choose_folder_title">Choose Folder</string> <string name="choose_folder_title">Choose Folder</string>
<string name="choose_color_title">Choose a Color</string>
<string name="activity_header_format"><xliff:g id="activity_prefix">%s</xliff:g><xliff:g id="unread_count">%s</xliff:g><xliff:g id="operation">%s</xliff:g></string> <string name="activity_header_format"><xliff:g id="activity_prefix">%s</xliff:g><xliff:g id="unread_count">%s</xliff:g><xliff:g id="operation">%s</xliff:g></string>

View File

@ -40,6 +40,12 @@
android:entries="@array/account_settings_display_count_entries" android:entries="@array/account_settings_display_count_entries"
android:entryValues="@array/account_settings_display_count_values" android:entryValues="@array/account_settings_display_count_values"
android:dialogTitle="@string/account_settings_mail_display_count_label" /> android:dialogTitle="@string/account_settings_mail_display_count_label" />
<Preference
android:key="chip_color"
android:singleLine="true"
android:title="Account color"
android:summary=""
/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/account_settings_message_view"> <PreferenceCategory android:title="@string/account_settings_message_view">

View File

@ -17,6 +17,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -59,6 +60,7 @@ public class Account implements BaseAccount
private String mAlwaysBcc; private String mAlwaysBcc;
private int mAutomaticCheckIntervalMinutes; private int mAutomaticCheckIntervalMinutes;
private int mDisplayCount; private int mDisplayCount;
private int mChipColor;
private long mLastAutomaticCheckTime; private long mLastAutomaticCheckTime;
private boolean mNotifyNewMail; private boolean mNotifyNewMail;
private boolean mNotifySelfNewMail; private boolean mNotifySelfNewMail;
@ -126,6 +128,8 @@ public class Account implements BaseAccount
mExpungePolicy = EXPUNGE_IMMEDIATELY; mExpungePolicy = EXPUNGE_IMMEDIATELY;
mAutoExpandFolderName = "INBOX"; mAutoExpandFolderName = "INBOX";
mMaxPushFolders = 10; mMaxPushFolders = 10;
mChipColor = (new Random()).nextInt();
searchableFolders = Searchable.ALL; searchableFolders = Searchable.ALL;
identities = new ArrayList<Identity>(); identities = new ArrayList<Identity>();
@ -179,6 +183,8 @@ public class Account implements BaseAccount
mMaxPushFolders = preferences.getPreferences().getInt(mUuid + ".maxPushFolders", 10); mMaxPushFolders = preferences.getPreferences().getInt(mUuid + ".maxPushFolders", 10);
mChipColor = preferences.getPreferences().getInt(mUuid+".chipColor", 0xff000000);
for (String type : networkTypes) for (String type : networkTypes)
{ {
Boolean useCompression = preferences.getPreferences().getBoolean(mUuid + ".useCompression." + type, Boolean useCompression = preferences.getPreferences().getBoolean(mUuid + ".useCompression." + type,
@ -408,6 +414,8 @@ public class Account implements BaseAccount
editor.putString(mUuid + ".expungePolicy", mExpungePolicy); editor.putString(mUuid + ".expungePolicy", mExpungePolicy);
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);
for (String type : networkTypes) for (String type : networkTypes)
{ {
Boolean useCompression = compressionMap.get(type); Boolean useCompression = compressionMap.get(type);
@ -489,6 +497,15 @@ public class Account implements BaseAccount
return stats; return stats;
} }
public void setChipColor(int color) {
mChipColor = color;
}
public int getChipColor() {
return mChipColor;
}
public String getUuid() public String getUuid()
{ {
return mUuid; return mUuid;

View File

@ -18,11 +18,13 @@ package com.fsck.k9;
import android.os.Bundle; import android.os.Bundle;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.graphics.*; import android.graphics.*;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
public class ColorPickerDialog extends Dialog { public class ColorPickerDialog extends Dialog {
public interface OnColorChangedListener { public interface OnColorChangedListener {
@ -202,6 +204,8 @@ public class ColorPickerDialog extends Dialog {
mTrackingCenter = false; // so we draw w/o halo mTrackingCenter = false; // so we draw w/o halo
invalidate(); invalidate();
} }
// Hack to _Always change the center color for now
mListener.colorChanged(mCenterPaint.getColor());
break; break;
} }
return true; return true;
@ -228,6 +232,6 @@ public class ColorPickerDialog extends Dialog {
}; };
setContentView(new ColorPickerView(getContext(), l, mInitialColor)); setContentView(new ColorPickerView(getContext(), l, mInitialColor));
setTitle("Pick a Color"); setTitle(getContext().getString(R.string.choose_color_title));
} }
} }

View File

@ -854,7 +854,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
if (account instanceof Account) if (account instanceof Account)
{ {
Account realAccount = (Account)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) if (unreadMessageCount == null)
{ {
holder.chip.getBackground().setAlpha(0); holder.chip.getBackground().setAlpha(0);
@ -871,7 +872,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
} }
else else
{ {
holder.chip.getBackground().setAlpha(0); holder.chip.setBackgroundColor(0x00000000);
} }
holder.description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getAccountName()); holder.description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getAccountName());

View File

@ -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.chip.getBackground().setAlpha(folder.unreadMessageCount == 0 ? 127 : 255);
holder.folderName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getFolderName()); holder.folderName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mFontSizes.getFolderName());

View File

@ -2000,7 +2000,7 @@ public class MessageList
holder.selected.setVisibility(View.GONE); 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); holder.chip.getBackground().setAlpha(message.read ? 127 : 255);
if (message.downloaded) if (message.downloaded)

View File

@ -15,6 +15,7 @@ import com.fsck.k9.activity.ChooseIdentity;
import com.fsck.k9.activity.ManageIdentities; import com.fsck.k9.activity.ManageIdentities;
import com.fsck.k9.mail.Store; import com.fsck.k9.mail.Store;
import com.fsck.k9.service.MailService; import com.fsck.k9.service.MailService;
import com.fsck.k9.ColorPickerDialog;
public class AccountSettings extends K9PreferenceActivity 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_EXPUNGE_POLICY = "expunge_policy";
private static final String PREFERENCE_AUTO_EXPAND_FOLDER = "account_setup_auto_expand_folder"; 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_SEARCHABLE_FOLDERS = "searchable_folders";
private static final String PREFERENCE_CHIP_COLOR = "chip_color";
private Account mAccount; private Account mAccount;
@ -71,6 +73,7 @@ public class AccountSettings extends K9PreferenceActivity
private ListPreference mExpungePolicy; private ListPreference mExpungePolicy;
private ListPreference mSearchableFolders; private ListPreference mSearchableFolders;
private Preference mAutoExpandFolder; private Preference mAutoExpandFolder;
private Preference mChipColor;
private boolean mIncomingChanged = false; private boolean mIncomingChanged = false;
@ -322,14 +325,29 @@ public class AccountSettings extends K9PreferenceActivity
mAutoExpandFolder.setSummary(translateFolder(mAccount.getAutoExpandFolderName())); mAutoExpandFolder.setSummary(translateFolder(mAccount.getAutoExpandFolderName()));
mAutoExpandFolder.setOnPreferenceClickListener( mAutoExpandFolder.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() new Preference.OnPreferenceClickListener() {
{
public boolean onPreferenceClick(Preference preference) public boolean onPreferenceClick(Preference preference)
{ {
onChooseAutoExpandFolder(); onChooseAutoExpandFolder();
return false; 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( findPreference(PREFERENCE_COMPOSITION).setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() new Preference.OnPreferenceClickListener()
@ -489,6 +507,13 @@ public class AccountSettings extends K9PreferenceActivity
AccountSetupOutgoing.actionEditOutgoingSettings(this, mAccount); 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() public void onChooseAutoExpandFolder()
{ {
Intent selectIntent = new Intent(this, ChooseFolder.class); Intent selectIntent = new Intent(this, ChooseFolder.class);