Methods Summary |
---|
public void | blockContact()
blockContact(getSelectedContact());
|
void | blockContact(android.database.Cursor c)
if (c == null) {
mHandler.showAlert(R.string.error, R.string.select_contact);
} else {
String nickname = c.getString(c.getColumnIndexOrThrow(Im.Contacts.NICKNAME));
final String address = c.getString(c.getColumnIndexOrThrow(Im.Contacts.USERNAME));
DialogInterface.OnClickListener confirmListener = new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int whichButton) {
try {
IContactListManager manager = mConn.getContactListManager();
int res = manager.blockContact(address);
if (res != ImErrorInfo.NO_ERROR) {
mHandler.showAlert(R.string.error,
ErrorResUtils.getErrorRes(getResources(), res, address));
}
} catch (RemoteException e) {
mHandler.showServiceErrorAlert();
}
}
};
Resources r = getResources();
new AlertDialog.Builder(mContext)
.setTitle(R.string.confirm)
.setMessage(r.getString(R.string.confirm_block_contact, nickname))
.setPositiveButton(R.string.yes, confirmListener) // default button
.setNegativeButton(R.string.no, null)
.setCancelable(false)
.show();
clearFocusIfEmpty(c);
}
|
public void | blockContactAtPosition(long packedPosition)
blockContact(getContactAtPosition(packedPosition));
|
private void | clearFocusIfEmpty(android.database.Cursor c)
// clear focus if there's only one item so that it would focus on the
// "empty" item after the contact removed.
if (c.getCount() == 1) {
clearFocus();
}
|
public void | endChat()
endChat(getSelectedContact());
|
void | endChat(android.database.Cursor c)
if(c != null) {
String username = c.getString(c.getColumnIndexOrThrow(Im.Contacts.USERNAME));
try {
IChatSessionManager manager = mConn.getChatSessionManager();
IChatSession session = manager.getChatSession(username);
if(session != null) {
session.leave();
}
} catch (RemoteException e) {
mHandler.showServiceErrorAlert();
}
clearFocusIfEmpty(c);
}
|
public void | endChatAtPosition(long packedPosition)
endChat(getContactAtPosition(packedPosition));
|
public android.database.Cursor | getContactAtPosition(long packedPosition)
int type = ExpandableListView.getPackedPositionType(packedPosition);
if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);
int childPosition = ExpandableListView.getPackedPositionChild(packedPosition);
return (Cursor) mAdapter.getChild(groupPosition, childPosition);
}
return null;
|
public android.widget.ExpandableListView | getListView()
return mContactsList;
|
public android.database.Cursor | getSelectedContact()
long pos = mContactsList.getSelectedPosition();
if (ExpandableListView.getPackedPositionType(pos)
== ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
return (Cursor)mContactsList.getSelectedItem();
}
return null;
|
public java.lang.String | getSelectedContactList()
long pos = mContactsList.getSelectedPosition();
int groupPos = ExpandableListView.getPackedPositionGroup(pos);
if (groupPos == -1) {
return null;
}
Cursor cursor = (Cursor)mAdapter.getGroup(groupPos);
if (cursor == null) {
return null;
}
return cursor.getString(cursor.getColumnIndexOrThrow(Im.ContactList.NAME));
|
public boolean | isContactAtPosition(long packedPosition)
int type = ExpandableListView.getPackedPositionType(packedPosition);
int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);
return (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD)
&& !mAdapter.isPosForSubscription(groupPosition);
|
public boolean | isContactSelected()
long pos = mContactsList.getSelectedPosition();
return isContactAtPosition(pos);
|
public boolean | isContactsLoaded()
try {
IContactListManager manager = mConn.getContactListManager();
return (manager.getState() == ContactListManager.LISTS_LOADED);
} catch (RemoteException e) {
mHandler.showServiceErrorAlert();
return false;
}
|
public boolean | isConversationAtPosition(long packedPosition)
int type = ExpandableListView.getPackedPositionType(packedPosition);
int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);
return (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD)
&& mAdapter.isPosForOngoingConversation(groupPosition);
|
public boolean | isConversationSelected()
long pos = mContactsList.getSelectedPosition();
return isConversationAtPosition(pos);
|
protected void | onFinishInflate()
super.onFinishInflate();
mPresenceView = (UserPresenceView)findViewById(R.id.userPresence);
mContactsList = (ExpandableListView) findViewById(R.id.contactsList);
mContactsList.setOnChildClickListener(mOnChildClickListener);
|
protected void | onLayout(boolean changed, int l, int t, int r, int b)
if (mAutoRefresh) {
super.onLayout(changed, l, t, r, b);
}
|
public void | onRestoreInstanceState(android.os.Parcelable state)
SavedState ss = (SavedState) state;
super.onRestoreInstanceState(ss.getSuperState());
mSavedState = ss;
|
public android.os.Parcelable | onSaveInstanceState()
Parcelable superState = super.onSaveInstanceState();
int[] expandedGroups = mAdapter == null ? null
: mAdapter.getExpandedGroups();
return new SavedState(superState, expandedGroups);
|
private void | registerListeners()
try{
IContactListManager listManager = mConn.getContactListManager();
listManager.registerContactListListener(mContactListListener);
listManager.registerSubscriptionListener(mSubscriptionListener);
}catch(RemoteException e) {
mHandler.showServiceErrorAlert();
}
|
public void | removeContact()
removeContact(getSelectedContact());
|
void | removeContact(android.database.Cursor c)
if (c == null) {
mHandler.showAlert(R.string.error, R.string.select_contact);
} else {
String nickname = c.getString(c.getColumnIndexOrThrow(Im.Contacts.NICKNAME));
final String address = c.getString(c.getColumnIndexOrThrow(Im.Contacts.USERNAME));
DialogInterface.OnClickListener confirmListener = new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int whichButton) {
try {
IContactListManager manager = mConn.getContactListManager();
int res = manager.removeContact(address);
if (res != ImErrorInfo.NO_ERROR) {
mHandler.showAlert(R.string.error,
ErrorResUtils.getErrorRes(getResources(), res, address));
}
} catch (RemoteException e) {
mHandler.showServiceErrorAlert();
}
}
};
Resources r = getResources();
new AlertDialog.Builder(mContext)
.setTitle(R.string.confirm)
.setMessage(r.getString(R.string.confirm_delete_contact, nickname))
.setPositiveButton(R.string.yes, confirmListener) // default button
.setNegativeButton(R.string.no, null)
.setCancelable(false)
.show();
clearFocusIfEmpty(c);
}
|
public void | removeContactAtPosition(long packedPosition)
removeContact(getContactAtPosition(packedPosition));
|
protected void | setAutoRefreshContacts(boolean isRefresh)
mAutoRefresh = isRefresh;
|
public void | setConnection(com.android.im.IImConnection conn)
if (mConn != conn) {
if (mConn != null) {
unregisterListeners();
}
mConn = conn;
if (conn != null) {
registerListeners();
mPresenceView.setConnection(conn);
if (mAdapter == null) {
mAdapter = new ContactListTreeAdapter(conn, mScreen);
mAdapter.setHideOfflineContacts(mHideOfflineContacts);
mContactsList.setAdapter(mAdapter);
mContactsList.setOnScrollListener(mAdapter);
if (mSavedState != null) {
int[] expandedGroups = mSavedState.mExpandedGroups;
if(expandedGroups != null) {
for (int group : expandedGroups) {
mContactsList.expandGroup(group);
}
}
}
} else {
mAdapter.changeConnection(conn);
}
try {
IContactListManager listMgr = conn.getContactListManager();
if (listMgr.getState() == ContactListManager.LISTS_LOADED) {
mAdapter.startAutoRequery();
}
} catch (RemoteException e) {
Log.e(ImApp.LOG_TAG, "Service died!");
}
}
} else {
mContactsList.invalidateViews();
}
|
public void | setHideOfflineContacts(boolean hide)
if (mAdapter != null) {
mAdapter.setHideOfflineContacts(hide);
} else {
mHideOfflineContacts = hide;
}
|
public void | startChat()
startChat(getSelectedContact());
|
void | startChat(android.database.Cursor c)
if (c != null) {
long id = c.getLong(c.getColumnIndexOrThrow(Im.Contacts._ID));
String username = c.getString(c.getColumnIndexOrThrow(Im.Contacts.USERNAME));
try {
IChatSessionManager manager = mConn.getChatSessionManager();
IChatSession session = manager.getChatSession(username);
if(session == null) {
manager.createChatSession(username);
}
Uri data = ContentUris.withAppendedId(Im.Chats.CONTENT_URI, id);
Intent i = new Intent(Intent.ACTION_VIEW, data);
i.addCategory(ImApp.IMPS_CATEGORY);
mScreen.startActivity(i);
setAutoRefreshContacts(false);
} catch (RemoteException e) {
mHandler.showServiceErrorAlert();
}
clearFocusIfEmpty(c);
}
|
public void | startChatAtPosition(long packedPosition)
startChat(getContactAtPosition(packedPosition));
|
private void | unregisterListeners()
try{
IContactListManager listManager = mConn.getContactListManager();
listManager.unregisterContactListListener(mContactListListener);
listManager.unregisterSubscriptionListener(mSubscriptionListener);
}catch(RemoteException e) {
mHandler.showServiceErrorAlert();
}
|
public void | viewContactPresence()
viewContactPresence(getSelectedContact());
|
public void | viewContactPresence(android.database.Cursor c)
if (c != null) {
long id = c.getLong(c.getColumnIndexOrThrow(Im.Contacts._ID));
Uri data = ContentUris.withAppendedId(Im.Contacts.CONTENT_URI, id);
Intent i = new Intent(Intent.ACTION_VIEW, data);
mScreen.startActivity(i);
}
|
public void | viewContactPresenceAtPostion(long packedPosition)
viewContactPresence(getContactAtPosition(packedPosition));
|