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