Android gesture Password Lockpatternview, lockpasswordutils, lockpatternutils
In the use of someone else to write this gesture password, we usually have their own needs, there may be a lot of code here is also very complex, there are many comments, the whole code to understand is to spend a lot of time and the basis is very good, may not be in the project time to study, below I listed some key places, Easy to modify code.
1. creategesturepasswordactivity When creating a gesture password
Here are some changes to the interface when the gesture password is set, and some things to deal with
Switch (muistage) {case introduction://just entered the time //Retry time Mlockpatternview.clearpattern (); Break;case helpscreen:// Just went in when Mlockpatternview.setpattern (Displaymode.animate, Manimatepattern); Break;case choicetooshort:// Set short release Mlockpatternview.setdisplaymode (Displaymode.wrong);p ostclearpatternrunnable (); Break;case FirstChoiceValid ://Set to release Break;case needtoconfirm://click Continue Mlockpatternview.clearpattern (); Updatepreviewviews (); break;case confirmwrong://the second and first time Mlockpatternview.setdisplaymode (Displaymode.wrong);p ostclearpatternrunnable (); Case choiceconfirmed://the second and first time break;}
2. Set the default, correct and wrong display picture of gesture password in Lockpatternview, in fact thatThe size of the circle varies according to the size of your picture .
Note: The size of the three images here is the same
The default picture of the draw gesture Mbitmapcircledefault = Getbitmapfor (R.DRAWABLE.GESTURE_PATTERN_ITEM_BG); picture gesture correct image mbitmapcirclegreen = Getbitmapfor (r.drawable.gesture_pattern_selected); picture gesture Error mbitmapcirclered = Getbitmapfor (R.drawable.gesture_ Pattern_selected_wrong);
3. Set the gesture password in Lockpatternview the color of the connector is red and yellow
Here's the color you might want to change the color of multiple places
Set Yellow Mpathpaint.setcolor (color.red), set red Mpathpaint.setcolor (Color.yellow);
4. Determine if there is a gesture password
if (App.getinstance (). Getlockpatternutils (). Savedpatternexists ()) {///If this is true there is a gesture password, false is no gesture password}
5. Clear gesture Password re-create
6. Gesture password at the top of the recording area, where the small circle can be set here size and spacing, here is the more troublesome area, you need to be very carefully set.
Note: Here the background cut must be done well, to the artist to mark you size and spacing,
<linearlayoutandroid:id= "@+id/gesturepwd_setting_preview" android:layout_width= "40.0dip" Android:layout_ height= "40.0dip" android:layout_gravity= "Center_horizontal" android:background= "@drawable/GESTURE_CREATE_GRID_BG "Android:orientation=" vertical "android:padding=" 5.0dip "> <linearlayout android:layout_width=" fill_parent " android:layout_height= "6.0dip" > <view android:id= "@+id/gesturepwd_setting_preview_0" Android:layout_width= "6.0dip" android:layout_height= "6.0dip" android:background= "@drawable/tr Ans "/> <view android:id=" @+id/gesturepwd_setting_preview_1 "android:layout_width=" 6.0d IP "android:layout_height=" 6.0dip "android:layout_marginleft=" 6.0dip "android:background= "@drawable/trans"/> <view android:id= "@+id/gesturepwd_setting_preview_2" android:layou T_width= "6.0dip" android:layout_height= "6.0dip "android:layout_marginleft=" 6.0dip "android:background=" @drawable/trans "/> </linearla yout> <linearlayout android:layout_width= "fill_parent" android:layout_height= "6.0dip" Androi d:layout_margintop= "6.0dip" > <view android:id= "@+id/gesturepwd_setting_preview_3" Android Oid:layout_width= "6.0dip" android:layout_height= "6.0dip" android:background= "@drawable/trans"/> <view android:id= "@+id/gesturepwd_setting_preview_4" android:layout_width= "6.0dip" android:layout_height= "6.0dip" android:layout_marginleft= "6.0dip" android:background= "@drawable/ Trans "/> <view android:id=" @+id/gesturepwd_setting_preview_5 "android:layout_width=" 6. 0dip "android:layout_height=" 6.0dip "android:layout_marginleft=" 6.0dip "Android:backgroun d= "@drawable/trans"/> </LinearLayout> <linearlayout android:layout_width= "fill_parent" android:layout_height= "6.0dip" android:layout_margintop= "6.0dip" > <view android:id= "@+id/gesturepwd_setting_preview_6" Android:layout_width= "6.0dip" android:layout_height= "6.0dip" android:background= "@drawable/ Trans "/> <view android:id=" @+id/gesturepwd_setting_preview_7 "android:layout_width=" 6. 0dip "android:layout_height=" 6.0dip "android:layout_marginleft=" 6.0dip "Android:backgroun d= "@drawable/trans"/> <view android:id= "@+id/gesturepwd_setting_preview_8" Android:lay Out_width= "6.0dip" android:layout_height= "6.0dip" android:layout_marginleft= "6.0dip" Android oid:background= "@drawable/trans"/> </LinearLayout></LinearLayout>
7.
As for the bottom button, hint text, background color, etc. are easy to solve
Accumulate some, even if you do not understand the code here, you can also do your gesture password.
SOURCE Download: http://download.csdn.net/detail/pcaxb/8747015
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android gesture Password Lockpatternview, lockpasswordutils, lockpatternutils and other analysis