10cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato/*
20cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Copyright (C) 2010 The Android Open Source Project
30cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato *
40cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Licensed under the Apache License, Version 2.0 (the "License");
50cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * you may not use this file except in compliance with the License.
60cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * You may obtain a copy of the License at
70cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato *
80cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato *      http://www.apache.org/licenses/LICENSE-2.0
90cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato *
100cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Unless required by applicable law or agreed to in writing, software
110cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * distributed under the License is distributed on an "AS IS" BASIS,
120cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * See the License for the specific language governing permissions and
140cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * limitations under the License.
150cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato */
160cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
170cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratopackage com.android.internal.statusbar;
180cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
190cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport android.os.Parcel;
200cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport android.os.Parcelable;
210cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
220cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratopublic class StatusBarIcon implements Parcelable {
230cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public String iconPackage;
240cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public int iconId;
250cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public int iconLevel;
26514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato    public boolean visible = true;
2718e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato    public int number;
286179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov    public CharSequence contentDescription;
290cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
306179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov    public StatusBarIcon(String iconPackage, int iconId, int iconLevel, int number,
316179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov            CharSequence contentDescription) {
320e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato        this.iconPackage = iconPackage;
330e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato        this.iconId = iconId;
340e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato        this.iconLevel = iconLevel;
350e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato        this.number = number;
366179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov        this.contentDescription = contentDescription;
370e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato    }
380e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato
396179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov    @Override
40514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato    public String toString() {
41514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato        return "StatusBarIcon(pkg=" + this.iconPackage + " id=0x" + Integer.toHexString(this.iconId)
4218e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato                + " level=" + this.iconLevel + " visible=" + visible
4318e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato                + " num=" + this.number + " )";
44514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato    }
45514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato
466179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov    @Override
470cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public StatusBarIcon clone() {
486179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov        StatusBarIcon that = new StatusBarIcon(this.iconPackage, this.iconId, this.iconLevel,
496179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov                this.number, this.contentDescription);
50514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato        that.visible = this.visible;
51514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato        return that;
520cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
530cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
540cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    /**
550cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato     * Unflatten the StatusBarIcon from a parcel.
560cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato     */
570cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public StatusBarIcon(Parcel in) {
580cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        readFromParcel(in);
590cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
600cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
610cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public void readFromParcel(Parcel in) {
620cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        this.iconPackage = in.readString();
630cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        this.iconId = in.readInt();
640cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        this.iconLevel = in.readInt();
65514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato        this.visible = in.readInt() != 0;
6618e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato        this.number = in.readInt();
676179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov        this.contentDescription = in.readCharSequence();
680cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
690cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
700cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public void writeToParcel(Parcel out, int flags) {
710cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        out.writeString(this.iconPackage);
720cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        out.writeInt(this.iconId);
730cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        out.writeInt(this.iconLevel);
74e345fff2f80947b0a821f6674c197a02b7bff08eJoe Onorato        out.writeInt(this.visible ? 1 : 0);
7518e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato        out.writeInt(this.number);
766179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov        out.writeCharSequence(this.contentDescription);
770cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
780cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
790cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public int describeContents() {
800cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        return 0;
810cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    }
820cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
830cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    /**
840cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato     * Parcelable.Creator that instantiates StatusBarIcon objects
850cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato     */
860cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    public static final Parcelable.Creator<StatusBarIcon> CREATOR
870cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            = new Parcelable.Creator<StatusBarIcon>()
880cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    {
890cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        public StatusBarIcon createFromParcel(Parcel parcel)
900cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        {
910cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            return new StatusBarIcon(parcel);
920cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        }
930cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
940cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        public StatusBarIcon[] newArray(int size)
950cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        {
960cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato            return new StatusBarIcon[size];
970cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato        }
980cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato    };
990cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato}
1000cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato
101