Merge "Refactor s/TypeInfo/MimeTypeInfo/ per feedback." into qt-dev
am: 191114330a
Change-Id: I3deac2026d67797436d782820ac1649b0756e545
This commit is contained in:
@@ -9515,7 +9515,7 @@ package android.content {
|
|||||||
method public static android.content.SyncAdapterType[] getSyncAdapterTypes();
|
method public static android.content.SyncAdapterType[] getSyncAdapterTypes();
|
||||||
method public static boolean getSyncAutomatically(android.accounts.Account, String);
|
method public static boolean getSyncAutomatically(android.accounts.Account, String);
|
||||||
method @Nullable public final String getType(@NonNull android.net.Uri);
|
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 @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 isSyncActive(android.accounts.Account, String);
|
||||||
method public static boolean isSyncPending(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
|
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 CharSequence getContentDescription();
|
||||||
method @NonNull public android.graphics.drawable.Icon getIcon();
|
method @NonNull public android.graphics.drawable.Icon getIcon();
|
||||||
method @NonNull public CharSequence getLabel();
|
method @NonNull public CharSequence getLabel();
|
||||||
|
|||||||
@@ -3398,7 +3398,7 @@ public abstract class ContentResolver implements ContentInterface {
|
|||||||
*
|
*
|
||||||
* @param mimeType Valid, concrete MIME type.
|
* @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);
|
Objects.requireNonNull(mimeType);
|
||||||
return MimeIconUtils.getTypeInfo(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
|
* Detailed description of a specific MIME type, including an icon and label
|
||||||
* that describe the type.
|
* that describe the type.
|
||||||
*/
|
*/
|
||||||
public static final class TypeInfo {
|
public static final class MimeTypeInfo {
|
||||||
private final Icon mIcon;
|
private final Icon mIcon;
|
||||||
private final CharSequence mLabel;
|
private final CharSequence mLabel;
|
||||||
private final CharSequence mContentDescription;
|
private final CharSequence mContentDescription;
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
public TypeInfo(@NonNull Icon icon, @NonNull CharSequence label,
|
public MimeTypeInfo(@NonNull Icon icon, @NonNull CharSequence label,
|
||||||
@NonNull CharSequence contentDescription) {
|
@NonNull CharSequence contentDescription) {
|
||||||
mIcon = Objects.requireNonNull(icon);
|
mIcon = Objects.requireNonNull(icon);
|
||||||
mLabel = Objects.requireNonNull(label);
|
mLabel = Objects.requireNonNull(label);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package com.android.internal.util;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.ContentResolver.TypeInfo;
|
import android.content.ContentResolver.MimeTypeInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -34,9 +34,9 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class MimeIconUtils {
|
public class MimeIconUtils {
|
||||||
@GuardedBy("sCache")
|
@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) {
|
int labelId, int extLabelId) {
|
||||||
final Resources res = Resources.getSystem();
|
final Resources res = Resources.getSystem();
|
||||||
|
|
||||||
@@ -49,10 +49,10 @@ public class MimeIconUtils {
|
|||||||
label = res.getString(labelId);
|
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) {
|
switch (mimeType) {
|
||||||
case "inode/directory":
|
case "inode/directory":
|
||||||
case "vnd.android.document/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
|
// Look for partial matches
|
||||||
if (mimeType.startsWith("audio/")) {
|
if (mimeType.startsWith("audio/")) {
|
||||||
return buildTypeInfo(mimeType, R.drawable.ic_doc_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);
|
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
|
// Normalize MIME type
|
||||||
mimeType = mimeType.toLowerCase(Locale.US);
|
mimeType = mimeType.toLowerCase(Locale.US);
|
||||||
|
|
||||||
synchronized (sCache) {
|
synchronized (sCache) {
|
||||||
TypeInfo res = sCache.get(mimeType);
|
MimeTypeInfo res = sCache.get(mimeType);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
res = buildTypeInfo(mimeType);
|
res = buildTypeInfo(mimeType);
|
||||||
sCache.put(mimeType, res);
|
sCache.put(mimeType, res);
|
||||||
|
|||||||
Reference in New Issue
Block a user