Start using packagecloud in minutes
Join thousands of developers using packagecloud to distribute software securely, consistently, and affordably.
README
last updated: Fri 05/17/24 at 02:16:27 PM bylucas-yupistudios
BioPass ID Signature SDK Android
Latest Version
May 16, 2024 - [v0.1.5]
Table of Contents
Quick Start Guide
First, you will need a license key to use the SDK. To get your license key contact us through our website BioPass ID.
Check out our official documentation for more in depth information on BioPass ID.
1. Prerequisites:
- Java 17 or higher
- Kotlin 1.9.0 or highr
- Gradle 8.6 or higher
- Android Gradle Plugin 8.4.0 or higher
- License key
- Internet connection is required to verify the license
Change the minimum Android sdk version to 23 (or higher) in your app/build.gradle
file.
minSdkVersion 23
2. Installation
With Gradle
The simplest and easiest way to install the SDK to your project, is to just add the following dependencies to your build.gradle:
dependencies
implementation "com.biopassid:signaturesdk:0.1.5" // latest version
Then on your settings.gradle file:
repositories
maven
url "https://packagecloud.io/biopassid/SignatureSDKAndroid/maven2"
With Local File
Another alternative to use Signature SDK is to download and install the AAR file locally. Here you can find the latest releases and after downloading place the .aar file in any folder of your choice.
We will use Android Studio for the following steps:
- First, with your project open, go to File --> Project Structure --> Dependencies.
- Then in the Dependencies tab, select your app in the modules tab and click on the plus symbol to show the option to add a JAR/AAR dependency.
- On step 1 input the AAR file path, and select the implementation option on step 2.
- Just rebuild your project and should be ready to use.
3. How to use
By now you should have all the tools available to start using the plugin in your own project. Here is a code example showing how to use Signature SDK. Through SignatureConfig, you can configure custom settings (such as colors and features).
activity_main
In your xml layout of your main activity:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/btnCapture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Capture Signature"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity
In your main activity:
import android.graphics.Bitmap
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Button
import br.com.biopassid.signaturesdk.Signature
import br.com.biopassid.signaturesdk.SignatureCallback
import br.com.biopassid.signaturesdk.config.SignatureButtonOptions
import br.com.biopassid.signaturesdk.config.SignatureConfig
import br.com.biopassid.signaturesdk.config.SignatureIconOptions
import br.com.biopassid.signaturesdk.config.SignatureScreenOrientation
import br.com.biopassid.signaturesdk.config.SignatureTextOptions
class MainActivity : AppCompatActivity()
private val TAG = "Demo_App"
private lateinit var btnCapture: Button
override fun onCreate(savedInstanceState: Bundle?)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Button in your xml layout responsible for calling the Signature SDK
this.btnCapture = findViewById(R.id.btnCapture)
// instantiate SignatureConfig with your preferred settings
val config = SignatureConfig()
config.licenseKey = "your-license-key"
// you can define a custom callback to receive the signature image bitmap
val callback = object: SignatureCallback
override fun onSignatureCapture(image: Bitmap)
// handle signature return
Log.d(TAG, "Signature: $image")
// eg. you can call the signature view inside a button's onClickListener
this.btnCapture.setOnClickListener
// just use this method that will build the signature view using the configs you choose
Signature.takeSignature(this, config, callback)
4. SignatureCallback
Setting the Callback
You can set a custom callback to receive the captured signature image. You can write you own callback following this example:
val callback = object: SignatureCallback
override fun onSignatureCapture(image: Bitmap)
// handle Signature return
Log.d(TAG, "Signature: $image")
5. LicenseKey
First, you will need a license key to use the SDK. To get your license key contact us through our website BioPass ID.
To use Signature you need a license key. To set the license key needed is simple as setting another attribute. Simply doing:
val config = SignatureConfig()
config.licenseKey = "your-license-key"
SignatureConfig
You can also use pre-build configurations on your application, so you can automatically start using multiples features that better suit your application. You can instantiate each one and use it's default properties, or if you prefer you can change every config available. Here are the types that are supported right now:
SignatureConfig
| Name | Type | Default value |
| ----------------- | -------------------------- | ----------------------------------- |
| licenseKey | String | "" |
| screenOrientation | SignatureScreenOrientation | SignatureScreenOrientation.PORTRAIT |
| pencilColor | Int | Color.BLACK |
| pencilWidth | Int | 5 |
| backgroundColor | Int | Color.WHITE |
| overlayColor | Int | Color.parseColor("#80000000") |
| fontFamily | Int | R.font.opensans_bold |
| titleText | SignatureTextOptions | |
| backButton | SignatureButtonOptions | |
| saveButton | SignatureButtonOptions | |
| deleteButton | SignatureButtonOptions | |
| undoButton | SignatureButtonOptions | |
SignatureButtonOptions
| Name | Type | Default value |
| --------------- | -------------------- | ------------- |
| enabled | Boolean | true |
| backgroundColor | Int | Color.WHITE |
| buttonPadding | Int | 0 |
| buttonSize | Size | Size(56, 56) |
| iconOptions | SignatureIconOptions | |
| labelOptions | SignatureTextOptions | |
SignatureIconOptions
| Name | Type | Default value |
| --------- | ------- | --------------------------- |
| enabled | Boolean | true |
| iconFile | Int | R.drawable.ic_close |
| iconColor | Int | Color.parseColor("#323232") |
| iconSize | Size | Size(32, 32) |
SignatureTextOptions
| Name | Type | Default value |
| --------- | ------- | --------------------------- |
| enabled | Boolean | true |
| content | String | "" |
| textColor | Int | Color.parseColor("#323232") |
| textSize | Int | 14 |
SignatureScreenOrientation (enum)
| Name |
| ------------------------------------ |
| SignatureScreenOrientation.PORTRAIT |
| SignatureScreenOrientation.LANDSCAPE |
How to change font family
You can use the default font family or set one of your own. To set a font family, create a font folder under res directory. Download the font which ever you want and paste it inside font folder. All font names must be only: lowercase a-z, 0-9, or underscore. The structure should be some thing like below.
Then, just set the font family passing the reference of the font family file.
val config = SignatureConfig()
config.licenseKey = "your-license-key"
config.fontFamily = R.font.roboto_mono_bold_italic
How to change icon
You can use the default icons or define one of your own. To set a icon, download the icon which ever you want and paste it inside drawable folder. The structure should be some thing like below.
Then, just set the icon passing the reference of the icon file.
val config = SignatureConfig()
config.licenseKey = "your-license-key"
// Changing back button icon
config.backButton.iconOptions.iconFile = R.drawable.ic_baseline_photo_camera
// Changing save button icon
config.saveButton.iconOptions.iconFile = R.drawable.ic_baseline_photo_camera
// Changing delete button icon
config.deleteButton.iconOptions.iconFile = R.drawable.ic_baseline_photo_camera
// Changing undo button icon
config.undoButton.iconOptions.iconFile = R.drawable.ic_baseline_photo_camera
Changelog
v0.1.5
- Documentation update;
- Changed the minimum Android sdk version from 21 to 23;
- Upgrade to Gradle 8.6, see prerequisites section;
- Upgrade to Android Gradle Plugin 8.4.0, see prerequisites section;
- Upgrade to Java 17, see prerequisites section;
- Upgrade to Kotlin 1.9.0, see prerequisites section.
v0.1.4
- Documentation update;
- Removed noDrawingAlert from SignatureConfig;
- Renamed buildSignatureView on Signature to takeSignature;
- Renamed receiveSignature on SignatureCallback to onSignatureCapture.
v0.1.3
- Documentation update.
v0.1.2
- Documentation update;
- Added new configuration noDrawingAlert:
- It's now possible to show an alert dialog when trying to save a blank signature.
- Bug fix in license functionality.
v0.1.1
- Documentation update.
v0.1.0
- Add documentation;
- Signature capture functionality;
- Customizable UI;
- Return of captured signature image.