Custom UI
When not using the Default UI, your application needs to define the UX of the entire scan process. For that, you first need some way to start the scan proces. In this example, a button will be responsible for starting and stopping the scan process. Here is a Kotlin example with its functionality:
fun onClickedBtnStartScan(view: View) {
val btnStartScan = (view as Button)
if (!TireTreadScanner.instance.isScanning) {
// Here we start scanning
TireTreadScanner.instance.startScanning()
btnStartScan.text = "Stop"
} else {
btnStartScan.visibility = View.GONE
btnStartScan.isEnabled = false
btnStartScan.isClickable = false
// Here we stop scanning
TireTreadScanner.instance.stopScanning()
}
}
The TireTreadScanner
also provides the captureDistanceStatus
property, with which your application can check if the user is positioning the device at the correct distance from the tire.
This property can be used to prevent scans from initiating at an incorrect distance, e.g.:
-
Kotlin
-
Swift
if (TireTreadScanner.instance.captureDistanceStatus == DistanceStatus.OK)
TireTreadScanner.instance.startScanning()
else {
Toast.makeText(
this,
"Move the phone to the correct position before starting.",
Toast.LENGTH_SHORT
).show()
}
if (TireTreadScanner.companion.instance.captureDistanceStatus == DistanceStatus.ok)
{
TireTreadScanner.companion.instance.startScanning()
}
else {
// Notify user to move the phone to the correct position before starting
print("Move the phone to the correct position before starting")
}
The scanning process can be stopped at any time. If not manually stopped, the scan process is automatically stopped after 10 seconds. |
Besides the "Start/Stop" button, you should also an "Abort" button (or e.g., an 'x' icon), through which the users can abort the Scan Process.
This button should call the abortScanning()
function of the TireTreadScanner
.