private void resetFilter() { int nCount = mItemAdapter.getCount(); for (int i = 0; i < nCount; ++i) { final DialpadItem item = (DialpadItem) mItemAdapter.getItem(i); item.setMatchField(FilterItem.INVALID_FIELD); item.setMatchKey(null); } }
@Override public void loadAllContacts() { // called by beforetext changed. String number = mDialpad.getNumber(); if (TextUtils.isEmpty(number)) { // enter first number, shold load contacts. log("loadAllContacts() loadDialpadItems..."); final List<DialpadItem> items = PimEngine.getInstance(this).loadDialpadItems(false); mItemAdapter.setIsShowInFilterList(true); mItemAdapter.update(items, true); } }
@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 public void filterNumber(String number) { resetFilter(); mItemAdapter.getFilter().filter(number, this); if (CAIDAN_NUMBER.equals(number)) { if (mPopupWin == null) { LayoutInflater inflater = LayoutInflater.from(this); View caidan = inflater.inflate(R.layout.caidan_layout, null); mPopupWin = new PopupWindow(caidan, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mPopupWin.setTouchable(true); View dialpadView = findViewById(R.id.dialpad_keyboard); mPopupWin.showAtLocation( dialpadView, Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0); caidan.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { if (mPopupWin != null) { mPopupWin.dismiss(); mPopupWin = null; } } }); } } }
// add by zenghuaying fix bug #8479 @Override public boolean onPrepareOptionsMenu(Menu menu) { if (mItemAdapter.getCount() <= 0) { menu.removeItem(R.id.menu_delete_log); } else { menu.clear(); getMenuInflater().inflate(R.menu.dialpad_options_menu, menu); } return super.onPrepareOptionsMenu(menu); }
private void reloadDialpadItems() { String number = mDialpad.getNumber(); if (TextUtils.isEmpty(number)) { categorizeCallLog(DialpadView.CALLLOG_TYPE_ALL); return; } else { final List<DialpadItem> items = PimEngine.getInstance(this).loadDialpadItems(false); // loge("reloadDialpadItems items size=" + items.size()); resetFilter(); mItemAdapter.updateAndFilter(items, true, number, this); // filterNumber(number); } }
public void categorizeCallLog(int logType) { if (null != mItemAdapter) { final List<DialpadItem> logGroups = PimEngine.getInstance(this).loadDialpadItems(false); final int count = logGroups.size(); if (count > 0) { final ArrayList<DialpadItem> newValues = new ArrayList<DialpadItem>(count); for (int i = 0; i < count; i++) { final DialpadItem item = logGroups.get(i); if ((DialpadView.CALLLOG_TYPE_ALL == logType || item.hasCallType(logType)) && DialpadItem.CALLLOG_TYPE == item.getType()) { // add by zenghuaying fix bug #8908 if (item.getContactId() == 0) { item.setName(null); } // add end newValues.add(item); } } mItemAdapter.setIsShowInFilterList(false); // add by zenghuaying mItemAdapter.setFilterCallType(logType); mItemAdapter.update(newValues, false); loge("categorizeCallLog adapter update"); } if (Calls.OUTGOING_TYPE == logType) { setLogsEmptyHint(getResources().getText(R.string.outgoing_logs_empty)); } else if (Calls.INCOMING_TYPE == logType) { setLogsEmptyHint(getResources().getText(R.string.incoming_logs_empty)); } else if (Calls.MISSED_TYPE == logType) { setLogsEmptyHint(getResources().getText(R.string.missed_logs_empty)); } else { setLogsEmptyHint(getResources().getText(R.string.call_logs_empty)); } } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfoIn) { super.onCreateContextMenu(menu, v, menuInfoIn); if (v.getId() == R.id.edt_dpkb_call_number) { menu.removeItem(android.R.id.switchInputMethod); menu.removeItem(android.R.id.selectAll); menu.removeItem(android.R.id.startSelectingText); return; } if (menuInfoIn != null) { AdapterView.AdapterContextMenuInfo menuInfo = null; try { menuInfo = (AdapterView.AdapterContextMenuInfo) menuInfoIn; } catch (ClassCastException e) { log("bad menuInfoIn e = " + e); return; } mContextMenuIdx = menuInfo.position; mDialpadItem = mItemAdapter.getItem(mContextMenuIdx); String name = mDialpadItem.getName(); String number = mDialpadItem.getNumber(); long contactId = mDialpadItem.getContactId(); log("onCreateContextMenu: name=" + name + " number=" + number + " contactId=" + contactId); if (!TextUtils.isEmpty(name)) { menu.setHeaderTitle(name); } else { if (number.equals(CallerInfo.UNKNOWN_NUMBER)) { number = getResources().getString(R.string.unknown); } else if (number.equals(CallerInfo.PRIVATE_NUMBER)) { number = getResources().getString(R.string.private_num); } else if (number.equals(CallerInfo.PAYPHONE_NUMBER)) { number = getResources().getString(R.string.payphone); } menu.setHeaderTitle(number); } if (DialpadItem.CALLLOG_TYPE == mDialpadItem.getType()) { menu.add(0, R.id.menu_log_detail, 0, R.string.view_calllog_detail); } menu.add(0, R.id.menu_send_message, 0, R.string.send_message); if (0 == contactId) { menu.add(0, R.id.menu_new_contact, 0, R.string.menu_newContact); // modify by zenghuaying fix bug #5705 if (!CommonMethod.contactsIsEmpty(this)) { menu.add(0, R.id.menu_add_to_contacts, 0, R.string.menu_add_to_contacts); } // modify end } else { menu.add(0, R.id.menu_view_contact, 0, R.string.view_contact); } if (DialpadItem.CALLLOG_TYPE == mDialpadItem.getType()) { menu.add(0, R.id.menu_delete_log, 0, R.string.delete_call_log); } if (CommonMethod.numberIsInBlacklist(this, number)) { menu.add(0, R.id.menu_clear_from_blacklist, 0, R.string.clear_from_blacklist); } else { menu.add(0, R.id.menu_add_to_blacklist, 0, R.string.add_to_blacklist); } } }