Giter VIP home page Giter VIP logo

privy-pena-android's Introduction

Pena ๐Ÿ’š Android

PrivyID's Official Client Integration Library for Android.

Requirement

  • Min SDK >= 30

Installation

  1. Add the JitPack repository to your build.gradle file.
allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
  1. Add the dependency
dependencies {
  implementation 'dev.privyid:pena-android:1.0.0'
}
  1. Add internet permission in your AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />

Usage

  1. Add Pena in your layout file
  <dev.privyid.pena.Pena
    android:id="@+id/pena"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
  />
  1. And handle on your Activity

Kotlin

import dev.privyid.pena.Payload
import dev.privyid.pena.Pena
import dev.privyid.pena.Placement

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val pena = findViewById<Pena>(R.id.pena)
        pena.openDoc(
            url = "https://sign.document.com/doc/xxx",
            lang = "en",
            signature = Placement(
                x = 100,
                y = 200,
                page = 1,
                fixed = true,
            ),
            onAfterAction = this::onAfterAction,
        )
    }

    private fun onAfterAction(payload: Payload) {
        if (payload.action == "sign")
            Toast.makeText(this, "Signed", Toast.LENGTH_SHORT).show()
    }
}

Java

import dev.privyid.pena.Payload;
import dev.privyid.pena.Pena;
import dev.privyid.pena.PenaDocument;
import dev.privyid.pena.Placement;
import kotlin.Unit;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Pena pena = findViewById(R.id.pena);
        pena.openDoc(
                new PenaDocument("https://sign.document.com/doc/xxx")
                        .setLang("en")
                        .setSignature(new Placement(100, 200, 1, true))
                        .setOnAfterAction(this::onAfterAction)

        );
    }

    private Unit onAfterAction(Payload payload) {
        if (payload.getAction().equals("sign"))
            Toast.makeText(this, "Signed", Toast.LENGTH_SHORT).show();

        return null;
    }
}

Options

Options Type Default Description
url String - (Required) Document's url
lang String en Set language, valid value is en or id
visibility Boolean true Set signature visibility
privyId String - Set recipient's privyId
signature Placement - Set signature placement
(Deprecated) use API to set placement when upload the document
โ”œ x Number - X Coordinate
โ”œ y Number - Y Coordinate
โ”œ page Number - Target page
โ”” fixed Boolean false Disabled signature for moving
debug Boolean false Enable debug mode
needScrollTo Number | String - Force user to scroll to target page before doing an action (sign,review,etc). Valid value is a number, or set last to target the last page
onAfterAction Function - After action hook

License

This project is licensed under the MIT License - see the LICENSE file for details

privy-pena-android's People

Contributors

adenvt avatar renovate[bot] avatar

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.