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

Commit 242040e8 authored by Flavio Lerda's avatar Flavio Lerda Committed by Android (Google) Code Review
Browse files

Merge "Extract nested classes from CallLogFragment."

parents 5a340628 568ad27e
Loading
Loading
Loading
Loading
+687 −0

File added.

Preview size limit exceeded, changes collapsed.

+1 −788

File changed.

Preview size limit exceeded, changes collapsed.

+2 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.contacts.calllog;

import com.android.common.widget.GroupingListAdapter;
import com.android.contacts.calllog.CallLogFragment.CallLogQuery;

import android.database.CharArrayBuffer;
import android.database.Cursor;
@@ -74,7 +73,7 @@ public class CallLogGroupBuilder {
            final boolean sameNumber = equalPhoneNumbers(firstNumber, currentNumber);
            final boolean shouldGroup;

            if (CallLogFragment.CallLogQuery.isSectionHeader(cursor)) {
            if (CallLogQuery.isSectionHeader(cursor)) {
                // Cannot group headers.
                shouldGroup = false;
            } else if (!sameNumber) {
@@ -120,7 +119,7 @@ public class CallLogGroupBuilder {
     * <p>
     * The group is always unexpanded.
     *
     * @see CallLogFragment.CallLogAdapter#addGroup(int, int, boolean)
     * @see CallLogAdapter#addGroup(int, int, boolean)
     */
    private void addGroup(int cursorPosition, int size) {
        mGroupCreator.addGroup(cursorPosition, size, false);
+85 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.contacts.calllog;

import android.database.Cursor;
import android.provider.CallLog.Calls;

/**
 * The query for the call log table.
 */
public final class CallLogQuery {
    // If you alter this, you must also alter the method that inserts a fake row to the headers
    // in the CallLogQueryHandler class called createHeaderCursorFor().
    public static final String[] _PROJECTION = new String[] {
            Calls._ID,
            Calls.NUMBER,
            Calls.DATE,
            Calls.DURATION,
            Calls.TYPE,
            Calls.COUNTRY_ISO,
            Calls.VOICEMAIL_URI,
            Calls.GEOCODED_LOCATION,
    };

    public static final int ID = 0;
    public static final int NUMBER = 1;
    public static final int DATE = 2;
    public static final int DURATION = 3;
    public static final int CALL_TYPE = 4;
    public static final int COUNTRY_ISO = 5;
    public static final int VOICEMAIL_URI = 6;
    public static final int GEOCODED_LOCATION = 7;

    /**
     * The name of the synthetic "section" column.
     * <p>
     * This column identifies whether a row is a header or an actual item, and whether it is
     * part of the new or old calls.
     */
    public static final String SECTION_NAME = "section";
    /** The index of the "section" column in the projection. */
    public static final int SECTION = 8;
    /** The value of the "section" column for the header of the new section. */
    public static final int SECTION_NEW_HEADER = 0;
    /** The value of the "section" column for the items of the new section. */
    public static final int SECTION_NEW_ITEM = 1;
    /** The value of the "section" column for the header of the old section. */
    public static final int SECTION_OLD_HEADER = 2;
    /** The value of the "section" column for the items of the old section. */
    public static final int SECTION_OLD_ITEM = 3;

    /** The call log projection including the section name. */
    public static final String[] EXTENDED_PROJECTION;
    static {
        EXTENDED_PROJECTION = new String[_PROJECTION.length + 1];
        System.arraycopy(_PROJECTION, 0, EXTENDED_PROJECTION, 0, _PROJECTION.length);
        EXTENDED_PROJECTION[_PROJECTION.length] = SECTION_NAME;
    }

    public static boolean isSectionHeader(Cursor cursor) {
        int section = cursor.getInt(CallLogQuery.SECTION);
        return section == CallLogQuery.SECTION_NEW_HEADER
                || section == CallLogQuery.SECTION_OLD_HEADER;
    }

    public static boolean isNewSection(Cursor cursor) {
        int section = cursor.getInt(CallLogQuery.SECTION);
        return section == CallLogQuery.SECTION_NEW_ITEM
                || section == CallLogQuery.SECTION_NEW_HEADER;
    }
}
 No newline at end of file
+1 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.contacts.calllog;

import com.android.common.io.MoreCloseables;
import com.android.contacts.calllog.CallLogFragment.CallLogQuery;
import com.android.contacts.voicemail.VoicemailStatusHelperImpl;

import android.content.AsyncQueryHandler;
@@ -104,7 +103,7 @@ import javax.annotation.concurrent.GuardedBy;
    /** Creates a cursor that contains a single row and maps the section to the given value. */
    private Cursor createHeaderCursorFor(int section) {
        MatrixCursor matrixCursor =
                new MatrixCursor(CallLogFragment.CallLogQuery.EXTENDED_PROJECTION);
                new MatrixCursor(CallLogQuery.EXTENDED_PROJECTION);
        // The values in this row correspond to default values for _PROJECTION from CallLogQuery
        // plus the section value.
        matrixCursor.addRow(new Object[]{ -1L, "", 0L, 0L, 0, "", "", "", section });
Loading