private void actionModeDelete() { ListView lv = getListView(); ArrayList<Long> checkedIds = new ArrayList<Long>(); for(int i = 0; i < lv.getCount(); i++) { if(lv.isItemChecked(i)) { long[] selectedIds = mAdapter.getCallIdsAtPosition(i); for(long id : selectedIds) { checkedIds.add(id); } } } if(checkedIds.size() > 0) { String strCheckedIds = TextUtils.join(", ", checkedIds); Log.d(THIS_FILE, "Checked positions ("+ strCheckedIds +")"); getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, Calls._ID + " IN ("+strCheckedIds+")", null); mMode.finish(); } }
public void set(long id, String name, String label, String number, int type, long date) { if( name == null ) { name = ContactAccessor.getInstance().getNameForNumber(getActivity(), number); } this.line1.setText((name == null || name.equals("")) ? number : name); this.number.setText((name == null || name.equals("")) ? "" : number); this.label.setText(label); this.date.setText(DateUtils.getRelativeDateTimeString(context, date, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE)); if (type == Calls.INCOMING_TYPE || type == RedPhoneCallTypes.INCOMING) callTypeIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_call_log_list_incoming_call)); else if (type == Calls.OUTGOING_TYPE || type == RedPhoneCallTypes.OUTGOING) callTypeIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_call_log_list_outgoing_call)); else if (type == Calls.MISSED_TYPE || type == RedPhoneCallTypes.MISSED) callTypeIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_call_log_list_missed_call)); this.contactData = new ContactData(id, name); this.contactData.numbers.add(new NumberData(null, number)); if (selectedContacts.containsKey(id)) this.line1.setChecked(true); else this.line1.setChecked(false); }
@Override public void setViewImage(ImageView view, String value) { if (view.getId() == R.id.liCallIcon) { switch (Integer.parseInt (value)) { case Calls.INCOMING_TYPE : view.setImageResource(R.drawable.ic_recived); break; case Calls.OUTGOING_TYPE : view.setImageResource(R.drawable.ic_made); break; case Calls.MISSED_TYPE : view.setImageResource(R.drawable.ic_missed); break; case Calls.REJECTED_TYPE : view.setImageResource(R.drawable.ic_rejected); break; } Log.d("APPTEST", value); } }
@Override public Cursor runQueryOnBackgroundThread(CharSequence constraint) { if (getFilterQueryProvider() != null) { return new CallsCursor(getFilterQueryProvider().runQuery(constraint)); } StringBuilder buffer; String[] args; buffer = new StringBuilder(); buffer.append(Calls.NUMBER); buffer.append(" LIKE ? OR "); buffer.append(Calls.CACHED_NAME); buffer.append(" LIKE ?"); String arg = "%" + (constraint != null && constraint.length() > 0? constraint.toString() : "@") + "%"; args = new String[] { arg, arg}; return new CallsCursor(mContent.query(Calls.CONTENT_URI, PROJECTION, buffer.toString(), args, Calls.NUMBER + " asc")); }
@Override public Cursor runQueryOnBackgroundThread(CharSequence constraint) { if (getFilterQueryProvider() != null) { return new CallsCursor(getFilterQueryProvider().runQuery( constraint)); } StringBuilder buffer; String[] args; buffer = new StringBuilder(); buffer.append(Calls.NUMBER); buffer.append(" LIKE ? OR "); buffer.append(Calls.CACHED_NAME); buffer.append(" LIKE ?"); String arg = "%" + (constraint != null && constraint.length() > 0 ? constraint .toString() : "@") + "%"; args = new String[] { arg, arg }; return new CallsCursor(mContent.query(Calls.CONTENT_URI, PROJECTION, buffer.toString(), args, Calls.NUMBER + " asc")); }
@Override public void onChange(boolean selfChange) { Cursor cursor = context.getContentResolver().query( Calls.CONTENT_URI, null, Calls.TYPE + " = ? AND " + Calls.NEW + " = ?", new String[] { Integer.toString(Calls.MISSED_TYPE), "1" }, Calls.DATE + " DESC "); int c = cursor.getCount(); if(c > 0) { Log.d(LOG_TAG, "missed call=" + c + " register screen off for activate bln"); // initialize receiver IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); if(screenReceiver == null) { screenReceiver = new ScreenReceiver(); } context.registerReceiver(screenReceiver, filter); }else { Log.d(LOG_TAG, "deactivate bln"); //set BLN off SysCommand.getInstance().writeSysfs("/sys/class/misc/backlightnotification/notification_led", "0"); } }
private static int queryMissCallCount(Context context) { int count = 0; Cursor cursor = null; try { cursor = context.getContentResolver().query(Calls.CONTENT_URI, null, "type=3 and new=1", null, null); } catch (IllegalStateException e) { System.gc(); } if (cursor != null) { count = cursor.getCount(); cursor.close(); } Log.d(TAG, "getMissCallCount count=" + count); return count; }
/** * Check, if there is dual sim support. */ public static boolean checkCallsSimIdColumn(final ContentResolver cr) { try { String where = BuildConfig.DEBUG_LOG ? null : "1=2"; Cursor c = cr.query(Calls.CONTENT_URI, null, where, null, null); boolean check = false; if (c != null) { check = SimIdColumnFinder.getsInstance().getSimIdColumn(cr, Calls.CONTENT_URI, c) >= 0; c.close(); } Log.i(TAG, "sim_id column found in calls database: " + check); return check; } catch (SQLiteException e) { Log.w(TAG, "sim_id check for calls failed", e); return false; } }
public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(getActivity(), SipManager.CALLLOG_URI, new String[] { Calls._ID, Calls.CACHED_NAME, Calls.CACHED_NUMBER_LABEL, Calls.CACHED_NUMBER_TYPE, Calls.DURATION, Calls.DATE, Calls.NEW, Calls.NUMBER, Calls.TYPE, SipManager.CALLLOG_PROFILE_ID_FIELD }, null, null, Calls.DEFAULT_SORT_ORDER); }
public void onMenuRemoveFromCallLog(MenuItem menuItem) { final StringBuilder callIds = new StringBuilder(); for (Uri callUri : getCallLogEntryUris()) { if (callIds.length() != 0) { callIds.append(","); } callIds.append(ContentUris.parseId(callUri)); } getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, Calls._ID + " IN (" + callIds + ")", null); if (quitListener != null) { quitListener.onQuit(); } }
private Drawable getCallTypeDrawable(int callType) { switch (callType) { case Calls.INCOMING_TYPE: return mResources.incoming; case Calls.OUTGOING_TYPE: return mResources.outgoing; case Calls.MISSED_TYPE: return mResources.missed; default: throw new IllegalArgumentException("invalid call type: " + callType); } }
private int getCallTypeText(int callType) { switch (callType) { case Calls.INCOMING_TYPE: return R.string.type_incoming; case Calls.OUTGOING_TYPE: return R.string.type_outgoing; case Calls.MISSED_TYPE: return R.string.type_missed; default: throw new IllegalArgumentException("invalid call type: " + callType); } }
private Cursor getCalls (int type) { Uri llamadasUri = CallLog.Calls.CONTENT_URI; ContentResolver contentResolver = getContentResolver(); String [] projection = new String [] {Calls._ID, Calls.NUMBER, Calls.DURATION, Calls.TYPE}; String selection = null; String [] selectionArgs = null; if (type == Calls.INCOMING_TYPE || type == Calls.OUTGOING_TYPE || type == Calls.MISSED_TYPE || type == Calls.REJECTED_TYPE ) { selection = Calls.TYPE + " = ? "; selectionArgs = new String [] {Integer.toString(type)}; } String order = Calls.DATE + " DESC "; // verificar permisos de llamada int permissionCheck = ContextCompat.checkSelfPermission (this, Manifest.permission.READ_CALL_LOG); if (permissionCheck == PackageManager.PERMISSION_GRANTED) { cursor = contentResolver.query(llamadasUri, // URI del Content provider projection, // Columnas a devolver selection, // Condición a la query selectionArgs, // Argumentos variables de la condición order); // Orden de los resultados } return cursor; }
private ContactFromCallsCursorWrapper(Cursor cursor) { super(cursor); cursor.moveToFirst(); ID = cursor.getColumnIndex(Calls._ID); NUMBER = cursor.getColumnIndex(Calls.NUMBER); NAME = cursor.getColumnIndex(Calls.CACHED_NAME); }
private Cursor getMissedCalls(Context context) { if (permissionChecker.canAccessMissedCallPermissions()) { //noinspection MissingPermission return context.getContentResolver().query( Calls.CONTENT_URI, new String[]{Calls.NUMBER, Calls.DATE, Calls.CACHED_NAME}, Calls.TYPE + " = ? AND " + Calls.NEW + " = ?", new String[]{Integer.toString(Calls.MISSED_TYPE), "1"}, Calls.DATE + " DESC" ); } return null; }
@Override public void bindView(View view, Context context, Cursor cursor) { long id = cursor.getLong(cursor.getColumnIndexOrThrow(Calls._ID)); String name = cursor.getString(cursor.getColumnIndexOrThrow(Calls.CACHED_NAME)); String label = cursor.getString(cursor.getColumnIndexOrThrow(Calls.CACHED_NUMBER_LABEL)); String number = cursor.getString(cursor.getColumnIndexOrThrow(Calls.NUMBER)); int type = cursor.getInt(cursor.getColumnIndexOrThrow(Calls.TYPE)); long date = cursor.getLong(cursor.getColumnIndexOrThrow(Calls.DATE)); ((CallItemView)view).set(id, name, label, number, type, date); }
@Override public void onStart() { super.onStart(); Receiver.engine(this).registerMore(); ContentResolver content = getContentResolver(); Cursor cursor = content.query(Calls.CONTENT_URI, PROJECTION, Calls.NUMBER+" like ?", new String[] { "%@%" }, Calls.DEFAULT_SORT_ORDER); CallsAdapter adapter = new CallsAdapter(this, cursor); sip_uri_box.setAdapter(adapter); sip_uri_box2.setAdapter(adapter); }
public void log(long start) { String number = getAddress(); long duration = (start != 0 ? SystemClock.elapsedRealtime()-start : 0); boolean isPrivateNumber = false; // TODO: need API for isPrivate() // Set the "type" to be displayed in the call log (see constants in CallLog.Calls) int callLogType; if (isIncoming()) { callLogType = (duration == 0 ? CallLog.Calls.MISSED_TYPE : CallLog.Calls.INCOMING_TYPE); } else { callLogType = CallLog.Calls.OUTGOING_TYPE; } // get the callerinfo object and then log the call with it. { Object o = getUserData(); CallerInfo ci; if ((o == null) || (o instanceof CallerInfo)){ ci = (CallerInfo) o; } else { ci = ((PhoneUtils.CallerInfoToken) o).currentInfo; } if (callLogType == CallLog.Calls.MISSED_TYPE) Receiver.onText(Receiver.MISSED_CALL_NOTIFICATION, ci != null && ci.name != null?ci.name:number, android.R.drawable.stat_notify_missed_call, 0); addCall(ci, Receiver.mContext, number, isPrivateNumber, callLogType, date, (int) duration / 1000); } }
private Uri getMoinitorUri(int type) { switch (type) { case MONITOR_PHONE: return Calls.CONTENT_URI; case MONITOR_MESSAGE: return Telephony.MmsSms.CONTENT_URI; case MONITOR_UPDATE: return null; // update uri default: break; } return null; }
@Override protected Map<String,CursorCell<?>> getProjectionMap() { Map<String,CursorCell<?>> projectionKeyToType = new HashMap<String, CursorCell<?>>(); projectionKeyToType.put(Calls._ID, intCell()); projectionKeyToType.put(Calls.NUMBER, new SensitiveCell(new PhoneNumberCell())); projectionKeyToType.put(Calls.DATE, longCell()); projectionKeyToType.put(Calls.TYPE, intCell()); projectionKeyToType.put(Calls.DURATION, longCell()); projectionKeyToType.put(Calls.CACHED_NAME, sensitiveStringCell()); projectionKeyToType.put(Calls.CACHED_NUMBER_LABEL, sensitiveStringCell()); projectionKeyToType.put(Calls.CACHED_NUMBER_TYPE, sensitiveStringCell()); return projectionKeyToType; }
/** * Finds all groups of adjacent entries in the call log which should be grouped together and * calls {@link CallLogListFragment.GroupCreator#addGroup(int, int, boolean)} on * {@link #mGroupCreator} for each of them. * <p> * For entries that are not grouped with others, we do not need to create a group of size one. * <p> * It assumes that the cursor will not change during its execution. * * @see GroupingListAdapter#addGroups(Cursor) */ public void addGroups(Cursor cursor) { final int count = cursor.getCount(); if (count == 0) { return; } int numberColIndex = cursor.getColumnIndex(Calls.NUMBER); int typeColIndex = cursor.getColumnIndex(Calls.TYPE); int currentGroupSize = 1; cursor.moveToFirst(); // The number of the first entry in the group. String firstNumber = cursor.getString(numberColIndex); // This is the type of the first call in the group. int firstCallType = cursor.getInt(typeColIndex); while (cursor.moveToNext()) { // The number of the current row in the cursor. final String currentNumber = cursor.getString(numberColIndex); final int callType = cursor.getInt(typeColIndex); final boolean sameNumber = equalNumbers(firstNumber, currentNumber); final boolean shouldGroup; if (!sameNumber) { // Should only group with calls from the same number. shouldGroup = false; } else if ( firstCallType == Calls.MISSED_TYPE) { // Voicemail and missed calls should only be grouped with subsequent missed calls. shouldGroup = callType == Calls.MISSED_TYPE; } else { // Incoming and outgoing calls group together. shouldGroup = callType == Calls.INCOMING_TYPE || callType == Calls.OUTGOING_TYPE; } if (shouldGroup) { // Increment the size of the group to include the current call, but do not create // the group until we find a call that does not match. currentGroupSize++; } else { // Create a group for the previous set of calls, excluding the current one, but do // not create a group for a single call. if (currentGroupSize > 1) { addGroup(cursor.getPosition() - currentGroupSize, currentGroupSize); } // Start a new group; it will include at least the current call. currentGroupSize = 1; // The current entry is now the first in the group. firstNumber = currentNumber; firstCallType = callType; } } // If the last set of calls at the end of the call log was itself a group, create it now. if (currentGroupSize > 1) { addGroup(count - currentGroupSize, currentGroupSize); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { // Make sure we have a valid convertView to start with final View result = convertView == null ? mLayoutInflater.inflate(R.layout.call_detail_history_item, parent, false) : convertView; PhoneCallDetails details = (PhoneCallDetails) getItem(position); CallTypeIconsView callTypeIconView = (CallTypeIconsView) result.findViewById(R.id.call_type_icon); TextView callTypeTextView = (TextView) result.findViewById(R.id.call_type_text); TextView dateView = (TextView) result.findViewById(R.id.date); TextView durationView = (TextView) result.findViewById(R.id.duration); int callType = details.callTypes[0]; callTypeIconView.clear(); callTypeIconView.add(callType); StringBuilder typeSb = new StringBuilder(); typeSb.append(mContext.getResources().getString(getCallTypeText(callType))); // If not 200, we add text for user feedback about what went wrong if(details.statusCode != 200) { typeSb.append(" - "); typeSb.append(details.statusCode); if(!TextUtils.isEmpty(details.statusText)) { typeSb.append(" / "); typeSb.append(details.statusText); } } callTypeTextView.setText(typeSb.toString()); // Set the date. CharSequence dateValue = DateUtils.formatDateRange(mContext, details.date, details.date, DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR); dateView.setText(dateValue); // Set the duration if (callType == Calls.MISSED_TYPE) { durationView.setVisibility(View.GONE); } else { durationView.setVisibility(View.VISIBLE); durationView.setText(formatDuration(details.duration)); } return result; }
@ReactMethod public void show( Callback callBack) { StringBuffer stringBuffer = new StringBuffer(); Cursor cursor = this.context.getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, CallLog.Calls.DATE + " DESC"); if (cursor == null) { callBack.invoke("[]"); return; } int number = cursor.getColumnIndex(CallLog.Calls.NUMBER); int type = cursor.getColumnIndex(CallLog.Calls.TYPE); int date = cursor.getColumnIndex(CallLog.Calls.DATE); int duration = cursor.getColumnIndex(CallLog.Calls.DURATION); int name = cursor.getColumnIndex(CallLog.Calls.CACHED_NAME); JSONArray callArray = new JSONArray(); while (cursor.moveToNext()) { String phNumber = cursor.getString(number); String callType = cursor.getString(type); String callDate = cursor.getString(date); Date callDayTime = new Date(Long.valueOf(callDate)); String callDuration = cursor.getString(duration); String cachedName = cursor.getString(name); String dir = null; int dircode = Integer.parseInt(callType); switch (dircode) { case CallLog.Calls.OUTGOING_TYPE: dir = "OUTGOING"; break; case CallLog.Calls.INCOMING_TYPE: dir = "INCOMING"; break; case CallLog.Calls.MISSED_TYPE: dir = "MISSED"; break; } JSONObject callObj = new JSONObject(); try{ callObj.put("phoneNumber",phNumber); callObj.put("callType", dir); callObj.put("callDate", callDate); callObj.put("callDuration", callDuration); callObj.put("callDayTime", callDayTime); callObj.put("cachedName", cachedName); callArray.put(callObj); } catch(JSONException e){ e.printStackTrace(); } } cursor.close(); callBack.invoke(callArray.toString()); }
@Override protected void syncData() { if (context == null || !isRunning()) { return; } if (ActivityCompat.checkSelfPermission( context, permission.READ_CALL_LOG) != PackageManager.PERMISSION_GRANTED) { Log.d(TAG, "Permission was NOT granted!"); setRunning(false); return; } long longLastKnownCallLogId = -1; DbCallLogSensor lastItem = daoProvider.getCallLogSensorDao().getLastCallLogEvent(); if (lastItem != null) { longLastKnownCallLogId = lastItem.getCallId(); } long deviceId = PreferenceProvider.getInstance(context).getCurrentDeviceId(); ContentResolver cr = context.getContentResolver(); Cursor cursor = null; try { cursor = cr.query(Calls.CONTENT_URI, null, Calls._ID + ">?", new String[]{String.valueOf(longLastKnownCallLogId)}, null); if (cursor == null || cursor.getCount() <= 0) { return; } // clear previous events events = new ArrayList<>(cursor.getCount()); String created = DateUtils.dateToISO8601String(new Date(), Locale.getDefault()); // Iterate over event while (cursor.moveToNext() && isRunning()) { DbCallLogSensor callLogEvent = new DbCallLogSensor(); callLogEvent.setCallId(getLongByColumnName(cursor, Calls._ID)); callLogEvent.setType(getIntByColumnName(cursor, Calls.TYPE)); callLogEvent.setNumber(getStringByColumnName(cursor, Calls.NUMBER)); callLogEvent.setName(getStringByColumnName(cursor, Calls.CACHED_NAME)); callLogEvent.setDate(getLongByColumnName(cursor, Calls.DATE)); callLogEvent.setDuration(getLongByColumnName(cursor, Calls.DURATION)); callLogEvent.setIsNew(Boolean.TRUE); callLogEvent.setIsDeleted(Boolean.FALSE); callLogEvent.setIsUpdated(Boolean.TRUE); callLogEvent.setDeviceId(deviceId); callLogEvent.setCreated(created); events.add(callLogEvent); } dumpData(); } finally { if (cursor != null) { cursor.close(); } } }
@Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { return new CursorLoader(getActivity(), Calls.CONTENT_URI, null, null, null, Calls.DEFAULT_SORT_ORDER); }
@Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.tv_dialButton: et_numberInput.setVisibility(View.GONE); mainActity.showNumberKeyBoard(); break; case R.id.tv_dialMenu: AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // builder.setIcon(R.drawable.); builder.setTitle("选择通话类型"); // 指定下拉列表的显示数据 final String[] cities = { "全部通话", "已接电话", "已拨电话", "未接来电" }; // 设置一个下拉的列表选择项 builder.setItems(cities, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: setShowedCallList(0); break; case Calls.INCOMING_TYPE: setShowedCallList(1); break; case Calls.OUTGOING_TYPE: setShowedCallList(2); break; case Calls.MISSED_TYPE: setShowedCallList(3); break; default: break; } adapter.notifyDataSetChanged(); } }); builder.show(); break; default: break; } }
public static void addCallToLog(ContentResolver contentResolver, String number, long duration, int type, long time) { ContentValues values = new ContentValues(); values.put(Calls.NUMBER, number); values.put(Calls.DATE, time); values.put(Calls.DURATION, duration); values.put(Calls.TYPE, type); values.put(Calls.NEW, 1); values.put(Calls.CACHED_NAME, ""); values.put(Calls.CACHED_NUMBER_TYPE, 0); values.put(Calls.CACHED_NUMBER_LABEL, ""); contentResolver.insert(Calls.CONTENT_URI, values); }
public static Uri addCall(CallerInfo ci, Context context, String number, boolean isPrivateNumber, int callType, long start, int duration) { final ContentResolver resolver = context.getContentResolver(); if (TextUtils.isEmpty(number)) { if (isPrivateNumber) { number = CallerInfo.PRIVATE_NUMBER; } else { number = CallerInfo.UNKNOWN_NUMBER; } } ContentValues values = new ContentValues(5); if (number.contains("&")) number = number.substring(0,number.indexOf("&")); values.put(Calls.NUMBER, number); values.put(Calls.TYPE, Integer.valueOf(callType)); values.put(Calls.DATE, Long.valueOf(start)); values.put(Calls.DURATION, Long.valueOf(duration)); values.put(Calls.NEW, Integer.valueOf(1)); if (ci != null) { values.put(Calls.CACHED_NAME, ci.name); values.put("cname", ci.name); if (ci.person_id > 0) values.put(Data.RAW_CONTACT_ID, ci.person_id); values.put(Calls.CACHED_NUMBER_TYPE, ci.numberType); values.put(Calls.CACHED_NUMBER_LABEL, ci.numberLabel); } if ((ci != null) && (ci.person_id > 0)) { ContactsContract.Contacts.markAsContacted(resolver, ci.person_id); } Uri result; try { result = resolver.insert(Calls.CONTENT_URI, values); } catch (IllegalArgumentException e) { if (ci != null) { values.remove("cname"); if (ci.person_id > 0) values.remove(Data.RAW_CONTACT_ID); } result = resolver.insert(Calls.CONTENT_URI, values); } if (result != null) { // send info about call to call meter final Intent intent = new Intent(ACTION_CM_SIP); intent.putExtra(EXTRA_SIP_URI, result.toString()); // TODO: add provider // intent.putExtra(EXTRA_SIP_PROVIDER, null); context.sendBroadcast(intent); } return result; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (position == 0) { final View header = convertView == null ? mLayoutInflater.inflate(R.layout.call_detail_history_header, parent, false) : convertView; // Call and SMS controls are only shown in the main UI if there is a known number. View callAndSmsContainer = header.findViewById(R.id.header_call_and_sms_container); callAndSmsContainer.setVisibility(mShowCallAndSms ? View.VISIBLE : View.GONE); header.setFocusable(true); header.setOnFocusChangeListener(mHeaderFocusChangeListener); return header; } // Make sure we have a valid convertView to start with final View result = convertView == null ? mLayoutInflater.inflate(R.layout.call_detail_history_item, parent, false) : convertView; PhoneCallDetails details = mPhoneCallDetails[position - 1]; CallTypeIconsView callTypeIconView = (CallTypeIconsView) result.findViewById(R.id.call_type_icon); TextView callTypeTextView = (TextView) result.findViewById(R.id.call_type_text); TextView dateView = (TextView) result.findViewById(R.id.date); TextView durationView = (TextView) result.findViewById(R.id.duration); int callType = details.callTypes[0]; callTypeIconView.clear(); callTypeIconView.add(callType); callTypeTextView.setText(mCallTypeHelper.getCallTypeText(callType)); // Set the date. CharSequence dateValue = DateUtils.formatDateRange(mContext, details.date, details.date, DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR); dateView.setText(dateValue); if (callType == Calls.MISSED_TYPE) { // Set the duration durationView.setVisibility(View.GONE); } else { durationView.setVisibility(View.VISIBLE); durationView.setText(formatDuration(details.duration)); } return result; }
public MissedCallObserver(Context context) { super(new Handler()); this.context = context; context.getContentResolver().registerContentObserver(Calls.CONTENT_URI, true, this); }