View Configuration

Create AnylineViewPlugin via View Configuration

With Anyline 4, with the View Configuration, you can also define the Scan Plugin and declare the parameters specifics for the Scan Plugin.

With the Anyline View Configuration, you can define the Look & Feel of your scanning app.

The configuration parameters define the visual information presented to the user, as well as the scan settings (like the resolution, etc.) and feedback that is presented to the user.

Anyline View Configuration Parameters

The full parameter list of the configuration can be found at Anyline View Configuration

How to add the View Configuration

Load View Configuration via JSON

The first option is to include the View Configuration in a separated JSON file, load it in the onCreate() method of your Activity and set it to your ScanView.

You can place the JSON file in your assets folder. From there it can be loaded via one of the following snippets.

Warning

With Anyline 4, there are multiple ways to load the View configuration. As configurations were splited in base configuration (configuration for camera and flash) and view configuration (configurations wich holds the cutout and the scan feedback properties), in Android you have to load them as showed bellow.

Load Base Configuration via JSON (1)
        ScanViewPluginConfig ocrScanViewPluginConfig = new ScanViewPluginConfig(getApplicationContext(), "isbn_view_config.json");
Load ScanFeedback Configuration via JSON (1)
        //init the base config used for camera and flash
        BaseScanViewConfig ocrBaseScanViewConfig = new BaseScanViewConfig(getApplicationContext(), "isbn_view_config.json");
        //set the scan Base config
        scanView.setScanViewConfig(ocrBaseScanViewConfig);

Warning

With Anyline 4, there is also another way to set the configuration once. In this way will be set the ScanViewPluginConfig to the scanView, therefore when initializing the ScanViewPlugin, the configuration should be taken via getScanViewPluginConfig() like in the code bellow.

Load Configuration via JSON(2)
    //initialise the view configuration
    mrzScanView.setScanConfig("mrz_view_config.json");
    //init the scan view
    IdScanViewPlugin scanViewPlugin = new IdScanViewPlugin(getApplicationContext(), getString(R.string.anyline_license_key), mrzScanView.getScanViewPluginConfig(), mrzConfig);

Warning

While you have declared the plugin inside the JSON file, the scanViewPlugin instantiation is not needed anymore and you can init directly everything from JSON with the following code:

Load Configuration via JSON When Scan Plugin is Inside the JSON
    //initialise the view configuration
    try {
        scanView.init("voucher_code_view_config.json", getString(R.string.anyline_license_key));
    } catch (Exception e) {
        e.printStackTrace();
    }

Changing Configuration Values

Please be aware that after a change in the configuration, the configuration has to be set to the scanView again.