Class FieldByFieldElement
java.lang.Object
com.microblink.photopay.entities.parsers.config.fieldbyfield.FieldByFieldElement
- All Implemented Interfaces:
android.os.Parcelable
Configuration for single scan field used in
FieldByFieldOverlayController
and
FieldByFieldScanActivity
.
This class will hold a combination of parser, parser title (shown in UI) and
parser message (shown in UI). Additionally, it can be used to set the scan region size and control
whether the scan field is optional or mandatory.-
Nested Class Summary
-
Field Summary
FieldsFields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Constructor Summary
ConstructorsConstructorDescriptionFieldByFieldElement
(int titleResource, int textResource, Parser<?> parser) Constructor which takes string resource ID's for string that will appear in UI.FieldByFieldElement
(String title, String text, Parser<?> parser) Constructor which takes normal strings for text that appears in UI. -
Method Summary
Modifier and TypeMethodDescriptionint
Parser<?>
Returns parser that is used for this scan element.float
Returns the current scan region height, represented as percentage of maximal allowed scan region height.float
Returns the current scan region width, represented as percentage of maximal allowed scan region width.float
Returns the current height of the scan region that will be shown to the user, represented as percentage of maximal allowed scan region height.float
Returns the current width of the scan region that will be shown to the user, represented as percentage of maximal allowed scan region width.getText
(android.content.Context ctx) Returns the text that will be displayed when parser is active.int
Returns the resource ID representing text that will be displayed when parser is active.getTitle
(android.content.Context ctx) Returns title that will be displayed.int
Returns the resource ID representing title that will be displayed or 0 if resource ID is not available.boolean
Returns whether scan field with this configuration is optional.void
setOptional
(boolean optional) Sets the flag that indicates whether this scan configuration is optional, which means that the data from the scan field with this configuration is not mandatory and can be skipped by user.void
Sets the parser that will be used for this scan element.void
setScanRegionRelativeHeight
(float scanRegionRelativeHeight) Sets the scan region height, represented as percentage of maximal allowed scan region height.void
setScanRegionRelativeWidth
(float scanRegionRelativeWidth) Sets the scan region width, represented as percentage of maximal allowed scan region width.void
setShownScanRegionRelativeHeight
(float shownScanRegionRelativeHeight) Sets the height of the scan region that will be shown to the user, represented as percentage of maximal allowed scan region height.void
setShownScanRegionRelativeWidth
(float shownScanRegionRelativeWidth) Sets the width of the scan region that will be shown to the user, represented as percentage of maximal allowed scan region width.void
Sets the text that will be displayed when parser is active.void
setTextResource
(int textResource) Sets the resource ID representing text that will be displayed when parser is active.void
Sets the title that will be displayed.void
setTitleResource
(int titleResource) Sets the resource ID representing title that will be displayed.toString()
void
writeToParcel
(android.os.Parcel dest, int flags)
-
Field Details
-
CREATOR
-
-
Constructor Details
-
FieldByFieldElement
public FieldByFieldElement(@StringRes int titleResource, @StringRes int textResource, @NonNull Parser<?> parser) Constructor which takes string resource ID's for string that will appear in UI.- Parameters:
titleResource
- String resource ID representing parser title displayed.textResource
- String resource ID representing message that will be displayed when parser is active.parser
- Parser that will be used for this scan element.
-
FieldByFieldElement
Constructor which takes normal strings for text that appears in UI.- Parameters:
title
- Parser title displayed.text
- Message that will be displayed when parser is active.parser
- Parser that will be used for this scan element.
-
-
Method Details
-
setTitle
Sets the title that will be displayed. This overrides title that will be loaded from resources (seesetTitleResource(int)
). Set to null to use resource set withsetTitleResource(int)
.- Parameters:
title
- Title that will be displayed or null to use resource set withsetTitleResource(int)
.
-
getTitle
Returns title that will be displayed. If title was set as string withsetTitle(String)
, that string will be returned. If title was set as resource withsetTitleResource(int)
, string resource will be resolved and resolved string will be returned.- Parameters:
ctx
- Context used for resolving string resource set withsetTitleResource(int)
.- Returns:
- Title that will be displayed.
-
getTitleResource
@StringRes public int getTitleResource()Returns the resource ID representing title that will be displayed or 0 if resource ID is not available.- Returns:
- the resource ID representing title that will be displayed or 0 if resource ID is not available.
-
setTitleResource
public void setTitleResource(@StringRes int titleResource) Sets the resource ID representing title that will be displayed.- Parameters:
titleResource
- String reosource representing title that will be displayed.
-
getTextResource
@StringRes public int getTextResource()Returns the resource ID representing text that will be displayed when parser is active.- Returns:
- the resource ID representing text that will be displayed when parser is active.
-
setTextResource
public void setTextResource(@StringRes int textResource) Sets the resource ID representing text that will be displayed when parser is active.- Parameters:
textResource
- the resource ID representing text that will be displayed when parser is active.
-
getText
Returns the text that will be displayed when parser is active. If text was set withsetText(String)
, the same string is returned. If text was set withsetTextResource(int)
, the text resource ID will be resolved and resolved string will be returned.- Parameters:
ctx
- Context used to resolve string resource.- Returns:
- Text that will be displayed when parser is active.
-
setText
Sets the text that will be displayed when parser is active. This overrides string resource set withsetTextResource(int)
. Set the text to null to use text loaded from resource set withsetTextResource(int)
.- Parameters:
text
- text that will be displayed when parser is active or null to use resource set withsetTextResource(int)
.
-
getParser
Returns parser that is used for this scan element.- Returns:
- the parser that is used for this scan element.
-
setParser
Sets the parser that will be used for this scan element.- Parameters:
parser
- parser that will be used for this scan element.
-
isOptional
public boolean isOptional()Returns whether scan field with this configuration is optional. SeesetOptional(boolean)
(boolean)}.- Returns:
- whether scan field with this configuration is optional. See
setOptional(boolean)
(boolean)}.
-
setOptional
public void setOptional(boolean optional) Sets the flag that indicates whether this scan configuration is optional, which means that the data from the scan field with this configuration is not mandatory and can be skipped by user. By default, this flag is set tofalse
and the scan field is mandatory.- Parameters:
optional
- If set totrue
, scan field with this configuration is optional and user can skip it, otherwise the scan field is mandatory.
-
getScanRegionRelativeWidth
public float getScanRegionRelativeWidth()Returns the current scan region width, represented as percentage of maximal allowed scan region width.- Returns:
- current scan region width, represented as percentage of maximal allowed scan region width.
-
setScanRegionRelativeWidth
public void setScanRegionRelativeWidth(@FloatRange(from=0.0,to=1.0) float scanRegionRelativeWidth) Sets the scan region width, represented as percentage of maximal allowed scan region width.- Parameters:
scanRegionRelativeWidth
- scan region width, represented as percentage of maximal allowed scan region width.
-
getScanRegionRelativeHeight
public float getScanRegionRelativeHeight()Returns the current scan region height, represented as percentage of maximal allowed scan region height.- Returns:
- current scan region height, represented as percentage of maximal allowed scan region height.
-
setScanRegionRelativeHeight
public void setScanRegionRelativeHeight(@FloatRange(from=0.0,to=1.0) float scanRegionRelativeHeight) Sets the scan region height, represented as percentage of maximal allowed scan region height.- Parameters:
scanRegionRelativeHeight
- scan region height, represented as percentage of maximal allowed scan region height.
-
getShownScanRegionRelativeWidth
public float getShownScanRegionRelativeWidth()Returns the current width of the scan region that will be shown to the user, represented as percentage of maximal allowed scan region width. It can be different from the scan region width that is used for scanning (OCR).- Returns:
- current width of the scan region that will be shown to the user, represented as percentage of maximal allowed scan region width.
-
setShownScanRegionRelativeWidth
public void setShownScanRegionRelativeWidth(@FloatRange(from=0.0,to=1.0) float shownScanRegionRelativeWidth) Sets the width of the scan region that will be shown to the user, represented as percentage of maximal allowed scan region width. It can be different from scan region width that is used for scanning (OCR). This option can be used to ensure that all characters that are important for current parser will be scanned and available for parsing. If the width of the shown scan region is not set, it will be equal to the width of the scan region that is used for scanning (OCR).- Parameters:
shownScanRegionRelativeWidth
- width of the scan region that will be shown to the user, represented as percentage of maximal allowed scan region width.
-
getShownScanRegionRelativeHeight
public float getShownScanRegionRelativeHeight()Returns the current height of the scan region that will be shown to the user, represented as percentage of maximal allowed scan region height. It can be different from the height of the scan region that is used for scanning (OCR).- Returns:
- height of the current scan region that will be shown to the user, represented as percentage of maximal allowed scan region height.
-
setShownScanRegionRelativeHeight
public void setShownScanRegionRelativeHeight(@FloatRange(from=0.0,to=1.0) float shownScanRegionRelativeHeight) Sets the height of the scan region that will be shown to the user, represented as percentage of maximal allowed scan region height. It can be different from the height of the scan region that is used for scanning (OCR). This option can be used to ensure that all characters that are important for current parser will be scanned and available for parsing. If the height of the shown scan region is not set, it will be equal to the height of the scan region that is used for scanning (OCR).- Parameters:
shownScanRegionRelativeHeight
- scan region height that will be shown to the user, represented as percentage of maximal allowed scan region height.
-
toString
-
describeContents
public int describeContents()- Specified by:
describeContents
in interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(@NonNull android.os.Parcel dest, int flags) - Specified by:
writeToParcel
in interfaceandroid.os.Parcelable
-