| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.internal.statusbar; |
| 18 |
|
| 19 |
import android.graphics.drawable.Icon; |
| 20 |
import android.os.Parcel; |
| 21 |
import android.os.Parcelable; |
| 22 |
import android.os.UserHandle; |
| 23 |
import android.text.TextUtils; |
| 24 |
|
| 25 |
public class StatusBarIcon implements Parcelable { |
| 26 |
public UserHandle user; |
| 27 |
public String pkg; |
| 28 |
public Icon icon; |
| 29 |
public int iconLevel; |
| 30 |
public boolean visible = true; |
| 31 |
public int number; |
| 32 |
public CharSequence contentDescription; |
| 33 |
|
| 34 |
public StatusBarIcon(UserHandle user, String resPackage, Icon icon, int iconLevel, int number, |
| 35 |
CharSequence contentDescription) { |
| 36 |
if (icon.getType() == Icon.TYPE_RESOURCE |
| 37 |
&& TextUtils.isEmpty(icon.getResPackage())) { |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
icon = Icon.createWithResource(resPackage, icon.getResId()); |
| 42 |
} |
| 43 |
this.pkg = resPackage; |
| 44 |
this.user = user; |
| 45 |
this.icon = icon; |
| 46 |
this.iconLevel = iconLevel; |
| 47 |
this.number = number; |
| 48 |
this.contentDescription = contentDescription; |
| 49 |
} |
| 50 |
|
| 51 |
public StatusBarIcon(String iconPackage, UserHandle user, |
| 52 |
int iconId, int iconLevel, int number, |
| 53 |
CharSequence contentDescription) { |
| 54 |
this(user, iconPackage, Icon.createWithResource(iconPackage, iconId), |
| 55 |
iconLevel, number, contentDescription); |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
public String toString() { |
| 60 |
return "StatusBarIcon(icon=" + icon |
| 61 |
+ ((iconLevel != 0)?(" level=" + iconLevel):"") |
| 62 |
+ (visible?" visible":"") |
| 63 |
+ " user=" + user.getIdentifier() |
| 64 |
+ ((number != 0)?(" num=" + number):"") |
| 65 |
+ " )"; |
| 66 |
} |
| 67 |
|
| 68 |
@Override |
| 69 |
public StatusBarIcon clone() { |
| 70 |
StatusBarIcon that = new StatusBarIcon(this.user, this.pkg, this.icon, |
| 71 |
this.iconLevel, this.number, this.contentDescription); |
| 72 |
that.visible = this.visible; |
| 73 |
return that; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
public StatusBarIcon(Parcel in) { |
| 80 |
readFromParcel(in); |
| 81 |
} |
| 82 |
|
| 83 |
public void readFromParcel(Parcel in) { |
| 84 |
this.icon = (Icon) in.readParcelable(null, android.graphics.drawable.Icon.class); |
| 85 |
this.pkg = in.readString(); |
| 86 |
this.user = (UserHandle) in.readParcelable(null, android.os.UserHandle.class); |
| 87 |
this.iconLevel = in.readInt(); |
| 88 |
this.visible = in.readInt() != 0; |
| 89 |
this.number = in.readInt(); |
| 90 |
this.contentDescription = in.readCharSequence(); |
| 91 |
} |
| 92 |
|
| 93 |
public void writeToParcel(Parcel out, int flags) { |
| 94 |
out.writeParcelable(this.icon, 0); |
| 95 |
out.writeString(this.pkg); |
| 96 |
out.writeParcelable(this.user, 0); |
| 97 |
out.writeInt(this.iconLevel); |
| 98 |
out.writeInt(this.visible ? 1 : 0); |
| 99 |
out.writeInt(this.number); |
| 100 |
out.writeCharSequence(this.contentDescription); |
| 101 |
} |
| 102 |
|
| 103 |
public int describeContents() { |
| 104 |
return 0; |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
public static final Parcelable.Creator<StatusBarIcon> CREATOR |
| 111 |
= new Parcelable.Creator<StatusBarIcon>() |
| 112 |
{ |
| 113 |
public StatusBarIcon createFromParcel(Parcel parcel) |
| 114 |
{ |
| 115 |
return new StatusBarIcon(parcel); |
| 116 |
} |
| 117 |
|
| 118 |
public StatusBarIcon[] newArray(int size) |
| 119 |
{ |
| 120 |
return new StatusBarIcon[size]; |
| 121 |
} |
| 122 |
}; |
| 123 |
} |
| 124 |
|