summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIhab Awad <ihab@google.com>2015-05-13 23:26:04 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-13 23:26:05 +0000
commit24145d451b823920022a643a73dafa8675e5a8a8 (patch)
treec4e05c89095aa3c5430754e360b5df41a98d83c9
parentfe112e7b388fe582a4e57c26fdf651511b0bbb5a (diff)
parenta7684ed63820fd5d486da7b0ae16cdbafa883dc1 (diff)
downloadframeworks_base-24145d451b823920022a643a73dafa8675e5a8a8.zip
frameworks_base-24145d451b823920022a643a73dafa8675e5a8a8.tar.gz
frameworks_base-24145d451b823920022a643a73dafa8675e5a8a8.tar.bz2
Merge "Refactor StatusHints (1/3)" into mnc-dev
-rw-r--r--api/current.txt6
-rw-r--r--api/system-current.txt10
-rw-r--r--telecomm/java/android/telecom/StatusHints.java73
3 files changed, 46 insertions, 43 deletions
diff --git a/api/current.txt b/api/current.txt
index 82a6c00..8d5d226 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -30453,13 +30453,11 @@ package android.telecom {
}
public final class StatusHints implements android.os.Parcelable {
- ctor public StatusHints(android.content.ComponentName, java.lang.CharSequence, int, android.os.Bundle);
+ ctor public StatusHints(java.lang.CharSequence, android.graphics.drawable.Icon, android.os.Bundle);
method public int describeContents();
method public android.os.Bundle getExtras();
- method public android.graphics.drawable.Drawable getIcon(android.content.Context);
- method public int getIconResId();
+ method public android.graphics.drawable.Icon getIcon();
method public java.lang.CharSequence getLabel();
- method public android.content.ComponentName getPackageName();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.telecom.StatusHints> CREATOR;
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 5b5099b..0de71e3 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -32611,13 +32611,15 @@ package android.telecom {
}
public final class StatusHints implements android.os.Parcelable {
- ctor public StatusHints(android.content.ComponentName, java.lang.CharSequence, int, android.os.Bundle);
+ ctor public deprecated StatusHints(android.content.ComponentName, java.lang.CharSequence, int, android.os.Bundle);
+ ctor public StatusHints(java.lang.CharSequence, android.graphics.drawable.Icon, android.os.Bundle);
method public int describeContents();
method public android.os.Bundle getExtras();
- method public android.graphics.drawable.Drawable getIcon(android.content.Context);
- method public int getIconResId();
+ method public deprecated android.graphics.drawable.Drawable getIcon(android.content.Context);
+ method public android.graphics.drawable.Icon getIcon();
+ method public deprecated int getIconResId();
method public java.lang.CharSequence getLabel();
- method public android.content.ComponentName getPackageName();
+ method public deprecated android.content.ComponentName getPackageName();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.telecom.StatusHints> CREATOR;
}
diff --git a/telecomm/java/android/telecom/StatusHints.java b/telecomm/java/android/telecom/StatusHints.java
index a32eae7..99c8d7f 100644
--- a/telecomm/java/android/telecom/StatusHints.java
+++ b/telecomm/java/android/telecom/StatusHints.java
@@ -16,15 +16,15 @@
package android.telecom;
+import android.annotation.SystemApi;
import android.content.ComponentName;
import android.content.Context;
-import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
-import java.util.MissingResourceException;
import java.util.Objects;
/**
@@ -32,24 +32,34 @@ import java.util.Objects;
*/
public final class StatusHints implements Parcelable {
- private final ComponentName mPackageName;
private final CharSequence mLabel;
- private final int mIconResId;
+ private final Icon mIcon;
private final Bundle mExtras;
+ /**
+ * @hide
+ */
+ @SystemApi @Deprecated
public StatusHints(ComponentName packageName, CharSequence label, int iconResId,
Bundle extras) {
- mPackageName = packageName;
+ this(label, Icon.createWithResource(packageName.getPackageName(), iconResId), extras);
+ }
+
+ public StatusHints(CharSequence label, Icon icon, Bundle extras) {
mLabel = label;
- mIconResId = iconResId;
+ mIcon = icon;
mExtras = extras;
}
/**
* @return A package used to load the icon.
+ *
+ * @hide
*/
+ @SystemApi @Deprecated
public ComponentName getPackageName() {
- return mPackageName;
+ // Minimal compatibility shim for legacy apps' tests
+ return new ComponentName("", "");
}
/**
@@ -63,16 +73,30 @@ public final class StatusHints implements Parcelable {
* The icon resource ID for the icon to show.
*
* @return A resource ID.
+ *
+ * @hide
*/
+ @SystemApi @Deprecated
public int getIconResId() {
- return mIconResId;
+ // Minimal compatibility shim for legacy apps' tests
+ return 0;
}
/**
* @return An icon displayed in the in-call UI.
+ *
+ * @hide
*/
+ @SystemApi @Deprecated
public Drawable getIcon(Context context) {
- return getIcon(context, mIconResId);
+ return mIcon.loadDrawable(context);
+ }
+
+ /**
+ * @return An icon depicting the status.
+ */
+ public Icon getIcon() {
+ return mIcon;
}
/**
@@ -89,9 +113,8 @@ public final class StatusHints implements Parcelable {
@Override
public void writeToParcel(Parcel out, int flags) {
- out.writeParcelable(mPackageName, flags);
out.writeCharSequence(mLabel);
- out.writeInt(mIconResId);
+ out.writeParcelable(mIcon, 0);
out.writeParcelable(mExtras, 0);
}
@@ -107,36 +130,17 @@ public final class StatusHints implements Parcelable {
};
private StatusHints(Parcel in) {
- mPackageName = in.readParcelable(getClass().getClassLoader());
mLabel = in.readCharSequence();
- mIconResId = in.readInt();
+ mIcon = in.readParcelable(getClass().getClassLoader());
mExtras = in.readParcelable(getClass().getClassLoader());
}
- private Drawable getIcon(Context context, int resId) {
- Context packageContext;
- try {
- packageContext = context.createPackageContext(mPackageName.getPackageName(), 0);
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(this, e, "Cannot find package %s", mPackageName.getPackageName());
- return null;
- }
- try {
- return packageContext.getDrawable(resId);
- } catch (MissingResourceException e) {
- Log.e(this, e, "Cannot find icon %d in package %s",
- resId, mPackageName.getPackageName());
- return null;
- }
- }
-
@Override
public boolean equals(Object other) {
if (other != null && other instanceof StatusHints) {
StatusHints otherHints = (StatusHints) other;
- return Objects.equals(otherHints.getPackageName(), getPackageName()) &&
- Objects.equals(otherHints.getLabel(), getLabel()) &&
- otherHints.getIconResId() == getIconResId() &&
+ return Objects.equals(otherHints.getLabel(), getLabel()) &&
+ Objects.equals(otherHints.getIcon(), getIcon()) &&
Objects.equals(otherHints.getExtras(), getExtras());
}
return false;
@@ -144,7 +148,6 @@ public final class StatusHints implements Parcelable {
@Override
public int hashCode() {
- return Objects.hashCode(mPackageName) + Objects.hashCode(mLabel) + mIconResId +
- Objects.hashCode(mExtras);
+ return Objects.hashCode(mLabel) + Objects.hashCode(mIcon) + Objects.hashCode(mExtras);
}
}