PageRenderTime 13ms CodeModel.GetById 17ms app.highlight 9ms RepoModel.GetById 0ms app.codeStats 1ms

/CVox/src/com/android/contacts/EditContactActivity.java

http://eyes-free.googlecode.com/
Java | 1583 lines | 73 code | 7 blank | 1503 comment | 1 complexity | 2294fbfd5d8aa880e37b7e2945d6f66b MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/*
   2 * Copyright (C) 2007 The Android Open Source Project
   3 *
   4 * Licensed under the Apache License, Version 2.0 (the "License");
   5 * you may not use this file except in compliance with the License.
   6 * You may obtain a copy of the License at
   7 *
   8 *      http://www.apache.org/licenses/LICENSE-2.0
   9 *
  10 * Unless required by applicable law or agreed to in writing, software
  11 * distributed under the License is distributed on an "AS IS" BASIS,
  12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 * See the License for the specific language governing permissions and
  14 * limitations under the License.
  15 */
  16
  17package com.android.contacts;
  18
  19//import com.google.android.collect.Lists;
  20//
  21//import static com.android.contacts.ContactEntryAdapter.CONTACT_CUSTOM_RINGTONE_COLUMN;
  22//import static com.android.contacts.ContactEntryAdapter.CONTACT_NAME_COLUMN;
  23//import static com.android.contacts.ContactEntryAdapter.CONTACT_NOTES_COLUMN;
  24//import static com.android.contacts.ContactEntryAdapter.CONTACT_PROJECTION;
  25//import static com.android.contacts.ContactEntryAdapter.CONTACT_SEND_TO_VOICEMAIL_COLUMN;
  26//import static com.android.contacts.ContactEntryAdapter.METHODS_AUX_DATA_COLUMN;
  27//import static com.android.contacts.ContactEntryAdapter.METHODS_DATA_COLUMN;
  28//import static com.android.contacts.ContactEntryAdapter.METHODS_ID_COLUMN;
  29//import static com.android.contacts.ContactEntryAdapter.METHODS_ISPRIMARY_COLUMN;
  30//import static com.android.contacts.ContactEntryAdapter.METHODS_KIND_COLUMN;
  31//import static com.android.contacts.ContactEntryAdapter.METHODS_LABEL_COLUMN;
  32//import static com.android.contacts.ContactEntryAdapter.METHODS_PROJECTION;
  33//import static com.android.contacts.ContactEntryAdapter.METHODS_TYPE_COLUMN;
  34//import static com.android.contacts.ContactEntryAdapter.ORGANIZATIONS_COMPANY_COLUMN;
  35//import static com.android.contacts.ContactEntryAdapter.ORGANIZATIONS_ID_COLUMN;
  36//import static com.android.contacts.ContactEntryAdapter.ORGANIZATIONS_ISPRIMARY_COLUMN;
  37//import static com.android.contacts.ContactEntryAdapter.ORGANIZATIONS_LABEL_COLUMN;
  38//import static com.android.contacts.ContactEntryAdapter.ORGANIZATIONS_PROJECTION;
  39//import static com.android.contacts.ContactEntryAdapter.ORGANIZATIONS_TITLE_COLUMN;
  40//import static com.android.contacts.ContactEntryAdapter.ORGANIZATIONS_TYPE_COLUMN;
  41//import static com.android.contacts.ContactEntryAdapter.PHONES_ID_COLUMN;
  42//import static com.android.contacts.ContactEntryAdapter.PHONES_ISPRIMARY_COLUMN;
  43//import static com.android.contacts.ContactEntryAdapter.PHONES_LABEL_COLUMN;
  44//import static com.android.contacts.ContactEntryAdapter.PHONES_NUMBER_COLUMN;
  45//import static com.android.contacts.ContactEntryAdapter.PHONES_PROJECTION;
  46//import static com.android.contacts.ContactEntryAdapter.PHONES_TYPE_COLUMN;
  47
  48import android.app.Activity;
  49import android.app.AlertDialog;
  50import android.app.Dialog;
  51import android.content.ActivityNotFoundException;
  52import android.content.ContentResolver;
  53import android.content.ContentUris;
  54import android.content.ContentValues;
  55import android.content.Context;
  56import android.content.DialogInterface;
  57import android.content.Intent;
  58import android.content.SharedPreferences;
  59import android.content.res.Resources;
  60import android.database.Cursor;
  61import android.graphics.Bitmap;
  62import android.media.Ringtone;
  63import android.media.RingtoneManager;
  64import android.net.Uri;
  65import android.os.Bundle;
  66import android.os.Parcel;
  67import android.os.Parcelable;
  68import android.preference.PreferenceManager;
  69import android.provider.Contacts;
  70import android.provider.Contacts.ContactMethods;
  71import android.provider.Contacts.Intents.Insert;
  72import android.provider.Contacts.Organizations;
  73import android.provider.Contacts.People;
  74import android.provider.Contacts.Phones;
  75import android.telephony.PhoneNumberFormattingTextWatcher;
  76import android.text.TextUtils;
  77import android.text.method.DialerKeyListener;
  78import android.text.method.TextKeyListener;
  79import android.text.method.TextKeyListener.Capitalize;
  80import android.util.Log;
  81import android.view.ContextThemeWrapper;
  82import android.view.KeyEvent;
  83import android.view.LayoutInflater;
  84import android.view.Menu;
  85import android.view.MenuItem;
  86import android.view.View;
  87import android.view.ViewGroup;
  88import android.view.ViewParent;
  89import android.widget.Button;
  90import android.widget.CheckBox;
  91import android.widget.EditText;
  92import android.widget.ExpandableListView;
  93import android.widget.ImageView;
  94import android.widget.LinearLayout;
  95import android.widget.SimpleExpandableListAdapter;
  96import android.widget.TextView;
  97import android.widget.Toast;
  98
  99import java.io.ByteArrayOutputStream;
 100import java.util.ArrayList;
 101import java.util.HashMap;
 102import java.util.List;
 103import java.util.Map;
 104
 105/**
 106 * Activity for editing or inserting a contact. Note that if the contact data changes in the
 107 * background while this activity is running, the updates will be overwritten.
 108 */
 109public final class EditContactActivity {
 110//extends Activity implements View.OnClickListener,
 111//        ExpandableListView.OnChildClickListener {
 112//    private static final String TAG = "EditContactActivity";
 113//
 114//    private static final int STATE_UNKNOWN = 0;
 115//    /** Editing an existing contact */
 116//    private static final int STATE_EDIT = 1;
 117//    /** The full insert mode */
 118//    private static final int STATE_INSERT = 2;
 119//
 120//    /** The launch code when picking a photo and the raw data is returned */
 121//    private static final int PHOTO_PICKED_WITH_DATA = 3021;
 122//
 123//    /** The launch code when picking a ringtone */
 124//    private static final int RINGTONE_PICKED = 3023;
 125//    
 126//    // Label picker position info
 127//    final static int LABEL_PICKER_PHONES_POSITION = 0;
 128//    final static int LABEL_PICKER_EMAIL_POSITION = 1;
 129//    final static int LABEL_PICKER_IM_POSITION = 2;
 130//    final static int LABEL_PICKER_POSTAL_POSITION = 3;
 131//    final static int LABEL_PICKER_OTHER_POSITION = 4;
 132//
 133//    // These correspond to the string array in resources for picker "other" items
 134//    final static int OTHER_ORGANIZATION = 0;
 135//    final static int OTHER_NOTE = 1;
 136//    
 137//    // Dialog IDs
 138//    final static int LABEL_PICKER_ALL_TYPES_DIALOG = 1;
 139//    final static int DELETE_CONFIRMATION_DIALOG = 2;
 140//
 141//    // Menu item IDs
 142//    public static final int MENU_ITEM_SAVE = 1;
 143//    public static final int MENU_ITEM_DONT_SAVE = 2;
 144//    public static final int MENU_ITEM_DELETE = 3;
 145//    public static final int MENU_ITEM_ADD = 5;
 146//    public static final int MENU_ITEM_PHOTO = 6;
 147//    
 148//    // Key listener types
 149//    final static int INPUT_TEXT = 1;
 150//    final static int INPUT_TEXT_WORDS = 2;
 151//    final static int INPUT_TEXT_SENTENCES = 3;
 152//    final static int INPUT_DIALER = 4;
 153//
 154//    /** Used to represent an invalid type for a contact entry */
 155//    private static final int INVALID_TYPE = -1;
 156//    
 157//    /** The default type for a phone that is added via an intent */
 158//    private static final int DEFAULT_PHONE_TYPE = Phones.TYPE_MOBILE;
 159//
 160//    /** The default type for an email that is added via an intent */
 161//    private static final int DEFAULT_EMAIL_TYPE = ContactMethods.TYPE_HOME;
 162//
 163//    /** The default type for a postal address that is added via an intent */
 164//    private static final int DEFAULT_POSTAL_TYPE = ContactMethods.TYPE_HOME;
 165//
 166//    private int mState; // saved across instances
 167//    private boolean mInsert; // saved across instances
 168//    private Uri mUri; // saved across instances
 169//    /** In insert mode this is the photo */
 170//    private Bitmap mPhoto; // saved across instances
 171//    private boolean mPhotoChanged = false; // saved across instances
 172//    
 173//    private EditText mNameView;
 174//    private ImageView mPhotoImageView;
 175//    private Button mPhotoButton;
 176//    private CheckBox mSendToVoicemailCheckBox;
 177//    private LinearLayout mLayout;
 178//    private LayoutInflater mInflater;
 179//    private MenuItem mPhotoMenuItem;
 180//    private boolean mPhotoPresent = false;
 181//
 182//    // These are accessed by inner classes. They're package scoped to make access more efficient.
 183//    /* package */ ContentResolver mResolver;
 184//    /* package */ ArrayList<EditEntry> mPhoneEntries = new ArrayList<EditEntry>();
 185//    /* package */ ArrayList<EditEntry> mEmailEntries = new ArrayList<EditEntry>();
 186//    /* package */ ArrayList<EditEntry> mImEntries = new ArrayList<EditEntry>();
 187//    /* package */ ArrayList<EditEntry> mPostalEntries = new ArrayList<EditEntry>();
 188//    /* package */ ArrayList<EditEntry> mOtherEntries = new ArrayList<EditEntry>();
 189//    /* package */ ArrayList<ArrayList<EditEntry>> mSections = new ArrayList<ArrayList<EditEntry>>();
 190//
 191//    /* package */ static final int MSG_DELETE = 1;
 192//    /* package */ static final int MSG_CHANGE_LABEL = 2;
 193//    /* package */ static final int MSG_ADD_PHONE = 3;
 194//    /* package */ static final int MSG_ADD_EMAIL = 4;
 195//    /* package */ static final int MSG_ADD_POSTAL = 5;
 196//
 197//    public void onClick(View v) {
 198//        switch (v.getId()) {
 199//            case R.id.photoButton:
 200//            case R.id.photoImage: {
 201//                doPickPhotoAction();
 202//                break;
 203//            }
 204//
 205//            case R.id.addMore:
 206//                doAddAction();
 207//                break;
 208//
 209//            case R.id.saveButton:
 210//                doSaveAction();
 211//                break;
 212//
 213//            case R.id.discardButton:
 214//                doRevertAction();
 215//                break;
 216//
 217//            case R.id.delete:
 218//            case R.id.delete2: {
 219//                EditEntry entry = findEntryForView(v);
 220//                if (entry != null) {
 221//                    // Clear the text and hide the view so it gets saved properly
 222//                    ((TextView) entry.view.findViewById(R.id.data)).setText(null);
 223//                    entry.view.setVisibility(View.GONE);
 224//                    entry.isDeleted = true;
 225//                }
 226//                break;
 227//            }
 228//
 229//            case R.id.label: {
 230//                EditEntry entry = findEntryForView(v);
 231//                if (entry != null) {
 232//                    String[] labels = getLabelsForKind(this, entry.kind);
 233//                    LabelPickedListener listener = new LabelPickedListener(entry, labels);
 234//                    new AlertDialog.Builder(EditContactActivity.this)
 235//                            .setItems(labels, listener)
 236//                            .setTitle(R.string.selectLabel)
 237//                            .show();
 238//                }
 239//                break;
 240//            }
 241//                
 242//            case R.id.data: {
 243//                EditEntry entry = findEntryForView(v);
 244//                if (isRingtoneEntry(entry)) {
 245//                    doPickRingtone(entry);
 246//                }
 247//                break;
 248//            }
 249//        }
 250//    }
 251//
 252//    private void setPhotoPresent(boolean present) {
 253//        mPhotoImageView.setVisibility(present ? View.VISIBLE : View.GONE);
 254//        mPhotoButton.setVisibility(present ? View.GONE : View.VISIBLE);
 255//        mPhotoPresent = present;
 256//        if (mPhotoMenuItem != null) {
 257//            if (present) {
 258//                mPhotoMenuItem.setTitle(R.string.removePicture);
 259//                mPhotoMenuItem.setIcon(android.R.drawable.ic_menu_delete);
 260//            } else {
 261//                mPhotoMenuItem.setTitle(R.string.addPicture);
 262//                mPhotoMenuItem.setIcon(android.R.drawable.ic_menu_add);
 263//            }
 264//        }
 265//    }
 266//    
 267//    private EditEntry findEntryForView(View v) {
 268//        // Try to find the entry for this view
 269//        EditEntry entry = null;
 270//        do {
 271//            Object tag = v.getTag();
 272//            if (tag != null && tag instanceof EditEntry) {
 273//                entry = (EditEntry) tag;
 274//                break;
 275//            } else {
 276//                ViewParent parent = v.getParent();
 277//                if (parent != null && parent instanceof View) {
 278//                    v = (View) parent;
 279//                } else {
 280//                    v = null;
 281//                }
 282//            }
 283//        } while (v != null);
 284//        return entry;
 285//    }
 286//
 287//    private DialogInterface.OnClickListener mDeleteContactDialogListener =
 288//            new DialogInterface.OnClickListener() {
 289//        public void onClick(DialogInterface dialog, int button) {
 290//            mResolver.delete(mUri, null, null);
 291//            finish();
 292//        }
 293//    };
 294//
 295//    private boolean mMobilePhoneAdded = false;
 296//    private boolean mPrimaryEmailAdded = false;
 297//
 298//    @Override
 299//    protected void onCreate(Bundle icicle) {
 300//        super.onCreate(icicle);
 301//
 302//        mResolver = getContentResolver();
 303//
 304//        // Build the list of sections
 305//        setupSections();
 306//
 307//        // Load the UI
 308//        setContentView(R.layout.edit_contact);
 309//        mLayout = (LinearLayout) findViewById(R.id.list);
 310//        mNameView = (EditText) findViewById(R.id.name);
 311//        mPhotoImageView = (ImageView) findViewById(R.id.photoImage);
 312//        mPhotoImageView.setOnClickListener(this);
 313//        mPhotoImageView.setVisibility(View.GONE);
 314//        mPhotoButton = (Button) findViewById(R.id.photoButton);
 315//        mPhotoButton.setOnClickListener(this);
 316//        mSendToVoicemailCheckBox = (CheckBox) findViewById(R.id.send_to_voicemail);
 317//
 318//        // Setup the bottom buttons 
 319//        View view = findViewById(R.id.addMore);
 320//        view.setOnClickListener(this);
 321//        view = findViewById(R.id.saveButton);
 322//        view.setOnClickListener(this);
 323//        view = findViewById(R.id.discardButton);
 324//        view.setOnClickListener(this);
 325//
 326//        mInflater = getLayoutInflater();
 327//
 328//        // Resolve the intent
 329//        mState = STATE_UNKNOWN;
 330//        Intent intent = getIntent();
 331//        String action = intent.getAction();
 332//        mUri = intent.getData();
 333//        if (mUri != null) {
 334//            if (action.equals(Intent.ACTION_EDIT)) {
 335//                if (icicle == null) {
 336//                    // Build the entries & views
 337//                    buildEntriesForEdit(getIntent().getExtras());
 338//                    buildViews();
 339//                }
 340//                mState = STATE_EDIT;
 341//            } else if (action.equals(Intent.ACTION_INSERT)) {
 342//                if (icicle == null) {
 343//                    // Build the entries & views
 344//                    buildEntriesForInsert(getIntent().getExtras());
 345//                    buildViews();
 346//                }
 347//                mState = STATE_INSERT;
 348//                mInsert = true;
 349//            }
 350//        }
 351//
 352//        if (mState == STATE_UNKNOWN) {
 353//            Log.e(TAG, "Cannot resolve intent: " + intent);
 354//            finish();
 355//            return;
 356//        }
 357//
 358//        if (mState == STATE_EDIT) {
 359//            setTitle(getResources().getText(R.string.editContact_title_edit));
 360//        } else {
 361//            setTitle(getResources().getText(R.string.editContact_title_insert));
 362//        }
 363//    }
 364//
 365//    private void setupSections() {
 366//        mSections.add(mPhoneEntries);
 367//        mSections.add(mEmailEntries);
 368//        mSections.add(mImEntries);
 369//        mSections.add(mPostalEntries);
 370//        mSections.add(mOtherEntries);
 371//    }
 372//    
 373//    @Override
 374//    protected void onSaveInstanceState(Bundle outState) {
 375//        outState.putParcelableArrayList("phoneEntries", mPhoneEntries);
 376//        outState.putParcelableArrayList("emailEntries", mEmailEntries);
 377//        outState.putParcelableArrayList("imEntries", mImEntries);
 378//        outState.putParcelableArrayList("postalEntries", mPostalEntries);
 379//        outState.putParcelableArrayList("otherEntries", mOtherEntries);
 380//        outState.putInt("state", mState);
 381//        outState.putBoolean("insert", mInsert);
 382//        outState.putParcelable("uri", mUri);
 383//        outState.putString("name", mNameView.getText().toString());
 384//        outState.putParcelable("photo", mPhoto);
 385//        outState.putBoolean("photoChanged", mPhotoChanged);
 386//        outState.putBoolean("sendToVoicemail", mSendToVoicemailCheckBox.isChecked());
 387//    }
 388//
 389//    @Override
 390//    protected void onRestoreInstanceState(Bundle inState) {
 391//        mPhoneEntries = inState.getParcelableArrayList("phoneEntries");
 392//        mEmailEntries = inState.getParcelableArrayList("emailEntries");
 393//        mImEntries = inState.getParcelableArrayList("imEntries");
 394//        mPostalEntries = inState.getParcelableArrayList("postalEntries");
 395//        mOtherEntries = inState.getParcelableArrayList("otherEntries");
 396//        setupSections();
 397//
 398//        mState = inState.getInt("state");
 399//        mInsert = inState.getBoolean("insert");
 400//        mUri = inState.getParcelable("uri");
 401//        mNameView.setText(inState.getString("name"));
 402//        mPhoto = inState.getParcelable("photo");
 403//        if (mPhoto != null) {
 404//            mPhotoImageView.setImageBitmap(mPhoto);
 405//            setPhotoPresent(true);
 406//        } else {
 407//            mPhotoImageView.setImageResource(R.drawable.ic_contact_picture);
 408//            setPhotoPresent(false);
 409//        }
 410//        mPhotoChanged = inState.getBoolean("photoChanged");
 411//        mSendToVoicemailCheckBox.setChecked(inState.getBoolean("sendToVoicemail"));
 412//        
 413//        // Now that everything is restored, build the view
 414//        buildViews();
 415//    }
 416//
 417//    @Override
 418//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 419//        if (resultCode != RESULT_OK) {
 420//            return;
 421//        }
 422//
 423//        switch (requestCode) {
 424//            case PHOTO_PICKED_WITH_DATA: {
 425//                final Bundle extras = data.getExtras();
 426//                if (extras != null) {
 427//                    Bitmap photo = extras.getParcelable("data");
 428//                    mPhoto = photo;
 429//                    mPhotoChanged = true;
 430//                    mPhotoImageView.setImageBitmap(photo);
 431//                    setPhotoPresent(true);
 432//                }
 433//                break;
 434//            }
 435//
 436//            case RINGTONE_PICKED: {
 437//                Uri pickedUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
 438//                handleRingtonePicked(pickedUri);
 439//                break;
 440//            }
 441//        }
 442//    }
 443//    
 444//    @Override
 445//    public boolean onKeyDown(int keyCode, KeyEvent event) {
 446//        switch (keyCode) {
 447//            case KeyEvent.KEYCODE_BACK: {
 448//                doSaveAction();
 449//                return true;
 450//            }
 451//        }
 452//        return super.onKeyDown(keyCode, event);
 453//    }
 454//
 455//    @Override
 456//    public boolean onCreateOptionsMenu(Menu menu) {
 457//        super.onCreateOptionsMenu(menu);
 458//        menu.add(0, MENU_ITEM_SAVE, 0, R.string.menu_done)
 459//                .setIcon(android.R.drawable.ic_menu_save)
 460//                .setAlphabeticShortcut('\n');
 461//        menu.add(0, MENU_ITEM_DONT_SAVE, 0, R.string.menu_doNotSave)
 462//                .setIcon(android.R.drawable.ic_menu_close_clear_cancel)
 463//                .setAlphabeticShortcut('q');
 464//        if (!mInsert) {
 465//            menu.add(0, MENU_ITEM_DELETE, 0, R.string.menu_deleteContact)
 466//                    .setIcon(android.R.drawable.ic_menu_delete);
 467//        }
 468//
 469//        menu.add(0, MENU_ITEM_ADD, 0, R.string.menu_addItem)
 470//                .setIcon(android.R.drawable.ic_menu_add)
 471//                .setAlphabeticShortcut('n');
 472//
 473//        mPhotoMenuItem = menu.add(0, MENU_ITEM_PHOTO, 0, null);
 474//        // Updates the state of the menu item
 475//        setPhotoPresent(mPhotoPresent);
 476//
 477//        return true;
 478//    }
 479//
 480//    @Override
 481//    public boolean onOptionsItemSelected(MenuItem item) {
 482//        switch (item.getItemId()) {
 483//            case MENU_ITEM_SAVE:
 484//                doSaveAction();
 485//                return true;
 486//    
 487//            case MENU_ITEM_DONT_SAVE:
 488//                doRevertAction();
 489//                return true;
 490//    
 491//            case MENU_ITEM_DELETE:
 492//                // Get confirmation
 493//                showDialog(DELETE_CONFIRMATION_DIALOG);
 494//                return true;
 495//    
 496//            case MENU_ITEM_ADD:
 497//                doAddAction();
 498//                return true;
 499//
 500//            case MENU_ITEM_PHOTO:
 501//                if (!mPhotoPresent) {
 502//                    doPickPhotoAction();
 503//                } else {
 504//                    doRemovePhotoAction();
 505//                }
 506//                return true;
 507//        }
 508//
 509//        return false;
 510//    }
 511//
 512//    private void doAddAction() {
 513//        showDialog(LABEL_PICKER_ALL_TYPES_DIALOG);
 514//    }
 515//
 516//    private void doRevertAction() {
 517//        finish();
 518//    }
 519//
 520//    private void doPickPhotoAction() {
 521//        Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
 522//        // TODO: get these values from constants somewhere
 523//        intent.setType("image/*");
 524//        intent.putExtra("crop", "true");
 525//        intent.putExtra("aspectX", 1);
 526//        intent.putExtra("aspectY", 1);
 527//        intent.putExtra("outputX", 96);
 528//        intent.putExtra("outputY", 96);
 529//        try {
 530//            intent.putExtra("return-data", true);
 531//            startActivityForResult(intent, PHOTO_PICKED_WITH_DATA);
 532//        } catch (ActivityNotFoundException e) {
 533//            new AlertDialog.Builder(EditContactActivity.this)
 534//                .setTitle(R.string.errorDialogTitle)
 535//                .setMessage(R.string.photoPickerNotFoundText)
 536//                .setPositiveButton(R.string.okButtonText, null)
 537//                .show();
 538//        }
 539//    }
 540//
 541//    private void doRemovePhotoAction() {
 542//        mPhoto = null;
 543//        mPhotoChanged = true;
 544//        mPhotoImageView.setImageResource(R.drawable.ic_contact_picture);
 545//        setPhotoPresent(false);
 546//    }
 547//    
 548//    private void doPickRingtone(EditEntry entry) {
 549//        Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
 550//        // Allow user to pick 'Default'
 551//        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
 552//        // Show only ringtones
 553//        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE);
 554//        // Don't show 'Silent'
 555//        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
 556//        if (entry.data != null) {
 557//            Uri ringtoneUri = Uri.parse(entry.data);
 558//            // Put checkmark next to the current ringtone for this contact
 559//            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, ringtoneUri);
 560//        }
 561//        // Launch!
 562//        startActivityForResult(intent, RINGTONE_PICKED);
 563//    }
 564//    
 565//    private void handleRingtonePicked(Uri pickedUri) {
 566//        EditEntry entry = getRingtoneEntry();
 567//        if (entry == null) {
 568//            Log.w(TAG, "Ringtone picked but could not find ringtone entry");
 569//            return;
 570//        }
 571//        
 572//        if (pickedUri == null || RingtoneManager.isDefault(pickedUri)) {
 573//            entry.data = null;
 574//        } else {
 575//            entry.data = pickedUri.toString();
 576//        }
 577//        
 578//        updateRingtoneView(entry);
 579//    }
 580//
 581//    private void updateRingtoneView(EditEntry entry) {
 582//        if (entry.data == null) {
 583//            updateDataView(entry, getString(R.string.default_ringtone));
 584//        } else {
 585//            Uri ringtoneUri = Uri.parse(entry.data);
 586//            Ringtone ringtone = RingtoneManager.getRingtone(this, ringtoneUri);
 587//            if (ringtone == null) {
 588//                Log.w(TAG, "ringtone's URI doesn't resolve to a Ringtone");
 589//                return;
 590//            }
 591//            updateDataView(entry, ringtone.getTitle(this));
 592//        }
 593//    }
 594//    
 595//    private void updateDataView(EditEntry entry, String text) {
 596//        TextView dataView = (TextView) entry.view.findViewById(R.id.data);
 597//        dataView.setText(text);
 598//    }
 599//    
 600//    @Override
 601//    protected Dialog onCreateDialog(int id) {
 602//        switch (id) {
 603//            case LABEL_PICKER_ALL_TYPES_DIALOG:
 604//                return createAllTypesPicker();
 605//
 606//            case DELETE_CONFIRMATION_DIALOG:
 607//                return new AlertDialog.Builder(EditContactActivity.this)
 608//                        .setTitle(R.string.deleteConfirmation_title)
 609//                        .setIcon(android.R.drawable.ic_dialog_alert)
 610//                        .setMessage(R.string.deleteConfirmation)
 611//                        .setNegativeButton(R.string.noButton, null)
 612//                        .setPositiveButton(R.string.yesButton, mDeleteContactDialogListener)
 613//                        .setCancelable(false)
 614//                        .create();
 615//        }
 616//        return super.onCreateDialog(id);
 617//    }
 618    
 619    static String[] getLabelsForKind(Context context, int kind) {
 620        final Resources resources = context.getResources();
 621        switch (kind) {
 622            case Contacts.KIND_PHONE:
 623                return resources.getStringArray(android.R.array.phoneTypes);
 624            case Contacts.KIND_EMAIL:
 625                return resources.getStringArray(android.R.array.emailAddressTypes);
 626            case Contacts.KIND_POSTAL:
 627                return resources.getStringArray(android.R.array.postalAddressTypes);
 628            case Contacts.KIND_IM:
 629                return resources.getStringArray(android.R.array.imProtocols);
 630            case Contacts.KIND_ORGANIZATION:
 631                return resources.getStringArray(android.R.array.organizationTypes);
 632//            case EditEntry.KIND_CONTACT:
 633//                return resources.getStringArray(R.array.otherLabels);
 634        }
 635        return null;
 636    }
 637
 638//    int getTypeFromLabelPosition(CharSequence[] labels, int labelPosition) {
 639//        // In the UI Custom... comes last, but it is uses the constant 0
 640//        // so it is in the same location across the various kinds. Fix up the
 641//        // position to a valid type here.
 642//        if (labelPosition == labels.length - 1) {
 643//            return ContactMethods.TYPE_CUSTOM;
 644//        } else {
 645//            return labelPosition + 1;
 646//        }
 647//    }
 648//
 649//    public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
 650//            int childPosition, long id) {
 651//        EditEntry entry = null;
 652//
 653//        // Make the dialog go away
 654//        dismissDialog(LABEL_PICKER_ALL_TYPES_DIALOG);
 655//
 656//        // Create the new entry
 657//        switch (groupPosition) {
 658//            case LABEL_PICKER_PHONES_POSITION: {
 659//                String[] labels = getLabelsForKind(this, Contacts.KIND_PHONE);
 660//                final int type = getTypeFromLabelPosition(labels, childPosition);
 661//                entry = EditEntry.newPhoneEntry(EditContactActivity.this,
 662//                        labels[childPosition], type,
 663//                        null, Uri.withAppendedPath(mUri, People.Phones.CONTENT_DIRECTORY), 0);
 664//                if (type == Phones.TYPE_CUSTOM) {
 665//                    createCustomPicker(entry, mPhoneEntries);
 666//                    return true;
 667//                } else {
 668//                    mPhoneEntries.add(entry);
 669//                }
 670//                break;
 671//            }
 672//
 673//            case LABEL_PICKER_EMAIL_POSITION: {
 674//                String[] labels = getLabelsForKind(this, Contacts.KIND_EMAIL);
 675//                final int type = getTypeFromLabelPosition(labels, childPosition);
 676//                entry = EditEntry.newEmailEntry(EditContactActivity.this,
 677//                        labels[childPosition], type, null,
 678//                        Uri.withAppendedPath(mUri, People.ContactMethods.CONTENT_DIRECTORY), 0);
 679//                if (type == ContactMethods.TYPE_CUSTOM) {
 680//                    createCustomPicker(entry, mEmailEntries);
 681//                    return true;
 682//                } else {
 683//                    mEmailEntries.add(entry);
 684//                }
 685//                break;
 686//            }
 687//            
 688//            case LABEL_PICKER_IM_POSITION: {
 689//                String[] labels = getLabelsForKind(this, Contacts.KIND_IM);
 690//                entry = EditEntry.newImEntry(EditContactActivity.this,
 691//                        labels[childPosition], childPosition, null,
 692//                        Uri.withAppendedPath(mUri, People.ContactMethods.CONTENT_DIRECTORY), 0);
 693//                mImEntries.add(entry);
 694//                break;
 695//            }
 696//
 697//            case LABEL_PICKER_POSTAL_POSITION: {
 698//                String[] labels = getLabelsForKind(this, Contacts.KIND_POSTAL);
 699//                final int type = getTypeFromLabelPosition(labels, childPosition);
 700//                entry = EditEntry.newPostalEntry(EditContactActivity.this,
 701//                        labels[childPosition], type, null,
 702//                        Uri.withAppendedPath(mUri, People.ContactMethods.CONTENT_DIRECTORY), 0);
 703//                if (type == ContactMethods.TYPE_CUSTOM) {
 704//                    createCustomPicker(entry, mPostalEntries);
 705//                    return true;
 706//                } else {
 707//                    mPostalEntries.add(entry);
 708//                }
 709//                break;
 710//            }
 711//            
 712//            case LABEL_PICKER_OTHER_POSITION: {
 713//                switch (childPosition) {
 714//                    case OTHER_ORGANIZATION:
 715//                        entry = EditEntry.newOrganizationEntry(EditContactActivity.this,
 716//                                Uri.withAppendedPath(mUri, Organizations.CONTENT_DIRECTORY),
 717//                                ContactMethods.TYPE_WORK);
 718//                        mOtherEntries.add(entry);
 719//                        break;
 720//
 721//                    case OTHER_NOTE:
 722//                        entry = EditEntry.newNotesEntry(EditContactActivity.this, null, mUri);
 723//                        mOtherEntries.add(entry);
 724//                        break;
 725//                        
 726//                    default:
 727//                        entry = null;
 728//                }
 729//                break;
 730//            }
 731//
 732//            default:
 733//                entry = null;
 734//        }
 735//
 736//        // Rebuild the views if needed
 737//        if (entry != null) {
 738//            buildViews();
 739//
 740//            View dataView = entry.view.findViewById(R.id.data);
 741//            if (dataView == null) {
 742//                entry.view.requestFocus();
 743//            } else {
 744//                dataView.requestFocus();
 745//            }
 746//        }
 747//        return true;
 748//    }
 749//
 750//    private EditEntry getRingtoneEntry() {
 751//        for (int i = mOtherEntries.size() - 1; i >= 0; i--) {
 752//            EditEntry entry = mOtherEntries.get(i);
 753//            if (isRingtoneEntry(entry)) {
 754//                return entry;
 755//            }
 756//        }
 757//        return null;
 758//    }
 759//    
 760//    private static boolean isRingtoneEntry(EditEntry entry) {
 761//        return entry != null && entry.column != null && entry.column.equals(People.CUSTOM_RINGTONE);
 762//    }
 763//    
 764//    private Dialog createAllTypesPicker() {
 765//        // Setup the adapter
 766//        List<Map<String, ?>> groupData = Lists.newArrayList();
 767//        List<List<Map<String, ?>>> childData = Lists.newArrayList();
 768//        List<Map<String, ?>> children;
 769//        HashMap<String, CharSequence> curGroupMap;
 770//        CharSequence[] labels;
 771//        int labelsSize;
 772//
 773//        // Phones
 774//        curGroupMap = new HashMap<String, CharSequence>();
 775//        groupData.add(curGroupMap);
 776//        curGroupMap.put("data", getText(R.string.phoneLabelsGroup));
 777//
 778//        labels = getLabelsForKind(this, Contacts.KIND_PHONE);
 779//        labelsSize = labels.length;
 780//        children = Lists.newArrayList();
 781//        for (int i = 0; i < labelsSize; i++) {
 782//            HashMap<String, CharSequence> curChildMap = new HashMap<String, CharSequence>();
 783//            children.add(curChildMap);
 784//            curChildMap.put("data", labels[i]);
 785//        }
 786//        childData.add(LABEL_PICKER_PHONES_POSITION, children);
 787//
 788//        // Email
 789//        curGroupMap = new HashMap<String, CharSequence>();
 790//        groupData.add(curGroupMap);
 791//        curGroupMap.put("data", getText(R.string.emailLabelsGroup));
 792//
 793//        labels = getLabelsForKind(this, Contacts.KIND_EMAIL);
 794//        labelsSize = labels.length;
 795//        children = Lists.newArrayList();
 796//        for (int i = 0; i < labelsSize; i++) {
 797//            HashMap<String, CharSequence> curChildMap = new HashMap<String, CharSequence>();
 798//            children.add(curChildMap);
 799//            curChildMap.put("data", labels[i]);
 800//        }
 801//        childData.add(LABEL_PICKER_EMAIL_POSITION, children);
 802//
 803//        // IM
 804//        curGroupMap = new HashMap<String, CharSequence>();
 805//        groupData.add(curGroupMap);
 806//        curGroupMap.put("data", getText(R.string.imLabelsGroup));
 807//
 808//        labels = getLabelsForKind(this, Contacts.KIND_IM);
 809//        labelsSize = labels.length;
 810//        children = Lists.newArrayList();
 811//        for (int i = 0; i < labelsSize; i++) {
 812//            HashMap<String, CharSequence> curChildMap = new HashMap<String, CharSequence>();
 813//            children.add(curChildMap);
 814//            curChildMap.put("data", labels[i]);
 815//        }
 816//        childData.add(LABEL_PICKER_IM_POSITION, children);
 817//        
 818//        // Postal
 819//        curGroupMap = new HashMap<String, CharSequence>();
 820//        groupData.add(curGroupMap);
 821//        curGroupMap.put("data", getText(R.string.postalLabelsGroup));
 822//
 823//        labels = getLabelsForKind(this, Contacts.KIND_POSTAL);
 824//        labelsSize = labels.length;
 825//        children = Lists.newArrayList();
 826//        for (int i = 0; i < labelsSize; i++) {
 827//            HashMap<String, CharSequence> curChildMap = new HashMap<String, CharSequence>();
 828//            children.add(curChildMap);
 829//            curChildMap.put("data", labels[i]);
 830//        }
 831//        childData.add(LABEL_PICKER_POSTAL_POSITION, children);
 832//
 833//        // Other
 834//        curGroupMap = new HashMap<String, CharSequence>();
 835//        groupData.add(curGroupMap);
 836//        curGroupMap.put("data", getText(R.string.otherLabelsGroup));
 837//
 838//        labels = getLabelsForKind(this, EditEntry.KIND_CONTACT);
 839//        labelsSize = labels.length;
 840//        children = Lists.newArrayList();
 841//        for (int i = 0; i < labelsSize; i++) {
 842//            HashMap<String, CharSequence> curChildMap = new HashMap<String, CharSequence>();
 843//            children.add(curChildMap);
 844//            curChildMap.put("data", labels[i]);
 845//        }
 846//        childData.add(LABEL_PICKER_OTHER_POSITION, children);
 847//
 848//        // Create the expandable list view
 849//        ExpandableListView list = new ExpandableListView(new ContextThemeWrapper(this,
 850//                android.R.style.Theme_Light));
 851//        list.setOnChildClickListener(this);
 852//        list.setAdapter(new SimpleExpandableListAdapter(
 853//                new ContextThemeWrapper(this, android.R.style.Theme_Light),
 854//                groupData,
 855//                android.R.layout.simple_expandable_list_item_1,
 856//                new String[] { "data" },
 857//                new int[] { android.R.id.text1 },
 858//                childData,
 859//                android.R.layout.simple_expandable_list_item_1,
 860//                new String[] { "data" },
 861//                new int[] { android.R.id.text1 }
 862//                ));
 863//        // This list shouldn't have a color hint since the dialog may be transparent
 864//        list.setCacheColorHint(0);
 865//
 866//        // Create the dialog
 867//        return new AlertDialog.Builder(this).setView(list).setInverseBackgroundForced(true)
 868//                .setTitle(R.string.selectLabel).create();
 869//    }
 870//
 871//    private void createCustomPicker(final EditEntry entry, final ArrayList<EditEntry> addTo) {
 872//        final EditText label = new EditText(this);
 873//        label.setKeyListener(TextKeyListener.getInstance(false, Capitalize.WORDS));
 874//        label.requestFocus();
 875//        new AlertDialog.Builder(this)
 876//                .setView(label)
 877//                .setTitle(R.string.customLabelPickerTitle)
 878//                .setPositiveButton(R.string.okButtonText, new DialogInterface.OnClickListener() {
 879//                    public void onClick(DialogInterface dialog, int which) {
 880//                        entry.setLabel(EditContactActivity.this, ContactMethods.TYPE_CUSTOM,
 881//                                label.getText().toString());
 882//                        if (addTo != null) {
 883//                            addTo.add(entry);
 884//                            buildViews();
 885//                            entry.view.requestFocus(View.FOCUS_DOWN);
 886//                        }
 887//                    }
 888//                })
 889//                .setNegativeButton(R.string.cancelButtonText, null)
 890//                .show();
 891//    }
 892//    
 893//    /**
 894//     * Saves or creates the contact based on the mode, and if sucessful finishes the activity.
 895//     */
 896//    private void doSaveAction() {
 897//        // Save or create the contact if needed
 898//        switch (mState) {
 899//            case STATE_EDIT:
 900//                save();
 901//                break;
 902//
 903//            case STATE_INSERT:
 904//                create();
 905//                break;
 906//
 907//            default:
 908//                Log.e(TAG, "Unknown state in doSaveOrCreate: " + mState);
 909//                break;
 910//        }
 911//        finish();
 912//    }
 913//    
 914//    /**
 915//     * Save the various fields to the existing contact.
 916//     */
 917//    private void save() {
 918//        ContentValues values = new ContentValues();
 919//        String data;
 920//        int numValues = 0;
 921//
 922//        // Handle the name and send to voicemail specially
 923//        final String name = mNameView.getText().toString();
 924//        if (name != null && TextUtils.isGraphic(name)) {
 925//            numValues++;
 926//        }
 927//        values.put(People.NAME, name);
 928//        values.put(People.SEND_TO_VOICEMAIL, mSendToVoicemailCheckBox.isChecked() ? 1 : 0);
 929//        mResolver.update(mUri, values, null, null);
 930//
 931//        if (mPhotoChanged) {
 932//            // Only write the photo if it's changed, since we don't initially load mPhoto
 933//            if (mPhoto != null) {
 934//                ByteArrayOutputStream stream = new ByteArrayOutputStream();
 935//                mPhoto.compress(Bitmap.CompressFormat.JPEG, 75, stream);
 936//                Contacts.People.setPhotoData(mResolver, mUri, stream.toByteArray());
 937//            } else {
 938//                Contacts.People.setPhotoData(mResolver, mUri, null);
 939//            }
 940//        }
 941//
 942//        int entryCount = ContactEntryAdapter.countEntries(mSections, false);
 943//        for (int i = 0; i < entryCount; i++) {
 944//            EditEntry entry = ContactEntryAdapter.getEntry(mSections, i, false);
 945//            int kind = entry.kind;
 946//            data = entry.getData();
 947//            boolean empty = data == null || !TextUtils.isGraphic(data);
 948//            if (kind == EditEntry.KIND_CONTACT) {
 949//                values.clear();
 950//                if (!empty) {
 951//                    values.put(entry.column, data);
 952//                    mResolver.update(entry.uri, values, null, null);
 953//                    numValues++;
 954//                } else {
 955//                    values.put(entry.column, (String) null);
 956//                    mResolver.update(entry.uri, values, null, null);
 957//                }
 958//            } else {
 959//                if (!empty) {
 960//                    values.clear();
 961//                    entry.toValues(values);
 962//                    if (entry.id != 0) {
 963//                        mResolver.update(entry.uri, values, null, null);
 964//                    } else {
 965//                        mResolver.insert(entry.uri, values);
 966//                    }
 967//                    numValues++;
 968//                } else if (entry.id != 0) {
 969//                    mResolver.delete(entry.uri, null, null);
 970//                }
 971//            }
 972//        }
 973//
 974//        if (numValues == 0) {
 975//            // The contact is completely empty, delete it
 976//            mResolver.delete(mUri, null, null);
 977//            mUri = null;
 978//            setResult(RESULT_CANCELED);
 979//        } else {
 980//            // Add the entry to the my contacts group if it isn't there already
 981//            People.addToMyContactsGroup(mResolver, ContentUris.parseId(mUri));
 982//            setResult(RESULT_OK, new Intent().setData(mUri));
 983//            Toast.makeText(this, R.string.contactSavedToast, Toast.LENGTH_SHORT).show();
 984//        }
 985//    }
 986//
 987//    /**
 988//     * Takes the entered data and saves it to a new contact.
 989//     */
 990//    private void create() {
 991//        ContentValues values = new ContentValues();
 992//        String data;
 993//        int numValues = 0;
 994//
 995//        // Create the contact itself
 996//        final String name = mNameView.getText().toString();
 997//        if (name != null && TextUtils.isGraphic(name)) {
 998//            numValues++;
 999//        }
1000//        values.put(People.NAME, name);
1001//        values.put(People.SEND_TO_VOICEMAIL, mSendToVoicemailCheckBox.isChecked() ? 1 : 0);
1002//
1003//        // Add the contact to the My Contacts group
1004//        Uri contactUri = People.createPersonInMyContactsGroup(mResolver, values);
1005//
1006//        // Add the contact to the group that is being displayed in the contact list
1007//        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
1008//        int displayType = prefs.getInt(ContactsPreferenceActivity.PREF_DISPLAY_TYPE,
1009//                ContactsPreferenceActivity.DISPLAY_TYPE_UNKNOWN);
1010//        if (displayType == ContactsPreferenceActivity.DISPLAY_TYPE_USER_GROUP) {
1011//            String displayGroup = prefs.getString(ContactsPreferenceActivity.PREF_DISPLAY_INFO,
1012//                    null);
1013//            if (!TextUtils.isEmpty(displayGroup)) {
1014//                People.addToGroup(mResolver, ContentUris.parseId(contactUri), displayGroup);
1015//            }
1016//        }
1017//
1018//        // Handle the photo
1019//        if (mPhoto != null) {
1020//            ByteArrayOutputStream stream = new ByteArrayOutputStream();
1021//            mPhoto.compress(Bitmap.CompressFormat.JPEG, 75, stream);
1022//            Contacts.People.setPhotoData(getContentResolver(), contactUri, stream.toByteArray());
1023//        }
1024//
1025//        // Create the contact methods
1026//        int entryCount = ContactEntryAdapter.countEntries(mSections, false);
1027//        for (int i = 0; i < entryCount; i++) {
1028//            EditEntry entry = ContactEntryAdapter.getEntry(mSections, i, false);
1029//            if (entry.kind != EditEntry.KIND_CONTACT) {
1030//                values.clear();
1031//                if (entry.toValues(values)) {
1032//                    // Only create the entry if there is data
1033//                    entry.uri = mResolver.insert(
1034//                            Uri.withAppendedPath(contactUri, entry.contentDirectory), values);
1035//                    entry.id = ContentUris.parseId(entry.uri);
1036//                    numValues++;
1037//                }
1038//            } else {
1039//                // Update the contact with any straggling data, like notes
1040//                data = entry.getData();
1041//                values.clear();
1042//                if (data != null && TextUtils.isGraphic(data)) {
1043//                    values.put(entry.column, data);
1044//                    mResolver.update(contactUri, values, null, null);
1045//                    numValues++;
1046//                }
1047//            }
1048//        }
1049//
1050//        if (numValues == 0) {
1051//            mResolver.delete(contactUri, null, null);
1052//            setResult(RESULT_CANCELED);
1053//        } else {
1054//            mUri = contactUri;
1055//            Intent resultIntent = new Intent()
1056//                    .setData(mUri)
1057//                    .putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
1058//            setResult(RESULT_OK, resultIntent);
1059//            Toast.makeText(this, R.string.contactCreatedToast, Toast.LENGTH_SHORT).show();
1060//        }
1061//    }
1062//
1063//    /**
1064//     * Build up the entries to display on the screen.
1065//     *
1066//     * @param extras the extras used to start this activity, may be null
1067//     */
1068//    private void buildEntriesForEdit(Bundle extras) {
1069//        Cursor personCursor = mResolver.query(mUri, CONTACT_PROJECTION, null, null, null);
1070//        if (personCursor == null) {
1071//            Log.e(TAG, "invalid contact uri: " + mUri);
1072//            finish();
1073//            return;
1074//        } else if (!personCursor.moveToFirst()) {
1075//            Log.e(TAG, "invalid contact uri: " + mUri);
1076//            finish();
1077//            personCursor.close();
1078//            return;
1079//        }
1080//
1081//        // Clear out the old entries
1082//        int numSections = mSections.size();
1083//        for (int i = 0; i < numSections; i++) {
1084//            mSections.get(i).clear();
1085//        }
1086//
1087//        EditEntry entry;
1088//
1089//        // Name
1090//        mNameView.setText(personCursor.getString(CONTACT_NAME_COLUMN));
1091//
1092//        // Photo
1093//        mPhoto = People.loadContactPhoto(this, mUri, 0, null);
1094//        if (mPhoto == null) {
1095//            setPhotoPresent(false);
1096//        } else {
1097//            setPhotoPresent(true);
1098//            mPhotoImageView.setImageBitmap(mPhoto);
1099//        }
1100//
1101//        // Send to voicemail
1102//        mSendToVoicemailCheckBox
1103//                .setChecked(personCursor.getInt(CONTACT_SEND_TO_VOICEMAIL_COLUMN) == 1);
1104//
1105//        // Organizations
1106//        Uri organizationsUri = Uri.withAppendedPath(mUri, Organizations.CONTENT_DIRECTORY);
1107//        Cursor organizationsCursor = mResolver.query(organizationsUri, ORGANIZATIONS_PROJECTION,
1108//                null, null, null);
1109//
1110//        if (organizationsCursor != null) {
1111//            while (organizationsCursor.moveToNext()) {
1112//                int type = organizationsCursor.getInt(ORGANIZATIONS_TYPE_COLUMN);
1113//                String label = organizationsCursor.getString(ORGANIZATIONS_LABEL_COLUMN);
1114//                String company = organizationsCursor.getString(ORGANIZATIONS_COMPANY_COLUMN);
1115//                String title = organizationsCursor.getString(ORGANIZATIONS_TITLE_COLUMN);
1116//                long id = organizationsCursor.getLong(ORGANIZATIONS_ID_COLUMN);
1117//                Uri uri = ContentUris.withAppendedId(Organizations.CONTENT_URI, id);
1118//
1119//                // Add an organization entry
1120//                entry = EditEntry.newOrganizationEntry(this, label, type, company, title, uri, id);
1121//                entry.isPrimary = organizationsCursor.getLong(ORGANIZATIONS_ISPRIMARY_COLUMN) != 0;
1122//                mOtherEntries.add(entry);
1123//            }
1124//            organizationsCursor.close();
1125//        }
1126//
1127//        // Notes
1128//        if (!personCursor.isNull(CONTACT_NOTES_COLUMN)) {
1129//            entry = EditEntry.newNotesEntry(this, personCursor.getString(CONTACT_NOTES_COLUMN),
1130//                    mUri);
1131//            mOtherEntries.add(entry);
1132//        }
1133//
1134//        // Ringtone
1135//        entry = EditEntry.newRingtoneEntry(this,
1136//                personCursor.getString(CONTACT_CUSTOM_RINGTONE_COLUMN), mUri);
1137//        mOtherEntries.add(entry);
1138//        personCursor.close();
1139//
1140//        // Build up the phone entries
1141//        Uri phonesUri = Uri.withAppendedPath(mUri, People.Phones.CONTENT_DIRECTORY);
1142//        Cursor phonesCursor = mResolver.query(phonesUri, PHONES_PROJECTION,
1143//                null, null, null);
1144//
1145//        if (phonesCursor != null) {
1146//            while (phonesCursor.moveToNext()) {
1147//                int type = phonesCursor.getInt(PHONES_TYPE_COLUMN);
1148//                String label = phonesCursor.getString(PHONES_LABEL_COLUMN);
1149//                String number = phonesCursor.getString(PHONES_NUMBER_COLUMN);
1150//                long id = phonesCursor.getLong(PHONES_ID_COLUMN);
1151//                boolean isPrimary = phonesCursor.getLong(PHONES_ISPRIMARY_COLUMN) != 0;
1152//                Uri uri = ContentUris.withAppendedId(phonesUri, id);
1153//
1154//                // Add a phone number entry
1155//                entry = EditEntry.newPhoneEntry(this, label, type, number, uri, id);
1156//                entry.isPrimary = isPrimary;
1157//                mPhoneEntries.add(entry);
1158//
1159//                // Keep track of which primary types have been added
1160//                if (type == Phones.TYPE_MOBILE) {
1161//                    mMobilePhoneAdded = true;
1162//                }
1163//            }
1164//
1165//            phonesCursor.close();
1166//        }
1167//
1168//        // Build the contact method entries
1169//        Uri methodsUri = Uri.withAppendedPath(mUri, People.ContactMethods.CONTENT_DIRECTORY);
1170//        Cursor methodsCursor = mResolver.query(methodsUri, METHODS_PROJECTION, null, null, null);
1171//
1172//        if (methodsCursor != null) {
1173//            while (methodsCursor.moveToNext()) {
1174//                int kind = methodsCursor.getInt(METHODS_KIND_COLUMN);
1175//                String label = methodsCursor.getString(METHODS_LABEL_COLUMN);
1176//                String data = methodsCursor.getString(METHODS_DATA_COLUMN);
1177//                String auxData = methodsCursor.getString(METHODS_AUX_DATA_COLUMN);
1178//                int type = methodsCursor.getInt(METHODS_TYPE_COLUMN);
1179//                long id = methodsCursor.getLong(METHODS_ID_COLUMN);
1180//                boolean isPrimary = methodsCursor.getLong(METHODS_ISPRIMARY_COLUMN) != 0;
1181//                Uri uri = ContentUris.withAppendedId(methodsUri, id);
1182//
1183//                switch (kind) {
1184//                    case Contacts.KIND_EMAIL: {
1185//                        entry = EditEntry.newEmailEntry(this, label, type, data, uri, id);
1186//                        entry.isPrimary = isPrimary;
1187//                        mEmailEntries.add(entry);
1188//    
1189//                        if (isPrimary) {
1190//                            mPrimaryEmailAdded = true;
1191//                        }
1192//                        break;
1193//                    }
1194//
1195//                    case Contacts.KIND_POSTAL: {
1196//                        entry = EditEntry.newPostalEntry(this, label,

Large files files are truncated, but you can click here to view the full file