forked from ndraiman/WifiPasswords
-
Notifications
You must be signed in to change notification settings - Fork 5
/
WifiEntry.java
119 lines (88 loc) · 2.67 KB
/
WifiEntry.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package com.pithsoftware.wifipasswords.pojo;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Arrays;
public class WifiEntry implements Parcelable {
public static final Parcelable.Creator<WifiEntry> CREATOR = new Parcelable.Creator<WifiEntry>() {
@Override
public WifiEntry createFromParcel(Parcel in) {
return new WifiEntry(in);
}
@Override
public WifiEntry[] newArray(int size) {
return new WifiEntry[size];
}
};
private String title;
private String password;
private String tag = "";
private boolean connectedInd = false;
public WifiEntry() {
}
public WifiEntry(String title, String password) {
initVars(title, password, false, "");
}
public WifiEntry(String title, String password, boolean connectedInd) {
initVars(title, password, connectedInd, "");
}
private void initVars(String title, String password, boolean connectedInd, String tag) {
this.title = title;
this.password = password;
this.connectedInd = connectedInd;
this.tag = tag;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPassword(boolean showAll) {
if (showAll) {
return password;
} else {
char[] fill = new char[password.length()];
Arrays.fill(fill, '*');
return new String(fill);
}
}
public void setPassword(String password) {
this.password = password;
}
public boolean getConnectedInd() {
return connectedInd;
}
public void setConnectedInd(boolean connectedInd) {
this.connectedInd = connectedInd;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
@Override
public String toString() {
return "Wifi: " + title + ", pass: " + password + ", Connected: " + connectedInd + ", tag: " + tag + "\n";
}
/************************************************************/
//Parcelable Implementation
//Parcel Constructor
protected WifiEntry(Parcel in) {
title = in.readString();
password = in.readString();
this.connectedInd = (in.readInt() == 1);
tag = in.readString();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(title);
dest.writeString(password);
dest.writeInt(connectedInd ? 1 : 0);
dest.writeString(tag);
}
}