The Signature Form Cell¶
Use the signature form cell to launch a SignatureCaptureFormCell
. This view can be used inline and opens a signature capture dialog on medium and expanded window size classes. On compact window size classes, it opens a full-screen dialog whenever users click the Add Signature button.
Using the Signature Form Cell From XML¶
The signature form cell can be defined In XML with its properties:
<com.sap.cloud.mobile.fiori.formcell.SignatureFormCell
android:id="@+id/signature_form_cell"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:key="Required Signature"
app:helperEnabled="true"
app:helperText="Job 3r9320"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
The signature form cell can be then referenced from XML.
override fun onCreate(savedInstanceState: Bundle?) {
...
val signatureFormCell = findViewById<SignatureFormCell>(R.id.signature_form_cell)
}
Using the Signature Form Cell in Code¶
The signature form cell can also be constructed and added dynamically at runtime.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val rootview = findViewById<ViewGroup>(R.id.activity_signature_form_layout)
val signatureFormCell = SignatureFormCell(this)
signatureFormCell.key = "The title for the signature"
signatureFormCell.setDescription("Please sign the document.")
signatureFormCell.helperText = "A helper text displaying the reason for signing."
rootview.addView(signatureFormCell)
}
Listening for Cell Value Changes¶
To monitor cell value updates, attach a CellValueChangeListener\<SignatureInfo>
using setCellValueChangeListener
:
signatureFormCell.cellValueChangeListener = object : CellValueChangeListener<SignatureInfo>() {
override fun cellChangeHandler(value: SignatureInfo?) {
value?.let { signatureInfo ->
if (signatureInfo.isValid) {
//storeBitmap is application logic.
storeBitmap(signatureInfo.bitmap!!)
}
}
}
}
Required State¶
The signature form cell subclasses inherit the properties and methods from FormCellMetadataLayout
. One common feature is setting the signature form cell as a "required" field, which can be configured using the respective XML attribute.
<com.sap.cloud.mobile.fiori.formcell.SignatureFormCell
android:id="@+id/signature_form_cell"
...
app:isRequired="true"
app:error="Please sign the form"
/>