Android SDK development
Zoho Sign SDK is a kit that enables users to instantly send their documents to sign or allow the user to sign the document from their application.
Compatibility
Operation System - Android 21 (Lollipop) and above.
Scopes
The following scopes need to be added while initializing Android SSO Library.
"ZohoSign.documents.ALL",
"ZohoSign.account.ALL",
"ZohoSign.setup.ALL",
"ZohoSign.templates.ALL"
Configure SDK in your project
Add the below repository in your project level settings.gradle.
CopieddependencyResolutionManagement {
repositories {
maven {
url "https://maven.zohodl.com/"
}
maven {
url "https://jitpack.io"
}
}
}
Add the below dependency in your app level build.gradle.
Copieddependencies {
implementation 'com.zoho.sign:android-sdk:1.5'
}
Implementation
The SDK has to be initialized before its methods are accessed by the client, so initialize the SDK in your Application class. When initializing the SDK, it is mandatory to pass the scopeName and SignSDKClientCallback listener as parameters.
Parameter description
scopeName: String (Optional) - Scope name is the unique identifier for your application and it empowers the SDK to identify and enable specific API's particular to the client.
callback:SignSDKClientCallback - This listener contains the basic callback methods to get the necessary data from the client application to make the SDK to serve it's purpose.
Callback methods:
requireAuthToken(accessTokenCallback: SignSDKAccessTokenCallback) - Implement the business logic to set the auth token using accessToken.onSuccess ("your_auth_token_here") method or handle failure case using accessToken.onFailure ("failure_message_here") .
setNonFatalException(throwable: Throwable, message: String) - Handle the hardware / device specific exceptions.
forceLogout(errorMessage: String, errorCode: Int) - Invoked when the app is forced to logout.
requireUserProfileImage(): Bitmap - Implement the business logic to return the profile image of the user.
Copiedclass SignSDKClient: Application() {
override fun onCreate() {
super.onCreate()
initSignSDK()
}
private fun initSignSDK() {
val signSdk = SignSDK.getInstance(applicationContext)
signSdk.initialize(scopeName = scopeName, listener = object: SignSDKClientCallback {
override fun requireAuthToken(accessTokenCallback: SignSDKAccessTokenCallback) {
TODO("Not yet implemented")
}
override fun setNonFatalException(throwable: Throwable, message: String?) {
TODO("Not yet implemented")
}
override fun forceLogout(errorMessage: String, errorCode: Int) {
TODO("Not yet implemented")
}
override fun requireUserProfileImage(): Bitmap {
TODO("Not yet implemented")
}
})
}
}
Sign SDK configurations
serviceUrl: String - This property customizes the service url to communicate with the server.
guestServiceUrl: String - This property customizes the guest service url to communicate with the server. This is used in the signing process.
CopiedsignSDK.setServiceUrl("https://sign.zoho.your_domain_here")
CopiedsignSDK.setGuestServiceUrl("https://sign.zoho.your_domain_here")
Themes
Override the following style in the below mentioned files.(Optional)
app/src/main/res/values/themes.xml
app/src/main/res/values-night/themes.xml
Copied<style name="SignSdkTheme" parent="SignSdkBaseTheme">
<item name="colorPrimary">@color/your_value_here</item>
<item name="colorPrimaryDark">@color/your_value_here</item>
<item name="colorAccent">@color/your_value_here</item>
<item name="colorControlActivated">@color/your_value_here</item>
</style>
Copied//or (Programmatically)
signSdk.setTheme("R.style.SignSdkTheme")
Style customization
Override the following attributes in the below mentioned files for style customization.
app/src/main/res/values/colors.xml
app/src/main/values-night/colors.xml
For customizing the toolbar color.
Copied<color name="sign_sdk_toolbar_bg">@color/your_value_here</color>
For customizing the toolbar title text color
Copied<color name="sign_sdk_toolbar_text_color">@color/your_value_here</color>
For customizing the toolbar icons color
Copied<color name="sign_sdk_toolbar_icon_color">@color/your_value_here</color>
API Functions
Get Current User Details
Parameter description
callback - listener for network request status.
DomainUser - Data class for wrapping user properties.
CopiedsignSdk.getCurrentUserDetails(object : SignSDKResponseCallback<DomainUser> {
override fun onLoading(loadingMessage: String) {
TODO("Not yet implemented")
}
override fun onSuccess(message: String, response: DomainUser?) {
TODO("Not yet implemented")
}
override fun onFailed(exception: SignSDKException) {
TODO("Not yet implemented")
}
})
Get User Profile Details
Parameter description
callback - listener for network request status.
DomainUserProfile - Data class for wrapping user profile properties.
CopiedsignSdk.getUserProfileDetails(object : SignSDKResponseCallback<DomainUserProfile> {
override fun onLoading(loadingMessage: String) {
TODO("Not yet implemented")
}
override fun onSuccess(message: String, response: DomainUserProfile?) {
TODO("Not yet implemented")
}
override fun onFailed(exception: SignSDKException) {
TODO("Not yet implemented")
}
})
Upload Document
Parameter description
multipartBodyFile: MultipartBody.Part - Pass the uploading document in multipart-body-part type.
password: String - Needed in case of password protected files.
callback: SignSDKResponseCallback<DomainUploadedDocument> - listener for network request status.
DomainUploadedDocument - Data class for wrapping uploaded document properties.
CopiedsignSDK.uploadDocument(multipartBodyFile, password, object : SignSDKResponseCallback<DomainUploadedDocument> {
override fun onLoading(loadingMessage: String) {
TODO("Not yet implemented")
}
override fun onSuccess(message: String, response: DomainUploadedDocument?) {
TODO("Not yet implemented")
}
override fun onFailed(exception: SignSDKException) {
TODO("Not yet implemented")
}
})
Create Self Sign Request
Parameter description
uploadedDocumentList: List<DomainUploadedDocument> - uploaded document List.
requestName: String - Self sign request name.
callback: SignSDKResponseCallback<DomainDocumentDetails> - listener for network request status.
DomainUploadedDocument - Data class for wrapping uploaded document properties.
DomainDocumentDetails - Data class for wrapping document properties.
CopiedsignSDK.createSelfSignRequest(uploadedDocumentList, requestName, object : SignSDKResponseCallback<DomainDocumentDetails> {
override fun onLoading(loadingMessage: String) {
TODO("Not yet implemented")
}
override fun onSuccess(message: String, response: DomainDocumentDetails?) {
TODO("Not yet implemented")
}
override fun onFailed(exception: SignSDKException) {
TODO("Not yet implemented")
}
})
Download Document as Pdf
Parameter description
requestId: String - unique identifier of the request.
documentId: String - unique identifier of the downloading document.
clientListener: SignSDKDocumentDownloaderListener - Interface containing callback method for updating download progress in percentage.
callback: SignSDKResponseCallback<ResponseBody> - listener for network request status.
Copiedval clientListener: SignSDKDocumentDownloaderListener = object : SignSDKDocumentDownloaderListener {
override fun onDownloadingProgressUpdated(percentage: Int) {
TODO("Not yet implemented")
}
}
signSDK.downloadDocumentAsPdf(
requestId,
documentId,
clientListener,
object : SignSDKResponseCallback<ResponseBody> {
override fun onLoading(loadingMessage: String) {
TODO("Not yet implemented")
}
override fun onSuccess(message: String, response: ResponseBody?) {
TODO("Not yet implemented")
}
override fun onFailed(exception: SignSDKException) {
TODO("Not yet implemented")
}
})
Download Document as Zip
Parameter description
requestId: String - unique identifier of the request.
documentId: String - unique identifier of the downloading document.
clientListener: SignSDKDocumentDownloaderListener - Interface containing callback method for updating download progress in percentage.
callback: SignSDKResponseCallback<ResponseBody> - listener for network request status.
Copiedval clientListener: SignSDKDocumentDownloaderListener = object : SignSDKDocumentDownloaderListener {
override fun onDownloadingProgressUpdated(percentage: Int) {
TODO("Not yet implemented")
}
}
signSDK.downloadDocumentAsZip(
requestId,
documentId,
clientListener,
object : SignSDKResponseCallback<ResponseBody> {
override fun onLoading(loadingMessage: String) {
TODO("Not yet implemented")
}
override fun onSuccess(message: String, response: ResponseBody?) {
TODO("Not yet implemented")
}
override fun onFailed(exception: SignSDKException) {
TODO("Not yet implemented")
}
})
Create Sign Account
Parameter description
organizationName: String - organization name for your account.
callback: SignSDKResponseCallback - listener for network request status.
CopiedsignSDK.createSignAccount(organizationName, object : SignSDKResponseCallback<Unit> {
override fun onLoading(loadingMessage: String) {
TODO("Not yet implemented")
}
override fun onSuccess(message: String, response: Unit?) {
TODO("Not yet implemented")
}
override fun onFailed(exception: SignSDKException) {
TODO("Not yet implemented")
}
})
User Interface Usages
Create Request
Copiedval intent = Intent(this, SignSDKCreatorActivity::class.java)
intent.putExtra(SignSDKClientConstants.IS_FROM_TEMPLATE, false)
startActivityForResult(intent, SignSDKClientConstants.CREATE_DOCUMENT_REQUEST_CODE)
Document Editor (Self Sign)
Copiedval intent = Intent(this, SignSDKDocumentEditorActivity::class.java)
intent.putExtra(SignSDKClientConstants.REQUEST_ID, "Enter_your_request_id")
intent.putExtra(SignSDKClientConstants.IS_SELF_SIGN, true)
startActivityForResult(intent, SignSDKClientConstants.DOCUMENT_EDITOR_REQUEST_CODE)
Guest Sign
Copiedval intent = Intent(this, SignSDKSigningActivity::class.java)
intent.putExtra(SignSDKClientConstants.SIGN_ID, "Enter your_sign_id")
intent.putExtra(SignSDKClientConstants.IS_GUEST, true)
startActivityForResult(intent, SignSDKClientConstants.SIGNING_ACTIVITY_REQUEST_CODE)
User profile
Copiedval intent = Intent(this, SignSDKProfileActivity::class.java)
startActivity(intent)
Create Sign Account
Case 1 - If invoking class is an activity
CopiedsignSDK.launchCreateSignAccountPage(supportFragmentManager)
Case 2 - If invoking class is a fragment
CopiedsignSDK.launchCreateSignAccountPage(childFragmentManager)