Android Imitation payment treasure gesture password unlock function _android

Source: Internet
Author: User
Tags int size

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.