[1/4] Use new Icon class in PhoneAccount.
Bug: 21088522 Change-Id: Ia03171d4861f758701e89733f4082863587e8c11
This commit is contained in:
@@ -30314,16 +30314,12 @@ package android.telecom {
|
||||
|
||||
public final class PhoneAccount implements android.os.Parcelable {
|
||||
method public static android.telecom.PhoneAccount.Builder builder(android.telecom.PhoneAccountHandle, java.lang.CharSequence);
|
||||
method public android.graphics.drawable.Drawable createIconDrawable(android.content.Context);
|
||||
method public int describeContents();
|
||||
method public android.telecom.PhoneAccountHandle getAccountHandle();
|
||||
method public android.net.Uri getAddress();
|
||||
method public int getCapabilities();
|
||||
method public int getHighlightColor();
|
||||
method public android.graphics.Bitmap getIconBitmap();
|
||||
method public java.lang.String getIconPackageName();
|
||||
method public int getIconResId();
|
||||
method public int getIconTint();
|
||||
method public android.graphics.drawable.Icon getIcon();
|
||||
method public java.lang.CharSequence getLabel();
|
||||
method public java.lang.CharSequence getShortDescription();
|
||||
method public android.net.Uri getSubscriptionAddress();
|
||||
@@ -30339,7 +30335,6 @@ package android.telecom {
|
||||
field public static final int CAPABILITY_VIDEO_CALLING = 8; // 0x8
|
||||
field public static final android.os.Parcelable.Creator<android.telecom.PhoneAccount> CREATOR;
|
||||
field public static final int NO_HIGHLIGHT_COLOR = 0; // 0x0
|
||||
field public static final int NO_ICON_TINT = 0; // 0x0
|
||||
field public static final int NO_RESOURCE_ID = -1; // 0xffffffff
|
||||
field public static final java.lang.String SCHEME_SIP = "sip";
|
||||
field public static final java.lang.String SCHEME_TEL = "tel";
|
||||
@@ -30354,11 +30349,7 @@ package android.telecom {
|
||||
method public android.telecom.PhoneAccount.Builder setAddress(android.net.Uri);
|
||||
method public android.telecom.PhoneAccount.Builder setCapabilities(int);
|
||||
method public android.telecom.PhoneAccount.Builder setHighlightColor(int);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(android.content.Context, int);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(java.lang.String, int);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(android.content.Context, int, int);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(java.lang.String, int, int);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(android.graphics.Bitmap);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(android.graphics.drawable.Icon);
|
||||
method public android.telecom.PhoneAccount.Builder setShortDescription(java.lang.CharSequence);
|
||||
method public android.telecom.PhoneAccount.Builder setSubscriptionAddress(android.net.Uri);
|
||||
method public android.telecom.PhoneAccount.Builder setSupportedUriSchemes(java.util.List<java.lang.String>);
|
||||
|
||||
@@ -32471,16 +32471,12 @@ package android.telecom {
|
||||
|
||||
public final class PhoneAccount implements android.os.Parcelable {
|
||||
method public static android.telecom.PhoneAccount.Builder builder(android.telecom.PhoneAccountHandle, java.lang.CharSequence);
|
||||
method public android.graphics.drawable.Drawable createIconDrawable(android.content.Context);
|
||||
method public int describeContents();
|
||||
method public android.telecom.PhoneAccountHandle getAccountHandle();
|
||||
method public android.net.Uri getAddress();
|
||||
method public int getCapabilities();
|
||||
method public int getHighlightColor();
|
||||
method public android.graphics.Bitmap getIconBitmap();
|
||||
method public java.lang.String getIconPackageName();
|
||||
method public int getIconResId();
|
||||
method public int getIconTint();
|
||||
method public android.graphics.drawable.Icon getIcon();
|
||||
method public java.lang.CharSequence getLabel();
|
||||
method public java.lang.CharSequence getShortDescription();
|
||||
method public android.net.Uri getSubscriptionAddress();
|
||||
@@ -32497,7 +32493,6 @@ package android.telecom {
|
||||
field public static final int CAPABILITY_VIDEO_CALLING = 8; // 0x8
|
||||
field public static final android.os.Parcelable.Creator<android.telecom.PhoneAccount> CREATOR;
|
||||
field public static final int NO_HIGHLIGHT_COLOR = 0; // 0x0
|
||||
field public static final int NO_ICON_TINT = 0; // 0x0
|
||||
field public static final int NO_RESOURCE_ID = -1; // 0xffffffff
|
||||
field public static final java.lang.String SCHEME_SIP = "sip";
|
||||
field public static final java.lang.String SCHEME_TEL = "tel";
|
||||
@@ -32512,11 +32507,7 @@ package android.telecom {
|
||||
method public android.telecom.PhoneAccount.Builder setAddress(android.net.Uri);
|
||||
method public android.telecom.PhoneAccount.Builder setCapabilities(int);
|
||||
method public android.telecom.PhoneAccount.Builder setHighlightColor(int);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(android.content.Context, int);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(java.lang.String, int);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(android.content.Context, int, int);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(java.lang.String, int, int);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(android.graphics.Bitmap);
|
||||
method public android.telecom.PhoneAccount.Builder setIcon(android.graphics.drawable.Icon);
|
||||
method public android.telecom.PhoneAccount.Builder setShortDescription(java.lang.CharSequence);
|
||||
method public android.telecom.PhoneAccount.Builder setSubscriptionAddress(android.net.Uri);
|
||||
method public android.telecom.PhoneAccount.Builder setSupportedUriSchemes(java.util.List<java.lang.String>);
|
||||
|
||||
@@ -18,9 +18,9 @@ package android.graphics.drawable;
|
||||
|
||||
import android.annotation.DrawableRes;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
@@ -29,15 +29,16 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.IllegalArgumentException;
|
||||
import java.lang.Override;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* An umbrella container for several serializable graphics representations, including Bitmaps,
|
||||
@@ -57,6 +58,8 @@ public final class Icon implements Parcelable {
|
||||
private static final int TYPE_DATA = 3;
|
||||
private static final int TYPE_URI = 4;
|
||||
|
||||
private static final int VERSION_STREAM_SERIALIZER = 1;
|
||||
|
||||
private final int mType;
|
||||
|
||||
// To avoid adding unnecessary overhead, we have a few basic objects that get repurposed
|
||||
@@ -281,16 +284,81 @@ public final class Icon implements Parcelable {
|
||||
return loadDrawable(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a serialized version of an Icon to the specified stream.
|
||||
*
|
||||
* @param stream The stream on which to serialize the Icon.
|
||||
* @hide
|
||||
*/
|
||||
public void writeToStream(OutputStream stream) throws IOException {
|
||||
DataOutputStream dataStream = new DataOutputStream(stream);
|
||||
|
||||
dataStream.writeInt(VERSION_STREAM_SERIALIZER);
|
||||
dataStream.writeByte(mType);
|
||||
|
||||
switch (mType) {
|
||||
case TYPE_BITMAP:
|
||||
getBitmap().compress(Bitmap.CompressFormat.PNG, 100, dataStream);
|
||||
break;
|
||||
case TYPE_DATA:
|
||||
dataStream.writeInt(getDataLength());
|
||||
dataStream.write(getDataBytes(), getDataOffset(), getDataLength());
|
||||
break;
|
||||
case TYPE_RESOURCE:
|
||||
dataStream.writeUTF(getResPackage());
|
||||
dataStream.writeInt(getResId());
|
||||
break;
|
||||
case TYPE_URI:
|
||||
dataStream.writeUTF(getUriString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Icon(int mType) {
|
||||
this.mType = mType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Icon from the specified stream.
|
||||
*
|
||||
* @param stream The input stream from which to reconstruct the Icon.
|
||||
* @hide
|
||||
*/
|
||||
public static Icon createFromStream(InputStream stream) throws IOException {
|
||||
DataInputStream inputStream = new DataInputStream(stream);
|
||||
|
||||
final int version = inputStream.readInt();
|
||||
if (version >= VERSION_STREAM_SERIALIZER) {
|
||||
final int type = inputStream.readByte();
|
||||
switch (type) {
|
||||
case TYPE_BITMAP:
|
||||
return createWithBitmap(BitmapFactory.decodeStream(inputStream));
|
||||
case TYPE_DATA:
|
||||
final int length = inputStream.readInt();
|
||||
final byte[] data = new byte[length];
|
||||
inputStream.read(data, 0 /* offset */, length);
|
||||
return createWithData(data, 0 /* offset */, length);
|
||||
case TYPE_RESOURCE:
|
||||
final String packageName = inputStream.readUTF();
|
||||
final int resId = inputStream.readInt();
|
||||
return createWithResource(packageName, resId);
|
||||
case TYPE_URI:
|
||||
final String uriOrPath = inputStream.readUTF();
|
||||
return createWithContentUri(uriOrPath);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Icon pointing to a drawable resource.
|
||||
* @param res Resources for a package containing the resource in question
|
||||
* @param resId ID of the drawable resource
|
||||
*/
|
||||
public static Icon createWithResource(Resources res, @DrawableRes int resId) {
|
||||
if (res == null) {
|
||||
throw new IllegalArgumentException("Resource must not be null.");
|
||||
}
|
||||
final Icon rep = new Icon(TYPE_RESOURCE);
|
||||
rep.mObj1 = res;
|
||||
rep.mInt1 = resId;
|
||||
@@ -304,6 +372,9 @@ public final class Icon implements Parcelable {
|
||||
* @param resId ID of the drawable resource
|
||||
*/
|
||||
public static Icon createWithResource(String resPackage, @DrawableRes int resId) {
|
||||
if (resPackage == null) {
|
||||
throw new IllegalArgumentException("Resource package name must not be null.");
|
||||
}
|
||||
final Icon rep = new Icon(TYPE_RESOURCE);
|
||||
rep.mInt1 = resId;
|
||||
rep.mString1 = resPackage;
|
||||
@@ -315,6 +386,9 @@ public final class Icon implements Parcelable {
|
||||
* @param bits A valid {@link android.graphics.Bitmap} object
|
||||
*/
|
||||
public static Icon createWithBitmap(Bitmap bits) {
|
||||
if (bits == null) {
|
||||
throw new IllegalArgumentException("Bitmap must not be null.");
|
||||
}
|
||||
final Icon rep = new Icon(TYPE_BITMAP);
|
||||
rep.mObj1 = bits;
|
||||
return rep;
|
||||
@@ -329,6 +403,9 @@ public final class Icon implements Parcelable {
|
||||
* @param length Length of the bitmap data
|
||||
*/
|
||||
public static Icon createWithData(byte[] data, int offset, int length) {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data must not be null.");
|
||||
}
|
||||
final Icon rep = new Icon(TYPE_DATA);
|
||||
rep.mObj1 = data;
|
||||
rep.mInt1 = length;
|
||||
@@ -342,6 +419,9 @@ public final class Icon implements Parcelable {
|
||||
* @param uri A uri referring to local content:// or file:// image data.
|
||||
*/
|
||||
public static Icon createWithContentUri(String uri) {
|
||||
if (uri == null) {
|
||||
throw new IllegalArgumentException("Uri must not be null.");
|
||||
}
|
||||
final Icon rep = new Icon(TYPE_URI);
|
||||
rep.mString1 = uri;
|
||||
return rep;
|
||||
@@ -353,6 +433,9 @@ public final class Icon implements Parcelable {
|
||||
* @param uri A uri referring to local content:// or file:// image data.
|
||||
*/
|
||||
public static Icon createWithContentUri(Uri uri) {
|
||||
if (uri == null) {
|
||||
throw new IllegalArgumentException("Uri must not be null.");
|
||||
}
|
||||
final Icon rep = new Icon(TYPE_URI);
|
||||
rep.mString1 = uri.toString();
|
||||
return rep;
|
||||
@@ -365,6 +448,9 @@ public final class Icon implements Parcelable {
|
||||
* a type that {@link android.graphics.BitmapFactory} can decode.
|
||||
*/
|
||||
public static Icon createWithFilePath(String path) {
|
||||
if (path == null) {
|
||||
throw new IllegalArgumentException("Path must not be null.");
|
||||
}
|
||||
final Icon rep = new Icon(TYPE_URI);
|
||||
rep.mString1 = path;
|
||||
return rep;
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -127,6 +128,7 @@ public final class PhoneAccount implements Parcelable {
|
||||
|
||||
/**
|
||||
* Indicating no icon tint is set.
|
||||
* @hide
|
||||
*/
|
||||
public static final int NO_ICON_TINT = 0;
|
||||
|
||||
@@ -144,14 +146,11 @@ public final class PhoneAccount implements Parcelable {
|
||||
private final Uri mAddress;
|
||||
private final Uri mSubscriptionAddress;
|
||||
private final int mCapabilities;
|
||||
private final int mIconResId;
|
||||
private final String mIconPackageName;
|
||||
private final Bitmap mIconBitmap;
|
||||
private final int mIconTint;
|
||||
private final int mHighlightColor;
|
||||
private final CharSequence mLabel;
|
||||
private final CharSequence mShortDescription;
|
||||
private final List<String> mSupportedUriSchemes;
|
||||
private final Icon mIcon;
|
||||
|
||||
/**
|
||||
* Helper class for creating a {@link PhoneAccount}.
|
||||
@@ -161,14 +160,11 @@ public final class PhoneAccount implements Parcelable {
|
||||
private Uri mAddress;
|
||||
private Uri mSubscriptionAddress;
|
||||
private int mCapabilities;
|
||||
private int mIconResId;
|
||||
private String mIconPackageName;
|
||||
private Bitmap mIconBitmap;
|
||||
private int mIconTint = NO_ICON_TINT;
|
||||
private int mHighlightColor = NO_HIGHLIGHT_COLOR;
|
||||
private CharSequence mLabel;
|
||||
private CharSequence mShortDescription;
|
||||
private List<String> mSupportedUriSchemes = new ArrayList<String>();
|
||||
private Icon mIcon;
|
||||
|
||||
/**
|
||||
* Creates a builder with the specified {@link PhoneAccountHandle} and label.
|
||||
@@ -189,14 +185,11 @@ public final class PhoneAccount implements Parcelable {
|
||||
mAddress = phoneAccount.getAddress();
|
||||
mSubscriptionAddress = phoneAccount.getSubscriptionAddress();
|
||||
mCapabilities = phoneAccount.getCapabilities();
|
||||
mIconResId = phoneAccount.getIconResId();
|
||||
mIconPackageName = phoneAccount.getIconPackageName();
|
||||
mIconBitmap = phoneAccount.getIconBitmap();
|
||||
mIconTint = phoneAccount.getIconTint();
|
||||
mHighlightColor = phoneAccount.getHighlightColor();
|
||||
mLabel = phoneAccount.getLabel();
|
||||
mShortDescription = phoneAccount.getShortDescription();
|
||||
mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
|
||||
mIcon = phoneAccount.getIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,65 +226,12 @@ public final class PhoneAccount implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon. See {@link PhoneAccount#createIconDrawable}.
|
||||
* Sets the icon. See {@link PhoneAccount#getIcon}.
|
||||
*
|
||||
* @param packageContext The package from which to load an icon.
|
||||
* @param iconResId The resource in {@code iconPackageName} representing the icon.
|
||||
* @return The builder.
|
||||
* @param icon The icon to set.
|
||||
*/
|
||||
public Builder setIcon(Context packageContext, int iconResId) {
|
||||
return setIcon(packageContext.getPackageName(), iconResId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon. See {@link PhoneAccount#createIconDrawable}.
|
||||
*
|
||||
* @param iconPackageName The package from which to load an icon.
|
||||
* @param iconResId The resource in {@code iconPackageName} representing the icon.
|
||||
* @return The builder.
|
||||
*/
|
||||
public Builder setIcon(String iconPackageName, int iconResId) {
|
||||
return setIcon(iconPackageName, iconResId, NO_ICON_TINT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon. See {@link PhoneAccount#createIconDrawable}.
|
||||
*
|
||||
* @param packageContext The package from which to load an icon.
|
||||
* @param iconResId The resource in {@code iconPackageName} representing the icon.
|
||||
* @param iconTint A color with which to tint this icon.
|
||||
* @return The builder.
|
||||
*/
|
||||
public Builder setIcon(Context packageContext, int iconResId, int iconTint) {
|
||||
return setIcon(packageContext.getPackageName(), iconResId, iconTint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon. See {@link PhoneAccount#createIconDrawable}.
|
||||
*
|
||||
* @param iconPackageName The package from which to load an icon.
|
||||
* @param iconResId The resource in {@code iconPackageName} representing the icon.
|
||||
* @param iconTint A color with which to tint this icon.
|
||||
* @return The builder.
|
||||
*/
|
||||
public Builder setIcon(String iconPackageName, int iconResId, int iconTint) {
|
||||
this.mIconPackageName = iconPackageName;
|
||||
this.mIconResId = iconResId;
|
||||
this.mIconTint = iconTint;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon. See {@link PhoneAccount#createIconDrawable}.
|
||||
*
|
||||
* @param iconBitmap The icon bitmap.
|
||||
* @return The builder.
|
||||
*/
|
||||
public Builder setIcon(Bitmap iconBitmap) {
|
||||
this.mIconBitmap = iconBitmap;
|
||||
this.mIconPackageName = null;
|
||||
this.mIconResId = NO_RESOURCE_ID;
|
||||
this.mIconTint = NO_ICON_TINT;
|
||||
public Builder setIcon(Icon icon) {
|
||||
mIcon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -363,10 +303,7 @@ public final class PhoneAccount implements Parcelable {
|
||||
mAddress,
|
||||
mSubscriptionAddress,
|
||||
mCapabilities,
|
||||
mIconResId,
|
||||
mIconPackageName,
|
||||
mIconBitmap,
|
||||
mIconTint,
|
||||
mIcon,
|
||||
mHighlightColor,
|
||||
mLabel,
|
||||
mShortDescription,
|
||||
@@ -379,10 +316,7 @@ public final class PhoneAccount implements Parcelable {
|
||||
Uri address,
|
||||
Uri subscriptionAddress,
|
||||
int capabilities,
|
||||
int iconResId,
|
||||
String iconPackageName,
|
||||
Bitmap iconBitmap,
|
||||
int iconTint,
|
||||
Icon icon,
|
||||
int highlightColor,
|
||||
CharSequence label,
|
||||
CharSequence shortDescription,
|
||||
@@ -391,10 +325,7 @@ public final class PhoneAccount implements Parcelable {
|
||||
mAddress = address;
|
||||
mSubscriptionAddress = subscriptionAddress;
|
||||
mCapabilities = capabilities;
|
||||
mIconResId = iconResId;
|
||||
mIconPackageName = iconPackageName;
|
||||
mIconBitmap = iconBitmap;
|
||||
mIconTint = iconTint;
|
||||
mIcon = icon;
|
||||
mHighlightColor = highlightColor;
|
||||
mLabel = label;
|
||||
mShortDescription = shortDescription;
|
||||
@@ -496,6 +427,15 @@ public final class PhoneAccount implements Parcelable {
|
||||
return mSupportedUriSchemes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The icon to represent this {@code PhoneAccount}.
|
||||
*
|
||||
* @return The icon.
|
||||
*/
|
||||
public Icon getIcon() {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the {@link PhoneAccount} supports calls to/from addresses with a specified URI
|
||||
* scheme.
|
||||
@@ -517,59 +457,6 @@ public final class PhoneAccount implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The icon resource ID for the icon of this {@code PhoneAccount}.
|
||||
* <p>
|
||||
* Creators of a {@code PhoneAccount} who possess the icon in static resources should prefer
|
||||
* this method of indicating the icon rather than using {@link #getIconBitmap()}, since it
|
||||
* leads to less resource usage.
|
||||
* <p>
|
||||
* Clients wishing to display a {@code PhoneAccount} should use {@link #createIconDrawable(Context)}.
|
||||
*
|
||||
* @return A resource ID.
|
||||
*/
|
||||
public int getIconResId() {
|
||||
return mIconResId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The package name from which to load the icon of this {@code PhoneAccount}.
|
||||
* <p>
|
||||
* If this property is {@code null}, the resource {@link #getIconResId()} will be loaded from
|
||||
* the package in the {@link ComponentName} of the {@link #getAccountHandle()}.
|
||||
* <p>
|
||||
* Clients wishing to display a {@code PhoneAccount} should use {@link #createIconDrawable(Context)}.
|
||||
*
|
||||
* @return A package name.
|
||||
*/
|
||||
public String getIconPackageName() {
|
||||
return mIconPackageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* A tint to apply to the icon of this {@code PhoneAccount}.
|
||||
*
|
||||
* @return A hexadecimal color value.
|
||||
*/
|
||||
public int getIconTint() {
|
||||
return mIconTint;
|
||||
}
|
||||
|
||||
/**
|
||||
* A literal icon bitmap to represent this {@code PhoneAccount} in a user interface.
|
||||
* <p>
|
||||
* If this property is specified, it is to be considered the preferred icon. Otherwise, the
|
||||
* resource specified by {@link #getIconResId()} should be used.
|
||||
* <p>
|
||||
* Clients wishing to display a {@code PhoneAccount} should use
|
||||
* {@link #createIconDrawable(Context)}.
|
||||
*
|
||||
* @return A bitmap.
|
||||
*/
|
||||
public Bitmap getIconBitmap() {
|
||||
return mIconBitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* A highlight color to use in displaying information about this {@code PhoneAccount}.
|
||||
*
|
||||
@@ -579,41 +466,6 @@ public final class PhoneAccount implements Parcelable {
|
||||
return mHighlightColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and returns an icon {@code Drawable} to represent this {@code PhoneAccount} in a user
|
||||
* interface. Uses the properties {@link #getIconResId()}, {@link #getIconPackageName()}, and
|
||||
* {@link #getIconBitmap()} as necessary.
|
||||
*
|
||||
* @param context A {@code Context} to use for loading {@code Drawable}s.
|
||||
*
|
||||
* @return An icon for this {@code PhoneAccount}.
|
||||
*/
|
||||
public Drawable createIconDrawable(Context context) {
|
||||
if (mIconBitmap != null) {
|
||||
return new BitmapDrawable(context.getResources(), mIconBitmap);
|
||||
}
|
||||
|
||||
if (mIconResId != 0) {
|
||||
try {
|
||||
Context packageContext = context.createPackageContext(mIconPackageName, 0);
|
||||
try {
|
||||
Drawable iconDrawable = packageContext.getDrawable(mIconResId);
|
||||
if (mIconTint != NO_ICON_TINT) {
|
||||
iconDrawable.setTint(mIconTint);
|
||||
}
|
||||
return iconDrawable;
|
||||
} catch (NotFoundException | MissingResourceException e) {
|
||||
Log.e(this, e, "Cannot find icon %d in package %s",
|
||||
mIconResId, mIconPackageName);
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.w(this, "Cannot find package %s", mIconPackageName);
|
||||
}
|
||||
}
|
||||
|
||||
return new ColorDrawable(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
//
|
||||
// Parcelable implementation
|
||||
//
|
||||
@@ -644,19 +496,16 @@ public final class PhoneAccount implements Parcelable {
|
||||
mSubscriptionAddress.writeToParcel(out, flags);
|
||||
}
|
||||
out.writeInt(mCapabilities);
|
||||
out.writeInt(mIconResId);
|
||||
out.writeString(mIconPackageName);
|
||||
if (mIconBitmap == null) {
|
||||
out.writeInt(0);
|
||||
} else {
|
||||
out.writeInt(1);
|
||||
mIconBitmap.writeToParcel(out, flags);
|
||||
}
|
||||
out.writeInt(mIconTint);
|
||||
out.writeInt(mHighlightColor);
|
||||
out.writeCharSequence(mLabel);
|
||||
out.writeCharSequence(mShortDescription);
|
||||
out.writeStringList(mSupportedUriSchemes);
|
||||
if (mIcon == null) {
|
||||
out.writeInt(0);
|
||||
} else {
|
||||
out.writeInt(1);
|
||||
mIcon.writeToParcel(out, flags);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<PhoneAccount> CREATOR
|
||||
@@ -689,18 +538,15 @@ public final class PhoneAccount implements Parcelable {
|
||||
mSubscriptionAddress = null;
|
||||
}
|
||||
mCapabilities = in.readInt();
|
||||
mIconResId = in.readInt();
|
||||
mIconPackageName = in.readString();
|
||||
if (in.readInt() > 0) {
|
||||
mIconBitmap = Bitmap.CREATOR.createFromParcel(in);
|
||||
} else {
|
||||
mIconBitmap = null;
|
||||
}
|
||||
mIconTint = in.readInt();
|
||||
mHighlightColor = in.readInt();
|
||||
mLabel = in.readCharSequence();
|
||||
mShortDescription = in.readCharSequence();
|
||||
mSupportedUriSchemes = Collections.unmodifiableList(in.createStringArrayList());
|
||||
if (in.readInt() > 0) {
|
||||
mIcon = Icon.CREATOR.createFromParcel(in);
|
||||
} else {
|
||||
mIcon = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user