Fields Summary |
---|
private static final String | TAG |
private static final boolean | LOCAL_DEBUG |
private LandingPage | mActivity |
private android.widget.ImageView | mProviderIcon |
private android.widget.ImageView | mStatusIcon |
private android.widget.TextView | mProviderName |
private android.widget.TextView | mLoginName |
private android.widget.TextView | mChatView |
private android.view.View | mUnderBubble |
private android.graphics.drawable.Drawable | mBubbleDrawable |
private android.graphics.drawable.Drawable | mDefaultBackground |
private int | mProviderIdColumn |
private int | mProviderFullnameColumn |
private int | mActiveAccountIdColumn |
private int | mActiveAccountUserNameColumn |
private int | mAccountPresenceStatusColumn |
private int | mAccountConnectionStatusColumn |
private android.content.res.ColorStateList | mProviderNameColors |
private android.content.res.ColorStateList | mLoginNameColors |
private android.content.res.ColorStateList | mChatViewColors |
Methods Summary |
---|
public void | bindView(android.database.Cursor cursor)
Resources r = getResources();
ImageView providerIcon = mProviderIcon;
ImageView statusIcon = mStatusIcon;
TextView providerName = mProviderName;
TextView loginName = mLoginName;
TextView chatView = mChatView;
int providerId = cursor.getInt(mProviderIdColumn);
String providerDisplayName = cursor.getString(mProviderFullnameColumn);
BrandingResources brandingRes = mActivity.getBrandingResource(providerId);
providerIcon.setImageDrawable(
brandingRes.getDrawable(BrandingResourceIDs.DRAWABLE_LOGO));
mUnderBubble.setBackgroundDrawable(mDefaultBackground);
statusIcon.setVisibility(View.GONE);
providerName.setTextColor(mProviderNameColors);
loginName.setTextColor(mLoginNameColors);
chatView.setTextColor(mChatViewColors);
if (!cursor.isNull(mActiveAccountIdColumn)) {
mLoginName.setVisibility(View.VISIBLE);
providerName.setVisibility(View.VISIBLE);
providerName.setText(providerDisplayName);
long accountId = cursor.getLong(mActiveAccountIdColumn);
int connectionStatus = cursor.getInt(mAccountConnectionStatusColumn);
String secondRowText;
chatView.setVisibility(View.GONE);
switch (connectionStatus) {
case Im.ConnectionStatus.CONNECTING:
secondRowText = r.getString(R.string.signing_in_wait);
break;
case Im.ConnectionStatus.ONLINE:
int presenceIconId = getPresenceIconId(cursor);
statusIcon.setImageDrawable(
brandingRes.getDrawable(presenceIconId));
statusIcon.setVisibility(View.VISIBLE);
ContentResolver cr = mActivity.getContentResolver();
int count = getConversationCount(cr, accountId);
if (count > 0) {
mUnderBubble.setBackgroundDrawable(mBubbleDrawable);
chatView.setVisibility(View.VISIBLE);
chatView.setText(r.getString(R.string.conversations, count));
providerName.setTextColor(0xff000000);
loginName.setTextColor(0xff000000);
chatView.setTextColor(0xff000000);
} else {
chatView.setVisibility(View.GONE);
}
secondRowText = cursor.getString(mActiveAccountUserNameColumn);
break;
default:
secondRowText = cursor.getString(mActiveAccountUserNameColumn);
break;
}
loginName.setText(secondRowText);
} else {
// No active account, show add account
mLoginName.setVisibility(View.GONE);
mProviderName.setText(providerDisplayName);
}
|
private int | getConversationCount(android.content.ContentResolver cr, long accountId)
// TODO: this is code used to get Google Talk's chat count. Not sure if this will work
// for IMPS chat count.
StringBuilder where = new StringBuilder();
where.append(Im.Chats.CONTACT_ID);
where.append(" in (select _id from contacts where ");
where.append(Im.Contacts.ACCOUNT);
where.append("=");
where.append(accountId);
where.append(")");
Cursor cursor = cr.query(Im.Chats.CONTENT_URI, null, where.toString(), null, null);
try {
return cursor.getCount();
} finally {
cursor.close();
}
|
private int | getPresenceIconId(android.database.Cursor cursor)
int presenceStatus = cursor.getInt(mAccountPresenceStatusColumn);
if (LOCAL_DEBUG) log("getPresenceIconId: presenceStatus=" + presenceStatus);
switch (presenceStatus) {
case Im.Presence.AVAILABLE:
return BrandingResourceIDs.DRAWABLE_PRESENCE_ONLINE;
case Im.Presence.IDLE:
case Im.Presence.AWAY:
return BrandingResourceIDs.DRAWABLE_PRESENCE_AWAY;
case Im.Presence.DO_NOT_DISTURB:
return BrandingResourceIDs.DRAWABLE_PRESENCE_BUSY;
case Im.Presence.INVISIBLE:
return BrandingResourceIDs.DRAWABLE_PRESENCE_INVISIBLE;
default:
return BrandingResourceIDs.DRAWABLE_PRESENCE_OFFLINE;
}
|
public void | init(android.database.Cursor c)
mProviderIcon = (ImageView) findViewById(R.id.providerIcon);
mStatusIcon = (ImageView) findViewById(R.id.statusIcon);
mProviderName = (TextView) findViewById(R.id.providerName);
mLoginName = (TextView) findViewById(R.id.loginName);
mChatView = (TextView) findViewById(R.id.conversations);
mUnderBubble = (View) findViewById(R.id.underBubble);
mBubbleDrawable = getResources().getDrawable(R.drawable.bubble);
mDefaultBackground = getResources().getDrawable(R.drawable.default_background);
mProviderIdColumn = c.getColumnIndexOrThrow(Im.Provider._ID);
mProviderFullnameColumn = c.getColumnIndexOrThrow(Im.Provider.FULLNAME);
mActiveAccountIdColumn = c.getColumnIndexOrThrow(
Im.Provider.ACTIVE_ACCOUNT_ID);
mActiveAccountUserNameColumn = c.getColumnIndexOrThrow(
Im.Provider.ACTIVE_ACCOUNT_USERNAME);
mAccountPresenceStatusColumn = c.getColumnIndexOrThrow(
Im.Provider.ACCOUNT_PRESENCE_STATUS);
mAccountConnectionStatusColumn = c.getColumnIndexOrThrow(
Im.Provider.ACCOUNT_CONNECTION_STATUS);
mProviderNameColors = mProviderName.getTextColors();
mLoginNameColors = mLoginName.getTextColors();
mChatViewColors = mChatView.getTextColors();
|
private void | log(java.lang.String msg)
Log.d(TAG, msg);
|