Skip to content

VGS Show - Android SDK that enables you to securely display sensitive data https://www.verygoodsecurity.com/docs/vgs-show

License

Notifications You must be signed in to change notification settings

verygoodsecurity/vgs-show-android

Repository files navigation

UT license

VGS Show Android SDK allows you to securely reveal data for your users without having to have that data pass through your systems. It provides customizable UI elements for showing users' sensitive data securely on Android devices.

Table of contents

Dependencies

Dependency Version
Min SDK 21
Target SDK 34
org.jetbrains.kotlin:kotlin-gradle-plugin 1.9.22
androidx.appcompat:appcompat 1.6.1
com.squareup.okhttp3:okhttp 4.12.0

Structure

  • VGSShow SDK - provides an API for interacting with the VGS Vault
  • app - sample application to act as the host app for testing the SDK during development

Integration

For integration you need to install the Android Studio and a JDK on your machine.

Integrate the VGS Show SDK to your project.
If you are using Maven, add the following to your build.gradle file.
dependencies {
    implementation "androidx.appcompat:appcompat:<version>"
    implementation "com.google.android.material:material:<version>"

    implementation "com.verygoodsecurity:vgsshow:<version>"
}
Add input fields to R.layout.activity_main layout file .
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
  
    <com.verygoodsecurity.vgsshow.widget.VGSTextView
        android:id="@+id/infoField"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:contentPath="<CONTENT_PATH>"
        app:gravity="center"
        app:textColor="@android:color/black"
        app:textStyle="bold" 

//Other fields..

</LinearLayout>
To initialize VGSShow you have to set your vault id and Environment type.
Use subscribe(VGSView) to attach view to VGSShow.
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.verygoodsecurity.demoshow.R
import com.verygoodsecurity.vgsshow.VGSShow
import com.verygoodsecurity.vgsshow.widget.VGSTextView
import com.verygoodsecurity.vgsshow.core.VGSEnvironment

class MainActivity : AppCompatActivity() {
    private lateinit var vgsShow: VGSShow
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        vgsShow = VGSShow(this, "<VAULT_ID>", VGSEnvironment.Sandbox())

        val view = findViewById<VGSTextView>(R.id.infoField)
        vgsShow.subscribe(view)
    }
}
Revealing Sensitive Data.
Call requestAsync to reveal and send data on VGS Server.
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.verygoodsecurity.demoshow.R
import com.verygoodsecurity.vgsshow.VGSShow
import com.verygoodsecurity.vgsshow.widget.VGSTextView
import com.verygoodsecurity.vgsshow.core.VGSEnvironment

class MainActivity : AppCompatActivity() {

    private lateinit var vgsShow: VGSShow
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        
        vgsShow = VGSShow(this, "<VAULT_ID>", VGSEnvironment.Sandbox())
        vgsShow.subscribe(findViewById(R.id.infoField))

        findViewById<Button>(R.id.revealButton)?.setOnClickListener {
            vgsShow.requestAsync("/post",
                VGSHttpMethod.POST,
                mapOf("<FIELD_NAME>" to "<REVEAL_ALIAS>")
            )
        }
    }
}
Receive responses.
To retrieve response you need to implement VGSOnResponseListener.
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.verygoodsecurity.demoshow.R
import com.verygoodsecurity.vgsshow.VGSShow
import com.verygoodsecurity.vgsshow.widget.VGSTextView
import com.verygoodsecurity.vgsshow.core.VGSEnvironment
import com.verygoodsecurity.vgsshow.core.network.model.VGSResponse
import com.verygoodsecurity.vgsshow.core.listener.VGSOnResponseListener

class MainActivity : AppCompatActivity() {

    private lateinit var vgsShow: VGSShow

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

        vgsShow = VGSShow(this, "<VAULT_ID>", VGSEnvironment.Sandbox())
        vgsShow.subscribe(findViewById(R.id.infoField))

        findViewById<Button>(R.id.revealButton)?.setOnClickListener {
            vgsShow.requestAsync("/post",
                VGSHttpMethod.POST,
                mapOf("<FIELD_NAME>" to "<REVEAL_ALIAS>")
            )
        }

        showVgs.addOnResponseListeners(object : VGSOnResponseListener {
            override fun onResponse(response: VGSResponse) {
                when(response) {
                    is VGSResponse.Success -> {
                        val code = response.code
                    }
                    is VGSResponse.Error -> {
                        val code = response.code
                        val message = response.message
                    }
                }
            }
        })
    }
}

Releases

To follow VGS Show SDK updates and changes check the releases page.

License

VGSShow Android SDK is released under the MIT license. See LICENSE for details.