public class FieldByFieldElement
extends java.lang.Object
implements android.os.Parcelable
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.Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator |
CREATOR |
Constructor and Description |
---|
FieldByFieldElement(int titleResource,
int textResource,
Parser parser)
Constructor which takes string resource ID's for string that will appear in UI.
|
FieldByFieldElement(java.lang.String title,
java.lang.String text,
Parser parser)
Constructor which takes normal strings for text that appears in UI.
|
Modifier and Type | Method and Description |
---|---|
int |
describeContents() |
Parser |
getParser()
Returns parser that is used for this scan element.
|
float |
getScanRegionRelativeHeight()
Returns the current scan region height, represented as percentage of maximal allowed scan region height.
|
float |
getScanRegionRelativeWidth()
Returns the current scan region width, represented as percentage of maximal allowed scan region width.
|
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.
|
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.
|
java.lang.String |
getText(android.content.Context ctx)
Returns the text that will be displayed when parser is active.
|
int |
getTextResource()
Returns the resource ID representing text that will be displayed when parser is active.
|
java.lang.String |
getTitle(android.content.Context ctx)
Returns title that will be displayed.
|
int |
getTitleResource()
Returns the resource ID representing title that will be displayed or 0 if resource ID is not available.
|
boolean |
isOptional()
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 |
setParser(Parser parser)
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 |
setText(java.lang.String text)
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 |
setTitle(java.lang.String title)
Sets the title that will be displayed.
|
void |
setTitleResource(int titleResource)
Sets the resource ID representing title that will be displayed.
|
java.lang.String |
toString() |
void |
writeToParcel(android.os.Parcel dest,
int flags) |
public FieldByFieldElement(@StringRes int titleResource, @StringRes int textResource, @NonNull Parser parser)
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.public FieldByFieldElement(@NonNull java.lang.String title, @NonNull java.lang.String text, @NonNull Parser parser)
title
- Parser title displayed.text
- Message that will be displayed when parser is active.parser
- Parser that will be used for this scan element.public void setTitle(@Nullable java.lang.String title)
FieldByFieldElement.setTitleResource(int)
).
Set to null to use resource set with FieldByFieldElement.setTitleResource(int)
.title
- Title that will be displayed or null to use resource set with FieldByFieldElement.setTitleResource(int)
.@NonNull public java.lang.String getTitle(@NonNull android.content.Context ctx)
FieldByFieldElement.setTitle(String)
, that string will be returned.
If title was set as resource with FieldByFieldElement.setTitleResource(int)
, string resource will be resolved and resolved string will be
returned.ctx
- Context used for resolving string resource set with FieldByFieldElement.setTitleResource(int)
.@StringRes public int getTitleResource()
public void setTitleResource(@StringRes int titleResource)
titleResource
- String reosource representing title that will be displayed.@StringRes public int getTextResource()
public void setTextResource(@StringRes int textResource)
textResource
- the resource ID representing text that will be displayed when parser is active.@NonNull public java.lang.String getText(@NonNull android.content.Context ctx)
FieldByFieldElement.setText(String)
,
the same string is returned. If text was set with FieldByFieldElement.setTextResource(int)
, the text resource ID will
be resolved and resolved string will be returned.ctx
- Context used to resolve string resource.public void setText(@Nullable java.lang.String text)
FieldByFieldElement.setTextResource(int)
. Set the text to null to use text loaded from resource set with
FieldByFieldElement.setTextResource(int)
.text
- text that will be displayed when parser is active or null to use resource set with FieldByFieldElement.setTextResource(int)
.@NonNull public Parser getParser()
public void setParser(@NonNull Parser parser)
parser
- parser that will be used for this scan element.public boolean isOptional()
FieldByFieldElement.setOptional(boolean)
(boolean)}.FieldByFieldElement.setOptional(boolean)
(boolean)}.public void setOptional(boolean optional)
false
and the scan field is mandatory.optional
- If set to true
, scan field with this configuration is optional
and user can skip it, otherwise the scan field is mandatory.public float getScanRegionRelativeWidth()
public void setScanRegionRelativeWidth(float scanRegionRelativeWidth)
scanRegionRelativeWidth
- scan region width, represented as percentage of maximal allowed scan region width.public float getScanRegionRelativeHeight()
public void setScanRegionRelativeHeight(float scanRegionRelativeHeight)
scanRegionRelativeHeight
- scan region height, represented as percentage of maximal allowed scan region height.public float getShownScanRegionRelativeWidth()
public void setShownScanRegionRelativeWidth(float shownScanRegionRelativeWidth)
shownScanRegionRelativeWidth
- width of the scan region that will be shown to the user, represented as
percentage of maximal allowed scan region width.public float getShownScanRegionRelativeHeight()
public void setShownScanRegionRelativeHeight(float shownScanRegionRelativeHeight)
shownScanRegionRelativeHeight
- scan region height that will be shown to the user, represented as
percentage of maximal allowed scan region height.@NonNull public java.lang.String toString()
toString
in class java.lang.Object
public int describeContents()
describeContents
in interface android.os.Parcelable
public void writeToParcel(@NonNull android.os.Parcel dest, int flags)
writeToParcel
in interface android.os.Parcelable