Merge "Remove illegal state exception entirely"
diff --git a/res/layout/contact_tile_frequent.xml b/res/layout/contact_tile_frequent.xml
index 4ba7396..fc9c04c 100644
--- a/res/layout/contact_tile_frequent.xml
+++ b/res/layout/contact_tile_frequent.xml
@@ -21,27 +21,44 @@
android:paddingRight="16dip"
android:paddingLeft="16dip" >
- <LinearLayout
+ <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <TextView
- android:id="@+id/contact_tile_name"
- android:layout_width="0dip"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:textSize="18sp"
- android:singleLine="true"
- android:ellipsize="end"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:paddingTop="24dip" />
-
<QuickContactBadge
android:id="@+id/contact_tile_quick"
android:layout_width="64dip"
android:layout_height="64dip"
- android:scaleType="centerCrop" />
+ android:scaleType="centerCrop"
+ android:layout_alignParentRight="true" />
- </LinearLayout>
+ <TextView
+ android:id="@+id/contact_tile_name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:layout_toLeftOf="@id/contact_tile_quick" />
+
+ <ImageView
+ android:id="@+id/contact_tile_presence"
+ android:layout_width="16dip"
+ android:layout_height="16dip"
+ android:layout_below="@id/contact_tile_name"
+ android:layout_alignParentLeft="true" />
+
+ <TextView
+ android:id="@+id/contact_tile_status"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="12sp"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:textColor="#cccccc"
+ android:layout_toRightOf="@id/contact_tile_presence"
+ android:layout_below="@id/contact_tile_name" />
+
+ </RelativeLayout>
</view>
diff --git a/res/layout/contact_tile_starred.xml b/res/layout/contact_tile_starred.xml
index 6cdf213..ba1dff2 100644
--- a/res/layout/contact_tile_starred.xml
+++ b/res/layout/contact_tile_starred.xml
@@ -30,11 +30,36 @@
<View
android:id="@+id/contact_tile_background"
- style="@style/ContactTileStarredTextBackground" />
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/contact_tile_shadowbox_height"
+ android:layout_alignParentBottom="true"
+ style="@style/ContactTileStarredShadowBox" />
+
+ <ImageView
+ android:id="@+id/contact_tile_presence"
+ android:layout_width="16dip"
+ android:layout_height="16dip"
+ android:layout_alignParentBottom="true"
+ android:layout_marginLeft="8dip"
+ android:layout_marginBottom="10dip" />
<TextView
android:id="@+id/contact_tile_name"
- style="@style/ContactTileStarredText" />
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@id/contact_tile_presence"
+ android:layout_above="@id/contact_tile_presence"
+ android:textColor="@android:color/white"
+ stlye="@style/ContactTileStarredName" />
+
+ <TextView
+ android:id="@+id/contact_tile_status"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/contact_tile_presence"
+ android:layout_below="@id/contact_tile_name"
+ android:layout_marginLeft="4dip"
+ style="@style/ContactTileStatusText" />
</RelativeLayout>
diff --git a/res/layout/contact_tile_starred_quick_contact.xml b/res/layout/contact_tile_starred_quick_contact.xml
index 241ab54..0fb580e 100644
--- a/res/layout/contact_tile_starred_quick_contact.xml
+++ b/res/layout/contact_tile_starred_quick_contact.xml
@@ -30,11 +30,36 @@
<View
android:id="@+id/contact_tile_background"
- style="@style/ContactTileStarredTextBackground" />
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/contact_tile_shadowbox_height"
+ android:layout_alignParentBottom="true"
+ style="@style/ContactTileStarredShadowBox" />
+
+ <ImageView
+ android:id="@+id/contact_tile_presence"
+ android:layout_width="16dip"
+ android:layout_height="16dip"
+ android:layout_alignParentBottom="true"
+ android:layout_marginLeft="8dip"
+ android:layout_marginBottom="10dip" />
<TextView
android:id="@+id/contact_tile_name"
- style="@style/ContactTileStarredText" />
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@id/contact_tile_presence"
+ android:layout_above="@id/contact_tile_presence"
+ android:textColor="@android:color/white"
+ stlye="@style/ContactTileStarredName" />
+
+ <TextView
+ android:id="@+id/contact_tile_status"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/contact_tile_presence"
+ android:layout_below="@id/contact_tile_name"
+ android:layout_marginLeft="4dip"
+ style="@style/ContactTileStatusText" />
</RelativeLayout>
diff --git a/res/layout/contact_tile_starred_secondary_target.xml b/res/layout/contact_tile_starred_secondary_target.xml
index a8ae00f..5d4e55e 100644
--- a/res/layout/contact_tile_starred_secondary_target.xml
+++ b/res/layout/contact_tile_starred_secondary_target.xml
@@ -30,24 +30,32 @@
<View
android:id="@+id/contact_tile_background"
- style="@style/ContactTileStarredTextBackground" />
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/contact_tile_shadowbox_height"
+ android:layout_alignParentBottom="true"
+ style="@style/ContactTileStarredShadowBox" />
<LinearLayout
- android:orientation="horizontal"
- style="@style/ContactTileStarredText">
+ android:layout_width="match_parent"
+ android:layout_height="48dip"
+ android:layout_alignParentBottom="true"
+ android:orientation="horizontal" >
<TextView
android:id="@+id/contact_tile_name"
- style="@style/ContactTileStarredText"
android:layout_width="0dip"
- android:layout_weight="2" />
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:gravity="center_vertical"
+ android:layout_marginLeft="8dip"
+ android:textColor="@android:color/white"
+ stlye="@style/ContactTileStarredName" />
<ImageButton
android:id="@+id/contact_tile_secondary_button"
android:src="@drawable/ic_tab_unselected_contacts"
android:layout_height="match_parent"
- android:layout_width="0dip"
- android:layout_weight="1" />
+ android:layout_width="wrap_content" />
</LinearLayout>
diff --git a/res/layout/group_browse_list_item.xml b/res/layout/group_browse_list_item.xml
index d94d444..b829704 100644
--- a/res/layout/group_browse_list_item.xml
+++ b/res/layout/group_browse_list_item.xml
@@ -22,42 +22,13 @@
android:layout_height="wrap_content"
style="@style/GroupBrowseListItem">
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="0dip"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:padding="5dip">
-
- <TextView
- android:id="@+id/label"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:gravity="center_vertical"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:ellipsize="end"
- android:singleLine="true" />
-
- <TextView
- android:id="@+id/account"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:gravity="center_vertical"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/textColorSecondary"
- android:ellipsize="end"
- android:singleLine="true"
- android:textStyle="italic" />
-
- </LinearLayout>
-
- <ImageView
- android:id="@+id/icon"
- android:scaleType="center"
+ <TextView
+ android:id="@+id/label"
+ android:layout_height="wrap_content"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_marginRight="20dip"
- android:layout_gravity="center_vertical"
- android:src="@drawable/ic_menu_display_all_holo_light" />
+ android:padding="10dip"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:ellipsize="end"
+ android:singleLine="true" />
</view>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b79bf0f..e155cbc 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -211,4 +211,7 @@
<dimen name="contact_browser_list_left_margin">24dip</dimen>
<dimen name="contact_browser_list_top_margin">8dip</dimen>
<dimen name="contacts_count_right_margin">40dip</dimen>
+
+ <!-- ContactTile Layouts -->
+ <dimen name="contact_tile_shadowbox_height">48dip</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cf4fff8..75e3249 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1650,4 +1650,14 @@
<!-- Menu item used to show only voicemails in the call log. [CHAR LIMIT=30] -->
<string name="menu_show_voicemails_only">Show voicemails only</string>
+
+ <!-- Used to display as default status when the contact is available for chat [CHAR LIMIT=19] -->
+ <string name="status_available">Available</string>
+
+ <!-- Used to display as default status when the contact is away or idle for chat [CHAR LIMIT=19] -->
+ <string name="status_away">Away</string>
+
+ <!-- Used to display as default status when the contact is busy or Do not disturb for chat [CHAR LIMIT=19] -->
+ <string name="status_busy">Busy</string>
+
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index e4b7525..d16590e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -360,24 +360,20 @@
<item name="android:background">@drawable/list_selector</item>
</style>
- <style name="ContactTileStarredText">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">48dip</item>
- <item name="android:layout_alignParentBottom">true</item>
- <item name="android:layout_alignParentLeft">true</item>
- <item name="android:gravity">center_vertical</item>
- <item name="android:paddingLeft">8dip</item>
+ <style name="ContactTileStarredName">
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
- <item name="android:textColor">@android:color/white</item>
- <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+ <item name="android:textSize">16sp</item>
</style>
- <style name="ContactTileStarredTextBackground">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">48dip</item>
- <item name="android:layout_alignParentBottom">true</item>
- <item name="android:layout_alignParentLeft">true</item>
+ <style name="ContactTileStatusText">
+ <item name="android:singleLine">true</item>
+ <item name="android:ellipsize">end</item>
+ <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
+ <item name="android:textColor">#777777</item>
+ </style>
+
+ <style name="ContactTileStarredShadowBox">
<item name="android:alpha">0.5</item>
<item name="android:background">@android:color/black</item>
</style>
diff --git a/src/com/android/contacts/ContactTileLoaderFactory.java b/src/com/android/contacts/ContactTileLoaderFactory.java
index 20ad26e..e90730a 100644
--- a/src/com/android/contacts/ContactTileLoaderFactory.java
+++ b/src/com/android/contacts/ContactTileLoaderFactory.java
@@ -33,13 +33,17 @@
public final static int STARRED = 2;
public final static int PHOTO_URI = 3;
public final static int LOOKUP_KEY = 4;
+ public final static int CONTACT_PRESENCE = 5;
+ public final static int CONTACT_STATUS = 6;
private static final String[] COLUMNS = new String[] {
Contacts._ID,
Contacts.DISPLAY_NAME,
Contacts.STARRED,
Contacts.PHOTO_URI,
- Contacts.LOOKUP_KEY
+ Contacts.LOOKUP_KEY,
+ Contacts.CONTACT_PRESENCE,
+ Contacts.CONTACT_STATUS,
};
public static CursorLoader createStrequentLoader(Context context) {
diff --git a/src/com/android/contacts/GroupMemberLoader.java b/src/com/android/contacts/GroupMemberLoader.java
index 452c5d0..9605747 100644
--- a/src/com/android/contacts/GroupMemberLoader.java
+++ b/src/com/android/contacts/GroupMemberLoader.java
@@ -53,6 +53,7 @@
Data.LOOKUP_KEY, // 11
Data.PHONETIC_NAME, // 12
Data.HAS_PHONE_NUMBER, // 13
+ Data.CONTACT_STATUS, // 14
};
private final long mGroupId;
@@ -71,6 +72,7 @@
public static final int CONTACT_LOOKUP_KEY_COLUMN_INDEX = 11;
public static final int CONTACT_PHONETIC_NAME_COLUMN_INDEX = 12;
public static final int CONTACT_HAS_PHONE_COLUMN_INDEX = 13;
+ public static final int CONTACT_STATUS_COLUMN_INDEX = 14;
public GroupMemberLoader(Context context, long groupId) {
super(context);
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 1ec590c..5d9494c 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -625,7 +625,7 @@
}
@Override
- public void onDeleted(Editor removedEditor) {
+ public void onDeleteRequested(Editor removedEditor) {
}
};
@@ -1673,7 +1673,9 @@
}
@Override
- public void onDeleted(Editor removedEditor) {
+ public void onDeleteRequested(Editor removedEditor) {
+ // The picture cannot be deleted, it can only be removed, which is handled by
+ // onRemovePictureChosen()
}
/**
@@ -1697,7 +1699,7 @@
* User has chosen to remove a picture
*/
@Override
- public void onRemovePictureChose() {
+ public void onRemovePictureChosen() {
mEditor.setPhotoBitmap(null);
}
diff --git a/src/com/android/contacts/editor/Editor.java b/src/com/android/contacts/editor/Editor.java
index a70bf3f..423ca94 100644
--- a/src/com/android/contacts/editor/Editor.java
+++ b/src/com/android/contacts/editor/Editor.java
@@ -30,9 +30,9 @@
public interface EditorListener {
/**
- * Called when the given {@link Editor} has been deleted.
+ * Called when the given {@link Editor} is requested to be deleted by the user.
*/
- public void onDeleted(Editor editor);
+ public void onDeleteRequested(Editor editor);
/**
* Called when the given {@link Editor} has a request, for example it
@@ -75,4 +75,14 @@
* allowing advanced editors to persist data in a specific way.
*/
public void onFieldChanged(String column, String value);
+
+ /**
+ * Performs the delete operation for this {@link Editor}.
+ */
+ public void deleteEditor();
+
+ /**
+ * Clears all fields in this {@link Editor}.
+ */
+ public void clearAllFields();
}
diff --git a/src/com/android/contacts/editor/EventFieldEditorView.java b/src/com/android/contacts/editor/EventFieldEditorView.java
index 41d564a..4c5affd 100644
--- a/src/com/android/contacts/editor/EventFieldEditorView.java
+++ b/src/com/android/contacts/editor/EventFieldEditorView.java
@@ -242,4 +242,14 @@
public static int getDefaultHourForBirthday() {
return DEFAULT_HOUR;
}
+
+ @Override
+ public void clearAllFields() {
+ // Update UI
+ mDateView.setText("");
+
+ // Update state
+ final String column = getKind().fieldList.get(0).column;
+ onFieldChanged(column, "");
+ }
}
diff --git a/src/com/android/contacts/editor/KindSectionView.java b/src/com/android/contacts/editor/KindSectionView.java
index c4da9fa..3b46307 100644
--- a/src/com/android/contacts/editor/KindSectionView.java
+++ b/src/com/android/contacts/editor/KindSectionView.java
@@ -106,14 +106,19 @@
});
}
- /** {@inheritDoc} */
@Override
- public void onDeleted(Editor editor) {
+ public void onDeleteRequested(Editor editor) {
+ // If there is only 1 editor in the section, then don't allow the user to delete it.
+ // Just clear the fields in the editor.
+ if (getEditorCount() == 1) {
+ editor.clearAllFields();
+ } else {
+ // Otherwise it's okay to delete this {@link Editor}
+ editor.deleteEditor();
+ }
updateAddFooterVisible();
- updateSectionVisible();
}
- /** {@inheritDoc} */
@Override
public void onRequest(int request) {
// If a field has become empty or non-empty, then check if another row
diff --git a/src/com/android/contacts/editor/LabeledEditorView.java b/src/com/android/contacts/editor/LabeledEditorView.java
index 91819a2..5bba2c4 100644
--- a/src/com/android/contacts/editor/LabeledEditorView.java
+++ b/src/com/android/contacts/editor/LabeledEditorView.java
@@ -75,6 +75,7 @@
private boolean mReadOnly;
private boolean mWasEmpty = true;
private boolean mIsDeletable = true;
+ private boolean mIsAttachedToWindow;
private EditType mType;
@@ -137,14 +138,17 @@
new Handler().post(new Runnable() {
@Override
public void run() {
- // Keep around in model, but mark as deleted
- mEntry.markDeleted();
-
- ((ViewGroup) getParent()).removeView(LabeledEditorView.this);
-
+ // Don't do anything if the view is no longer attached to the window
+ // (This check is needed because when this {@link Runnable} is executed,
+ // we can't guarantee the view is still valid.
+ if (!mIsAttachedToWindow) {
+ return;
+ }
+ // Send the delete request to the listener (which will in turn call
+ // deleteEditor() on this view if the deletion is valid - i.e. this is not
+ // the last {@link Editor} in the section).
if (mListener != null) {
- // Notify listener when present
- mListener.onDeleted(LabeledEditorView.this);
+ mListener.onDeleteRequested(LabeledEditorView.this);
}
}
});
@@ -152,6 +156,29 @@
});
}
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ // Keep track of when the view is attached or detached from the window, so we know it's
+ // safe to remove views (in case the user requests to delete this editor).
+ mIsAttachedToWindow = true;
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ mIsAttachedToWindow = false;
+ }
+
+ @Override
+ public void deleteEditor() {
+ // Keep around in model, but mark as deleted
+ mEntry.markDeleted();
+
+ // Remove the view
+ ((ViewGroup) getParent()).removeView(LabeledEditorView.this);
+ }
+
public boolean isReadOnly() {
return mReadOnly;
}
diff --git a/src/com/android/contacts/editor/PhotoActionPopup.java b/src/com/android/contacts/editor/PhotoActionPopup.java
index bc50da9..ac2d64f 100644
--- a/src/com/android/contacts/editor/PhotoActionPopup.java
+++ b/src/com/android/contacts/editor/PhotoActionPopup.java
@@ -83,7 +83,7 @@
listener.onUseAsPrimaryChosen();
break;
case ChoiceListItem.ID_REMOVE:
- listener.onRemovePictureChose();
+ listener.onRemovePictureChosen();
break;
case ChoiceListItem.ID_TAKE_PHOTO:
listener.onTakePhotoChosen();
@@ -131,7 +131,7 @@
public interface Listener {
void onUseAsPrimaryChosen();
- void onRemovePictureChose();
+ void onRemovePictureChosen();
void onTakePhotoChosen();
void onPickFromGalleryChosen();
}
diff --git a/src/com/android/contacts/editor/PhotoEditorView.java b/src/com/android/contacts/editor/PhotoEditorView.java
index 7b86291..b9b8c2c 100644
--- a/src/com/android/contacts/editor/PhotoEditorView.java
+++ b/src/com/android/contacts/editor/PhotoEditorView.java
@@ -183,4 +183,14 @@
public boolean isEmpty() {
return !mHasSetPhoto;
}
+
+ @Override
+ public void deleteEditor() {
+ // Photo is not deletable
+ }
+
+ @Override
+ public void clearAllFields() {
+ resetDefault();
+ }
}
diff --git a/src/com/android/contacts/editor/TextFieldsEditorView.java b/src/com/android/contacts/editor/TextFieldsEditorView.java
index ad1c7b6..0d8aba6 100644
--- a/src/com/android/contacts/editor/TextFieldsEditorView.java
+++ b/src/com/android/contacts/editor/TextFieldsEditorView.java
@@ -405,4 +405,14 @@
}
}
}
+
+ @Override
+ public void clearAllFields() {
+ if (mFieldEditTexts != null) {
+ for (EditText fieldEditText : mFieldEditTexts) {
+ // Update UI (which will trigger a state change through the {@link TextWatcher})
+ fieldEditText.setText("");
+ }
+ }
+ }
}
diff --git a/src/com/android/contacts/group/GroupBrowseListAdapter.java b/src/com/android/contacts/group/GroupBrowseListAdapter.java
index cc15213..2dd194d 100644
--- a/src/com/android/contacts/group/GroupBrowseListAdapter.java
+++ b/src/com/android/contacts/group/GroupBrowseListAdapter.java
@@ -234,7 +234,6 @@
public static class GroupListItem extends LinearLayout {
private TextView mLabel;
- private TextView mAccount;
private Uri mUri;
public GroupListItem(Context context, AttributeSet attrs, int defStyle) {
@@ -253,12 +252,10 @@
protected void onFinishInflate() {
super.onFinishInflate();
mLabel = (TextView) findViewById(R.id.label);
- mAccount = (TextView) findViewById(R.id.account);
}
public void loadFromGroup(GroupMetaData group) {
mLabel.setText(group.getTitle());
- mAccount.setText(group.getAccountName());
mUri = getGroupUriFromId(group.getGroupId());
}
diff --git a/src/com/android/contacts/list/ContactTileAdapter.java b/src/com/android/contacts/list/ContactTileAdapter.java
index 9674960..48a9938 100644
--- a/src/com/android/contacts/list/ContactTileAdapter.java
+++ b/src/com/android/contacts/list/ContactTileAdapter.java
@@ -59,6 +59,8 @@
private int mPhotoUriIndex;
private int mNameIndex;
private int mStarredIndex;
+ private int mPresenceIndex;
+ private int mStatusIndex;
private boolean mIsQuickContactEnabled = false;
@@ -139,12 +141,16 @@
mPhotoUriIndex = GroupMemberLoader.CONTACT_PHOTO_URI_COLUMN_INDEX;
mNameIndex = GroupMemberLoader.CONTACT_DISPLAY_NAME_PRIMARY_COLUMN_INDEX;
mStarredIndex = GroupMemberLoader.CONTACT_STARRED_COLUMN_INDEX;
+ mPresenceIndex = GroupMemberLoader.CONTACT_PRESENCE_STATUS_COLUMN_INDEX;
+ mStatusIndex = GroupMemberLoader.CONTACT_STATUS_COLUMN_INDEX;
} else {
mIdIndex = ContactTileLoaderFactory.CONTACT_ID;
mLookupIndex = ContactTileLoaderFactory.LOOKUP_KEY;
mPhotoUriIndex = ContactTileLoaderFactory.PHOTO_URI;
mNameIndex = ContactTileLoaderFactory.DISPLAY_NAME;
mStarredIndex = ContactTileLoaderFactory.STARRED;
+ mPresenceIndex = ContactTileLoaderFactory.CONTACT_PRESENCE;
+ mStatusIndex = ContactTileLoaderFactory.CONTACT_STATUS;
}
}
@@ -192,9 +198,11 @@
ContactEntry contact = new ContactEntry();
contact.name = cursor.getString(mNameIndex);
+ contact.status = cursor.getString(mStatusIndex);
contact.photoUri = (photoUri != null ? Uri.parse(photoUri) : null);
contact.lookupKey = ContentUris.withAppendedId(
Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey), id);
+ contact.presence = cursor.isNull(mPresenceIndex) ? null : cursor.getInt(mPresenceIndex);
return contact;
}
@@ -455,9 +463,11 @@
* Class to hold contact information
*/
public static class ContactEntry {
- public Uri photoUri;
public String name;
+ public String status;
+ public Uri photoUri;
public Uri lookupKey;
+ public Integer presence;
}
private static class ViewTypes {
diff --git a/src/com/android/contacts/list/ContactTileView.java b/src/com/android/contacts/list/ContactTileView.java
index 7981bd1..715c331 100644
--- a/src/com/android/contacts/list/ContactTileView.java
+++ b/src/com/android/contacts/list/ContactTileView.java
@@ -20,6 +20,8 @@
import com.android.contacts.list.ContactTileAdapter.ContactEntry;
import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
@@ -29,6 +31,9 @@
import android.widget.QuickContactBadge;
import android.widget.TextView;
+import android.provider.ContactsContract.StatusUpdates;
+
+
/**
* A ContactTile displays the contact's picture overlayed with their name
*/
@@ -37,8 +42,10 @@
private Uri mLookupUri;
private ImageView mPhoto;
+ private ImageView mPresence;
private QuickContactBadge mQuickContact;
private TextView mName;
+ private TextView mStatus;
private ContactPhotoManager mPhotoManager = null;
public ContactTileView(Context context, AttributeSet attrs) {
@@ -53,6 +60,8 @@
mQuickContact = (QuickContactBadge) findViewById(R.id.contact_tile_quick);
mPhoto = (ImageView) findViewById(R.id.contact_tile_image);
+ mPresence = (ImageView) findViewById(R.id.contact_tile_presence);
+ mStatus = (TextView) findViewById(R.id.contact_tile_status);
}
public void setPhotoManager(ContactPhotoManager photoManager) {
@@ -68,6 +77,24 @@
mName.setText(entry.name);
mLookupUri = entry.lookupKey;
+ int presenceDrawableResId = (entry.presence == null ? 0 :
+ StatusUpdates.getPresenceIconResourceId(entry.presence));
+
+ if (mPresence != null) {
+ mPresence.setBackgroundResource(presenceDrawableResId);
+ }
+
+ if (mStatus != null) {
+ String statusText;
+ if (entry.presence == null) {
+ statusText = null;
+ } else {
+ statusText =
+ (entry.status == null ? getStatusString(entry.presence) : entry.status);
+ }
+ mStatus.setText(statusText);
+ }
+
if (mQuickContact != null) {
mQuickContact.assignContactUri(mLookupUri);
mQuickContact.setImageBitmap(null);
@@ -92,6 +119,23 @@
}
}
+ private String getStatusString(int presence) {
+ Resources resources = getResources();
+ switch (presence) {
+ case StatusUpdates.AVAILABLE:
+ return resources.getString(R.string.status_available);
+ case StatusUpdates.IDLE:
+ case StatusUpdates.AWAY:
+ return resources.getString(R.string.status_away);
+ case StatusUpdates.DO_NOT_DISTURB:
+ return resources.getString(R.string.status_busy);
+ case StatusUpdates.OFFLINE:
+ case StatusUpdates.INVISIBLE:
+ default:
+ return null;
+ }
+ }
+
public Uri getLookupUri() {
return mLookupUri;
}