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
22/**
23 * @hide
24 */
25public class StatusBarIcon implements Parcelable {
26    public String iconPackage;
27    public int iconId;
28    public int iconLevel;
29    public boolean visible = true;
30    public int number;
31
32    private StatusBarIcon() {
33    }
34
35    public StatusBarIcon(String iconPackage, int iconId, int iconLevel) {
36        this.iconPackage = iconPackage;
37        this.iconId = iconId;
38        this.iconLevel = iconLevel;
39    }
40
41    public StatusBarIcon(String iconPackage, int iconId, int iconLevel, int number) {
42        this.iconPackage = iconPackage;
43        this.iconId = iconId;
44        this.iconLevel = iconLevel;
45        this.number = number;
46    }
47
48    public String toString() {
49        return "StatusBarIcon(pkg=" + this.iconPackage + " id=0x" + Integer.toHexString(this.iconId)
50                + " level=" + this.iconLevel + " visible=" + visible
51                + " num=" + this.number + " )";
52    }
53
54    public StatusBarIcon clone() {
55        StatusBarIcon that = new StatusBarIcon(this.iconPackage, this.iconId, this.iconLevel);
56        that.visible = this.visible;
57        that.number = this.number;
58        return that;
59    }
60
61    /**
62     * Unflatten the StatusBarIcon from a parcel.
63     */
64    public StatusBarIcon(Parcel in) {
65        readFromParcel(in);
66    }
67
68    public void readFromParcel(Parcel in) {
69        this.iconPackage = in.readString();
70        this.iconId = in.readInt();
71        this.iconLevel = in.readInt();
72        this.visible = in.readInt() != 0;
73        this.number = in.readInt();
74    }
75
76    public void writeToParcel(Parcel out, int flags) {
77        out.writeString(this.iconPackage);
78        out.writeInt(this.iconId);
79        out.writeInt(this.iconLevel);
80        out.writeInt(this.visible ? 1 : 0);
81        out.writeInt(this.number);
82    }
83
84    public int describeContents() {
85        return 0;
86    }
87
88    /**
89     * Parcelable.Creator that instantiates StatusBarIcon objects
90     */
91    public static final Parcelable.Creator<StatusBarIcon> CREATOR
92            = new Parcelable.Creator<StatusBarIcon>()
93    {
94        public StatusBarIcon createFromParcel(Parcel parcel)
95        {
96            return new StatusBarIcon(parcel);
97        }
98
99        public StatusBarIcon[] newArray(int size)
100        {
101            return new StatusBarIcon[size];
102        }
103    };
104}
105
106