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

Commit 6fa570f2 authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Avoid using prioritized mimetype on pre-M SDKs

Bug: 25629359
Change-Id: Id6f960fc5d39e3d3d1133d812ca273aaa48d312d
parent 2bef0a83
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 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.common.compat;

import android.os.Build;

import com.android.contacts.common.compat.SdkVersionOverride;

public final class CompatUtils {
    /**
     * PrioritizedMimeType is added in API level 23.
     */
    public static boolean hasPrioritizedMimeType() {
        return SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M)
                >= Build.VERSION_CODES.M;
    }
}
+7 −4
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.widget.TextView;
import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
import com.android.contacts.common.R;
import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.util.SearchUtil;

import java.util.HashSet;
@@ -723,10 +724,12 @@ public abstract class ContactEntryListAdapter extends IndexerListAdapter {
        QuickContactBadge quickContact = view.getQuickContact();
        quickContact.assignContactUri(
                getContactUri(partitionIndex, cursor, contactIdColumn, lookUpKeyColumn));
        if (CompatUtils.hasPrioritizedMimeType()) {
            // The Contacts app never uses the QuickContactBadge. Therefore, it is safe to assume
            // that only Dialer will use this QuickContact badge. This means prioritizing the phone
            // mimetype here is reasonable.
            quickContact.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE);
        }

        if (photoId != 0 || photoUriColumn == -1) {
            getPhotoLoader().loadThumbnail(quickContact, photoId, mDarkTheme, mCircularPhotos,