Giter Club home page Giter Club logo

android-signaturepad's People

Contributors

adamcoulter avatar bradmartin avatar bryant1410 avatar ch3d avatar dandar3 avatar dankellymn avatar eyalbira avatar friederbluemle avatar gcacace avatar inktomi avatar jitpack-io avatar juscezari avatar juxbzh avatar masc3d avatar omaraf avatar radimvaculik avatar robertoestrada avatar robinbuerkli avatar rupinderjeet avatar sadams2 avatar sinergy avatar thomasleveil avatar vladislavbakan avatar voghdev avatar voidhug avatar xiaoyaolml avatar yelinaung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-signaturepad's Issues

Bio-metric data

Is it possible to get bio metric data from the signature?

spatial coordinate x(t)
spatial coordinate y(t)
pressure p(t)
azimuth az(t)
inclination in(t)
pen up/down

Support for different Bitmap configs

Hello, is it possible to add the support for different bitmap configs?
I'd like to reduce an image size as much as i can by applying ALPHA_8, but as i see the library works only with ARGB_8888.

getTransparentSignatureBitmap() remove one line of pixel

Hello,

I'm using signature pad with screen rotation, so I use getTransparentSignatureBitmap and setSignatureBitmap and each time the screen rotate it removes a pixel line.

To fixe this I change the return line of getTransparentSignatureBitmap:

return Bitmap.createBitmap(mSignatureBitmap, xMin, yMin, xMax - xMin, yMax - yMin);

into

        return Bitmap.createBitmap(
                mSignatureBitmap,
                xMin > 0 ? xMin - 1 : 0,
                yMin > 0 ? yMin - 1 : 0,
                xMax < imgWidth  ? (xMax - xMin + 2): (xMax - xMin),
                yMax < imgHeight ? (yMax - yMin + 2): (yMax - yMin));

Best regards,

Unable to store signature.

Unable to Store Signature and Unable to store svg signature these two messages are populating when I am trying to save the image.

OutOfMemoryException

We got a OutOfMemoryException crash report from out production app. First time it's ever happened, but I thought I'd log it anyway in the hopes that you can improve your library :)

Device: Samsung Galaxy Note 10.1 2014 Edition (SM-P605)
OS Version: Android 4.4.2

Stack Trace:
java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:924)
at android.graphics.Bitmap.createBitmap(Bitmap.java:901)
at android.graphics.Bitmap.createBitmap(Bitmap.java:868)
at com.github.gcacace.signaturepad.views.SignaturePad.ensureSignatureBitmap(SignaturePad.java:471)
at com.github.gcacace.signaturepad.views.SignaturePad.addBezier(SignaturePad.java:363)
at com.github.gcacace.signaturepad.views.SignaturePad.addPoint(SignaturePad.java:351)
at com.github.gcacace.signaturepad.views.SignaturePad.onTouchEvent(SignaturePad.java:159)
at android.view.View.dispatchTouchEvent(View.java:8045)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2295)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1622)
at android.app.Dialog.dispatchTouchEvent(Dialog.java:761)
at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2243)
at android.view.View.dispatchPointerEvent(View.java:8240)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4654)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4520)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4078)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4132)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4101)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4212)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4109)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4269)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4078)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4132)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4101)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4109)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4078)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6437)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6354)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6325)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6290)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6517)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6490)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6536)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:571)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)

How to sign more?

Hello, the code written really good, I was used in Android TV at the same time more than one signature, what should I do?

Feature Request: be able to setSignatureSVG

Based on how I have to save and load the SVG I'm dealing with, it'd be really helpful if there was a conversion from SVG back into the canvas. This would, in a lot of cases I think, greatly shrink the storage requirements for the signatures.

I've tried several different methods of converting the Bitmap to string, converting the saved SVG into a bitmap, and compressing the bitmap. But my bitmaps are coming out > 9MB. I would store them on the device, but then I have to add code to manage that over time.

Does anyone have any ideas on best way to manage this data? By and large my data is being stored in a SqlLite via SugarOrm, and it balks on large fields. It seems crazy to store the data in a bitmap when the SVG is so much more concise.

unwanted line on svg

hi, I want to to use the svg file to save it on my project, so I draw the signature on android like this

screenshot_2016-04-22-13-35-12 1

then i saved it and check the jpeg file, it shows the same picture like this

signature_1461298684523

but when i check the svg file, I open it on AI, it shows like this

1461307092072

yes it shows the same picture like the original, but there are some unwanted line from the up-left corner of the picture
can anyone help me? :)

Adjust getTransparentSignatureBitmap()

Im sorry for open an Issue to do this, but i dont really know how GitHub works :D

This is a suggestion to put in getTransparentSignatureBitmap() method:

public static Bitmap TrimImage(Bitmap bmp) {
int imgHeight = bmp.getHeight();
int imgWidth = bmp.getWidth();

    //TRIM WIDTH
    int width  = 0;
    for(int i = 0; i < imgHeight; i++) {
        for(int j = imgWidth - 1; j >= 0; j--) {
            if(bmp.getPixel(j, i) != Color.TRANSPARENT &&
                    j > width) {
                width = j;
                break;
            }
        }
    }
    //TRIM HEIGHT
    int height = 0;
    for(int i = 0; i < imgWidth; i++) {
        for(int j = imgHeight - 1; j >= 0; j--) {
            if(bmp.getPixel(i, j) != Color.TRANSPARENT &&
                    j > height) {
                height = j;
                break;
            }
        }
    }

    return Bitmap.createBitmap(bmp, 0,0,width, height);
}

This will get just the Signature image, not returning the white/transparent space. A better result for the method

Hope it helps someone

onSigned issue

When we just touch the signaturepad and have not drawn our signature, onSigned callback gets executed.

Signature Pen Color

Signature pen color is not set after calling a method
mSignaturePad.setPenColorRes(color);//where color is get by Color Picker Dialog.

Extra data for note4

I am using your lib to capture signatures. It works for all devices that I have except the note4. It gives error when I am trying to open it on my phone after I compress it on a png format.

Only have this problem on the note4. any compression/decompression on it is failing.
The file that gets created is : https://www.dropbox.com/s/r83eha2wrjikdqs/signature?dl=0

On nexus the file that gets created with same codebase is: https://www.dropbox.com/s/wmm6xtg3lo7xsqq/signature-2?dl=0

Please advise as I am stuck.

Question - Get Bitmap Signature Path

First, many thanks for this awesome library.
I have a quick question regarding the upload of the Bitmap Signature on a server.

When calling the getSignatureBitmap() and receiving the Bitmap:

  • Is the Bitmap already stored somewhere?
  • Can we upload it as is to a server? If so how can we retrieve the Bitmap path?
  • If not, I guess I have to copy the Bitmap to the user storage?

Thanks a lot in advance for your assistance,

Isabelle,

Cannot open project

I'm trying to open the project in Android Studio - I'm getting the following messages:

C:\Users\JIMB\AndroidStudioProjects\android-signaturepad\signature-pad\build.gradle
Error:(10, 0) C:\Users\JIMB\AndroidStudioProjects\android-signaturepad\bintray.properties (The system cannot find the file specified)

Any ideas?

Missing tests

Currently there are no unit tests for the library.

Set Already Signed Bitmap as signature bitmap

Hi i have a requirement, i need to set the already signed signature bit to the signature view, and allow user to edit or modify the signature. I couldnt do this with this library. Except this , the library is working awesome. Please provide a solution. Thanks in advance.
my email is [email protected]. Its urgent for me. If you help me to find a solution, it will help a lot.

Can I use the bitmap as a image for a 3d plane?

I need to be able to save the signature as a bitmap within the app and then apply it as a texture for a 3d plane. Can I do that without saving it to the storage on the device? In the same way you would do text to bitmap?

Multiple lines on signature

The moment you life your finger the saveSignature function is called. The saveSignature function never fires again unless a clear is called. As a result, any signatures that require lifting the finger, do not render anything after the life when saved.

Can the touch fire save after every finger lift or after a delay (i.e. if the finger does not touch the screen in x seconds, then save)

SVG issue with 1.2.0

I just noticed an issue with the SVG generated by 1.2.0 that I could not replicate with 1.1.0 - it seems to connect on its own to the top left corner, see the two SVG / emulator screenshots with the different versions. The signature is a simple series of loops starting from somewhere in the top left corner.

(PS: It appears there is a difference in default line thinkness between the two versions, I can raise that as a different issue, I left it with defaults just in case it might be relevant somehow).

Comparing v1.1.0...v1.2.0 I see there are quite a few SVG related changes mostly done by @thomasleveil, copying him for thoughts on this.

Tested with Visual Studio Emulator for Android
4.5", xhdpi, Android 5.1.1 (similar to Motorola Moto G, Motorola Moto X)

screenshots + svgs.zip

The pad is not empty after clearOnDoubleClick

After using the clearOnDoubleClick feature, the pad is not empty (isEmpty() == false).
I want to use the OnSignedListener to toggle a button state but onSigned is always called after the double click gesture.

If you look at this line, you can see that something is drawn after MotionEvent.ACTION_UP events preventing the pad to be cleared properly.

add stamp in gcacece android signature

how to add stamp in my signature,
i create an purchase order application,
how to add my PO number in my signature.
ex PO01/12/13
my po number in top right of my signature

need help

Bitmap size exceeds 32bits

HI, I have a problem with your library, applicaiton crash on Motorolla Moto G phone.

It's work on nexus phone everytime.
But on moto G if I set fix size, it's work, but if I set match_parent, application crash :

11-30 10:41:54.441 18324-18324/temp.com.payzenmpos.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: temp.com.payzenmpos.dev, PID: 18324
java.lang.IllegalArgumentException: bitmap size exceeds 32bits
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:836)
at android.graphics.Bitmap.createBitmap(Bitmap.java:813)
at android.graphics.Bitmap.createBitmap(Bitmap.java:780)

Do you have any idea ?

Gradle support

It would be awesome to have gradle support for easily integration of this library into any project.

SVG support?

Is it possible to export an .svg of the signature? or is bitmap only possible with this library?

If it is possible, please add documentation for it. If not, please add it!

Thanks!

add setSignatureColor support

currently doing it this way:

public class SignaturePad extends com.github.gcacace.signaturepad.views.SignaturePad {
    public SignaturePad(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setSignatureColorRes(int colorRes) {
        try {
            setSignatureColor(getResources().getColor(colorRes));
        } catch (Resources.NotFoundException e) {
            setSignatureColor(getResources().getColor(R.color.black));
        }
    }

    public void setSignatureColor(int color) {
        Field[] fields = getClass().getDeclaredFields();
        for (Field field : fields) {
            if ("mPaint".equals(field.getName())) {
                field.setAccessible(true);
                try {
                    field.set(this, color);
                } catch (IllegalAccessException ignore) {
                }
                break;
            }
        }
    }
}

OnSignedListener on a null object reference

When trying to start the activity with this view in it:
`

    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="@android:color/darker_gray"
        android:layout_marginBottom="8dp"
        android:layout_above="@+id/signature_pad_description" />

    <TextView
        android:id="@+id/signature_pad_description"
        android:layout_width="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_height="wrap_content"
        android:textColor="@android:color/darker_gray"
        android:layout_marginBottom="16dp"
        android:layout_alignParentBottom="true"
        android:text="@string/agreementR" />

    <com.github.gcacace.signaturepad.views.SignaturePad
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/signature_pad"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:penColor="@android:color/black"
        />
</RelativeLayout>`

I get this error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.portalcarriers.portal/com.portalcarriers.portal.SignActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.gcacace.signaturepad.views.SignaturePad.setOnSignedListener(com.github.gcacace.signaturepad.views.SignaturePad$OnSignedListener)' on a null object reference at ... com.portalcarriers.portal.SignActivity.onCreate(SignActivity.java:41) at ...ย 

Here's the onCreate for the activity:
`@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scan);
this.extras = getIntent().getExtras();
this.type = this.extras.getInt("type");

    TextView agreement = (TextView) findViewById(R.id.signature_pad_description);
    if(type == 1){
        agreement.setText(R.string.agreementR);
    }
    else if(type == 2){
        agreement.setText(R.string.agreementD);
    }
    mSignaturePad = (SignaturePad) findViewById(R.id.signature_pad);
    //LINE 41-----mSignaturePad.setOnSignedListener(new SignaturePad.OnSignedListener() {
        @Override
        public void onStartSigning() {
        }

        @Override
        public void onSigned() {
            mSaveButton.setEnabled(true);
            mClearButton.setEnabled(true);
        }

        @Override
        public void onClear() {
            mSaveButton.setEnabled(false);
            mClearButton.setEnabled(false);
        }
    });

    mClearButton = (Button) findViewById(R.id.clear_button);
    mSaveButton = (Button) findViewById(R.id.save_button);

    mClearButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mSignaturePad.clear();
        }
    });

    mSaveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Bitmap signatureBitmap = mSignaturePad.getTransparentSignatureBitmap();
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            signatureBitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
            byte[] byteArray = byteArrayOutputStream .toByteArray();
            String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
            Intent returnIntent = new Intent();
            returnIntent.putExtra("img", encoded);
            setResult(Activity.RESULT_OK, returnIntent);
            finish();
        }
    });
}`

eraser

I need to remove a specific area . Not the entire area.
So i tried changing pen color with transparent, but it clear a rect area.
I just need to remove specific line.

Please tell me how to do it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.