• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.server.status;
2 
3 import android.util.Log;
4 
5 public class IconData {
6     /**
7      * Indicates ths item represents a piece of text.
8      */
9     public static final int TEXT = 1;
10 
11     /**
12      * Indicates ths item represents an icon.
13      */
14     public static final int ICON = 2;
15 
16     /**
17      * The type of this item. One of TEXT, ICON, or LEVEL_ICON.
18      */
19     public int type;
20 
21     /**
22      * The slot that this icon will be in if it is not a notification
23      */
24     public String slot;
25 
26     /**
27      * The package containting the icon to draw for this item. Valid if this is
28      * an ICON type.
29      */
30     public String iconPackage;
31 
32     /**
33      * The icon to draw for this item. Valid if this is an ICON type.
34      */
35     public int iconId;
36 
37     /**
38      * The level associated with the icon. Valid if this is a LEVEL_ICON type.
39      */
40     public int iconLevel;
41 
42     /**
43      * The "count" number.
44      */
45     public int number;
46 
47     /**
48      * The text associated with the icon. Valid if this is a TEXT type.
49      */
50     public CharSequence text;
51 
IconData()52     private IconData() {
53     }
54 
makeIcon(String slot, String iconPackage, int iconId, int iconLevel, int number)55     public static IconData makeIcon(String slot,
56             String iconPackage, int iconId, int iconLevel, int number) {
57         IconData data = new IconData();
58         data.type = ICON;
59         data.slot = slot;
60         data.iconPackage = iconPackage;
61         data.iconId = iconId;
62         data.iconLevel = iconLevel;
63         data.number = number;
64         return data;
65     }
66 
makeText(String slot, CharSequence text)67     public static IconData makeText(String slot, CharSequence text) {
68         IconData data = new IconData();
69         data.type = TEXT;
70         data.slot = slot;
71         data.text = text;
72         return data;
73     }
74 
copyFrom(IconData that)75     public void copyFrom(IconData that) {
76         this.type = that.type;
77         this.slot = that.slot;
78         this.iconPackage = that.iconPackage;
79         this.iconId = that.iconId;
80         this.iconLevel = that.iconLevel;
81         this.number = that.number;
82         this.text = that.text; // should we clone this?
83     }
84 
clone()85     public IconData clone() {
86         IconData that = new IconData();
87         that.copyFrom(this);
88         return that;
89     }
90 
toString()91     public String toString() {
92         if (this.type == TEXT) {
93             return "IconData(slot=" + (this.slot != null ? "'" + this.slot + "'" : "null")
94                     + " text='" + this.text + "')";
95         }
96         else if (this.type == ICON) {
97             return "IconData(slot=" + (this.slot != null ? "'" + this.slot + "'" : "null")
98                     + " package=" + this.iconPackage
99                     + " iconId=" + Integer.toHexString(this.iconId)
100                     + " iconLevel=" + this.iconLevel + ")";
101         }
102         else {
103             return "IconData(type=" + type + ")";
104         }
105     }
106 }
107