Skip to content

Commit

Permalink
Serial num alphanumeric
Browse files Browse the repository at this point in the history
  • Loading branch information
ldbonkowski committed Nov 27, 2023
1 parent 159b093 commit 642f8e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,17 @@ public void scanImage(String imageUri) {
* @return the chosen serial number
*/
private static String selectBestLine(Text text) {
String bestLine = "";
String bestElement = "";

for (Text.TextBlock block : text.getTextBlocks()) {
for (Text.Line line : block.getLines()) {
// Convert each line into a string of numbers
String lineText = line.getText().replaceAll("[^0-9]", "");

// Serial numbers are usually at the bottom?
if (lineText.length() >= bestLine.length())
bestLine = lineText;
for (Text.Element element : line.getElements())
// Serial numbers are usually at the bottom
if (element.getText().length() >= bestElement.length())
bestElement = element.getText();
}
}
return bestLine;
return bestElement;
}

}
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_add_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/add_item_serial_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal" />
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.button.MaterialButton
Expand Down

0 comments on commit 642f8e3

Please sign in to comment.