Developed by scan service: Difference between revisions

From wizarPOS
Line 160: Line 160:


In overlay mode, the camera scanner service only provide the scanner window, the window will display on top of the third app UI. So the third app can draw the UI by itself, such as the title, the buttons. In this mode, if the app need to switch the camera, the flash light, the indicator light, it must use the broadcast like belows:
In overlay mode, the camera scanner service only provide the scanner window, the window will display on top of the third app UI. So the third app can draw the UI by itself, such as the title, the buttons. In this mode, if the app need to switch the camera, the flash light, the indicator light, it must use the broadcast like belows:
* <big>Camera</big>:
* <big>Camera</big>:



Revision as of 08:01, 20 April 2018

The scan service ,which is an app and started by using AIDL and the third apps custom their UI through by transfer some parameters, provides convenient services that include scaning bar code and getting result of scanning for comsumers.

Introduction

There are many applications are developed based on smart POS. In one thing, many of the Smart POS developers also have POS industry background,but not professional Android developers. So when they start developing applications, they want to be provided with a convenient scan API by WizarPOS, instead of learning Zxing/Zbar themselves.In other thing,from the hardware point of view, the scan parts used on smart POS, are not necessarily the standard camera, there will be some transformation. In some cases, the scan part will be required to be a specialized hardware. Therefore, the direct use of Zxing/Zbar is not really applicable for WizarPOS smart POS, but need some modification and customization.
For the reasons above, we consider to develop WizarPOS Scan Services to facilitate the third party developers in developing applications with scan function.

Interface

scanBarcode

scanBarcode is a synchronous calling interface.

After the application calls the interface, the scan service opens the camera defined by the scan parameter and then starts the scan. Once getting the result of scanning, the camera is closes and the results are returned immediately.

Parameter: Scan parameter

Return: Scan result

startScan

startScan is an asynchronous call interface and indicating the continuous scanning is started.

After the application calls this interface, the scan service opens the camera defined by the scan parameter and starts the scan. After every single scanning, the results will be returned during the callback. After each callback is done, the next scanning continue to run starts.

Parameter:Scan parameter, IScanCallBack

Return: void

foundBarcode

foundBarcode is a function of IScanCallBack that is a parameter of previous interface.

The caller can get the Scan Result through this interface. When this interface is called, the scan service is in the pause state, and when the call in returned, then the next scanning will be continued. You can turn off the scan service that is in pause with “stopScan” that is another interface .

Parameter: ScanResult

Return:Void

stopScan

This interface Stops the continuous scan, and closes the scan service's UI.

After stop, other callers can call startScan, or scanBarcode interface.

Return: true / false.

Description

Scan Parameter

Scan Parameter is a parameter object, it defines the parameters that need by the scan service. method: set(String key, String value) (Value Not case sensitive)

Key Value Type Value Description
window_top int Default: 0,Range: >0 The distance to the screen top. Effect in overlaymode.(dp)
window_left int Default: 0,Range: >0 The distance to the screen left. Effect in overlaymode.(dp)
window_width int Default: screen width,Range: >0 Screen width. Effect in overlaymode.(dp)
window_height int Default: screen ,Range: >0 Screen hight. Effect in overlaymode.(dp)
enable_scan_section boolean Default: true False: all the display window is the area for scanner, remove the scanner frame.

True: customize the area of the scanner, has a scanner frame, the other part is semitransparent, the scanner frame is in center, can adjust the width or the height of the scanner frame.

scan_section_width int Default: 300dip,Range: >0 The width of the scanner frame.
scan_section_height int Default: 300dip,Range: >0 The height of the scanner frame.
display_scan_line String Default: moving,Range: No/fixed/moving Display the red line in scanner area.

NO: Not display Fixed: In center Moving: Move up and down.(dp)

enable_flash_icon boolean Q1): (T|F) Whether to display the hover button of controlling the flash.
enable_switch_icon boolean Default: T Whether to display the hover button of switching camera.
enable_indicator_light boolean Default: F Whether to display the indicator light button, only supported in Q1.
decodeformat String Default: BARCODE_ALL Decode format range.Default is BARCODE_ALL,the formats are separated by “,”.
decoder_mode int Default: 2,Range:0-2 Decode mode:

0: mode1 1: mode2 2: mode3

enable_return_image boolean Default: F Whether to return the scanned image.
camera_index int Default: 0,Range:0-2 0: fixed camera.

1:zomm camera. 2:customer display camera

scan_time_out long (ms) Default: -1,Range: >0 <=0:scan forever

>0:scan with timeout,when timeout, return timeout error, only effected in synchronized interface.

scan_section_border_color int Default: Color.WHITE The color of scan border, use Color.argb
scan_section_corner_color int Default: Color.argb(0xFF,0x21, 0xDB, 0xD5) The color of the scan corner
scan_section_line_color int Default: Color.RED The color of the scan line
scan_tip_textSize int Default: 15 The size of the tip text Unit: sp
scan_tip_textColor int Default: Color.WHITE The distance between the tip text and the bottom of the screen Unit: dp
scan_tip_textMargin int Default: 30 The distance between thetip text and the bottom of the screen Unit: dp
flash_light_state boolean Default: F Initial state of indicator light

true: opened false: closed

indicator_light_state iboolean Default: F Initial state of indicator light

true: opened false: closed

scan_mode String Default: dialog Scanner window mode dialog: activity with specified UI

overlay:only has scanner window, without UItitles, UI buttons, the scanner window on top of other UI activities

scan_camera_exposure int Default: 0 Camera exposure compensation for zoom camera
scan_time_limit int Default: 50 The max decode time
enable_mirror_scan boolean Default: T Enable mirror scan Default is true, opened
Scan Mode

In dialog mode, the scanner UI has drawed by the camera scanner service, the third app don’t need to consider about the UI.

In overlay mode, the camera scanner service only provide the scanner window, the window will display on top of the third app UI. So the third app can draw the UI by itself, such as the title, the buttons. In this mode, if the app need to switch the camera, the flash light, the indicator light, it must use the broadcast like belows:

  • Camera:

Broadcast Action : com.wizarpos.scanner.setcamera

Broadcast Key: overlay_config

Value: 0 Fixed camera;1 zoom camera; 2 customer display* camera

  • Flash light:

Broadcast Action : com.wizarpos.scanner.setflashlight

Broadcast Key: overlay_config

Value: true opened; false closed

  • Indicator light:

Broadcast Action : com.wizarpos.scanner.setindicator

Broadcast Key : overlay_config

Value: true opened; false closed

Scan Result
Error Code