removed google play's barcodescanner dependency
This commit is contained in:
parent
385a19a6ee
commit
05f95ef30d
|
@ -32,7 +32,10 @@ android {
|
||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding = true
|
viewBinding = true
|
||||||
|
buildConfig = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
|
@ -50,14 +53,14 @@ dependencies {
|
||||||
testImplementation(libs.junit)
|
testImplementation(libs.junit)
|
||||||
implementation(libs.volley)
|
implementation(libs.volley)
|
||||||
androidTestImplementation(libs.androidx.junit)
|
androidTestImplementation(libs.androidx.junit)
|
||||||
implementation (libs.play.services.code.scanner)
|
implementation(libs.zxing.android.embedded)
|
||||||
|
implementation("com.google.zxing:core:3.4.1")
|
||||||
androidTestImplementation(libs.androidx.espresso.core)
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
|
||||||
// implementation("com.google.android.material:1.2.0")
|
|
||||||
|
|
||||||
// Barcode scanning API
|
// Barcode scanning API
|
||||||
implementation (libs.barcode.scanning)
|
implementation (libs.barcode.scanning)
|
||||||
// CameraX library
|
|
||||||
|
// CameraX library
|
||||||
|
|
||||||
implementation (libs.androidx.camera.camera2)
|
implementation (libs.androidx.camera.camera2)
|
||||||
implementation (libs.androidx.camera.lifecycle)
|
implementation (libs.androidx.camera.lifecycle)
|
||||||
|
|
|
@ -43,6 +43,10 @@
|
||||||
android:label="@string/title_activity_fullscreen"
|
android:label="@string/title_activity_fullscreen"
|
||||||
android:theme="@style/Theme.BarcodeScannerForEmployees.Fullscreen"/>
|
android:theme="@style/Theme.BarcodeScannerForEmployees.Fullscreen"/>
|
||||||
|
|
||||||
|
<activity android:name="com.journeyapps.barcodescanner.CaptureActivity"
|
||||||
|
android:screenOrientation="fullSensor"
|
||||||
|
tools:replace="android:screenOrientation"/>
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="com.google.firebase.components.activities.MainActivity.provider;com.google.firebase.components.activities.FullscreenActivity.provider;com.google.firebase.components.activities.AddAbstractProductActivity.provider;com.google.firebase.components.activities.AddProductActivity.provider"
|
android:authorities="com.google.firebase.components.activities.MainActivity.provider;com.google.firebase.components.activities.FullscreenActivity.provider;com.google.firebase.components.activities.AddAbstractProductActivity.provider;com.google.firebase.components.activities.AddProductActivity.provider"
|
||||||
|
@ -53,11 +57,6 @@
|
||||||
android:resource="@xml/file_path"/>
|
android:resource="@xml/file_path"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
<meta-data
|
|
||||||
android:name="com.google.mlkit.vision.DEPENDENCIES"
|
|
||||||
android:value="barcode_ui">
|
|
||||||
</meta-data>
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.MainActivity"
|
android:name=".activities.MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|
|
@ -28,11 +28,11 @@ class Parser constructor() {
|
||||||
val (name, netWeight, unit) = findNetWeightInText(
|
val (name, netWeight, unit) = findNetWeightInText(
|
||||||
text,
|
text,
|
||||||
listOf(
|
listOf(
|
||||||
Regex("[0-9]+,?[0-9]*\\s*[лЛ]"),
|
Regex("\\d*[.,]?\\d+\\s*[лЛ]"),
|
||||||
Regex("[0-9]+,?[0-9]*\\s*((мл)|(МЛ)|(Мл))"),
|
Regex("[0-9]+((,?)|(.?))+[0-9]*\\s*((мл)|(МЛ)|(Мл))"),
|
||||||
Regex("[0-9]+,?[0-9]*\\s*((кг)|(Кг))"),
|
Regex("[0-9]+((,?)|(.?))+[0-9]*\\s*((кг)|(Кг))"),
|
||||||
Regex("[0-9]+,?[0-9]*\\s*[гГ]"),
|
Regex("[0-9]+((,?)|(.?))+[0-9]*\\s*[гГ]"),
|
||||||
Regex("[0-9]+,?[0-9*]\\s*((шт)|(Шт))")
|
Regex("\\d+\\s*(шт)|(Шт)")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
var unitNumber = -1
|
var unitNumber = -1
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.foxarmy.barcodescannerforemployees.activities
|
package org.foxarmy.barcodescannerforemployees.activities
|
||||||
|
|
||||||
import android.Manifest
|
//import com.google.mlkit.vision.codescanner.GmsBarcodeScannerOptions
|
||||||
|
//import com.google.mlkit.vision.codescanner.GmsBarcodeScanning
|
||||||
|
|
||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -15,9 +17,9 @@ import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.widget.addTextChangedListener
|
import androidx.core.widget.addTextChangedListener
|
||||||
import com.google.mlkit.vision.barcode.common.Barcode
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
import com.google.mlkit.vision.codescanner.GmsBarcodeScannerOptions
|
import com.journeyapps.barcodescanner.ScanIntentResult
|
||||||
import com.google.mlkit.vision.codescanner.GmsBarcodeScanning
|
import com.journeyapps.barcodescanner.ScanOptions
|
||||||
import org.foxarmy.barcodescannerforemployees.*
|
import org.foxarmy.barcodescannerforemployees.*
|
||||||
import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
|
import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -44,6 +46,8 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||||
private lateinit var picturesPath: File
|
private lateinit var picturesPath: File
|
||||||
private var barcode: String = ""
|
private var barcode: String = ""
|
||||||
|
|
||||||
|
private var scanningBarcode = false
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
@ -55,8 +59,6 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||||
barcode = abstractProduct!!.barcode
|
barcode = abstractProduct!!.barcode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
picturesPath = File(filesDir, "pictures")
|
picturesPath = File(filesDir, "pictures")
|
||||||
val thumbnailsDir = File(cacheDir, "thumbnails")
|
val thumbnailsDir = File(cacheDir, "thumbnails")
|
||||||
thumbnailsDir.mkdirs()
|
thumbnailsDir.mkdirs()
|
||||||
|
@ -131,36 +133,24 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||||
if (abstractProduct == null) {
|
if (abstractProduct == null) {
|
||||||
db.insert(AbstractProductContract.AbstractProductEntry.TABLE_NAME, null, values)
|
db.insert(AbstractProductContract.AbstractProductEntry.TABLE_NAME, null, values)
|
||||||
} else {
|
} else {
|
||||||
db.update(AbstractProductContract.AbstractProductEntry.TABLE_NAME, values, "${BaseColumns._ID} = ?", arrayOf(abstractProduct!!.id.toString()))
|
db.update(
|
||||||
|
AbstractProductContract.AbstractProductEntry.TABLE_NAME,
|
||||||
|
values,
|
||||||
|
"${BaseColumns._ID} = ?",
|
||||||
|
arrayOf(abstractProduct!!.id.toString())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
takePictureButton.setOnClickListener {
|
takePictureButton.setOnClickListener {
|
||||||
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
|
requestPermissionLauncher.launch(android.Manifest.permission.CAMERA)
|
||||||
}
|
}
|
||||||
|
|
||||||
scanButton.setOnClickListener {
|
scanButton.setOnClickListener {
|
||||||
val options = GmsBarcodeScannerOptions.Builder()
|
scanningBarcode = true
|
||||||
.setBarcodeFormats(
|
requestPermissionLauncher.launch(android.Manifest.permission.CAMERA)
|
||||||
Barcode.FORMAT_EAN_13
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
val scanner = GmsBarcodeScanning.getClient(this)
|
|
||||||
scanner.startScan()
|
|
||||||
.addOnSuccessListener { barcode ->
|
|
||||||
this.barcode = barcode.rawValue.toString()
|
|
||||||
|
|
||||||
performRequest(this.barcode)
|
|
||||||
}
|
|
||||||
.addOnFailureListener { e ->
|
|
||||||
Toast.makeText(
|
|
||||||
this,
|
|
||||||
"Failed to scan barcode. Please, try again or enter data manually",
|
|
||||||
Toast.LENGTH_LONG
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +160,11 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||||
requester.request(this, barcode)
|
requester.request(this, barcode)
|
||||||
var abstractProduct: AbstractProduct
|
var abstractProduct: AbstractProduct
|
||||||
|
|
||||||
if (DBStorageController(this).findAbstractProductByBarcode(DBStorageController(this).readableDatabase, this.barcode) != null) {
|
if (DBStorageController(this).findAbstractProductByBarcode(
|
||||||
|
DBStorageController(this).readableDatabase,
|
||||||
|
this.barcode
|
||||||
|
) != null
|
||||||
|
) {
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
.setMessage("You've got an abstract product with such barcode in your database")
|
.setMessage("You've got an abstract product with such barcode in your database")
|
||||||
.setPositiveButton("Quit") { _: DialogInterface, _: Int ->
|
.setPositiveButton("Quit") { _: DialogInterface, _: Int ->
|
||||||
|
@ -179,7 +173,10 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||||
.setNegativeButton("Edit existing") { _: DialogInterface, _: Int ->
|
.setNegativeButton("Edit existing") { _: DialogInterface, _: Int ->
|
||||||
val addProductIntent = Intent(this, AddAbstractProductActivity::class.java)
|
val addProductIntent = Intent(this, AddAbstractProductActivity::class.java)
|
||||||
val extras = Bundle()
|
val extras = Bundle()
|
||||||
val existingAbstractProduct = DBStorageController(this).findAbstractProductByBarcode(DBStorageController(this).readableDatabase, this.barcode)
|
val existingAbstractProduct = DBStorageController(this).findAbstractProductByBarcode(
|
||||||
|
DBStorageController(this).readableDatabase,
|
||||||
|
this.barcode
|
||||||
|
)
|
||||||
extras.putParcelable("abstractProduct", existingAbstractProduct)
|
extras.putParcelable("abstractProduct", existingAbstractProduct)
|
||||||
addProductIntent.putExtras(extras)
|
addProductIntent.putExtras(extras)
|
||||||
ContextCompat.startActivity(this, addProductIntent, extras)
|
ContextCompat.startActivity(this, addProductIntent, extras)
|
||||||
|
@ -189,10 +186,12 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||||
|
|
||||||
thread {
|
thread {
|
||||||
// Я сам в ахуях какой это костыль, пока хз как фиксить, потом придумаю :))
|
// Я сам в ахуях какой это костыль, пока хз как фиксить, потом придумаю :))
|
||||||
while (requester.response == "") { }
|
while (requester.response == "") {
|
||||||
|
}
|
||||||
if (requester.response == "Not found 404") {
|
if (requester.response == "Not found 404") {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
Toast.makeText(this, "Product not found. Please, try again or type manually", Toast.LENGTH_LONG).show()
|
Toast.makeText(this, "Product not found. Please, try again or type manually", Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
}
|
}
|
||||||
return@thread
|
return@thread
|
||||||
}
|
}
|
||||||
|
@ -217,7 +216,8 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
val arrayAdapter = ArrayAdapter<String>(this, androidx.appcompat.R.layout.support_simple_spinner_dropdown_item, units)
|
val arrayAdapter =
|
||||||
|
ArrayAdapter<String>(this, androidx.appcompat.R.layout.support_simple_spinner_dropdown_item, units)
|
||||||
arrayAdapter.setDropDownViewResource(androidx.appcompat.R.layout.support_simple_spinner_dropdown_item)
|
arrayAdapter.setDropDownViewResource(androidx.appcompat.R.layout.support_simple_spinner_dropdown_item)
|
||||||
unitTypeSpinner.adapter = arrayAdapter
|
unitTypeSpinner.adapter = arrayAdapter
|
||||||
}
|
}
|
||||||
|
@ -231,15 +231,24 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||||
CategoriesContract.CategoryEntry.CATEGORY_NAME
|
CategoriesContract.CategoryEntry.CATEGORY_NAME
|
||||||
)
|
)
|
||||||
|
|
||||||
val cursor = db.query(CategoriesContract.CategoryEntry.TABLE_NAME, projection, null, null, null, null, BaseColumns._ID+" ASC")
|
val cursor = db.query(
|
||||||
|
CategoriesContract.CategoryEntry.TABLE_NAME,
|
||||||
|
projection,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
BaseColumns._ID + " ASC"
|
||||||
|
)
|
||||||
|
|
||||||
with (cursor) {
|
with(cursor) {
|
||||||
while (moveToNext()) {
|
while (moveToNext()) {
|
||||||
categories.add(getString(getColumnIndexOrThrow(CategoriesContract.CategoryEntry.CATEGORY_NAME)))
|
categories.add(getString(getColumnIndexOrThrow(CategoriesContract.CategoryEntry.CATEGORY_NAME)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val arrayAdapter = ArrayAdapter<String>(this, androidx.appcompat.R.layout.support_simple_spinner_dropdown_item, categories)
|
val arrayAdapter =
|
||||||
|
ArrayAdapter<String>(this, androidx.appcompat.R.layout.support_simple_spinner_dropdown_item, categories)
|
||||||
arrayAdapter.setDropDownViewResource(androidx.appcompat.R.layout.support_simple_spinner_dropdown_item)
|
arrayAdapter.setDropDownViewResource(androidx.appcompat.R.layout.support_simple_spinner_dropdown_item)
|
||||||
categorySpinner.adapter = arrayAdapter
|
categorySpinner.adapter = arrayAdapter
|
||||||
}
|
}
|
||||||
|
@ -264,7 +273,7 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.R)
|
@RequiresApi(Build.VERSION_CODES.R)
|
||||||
fun getPicture () {
|
fun getPicture() {
|
||||||
//Saving picture to a temp file for further hash calculation and moving to a proper directory
|
//Saving picture to a temp file for further hash calculation and moving to a proper directory
|
||||||
val imageFile = File(this.filesDir, "image.png")
|
val imageFile = File(this.filesDir, "image.png")
|
||||||
val imageUri = getImageUri(this, imageFile)
|
val imageUri = getImageUri(this, imageFile)
|
||||||
|
@ -279,9 +288,38 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||||
ActivityResultContracts.RequestPermission()
|
ActivityResultContracts.RequestPermission()
|
||||||
) { isGranted: Boolean ->
|
) { isGranted: Boolean ->
|
||||||
if (isGranted) {
|
if (isGranted) {
|
||||||
getPicture()
|
if (scanningBarcode) {
|
||||||
|
prepareBarcodeScanner()
|
||||||
|
} else {
|
||||||
|
getPicture()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, "I need permission in order to take a picture", Toast.LENGTH_LONG).show()
|
Toast.makeText(this, "I need permission in order to take a picture", Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val scanLauncher = registerForActivityResult(ScanContract()) { result: ScanIntentResult ->
|
||||||
|
run {
|
||||||
|
if (result.contents == null) {
|
||||||
|
Toast.makeText(this, "Cancelled", Toast.LENGTH_SHORT).show()
|
||||||
|
} else {
|
||||||
|
scanningBarcode = false
|
||||||
|
val scannedBarcode = result.contents
|
||||||
|
barcodeText.setText(scannedBarcode)
|
||||||
|
performRequest(scannedBarcode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prepareBarcodeScanner() {
|
||||||
|
val options = ScanOptions()
|
||||||
|
options.setDesiredBarcodeFormats(ScanOptions.EAN_13)
|
||||||
|
options.setPrompt("Scan barcode of a product")
|
||||||
|
options.setCameraId(0)
|
||||||
|
options.setBeepEnabled(false)
|
||||||
|
options.setBarcodeImageEnabled(true)
|
||||||
|
options.setOrientationLocked(false)
|
||||||
|
|
||||||
|
scanLauncher.launch(options)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,17 @@
|
||||||
package org.foxarmy.barcodescannerforemployees.activities
|
package org.foxarmy.barcodescannerforemployees.activities
|
||||||
|
|
||||||
import android.app.DatePickerDialog
|
import android.app.DatePickerDialog
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.widget.addTextChangedListener
|
import androidx.core.widget.addTextChangedListener
|
||||||
import com.google.mlkit.vision.codescanner.GmsBarcodeScanning
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
|
import com.journeyapps.barcodescanner.ScanIntentResult
|
||||||
|
import com.journeyapps.barcodescanner.ScanOptions
|
||||||
import org.foxarmy.barcodescannerforemployees.DBStorageController
|
import org.foxarmy.barcodescannerforemployees.DBStorageController
|
||||||
import org.foxarmy.barcodescannerforemployees.R
|
import org.foxarmy.barcodescannerforemployees.R
|
||||||
import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
|
import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
|
||||||
|
@ -77,17 +82,7 @@ class AddProductActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
scanButton.setOnClickListener {
|
scanButton.setOnClickListener {
|
||||||
val scanner = GmsBarcodeScanning.getClient(this)
|
requestPermissionLauncher.launch(android.Manifest.permission.CAMERA)
|
||||||
scanner.startScan()
|
|
||||||
.addOnSuccessListener { bc ->
|
|
||||||
abstractProduct = DBStorageController(this).findAbstractProductByBarcode(DBStorageController(this).readableDatabase, bc.rawValue.toString())
|
|
||||||
product!!.abstractProductId = abstractProduct!!.id
|
|
||||||
|
|
||||||
displayAbstractProduct(abstractProduct!!)
|
|
||||||
}
|
|
||||||
.addOnFailureListener {
|
|
||||||
Toast.makeText(this, "Cannot scan barcode", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expiryDateRadioButton.setOnClickListener {
|
expiryDateRadioButton.setOnClickListener {
|
||||||
|
@ -215,4 +210,41 @@ class AddProductActivity : AppCompatActivity() {
|
||||||
abstractProductView.abstractProduct = abstractProduct
|
abstractProductView.abstractProduct = abstractProduct
|
||||||
abstractProductView.update()
|
abstractProductView.update()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.R)
|
||||||
|
val requestPermissionLauncher =
|
||||||
|
registerForActivityResult(
|
||||||
|
ActivityResultContracts.RequestPermission()
|
||||||
|
) { isGranted: Boolean ->
|
||||||
|
if (isGranted) {
|
||||||
|
prepareBarcodeScanner()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "I need permission in order to take a picture", Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val scanLauncher = registerForActivityResult(ScanContract()) { result: ScanIntentResult ->
|
||||||
|
run {
|
||||||
|
if (result.contents == null) {
|
||||||
|
Toast.makeText(this, "Cancelled", Toast.LENGTH_SHORT).show()
|
||||||
|
} else {
|
||||||
|
val scannedBarcode = result.contents
|
||||||
|
abstractProduct = DBStorageController(this).findAbstractProductByBarcode(DBStorageController(this).readableDatabase, scannedBarcode)
|
||||||
|
displayAbstractProduct(abstractProduct!!)
|
||||||
|
product?.abstractProductId = abstractProduct!!.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prepareBarcodeScanner() {
|
||||||
|
val options = ScanOptions()
|
||||||
|
options.setDesiredBarcodeFormats(ScanOptions.EAN_13)
|
||||||
|
options.setPrompt("Scan barcode of a product")
|
||||||
|
options.setCameraId(0)
|
||||||
|
options.setBeepEnabled(false)
|
||||||
|
options.setBarcodeImageEnabled(true)
|
||||||
|
options.setOrientationLocked(false)
|
||||||
|
|
||||||
|
scanLauncher.launch(options)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -121,7 +121,6 @@ class StorageFragment : Fragment() {
|
||||||
)
|
)
|
||||||
|
|
||||||
var orderBy: String = ""
|
var orderBy: String = ""
|
||||||
Log.d("QWERTYUIOP", binding.spinner.selectedItem.toString())
|
|
||||||
when(binding.spinner.selectedItem) {
|
when(binding.spinner.selectedItem) {
|
||||||
"Name" -> {
|
"Name" -> {
|
||||||
orderBy = "${AbstractProductContract.AbstractProductEntry.PRODUCT_NAME} ASC"
|
orderBy = "${AbstractProductContract.AbstractProductEntry.PRODUCT_NAME} ASC"
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="16dp">
|
android:padding="16dp" android:layout_gravity="center">
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/scan_button"
|
android:id="@+id/scan_button"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
|
@ -17,23 +17,23 @@
|
||||||
android:text="@string/scan_label"
|
android:text="@string/scan_label"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/categoryTextView"
|
app:layout_constraintTop_toBottomOf="@+id/categoryTextView"
|
||||||
android:layout_marginTop="15dp"/>
|
android:layout_marginTop="15dp" android:layout_marginStart="5dp"/>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:src="@android:drawable/ic_menu_camera"
|
android:src="@android:drawable/ic_menu_camera"
|
||||||
android:layout_width="356dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="303dp" android:id="@+id/imageView"
|
android:layout_height="303dp" android:id="@+id/imageView"
|
||||||
android:layout_marginBottom="25dp"
|
android:layout_marginBottom="25dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/productName" app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintBottom_toTopOf="@+id/productName" app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent"
|
||||||
android:layout_marginTop="15dp"/>
|
android:layout_marginTop="15dp" android:layout_marginStart="5dp" android:layout_marginEnd="5dp"/>
|
||||||
<EditText
|
<EditText
|
||||||
android:layout_width="350dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:inputType="text"
|
android:inputType="text"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:id="@+id/productName"
|
android:id="@+id/productName"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:layout_marginStart="8dp" android:layout_marginEnd="8dp"
|
android:layout_marginStart="5dp" android:layout_marginEnd="5dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/netWeight"
|
app:layout_constraintBottom_toTopOf="@+id/netWeight"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:id="@+id/netWeight"
|
android:id="@+id/netWeight"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="5dp"
|
||||||
android:visibility="visible" android:hint="@string/netWeight" android:textColorHint="#737373"
|
android:visibility="visible" android:hint="@string/netWeight" android:textColorHint="#737373"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/productName"
|
app:layout_constraintTop_toBottomOf="@+id/productName"
|
||||||
/>
|
/>
|
||||||
|
@ -56,13 +56,14 @@
|
||||||
app:layout_constraintStart_toEndOf="@+id/netWeight"
|
app:layout_constraintStart_toEndOf="@+id/netWeight"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/productName" app:layout_constraintEnd_toEndOf="parent"/>
|
app:layout_constraintTop_toBottomOf="@+id/productName" app:layout_constraintEnd_toEndOf="parent"/>
|
||||||
<EditText
|
<EditText
|
||||||
android:layout_width="350dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="text"
|
android:inputType="text"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:id="@+id/barcodeTextEdit" app:layout_constraintTop_toBottomOf="@+id/imageView"
|
android:id="@+id/barcodeTextEdit" app:layout_constraintTop_toBottomOf="@+id/imageView"
|
||||||
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
|
||||||
android:layout_marginTop="8dp" android:hint="Barcode" android:textColorHint="#737373"/>
|
android:layout_marginTop="8dp" android:hint="Barcode" android:textColorHint="#737373"
|
||||||
|
android:layout_marginStart="5dp" android:layout_marginEnd="5dp"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/category"
|
android:text="@string/category"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -81,15 +82,15 @@
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="50dp" android:id="@+id/saveButton"
|
android:layout_height="50dp" android:id="@+id/saveButton"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/categoryTextView"
|
app:layout_constraintTop_toBottomOf="@+id/categoryTextView"
|
||||||
android:layout_marginTop="15dp" app:layout_constraintEnd_toEndOf="parent"/>
|
android:layout_marginTop="15dp" app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:layout_marginEnd="5dp"/>
|
||||||
<Button
|
<Button
|
||||||
android:text="@string/takePicture"
|
android:text="@string/takePicture"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="55dp" android:id="@+id/takePictureButton"
|
android:layout_height="55dp" android:id="@+id/takePictureButton"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/categoryTextView"
|
app:layout_constraintTop_toBottomOf="@+id/categoryTextView"
|
||||||
android:layout_marginTop="15dp" app:layout_constraintStart_toEndOf="@+id/scan_button"
|
android:layout_marginTop="15dp"
|
||||||
android:layout_marginStart="33dp" app:layout_constraintEnd_toStartOf="@+id/saveButton"
|
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>
|
||||||
android:layout_marginEnd="6dp" app:layout_constraintHorizontal_bias="0.0"/>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
|
@ -19,6 +19,7 @@ legacySupportV4 = "1.0.0"
|
||||||
fragment = "1.8.4"
|
fragment = "1.8.4"
|
||||||
playServicesCodeScanner = "16.1.0"
|
playServicesCodeScanner = "16.1.0"
|
||||||
volley = "1.2.1"
|
volley = "1.2.1"
|
||||||
|
zxingAndroidEmbedded = "4.3.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-camera-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "cameraView" }
|
androidx-camera-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "cameraView" }
|
||||||
|
@ -41,6 +42,7 @@ androidx-legacy-support-v4 = { group = "androidx.legacy", name = "legacy-support
|
||||||
androidx-fragment = { group = "androidx.fragment", name = "fragment", version.ref = "fragment" }
|
androidx-fragment = { group = "androidx.fragment", name = "fragment", version.ref = "fragment" }
|
||||||
play-services-code-scanner = { module = "com.google.android.gms:play-services-code-scanner", version.ref = "playServicesCodeScanner" }
|
play-services-code-scanner = { module = "com.google.android.gms:play-services-code-scanner", version.ref = "playServicesCodeScanner" }
|
||||||
volley = { module = "com.android.volley:volley", version.ref = "volley" }
|
volley = { module = "com.android.volley:volley", version.ref = "volley" }
|
||||||
|
zxing-android-embedded = { module = "com.journeyapps:zxing-android-embedded", version.ref = "zxingAndroidEmbedded" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|
Loading…
Reference in New Issue