Android仿支付寶手勢(shì)密碼解鎖功能
Starting
創(chuàng)建手勢(shì)密碼可以查看 CreateGestureActivity.java 文件.
登陸驗(yàn)證手勢(shì)密碼可以看 GestureLoginActivity.java 文件.
Features
使用了 JakeWharton/butterknife butterknife
使用了 ACache 來存儲(chǔ)手勢(shì)密碼
/**
* 保存手勢(shì)密碼
*/
private void saveChosenPattern(List<LockPatternView.Cell> cells)
{
byte[] bytes = LockPatternUtil.patternToHash(cells);
aCache.put(Constant.GESTURE_PASSWORD, bytes);
}
Warning: 使用 ACache 類保存密碼并不是無限期的. 具體期限可以查看 ACache 類.
使用了 SHA 算法保存手勢(shì)密碼
/**
* Generate an SHA-1 hash for the pattern.
* Not the most secure, but it is at
* least a second level of protection. First level is that the file is in a
* location only readable by the system process.*
* @param pattern
* @return the hash of the pattern in a byte array.
*/
public static byte[] patternToHash(List<LockPatternView.Cell> pattern)
{
if (pattern == null) {
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;
}
}
}
可以開啟震動(dòng)模式,當(dāng)選中一個(gè)圈的時(shí)候,手機(jī)會(huì)震動(dòng)
/** * Set whether the view will use tactile feedback.
*If true, there will be
* tactile feedback as the user enters the pattern.
* @param tactileFeedbackEnabled Whether tactile feedback is enabled
*/
public void setTactileFeedbackEnabled(boolean tactileFeedbackEnabled) {
mEnableHapticFeedback = tactileFeedbackEnabled;
}
可以開啟繪制路徑隱藏模式
/**
* Set whether the view is in stealth mode. If true, there will be no
* visible feedback as the user enters the pattern.
* @param inStealthMode Whether in stealth mode.
*/public void setInStealthMode(boolean inStealthMode) {
mInStealthMode = inStealthMode;
}
Example

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Android添加ButterKnife時(shí)報(bào)錯(cuò)Error:(2, 0) Cannot add extension wit
今天小編就為大家分享一篇關(guān)于Android添加ButterKnife時(shí)報(bào)錯(cuò)Error:(2, 0) Cannot add extension with name 'android'的解決辦法,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2018-12-12
TabLayout+ViewPager2的簡(jiǎn)單使用詳解
這篇文章主要為大家詳細(xì)介紹了TabLayout+ViewPager2的簡(jiǎn)單使用,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-09-09
Android使用ftp方式實(shí)現(xiàn)文件上傳和下載功能
這篇文章主要介紹了Android使用ftp方式實(shí)現(xiàn)文件上傳和下載功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-06
關(guān)于android studio通過命令行運(yùn)行g(shù)radle編譯命令的問題
這篇文章主要介紹了關(guān)于android studio通過命令行運(yùn)行g(shù)radle編譯命令的問題,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-11-11
詳解Android項(xiàng)目多服務(wù)端接口適配(超簡(jiǎn)單)
這篇文章主要介紹了Android項(xiàng)目多服務(wù)端接口適配(超簡(jiǎn)單),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08
Android入門之使用eclipse進(jìn)行源碼開發(fā)的方法
這篇文章主要介紹了Android入門之使用eclipse進(jìn)行源碼開發(fā)的方法,較為詳細(xì)的分析了使用eclipse進(jìn)行Android源碼開發(fā)的具體步驟與相關(guān)注意事項(xiàng),需要的朋友可以參考下2016-02-02
Android開發(fā)中通過手機(jī)號(hào)+短信驗(yàn)證碼登錄的實(shí)例代碼
最近在開發(fā)一個(gè)android的項(xiàng)目,需要通過獲取手機(jī)驗(yàn)證碼來完成登錄功能,接下來通過實(shí)例代碼給大家分享手機(jī)號(hào)+短信驗(yàn)證碼登錄的實(shí)現(xiàn)方法,需要的的朋友參考下吧2017-05-05
Android 模擬器(JAVA)與C++ socket 通訊 分享
Android 模擬器(JAVA)與C++ socket 通訊 分享,需要的朋友可以參考一下2013-05-05
Android中使用GridView實(shí)現(xiàn)仿微信圖片上傳功能(附源代碼)
由于工作要求最近在使用GridView完成圖片的批量上傳功能,我的例子當(dāng)中包含仿微信圖片上傳、拍照、本地選擇、相片裁剪等功能,如果有需要的朋友可以看一下2017-08-08

