FileDocCategorySizeDatePackage
FdnList.javaAPI DocAndroid 1.5 API4653Wed May 06 22:42:46 BST 2009com.android.phone

FdnList

public class FdnList extends ADNList
FDN List UI for the Phone app.

Fields Summary
private static final int
MENU_ADD
private static final int
MENU_EDIT
private static final int
MENU_DELETE
private static final String
INTENT_EXTRA_NAME
private static final String
INTENT_EXTRA_NUMBER
Constructors Summary
Methods Summary
private voidaddContact()

        // if we don't put extras "name" when starting this activity, then
        // EditFdnContactScreen treats it like add contact.
        Intent intent = new Intent();
        intent.setClass(this, EditFdnContactScreen.class);
        startActivity(intent);
    
private voiddeleteSelected()

        if (mCursor.moveToPosition(getSelectedItemPosition())) {
            String name = mCursor.getString(NAME_COLUMN);
            String number = mCursor.getString(NUMBER_COLUMN);

            Intent intent = new Intent();
            intent.setClass(this, DeleteFdnContactScreen.class);
            intent.putExtra(INTENT_EXTRA_NAME, name);
            intent.putExtra(INTENT_EXTRA_NUMBER, number);
            startActivity(intent);
        }
    
private voideditSelected()
Overloaded to call editSelected with the current selection by default. This method may have a problem with touch UI since touch UI does not really have a concept of "selected" items.

        editSelected(getSelectedItemPosition());
    
private voideditSelected(int position)
Edit the item at the selected position in the list.

        if (mCursor.moveToPosition(position)) {
            String name = mCursor.getString(NAME_COLUMN);
            String number = mCursor.getString(NUMBER_COLUMN);

            Intent intent = new Intent();
            intent.setClass(this, EditFdnContactScreen.class);
            intent.putExtra(INTENT_EXTRA_NAME, name);
            intent.putExtra(INTENT_EXTRA_NUMBER, number);
            startActivity(intent);
        }
    
public booleanonCreateOptionsMenu(android.view.Menu menu)

        super.onCreateOptionsMenu(menu);

        Resources r = getResources();

        // Added the icons to the context menu
        menu.add(0, MENU_ADD, 0, r.getString(R.string.menu_add))
                .setIcon(android.R.drawable.ic_menu_add);
        menu.add(0, MENU_EDIT, 0, r.getString(R.string.menu_edit))
                .setIcon(android.R.drawable.ic_menu_edit);
        menu.add(0, MENU_DELETE, 0, r.getString(R.string.menu_delete))
                .setIcon(android.R.drawable.ic_menu_delete);
        return true;
    
public voidonListItemClick(android.widget.ListView l, android.view.View v, int position, long id)

        // TODO: is this what we really want?
        editSelected(position);
    
public booleanonOptionsItemSelected(android.view.MenuItem item)

        switch (item.getItemId()) {
            case MENU_ADD:
                addContact();
                return true;

            case MENU_EDIT:
                editSelected();
                return true;

            case MENU_DELETE:
                deleteSelected();
                return true;
        }

        return super.onOptionsItemSelected(item);
    
public booleanonPrepareOptionsMenu(android.view.Menu menu)

        super.onPrepareOptionsMenu(menu);
        boolean hasSelection = (getSelectedItemPosition() >= 0);

        menu.findItem(MENU_ADD).setVisible(true);
        menu.findItem(MENU_EDIT).setVisible(hasSelection);
        menu.findItem(MENU_DELETE).setVisible(hasSelection);

        return true;
    
protected android.net.UriresolveIntent()



    
       
        Intent intent = getIntent();
        intent.setData(Uri.parse("content://sim/fdn"));
        return intent.getData();