CoatedMoose / CustomViews

A set of views for use in android applications, including a signature capture view.
24 stars 6 forks source link

How to know if you have painted or not? #9

Open cataro opened 10 years ago

cataro commented 10 years ago

Hi!!! I need to know if you have painted or not?

Thanks!!!

CoatedMoose commented 10 years ago

I am not sure what you mean, could you elaborate?

cataro commented 10 years ago

Yes, of course. When I present the Signatureview and I click the Ok button, would need to know if it is signed or not, since it always captures the image, has been signed or not.

Thank you.

2014-06-23 14:34 GMT+02:00 Andrew Crichton notifications@github.com:

I am not sure what you mean, could you elaborate?

— Reply to this email directly or view it on GitHub https://github.com/CoatedMoose/CustomViews/issues/9#issuecomment-46838621 .

cataro commented 10 years ago

Yes, of course. When I present the Signatureview and I click the Ok button, would need to know if it is signed or not, since it always captures the image, has been signed or not.

Thank you.

CoatedMoose commented 10 years ago

Knowing if it is signed is not really a possibility given the nature of signatures. I think that a reasonable solution would be to implement listeners for touch-down/touch-up events and assume that if a line is drawn, that it is signed. Alternatively, you could check the image to ensure the % of pixels coloured is > than some value (this seems like it might frustrate users with small/sparse signatures.

momoteRyanmt commented 9 years ago

My solution was to place a counter in touchMove that is incremented by one each time the method is called.

then before saving the signature I call the following method to validate it

public boolean isCompletedSignature() {
    if(counter >= COMPLETED_THRESHOLD)  
    {
        return true;
    }
    return false;
}

completed threshold is set at 5 which seems to be high enough to prevent just a short line being accepted but passes anything else. Old post i know but might help somebody else