Starting
Create a gesture password to view the Creategestureactivity.java file.
Login verification gesture Password can look Gestureloginactivity.java file.
Features
Using the Jakewharton/butterknife Butterknife
Use Acache to store gesture passwords
/**
* Save gesture Password
*
/private void Savechosenpattern (list<lockpatternview.cell> cells)
{
byte[ ] bytes = Lockpatternutil.patterntohash (cells);
Acache.put (Constant.gesture_password, bytes);
}
Warning: saving passwords using the Acache class is not indefinite. The specific term can be viewed Acache class.
Using the SHA algorithm to save gesture passwords
/**
* Generate a SHA-1 hash for the pattern.
* Not the most secure, but it are at
* least a second level of protection. The ' file is ' in a
* location only readable by the system process.*
* @param pattern
* @retu RN The hash of the pattern in a byte array.
*/public
static byte[] Patterntohash (list<lockpatternview.cell> pattern)
{
if (pattern = = null) { C11/>return null;
} else {
int size = Pattern.size ();
byte[] res = new Byte[size];
for (int i = 0; i < size; i++) {
Lockpatternview.cell Cell = Pattern.get (i);
Res[i] = (byte) cell.getindex ();
}
MessageDigest MD = NULL;
try {
MD = messagedigest.getinstance ("SHA-1");
Return Md.digest (res);
catch (NoSuchAlgorithmException e) {
e.printstacktrace ();
return res;
}
}
can open the vibration mode, the election of a circle when the hands of the opportunity to vibrate
/** * Set Whether the view would use tactile feedback.
*if true, there would be
* Tactile feedback as the user enters the pattern.
* @param tactilefeedbackenabled Whether Tactile feedback is enabled
/public void settactilefeedbackenabled ( Boolean tactilefeedbackenabled) {
menablehapticfeedback = tactilefeedbackenabled;
}
You can turn on drawing path hiding mode
/**
* Set Whether the view is in stealth mode. If true, there'll is no
* visible feedback as the user enters the pattern.
* @param instealthmode Whether in stealth mode.
*/public void Setinstealthmode (Boolean instealthmode) {
minstealthmode = Instealthmode;
}
Example
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.