Skip to main content

ProGlove Documentation

Button-blocking

The button-blocking feature allows you to block or unblock certain button gestures on a scanner connected to Insight Mobile. This makes it impossible to scan any barcodes, receive certain button events, or take photos with the scanner until the block is resolved.

Use it in situations where the worker needs to perform an action outside of the regular workflow, like an acknowledgement of an error.

Depending on the blocking command, the button can be enabled again either by a predefined action of the worker or by sending the unblocking command.

Turn on button-blocking

To block the button, call blockPgTrigger() on your PgManager reference with the following parameters:

  • PgCommand object holding the BlockPgTriggersParams and an optional PgCommandParams, where BlockPgTriggersParams consists of:

    • blockByTriggers - List of PredefinedPgTrigger button gestures to block. If empty and [block] is true, all known button gestures will be blocked

    • unblockByTriggers - List of PredefinedPgTrigger button gestures that unblock the blocked buttons

    • durationMs - The duration that the button should be blocked, in milliseconds. A value of 0 will block the button indefinitely

      Note

      If you are using scanners with firmware version lower than v2.5.0 durationMs value will be ignored.

    • block - True

  • The object implementing IBlockPgTriggersCallback. After the button is successfully blocked (or in case of any errors), the IBlockPgTriggersCallback is called with the relevant information.

You can also broadcast an Intent with the following data:

  • Action: com.proglove.api.BLOCK_TRIGGER

  • Extras:

    • com.proglove.api.extra.TRIGGERS_BLOCK - Array of button gestures (identified by a string) to block. If empty, all known button gestures will be blocked. The allowed values:

      • BUTTON_1_SINGLE_CLICK

      • BUTTON_1_DOUBLE_CLICK

      • BUTTON_1_TRIPLE_CLICK

      Note

      If you do not send this extra, the single-press will be blocked.

    • com.proglove.api.extra.TRIGGERS_UNBLOCK_BY - Array of button gestures (identified by a string) that unblock the blocked buttons. The allowed values:

      • BUTTON_1_SINGLE_CLICK

      • BUTTON_1_DOUBLE_CLICK

      • BUTTON_1_TRIPLE_CLICK

      Note

      If you do not send this extra, the double-press unblocks the button.

    • com.proglove.api.extra.DURATION - The duration in milliseconds (integer) that the button should be blocked. A value of 0 will block the button indefinitely

      Note

      If you do not send this extra, the button will be blocked indefinitely.

      If you are using scanners with firmware version lower than v2.5.0 this extra will be ignored.

Example 66. Block the single-press button for 10 seconds
Example 67. SDK
val blockParams = BlockPgTriggersParams(
    blockTriggers = listOf(PredefinedPgTrigger.DefaultPgTrigger),
    unblockByTriggers = emptyList(),
    durationMs = 10000,
    block = true
)

pgManager.blockPgTrigger(
    PgCommand(blockParams),
    object : IBlockPgTriggersCallback {
        override fun onBlockTriggersCommandSuccess() {
            runOnUiThread {
                Toast.makeText(
                    applicationContext,
                    "Blocking trigger(s) success",
                    Toast.LENGTH_LONG
                ).show()
                lastResponseValue.text = getString(R.string.block_trigger_success)
            }
        }

        override fun onError(error: PgError) {
            runOnUiThread {
                Toast.makeText(
                    applicationContext,
                    "Failed to block the trigger(s): $error",
                    Toast.LENGTH_LONG
                ).show()
                lastResponseValue.text = error.toString()
            }
        }
    })


Example 68. Intent
val intent = Intent().apply {
    action = "com.proglove.api.BLOCK_TRIGGER"
    putExtra("com.proglove.api.extra.TRIGGERS_BLOCK", arrayOf("BUTTON_1_SINGLE_CLICK"))
    putExtra("com.proglove.api.extra.TRIGGERS_UNBLOCK_BY", emptyArray<String>())
    putExtra("com.proglove.api.extra.DURATION", 10000)
}
sendBroadcast(intent)




Example 69. Block all buttons
Example 70. SDK
val blockParams = BlockPgTriggersParams(
    blockTriggers = emptyList(),
    unblockByTriggers = emptyList(),
    durationMs = 0,
    block = true
)

pgManager.blockPgTrigger(
    PgCommand(blockParams),
    object : IBlockPgTriggersCallback {
        override fun onBlockTriggersCommandSuccess() {
            runOnUiThread {
                Toast.makeText(
                    applicationContext,
                    "Blocking trigger(s) success",
                    Toast.LENGTH_LONG
                ).show()
                lastResponseValue.text = getString(R.string.block_trigger_success)
            }
        }

        override fun onError(error: PgError) {
            runOnUiThread {
                Toast.makeText(
                    applicationContext,
                    "Failed to block the trigger(s): $error",
                    Toast.LENGTH_LONG
                ).show()
                lastResponseValue.text = error.toString()
            }
        }
    })


Example 71. Intent
val intent = Intent().apply {
    action = "com.proglove.api.BLOCK_TRIGGER"
    putExtra("com.proglove.api.extra.TRIGGERS_BLOCK", emptyArray<String>())
    putExtra("com.proglove.api.extra.TRIGGERS_UNBLOCK_BY", emptyArray<String>())
    putExtra("com.proglove.api.extra.DURATION", 0)
}
sendBroadcast(intent)




Example 72. Block scanning until the worker confirms with a double-press
Example 73. SDK
val blockParams = BlockPgTriggersParams(
    blockTriggers = listOf(PredefinedPgTrigger.DefaultPgTrigger),
    unblockByTriggers = listOf(PredefinedPgTrigger.DoubleClickMainPgTrigger),
    durationMs = 0,
    block = true
)

pgManager.blockPgTrigger(
    PgCommand(blockParams),
    object : IBlockPgTriggersCallback {
        override fun onBlockTriggersCommandSuccess() {
            runOnUiThread {
                Toast.makeText(
                    applicationContext,
                    "Blocking trigger(s) success",
                    Toast.LENGTH_LONG
                ).show()
                lastResponseValue.text = getString(R.string.block_trigger_success)
            }
        }

        override fun onError(error: PgError) {
            runOnUiThread {
                Toast.makeText(
                    applicationContext,
                    "Failed to block the trigger(s): $error",
                    Toast.LENGTH_LONG
                ).show()
                lastResponseValue.text = error.toString()
            }
        }
    })
Example 74. Intent
val intent = Intent().apply {
    action = "com.proglove.api.BLOCK_TRIGGER"
    putExtra("com.proglove.api.extra.TRIGGERS_BLOCK", arrayOf("BUTTON_1_SINGLE_CLICK"))
    putExtra("com.proglove.api.extra.TRIGGERS_UNBLOCK_BY", arrayOf("BUTTON_1_DOUBLE_CLICK"))
    putExtra("com.proglove.api.extra.DURATION", 0)
}
sendBroadcast(intent)






Turn off button-blocking

To unblock the button, call blockTrigger() on PgManager reference with the following parameters:

  • PgCommand object holding the BlockPgTriggersParams and an optional PgCommandParams, where BlockPgTriggersParams consists of:

    • blockByTriggers - Empty list

    • unblockByTriggers - Empty list

    • durationMs - 0

    • block - False

  • The object implementing IBlockPgTriggersCallback. After the button is successfully unblocked (or in case of any errors), the IBlockPgTriggersCallback is called with the relevant information.

You can also broadcast an Intent with the following data:

  • Action: com.proglove.api.UNBLOCK_TRIGGER

  • No Extras

Example 75. SDK
val blockParams = BlockPgTriggersParams(
    blockTriggers = emptyList(),
    unblockByTriggers = emptyList(),
    durationMs = 0,
    block = false
)

pgManager.blockPgTrigger(
    PgCommand(blockParams),
    object : IBlockPgTriggersCallback {
        override fun onBlockTriggersCommandSuccess() {
            runOnUiThread {
                Toast.makeText(
                    applicationContext,
                    "Unblocking triggers success",
                    Toast.LENGTH_LONG
                ).show()
                lastResponseValue.text = getString(R.string.block_trigger_success)
            }
        }

        override fun onError(error: PgError) {
            runOnUiThread {
                Toast.makeText(
                    applicationContext,
                    "Failed to unblock the triggers: $error",
                    Toast.LENGTH_LONG
                ).show()
                lastResponseValue.text = error.toString()
            }
        }
    })


Example 76. Intent
val intent = Intent().apply {
    action = "com.proglove.api.UNBLOCK_TRIGGER"
}
sendBroadcast(intent)


Another way to unblock the button is to use the button gestures specified in the unblockByTriggers or com.proglove.api.extra.TRIGGERS_UNBLOCK_BY under Turn on button-blocking.

You can also wait for the blocking timeout specified in the durationMs or com.proglove.api.extra.DURATION under Turn on button-blocking to expire.

  • Action: com.proglove.api.TRIGGER_UNBLOCKED

  • No Extras

To get this, call the pgManager.subscribeToPgTriggersUnblocked() function and implement the ITriggersUnblockedOutput interface.

For example, in the same onCreate of our sample app we subscribe to the button unblocked info, and we unsubscribe in the onDestroy() function.

Example 77. SDK
override fun onCreate(savedInstanceState: Bundle?) {
     //...
     pgManager.subscribeToPgTriggersUnblocked(this)
     //...
}

override fun onDestroy() {
     super.onDestroy()
     //...
     pgManager.unsubscribeFromPgTriggersUnblocked(this)
}

// To do this, our Activity needs to implement the `ITriggersUnblockedOutput` interface:

//
// -- ITriggersUnblockedOutput --
//

override fun onPgTriggersUnblocked() {
    // the trigger unblocked events will come on background threads, make sure to execute this on the UI Thread
    runOnUiThread {
        Toast.makeText(this, "Triggers unblocked", Toast.LENGTH_SHORT).show()
    }
}


Example 78. Intent
// 1 Implement a broadcast receiver (in this case the class is called MessageHandler):

class MessageHandler : BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {
        if (intent != null && intent.action == "com.proglove.api.TRIGGER_UNBLOCKED") {
            // Triggers unblocked
        }
    }
} 

// 2 define an IntentFilter filtering for the specified actions:

val messageHandler: MessageHandler = MessageHandler()
val filter = IntentFilter()
filter.addAction("com.proglove.api.TRIGGER_UNBLOCKED")
filter.addCategory(Intent.CATEGORY_DEFAULT)

// 3 Somewhere where a context is available (usually an Activity's or Service's onCreate):

context.registerReceiver(messageHandler, filter) 

// Do not forget to unregister the receiver again, for example in onDestroy:

context.unregisterReceiver(messageHandler)


When the button is unblocked, scanning, receiving button events and taking photos with scanner are enabled again.