Skip to content

frslabs/cropus-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 

Repository files navigation

CROPUS ANDROID SDK

version

The Cropus Android SDK is a real-time signature capture and crop solution for Android.

Features available are

  • Signature Capture
  • Manual Crop
  • White Background Removal (Transparent Background , allowing seamless overlaying of the signature on another document)

Find the changelog and release history Here

‼ ATTENTION ‼ → BREAKING CHANGE introduced at Cropus SDK v1.1.0. We have introduced a new license format. If you are using versions prior to v1.1.0 and intend to update to v1.1.0 or above, contact support@frslabs.com for an updated license.

Table Of Content

Prerequisite

You will need a valid license to use the Cropus Android SDK, which can be obtained by contacting support@frslabs.com .

Once you have the license , follow the below instructions for a successful integration of Cropus Android SDK onto your Android Application.

Android SDK Requirements

Minimum SDK Version - 23

Download

Using maven repository

Add the following code to your project level build.gradle file

allprojects { 
    repositories { 
       maven { 
            // Maven Url and Credentials for Cropus SDK. 
            url "https://www.repo2.frslabs.space/repository/cropus-android/"              
            credentials { 
                   username 'repo-username' 
                   password 'repo-password' 
            }
       }
        
    }
}

After that, add the following code to your app level build.gradle file

// ...

  compileOptions {
      
       sourceCompatibility = 1.8
       targetCompatibility = 1.8
       
       //Add below line only if minSdkVersion is < 24 
       coreLibraryDesugaringEnabled true
       
  }

// ...

And then, add the dependencies

// ...

dependencies {
    /* Standard AndroidX Library Dependencies */ 
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
   
    //REQUIRED - Cropus SDK Dependency
    implementation 'com.frslabs.android.sdk:cropus:1.2.1'
    
    //Add below line only if minSdkVersion is < 24 
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10'
    
}

Setup

Permissions

Cropus SDK uses the required permissions and features

    <!--Permissions-->
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.VIBRATE" />
    
    <!--Features-->
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

Quick Start

Invoking the Cropus SDK

Initialize the Cropus instance with the appropriate configurations. Call start on the instance to invoke the SDK. Handle the result by extending the CropusResultCallback

public class MainActivity extends AppCompatActivity implements CropusResultCallback {

    // ...

    /* Enter the Cropus SDK license key here */
    private String CROPUS_LICENSE_KEY = "ENTER_YOUR_LICENSE_KEY_HERE";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        Button callSdk = findViewById(R.id.call_sdk);
        callSdk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                /* Invoke the Cropus SDK */
                invokeCropusSDK();
            }
        });
    }

    private void invokeCropusSDK() {
    
        //Initialize the Cropus SDK Config object with the appropriate configurations
        CropusConfig cropusConfig = new CropusConfig.Builder()
                .setLicenseKey(CROPUS_LICENSE_KEY)
                //.setOutputImageFormat("jpg")    //OPTIONAL: Output image format either jpg or png by default result will be in jpg format.
                // .setCropusOutputImageQuality(CropusOutputImageQuality.both()) //OPTIONAL: To set output image quality. by default it's high image quality
                .build();

        //Call the Cropus SDK 
        Cropus cropus = new Cropus(cropusConfig);
        cropus.start(this, this);
    }
    
    @Override
    public void onCropusSuccess(CropusResult cropusResult) {
        //Handle the Cropus SDK Result Here
        Toast.makeText(this, cropusResult.getImagePath().getPath(), Toast.LENGTH_LONG).show();
    }

    @Override
    public void onCropusFailure(int errorCode) {
        /* Handle the Cropus SDK error here */
        Toast.makeText(this, "Error: "+ errorCode, Toast.LENGTH_SHORT).show();
    }
    
    // ...

}

Cropus SDK Result

The result is obtained through the CropusResult object

Given below are the public methods in brief.

Public Methods
Uri getImagePath() Returns the Signature Image Path as Uri
Uri getImagePathHighres() Returns the Signature high resolution Image Path as Uri
Uri getImagePathLowres() Returns the Signature lower resolution Image Path as Uri

Cropus SDK Error Codes

Error codes and their meaning are tabulated below

Label Code Message
ERROR_CODE_CAM_PERMISSION 803 Required permissions for Cropus SDK were not granted
ERROR_CODE_INTERRUPTED 804 Cropus SDK Interrupted
ERROR_CODE_EXPIRED_LICENCE 805 Cropus SDK License has expired
ERROR_CODE_INVALID_LICENCE 806 Invalid Cropus SDK License
ERROR_CODE_INVALID_CONFIG 807 Invalid Cropus SDK Config
ERROR_CODE_FILE_IO 809 Error Saving File to Disk

Cropus SDK Parameters

CropusConfig.Builder() allows to instantiate the CropusConfig object with customisable features. CropusConfig is to be set when instantiating Cropus object.

Method Default Required Comments
setLicenceKey(String licenseKey) NULL Yes Sets the License Key needed for Cropus SDK
setOutputImageFormat(String) jpg Optional To get output image in jpg/jpeg format use jpg, and for png format use png
setCropusOutputImageQuality() CropusOutputImageQuality.high() Optional Use CropusOutputImageQuality to set different resolution images. For high resolution image use .high(), for low resolution image use .low() (Default: below 25KB) or .low(int) (To set custom image size. minimum is 5KB) and .custom(int width, int height)
build() - - Builds CropusConfig Instance

Help

For any queries/feedback , contact us at support@frslabs.com

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published