public class SmartScannerLegacy extends SmartScanner
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
DEFAULT_MINIMAL_SCORE, ID_AUTO_FOCUS, ID_DEBUG, ID_DECODE, ID_DECODE_FAILED, ID_DECODE_SUCCEEDED, ID_LAUNCH_PRODUCT_QUERY, ID_PAUSE_DECODING, ID_QUIT, ID_RESUME_DECODING, LEVEL_3, LEVEL_FULL, LEVEL_LIMITED, NO_CAMERA_ID
Constructor and Description |
---|
SmartScannerLegacy(android.content.Context ctx)
Instantiate the SmartScanner object.
|
Modifier and Type | Method and Description |
---|---|
CameraControllerLegacy |
getCameraController()
Gets CameraControllerLegacy used to interact with the device
|
android.content.Context |
getContext()
Get the context.
|
SmartScannerHandlerLegacy |
getHandler()
Gets the smartscanner app thread Handler that binds with decoding thread
|
java.lang.String |
getIcareDecodersSDKDescription()
Prints the native SDK build description.
|
android.graphics.Rect |
getRegionOfInterest()
Get current region of interest.
|
java.lang.String |
getTypeSmartscan()
Return the smartscan library activated.
|
java.lang.String |
getVersion()
Displays smartscan java library information.
|
void |
handleDecoderResult(DecodedResult decodedResult)
A valid result has been found, so execute callback if given.
|
void |
init()
Initializes the SmartScanner library objects and processes.
|
boolean |
isFlashAvailable()
Checks if flashlight is available on device.
|
boolean |
isZoomSupported()
Get the information about the availability of the zoom .
|
void |
manualFocus(float x,
float y,
android.view.View view,
boolean isFocusRectangleVisible)
On double tap we switch to manual focus.
|
void |
pauseDecoding()
Pauses the decoding process.
|
void |
release()
This methods frees memory by releasing objects and processes used by SmartScanner.
|
void |
restartDecoding()
Restarts the decoding process.
|
void |
setAutoFocusEnabled(boolean isAutoFocusEnabled)
If not already activated we turn on the auto focus.
|
void |
setBeepOn(int beepResId)
Enables and set the beep sound when a scan is done.
|
void |
setCameraId(int cameraId)
Sets the camera to use.
|
void |
setCanvasDrawer(CanvasDrawerInterface canvasDrawer)
Sets the CanvasDrawer, ie. the view that displays the target.
|
void |
setContinuousDecoding(boolean isContinuousDecoding)
Restarts decoding as soon as a result has been found, without manual call to
restartDecoding . |
void |
setDebugView(android.view.SurfaceView view)
Defines the SurfaceView holding the debug preview, inside your layout.
|
void |
setDecodingType(long decodingType,
long decodingSubType)
Sets the decoder to use.
|
void |
setFlashEnabled(boolean isFlashEnabled)
Enables/Disables the flashlight LED during the scanning process
|
void |
setOnErrorListener(OnDecoderErrorListener listener) |
void |
setOnLoadedListener(OnDecoderLoadedListener listener) |
void |
setOnResultListener(OnDecoderResultFoundListener listener)
Setting the listeners for the application.
|
void |
setRegionOfInterest(android.graphics.Rect rect)
Allows to manually set the region of interest.
|
void |
setTextureView(AutoFitTextureView textureView)
Defines the AutoFitTextureView holding the camera preview, inside your layout.
|
void |
setVibrateOn(boolean enabled)
Enables the vibration when a scan is done.
|
void |
setVisualDebug(boolean visualDebug)
Activate the visualdebug.
|
void |
setZoomCamera(int zoom)
Set the zoom of the camera.
|
public SmartScannerLegacy(android.content.Context ctx)
ctx
- Context. Application Context will be derived from this to avoid leaks.public java.lang.String getTypeSmartscan()
getTypeSmartscan
in class SmartScanner
public void setOnResultListener(OnDecoderResultFoundListener listener)
setOnResultListener
in class SmartScanner
public void setOnLoadedListener(OnDecoderLoadedListener listener)
setOnLoadedListener
in class SmartScanner
public void setOnErrorListener(OnDecoderErrorListener listener)
setOnErrorListener
in class SmartScanner
public android.content.Context getContext()
getContext
in class SmartScanner
public void setVisualDebug(boolean visualDebug)
setVisualDebug
in class SmartScanner
visualDebug
- Set the state of the visual degub on the library. To work correctly you
need to implement a surface in the layout and make some modifications in
your main activity. See Readme file.public java.lang.String getIcareDecodersSDKDescription()
getIcareDecodersSDKDescription
in class SmartScanner
public void setContinuousDecoding(boolean isContinuousDecoding)
restartDecoding
. Default is false.setContinuousDecoding
in class SmartScanner
isContinuousDecoding
- true if the decoder should decode continuously, false to pause after resultpublic void setBeepOn(int beepResId)
setBeepOn
in class SmartScanner
beepResId
- int resource id of the sound file.public void setVibrateOn(boolean enabled)
setVibrateOn
in class SmartScanner
enabled
- Sets the state of the vibration on the device.public void setFlashEnabled(boolean isFlashEnabled)
setFlashEnabled
in class SmartScanner
isFlashEnabled
- Sets the state of the flash on the device.public boolean isFlashAvailable()
init
because it needs to access the camera instance.
For example, a safe place to call this method is in your implementation of
{link OnDecoderLoadedListener.onDecoderLoaded() OnDecoderLoadedListener.onDecoderLoaded }.
For a more straightforward but less reliable method, you can use
getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)
on your activity.isFlashAvailable
in class SmartScanner
public void setDecodingType(long decodingType, long decodingSubType)
SmartScanner
Bitwise
combinations can be used to specify multiple decoding types.setDecodingType
in class SmartScanner
decodingType
- Decoding typedecodingSubType
- Decoding subtypepublic void setRegionOfInterest(android.graphics.Rect rect)
setRegionOfInterest
in class SmartScanner
rect
- Rect representation of the region of interestpublic void setTextureView(AutoFitTextureView textureView)
setTextureView
in class SmartScanner
textureView
- AutoFitTextureView view instancepublic void setCanvasDrawer(CanvasDrawerInterface canvasDrawer)
setCanvasDrawer
in class SmartScanner
canvasDrawer
- view that implement CanvasDrawerInterfacepublic void setDebugView(android.view.SurfaceView view)
setDebugView
in class SmartScanner
view
- SurfaceView view instancepublic SmartScannerHandlerLegacy getHandler()
getHandler
in class SmartScanner
SmartScannerHandlerLegacy
public CameraControllerLegacy getCameraController()
getCameraController
in class SmartScanner
CameraControllerLegacy
public java.lang.String getVersion()
getVersion
in class SmartScanner
public void setCameraId(int cameraId)
cameraId
- int camera id. On most devices 0 is the first back facing camera.public void init()
OnDecoderLoadedListener#onDecoderLoaded(Rect), OnDecoderLoadedListener.onDecoderLoaded
occurs.init
in class SmartScanner
public void release()
release
in class SmartScanner
public void handleDecoderResult(DecodedResult decodedResult)
OnDecoderResultFoundListener#onResultFound(DecodedResult), OnDecoderResultListener.onResultFound
Restarts decoding if continuous decoding is enabled.
This method is called internally.handleDecoderResult
in class SmartScanner
decodedResult
- DecodedResult objectpublic void restartDecoding()
setContinuousDecoding
is false.restartDecoding
in class SmartScanner
public void pauseDecoding()
restartDecoding
.pauseDecoding
in class SmartScanner
public android.graphics.Rect getRegionOfInterest()
getRegionOfInterest
in class SmartScanner
public boolean isZoomSupported()
isZoomSupported
in class SmartScanner
public void setZoomCamera(int zoom)
setZoomCamera
in class SmartScanner
zoom
- Level of the zoom to set for the camera.public void manualFocus(float x, float y, android.view.View view, boolean isFocusRectangleVisible)
manualFocus
in class SmartScanner
x
- Position on x axis on the screeny
- Position on y axis on the screenview
- View where we will draw the focus rectangleisFocusRectangleVisible
- Option to draw the focus rectangle or notpublic void setAutoFocusEnabled(boolean isAutoFocusEnabled)
setAutoFocusEnabled
in class SmartScanner
isAutoFocusEnabled
- Boolean to activate/deactivate the autofocus.