2012-04-08 12:29:08 -04:00
|
|
|
package com.fsck.k9.activity;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
import android.widget.ListView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.AdapterView.OnItemClickListener;
|
|
|
|
|
|
|
|
import com.fsck.k9.R;
|
2012-04-08 12:32:04 -04:00
|
|
|
import com.fsck.k9.helper.ContactItem;
|
2012-04-08 12:29:08 -04:00
|
|
|
|
2011-10-01 13:16:35 -04:00
|
|
|
public class EmailAddressList extends K9ListActivity implements OnItemClickListener {
|
2012-04-08 19:23:45 -04:00
|
|
|
public static final String EXTRA_CONTACT_ITEM = "contact";
|
|
|
|
public static final String EXTRA_EMAIL_ADDRESS = "emailAddress";
|
|
|
|
|
|
|
|
|
2012-04-08 12:29:08 -04:00
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
2011-10-01 13:16:35 -04:00
|
|
|
setContentView(R.layout.email_address_list);
|
2012-04-08 12:29:08 -04:00
|
|
|
|
2012-04-08 12:32:04 -04:00
|
|
|
Intent i = getIntent();
|
2012-04-08 19:23:45 -04:00
|
|
|
ContactItem contact = (ContactItem) i.getSerializableExtra(EXTRA_CONTACT_ITEM);
|
2012-04-08 12:32:04 -04:00
|
|
|
if (contact == null) {
|
2012-04-08 19:23:45 -04:00
|
|
|
finish();
|
2012-04-08 12:29:08 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-08 19:14:51 -04:00
|
|
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
|
|
|
|
R.layout.email_address_list_item, contact.emailAddresses);
|
2012-04-08 12:29:08 -04:00
|
|
|
|
|
|
|
ListView listView = getListView();
|
|
|
|
listView.setOnItemClickListener(this);
|
|
|
|
listView.setAdapter(adapter);
|
2012-04-08 19:14:51 -04:00
|
|
|
setTitle(contact.displayName);
|
2012-04-08 12:29:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
String item = (String)parent.getItemAtPosition(position);
|
|
|
|
|
2011-10-01 13:16:35 -04:00
|
|
|
Toast.makeText(EmailAddressList.this, item, Toast.LENGTH_LONG).show();
|
2012-04-08 12:29:08 -04:00
|
|
|
|
|
|
|
Intent intent = new Intent();
|
2012-04-08 19:23:45 -04:00
|
|
|
intent.putExtra(EXTRA_EMAIL_ADDRESS, item);
|
2012-04-08 12:29:08 -04:00
|
|
|
setResult(RESULT_OK, intent);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|