Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need working solution to use Android Pattern Lock Screen in custom Application (and not source code redirects)

Tags:

java

android

I'd like to use the Android Lock Screen Pattern in my custom application while opening the app. I've searched a lot, but everyone asks to use the LockScreenUtils.java class from the source code. I'm having a tough time doing this.

One post on stackoverflow asks to make custom 3x3 matrix with a button on each cell and listen for the selection pattern, but then that doesn't look artistically good :)

Any thoughts or suggestions on how do I implement this?

Thanks!!!

like image 617
Anwaarullah Avatar asked May 22 '12 11:05

Anwaarullah


2 Answers

After struggling with those custom buttons, spending time digging out the LockPattern Source from the AOSP, I stumbled upon this awesome library which solved my problem. Hope it helps you out as well.

Android Lock Pattern Library

like image 166
Anwaarullah Avatar answered Nov 15 '22 17:11

Anwaarullah


Doing it manually, you could just have a single View, and manually draw some nice graphics at the 9 points you want. Then just listen for any MotionEvent; if it's within a 'button zone' that hasn't been touched before, mark it as pushed (and change the graphics) and add a pretty line joining it to the last touched 'button' to the stuff to draw.

So all you need is:

  • A View with some simple customized rendering code and nice 'on'/'off' graphics for the buttons.
  • A list of 'button zones', with coordinates and 'on'/'off' states.
  • A list of the buttons pushed so far, used to store the pattern entered and to draw lines for the sequence so far.

This should be easier to improve the appearance of than buttons in a table.

like image 30
not all wrong Avatar answered Nov 15 '22 16:11

not all wrong