summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtwebster <miketwebster@gmail.com>2010-08-25 16:30:10 -0400
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2011-08-21 23:48:57 +0100
commit3d238c13a01d01dc961ffd73c07c8995929d8ffb (patch)
tree2f39d7220ee263728067ea0bfd7134bf7040b7b9
parent3ecadc4c1d0132bac5b231a725fc41301dd9ee9d (diff)
downloadandroid_packages_apps_Email-3d238c13a01d01dc961ffd73c07c8995929d8ffb.tar.gz
android_packages_apps_Email-3d238c13a01d01dc961ffd73c07c8995929d8ffb.tar.bz2
android_packages_apps_Email-3d238c13a01d01dc961ffd73c07c8995929d8ffb.zip
Add customizable account 'color' chip - (credit to copolii)
will allow user to pick a specific color, rather than having it randomly assigned at account creation. Change-Id: I75e7d5d5043050b02a0029877aa5476b80a64f5d
-rw-r--r--res/drawable-hdpi/chip_mask.9.pngbin0 -> 241 bytes
-rw-r--r--res/drawable-mdpi/chip_mask.9.pngbin0 -> 188 bytes
-rw-r--r--res/layout/account_folder_list_item.xml13
-rw-r--r--res/layout/account_setup_color.xml222
-rw-r--r--res/layout/color_preference.xml55
-rw-r--r--res/layout/mailbox_list_item.xml13
-rw-r--r--res/layout/message_list_item.xml15
-rw-r--r--res/values/strings.xml8
-rw-r--r--res/xml/account_settings_preferences.xml14
-rw-r--r--src/com/android/email/Account.java145
-rw-r--r--src/com/android/email/Email.java15
-rw-r--r--src/com/android/email/LegacyConversions.java5
-rw-r--r--src/com/android/email/activity/AccountFolderList.java2
-rw-r--r--src/com/android/email/activity/MailboxList.java5
-rw-r--r--src/com/android/email/activity/MessageList.java11
-rw-r--r--src/com/android/email/activity/setup/AccountSettings.java30
-rw-r--r--src/com/android/email/activity/setup/AccountSetupColor.java245
-rw-r--r--src/com/android/email/activity/setup/AccountSetupOptions.java9
-rw-r--r--src/com/android/email/activity/setup/ColorPreference.java97
-rw-r--r--src/com/android/email/provider/EmailContent.java31
-rw-r--r--src/com/android/email/provider/EmailProvider.java59
-rw-r--r--src/com/android/exchange/utility/CalendarUtilities.java2
22 files changed, 897 insertions, 99 deletions
diff --git a/res/drawable-hdpi/chip_mask.9.png b/res/drawable-hdpi/chip_mask.9.png
new file mode 100644
index 000000000..2d9c8b863
--- /dev/null
+++ b/res/drawable-hdpi/chip_mask.9.png
Binary files differ
diff --git a/res/drawable-mdpi/chip_mask.9.png b/res/drawable-mdpi/chip_mask.9.png
new file mode 100644
index 000000000..e354cb7fc
--- /dev/null
+++ b/res/drawable-mdpi/chip_mask.9.png
Binary files differ
diff --git a/res/layout/account_folder_list_item.xml b/res/layout/account_folder_list_item.xml
index f87ec3e69..809cb8ee9 100644
--- a/res/layout/account_folder_list_item.xml
+++ b/res/layout/account_folder_list_item.xml
@@ -21,12 +21,17 @@
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingRight="4dip">
- <View
+ <RelativeLayout
android:id="@+id/chip"
- android:background="@drawable/appointment_indicator_leftside_1"
- android:layout_width="4dip"
android:layout_height="match_parent"
- android:layout_centerVertical="true" />
+ android:layout_width="4dip" >
+ <View
+ android:background="@drawable/chip_mask"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true" />
+ </RelativeLayout>
<ImageView
android:id="@+id/folder_icon"
android:layout_width="30dip"
diff --git a/res/layout/account_setup_color.xml b/res/layout/account_setup_color.xml
new file mode 100644
index 000000000..98170bca5
--- /dev/null
+++ b/res/layout/account_setup_color.xml
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fillViewport="true" >
+
+ <!-- Main container -->
+ <RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+
+ <!-- sample -->
+ <LinearLayout
+ android:id="@+id/sample_item"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="?android:attr/listPreferredItemHeight"
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:paddingRight="4dip"
+ android:layout_alignParentTop="true"
+ >
+ <View
+ android:id="@+id/sample_chip"
+ android:background="#ffffffff"
+ android:layout_width="4dip"
+ android:layout_height="fill_parent"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true" />
+
+ <ImageView
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_alignParentRight="true"
+ android:layout_marginLeft="4dip"
+ android:layout_marginRight="4dip"
+ android:minWidth="30dip"
+ android:src="@drawable/ic_list_folder" />
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:layout_weight="1">
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="8dip"
+ android:gravity="center_vertical"
+ android:orientation="vertical">
+ <TextView
+ android:text="@string/sample_account_name"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="?android:attr/textColorPrimary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ <!-- sample -->
+
+ <!-- NEXT Button -->
+ <RelativeLayout
+ android:id="@+id/nav_bar"
+ android:layout_alignParentBottom="true"
+ android:layout_width="fill_parent"
+ android:layout_height="54dip"
+ android:background="@android:drawable/bottom_bar">
+ <Button
+ android:id="@+id/next"
+ android:text="@string/next_action"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:minWidth="@dimen/button_minWidth"
+ android:drawableRight="@drawable/button_indicator_next"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true" />
+ </RelativeLayout>
+ <!-- NEXT Button -->
+
+ <!-- Current -->
+ <RelativeLayout
+ android:layout_below="@id/sample_item"
+ android:id="@+id/current_selection"
+ android:layout_width="fill_parent"
+ android:layout_height="50dip"
+
+ >
+ <View
+ android:id="@+id/color_sample"
+ android:background="#ffffffff"
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_marginLeft="15dip"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true" />
+ <TextView
+ android:id="@+id/color_html_code"
+ android:text="@string/default_html_color_code"
+ android:layout_toRightOf="@id/color_sample"
+ android:layout_marginRight="5dip"
+ android:layout_marginLeft="15dip"
+ android:layout_marginTop="2dip"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:textColor="#ffffff"
+ android:layout_centerVertical="true"
+ >
+ </TextView>
+ </RelativeLayout>
+ <!-- Current -->
+
+ <!-- Chooser -->
+ <LinearLayout
+ android:id="@+id/color_chooser"
+ android:layout_below="@id/current_selection"
+ android:layout_above="@id/nav_bar"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="100dip"
+ >
+ <!-- RED -->
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+ <TextView
+ android:layout_alignParentRight="true"
+ android:id="@+id/color_R_val"
+ android:textColor="#ff0000"
+ android:layout_marginRight="5dip"
+ android:text="@string/default_rgb_value"
+ android:layout_width="25dip"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"/>
+ <SeekBar
+ android:id="@+id/color_R"
+ android:layout_centerVertical="true"
+ android:layout_toLeftOf="@id/color_R_val"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:max="255"/>
+ </RelativeLayout>
+ <!-- RED -->
+
+ <!-- GREEN -->
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="15dip" >
+ <TextView
+ android:id="@+id/color_G_val"
+ android:textColor="#00ff00"
+ android:layout_width="25dip"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="5dip"
+ android:text="@string/default_rgb_value"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"/>
+ <SeekBar
+ android:id="@+id/color_G"
+ android:layout_toLeftOf="@id/color_G_val"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:max="255"
+ android:layout_centerVertical="true"/>
+ </RelativeLayout>
+ <!-- GREEN -->
+
+ <!-- BLUE -->
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="15dip" >
+ <TextView
+ android:id="@+id/color_B_val"
+ android:text="@string/default_rgb_value"
+ android:textColor="#0000ff"
+ android:layout_alignParentRight="true"
+ android:layout_marginRight="5dip"
+ android:layout_width="25dip"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"/>
+ <SeekBar
+ android:id="@+id/color_B"
+ android:layout_toLeftOf="@id/color_B_val"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:max="255"
+ android:layout_centerVertical="true"/>
+ </RelativeLayout>
+ <!-- BLUE -->
+
+ </LinearLayout>
+ <!-- Chooser -->
+
+ </RelativeLayout>
+ <!-- Main container -->
+</ScrollView>
diff --git a/res/layout/color_preference.xml b/res/layout/color_preference.xml
new file mode 100644
index 000000000..2c05ded93
--- /dev/null
+++ b/res/layout/color_preference.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="5dip" >
+
+ <View
+ android:id="@+id/color_prefs_chip"
+ android:background="#ffffff"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:layout_width="25dip"
+ android:layout_height="25dip"
+ android:layout_marginRight="15dip" />
+
+ <LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true"
+ android:layout_marginLeft="10dip"
+ >
+ <TextView
+ android:id="@+id/color_prefs_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textStyle="bold"
+ android:typeface="normal"
+ android:textSize="21dp"/>
+ <TextView
+ android:id="@+id/color_prefs_summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="14dp"
+ />
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/res/layout/mailbox_list_item.xml b/res/layout/mailbox_list_item.xml
index 390c2b84f..5f8ddc1f1 100644
--- a/res/layout/mailbox_list_item.xml
+++ b/res/layout/mailbox_list_item.xml
@@ -21,12 +21,17 @@
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingRight="8dip">
- <View
+ <RelativeLayout
android:id="@+id/chip"
- android:background="@drawable/appointment_indicator_leftside_1"
- android:layout_width="4dip"
android:layout_height="match_parent"
- android:layout_centerVertical="true" />
+ android:layout_width="4dip" >
+ <View
+ android:background="@drawable/chip_mask"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true" />
+ </RelativeLayout>
<ImageView
android:id="@+id/folder_icon"
android:layout_width="wrap_content"
diff --git a/res/layout/message_list_item.xml b/res/layout/message_list_item.xml
index a74c898e1..9e1d0b7dd 100644
--- a/res/layout/message_list_item.xml
+++ b/res/layout/message_list_item.xml
@@ -19,12 +19,17 @@
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:paddingRight="10dip">
- <View
- android:id="@+id/chip"
- android:background="@drawable/appointment_indicator_leftside_1"
- android:layout_width="4dip"
+ <RelativeLayout
+ android:id="@+id/chip"
android:layout_height="match_parent"
- android:layout_centerVertical="true" />
+ android:layout_width="4dip" >
+ <View
+ android:background="@drawable/chip_mask"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true" />
+ </RelativeLayout>
<!-- TODO: Remove the top padding hack and align to the subject baseline -->
<ImageView
android:id="@+id/selected"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4db71bca4..cd90e7a24 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -462,6 +462,8 @@ save attachment.</string>
<!-- In Account setup options screen, Activity title -->
<string name="account_setup_options_title">Account options</string>
+ <!-- In Account setup color screen, Activity title -->
+ <string name="account_setup_color_title">Account color</string>
<!-- In Account setup options screen, label for email check frequency selector -->
<string name="account_setup_options_mail_check_frequency_label">Inbox checking frequency</string>
<!-- In Account setup options & Account Settings screens, label for email check frequency option -->
@@ -575,6 +577,8 @@ save attachment.</string>
<!-- On Settings screen, setting option name and title of dialog box that opens -->
<string name="account_settings_mail_check_frequency_label">Inbox check frequency</string>
<!-- On Settings screen, setting option name -->
+ <string name="account_settings_color_label">Account color</string>
+ <!-- On Settings screen, setting option name -->
<string name="account_settings_incoming_label">Incoming settings</string>
<!-- On Settings screen, setting option name -->
<string name="account_settings_outgoing_label">Outgoing settings</string>
@@ -739,4 +743,8 @@ save attachment.</string>
<string name="toast_folder_hide_on">Hiding folder:</string>
<string name="toast_folder_hide_off">Unhiding folder:</string>
<string name="toast_folder_hide_invalid">Cannot hide this folder!</string>
+
+ <string name="sample_account_name" >Sample Account Name</string>
+ <string name="default_rgb_value" >255</string>
+ <string name="default_html_color_code" >0xFFFFFFFF</string>
</resources>
diff --git a/res/xml/account_settings_preferences.xml b/res/xml/account_settings_preferences.xml
index 9de5f71f7..008819e64 100644
--- a/res/xml/account_settings_preferences.xml
+++ b/res/xml/account_settings_preferences.xml
@@ -33,25 +33,31 @@
android:summary=""
android:dialogTitle="@string/account_settings_name_label" />
+ <com.android.email.activity.setup.ColorPreference
+ android:order="3"
+ android:key="color"
+ android:summary=""
+ android:title="@string/account_settings_color_label"/>
+
<EditTextPreference
- android:order="3"
+ android:order="4"
android:key="account_signature"
android:title="@string/account_settings_signature_label"
android:summary=""
android:dialogTitle="@string/account_settings_signature_label" />
<ListPreference
- android:order="4"
+ android:order="5"
android:key="account_check_frequency"
android:title="@string/account_settings_mail_check_frequency_label"
android:entries="@array/account_settings_check_frequency_entries"
android:entryValues="@array/account_settings_check_frequency_values"
android:dialogTitle="@string/account_settings_mail_check_frequency_label" />
- <!-- Reserve order#5 here for window size (if inserted) -->
+ <!-- Reserve order#6 here for window size (if inserted) -->
<CheckBoxPreference
- android:order="6"
+ android:order="7"
android:key="account_default"
android:title="@string/account_settings_default_label"
android:summary="@string/account_settings_default_summary" />
diff --git a/src/com/android/email/Account.java b/src/com/android/email/Account.java
index aea3467bd..527ef3b4c 100644
--- a/src/com/android/email/Account.java
+++ b/src/com/android/email/Account.java
@@ -62,6 +62,7 @@ public class Account {
String mDescription;
String mName;
String mEmail;
+ int mAccountColor;
int mAutomaticCheckIntervalMinutes;
long mLastAutomaticCheckTime;
boolean mNotifyNewMail;
@@ -96,7 +97,26 @@ public class Account {
private static final String KEY_PROTOCOL_VERSION = ".protocolVersion";
private static final String KEY_SECURITY_FLAGS = ".securityFlags";
private static final String KEY_SIGNATURE = ".signature";
- private static final String KEY_VIBRATE_WHEN_SILENT = ".vibrateWhenSilent";
+ private final String KEY_STORE_URI = ".storeUri";
+ private final String KEY_LOCALSTORE_URI = ".localStoreUri";
+ private final String KEY_SENDER_URI = ".senderUri";
+ private final String OLD_KEY_TRANSPORT_URI = ".transportUri";
+ private final String KEY_DESCRIPTION = ".description";
+ private final String KEY_NAME = ".name";
+ private final String KEY_EMAIL = ".email";
+ private final String KEY_ACCOUNT_COLOR = ".accountColor";
+ private final String KEY_AUTO_CHECK_INTERVAL_MINS = ".automaticCheckIntervalMinutes";
+ private final String KEY_LAST_AUTO_CHECK_TIME = ".lastAutomaticCheckTime";
+ private final String KEY_NOTIFY_NEW_MAIL = ".notifyNewMail";
+ private final String KEY_DELETE_POLICY = ".deletePolicy";
+ private final String KEY_DRAFTS_FOLDER_NAME = ".draftsFolderName";
+ private final String KEY_SENT_FOLDER_NAME = ".sentFolderName";
+ private final String KEY_TRASH_FOLDER_NAME = ".trashFolderName";
+ private final String KEY_OUTBOX_FOLDER_NAME = ".outboxFolderName";
+ private final String KEY_ACCOUNT_NUMBER = ".accountNumber";
+ private final String KEY_VIBRATE = ".vibrate";
+ private final String KEY_VIBRATE_WHEN_SILENT = ".vibrateWhenSilent";
+ private final String KEY_RINGTONE = ".ringtone";
public Account(Context context) {
// TODO Change local store path to something readable / recognizable
@@ -127,48 +147,51 @@ public class Account {
mPreferences = preferences;
mStoreUri = Utility.base64Decode(preferences.mSharedPreferences.getString(mUuid
- + ".storeUri", null));
- mLocalStoreUri = preferences.mSharedPreferences.getString(mUuid + ".localStoreUri", null);
+ + KEY_STORE_URI, null));
+ mLocalStoreUri = preferences.mSharedPreferences.getString(mUuid + KEY_LOCALSTORE_URI, null);
- String senderText = preferences.mSharedPreferences.getString(mUuid + ".senderUri", null);
+ String senderText = preferences.mSharedPreferences.getString(mUuid + KEY_SENDER_URI, null);
if (senderText == null) {
- // Preference ".senderUri" was called ".transportUri" in earlier versions, so we'll
+ // Preference KEY_SENDER_URI was called OLD_KEY_TRANSPORT_URI in earlier versions, so we'll
// do a simple upgrade here when necessary.
- senderText = preferences.mSharedPreferences.getString(mUuid + ".transportUri", null);
+ senderText = preferences.mSharedPreferences.getString(mUuid + OLD_KEY_TRANSPORT_URI, null);
}
mSenderUri = Utility.base64Decode(senderText);
- mDescription = preferences.mSharedPreferences.getString(mUuid + ".description", null);
- mName = preferences.mSharedPreferences.getString(mUuid + ".name", mName);
- mEmail = preferences.mSharedPreferences.getString(mUuid + ".email", mEmail);
+ mDescription = preferences.mSharedPreferences.getString(mUuid + KEY_DESCRIPTION, null);
+ mName = preferences.mSharedPreferences.getString(mUuid + KEY_NAME, mName);
+ mEmail = preferences.mSharedPreferences.getString(mUuid + KEY_EMAIL, mEmail);
+
+ mAccountColor = preferences.mSharedPreferences.getInt(mUuid + KEY_ACCOUNT_COLOR, 0xffffffff);
+
mAutomaticCheckIntervalMinutes = preferences.mSharedPreferences.getInt(mUuid
- + ".automaticCheckIntervalMinutes", -1);
+ + KEY_AUTO_CHECK_INTERVAL_MINS, -1);
mLastAutomaticCheckTime = preferences.mSharedPreferences.getLong(mUuid
- + ".lastAutomaticCheckTime", 0);
- mNotifyNewMail = preferences.mSharedPreferences.getBoolean(mUuid + ".notifyNewMail",
+ + KEY_LAST_AUTO_CHECK_TIME, 0);
+ mNotifyNewMail = preferences.mSharedPreferences.getBoolean(mUuid + KEY_NOTIFY_NEW_MAIL,
false);
// delete policy was incorrectly set on earlier versions, so we'll upgrade it here.
// rule: if IMAP account and policy = 0 ("never"), change policy to 2 ("on delete")
- mDeletePolicy = preferences.mSharedPreferences.getInt(mUuid + ".deletePolicy", 0);
+ mDeletePolicy = preferences.mSharedPreferences.getInt(mUuid + KEY_DELETE_POLICY, 0);
if (mDeletePolicy == DELETE_POLICY_NEVER &&
mStoreUri != null && mStoreUri.toString().startsWith(Store.STORE_SCHEME_IMAP)) {
mDeletePolicy = DELETE_POLICY_ON_DELETE;
}
- mDraftsFolderName = preferences.mSharedPreferences.getString(mUuid + ".draftsFolderName",
+ mDraftsFolderName = preferences.mSharedPreferences.getString(mUuid + KEY_DRAFTS_FOLDER_NAME,
"Drafts");
- mSentFolderName = preferences.mSharedPreferences.getString(mUuid + ".sentFolderName",
+ mSentFolderName = preferences.mSharedPreferences.getString(mUuid + KEY_SENT_FOLDER_NAME,
"Sent");
- mTrashFolderName = preferences.mSharedPreferences.getString(mUuid + ".trashFolderName",
+ mTrashFolderName = preferences.mSharedPreferences.getString(mUuid + KEY_TRASH_FOLDER_NAME,
"Trash");
- mOutboxFolderName = preferences.mSharedPreferences.getString(mUuid + ".outboxFolderName",
+ mOutboxFolderName = preferences.mSharedPreferences.getString(mUuid + KEY_OUTBOX_FOLDER_NAME,
"Outbox");
- mAccountNumber = preferences.mSharedPreferences.getInt(mUuid + ".accountNumber", 0);
- mVibrate = preferences.mSharedPreferences.getBoolean(mUuid + ".vibrate", false);
+ mAccountNumber = preferences.mSharedPreferences.getInt(mUuid + KEY_ACCOUNT_NUMBER, 0);
+ mVibrate = preferences.mSharedPreferences.getBoolean(mUuid + KEY_VIBRATE, false);
mVibrateWhenSilent = preferences.mSharedPreferences.getBoolean(mUuid +
KEY_VIBRATE_WHEN_SILENT, false);
- mRingtoneUri = preferences.mSharedPreferences.getString(mUuid + ".ringtone",
+ mRingtoneUri = preferences.mSharedPreferences.getString(mUuid + KEY_RINGTONE,
"content://settings/system/notification_sound");
mSyncWindow = preferences.mSharedPreferences.getInt(mUuid + KEY_SYNC_WINDOW,
@@ -224,6 +247,14 @@ public class Account {
public void setEmail(String email) {
this.mEmail = email;
}
+
+ public int getAccountColor () {
+ return mAccountColor;
+ }
+
+ public void setAccountColor (int color) {
+ mAccountColor = color;
+ }
public boolean isVibrate() {
return mVibrate;
@@ -264,24 +295,25 @@ public class Account {
SharedPreferences.Editor editor = preferences.mSharedPreferences.edit();
editor.putString("accountUuids", accountUuids);
- editor.remove(mUuid + ".storeUri");
- editor.remove(mUuid + ".localStoreUri");
- editor.remove(mUuid + ".senderUri");
- editor.remove(mUuid + ".description");
- editor.remove(mUuid + ".name");
- editor.remove(mUuid + ".email");
- editor.remove(mUuid + ".automaticCheckIntervalMinutes");
- editor.remove(mUuid + ".lastAutomaticCheckTime");
- editor.remove(mUuid + ".notifyNewMail");
- editor.remove(mUuid + ".deletePolicy");
- editor.remove(mUuid + ".draftsFolderName");
- editor.remove(mUuid + ".sentFolderName");
- editor.remove(mUuid + ".trashFolderName");
- editor.remove(mUuid + ".outboxFolderName");
- editor.remove(mUuid + ".accountNumber");
- editor.remove(mUuid + ".vibrate");
+ editor.remove(mUuid + KEY_STORE_URI);
+ editor.remove(mUuid + KEY_LOCALSTORE_URI);
+ editor.remove(mUuid + KEY_SENDER_URI);
+ editor.remove(mUuid + KEY_DESCRIPTION);
+ editor.remove(mUuid + KEY_NAME);
+ editor.remove(mUuid + KEY_EMAIL);
+ editor.remove(mUuid + KEY_ACCOUNT_COLOR);
+ editor.remove(mUuid + KEY_AUTO_CHECK_INTERVAL_MINS);
+ editor.remove(mUuid + KEY_LAST_AUTO_CHECK_TIME);
+ editor.remove(mUuid + KEY_NOTIFY_NEW_MAIL);
+ editor.remove(mUuid + KEY_DELETE_POLICY);
+ editor.remove(mUuid + KEY_DRAFTS_FOLDER_NAME);
+ editor.remove(mUuid + KEY_SENT_FOLDER_NAME);
+ editor.remove(mUuid + KEY_TRASH_FOLDER_NAME);
+ editor.remove(mUuid + KEY_OUTBOX_FOLDER_NAME);
+ editor.remove(mUuid + KEY_ACCOUNT_NUMBER);
+ editor.remove(mUuid + KEY_VIBRATE);
editor.remove(mUuid + KEY_VIBRATE_WHEN_SILENT);
- editor.remove(mUuid + ".ringtone");
+ editor.remove(mUuid + KEY_RINGTONE);
editor.remove(mUuid + KEY_SYNC_WINDOW);
editor.remove(mUuid + KEY_BACKUP_FLAGS);
editor.remove(mUuid + KEY_PROTOCOL_VERSION);
@@ -289,7 +321,7 @@ public class Account {
editor.remove(mUuid + KEY_SIGNATURE);
// also delete any deprecated fields
- editor.remove(mUuid + ".transportUri");
+ editor.remove(mUuid + OLD_KEY_TRANSPORT_URI);
editor.commit();
}
@@ -332,24 +364,25 @@ public class Account {
SharedPreferences.Editor editor = preferences.mSharedPreferences.edit();
- editor.putString(mUuid + ".storeUri", Utility.base64Encode(mStoreUri));
- editor.putString(mUuid + ".localStoreUri", mLocalStoreUri);
- editor.putString(mUuid + ".senderUri", Utility.base64Encode(mSenderUri));
- editor.putString(mUuid + ".description", mDescription);
- editor.putString(mUuid + ".name", mName);
- editor.putString(mUuid + ".email", mEmail);
- editor.putInt(mUuid + ".automaticCheckIntervalMinutes", mAutomaticCheckIntervalMinutes);
- editor.putLong(mUuid + ".lastAutomaticCheckTime", mLastAutomaticCheckTime);
- editor.putBoolean(mUuid + ".notifyNewMail", mNotifyNewMail);
- editor.putInt(mUuid + ".deletePolicy", mDeletePolicy);
- editor.putString(mUuid + ".draftsFolderName", mDraftsFolderName);
- editor.putString(mUuid + ".sentFolderName", mSentFolderName);
- editor.putString(mUuid + ".trashFolderName", mTrashFolderName);
- editor.putString(mUuid + ".outboxFolderName", mOutboxFolderName);
- editor.putInt(mUuid + ".accountNumber", mAccountNumber);
- editor.putBoolean(mUuid + ".vibrate", mVibrate);
+ editor.putString(mUuid + KEY_STORE_URI, Utility.base64Encode(mStoreUri));
+ editor.putString(mUuid + KEY_LOCALSTORE_URI, mLocalStoreUri);
+ editor.putString(mUuid + KEY_SENDER_URI, Utility.base64Encode(mSenderUri));
+ editor.putString(mUuid + KEY_DESCRIPTION, mDescription);
+ editor.putString(mUuid + KEY_NAME, mName);
+ editor.putString(mUuid + KEY_EMAIL, mEmail);
+ editor.putInt(mUuid + KEY_ACCOUNT_COLOR, mAccountColor);
+ editor.putInt(mUuid + KEY_AUTO_CHECK_INTERVAL_MINS, mAutomaticCheckIntervalMinutes);
+ editor.putLong(mUuid + KEY_LAST_AUTO_CHECK_TIME, mLastAutomaticCheckTime);
+ editor.putBoolean(mUuid + KEY_NOTIFY_NEW_MAIL, mNotifyNewMail);
+ editor.putInt(mUuid + KEY_DELETE_POLICY, mDeletePolicy);
+ editor.putString(mUuid + KEY_DRAFTS_FOLDER_NAME, mDraftsFolderName);
+ editor.putString(mUuid + KEY_SENT_FOLDER_NAME, mSentFolderName);
+ editor.putString(mUuid + KEY_TRASH_FOLDER_NAME, mTrashFolderName);
+ editor.putString(mUuid + KEY_OUTBOX_FOLDER_NAME, mOutboxFolderName);
+ editor.putInt(mUuid + KEY_ACCOUNT_NUMBER, mAccountNumber);
+ editor.putBoolean(mUuid + KEY_VIBRATE, mVibrate);
editor.putBoolean(mUuid + KEY_VIBRATE_WHEN_SILENT, mVibrateWhenSilent);
- editor.putString(mUuid + ".ringtone", mRingtoneUri);
+ editor.putString(mUuid + KEY_RINGTONE, mRingtoneUri);
editor.putInt(mUuid + KEY_SYNC_WINDOW, mSyncWindow);
editor.putInt(mUuid + KEY_BACKUP_FLAGS, mBackupFlags);
editor.putString(mUuid + KEY_PROTOCOL_VERSION, mProtocolVersion);
@@ -361,7 +394,7 @@ public class Account {
// editor.putString(mUuid + PREF_TAG_STORE_PERSISTENT, mStorePersistent);
// also delete any deprecated fields
- editor.remove(mUuid + ".transportUri");
+ editor.remove(mUuid + OLD_KEY_TRANSPORT_URI);
editor.commit();
}
diff --git a/src/com/android/email/Email.java b/src/com/android/email/Email.java
index d205c829d..f29b97b15 100644
--- a/src/com/android/email/Email.java
+++ b/src/com/android/email/Email.java
@@ -179,13 +179,22 @@ public class Email extends Application {
return Math.abs((int) (accountId - 1) % ACCOUNT_COLOR_CHIP_RES_IDS.length);
}
- public static int getAccountColorResourceId(long accountId) {
+ public static int getOldAccountColorResourceId(long accountId) {
return ACCOUNT_COLOR_CHIP_RES_IDS[getColorIndexFromAccountId(accountId)];
}
-
- public static int getAccountColor(long accountId) {
+
+ public static int getOldAccountColor(long accountId) {
return ACCOUNT_COLOR_CHIP_RGBS[getColorIndexFromAccountId(accountId)];
}
+
+ public static int getAccountColorResourceId(long accountId) {
+ return R.drawable.chip_mask;
+ }
+
+ @Deprecated
+ public static int getAccountColor(long accountId) {
+ return 0x00ffffff;
+ }
public static void setTempDirectory(Context context) {
sTempDirectory = context.getCacheDir();
diff --git a/src/com/android/email/LegacyConversions.java b/src/com/android/email/LegacyConversions.java
index 8979af115..953b4109b 100644
--- a/src/com/android/email/LegacyConversions.java
+++ b/src/com/android/email/LegacyConversions.java
@@ -624,7 +624,8 @@ public class LegacyConversions {
// int fromAccount.mNewMessageCount = will be reset on next sync
result.mSecurityFlags = fromAccount.mSecurityFlags;
result.mSignature = fromAccount.mSignature;
-
+ result.mAccountColor = fromAccount.mAccountColor;
+
// Use the existing conversions from HostAuth <-> Uri
result.setStoreUri(fromAccount.getStoreUri(context));
result.setSenderUri(fromAccount.getSenderUri(context));
@@ -668,6 +669,8 @@ public class LegacyConversions {
result.mSecurityFlags = fromAccount.mSecurityFlags;
result.mSecuritySyncKey = null;
result.mSignature = fromAccount.mSignature;
+ //result.mAccountColor = fromAccount.mAccountColor;
+ result.mAccountColor = Email.getOldAccountColor(fromAccount.mAccountNumber);
result.setStoreUri(context, fromAccount.getStoreUri());
result.setSenderUri(context, fromAccount.getSenderUri());
diff --git a/src/com/android/email/activity/AccountFolderList.java b/src/com/android/email/activity/AccountFolderList.java
index 8896171bd..9a65bb3f1 100644
--- a/src/com/android/email/activity/AccountFolderList.java
+++ b/src/com/android/email/activity/AccountFolderList.java
@@ -849,7 +849,7 @@ public class AccountFolderList extends ListActivity implements OnItemClickListen
long accountId = cursor.getLong(Account.CONTENT_ID_COLUMN);
View chipView = view.findViewById(R.id.chip);
- chipView.setBackgroundResource(Email.getAccountColorResourceId(accountId));
+ chipView.setBackgroundColor(cursor.getInt(Account.CONTENT_COLOR_COLUMN));
chipView.setVisibility(View.VISIBLE);
String text = cursor.getString(Account.CONTENT_DISPLAY_NAME_COLUMN);
diff --git a/src/com/android/email/activity/MailboxList.java b/src/com/android/email/activity/MailboxList.java
index 6345228d2..c86a4b155 100644
--- a/src/com/android/email/activity/MailboxList.java
+++ b/src/com/android/email/activity/MailboxList.java
@@ -707,8 +707,11 @@ public class MailboxList extends ListActivity implements OnItemClickListener, On
} else {
statusView.setVisibility(View.GONE);
}
+
+ long boxId = cursor.getLong(COLUMN_ID);
View chipView = view.findViewById(R.id.chip);
- chipView.setBackgroundResource(Email.getAccountColorResourceId(mAccountId));
+ chipView.setBackgroundColor(Account.restoreAccountWithId(mContext, Mailbox.restoreMailboxWithId(mContext, boxId).mAccountKey).getAccountColor());
+
// TODO do we use a different count for special mailboxes (total count vs. unread)
int count = -1;
switch (type) {
diff --git a/src/com/android/email/activity/MessageList.java b/src/com/android/email/activity/MessageList.java
index fc23f6a07..05794060a 100644
--- a/src/com/android/email/activity/MessageList.java
+++ b/src/com/android/email/activity/MessageList.java
@@ -283,8 +283,9 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
mLoadMessagesTask.execute();
addFooterView(mMailboxId, -1, -1);
} else {
- int mailboxType = intent.getIntExtra(EXTRA_MAILBOX_TYPE, Mailbox.TYPE_INBOX);
+ int mailboxType = intent.getIntExtra(EXTRA_MAILBOX_TYPE, Mailbox.TYPE_INBOX);
Uri uri = intent.getData();
+ // TODO Possible ANR. getAccountIdFromShortcutSafeUri accesses DB.
long accountId = (uri == null) ? -1
: Account.getAccountIdFromShortcutSafeUri(this, uri);
@@ -1293,9 +1294,9 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
// the position;
restoreListPosition();
autoRefreshStaleMailbox();
- MailService.resetNewMessageCount(MessageList.this, -1);
+ MailService.resetNewMessageCount(MessageList.this, -1);
+ }
}
- }
private class SetTitleTask extends AsyncTask<Void, Void, Object[]> {
@@ -1783,7 +1784,9 @@ public class MessageList extends ListActivity implements OnItemClickListener, On
// Load the UI
View chipView = view.findViewById(R.id.chip);
- chipView.setBackgroundResource(Email.getAccountColorResourceId(itemView.mAccountId));
+
+ EmailContent.Account acc = EmailContent.Account.restoreAccountWithId(mContext, itemView.mAccountId);
+ chipView.setBackgroundColor(acc.getAccountColor());
TextView fromView = (TextView) view.findViewById(R.id.from);
String text = cursor.getString(COLUMN_DISPLAY_NAME);
diff --git a/src/com/android/email/activity/setup/AccountSettings.java b/src/com/android/email/activity/setup/AccountSettings.java
index bd4fdf470..97171cca7 100644
--- a/src/com/android/email/activity/setup/AccountSettings.java
+++ b/src/com/android/email/activity/setup/AccountSettings.java
@@ -49,6 +49,7 @@ public class AccountSettings extends PreferenceActivity {
private static final String PREFERENCE_TOP_CATEGORY = "account_settings";
private static final String PREFERENCE_DESCRIPTION = "account_description";
private static final String PREFERENCE_NAME = "account_name";
+ private static final String PREFERENCE_COLOR = "color";
private static final String PREFERENCE_SIGNATURE = "account_signature";
private static final String PREFERENCE_FREQUENCY = "account_check_frequency";
private static final String PREFERENCE_DEFAULT = "account_default";
@@ -95,6 +96,7 @@ public class AccountSettings extends PreferenceActivity {
private CheckBoxPreference mMsgListOnDelete;
private CheckBoxPreference mConfirmOnDelete;
private CheckBoxPreference mConfirmOnSend;
+ private ColorPreference mColor;
/**
* Display (and edit) settings for a specific account
@@ -170,6 +172,18 @@ public class AccountSettings extends PreferenceActivity {
return false;
}
});
+
+ mColor = (ColorPreference)findPreference(PREFERENCE_COLOR);
+ int color = mAccount.getAccountColor();
+ mColor.setSummary("0x" + Integer.toHexString(color).toUpperCase());
+ mColor.setChipColor(color);
+ mColor.setOnPreferenceClickListener(
+ new Preference.OnPreferenceClickListener() {
+ public boolean onPreferenceClick(Preference preference) {
+ onColorSettings();
+ return true;
+ }
+ });
mAccountSignature = (EditTextPreference) findPreference(PREFERENCE_SIGNATURE);
mAccountSignature.setSummary(mAccount.getSignature());
@@ -358,6 +372,11 @@ public class AccountSettings extends PreferenceActivity {
return;
}
mAccount.setDeletePolicy(refreshedAccount.getDeletePolicy());
+
+ int newcol = refreshedAccount.getAccountColor();
+ mColor.setChipColor(newcol);
+ mColor.setSummary("0x" + Integer.toHexString(newcol).toUpperCase());
+
mAccountDirty = false;
}
}
@@ -410,6 +429,17 @@ public class AccountSettings extends PreferenceActivity {
return super.onKeyDown(keyCode, event);
}
+ private void onColorSettings () {
+ try {
+ java.lang.reflect.Method m = AccountSetupColor.class.getMethod("actionEditColorSettings",
+ android.app.Activity.class, Account.class);
+ m.invoke(null, this, mAccount);
+ mAccountDirty = true;
+ } catch (Exception e) {
+ Log.d(Email.LOG_TAG, "Error while trying to invoke store settings.", e);
+ }
+ }
+
private void onIncomingSettings() {
try {
Store store = Store.getInstance(mAccount.getStoreUri(this), getApplication(), null);
diff --git a/src/com/android/email/activity/setup/AccountSetupColor.java b/src/com/android/email/activity/setup/AccountSetupColor.java
new file mode 100644
index 000000000..5318d80b8
--- /dev/null
+++ b/src/com/android/email/activity/setup/AccountSetupColor.java
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.email.activity.setup;
+
+import com.android.email.AccountBackupRestore;
+import com.android.email.Email;
+import com.android.email.ExchangeUtils;
+import com.android.email.R;
+import com.android.email.mail.Store;
+import com.android.email.mail.store.ExchangeStore;
+import com.android.email.provider.EmailContent;
+import com.android.email.provider.EmailContent.Account;
+
+import android.accounts.AccountManagerCallback;
+import android.accounts.AccountManagerFuture;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.CheckBox;
+import android.widget.Spinner;
+import android.widget.SeekBar;
+import android.widget.TextView;
+import android.widget.Button;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class AccountSetupColor extends Activity implements OnClickListener, SeekBar.OnSeekBarChangeListener {
+ private static final String EXTRA_ACCOUNT = "account";
+ private static final String EXTRA_COLOR = "color";
+ private static final String EXTRA_EAS_FLOW = "easFlow";
+
+ private static final String TAG = "AccountSetupColor";
+
+ private static final int r = 0;
+ private static final int g = 1;
+ private static final int b = 2;
+ private static final int RGB_COMP_COUNT = 3;
+
+ private static String COMPONENT_NAMES[] = { "RED", "GREEN", "BLUE"};
+
+ final int RGB_SEEKBAR_MAX = 255;
+
+ private static final int SLIDER_IDS[] = {
+ R.id.color_R,
+ R.id.color_G,
+ R.id.color_B
+ };
+
+ private static final int RGB_VAL_IDS[] = {
+ R.id.color_R_val,
+ R.id.color_G_val,
+ R.id.color_B_val
+ };
+
+ private View mSampleChip; // sample_chip
+ private View mColorSample; // color_sample
+ private TextView mHtmlCode; // color_html_code
+ private TextView mRGBValue[]; // color_R_val
+ private SeekBar mRGBSlider []; // color_R
+
+ private Button mNext;
+
+ private EmailContent.Account mAccount;
+
+ private int mCurrentColor;
+
+ private boolean mEasFlowMode;
+
+ private boolean mEditMode;
+
+ public static void actionSetColor(Activity fromActivity, EmailContent.Account account,
+ boolean easFlowMode) {
+ Intent i = new Intent(fromActivity, AccountSetupColor.class);
+ i.putExtra(EXTRA_ACCOUNT, account);
+ i.putExtra(EXTRA_EAS_FLOW, easFlowMode);
+ fromActivity.startActivity(i);
+ }
+
+ public static void actionEditColorSettings(Activity fromActivity, EmailContent.Account account)
+ {
+ Intent i = new Intent(fromActivity, AccountSetupColor.class);
+ i.setAction(Intent.ACTION_EDIT);
+ i.putExtra(EXTRA_ACCOUNT, account);
+ fromActivity.startActivity(i);
+ }
+
+ private void initComponents ()
+ {
+ setContentView(R.layout.account_setup_color);
+
+ mSampleChip = (View)findViewById(R.id.sample_chip);
+ mColorSample = (View)findViewById(R.id.color_sample);
+ mHtmlCode = (TextView)findViewById(R.id.color_html_code);
+
+ mRGBValue = new TextView[RGB_COMP_COUNT];
+ mRGBSlider = new SeekBar[RGB_COMP_COUNT];
+
+ for (int i = r; i < RGB_COMP_COUNT; i++)
+ {
+ mRGBValue[i] = (TextView)findViewById(RGB_VAL_IDS[i]);
+ mRGBSlider[i] = (SeekBar)findViewById(SLIDER_IDS[i]);
+ initSeeKbar(mRGBSlider[i]);
+ }
+
+ mNext = (Button)findViewById(R.id.next);
+ mNext.setOnClickListener(this);
+ }
+
+ private void initSeeKbar (SeekBar item)
+ {
+ item.setMax(RGB_SEEKBAR_MAX);
+ item.setKeyProgressIncrement(1);
+
+ if (!mEditMode)
+ {
+ item.setProgress((int)(Math.random() * RGB_SEEKBAR_MAX));
+ item.invalidate();
+ }
+
+ item.setOnSeekBarChangeListener(this);
+ }
+
+ private void updateColor ()
+ {
+ int rgb[] = new int [RGB_COMP_COUNT];
+
+ for (int i = r; i < RGB_COMP_COUNT; i++)
+ {
+ rgb[i] = mRGBSlider[i].getProgress();
+ mRGBValue[i].setText(rgb[i] + "");
+ }
+
+ mCurrentColor = Color.argb(RGB_SEEKBAR_MAX, rgb[r], rgb[g], rgb[b]);
+
+ mSampleChip.setBackgroundColor(mCurrentColor);
+ mColorSample.setBackgroundColor(mCurrentColor);
+ mHtmlCode.setTextColor(mCurrentColor);
+ mHtmlCode.setText("0x" + Integer.toHexString(mCurrentColor).toUpperCase());
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ initComponents ();
+ mAccount = (EmailContent.Account) getIntent().getParcelableExtra(EXTRA_ACCOUNT);
+ mEditMode = Intent.ACTION_EDIT.equals(getIntent().getAction());
+
+ if (mEditMode) {
+ mAccount = Account.restoreAccountWithId(this, mAccount.mId);
+ mCurrentColor = mAccount.getAccountColor();
+ }
+ else
+ {
+ // Setup any additional items to support EAS & EAS flow mode
+ mEasFlowMode = getIntent().getBooleanExtra(EXTRA_EAS_FLOW, false);
+ }
+
+ int rgb[] = {Color.red(mCurrentColor), Color.green(mCurrentColor), Color.blue(mCurrentColor)};
+
+ for (int i = r; i < RGB_COMP_COUNT; i++)
+ {
+ mRGBSlider[i].setProgress(rgb[i]);
+ }
+
+ updateColor ();
+ }
+
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
+ {
+ updateColor ();
+ }
+
+ public void onStartTrackingTouch(SeekBar seekBar)
+ {
+ // do nothing
+ }
+
+ public void onStopTrackingTouch(SeekBar seekBar)
+ {
+ // do nothing
+ }
+
+ private void onDone() {
+ updateColor ();
+ mAccount.setAccountColor(mCurrentColor);
+
+ if (mEditMode)
+ {
+ if (mAccount.isSaved()) {
+ mAccount.update(this, mAccount.toContentValues());
+ } else {
+ mAccount.save(this);
+ }
+ // Update the backup (side copy) of the accounts
+ AccountBackupRestore.backupAccounts(this);
+ finish();
+ }
+ else {
+ // Clear the incomplete flag now
+ mAccount.mFlags &= ~Account.FLAGS_INCOMPLETE;
+ AccountSettingsUtils.commitSettings(this, mAccount);
+ Email.setServicesEnabled(this);
+ AccountSetupNames.actionSetNames(this, mAccount.mId, mEasFlowMode);
+ // Start up SyncManager (if it isn't already running)
+ ExchangeUtils.startExchangeService(this);
+ }
+ }
+
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.next:
+ onDone();
+ break;
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/src/com/android/email/activity/setup/AccountSetupOptions.java b/src/com/android/email/activity/setup/AccountSetupOptions.java
index 1be825b2a..2a6a810e9 100644
--- a/src/com/android/email/activity/setup/AccountSetupOptions.java
+++ b/src/com/android/email/activity/setup/AccountSetupOptions.java
@@ -185,13 +185,8 @@ public class AccountSetupOptions extends Activity implements OnClickListener {
}
private void finishOnDone() {
- // Clear the incomplete flag now
- mAccount.mFlags &= ~Account.FLAGS_INCOMPLETE;
- AccountSettingsUtils.commitSettings(this, mAccount);
- Email.setServicesEnabled(this);
- AccountSetupNames.actionSetNames(this, mAccount.mId, mEasFlowMode);
- // Start up SyncManager (if it isn't already running)
- ExchangeUtils.startExchangeService(this);
+ // Let's get the account color too
+ AccountSetupColor.actionSetColor(this, mAccount, mEasFlowMode);
finish();
}
diff --git a/src/com/android/email/activity/setup/ColorPreference.java b/src/com/android/email/activity/setup/ColorPreference.java
new file mode 100644
index 000000000..0f89ba091
--- /dev/null
+++ b/src/com/android/email/activity/setup/ColorPreference.java
@@ -0,0 +1,97 @@
+package com.android.email.activity.setup;
+
+import com.android.email.R;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Typeface;
+import android.preference.Preference;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+public class ColorPreference extends Preference {
+ private static final int DEFAULT_COLOR = 0xffffffff;
+
+ private int mColor;
+ private View mColorChip;
+ private TextView mSummary;
+
+
+ public ColorPreference(Context context) {
+ super(context);
+ mColor = DEFAULT_COLOR;
+ }
+
+ public ColorPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mColor = DEFAULT_COLOR;
+ }
+
+ public ColorPreference(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ mColor = DEFAULT_COLOR;
+ }
+
+ @Override
+ protected View onCreateView(ViewGroup parent){
+ Context context = getContext();
+ LayoutInflater li = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+ View v = li.inflate(R.layout.color_preference, null);
+
+ mColorChip = v.findViewById(R.id.color_prefs_chip);
+ TextView title = (TextView)v.findViewById(R.id.color_prefs_title);
+ mSummary = (TextView)v.findViewById(R.id.color_prefs_summary);
+
+ setChipColor(mColor);
+ title.setText(getTitle());
+ setSummary(getSummary());
+
+ v.setId(android.R.id.widget_frame);
+ return v;
+ }
+
+ public void setChipColor (int color)
+ {
+ mColor = color;
+ notifyChanged();
+ }
+
+ @Override
+ public void setSummary(CharSequence summary) {
+ super.setSummary(summary);
+ notifyChanged();
+ }
+
+ @Override
+ protected void notifyChanged() {
+ super.notifyChanged();
+ persistInt(mColor);
+
+ if (null != mSummary) mSummary.setText(getSummary());
+ if (null != mColorChip) mColorChip.setBackgroundColor(mColor);
+ }
+
+ @Override
+ protected void onSetInitialValue(boolean restorePersistedValue,
+ Object defaultValue) {
+ mColor = restorePersistedValue ? getPersistedInt(mColor): (Integer)defaultValue;
+
+ if (shouldPersist())
+ persistInt(mColor);
+
+ notifyChanged();
+ }
+
+ @Override
+ protected Object onGetDefaultValue(TypedArray ta,int index){
+ int val = ta.getInt(index,DEFAULT_COLOR);
+ notifyChanged();
+ return val;
+ }
+}
diff --git a/src/com/android/email/provider/EmailContent.java b/src/com/android/email/provider/EmailContent.java
index 96e77cadb..f1cf2fed6 100644
--- a/src/com/android/email/provider/EmailContent.java
+++ b/src/com/android/email/provider/EmailContent.java
@@ -792,6 +792,8 @@ public abstract class EmailContent {
public static final String DISPLAY_NAME = "displayName";
// The email address corresponding to this account
public static final String EMAIL_ADDRESS = "emailAddress";
+ // The color associated with this account
+ public static final String ACCOUNT_COLOR = "accountColor";
// A server-based sync key on an account-wide basis (EAS needs this)
public static final String SYNC_KEY = "syncKey";
// The default sync lookback period for this account
@@ -867,6 +869,7 @@ public abstract class EmailContent {
public int mSecurityFlags;
public String mSecuritySyncKey;
public String mSignature;
+ public int mAccountColor;
// Convenience for creating an account
public transient HostAuth mHostAuthRecv;
@@ -890,7 +893,7 @@ public abstract class EmailContent {
public static final int CONTENT_SECURITY_FLAGS_COLUMN = 15;
public static final int CONTENT_SECURITY_SYNC_KEY_COLUMN = 16;
public static final int CONTENT_SIGNATURE_COLUMN = 17;
- public static final int CONTENT_IS_EAS_COLUMN = 18;
+ public static final int CONTENT_COLOR_COLUMN = 18;
public static final String[] CONTENT_PROJECTION = new String[] {
RECORD_ID, AccountColumns.DISPLAY_NAME,
@@ -900,7 +903,8 @@ public abstract class EmailContent {
AccountColumns.COMPATIBILITY_UUID, AccountColumns.SENDER_NAME,
AccountColumns.RINGTONE_URI, AccountColumns.PROTOCOL_VERSION,
AccountColumns.NEW_MESSAGE_COUNT, AccountColumns.SECURITY_FLAGS,
- AccountColumns.SECURITY_SYNC_KEY, AccountColumns.SIGNATURE
+ AccountColumns.SECURITY_SYNC_KEY, AccountColumns.SIGNATURE,
+ AccountColumns.ACCOUNT_COLOR
};
public static final int CONTENT_MAILBOX_TYPE_COLUMN = 1;
@@ -959,7 +963,7 @@ public abstract class EmailContent {
/**
* Refresh an account that has already been loaded. This is slightly less expensive
- * that generating a brand-new account object.
+ * than generating a brand-new account object.
*/
public void refresh(Context context) {
Cursor c = context.getContentResolver().query(this.getUri(), Account.CONTENT_PROJECTION,
@@ -996,6 +1000,7 @@ public abstract class EmailContent {
mSecurityFlags = cursor.getInt(CONTENT_SECURITY_FLAGS_COLUMN);
mSecuritySyncKey = cursor.getString(CONTENT_SECURITY_SYNC_KEY_COLUMN);
mSignature = cursor.getString(CONTENT_SIGNATURE_COLUMN);
+ mAccountColor = cursor.getInt(CONTENT_COLOR_COLUMN);
return this;
}
@@ -1032,8 +1037,25 @@ public abstract class EmailContent {
public void setEmailAddress(String emailAddress) {
mEmailAddress = emailAddress;
}
+
+ /**
+ * @return the color associated with this account
+ */
+ public int getAccountColor ()
+ {
+ return mAccountColor;
+ }
/**
+ * Associate a color with this account
+ * @param col the new color for this account
+ */
+ public void setAccountColor (int col)
+ {
+ mAccountColor = col;
+ }
+
+ /**
* @return the sender's name for this account
*/
public String getSenderName() {
@@ -1510,6 +1532,7 @@ public abstract class EmailContent {
values.put(AccountColumns.SECURITY_FLAGS, mSecurityFlags);
values.put(AccountColumns.SECURITY_SYNC_KEY, mSecuritySyncKey);
values.put(AccountColumns.SIGNATURE, mSignature);
+ values.put(AccountColumns.ACCOUNT_COLOR, mAccountColor);
return values;
}
@@ -1557,6 +1580,7 @@ public abstract class EmailContent {
dest.writeInt(mSecurityFlags);
dest.writeString(mSecuritySyncKey);
dest.writeString(mSignature);
+ dest.writeInt(mAccountColor);
if (mHostAuthRecv != null) {
dest.writeByte((byte)1);
@@ -1596,6 +1620,7 @@ public abstract class EmailContent {
mSecurityFlags = in.readInt();
mSecuritySyncKey = in.readString();
mSignature = in.readString();
+ mAccountColor = in.readInt();
mHostAuthRecv = null;
if (in.readByte() == 1) {
diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java
index 8836d3dc5..6baea6141 100644
--- a/src/com/android/email/provider/EmailProvider.java
+++ b/src/com/android/email/provider/EmailProvider.java
@@ -81,7 +81,8 @@ public class EmailProvider extends ContentProvider {
// Version 10: Add meeting info to message table
// Version 11: Add content and flags to attachment table
// Version 12: Add content_bytes to attachment table. content is deprecated.
- public static final int DATABASE_VERSION = 12;
+ // version 13: Add accountColor field to the Account table
+ public static final int DATABASE_VERSION = 13;
// Any changes to the database format *must* include update-in-place code.
// Original version: 2
@@ -90,7 +91,7 @@ public class EmailProvider extends ContentProvider {
// Version 5: Database wipe required; changing AccountManager interface w/Exchange
// Version 6: Adding Body.mIntroText column
public static final int BODY_DATABASE_VERSION = 6;
-
+
public static final String EMAIL_AUTHORITY = "com.android.email.provider";
private static final int ACCOUNT_BASE = 0;
@@ -417,7 +418,8 @@ public class EmailProvider extends ContentProvider {
+ AccountColumns.NEW_MESSAGE_COUNT + " integer, "
+ AccountColumns.SECURITY_FLAGS + " integer, "
+ AccountColumns.SECURITY_SYNC_KEY + " text, "
- + AccountColumns.SIGNATURE + " text "
+ + AccountColumns.SIGNATURE + " text, "
+ + AccountColumns.ACCOUNT_COLOR + "integer"
+ ");";
db.execSQL("create table " + Account.TABLE_NAME + s);
// Deleting an account deletes associated Mailboxes and HostAuth's
@@ -430,7 +432,7 @@ public class EmailProvider extends ContentProvider {
" where " + EmailContent.RECORD_ID + "=old." + AccountColumns.HOST_AUTH_KEY_SEND +
"; end");
}
-
+
static void resetAccountTable(SQLiteDatabase db, int oldVersion, int newVersion) {
try {
db.execSQL("drop table " + Account.TABLE_NAME);
@@ -438,7 +440,7 @@ public class EmailProvider extends ContentProvider {
}
createAccountTable(db);
}
-
+
static void createHostAuthTable(SQLiteDatabase db) {
String s = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
+ HostAuthColumns.PROTOCOL + " text, "
@@ -680,6 +682,36 @@ public class EmailProvider extends ContentProvider {
createHostAuthTable(db);
createAccountTable(db);
}
+
+ void preserveAccountColors (SQLiteDatabase db)
+ {
+ String [] cols = {AccountColumns.ID};
+ Cursor c = db.query(Account.TABLE_NAME, cols, null, null, null, null, null);
+ int count = c.getCount();
+ try {
+ if (0 == count) return; // nothing to update
+
+ Log.i(TAG, "Attempting to preserve account colors for " + count + " accounts");
+
+ while (c.moveToNext())
+ {
+ long id = c.getLong(0);
+ int oldColor = Email.getOldAccountColor(id);
+
+ String sql_query = "update " + Account.TABLE_NAME + " set " + AccountColumns.ACCOUNT_COLOR + "=" + oldColor + " where " + AccountColumns.ID + "=" + id + ";";
+
+ try {
+ db.execSQL(sql_query);
+ Log.i(TAG, "Preserved color 0x" + Integer.toHexString(oldColor) + " for account with id " + id);
+ }
+ catch (Exception e){
+ Log.i(TAG, "Failed to preserve color 0x" + Integer.toHexString(oldColor) + " for account with id " + id);
+ }
+ }
+ } finally {
+ c.close();
+ }
+ }
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
@@ -782,6 +814,23 @@ public class EmailProvider extends ContentProvider {
}
oldVersion = 12;
}
+ if (oldVersion == 12)
+ {
+ // add the color column to the table
+ try {
+ db.execSQL("alter table " + Account.TABLE_NAME
+ + " add column " + AccountColumns.ACCOUNT_COLOR + " integer;");
+
+ Log.i(TAG, "EmailProvider.db upgraded from version 12 to 13 ");
+ } catch (SQLException e) {
+ Log.w(TAG, "Exception upgrading EmailProvider.db from 12 to 13 " + e);
+ }
+
+ // attempt to preserve the colors
+ preserveAccountColors (db);
+
+ oldVersion = 13;
+ }
}
@Override
diff --git a/src/com/android/exchange/utility/CalendarUtilities.java b/src/com/android/exchange/utility/CalendarUtilities.java
index 21108fe4d..1131009c5 100644
--- a/src/com/android/exchange/utility/CalendarUtilities.java
+++ b/src/com/android/exchange/utility/CalendarUtilities.java
@@ -1221,7 +1221,7 @@ public class CalendarUtilities {
// TODO Coordinate account colors w/ Calendar, if possible
// Make Email account color opaque
- cv.put(Calendars.COLOR, 0xFF000000 | Email.getAccountColor(account.mId));
+ cv.put(Calendars.COLOR, 0xFF000000 | account.getAccountColor());
cv.put(Calendars.TIMEZONE, Time.getCurrentTimezone());
cv.put(Calendars.ACCESS_LEVEL, Calendars.OWNER_ACCESS);
cv.put(Calendars.OWNER_ACCOUNT, account.mEmailAddress);