Java Code Examples for android.provider.CallLog.Calls#MISSED_TYPE

The following examples show how to use android.provider.CallLog.Calls#MISSED_TYPE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CallTypeIconsView.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example 2
Source File: CallDetailHistoryAdapter.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example 3
Source File: CallLogModule.java    From react-native-call-log with MIT License 5 votes vote down vote up
private String resolveCallType(int callTypeCode) {
    switch (callTypeCode) {
        case Calls.OUTGOING_TYPE:
            return "OUTGOING";
        case Calls.INCOMING_TYPE:
            return "INCOMING";
        case Calls.MISSED_TYPE:
            return "MISSED";
        default:
            return "UNKNOWN";
    }
}
 
Example 4
Source File: LogEntryAdapter.java    From emerald-dialer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {
	final LogEntryCache viewCache = (LogEntryCache) view.getTag();
	if (viewCache == null) {
		return;
	}
	String name = cursor.getString(COLUMN_NAME);
	String phoneNumber = cursor.getString(COLUMN_NUMBER);
	if (phoneNumber == null) {
		phoneNumber = "";
	}
	String formattedNumber = PhoneNumberUtils.formatNumber(phoneNumber, Locale.getDefault().getCountry());
	if (!TextUtils.isEmpty(name)) {
		viewCache.contactName.setText(name);
		viewCache.phoneNumber.setText(formattedNumber);
	} else if (!TextUtils.isEmpty(formattedNumber)) {
		viewCache.contactName.setText(formattedNumber);
		viewCache.phoneNumber.setText("");
	} else {
		viewCache.contactName.setText("no number");
		viewCache.phoneNumber.setText("");
	}
	long date = cursor.getLong(COLUMN_DATE);
	viewCache.callDate.setText(DateUtils.formatSameDayTime(date, System.currentTimeMillis(), DateFormat.MEDIUM, DateFormat.SHORT));

	int id = cursor.getInt(COLUMN_TYPE);
	int callTypeDrawableId = 0;
	switch (id) {
		case Calls.INCOMING_TYPE:
			callTypeDrawableId = callReceivedDrawableId;
			break;
		case Calls.OUTGOING_TYPE:
			callTypeDrawableId = callMadeDrawableId;
			break;
		case Calls.MISSED_TYPE:
			callTypeDrawableId = R.drawable.ic_call_missed;
			break;
	}
	if (callTypeDrawableId != 0) {
		viewCache.callTypeImage.setImageDrawable(context.getResources().getDrawable(callTypeDrawableId, context.getTheme()));
	}
	viewCache.contactImage.setTag(phoneNumber); // set a tag for the callback to be able to check, so we don't set the contact image of a reused view
	Drawable d = mAsyncContactImageLoader.loadDrawableForNumber(phoneNumber, new ImageCallback() {
		
		@Override
		public void imageLoaded(Drawable imageDrawable, String number) {
			if (TextUtils.equals(number, (String)viewCache.contactImage.getTag())) {
				viewCache.contactImage.setImageDrawable(imageDrawable);
			}
		}
	});
	viewCache.contactImage.setImageDrawable(d);
	if (phoneNumber.length() == 0) {
		return;
	}
	viewCache.contactImage.setOnClickListener(this);
	
}
 
Example 5
Source File: CallLogGroupBuilder.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 6
Source File: CallDetailHistoryAdapter.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@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;
}
 
Example 7
Source File: RecentCallsFragment.java    From callerid-for-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void execute() {
	// Overriding executive seems weird... here's why I do it:
	// The background task (and its related preExecute/success/... handlers)
	// should only be called when a background lookup is necessary.
	// In the case of "special" numbers (payphone, unknown, and private)
	// any further lookup is unnecessary and not desired, but other
	// setup (like displaying the right icon and right text) is.
	// By overriding execute() and only calling super.execute() when
	// a background lookup should be done, that goal can be achieved.
	
	// Set the date/time field by mixing relative and absolute times.
	dateView.setText(
			DateUtils.getRelativeTimeSpanString(
					date,
					System.currentTimeMillis(), 
					DateUtils.MINUTE_IN_MILLIS, 
					DateUtils.FORMAT_ABBREV_RELATIVE));
	
          // Set the icon
          switch (callType) {
              case Calls.INCOMING_TYPE:
             	 callTypeIcon.setImageDrawable(drawableIncoming);
                  break;
              case Calls.OUTGOING_TYPE:
             	 callTypeIcon.setImageDrawable(drawableOutgoing);
                  break;
              case Calls.MISSED_TYPE:
             	 callTypeIcon.setImageDrawable(drawableMissed);
                  break;
          }
          
          if(TextUtils.isEmpty(phoneNumber) || SpecialPhoneNumbers.UNKNOWN_NUMBER.equals(phoneNumber)){
              callIcon.setOnClickListener(null);
              numberView.setText("");
              line1View.setText(lookupUnknown);
              labelView.setText("");
          }else if(SpecialPhoneNumbers.PRIVATE_NUMBER.equals(phoneNumber)){
              callIcon.setOnClickListener(null);
              numberView.setText("");
              line1View.setText(lookupPrivate);
              labelView.setText("");
          }else if(SpecialPhoneNumbers.PAYPHONE_NUMBER.equals(phoneNumber)){
              callIcon.setOnClickListener(null);
              numberView.setText("");
              line1View.setText(lookupPayphone);
              labelView.setText("");
          }else{
		numberView.setText(PhoneNumberUtils.formatNumber(phoneNumber));
		
		final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
		try{
			final PhoneNumber phoneNumberPhoneNumber = phoneNumberUtil.parse(phoneNumber.toString(), countryDetector.getCountry());
			final PhoneNumberOfflineGeocoder phoneNumberOfflineGeocoder = PhoneNumberOfflineGeocoder.getInstance();
			offlineGeocoderResult = phoneNumberOfflineGeocoder.getDescriptionForNumber(phoneNumberPhoneNumber, Locale.getDefault());
		}catch(NumberParseException e){
			//ignore this exception
		}
		if("".equals(offlineGeocoderResult)) offlineGeocoderResult = null;
		if(offlineGeocoderResult == null){
			labelView.setText(lookupInProgress);
			line1View.setText("");
		}else{
			line1View.setText(offlineGeocoderResult);
			labelView.setText("");
		}
            
            callIcon.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
                 Uri callUri;
                 if (CallerIDApplication.isUriNumber(phoneNumber)) {
                     callUri = Uri.fromParts("sip", phoneNumber, null);
                 } else {
                     callUri = Uri.fromParts("tel", phoneNumber, null);
                 }
                 startActivity(new Intent(Intent.ACTION_CALL,callUri));
			}
		});
            
           super.execute();
          }
}