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

Commit 9b8a7ae9 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by android-build-merger
Browse files

Merge "Refactor s/TypeInfo/MimeTypeInfo/ per feedback." into qt-dev

am: 19111433

Change-Id: I3deac2026d67797436d782820ac1649b0756e545
parents f6b59e32 19111433
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -9515,7 +9515,7 @@ package android.content {
    method public static android.content.SyncAdapterType[] getSyncAdapterTypes();
    method public static boolean getSyncAutomatically(android.accounts.Account, String);
    method @Nullable public final String getType(@NonNull android.net.Uri);
    method @NonNull public final android.content.ContentResolver.TypeInfo getTypeInfo(@NonNull String);
    method @NonNull public final android.content.ContentResolver.MimeTypeInfo getTypeInfo(@NonNull String);
    method @Nullable public final android.net.Uri insert(@RequiresPermission.Write @NonNull android.net.Uri, @Nullable android.content.ContentValues);
    method public static boolean isSyncActive(android.accounts.Account, String);
    method public static boolean isSyncPending(android.accounts.Account, String);
@@ -9595,7 +9595,7 @@ package android.content {
    field public static final int SYNC_OBSERVER_TYPE_SETTINGS = 1; // 0x1
  }
  public static final class ContentResolver.TypeInfo {
  public static final class ContentResolver.MimeTypeInfo {
    method @NonNull public CharSequence getContentDescription();
    method @NonNull public android.graphics.drawable.Icon getIcon();
    method @NonNull public CharSequence getLabel();
+3 −3
Original line number Diff line number Diff line
@@ -3398,7 +3398,7 @@ public abstract class ContentResolver implements ContentInterface {
     *
     * @param mimeType Valid, concrete MIME type.
     */
    public final @NonNull TypeInfo getTypeInfo(@NonNull String mimeType) {
    public final @NonNull MimeTypeInfo getTypeInfo(@NonNull String mimeType) {
        Objects.requireNonNull(mimeType);
        return MimeIconUtils.getTypeInfo(mimeType);
    }
@@ -3407,13 +3407,13 @@ public abstract class ContentResolver implements ContentInterface {
     * Detailed description of a specific MIME type, including an icon and label
     * that describe the type.
     */
    public static final class TypeInfo {
    public static final class MimeTypeInfo {
        private final Icon mIcon;
        private final CharSequence mLabel;
        private final CharSequence mContentDescription;

        /** {@hide} */
        public TypeInfo(@NonNull Icon icon, @NonNull CharSequence label,
        public MimeTypeInfo(@NonNull Icon icon, @NonNull CharSequence label,
                @NonNull CharSequence contentDescription) {
            mIcon = Objects.requireNonNull(icon);
            mLabel = Objects.requireNonNull(label);
+8 −8
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package com.android.internal.util;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ContentResolver.TypeInfo;
import android.content.ContentResolver.MimeTypeInfo;
import android.content.res.Resources;
import android.graphics.drawable.Icon;
import android.text.TextUtils;
@@ -34,9 +34,9 @@ import java.util.Objects;

public class MimeIconUtils {
    @GuardedBy("sCache")
    private static final ArrayMap<String, TypeInfo> sCache = new ArrayMap<>();
    private static final ArrayMap<String, MimeTypeInfo> sCache = new ArrayMap<>();

    private static TypeInfo buildTypeInfo(String mimeType, int iconId,
    private static MimeTypeInfo buildTypeInfo(String mimeType, int iconId,
            int labelId, int extLabelId) {
        final Resources res = Resources.getSystem();

@@ -49,10 +49,10 @@ public class MimeIconUtils {
            label = res.getString(labelId);
        }

        return new TypeInfo(Icon.createWithResource(res, iconId), label, label);
        return new MimeTypeInfo(Icon.createWithResource(res, iconId), label, label);
    }

    private static @Nullable TypeInfo buildTypeInfo(@NonNull String mimeType) {
    private static @Nullable MimeTypeInfo buildTypeInfo(@NonNull String mimeType) {
        switch (mimeType) {
            case "inode/directory":
            case "vnd.android.document/directory":
@@ -222,7 +222,7 @@ public class MimeIconUtils {
        }
    }

    private static @Nullable TypeInfo buildGenericTypeInfo(@NonNull String mimeType) {
    private static @Nullable MimeTypeInfo buildGenericTypeInfo(@NonNull String mimeType) {
        // Look for partial matches
        if (mimeType.startsWith("audio/")) {
            return buildTypeInfo(mimeType, R.drawable.ic_doc_audio,
@@ -252,12 +252,12 @@ public class MimeIconUtils {
                R.string.mime_type_generic, R.string.mime_type_generic_ext);
    }

    public static @NonNull TypeInfo getTypeInfo(@NonNull String mimeType) {
    public static @NonNull MimeTypeInfo getTypeInfo(@NonNull String mimeType) {
        // Normalize MIME type
        mimeType = mimeType.toLowerCase(Locale.US);

        synchronized (sCache) {
            TypeInfo res = sCache.get(mimeType);
            MimeTypeInfo res = sCache.get(mimeType);
            if (res == null) {
                res = buildTypeInfo(mimeType);
                sCache.put(mimeType, res);