use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.
the class ContactsListFragment method unarchiveContact.
private static void unarchiveContact(Activity activity, String address, int contactType, long providerId, long accountId) {
try {
IImConnection mConn;
ImApp app = ((ImApp) activity.getApplication());
mConn = app.getConnection(providerId, accountId);
// then delete the contact from our list
IContactListManager manager = mConn.getContactListManager();
int res = manager.archiveContact(address, contactType, false);
if (res != ImErrorInfo.NO_ERROR) {
// mHandler.showAlert(R.string.error,
// ErrorResUtils.getErrorRes(getResources(), res, address));
}
} catch (RemoteException re) {
}
}
use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.
the class ContactsListFragment method deleteContact.
private static void deleteContact(Activity activity, long itemId, String address, long providerId, long accountId) {
try {
IImConnection mConn;
ImApp app = ((ImApp) activity.getApplication());
mConn = app.getConnection(providerId, accountId);
// first leave, delete an existing chat session
IChatSessionManager sessionMgr = mConn.getChatSessionManager();
if (sessionMgr != null) {
IChatSession session = sessionMgr.getChatSession(Address.stripResource(address));
}
// then delete the contact from our list
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 re) {
}
}
use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.
the class ContactsPickerActivity method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
((ImApp) getApplication()).setAppTheme(this);
setContentView(R.layout.contacts_picker_activity);
if (getIntent().getData() != null)
mUri = getIntent().getData();
mLayoutContactSelect = findViewById(R.id.layoutContactSelect);
mLayoutGroupSelect = findViewById(R.id.layoutGroupSelect);
mSelectedContacts = (FlowLayout) findViewById(R.id.flSelectedContacts);
mSelectedContacts.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
// When the tag view grows we don't want the list to jump around, so
// compensate for this by trying to scroll the list.
final int diff = bottom - oldBottom;
ListViewCompat.scrollListBy(mListView, diff);
}
});
boolean isGroupOnlyMode = isGroupOnlyMode();
excludedContacts = getIntent().getStringArrayListExtra(EXTRA_EXCLUDED_CONTACTS);
mShowGroups = getIntent().getBooleanExtra(EXTRA_SHOW_GROUPS, false);
View btnCreateGroup = findViewById(R.id.btnCreateGroup);
btnCreateGroup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setGroupMode(true);
}
});
btnCreateGroup.setVisibility(isGroupOnlyMode ? View.GONE : View.VISIBLE);
View btnAddContact = findViewById(R.id.btnAddFriend);
btnAddContact.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(ContactsPickerActivity.this, AddContactActivity.class);
startActivityForResult(i, REQUEST_CODE_ADD_CONTACT);
}
});
btnAddContact.setVisibility(isGroupOnlyMode ? View.GONE : View.VISIBLE);
// Make sure the tag view can not be more than a third of the screen
View root = findViewById(R.id.llRoot);
if (root != null) {
root.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if ((bottom - top) != (oldBottom - oldTop)) {
ViewGroup.LayoutParams lp = mSelectedContacts.getLayoutParams();
lp.height = (bottom - top) / 3;
mSelectedContacts.setLayoutParams(lp);
}
}
});
}
mListView = (ListView) findViewById(R.id.contactsList);
setGroupMode(isGroupOnlyMode);
mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
multiStart(i);
return true;
}
});
// Uncomment this to set as list view header instead.
// ((ViewGroup)mSelectedContacts.getParent()).removeView(mSelectedContacts);
// mSelectedContacts.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
// mListView.addHeaderView(mSelectedContacts);
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {
if (mListView.getChoiceMode() == ListView.CHOICE_MODE_MULTIPLE) {
if (isSelected(id)) {
unselect(id);
} else {
select(position);
}
} else {
Cursor cursor = (Cursor) mAdapter.getItem(position);
Intent data = new Intent();
data.putExtra(EXTRA_RESULT_USERNAME, cursor.getString(ContactListItem.COLUMN_CONTACT_USERNAME));
data.putExtra(EXTRA_RESULT_PROVIDER, cursor.getLong(ContactListItem.COLUMN_CONTACT_PROVIDER));
data.putExtra(EXTRA_RESULT_ACCOUNT, cursor.getLong(ContactListItem.COLUMN_CONTACT_ACCOUNT));
setResult(RESULT_OK, data);
finish();
}
}
});
doFilterAsync("");
}
use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.
the class ConversationListItem method getEncryptionState.
private void getEncryptionState(long providerId, long accountId, String address, ConversationViewHolder holder) {
try {
ImApp app = ((ImApp) ((Activity) getContext()).getApplication());
IImConnection conn = app.getConnection(providerId, accountId);
if (conn == null || conn.getChatSessionManager() == null)
return;
IChatSession chatSession = conn.getChatSessionManager().getChatSession(address);
if (chatSession != null) {
if (chatSession.isEncrypted()) {
holder.mStatusIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_encrypted_grey));
holder.mStatusIcon.setVisibility(View.VISIBLE);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// mCurrentChatSession.getOtrChatSession();
}
use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.
the class SimpleAlertHandler method unregisterForBroadcastEvents.
public void unregisterForBroadcastEvents() {
ImApp app = (ImApp) mActivity.getApplication();
app.unregisterForBroadcastEvent(ImApp.EVENT_CONNECTION_DISCONNECTED, this);
}
Aggregations