Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f44b0ee authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Merge "Fix call grouping." into cm-10.1

parents 9aad5b39 2a150bdc
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -54,8 +54,7 @@ public class CallStatsDetails implements CallDetailHeader.Data, Parcelable {
        this.geocode = geocode;
        this.date = date;

        this.inDuration = this.outDuration = 0;
        this.incomingCount = this.outgoingCount = this.missedCount = 0;
        reset();

        if (info != null) {
            updateFromInfo(info);
@@ -167,6 +166,11 @@ public class CallStatsDetails implements CallDetailHeader.Data, Parcelable {
        this.missedCount += other.missedCount;
    }

    public void reset() {
        this.inDuration = this.outDuration = 0;
        this.incomingCount = this.outgoingCount = this.missedCount = 0;
    }

    /* Parcelable interface */

    @Override
+4 −7
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public class CallStatsQueryHandler extends AsyncQueryHandler {

        startQuery(QUERY_CALLS_TOKEN, null, Calls.CONTENT_URI, CallStatsQuery._PROJECTION,
                selection.toString(), selectionArgs.toArray(EMPTY_STRING_ARRAY),
                Calls.NUMBER + " DESC");
                Calls.NUMBER + " ASC");
    }

    @Override
@@ -194,24 +194,21 @@ public class CallStatsQueryHandler extends AsyncQueryHandler {
        final ArrayList<CallStatsDetails> callsToRemove = new ArrayList<CallStatsDetails>();
        final ArrayList<ContactInfo> infosToRemove = new ArrayList<ContactInfo>();

        // numbers in non-international format will be the first
        for (int i = 0; i < calls.size(); i++) {
            final CallStatsDetails outerItem = calls.get(i);
            final String currentFormattedNumber = outerItem.number.toString();

            if (currentFormattedNumber.startsWith("+")) {
                continue; // we don't check numbers starting with +, only removing from this point
            }

            for (int j = calls.size() - 1; j > i; j--) {
                final CallStatsDetails innerItem = calls.get(j);
                final String innerNumber = innerItem.number.toString();

                if (ContactsUtils.phoneNumbersEqual(currentFormattedNumber, innerNumber)) {
                    outerItem.mergeWith(innerItem);
                    //make sure we're not counting twice in case we're dealing with
                    //multiple different formats
                    innerItem.reset();
                    callsToRemove.add(innerItem);
                    infosToRemove.add(infos.get(j));
                    break; // we don't have multiple items with the same number, stop
                }
            }
        }