B4A Library [Class] Simple Unlock Pattern

Lib: GestureDetector V1.1 is needed. Thanks to Informatix.
http://www.b4x.com/forum/additional-libraries-classes-official-updates/21502-lib-gesture-detector.html#post124392

Last path can be cancel by back tracking (like backspace)
if NoOfPoint < 10
Last path can be cancel by choosing the starting point of the last path again
The first point can be cancelled by "flicking" if it is the only point selected.
if NoOfPoint = 10 -> NoOfButton = 0
As soon as the finger is off the screen, Ok button is automatically executed.

Optional title and buttons.
Property:
NoOfPoint - default 5
NoOfButton - default no button (0)
Title - default no title ("")
TextSize - default 15
 

Attachments

  • Unlock Pattern.png
    Unlock Pattern.png
    11.8 KB · Views: 391
  • Simple Unlock Pattern Class v 1.0.zip
    8.8 KB · Views: 377
Last edited:

aaronk

Well-Known Member
Licensed User
Longtime User
Thanks heaps for this.. been waiting a while for this!

I have been able to change it so it is full screen which is great but how can I make it so as soon as they take there finger off the screen, it automatically press the ok button?

Basically I want to remove the OK button and allow them to only press dot while there finger is down on the screen (and require them to slide there finger), soon as they lift there finger off the screen then it should check if the pattern is correct (run the code in the OK button).

Any ideas?
 

drachmad

Member
Licensed User
Longtime User
Hi aaronk, thanks for testing it and your suggestion.
Try the attach file, I have not fully test it.
Set the NoOfPoint = 10, the button will automatically remove (NoOfButton = 0)
After you test it maybe I want to make it the formal release (v 1.0)
 

Attachments

  • UnlockPattern.zip
    8.7 KB · Views: 277

aaronk

Well-Known Member
Licensed User
Longtime User
Hi drachmad,

That works better now.

Anther idea would be to use the Designer to create your own custom Pattern screens so you can customize the round dots etc.

Other than that it looks good.
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi drachmad,

it 's more useful for me,let me bring for using(I 've converted to be clsunlockpattern.jar andclsunlockpattern.xml). Thank you for making this.
 

drachmad

Member
Licensed User
Longtime User
Hi Aaronk and Theera, thanks again for testing.
For @aaronk, I am apologize, I am only a newbie so I can not fullfill your request.
And for @Theera, I just want to make it a class and not a library so that other b4a members can have more benefit by modifying it or learning the logic behind it. And may be the experts can correct it if it is not right. I learn a lot by looking at the classes made by the experts.
 
Last edited:

drachmad

Member
Licensed User
Longtime User
No more feedback, I make it official release (V 1.0)
It is not much difference with attachment posted in #3

Compare with V 0.3
As soon as the finger is off the screen, Ok button is automatically executed.
Auto documentation of the property.
Renaming the property to be more consistent.
Using two layer for drawing.
Bug solved:
First point can not be reselected just after deleting.
 

Mahares

Expert
Licensed User
Longtime User
Attached is a project using drachmad class, where I use a pattern as a substitute for a password:
1. The program creates for the first time in rootexternal a file to store your pattern.
2. In subsequent runs, you are given 3 chances (number can be changed) to draw the correct saved pattern to enter the program. If after 3 tries the entered pattern does not match the saved one, you are not allowed to enter the program and open the activity.
3. I hope it is of some help in illustrating the unlock process. If you can improve upon it, which I am certain you can, please post your revised project.
Thank you
 

Attachments

  • UnlockPatternDrachmadMahares.zip
    10.9 KB · Views: 281

aeropic

Active Member
Licensed User
Longtime User
Hi,

I'm trying to use this nice class but I get a " java.lang.String cannot be cast to java.lang.Boolean" exception as soon as I put the finger on the screen.
I'm afraid it comes from the gesture detector librairy which is now in release 2.2 ?

My phone is a samsung S3 android 4.3

Any idea ?

Alain


Installing file.
PackageAdded: package:b4a.UnlockPattern
** Activity (main) Resume **
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.UnlockPattern
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
at flm.b4a.gesturedetector.GestureDetectorForB4A$1.onTouch(GestureDetectorForB4A.java:111)
at android.view.View.dispatchTouchEvent(View.java:7812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2435)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2326)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1612)
at android.app.Activity.dispatchTouchEvent(Activity.java:2494)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2274)
at android.view.View.dispatchPointerEvent(View.java:8025)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4668)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4556)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4207)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4176)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4261)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4184)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4318)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4207)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4176)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4184)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6302)
 

Lyndon Bermoy

Active Member
Licensed User
Longtime User
Hi,

I'm trying to use this nice class but I get a " java.lang.String cannot be cast to java.lang.Boolean" exception as soon as I put the finger on the screen.
I'm afraid it comes from the gesture detector librairy which is now in release 2.2 ?

My phone is a samsung S3 android 4.3

Any idea ?

Alain


Installing file.
PackageAdded: package:b4a.UnlockPattern
** Activity (main) Resume **
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.UnlockPattern
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
at flm.b4a.gesturedetector.GestureDetectorForB4A$1.onTouch(GestureDetectorForB4A.java:111)
at android.view.View.dispatchTouchEvent(View.java:7812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2435)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2326)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1612)
at android.app.Activity.dispatchTouchEvent(Activity.java:2494)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2274)
at android.view.View.dispatchPointerEvent(View.java:8025)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4668)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4556)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4207)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4176)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4261)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4184)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4318)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4207)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4176)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4184)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6302)


Yes, this is also the error in my Alcatel Pop C9 phone. how to fix this sir? and when running the application, upon making a pattern, it will close the app because of this error
 

tcgoh

Active Member
Licensed User
Longtime User
Hi,

I'm trying to use this nice class but I get a " java.lang.String cannot be cast to java.lang.Boolean" exception as soon as I put the finger on the screen.
I'm afraid it comes from the gesture detector librairy which is now in release 2.2 ?

My phone is a samsung S3 android 4.3

Any idea ?

Alain


Installing file.
PackageAdded: package:b4a.UnlockPattern
** Activity (main) Resume **
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.UnlockPattern
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
at flm.b4a.gesturedetector.GestureDetectorForB4A$1.onTouch(GestureDetectorForB4A.java:111)
at android.view.View.dispatchTouchEvent(View.java:7812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2435)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2131)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2326)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1612)
at android.app.Activity.dispatchTouchEvent(Activity.java:2494)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2274)
at android.view.View.dispatchPointerEvent(View.java:8025)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4668)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4556)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4207)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4176)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4261)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4184)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4318)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4207)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4176)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4184)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6302)

Hi,

Any update on this error?
I am using galaxy S5 and the app stop with both Lib: GestureDetector V1.2 and V2.2.
It will be great if I can get this simple unlock pattern app going.

Thanks
 
Top