java.lang.Object
com.microblink.photopay.entities.parsers.config.fieldbyfield.FieldByFieldElement
All Implemented Interfaces:
android.os.Parcelable

public class FieldByFieldElement extends Object implements 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

    Nested classes/interfaces inherited from interface android.os.Parcelable

    android.os.Parcelable.ClassLoaderCreator<T extends Object>, android.os.Parcelable.Creator<T extends Object>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final android.os.Parcelable.Creator<FieldByFieldElement>
     

    Fields inherited from interface android.os.Parcelable

    CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
  • Constructor Summary

    Constructors
    Constructor
    Description
    FieldByFieldElement(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 Type
    Method
    Description
    int
     
    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
    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
    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.
     
    void
    writeToParcel(android.os.Parcel dest, int flags)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • CREATOR

      @NonNull public static final android.os.Parcelable.Creator<FieldByFieldElement> 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

      public FieldByFieldElement(@NonNull String title, @NonNull String text, @NonNull Parser<?> parser)
      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

      public void setTitle(@Nullable String title)
      Sets the title that will be displayed. This overrides title that will be loaded from resources (see setTitleResource(int)). Set to null to use resource set with setTitleResource(int).
      Parameters:
      title - Title that will be displayed or null to use resource set with setTitleResource(int).
    • getTitle

      @NonNull public String getTitle(@NonNull android.content.Context ctx)
      Returns title that will be displayed. If title was set as string with setTitle(String), that string will be returned. If title was set as resource with setTitleResource(int), string resource will be resolved and resolved string will be returned.
      Parameters:
      ctx - Context used for resolving string resource set with setTitleResource(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

      @NonNull public String getText(@NonNull android.content.Context ctx)
      Returns the text that will be displayed when parser is active. If text was set with setText(String), the same string is returned. If text was set with setTextResource(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

      public void setText(@Nullable String text)
      Sets the text that will be displayed when parser is active. This overrides string resource set with setTextResource(int). Set the text to null to use text loaded from resource set with setTextResource(int).
      Parameters:
      text - text that will be displayed when parser is active or null to use resource set with setTextResource(int).
    • getParser

      @NonNull public Parser<?> getParser()
      Returns parser that is used for this scan element.
      Returns:
      the parser that is used for this scan element.
    • setParser

      public void setParser(@NonNull Parser<?> parser)
      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. See setOptional(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 to false and the scan field is mandatory.
      Parameters:
      optional - If set to true, 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

      @NonNull public String toString()
      Overrides:
      toString in class Object
    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface android.os.Parcelable
    • writeToParcel

      public void writeToParcel(@NonNull android.os.Parcel dest, int flags)
      Specified by:
      writeToParcel in interface android.os.Parcelable