UIFeedback Config

In some scenarios it may be appropriate to use UIFeedback elements to provide the user real-time feedback about environment conditions (brightness, distance) or content (format) like:

  • Showing visual elements (images and text), positioned based on cutout coordinates

  • Playing defined sounds

  • Adding clickable functionality to elements that can create events (observable in code)

At this moment, the UIFeedback is only available to be used with internal presets

Configuring a ViewConfig with uiFeedbackConfig section
{
  "cameraConfig": {},
  "flashConfig": {},
  "viewPluginConfig": {
    "pluginConfig": {},
    "cutoutConfig": {},
    "scanFeedbackConfig": {},
    "uiFeedbackConfig": {
      "presets": [
        {
          "presetName": "internal_preset_name",
          "presetAttributes": [
            {
              "attributeName": "internal_preset_attribute1",
              "attributeValue": "value_of_attribute1"
            },
            {
              "attributeName": "internal_preset_attribute2",
              "attributeValue": "value_of_attribute2"
            }
          ]
        }
      ]
    }
  }
}

UIFeedback TIN preset

This preset includes a set of elements to improve TIN scanning experience:

  • A customizable cutout guide image

  • A customizable instruction label positioned above the cutout

  • Configurable text, images and sound alerts for each user condition (brightness, distance and content)

The UIFeedback TIN preset must be referred by name "tin_custom_v1"

TIN Preset usage sample

Below is shown how the preset "tin_custom_v1" would be used. The displayed code can be used as-is or adapted as necessary.

TIN Preset Sample
{
  "cameraConfig": {},
  "flashConfig": {},
  "viewPluginConfig": {
    "pluginConfig": {},
    "cutoutConfig": {},
    "scanFeedbackConfig": {},
    "uiFeedbackConfig": {
      "presets": [
        {
          "presetName": "tin_custom_v1",
          "presetAttributes": [
            {
              "attributeName": "lighting_toodark_image",
              "attributeValue": "ic_too_dark"
            },
            {
              "attributeName": "lighting_toobright_image",
              "attributeValue": "ic_too_bright"
            },
            {
              "attributeName": "distance_moveback_image",
              "attributeValue": "ic_move_back"
            },
            {
              "attributeName": "distance_movecloser_image",
              "attributeValue": "ic_move_closer"
            },
            {
              "attributeName": "format_wrong_image",
              "attributeValue": "ic_wrong_format"
            },
            {
              "attributeName": "date_wrong_image",
              "attributeValue": "ic_wrong_date"
            },
            {
              "attributeName": "lighting_toodark_text",
              "attributeValue": "Too dark"
            },
            {
              "attributeName": "lighting_toobright_text",
              "attributeValue": "Too bright"
            },
            {
              "attributeName": "distance_moveback_text",
              "attributeValue": "Position cutout correctly"
            },
            {
              "attributeName": "distance_movecloser_text",
              "attributeValue": "Position cutout correctly"
            },
            {
              "attributeName": "format_wrong_text",
              "attributeValue": "Wrong format detected"
            },
            {
              "attributeName": "date_wrong_text",
              "attributeValue": "Wrong date detected"
            },
            {
              "attributeName": "lighting_toodark_sound",
              "attributeValue": "info_sound_TIN.wav"
            },
            {
              "attributeName": "lighting_toobright_sound",
              "attributeValue": "info_sound_TIN.wav"
            },
            {
              "attributeName": "distance_moveback_sound",
              "attributeValue": "info_sound_TIN.wav"
            },
            {
              "attributeName": "distance_movecloser_sound",
              "attributeValue": "info_sound_TIN.wav"
            },
            {
              "attributeName": "format_wrong_sound",
              "attributeValue": "info_sound_TIN.wav"
            },
            {
              "attributeName": "date_wrong_sound",
              "attributeValue": "info_sound_TIN.wav"
            }
          ]
        }
      ]
    }
  }
}
The following image files are deployed as default on the SDK and can be used on your app: dot_overlay, ic_wrong_format, ic_too_bright, ic_too_dark, ic_move_back, as well as the sound file info_sound_TIN.wav

UIFeedback TIN preset attributes

Find an explanation of all the attributes for the preset "tin_custom_v1" below.

Name Type Description

lighting_toodark_image

Drawable resource

Image shown when the image is too dark to be processed. Advise the user to increase the lighting.

lighting_toobright_image

Drawable resource

Image shown when too much light is being received with the image. Advise the user to reduce the lighting.

distance_moveback_image

Drawable resource

Image shown when the contours detected are out of bounds of cutout. Advise the user to increase distance to scan target.

distance_movecloser_image

Drawable resource

Image shown when the contours detected are too small. Advise the user to decrease distance to scan target.

format_wrong_image

Drawable resource

Image shown when a result format is different then expected

date_wrong_image

Drawable resource

Image shown when a result format is different then expected

lighting_toodark_text

String

Text shown when the image is too dark to be processed

lighting_toobright_text

String

Text shown when too much light is being received with the image

distance_moveback_text

String

Text shown when the contours detected are out of bounds of cutout

distance_movecloser_text

String

Text shown when the contours detected are too small

format_wrong_text

String

Text shown when a result format is different then expected

date_wrong_text

String

Text shown when a result format is different then expected

lighting_toodark_sound

Sound asset

Sound played when the image is too dark to be processed

lighting_toobright_sound

Sound asset

Sound played when too much light is being received with the image

distance_moveback_sound

Sound asset

Sound played when the contours detected are out of bounds of cutout

distance_movecloser_sound

Sound asset

Sound played when the contours detected are too small

format_wrong_sound

Sound asset

Sound played when a result format is different then expected

date_wrong_sound

Sound asset

Sound played when a result format is different then expected

  • Attributes of type Drawable resource refer to a valid image resource identifier

  • Attributes of type Sound asset refer to .wav files inside the asset folder

If any of the feedback resources (images or sounds) are not available at runtime, the plugin will ignore them and continue its execution without breaking or throwing an exception. Refer to Tracing UI Feedback Config for more details.

Tracing UIFeedback Config

If you notice that the feature is not working correctly or some feedback is not being triggered, it is possible to listen to the onUIFeedbackInfo method of ScanViewPlugin to receive messages (information, alerts and errors) about the loading and processing of UIFeedback.

Use the following code on how to receive Event data, after being attached to your scanView.scanViewPlugin.onUIFeedbackInfo.

Receiving Event data from onUIFeedbackInfo Example
scanView.scanViewPlugin.onUIFeedbackInfo = Event { data ->
    data.optJSONArray("messages")?.let { msgArray ->
        for (i in 0 until msgArray.length()) {
            UIFeedbackOverlayInfoEntry.fromJson(msgArray[i] as JSONObject).also { msgEntry ->
                when (msgEntry.level) {
                    UIFeedbackOverlayInfoEntry.Level.Info -> Log.d("onUIFeedbackInfo", msgEntry.message)
                    UIFeedbackOverlayInfoEntry.Level.Warning -> Log.w("onUIFeedbackInfo", msgEntry.message)
                    UIFeedbackOverlayInfoEntry.Level.Error -> Log.e("onUIFeedbackInfo", msgEntry.message)
                }
            }
        }
    }
}

In your LogCat output you will then find the Event data, similar to the example below.

Tracing UIFeedback Logcat sample
 I  onUIFeedbackInfo: RunSkipped triggered for element feedback_image.
 I  onUIFeedbackInfo: RunSkipped triggered for element feedback_text.
 I  onUIFeedbackInfo: RunSkipped triggered for element feedback_sound.
 W  onUIFeedbackInfo: Sound not found for resource info_sound_TIN2.wav.