StatusBarIcon.java revision 6179ea3196e9306d3f14361fe9ef14191b1edba6
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.statusbar;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22public class StatusBarIcon implements Parcelable {
23    public String iconPackage;
24    public int iconId;
25    public int iconLevel;
26    public boolean visible = true;
27    public int number;
28    public CharSequence contentDescription;
29
30    public StatusBarIcon(String iconPackage, int iconId, int iconLevel, int number,
31            CharSequence contentDescription) {
32        this.iconPackage = iconPackage;
33        this.iconId = iconId;
34        this.iconLevel = iconLevel;
35        this.number = number;
36        this.contentDescription = contentDescription;
37    }
38
39    @Override
40    public String toString() {
41        return "StatusBarIcon(pkg=" + this.iconPackage + " id=0x" + Integer.toHexString(this.iconId)
42                + " level=" + this.iconLevel + " visible=" + visible
43                + " num=" + this.number + " )";
44    }
45
46    @Override
47    public StatusBarIcon clone() {
48        StatusBarIcon that = new StatusBarIcon(this.iconPackage, this.iconId, this.iconLevel,
49                this.number, this.contentDescription);
50        that.visible = this.visible;
51        return that;
52    }
53
54    /**
55     * Unflatten the StatusBarIcon from a parcel.
56     */
57    public StatusBarIcon(Parcel in) {
58        readFromParcel(in);
59    }
60
61    public void readFromParcel(Parcel in) {
62        this.iconPackage = in.readString();
63        this.iconId = in.readInt();
64        this.iconLevel = in.readInt();
65        this.visible = in.readInt() != 0;
66        this.number = in.readInt();
67        this.contentDescription = in.readCharSequence();
68    }
69
70    public void writeToParcel(Parcel out, int flags) {
71        out.writeString(this.iconPackage);
72        out.writeInt(this.iconId);
73        out.writeInt(this.iconLevel);
74        out.writeInt(this.visible ? 1 : 0);
75        out.writeInt(this.number);
76        out.writeCharSequence(this.contentDescription);
77    }
78
79    public int describeContents() {
80        return 0;
81    }
82
83    /**
84     * Parcelable.Creator that instantiates StatusBarIcon objects
85     */
86    public static final Parcelable.Creator<StatusBarIcon> CREATOR
87            = new Parcelable.Creator<StatusBarIcon>()
88    {
89        public StatusBarIcon createFromParcel(Parcel parcel)
90        {
91            return new StatusBarIcon(parcel);
92        }
93
94        public StatusBarIcon[] newArray(int size)
95        {
96            return new StatusBarIcon[size];
97        }
98    };
99}
100
101