@Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo menuInfo = null;
    try {
      menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
      log("bad menuInfoIn e=" + e);
      return super.onContextItemSelected(item);
    }

    if (mDialpadItem == null) {
      mDialpadItem = mItemAdapter.getItem(mContextMenuIdx);
    }
    String name = mDialpadItem.getName();
    String number = mDialpadItem.getNumber();
    long contactId = mDialpadItem.getContactId();
    log("onContextItemSelected: name=" + name + " number=" + number + " contactId=" + contactId);
    switch (item.getItemId()) {
      case R.id.menu_new_contact:
        CommonMethod.newContact(this, number);
        break;

      case R.id.menu_add_to_contacts:
        CommonMethod.createContact(this, number);
        break;

      case R.id.menu_view_contact:
        CommonMethod.viewContact(this, contactId);
        break;

      case R.id.menu_send_message:
        CommonMethod.sendMessage(this, number, null);
        break;

      case R.id.menu_delete_log:
        CommonMethod.showConfirmDlg(
            this,
            R.string.clear_call_log_by_number_confirm,
            R.string.alert_dialog_title,
            new DelCallLogItemListener());
        break;

      case R.id.menu_log_detail:
        CommonMethod.viewPimDetail(this, name, number, contactId, DetailEntry.LOG_DETAIL);
        break;

      case R.id.menu_add_to_blacklist:
        CommonMethod.addToBlacklist(this, name, number);
        break;

      case R.id.menu_clear_from_blacklist:
        CommonMethod.clearFromBlacklist(this, name, number);
        break;

      default:
        break;
    }

    return super.onContextItemSelected(item);
  }
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    {
      super.onListItemClick(l, v, position, id);
      DialpadItem item = (DialpadItem) l.getItemAtPosition(position);
      String number = item.getNumber();
      long contactId = item.getContactId();
      String name = item.getName();
      SharedPreferences mPrefs = getSharedPreferences("call_log_settings", Context.MODE_PRIVATE);

      int mClickOption = mPrefs.getInt("call_log_click_option", 0);

      log("onListItemClick: " + position + " " + number + "Clickoption = " + mClickOption);
      if (!TextUtils.isEmpty(number)) {
        if (mClickOption == 0) {
          CommonMethod.viewPimDetail(
              this,
              name,
              number,
              contactId,
              (item.getType() == DialpadItem.CALLLOG_TYPE
                  ? DetailEntry.LOG_DETAIL
                  : DetailEntry.CONTACT_DETAIL));
        } else {
          // Added by GanFeng 20120213, fix bug3391
          if ((null != mDialpad) && TextUtils.isEmpty(mDialpad.getNumber())) {
            long timeElapsed = Math.abs(System.currentTimeMillis() - mDialpad.getTimeStamp());
            if (timeElapsed < 1000) { // the elapsed time < 1S
              return;
            }
          }
          if ((null != mDialpad) && !TextUtils.isEmpty(mDialpad.getNumber())) {
            mDialpad.setNumber(null);
            mDialpad.showNumberUI();
          }
          call(number);
        }
      }
    }
  }