2014-07-16 22:03:37 +00:00
|
|
|
package eu.siacs.conversations.ui;
|
|
|
|
|
2018-02-27 17:08:09 +00:00
|
|
|
import android.app.Activity;
|
2014-07-16 22:03:37 +00:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2018-12-01 12:27:00 +00:00
|
|
|
import android.content.SharedPreferences;
|
2014-07-16 22:03:37 +00:00
|
|
|
import android.os.Bundle;
|
2018-03-07 11:56:35 +00:00
|
|
|
import android.support.annotation.NonNull;
|
2016-05-27 17:17:57 +00:00
|
|
|
import android.support.annotation.StringRes;
|
2018-03-14 06:20:44 +00:00
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
import android.support.v4.app.FragmentTransaction;
|
2018-02-16 11:30:46 +00:00
|
|
|
import android.support.v7.app.ActionBar;
|
2015-03-17 14:00:50 +00:00
|
|
|
import android.view.ActionMode;
|
2018-12-01 12:27:00 +00:00
|
|
|
import android.view.KeyEvent;
|
2015-03-17 14:00:50 +00:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
2014-07-16 22:03:37 +00:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.inputmethod.InputMethodManager;
|
2015-03-17 14:00:50 +00:00
|
|
|
import android.widget.AbsListView.MultiChoiceModeListener;
|
2018-12-01 12:27:00 +00:00
|
|
|
import android.widget.AdapterView;
|
2015-03-17 14:00:50 +00:00
|
|
|
import android.widget.ListView;
|
2018-12-01 12:27:00 +00:00
|
|
|
import android.widget.TextView;
|
2014-12-21 20:43:58 +00:00
|
|
|
|
2015-07-20 12:26:29 +00:00
|
|
|
import java.util.ArrayList;
|
2018-03-14 10:03:08 +00:00
|
|
|
import java.util.Arrays;
|
2014-12-21 20:43:58 +00:00
|
|
|
import java.util.Collections;
|
2015-07-20 12:26:29 +00:00
|
|
|
import java.util.HashSet;
|
2015-03-17 14:00:50 +00:00
|
|
|
import java.util.List;
|
2015-07-20 12:26:29 +00:00
|
|
|
import java.util.Set;
|
2014-12-21 20:43:58 +00:00
|
|
|
|
2016-01-04 16:27:51 +00:00
|
|
|
import eu.siacs.conversations.Config;
|
2015-03-17 14:00:50 +00:00
|
|
|
import eu.siacs.conversations.R;
|
2014-07-16 22:03:37 +00:00
|
|
|
import eu.siacs.conversations.entities.Account;
|
|
|
|
import eu.siacs.conversations.entities.Contact;
|
2018-02-27 17:08:09 +00:00
|
|
|
import eu.siacs.conversations.entities.Conversation;
|
2014-07-16 22:03:37 +00:00
|
|
|
import eu.siacs.conversations.entities.ListItem;
|
2018-02-27 17:08:09 +00:00
|
|
|
import eu.siacs.conversations.entities.MucOptions;
|
2018-03-14 09:07:52 +00:00
|
|
|
import eu.siacs.conversations.ui.interfaces.OnBackendConnected;
|
2018-03-07 11:56:35 +00:00
|
|
|
import eu.siacs.conversations.ui.util.ActivityResult;
|
|
|
|
import eu.siacs.conversations.ui.util.PendingItem;
|
|
|
|
import eu.siacs.conversations.utils.XmppUri;
|
2018-03-05 17:30:40 +00:00
|
|
|
import rocks.xmpp.addr.Jid;
|
2014-08-31 14:28:21 +00:00
|
|
|
|
2018-12-01 12:27:00 +00:00
|
|
|
public class ChooseContactActivity extends AbstractSearchableListItemActivity implements MultiChoiceModeListener, AdapterView.OnItemClickListener {
|
2018-06-23 19:35:37 +00:00
|
|
|
public static final String EXTRA_TITLE_RES_ID = "extra_title_res_id";
|
2018-06-24 09:23:10 +00:00
|
|
|
public static final String EXTRA_GROUP_CHAT_NAME = "extra_group_chat_name";
|
|
|
|
public static final String EXTRA_SELECT_MULTIPLE = "extra_select_multiple";
|
|
|
|
public static final String EXTRA_SHOW_ENTER_JID = "extra_show_enter_jid";
|
|
|
|
public static final String EXTRA_CONVERSATION = "extra_conversation";
|
|
|
|
private static final String EXTRA_FILTERED_CONTACTS = "extra_filtered_contacts";
|
2018-06-23 19:35:37 +00:00
|
|
|
private List<String> mActivatedAccounts = new ArrayList<>();
|
|
|
|
private Set<String> selected = new HashSet<>();
|
|
|
|
private Set<String> filterContacts;
|
|
|
|
|
|
|
|
private boolean showEnterJid = false;
|
2018-12-01 12:27:00 +00:00
|
|
|
private boolean startSearching = false;
|
|
|
|
private boolean multiple = false;
|
2018-06-23 19:35:37 +00:00
|
|
|
|
|
|
|
private PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
|
|
|
|
|
|
|
|
public static Intent create(Activity activity, Conversation conversation) {
|
|
|
|
final Intent intent = new Intent(activity, ChooseContactActivity.class);
|
|
|
|
List<String> contacts = new ArrayList<>();
|
|
|
|
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
|
|
|
for (MucOptions.User user : conversation.getMucOptions().getUsers(false)) {
|
|
|
|
Jid jid = user.getRealJid();
|
|
|
|
if (jid != null) {
|
|
|
|
contacts.add(jid.asBareJid().toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
contacts.add(conversation.getJid().asBareJid().toString());
|
|
|
|
}
|
2018-06-24 09:23:10 +00:00
|
|
|
intent.putExtra(EXTRA_FILTERED_CONTACTS, contacts.toArray(new String[contacts.size()]));
|
|
|
|
intent.putExtra(EXTRA_CONVERSATION, conversation.getUuid());
|
|
|
|
intent.putExtra(EXTRA_SELECT_MULTIPLE, true);
|
|
|
|
intent.putExtra(EXTRA_SHOW_ENTER_JID, true);
|
2018-06-23 19:35:37 +00:00
|
|
|
intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toString());
|
|
|
|
return intent;
|
|
|
|
}
|
|
|
|
|
2018-06-24 09:23:10 +00:00
|
|
|
public static List<Jid> extractJabberIds(Intent result) {
|
|
|
|
List<Jid> jabberIds = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
if (result.getBooleanExtra(EXTRA_SELECT_MULTIPLE, false)) {
|
|
|
|
String[] toAdd = result.getStringArrayExtra("contacts");
|
|
|
|
for (String item : toAdd) {
|
|
|
|
jabberIds.add(Jid.of(item));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
jabberIds.add(Jid.of(result.getStringExtra("contact")));
|
|
|
|
}
|
|
|
|
return jabberIds;
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
|
return jabberIds;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-23 19:35:37 +00:00
|
|
|
@Override
|
|
|
|
public void onCreate(final Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
filterContacts = new HashSet<>();
|
|
|
|
if (savedInstanceState != null) {
|
|
|
|
String[] selectedContacts = savedInstanceState.getStringArray("selected_contacts");
|
|
|
|
if (selectedContacts != null) {
|
|
|
|
selected.clear();
|
|
|
|
selected.addAll(Arrays.asList(selectedContacts));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-24 09:23:10 +00:00
|
|
|
String[] contacts = getIntent().getStringArrayExtra(EXTRA_FILTERED_CONTACTS);
|
2018-06-23 19:35:37 +00:00
|
|
|
if (contacts != null) {
|
|
|
|
Collections.addAll(filterContacts, contacts);
|
|
|
|
}
|
|
|
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
2018-12-01 12:27:00 +00:00
|
|
|
multiple = intent.getBooleanExtra(EXTRA_SELECT_MULTIPLE, false);
|
2018-06-23 19:35:37 +00:00
|
|
|
if (multiple) {
|
|
|
|
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
|
|
|
|
getListView().setMultiChoiceModeListener(this);
|
|
|
|
}
|
|
|
|
|
2018-12-01 12:27:00 +00:00
|
|
|
getListView().setOnItemClickListener(this);
|
|
|
|
this.showEnterJid = intent.getBooleanExtra(EXTRA_SHOW_ENTER_JID, false);
|
2018-06-23 19:35:37 +00:00
|
|
|
this.binding.fab.setOnClickListener(this::onFabClicked);
|
|
|
|
if (this.showEnterJid) {
|
2018-12-01 12:27:00 +00:00
|
|
|
this.binding.fab.show();
|
2018-06-23 19:35:37 +00:00
|
|
|
} else {
|
2018-12-01 12:27:00 +00:00
|
|
|
binding.fab.setImageResource(R.drawable.ic_forward_white_24dp);
|
2018-06-23 19:35:37 +00:00
|
|
|
}
|
2018-12-01 12:27:00 +00:00
|
|
|
|
|
|
|
final SharedPreferences preferences = getPreferences();
|
|
|
|
this.startSearching = intent.getBooleanExtra("direct_search", false) && preferences.getBoolean("start_searching", getResources().getBoolean(R.bool.start_searching));
|
|
|
|
|
2018-06-23 19:35:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onFabClicked(View v) {
|
|
|
|
if (selected.size() == 0) {
|
|
|
|
showEnterJidDialog(null);
|
|
|
|
} else {
|
|
|
|
submitSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
|
|
|
mode.setTitle(getTitleFromIntent());
|
|
|
|
binding.fab.setImageResource(R.drawable.ic_forward_white_24dp);
|
2018-12-01 12:27:00 +00:00
|
|
|
binding.fab.show();
|
2018-06-23 19:35:37 +00:00
|
|
|
final View view = getSearchEditText();
|
|
|
|
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
if (view != null && imm != null) {
|
|
|
|
imm.hideSoftInputFromWindow(getSearchEditText().getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDestroyActionMode(ActionMode mode) {
|
|
|
|
this.binding.fab.setImageResource(R.drawable.ic_person_add_white_24dp);
|
|
|
|
if (this.showEnterJid) {
|
2018-12-01 12:27:00 +00:00
|
|
|
this.binding.fab.show();
|
2018-06-23 19:35:37 +00:00
|
|
|
} else {
|
2018-12-01 12:27:00 +00:00
|
|
|
this.binding.fab.hide();
|
2018-06-23 19:35:37 +00:00
|
|
|
}
|
|
|
|
selected.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void submitSelection() {
|
|
|
|
final Intent request = getIntent();
|
|
|
|
final Intent data = new Intent();
|
2018-06-24 09:23:10 +00:00
|
|
|
data.putExtra("contacts", getSelectedContactJids());
|
|
|
|
data.putExtra(EXTRA_SELECT_MULTIPLE, true);
|
2018-06-23 19:35:37 +00:00
|
|
|
data.putExtra(EXTRA_ACCOUNT, request.getStringExtra(EXTRA_ACCOUNT));
|
2018-06-24 09:23:10 +00:00
|
|
|
copy(request, data);
|
2018-06-23 19:35:37 +00:00
|
|
|
setResult(RESULT_OK, data);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
2018-06-24 09:23:10 +00:00
|
|
|
private static void copy(Intent from, Intent to) {
|
|
|
|
to.putExtra(EXTRA_CONVERSATION, from.getStringExtra(EXTRA_CONVERSATION));
|
|
|
|
to.putExtra(EXTRA_GROUP_CHAT_NAME, from.getStringExtra(EXTRA_GROUP_CHAT_NAME));
|
|
|
|
}
|
|
|
|
|
2018-06-23 19:35:37 +00:00
|
|
|
@Override
|
|
|
|
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
|
2018-06-27 15:17:31 +00:00
|
|
|
if (selected.size() != 0) {
|
|
|
|
getListView().playSoundEffect(0);
|
|
|
|
}
|
2018-06-23 19:35:37 +00:00
|
|
|
Contact item = (Contact) getListItems().get(position);
|
|
|
|
if (checked) {
|
|
|
|
selected.add(item.getJid().toString());
|
|
|
|
} else {
|
|
|
|
selected.remove(item.getJid().toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStart() {
|
|
|
|
super.onStart();
|
|
|
|
ActionBar bar = getSupportActionBar();
|
|
|
|
if (bar != null) {
|
|
|
|
try {
|
|
|
|
bar.setTitle(getTitleFromIntent());
|
|
|
|
} catch (Exception e) {
|
|
|
|
bar.setTitle(R.string.title_activity_choose_contact);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public @StringRes
|
|
|
|
int getTitleFromIntent() {
|
|
|
|
final Intent intent = getIntent();
|
2018-06-24 09:23:10 +00:00
|
|
|
boolean multiple = intent != null && intent.getBooleanExtra(EXTRA_SELECT_MULTIPLE, false);
|
2018-06-23 19:35:37 +00:00
|
|
|
@StringRes int fallback = multiple ? R.string.title_activity_choose_contacts : R.string.title_activity_choose_contact;
|
|
|
|
return intent != null ? intent.getIntExtra(EXTRA_TITLE_RES_ID, fallback) : fallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCreateOptionsMenu(final Menu menu) {
|
|
|
|
super.onCreateOptionsMenu(menu);
|
|
|
|
final Intent i = getIntent();
|
2018-06-24 09:23:10 +00:00
|
|
|
boolean showEnterJid = i != null && i.getBooleanExtra(EXTRA_SHOW_ENTER_JID, false);
|
2018-06-23 19:35:37 +00:00
|
|
|
menu.findItem(R.id.action_scan_qr_code).setVisible(isCameraFeatureAvailable() && showEnterJid);
|
2018-12-01 12:27:00 +00:00
|
|
|
MenuItem mMenuSearchView = menu.findItem(R.id.action_search);
|
|
|
|
if (startSearching) {
|
|
|
|
mMenuSearchView.expandActionView();
|
|
|
|
}
|
2018-06-23 19:35:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSaveInstanceState(Bundle savedInstanceState) {
|
|
|
|
savedInstanceState.putStringArray("selected_contacts", getSelectedContactJids());
|
|
|
|
super.onSaveInstanceState(savedInstanceState);
|
|
|
|
}
|
|
|
|
|
2018-12-01 12:27:00 +00:00
|
|
|
@Override
|
|
|
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
|
if (multiple) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
List<ListItem> items = getListItems();
|
|
|
|
if (items.size() == 1) {
|
|
|
|
onListItemClicked(items.get(0));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-23 19:35:37 +00:00
|
|
|
protected void filterContacts(final String needle) {
|
|
|
|
getListItems().clear();
|
|
|
|
if (xmppConnectionService == null) {
|
|
|
|
getListItemAdapter().notifyDataSetChanged();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (final Account account : xmppConnectionService.getAccounts()) {
|
|
|
|
if (account.getStatus() != Account.State.DISABLED) {
|
|
|
|
for (final Contact contact : account.getRoster().getContacts()) {
|
2018-10-31 09:52:14 +00:00
|
|
|
if (contact.showInContactList() &&
|
2018-06-23 19:35:37 +00:00
|
|
|
!filterContacts.contains(contact.getJid().asBareJid().toString())
|
|
|
|
&& contact.match(this, needle)) {
|
|
|
|
getListItems().add(contact);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Collections.sort(getListItems());
|
|
|
|
getListItemAdapter().notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
private String[] getSelectedContactJids() {
|
2018-12-01 12:27:00 +00:00
|
|
|
return selected.toArray(new String[0]);
|
2018-06-23 19:35:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void refreshUiReal() {
|
|
|
|
//nothing to do. This Activity doesn't implement any listeners
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.action_scan_qr_code:
|
|
|
|
ScanActivity.scan(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void showEnterJidDialog(XmppUri uri) {
|
|
|
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
|
|
|
Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
|
|
|
|
if (prev != null) {
|
|
|
|
ft.remove(prev);
|
|
|
|
}
|
|
|
|
ft.addToBackStack(null);
|
|
|
|
Jid jid = uri == null ? null : uri.getJid();
|
|
|
|
EnterJidDialog dialog = EnterJidDialog.newInstance(
|
|
|
|
mActivatedAccounts,
|
|
|
|
getString(R.string.enter_contact),
|
|
|
|
getString(R.string.select),
|
|
|
|
jid == null ? null : jid.asBareJid().toString(),
|
|
|
|
getIntent().getStringExtra(EXTRA_ACCOUNT),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
dialog.setOnEnterJidDialogPositiveListener((accountJid, contactJid) -> {
|
|
|
|
final Intent request = getIntent();
|
|
|
|
final Intent data = new Intent();
|
|
|
|
data.putExtra("contact", contactJid.toString());
|
|
|
|
data.putExtra(EXTRA_ACCOUNT, accountJid.toString());
|
2018-06-24 09:23:10 +00:00
|
|
|
data.putExtra(EXTRA_SELECT_MULTIPLE, false);
|
|
|
|
copy(request, data);
|
2018-06-23 19:35:37 +00:00
|
|
|
setResult(RESULT_OK, data);
|
|
|
|
finish();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
dialog.show(ft, "dialog");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
|
|
|
super.onActivityResult(requestCode, requestCode, intent);
|
|
|
|
ActivityResult activityResult = ActivityResult.of(requestCode, resultCode, intent);
|
|
|
|
if (xmppConnectionService != null) {
|
|
|
|
handleActivityResult(activityResult);
|
|
|
|
} else {
|
|
|
|
this.postponedActivityResult.push(activityResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleActivityResult(ActivityResult activityResult) {
|
|
|
|
if (activityResult.resultCode == RESULT_OK && activityResult.requestCode == ScanActivity.REQUEST_SCAN_QR_CODE) {
|
|
|
|
String result = activityResult.data.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
|
|
|
|
XmppUri uri = new XmppUri(result == null ? "" : result);
|
|
|
|
if (uri.isJidValid()) {
|
|
|
|
showEnterJidDialog(uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
void onBackendConnected() {
|
|
|
|
filterContacts();
|
|
|
|
this.mActivatedAccounts.clear();
|
|
|
|
for (Account account : xmppConnectionService.getAccounts()) {
|
|
|
|
if (account.getStatus() != Account.State.DISABLED) {
|
|
|
|
if (Config.DOMAIN_LOCK != null) {
|
|
|
|
this.mActivatedAccounts.add(account.getJid().getLocal());
|
|
|
|
} else {
|
|
|
|
this.mActivatedAccounts.add(account.getJid().asBareJid().toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ActivityResult activityResult = this.postponedActivityResult.pop();
|
|
|
|
if (activityResult != null) {
|
|
|
|
handleActivityResult(activityResult);
|
|
|
|
}
|
2018-12-01 12:27:00 +00:00
|
|
|
final Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG_DIALOG);
|
|
|
|
if (fragment instanceof OnBackendConnected) {
|
2018-06-23 19:35:37 +00:00
|
|
|
((OnBackendConnected) fragment).onBackendConnected();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
|
|
|
ScanActivity.onRequestPermissionResult(this, requestCode, grantResults);
|
|
|
|
}
|
2018-12-01 12:27:00 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
if (multiple) {
|
|
|
|
startActionMode(this);
|
|
|
|
getListView().setItemChecked(position, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
imm.hideSoftInputFromWindow(getSearchEditText().getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
|
|
|
|
final ListItem mListItem = getListItems().get(position);
|
|
|
|
onListItemClicked(mListItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onListItemClicked(ListItem item) {
|
|
|
|
final Intent request = getIntent();
|
|
|
|
final Intent data = new Intent();
|
|
|
|
data.putExtra("contact", item.getJid().toString());
|
|
|
|
String account = request.getStringExtra(EXTRA_ACCOUNT);
|
|
|
|
if (account == null && item instanceof Contact) {
|
|
|
|
account = ((Contact) item).getAccount().getJid().asBareJid().toString();
|
|
|
|
}
|
|
|
|
data.putExtra(EXTRA_ACCOUNT, account);
|
|
|
|
data.putExtra(EXTRA_SELECT_MULTIPLE, false);
|
|
|
|
copy(request, data);
|
|
|
|
setResult(RESULT_OK, data);
|
|
|
|
finish();
|
|
|
|
}
|
2014-07-16 22:03:37 +00:00
|
|
|
}
|