|
@@ -1,9 +1,18 @@
|
|
|
package de.tudarmstadt.informatik.hostage.model;
|
|
|
|
|
|
+import android.content.Context;
|
|
|
+import android.content.SharedPreferences;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.BitmapFactory;
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Parcel;
|
|
|
+import android.os.Parcelable;
|
|
|
+
|
|
|
+import java.io.Serializable;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
|
|
|
|
|
@@ -11,12 +20,12 @@ import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
|
|
|
* @author Alexander Brakowski
|
|
|
* @created 14.01.14 18:04
|
|
|
*/
|
|
|
-public class Profile {
|
|
|
+public class Profile implements Serializable {
|
|
|
public String mText;
|
|
|
public String mLabel;
|
|
|
public int mId;
|
|
|
public boolean mActivated;
|
|
|
- public Bitmap mIcon;
|
|
|
+ transient public Bitmap mIcon;
|
|
|
public int mIconId;
|
|
|
public String mIconName;
|
|
|
|
|
@@ -25,6 +34,8 @@ public class Profile {
|
|
|
public boolean mIsBackVisible = false;
|
|
|
public boolean mEditable = false;
|
|
|
|
|
|
+ public HashMap<String, Boolean> mActiveProtocols = new HashMap<String, Boolean>();
|
|
|
+
|
|
|
public Profile(){
|
|
|
this.mEditable = true;
|
|
|
this.mActivated = false;
|
|
@@ -55,6 +66,18 @@ public class Profile {
|
|
|
this.mEditable = editable;
|
|
|
}
|
|
|
|
|
|
+ public Profile(Parcel in) {
|
|
|
+ mText = in.readString();
|
|
|
+ mLabel = in.readString();
|
|
|
+ mId = in.readInt();
|
|
|
+ mActivated = in.readInt() == 1;
|
|
|
+ mIconId = in.readInt();
|
|
|
+ mIconName = in.readString();
|
|
|
+ mIconPath = in.readString();
|
|
|
+ mEditable = in.readInt() == 1;
|
|
|
+ mActiveProtocols = (HashMap<String,Boolean>) in.readSerializable();
|
|
|
+ }
|
|
|
+
|
|
|
public void setIcon(Bitmap bitmap){
|
|
|
this.mIcon = bitmap;
|
|
|
}
|
|
@@ -90,8 +113,13 @@ public class Profile {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public boolean isProtocolActive(String protocol){
|
|
|
+ if(!mActiveProtocols.containsKey(protocol)) return false;
|
|
|
+ return mActiveProtocols.get(protocol);
|
|
|
+ }
|
|
|
+
|
|
|
public Drawable getIconDrawable(){
|
|
|
- return new BitmapDrawable(getIconBitmap());
|
|
|
+ return new BitmapDrawable(MainActivity.context.getResources(), getIconBitmap());
|
|
|
}
|
|
|
|
|
|
public boolean isEditable(){
|
|
@@ -101,4 +129,46 @@ public class Profile {
|
|
|
public Profile cloneProfile(){
|
|
|
return new Profile(mId, mLabel, mText, mIcon, mEditable);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Describe the kinds of special objects contained in this Parcelable's
|
|
|
+ * marshalled representation.
|
|
|
+ *
|
|
|
+ * @return a bitmask indicating the set of special object types marshalled
|
|
|
+ * by the Parcelable.
|
|
|
+ */
|
|
|
+ //@Override
|
|
|
+ public int describeContents() {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Flatten this object in to a Parcel.
|
|
|
+ *
|
|
|
+ * @param dest The Parcel in which the object should be written.
|
|
|
+ * @param flags Additional flags about how the object should be written.
|
|
|
+ * May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
|
|
|
+ */
|
|
|
+ //@Override
|
|
|
+ public void writeToParcel(Parcel dest, int flags) {
|
|
|
+ dest.writeString(this.mText);
|
|
|
+ dest.writeString(this.mLabel);
|
|
|
+ dest.writeInt(this.mId);
|
|
|
+ dest.writeInt(this.mActivated ? 1 : 0);
|
|
|
+ dest.writeInt(this.mIconId);
|
|
|
+ dest.writeString(this.mIconName);
|
|
|
+ dest.writeString(this.mIconPath);
|
|
|
+ dest.writeInt(this.mEditable ? 1 : 0);
|
|
|
+ dest.writeSerializable(mActiveProtocols);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
|
|
|
+ public Profile createFromParcel(Parcel in) {
|
|
|
+ return new Profile(in);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Profile[] newArray(int size) {
|
|
|
+ return new Profile[size];
|
|
|
+ }
|
|
|
+ };
|
|
|
}
|