Android仿支付寶手勢(shì)密碼解鎖功能
Starting
創(chuàng)建手勢(shì)密碼可以查看 CreateGestureActivity.java 文件.
登陸驗(yàn)證手勢(shì)密碼可以看 GestureLoginActivity.java 文件.
Features
使用了 JakeWharton/butterknife butterknife
使用了 ACache 來(lái)存儲(chǔ)手勢(shì)密碼
/**
* 保存手勢(shì)密碼
*/
private void saveChosenPattern(List<LockPatternView.Cell> cells)
{
byte[] bytes = LockPatternUtil.patternToHash(cells);
aCache.put(Constant.GESTURE_PASSWORD, bytes);
}
Warning: 使用 ACache 類(lèi)保存密碼并不是無(wú)限期的. 具體期限可以查看 ACache 類(lèi).
使用了 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;
}
}
}
可以開(kāi)啟震動(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;
}
可以開(kāi)啟繪制路徑隱藏模式
/**
* 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控件之AnalogClock與DigitalClock用法實(shí)例分析
這篇文章主要介紹了Android控件之AnalogClock與DigitalClock用法,以實(shí)例形式分析了Android時(shí)鐘控件AnalogClock和DigitalClock用于顯示時(shí)間的具體使用技巧,需要的朋友可以參考下2015-09-09
Android使用setCustomTitle()方法自定義對(duì)話框標(biāo)題
Android有自帶的對(duì)話框標(biāo)題,但是不太美觀,如果要給彈出的對(duì)話框設(shè)置一個(gè)自定義的標(biāo)題,使用AlertDialog.Builder的setCustomTitle()方法非常方便,接下來(lái)通過(guò)本文給大家介紹Android使用setCustomTitle()方法自定義對(duì)話框標(biāo)題,感興趣的朋友一起學(xué)習(xí)吧2016-02-02
Android購(gòu)物車(chē)項(xiàng)目快速開(kāi)發(fā)
這篇文章主要為大家詳細(xì)介紹了Android購(gòu)物車(chē)項(xiàng)目快速開(kāi)發(fā),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01
Android中VideoView音視頻開(kāi)發(fā)的實(shí)現(xiàn)
VideoView是一個(gè)用于播放視頻的視圖組件,可以方便地在應(yīng)用程序中播放本地或網(wǎng)絡(luò)上的視頻文件,本文主要介紹了Android中VideoView音視頻開(kāi)發(fā)的實(shí)現(xiàn),具有一定的 參考價(jià)值,感興趣的可以了解一下2025-03-03
關(guān)于Android bitmap你不知道的一些事
這篇文章主要為大家詳細(xì)介紹了關(guān)于Android bitmap你不知道的一些事,使用bitmap需要注意的一些細(xì)節(jié),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11
Android基于ListView實(shí)現(xiàn)類(lèi)似Market分頁(yè)加載效果示例
這篇文章主要介紹了Android基于ListView實(shí)現(xiàn)類(lèi)似Market分頁(yè)加載效果,結(jié)合完整實(shí)例形式分析了ListView的OnScroll方法來(lái)實(shí)現(xiàn)分頁(yè)與滾動(dòng)加載的操作步驟與相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-10-10
Android實(shí)現(xiàn)獲取聯(lián)系人電話號(hào)碼功能
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)獲取聯(lián)系人電話號(hào)碼功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03

