Compare commits
8 Commits
alpha-0.0.
...
alpha-0.0.
| Author | SHA1 | Date | |
|---|---|---|---|
| 6e497323c0 | |||
| 6e32545b9d | |||
| 62cc4db615 | |||
| 60aa1973b1 | |||
| 9b9946b280 | |||
| 4f1845dd0e | |||
| 79ab5c83c0 | |||
| e05f223075 |
@@ -36,6 +36,18 @@
|
||||
android:name=".activities.AddAbstractProductActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.BarcodeScannerForEmployees"/>
|
||||
<activity
|
||||
android:name=".activities.ExpiryCalendarActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.BarcodeScannerForEmployees"/>
|
||||
<activity
|
||||
android:name=".activities.ExpiryCalendarGroupActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.BarcodeScannerForEmployees"/>
|
||||
<activity
|
||||
android:name=".activities.FindBarcodelessAbstractProduct"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.BarcodeScannerForEmployees"/>
|
||||
<activity
|
||||
android:name=".activities.FullscreenActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
@@ -49,7 +61,7 @@
|
||||
|
||||
<provider
|
||||
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;com.google.firebase.components.activities.ExpiryCalendarActivity.provider;com.google.firebase.components.activities.FindBarcodelessAbstractProduct.provider;com.google.firebase.components.activities.ExpiryCalendarGroupActivity.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
|
||||
@@ -200,6 +200,49 @@ class DBStorageController(context: Context) : SQLiteOpenHelper(context, DATABASE
|
||||
db.insert(ProductContract.ProductEntry.TABLE_NAME, null, values)
|
||||
}
|
||||
|
||||
fun findAmountOfProductsWithExpiryDate(db: SQLiteDatabase, date: Long): Int {
|
||||
var amount = 0
|
||||
|
||||
val projection = arrayOf(
|
||||
ProductContract.ProductEntry.ABSTRACT_PRODUCT_ID,
|
||||
ProductContract.ProductEntry.AMOUNT,
|
||||
ProductContract.ProductEntry.DATE_OF_PRODUCTION,
|
||||
)
|
||||
|
||||
val selection = "${ProductContract.ProductEntry.EXPIRY_DATE} = ?"
|
||||
val selectionArgs = arrayOf(date.toString())
|
||||
|
||||
val cursor = db.query(ProductContract.ProductEntry.TABLE_NAME, projection, selection, selectionArgs, null, null, null)
|
||||
|
||||
with(cursor) {
|
||||
while (moveToNext()) {
|
||||
amount++
|
||||
}
|
||||
}
|
||||
|
||||
return amount
|
||||
}
|
||||
|
||||
fun findAllExpiryDates(db:SQLiteDatabase): Set<Long> {
|
||||
val dates: MutableSet<Long> = mutableSetOf<Long>()
|
||||
|
||||
val projection = arrayOf(
|
||||
ProductContract.ProductEntry.EXPIRY_DATE
|
||||
)
|
||||
|
||||
val orderBy = "${ProductContract.ProductEntry.EXPIRY_DATE} ASC"
|
||||
|
||||
val cursor = db.query(ProductContract.ProductEntry.TABLE_NAME, projection, null, null, null, null, orderBy)
|
||||
|
||||
with(cursor) {
|
||||
while (moveToNext()) {
|
||||
dates.add(getLong(getColumnIndexOrThrow(ProductContract.ProductEntry.EXPIRY_DATE)))
|
||||
}
|
||||
}
|
||||
|
||||
return dates
|
||||
}
|
||||
|
||||
fun findAbstractProductByBarcode (db: SQLiteDatabase, barcode: String) : AbstractProduct? {
|
||||
var abstractProduct: AbstractProduct? = null
|
||||
val projection = arrayOf(
|
||||
|
||||
@@ -13,8 +13,9 @@ class Parser constructor() {
|
||||
val found = foundByRegex.groupValues[0]
|
||||
text = text.replace(found, "")
|
||||
netWeight = stripNetWeight(found)
|
||||
// }
|
||||
return Triple(text, netWeight, found)
|
||||
} else {
|
||||
return Triple(text, 0.0, "")
|
||||
}
|
||||
}
|
||||
return Triple("", 0.0, "")
|
||||
@@ -40,7 +41,9 @@ class Parser constructor() {
|
||||
"мл" -> { 3 }
|
||||
"шт" -> { 4 }
|
||||
|
||||
else -> { -1 }
|
||||
else -> {
|
||||
4
|
||||
}
|
||||
}
|
||||
|
||||
return AbstractProduct(0, "", name, netWeight, "", 0, unitNumber)
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.foxarmy.barcodescannerforemployees.activities
|
||||
|
||||
//import com.google.mlkit.vision.codescanner.GmsBarcodeScannerOptions
|
||||
//import com.google.mlkit.vision.codescanner.GmsBarcodeScanning
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
@@ -35,6 +32,7 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||
private lateinit var scanButton: Button
|
||||
|
||||
private lateinit var barcodeText: EditText
|
||||
private lateinit var noBarcodeCheckBox: CheckBox
|
||||
private lateinit var productNameText: TextView
|
||||
private lateinit var netWeightText: TextView
|
||||
private lateinit var unitTypeSpinner: Spinner
|
||||
@@ -66,6 +64,7 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||
scanButton = findViewById(R.id.scan_button)
|
||||
|
||||
barcodeText = findViewById(R.id.barcodeTextEdit)
|
||||
noBarcodeCheckBox = findViewById(R.id.noBarcodeCheckBox)
|
||||
productNameText = findViewById(R.id.productName)
|
||||
netWeightText = findViewById(R.id.netWeight)
|
||||
unitTypeSpinner = findViewById(R.id.unitTypeSpinner)
|
||||
@@ -75,6 +74,12 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||
fillupCategorySpinner()
|
||||
fillupUnitsSpinner()
|
||||
|
||||
noBarcodeCheckBox.setOnClickListener {
|
||||
if (noBarcodeCheckBox.isChecked) {
|
||||
barcodeText.setText("")
|
||||
}
|
||||
}
|
||||
|
||||
barcodeText.addTextChangedListener {
|
||||
this.barcode = barcodeText.text.toString()
|
||||
}
|
||||
@@ -106,12 +111,12 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||
saveButton.setOnClickListener {
|
||||
val productName = productNameText.text.toString()
|
||||
val netWeight = netWeightText.text
|
||||
if (abstractProduct == null && (!this::pictureFile.isInitialized || !pictureFile.exists())) {
|
||||
if (action != "update" && (!this::pictureFile.isInitialized || !pictureFile.exists())) {
|
||||
Toast.makeText(this, getString(R.string.product_picture_request), Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (barcode == "") {
|
||||
if (barcode == "" && !noBarcodeCheckBox.isChecked) {
|
||||
Toast.makeText(this, getString(R.string.product_barcode_request), Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
@@ -170,11 +175,11 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||
) != null
|
||||
) {
|
||||
AlertDialog.Builder(this)
|
||||
.setMessage("You've got an abstract product with such barcode in your database")
|
||||
.setPositiveButton("Quit") { _: DialogInterface, _: Int ->
|
||||
.setMessage(getString(R.string.abstract_product_already_exists))
|
||||
.setPositiveButton(getString(R.string.quit)) { _: DialogInterface, _: Int ->
|
||||
finish()
|
||||
}
|
||||
.setNegativeButton("Edit existing") { _: DialogInterface, _: Int ->
|
||||
.setNegativeButton(getString(R.string.edit_existing)) { _: DialogInterface, _: Int ->
|
||||
val addProductIntent = Intent(this, AddAbstractProductActivity::class.java)
|
||||
val extras = Bundle()
|
||||
val existingAbstractProduct = DBStorageController(this).findAbstractProductByBarcode(
|
||||
@@ -194,7 +199,7 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||
}
|
||||
if (requester.response == "Not found 404") {
|
||||
runOnUiThread {
|
||||
Toast.makeText(this, "Product not found. Please, try again or type manually", Toast.LENGTH_LONG)
|
||||
Toast.makeText(this, getString(R.string.no_product_in_online_database), Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
return@thread
|
||||
@@ -307,11 +312,11 @@ class AddAbstractProductActivity : AppCompatActivity() {
|
||||
if (result.contents == null) {
|
||||
Toast.makeText(this, getString(R.string.cancelled), Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
scanningBarcode = false
|
||||
val scannedBarcode = result.contents
|
||||
barcodeText.setText(scannedBarcode)
|
||||
performRequest(scannedBarcode)
|
||||
}
|
||||
scanningBarcode = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.foxarmy.barcodescannerforemployees.activities
|
||||
|
||||
import android.app.DatePickerDialog
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
@@ -26,19 +26,18 @@ import java.util.*
|
||||
class AddProductActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var scanButton: Button
|
||||
private lateinit var noBarcodeButton: Button
|
||||
private lateinit var abstractProductView: AbstractProductView
|
||||
private lateinit var expiryDateRadioButton: RadioButton
|
||||
private lateinit var shelfLifeRadioButton: RadioButton
|
||||
|
||||
private lateinit var expiryDateTextView: TextView
|
||||
private lateinit var expiryDateSelectButton: Button
|
||||
private lateinit var expiryDatePicker: DatePicker
|
||||
|
||||
private lateinit var shelfLifeTextView: TextView
|
||||
private lateinit var shelfLifeTextEdit: EditText
|
||||
|
||||
private lateinit var amountTextEdit: EditText
|
||||
|
||||
private lateinit var dateOfProductionSelectButton: Button
|
||||
private lateinit var dateOfProductionDatePicker: DatePicker
|
||||
private lateinit var saveProductButton: Button
|
||||
|
||||
private var expiryDateOverShelfLife: Boolean? = null
|
||||
@@ -52,20 +51,19 @@ class AddProductActivity : AppCompatActivity() {
|
||||
setContentView(R.layout.fragment_add_product)
|
||||
|
||||
scanButton = findViewById(R.id.scanButton)
|
||||
noBarcodeButton = findViewById(R.id.noBarcodeButton)
|
||||
abstractProductView = findViewById(R.id.abstractProductView)
|
||||
expiryDateRadioButton = findViewById(R.id.expiryDateRadio)
|
||||
shelfLifeRadioButton = findViewById(R.id.shelfLifeRadio)
|
||||
|
||||
expiryDateTextView = findViewById(R.id.expiryDateTextView)
|
||||
expiryDateSelectButton = findViewById(R.id.selectExpiryDateButton)
|
||||
expiryDatePicker = findViewById(R.id.expiryDatePicker)
|
||||
|
||||
shelfLifeTextView = findViewById(R.id.shelfLife)
|
||||
shelfLifeTextEdit = findViewById(R.id.shelfLifeTextEdit)
|
||||
|
||||
amountTextEdit = findViewById(R.id.amountTextEdit)
|
||||
amountTextEdit.setText("1")
|
||||
|
||||
dateOfProductionSelectButton = findViewById(R.id.selectDateOfProductionButton)
|
||||
dateOfProductionDatePicker = findViewById(R.id.dateOfProductionDatePicker)
|
||||
saveProductButton = findViewById(R.id.saveProductButton)
|
||||
|
||||
val extras = intent.extras
|
||||
@@ -82,13 +80,16 @@ class AddProductActivity : AppCompatActivity() {
|
||||
update()
|
||||
} else {
|
||||
product = Product(0, 0, 0, 0, 0)
|
||||
abstractProduct = AbstractProduct(0, "", "", 0.0, "", 0, 0)
|
||||
}
|
||||
|
||||
scanButton.setOnClickListener {
|
||||
requestPermissionLauncher.launch(android.Manifest.permission.CAMERA)
|
||||
}
|
||||
|
||||
noBarcodeButton.setOnClickListener {
|
||||
intentLauncher.launch(Intent(this, FindBarcodelessAbstractProduct::class.java))
|
||||
}
|
||||
|
||||
expiryDateRadioButton.setOnClickListener {
|
||||
expiryDateOverShelfLife = true
|
||||
update()
|
||||
@@ -99,32 +100,14 @@ class AddProductActivity : AppCompatActivity() {
|
||||
update()
|
||||
}
|
||||
|
||||
dateOfProductionSelectButton.setOnClickListener {
|
||||
val c = Calendar.getInstance()
|
||||
val year = c.get(Calendar.YEAR)
|
||||
val month = c.get(Calendar.MONTH)
|
||||
val day = c.get(Calendar.DAY_OF_MONTH)
|
||||
|
||||
val dpd = DatePickerDialog(this, { _, y, m, d ->
|
||||
product!!.dateOfProduction = SimpleDateFormat("dd.MM.yyyy").parse("$d.${m+1}.$y")!!.time / 1000
|
||||
update()
|
||||
}, year, month, day)
|
||||
|
||||
dpd.show()
|
||||
dateOfProductionDatePicker.setOnDateChangedListener { _, year, monthOfYear, dayOfMonth ->
|
||||
product!!.dateOfProduction = SimpleDateFormat("dd.MM.yyyy").parse("$dayOfMonth.$monthOfYear.$year")!!.time / 1000
|
||||
update()
|
||||
}
|
||||
|
||||
expiryDateSelectButton.setOnClickListener {
|
||||
val c = Calendar.getInstance()
|
||||
val year = c.get(Calendar.YEAR)
|
||||
val month = c.get(Calendar.MONTH)
|
||||
val day = c.get(Calendar.DAY_OF_MONTH)
|
||||
|
||||
val dpd = DatePickerDialog(this, { _, y, m, d ->
|
||||
product!!.dateOfExpiry = SimpleDateFormat("dd.MM.yyyy").parse("$d.${m+1}.$y")!!.time / 1000
|
||||
update()
|
||||
}, year, month, day)
|
||||
|
||||
dpd.show()
|
||||
expiryDatePicker.setOnDateChangedListener { _, year, monthOfYear, dayOfMonth ->
|
||||
product!!.dateOfExpiry = SimpleDateFormat("dd.MM.yyyy").parse("$dayOfMonth.$monthOfYear.$year")!!.time / 1000
|
||||
update()
|
||||
}
|
||||
|
||||
amountTextEdit.addTextChangedListener {
|
||||
@@ -134,6 +117,11 @@ class AddProductActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
saveProductButton.setOnClickListener {
|
||||
if (abstractProduct == null) {
|
||||
Toast.makeText(this, getString(R.string.abstract_product_request), Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (expiryDateOverShelfLife == null) {
|
||||
Toast.makeText(this, getString(R.string.shell_life_or_expiry_date_request), Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
@@ -167,27 +155,35 @@ class AddProductActivity : AppCompatActivity() {
|
||||
|
||||
finish()
|
||||
}
|
||||
update()
|
||||
|
||||
val today = SimpleDateFormat("dd.MM.yyyy").format(Calendar.getInstance().time).split(".")
|
||||
|
||||
|
||||
dateOfProductionDatePicker.updateDate(today[2].toInt(), today[1].toInt(), today[0].toInt())
|
||||
expiryDatePicker.updateDate(today[2].toInt(), today[1].toInt(), today[0].toInt())
|
||||
}
|
||||
|
||||
private val intentLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
if (result.resultCode == Activity.RESULT_OK) {
|
||||
val selectedAbstractProduct = (result.data?.extras!!.getParcelable("abstractProduct") as AbstractProduct?)!!
|
||||
product!!.abstractProductId = selectedAbstractProduct.id
|
||||
abstractProduct = selectedAbstractProduct
|
||||
displayAbstractProduct(selectedAbstractProduct, "")
|
||||
}
|
||||
}
|
||||
|
||||
private fun update () {
|
||||
if (expiryDateOverShelfLife == true) {
|
||||
expiryDateTextView.visibility = View.VISIBLE
|
||||
expiryDateSelectButton.visibility = View.VISIBLE
|
||||
expiryDatePicker.visibility = View.VISIBLE
|
||||
|
||||
shelfLifeTextEdit.visibility = View.INVISIBLE
|
||||
shelfLifeTextView.visibility = View.INVISIBLE
|
||||
} else if (expiryDateOverShelfLife == false){
|
||||
expiryDateTextView.visibility = View.INVISIBLE
|
||||
expiryDateSelectButton.visibility = View.INVISIBLE
|
||||
expiryDatePicker.visibility = View.INVISIBLE
|
||||
|
||||
shelfLifeTextEdit.visibility = View.VISIBLE
|
||||
shelfLifeTextView.visibility = View.VISIBLE
|
||||
}
|
||||
val dateOfProductionParsed = SimpleDateFormat("dd.MM.yyyy").format(Date(product!!.dateOfProduction * 1000))
|
||||
findViewById<TextView>(R.id.dateOfProductionTextView).text = "${getString(R.string.date_of_production)}: $dateOfProductionParsed"
|
||||
|
||||
val expiryDateParsed = SimpleDateFormat("dd.MM.yyyy").format(Date(product!!.dateOfExpiry * 1000))
|
||||
expiryDateTextView.text = "${getString(R.string.expiry_date)}: $expiryDateParsed"
|
||||
|
||||
if (amountTextEdit.text.toString() == "") {
|
||||
amountTextEdit.setText(product!!.amount.toString())
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.foxarmy.barcodescannerforemployees.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.LinearLayout
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import org.foxarmy.barcodescannerforemployees.DBStorageController
|
||||
import org.foxarmy.barcodescannerforemployees.R
|
||||
import org.foxarmy.barcodescannerforemployees.databinding.ActivityExpiryCalendarBinding
|
||||
import org.foxarmy.barcodescannerforemployees.views.ExpiryGroupView
|
||||
|
||||
class ExpiryCalendarActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityExpiryCalendarBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContentView(R.layout.fragment_expiry_dates)
|
||||
|
||||
fillUp()
|
||||
}
|
||||
|
||||
fun displayDate(date:Long) {
|
||||
val expiryCalendarGroupActivityIntent = Intent(this, ExpiryCalendarGroupActivity::class.java)
|
||||
val extras = Bundle()
|
||||
extras.putLong("date", date)
|
||||
expiryCalendarGroupActivityIntent.putExtras(extras)
|
||||
ContextCompat.startActivity(this, expiryCalendarGroupActivityIntent, extras)
|
||||
}
|
||||
|
||||
private fun fillUp() {
|
||||
val dates = DBStorageController(this).findAllExpiryDates(DBStorageController(this).readableDatabase)
|
||||
|
||||
val container = findViewById<LinearLayout>(R.id.datesLinearLayout)
|
||||
|
||||
dates.forEach { date ->
|
||||
val newDate = ExpiryGroupView(this, this as Context, date)
|
||||
container.addView(newDate)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.foxarmy.barcodescannerforemployees.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.foxarmy.barcodescannerforemployees.R
|
||||
import org.foxarmy.barcodescannerforemployees.databinding.ActivityExpiryCalendarGroupBinding
|
||||
import org.foxarmy.barcodescannerforemployees.fragments.ShelfFragment
|
||||
|
||||
class ExpiryCalendarGroupActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityExpiryCalendarGroupBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = ActivityExpiryCalendarGroupBinding.inflate(layoutInflater)
|
||||
|
||||
val date = intent.extras!!.getLong("date")
|
||||
|
||||
val ft = supportFragmentManager.beginTransaction()
|
||||
ft.replace(R.id.content, ShelfFragment.newInstance(date))
|
||||
ft.commit()
|
||||
setContentView(binding.root)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.foxarmy.barcodescannerforemployees.activities
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.foxarmy.barcodescannerforemployees.R
|
||||
import org.foxarmy.barcodescannerforemployees.databinding.ActivityFindBarcodelessAbstractProductBinding
|
||||
import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
|
||||
import org.foxarmy.barcodescannerforemployees.fragments.StorageFragment
|
||||
|
||||
class FindBarcodelessAbstractProduct() : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityFindBarcodelessAbstractProductBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = ActivityFindBarcodelessAbstractProductBinding.inflate(layoutInflater)
|
||||
|
||||
val ft = supportFragmentManager.beginTransaction()
|
||||
val fragment = StorageFragment.newInstance("barcodeless", arrayOf(""))
|
||||
ft.replace(R.id.content, fragment)
|
||||
ft.commit()
|
||||
|
||||
setContentView(binding.root)
|
||||
}
|
||||
|
||||
fun selected(abstractProduct: AbstractProduct) {
|
||||
val data = Intent()
|
||||
data.putExtra("abstractProduct", abstractProduct)
|
||||
setResult(Activity.RESULT_OK, data)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,13 @@ class MainActivity : AppCompatActivity() {
|
||||
setupViewPager(binding.tabViewpager)
|
||||
binding.tabTablayout.setupWithViewPager(binding.tabViewpager)
|
||||
|
||||
binding.expiryCalendarFab.setOnClickListener { _ ->
|
||||
val expiryCalendarIntent = Intent(this, ExpiryCalendarActivity::class.java)
|
||||
val extras = Bundle()
|
||||
expiryCalendarIntent.putExtras(extras)
|
||||
ContextCompat.startActivity(this, expiryCalendarIntent, extras)
|
||||
}
|
||||
|
||||
binding.newElementFab.setOnClickListener { view ->
|
||||
val currentPosition = binding.tabTablayout.selectedTabPosition
|
||||
val fragment = adapter.getItem(currentPosition)
|
||||
@@ -70,7 +77,7 @@ class MainActivity : AppCompatActivity() {
|
||||
private fun setupViewPager(viewpager: ViewPager) {
|
||||
adapter = ViewPagerAdapter(supportFragmentManager)
|
||||
|
||||
adapter.addFragment(StorageFragment(), getString(R.string.storage_title))
|
||||
adapter.addFragment(StorageFragment.newInstance("", arrayOf("")), getString(R.string.storage_title))
|
||||
adapter.addFragment(ShelfFragment(), getString(R.string.shelf_title))
|
||||
adapter.addFragment(CategoriesFragment(), getString(R.string.categories_title))
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.foxarmy.barcodescannerforemployees.R
|
||||
import org.foxarmy.barcodescannerforemployees.databinding.FragmentAddAbstractProductBinding
|
||||
|
||||
class AddAbstractProductFragment : Fragment() {
|
||||
@@ -16,6 +15,6 @@ class AddAbstractProductFragment : Fragment() {
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentAddAbstractProductBinding.inflate(layoutInflater)
|
||||
return inflater.inflate(R.layout.fragment_add_abstract_product, container, false)
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.foxarmy.barcodescannerforemployees.R
|
||||
import org.foxarmy.barcodescannerforemployees.databinding.FragmentAddProductBinding
|
||||
|
||||
class AddProductFragment : Fragment() {
|
||||
@@ -16,6 +15,6 @@ class AddProductFragment : Fragment() {
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentAddProductBinding.inflate(layoutInflater)
|
||||
return inflater.inflate(R.layout.fragment_add_product, container, false)
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.foxarmy.barcodescannerforemployees.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.foxarmy.barcodescannerforemployees.databinding.FragmentExpiryDatesBinding
|
||||
|
||||
class ExpiryDatesFragment : Fragment() {
|
||||
private lateinit var binding: FragmentExpiryDatesBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentExpiryDatesBinding.inflate(layoutInflater)
|
||||
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.foxarmy.barcodescannerforemployees.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.provider.BaseColumns
|
||||
@@ -28,6 +29,8 @@ class ShelfFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentShelfBinding
|
||||
private var updateInProgress = false
|
||||
private var filterBy = ""
|
||||
private var filter = ""
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
@@ -37,6 +40,12 @@ class ShelfFragment : Fragment() {
|
||||
|
||||
fillUpSortBySpinner()
|
||||
|
||||
val filterByDate = arguments?.getLong("filterByExpiryDate") as Long?
|
||||
if (filterByDate != null) {
|
||||
filter = filterByDate.toString()
|
||||
filterBy = "expiryDate"
|
||||
}
|
||||
|
||||
binding.spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
updateContent()
|
||||
@@ -135,7 +144,20 @@ class ShelfFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
val cursor = db.query(ProductContract.ProductEntry.TABLE_NAME, projection, null, null, null, null, orderBy)
|
||||
var selection: String? = null
|
||||
var selectionArgs: Array<String>? = null
|
||||
|
||||
when (filterBy) {
|
||||
"expiryDate" -> {
|
||||
selection = "${ProductContract.ProductEntry.EXPIRY_DATE} = ?"
|
||||
selectionArgs = arrayOf(filter)
|
||||
}
|
||||
|
||||
"" -> {}
|
||||
}
|
||||
|
||||
|
||||
val cursor = db.query(ProductContract.ProductEntry.TABLE_NAME, projection, selection, selectionArgs, null, null, orderBy)
|
||||
|
||||
val products = mutableListOf<Product>()
|
||||
|
||||
@@ -206,4 +228,16 @@ class ShelfFragment : Fragment() {
|
||||
updateContent()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun newInstance(date: Long):ShelfFragment = ShelfFragment().apply {
|
||||
val fragment = ShelfFragment()
|
||||
val args = Bundle()
|
||||
args.putLong("filterByExpiryDate", date)
|
||||
fragment.setArguments(args)
|
||||
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,7 @@ import android.provider.BaseColumns
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import android.widget.*
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.children
|
||||
import androidx.fragment.app.Fragment
|
||||
@@ -17,6 +14,7 @@ import org.foxarmy.barcodescannerforemployees.AbstractProductContract
|
||||
import org.foxarmy.barcodescannerforemployees.DBStorageController
|
||||
import org.foxarmy.barcodescannerforemployees.R
|
||||
import org.foxarmy.barcodescannerforemployees.activities.AddAbstractProductActivity
|
||||
import org.foxarmy.barcodescannerforemployees.activities.FindBarcodelessAbstractProduct
|
||||
import org.foxarmy.barcodescannerforemployees.databinding.FragmentStorageBinding
|
||||
import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
|
||||
import org.foxarmy.barcodescannerforemployees.generateThumbnailForImage
|
||||
@@ -26,7 +24,8 @@ import kotlin.concurrent.thread
|
||||
class StorageFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentStorageBinding
|
||||
private var filterByCategory = ""
|
||||
private var filterBy = ""
|
||||
private lateinit var filter: Array<String>
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
@@ -46,10 +45,13 @@ class StorageFragment : Fragment() {
|
||||
}
|
||||
|
||||
binding.dropFiltersButton.setOnClickListener {
|
||||
filterByCategory = ""
|
||||
filterBy = ""
|
||||
updateContent()
|
||||
}
|
||||
|
||||
filterBy = arguments?.getString("filterBy")!!
|
||||
filter = arguments?.getStringArray("filter")!!
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@@ -137,11 +139,18 @@ class StorageFragment : Fragment() {
|
||||
var selection = ""
|
||||
var selectionArgs: Array<String>? = null
|
||||
|
||||
if (filterByCategory != "") {
|
||||
selection = "${AbstractProductContract.AbstractProductEntry.CATEGORY} = ?"
|
||||
selectionArgs = arrayOf(filterByCategory)
|
||||
when (filterBy) {
|
||||
"category" -> {
|
||||
selection = "${AbstractProductContract.AbstractProductEntry.CATEGORY} = ?"
|
||||
selectionArgs = filter
|
||||
}
|
||||
"barcodeless" -> {
|
||||
selection = "${AbstractProductContract.AbstractProductEntry.BARCODE} = '' "
|
||||
selectionArgs = null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val cursor = db.query(AbstractProductContract.AbstractProductEntry.TABLE_NAME, projection, selection, selectionArgs, null, null, orderBy)
|
||||
|
||||
with (cursor) {
|
||||
@@ -164,6 +173,16 @@ class StorageFragment : Fragment() {
|
||||
product
|
||||
)
|
||||
|
||||
if (filterBy == "barcodeless") {
|
||||
abstractProduct.setOnClickListener {
|
||||
(activity as FindBarcodelessAbstractProduct).selected(abstractProduct.abstractProduct)
|
||||
}
|
||||
abstractProduct.findViewById<TextView>(R.id.productNameView).setOnClickListener {
|
||||
(activity as FindBarcodelessAbstractProduct).selected(abstractProduct.abstractProduct)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
activity!!.runOnUiThread{
|
||||
grv.addView(abstractProduct)
|
||||
}
|
||||
@@ -179,8 +198,20 @@ class StorageFragment : Fragment() {
|
||||
}
|
||||
|
||||
fun filterByCategory(id: Int) {
|
||||
// filterByCategory = DBStorageController(context!!).getCategoryNameById(DBStorageController(context!!).readableDatabase, id)
|
||||
filterByCategory = "$id"
|
||||
filterBy = "category"
|
||||
filter = arrayOf("$id")
|
||||
updateContent()
|
||||
}
|
||||
companion object {
|
||||
|
||||
fun newInstance(filterBy: String, filter: Array<String>):StorageFragment = StorageFragment().apply {
|
||||
val fragment = StorageFragment()
|
||||
val args = Bundle()
|
||||
args.putString("filterBy", filterBy)
|
||||
args.putStringArray("filter", filter)
|
||||
fragment.setArguments(args)
|
||||
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import android.view.LayoutInflater
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
@@ -71,6 +72,10 @@ class AbstractProductView: LinearLayout {
|
||||
this.background = ContextCompat.getDrawable(context, if (isProductSelected) R.drawable.outline_selected else R.drawable.outline)
|
||||
true
|
||||
}
|
||||
|
||||
productNameField!!.setOnClickListener {
|
||||
Toast.makeText(activity, productNameField!!.text, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
fun update() {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.foxarmy.barcodescannerforemployees.views
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import org.foxarmy.barcodescannerforemployees.DBStorageController
|
||||
import org.foxarmy.barcodescannerforemployees.R
|
||||
import org.foxarmy.barcodescannerforemployees.activities.ExpiryCalendarActivity
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
class ExpiryGroupView : LinearLayout {
|
||||
|
||||
private var representingDate: Long? = null
|
||||
|
||||
constructor(activity: Activity, context: Context, representingDate: Long) : super(context) {
|
||||
|
||||
val inflater: LayoutInflater = activity.layoutInflater
|
||||
inflater.inflate(R.layout.expiry_group_view, this)
|
||||
|
||||
this.representingDate = representingDate
|
||||
|
||||
this.background = ContextCompat.getDrawable(context,R.drawable.outline)
|
||||
|
||||
var amount = DBStorageController(context).findAmountOfProductsWithExpiryDate(DBStorageController(context).readableDatabase, representingDate)
|
||||
|
||||
findViewById<TextView>(R.id.representingDateTextView).text = SimpleDateFormat("dd.MM.yyyy").format(representingDate * 1000)
|
||||
findViewById<TextView>(R.id.amountTextView).text = amount.toString()
|
||||
|
||||
setOnClickListener {
|
||||
(activity as ExpiryCalendarActivity).displayDate(representingDate)
|
||||
// (activity as MainActivity).filterAbstractProductsByCategory(category.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,11 @@ class ProductView: LinearLayout {
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
fun update () {
|
||||
val linkedAbstractProduct: AbstractProduct = DBStorageController(activity).findAbstractProductById(DBStorageController(activity).readableDatabase, product.abstractProductId)!!
|
||||
val linkedAbstractProduct: AbstractProduct? = DBStorageController(activity).findAbstractProductById(DBStorageController(activity).readableDatabase, product.abstractProductId)
|
||||
|
||||
if(linkedAbstractProduct == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val thumbnailsDir = File(activity.cacheDir, "thumbnails")
|
||||
thumbnailsDir.mkdirs()
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".fragments.AddAbstractProductFragment">
|
||||
<include layout="@layout/content_add_abstract_product" android:id="@+id/include_content"/>
|
||||
<include layout="@layout/fragment_add_abstract_product" android:id="@+id/include_content"/>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@@ -1,10 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".fragments.AddProductFragment">
|
||||
<include layout="@layout/content_add_product" android:id="@+id/include_content"/>
|
||||
<include layout="@layout/fragment_add_product" android:id="@+id/include_content"/>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
9
app/src/main/res/layout/activity_expiry_calendar.xml
Normal file
9
app/src/main/res/layout/activity_expiry_calendar.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".fragments.ExpiryDatesFragment">
|
||||
<include layout="@layout/fragment_expiry_dates" android:id="@+id/include_content"/>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
10
app/src/main/res/layout/activity_expiry_calendar_group.xml
Normal file
10
app/src/main/res/layout/activity_expiry_calendar_group.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".fragments.ShelfFragment"
|
||||
android:id="@+id/content">
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".fragments.ShelfFragment"
|
||||
android:id="@+id/content">
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@@ -50,5 +50,12 @@
|
||||
android:layout_marginEnd="@dimen/fab_margin"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:srcCompat="@android:drawable/ic_input_add"/>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true" app:srcCompat="@android:drawable/ic_menu_my_calendar"
|
||||
android:id="@+id/expiryCalendarFab" android:layout_gravity="bottom|end"
|
||||
tools:layout_editor_absoluteY="742dp" tools:layout_editor_absoluteX="337dp"
|
||||
android:layout_marginBottom="84dp" android:layout_marginRight="16dp"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" android:id="@+id/addAbstractProductLayout">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" app:navGraph="@navigation/nav_graph_add_abstract_product"
|
||||
app:defaultNavHost="true" android:id="@+id/fragmentContainerView"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" android:id="@+id/addProductLayout">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" app:navGraph="@navigation/nav_graph_add_product"
|
||||
app:defaultNavHost="true" android:id="@+id/fragmentContainerView"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
17
app/src/main/res/layout/expiry_group_view.xml
Normal file
17
app/src/main/res/layout/expiry_group_view.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:text="TextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/representingDateTextView" android:layout_weight="1"
|
||||
android:textSize="45sp"/>
|
||||
<TextView
|
||||
android:text="TextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/amountTextView" android:layout_weight="1"
|
||||
android:textSize="45sp" android:textAlignment="textEnd"/>
|
||||
</LinearLayout>
|
||||
@@ -61,9 +61,16 @@
|
||||
android:inputType="text"
|
||||
android:ems="10"
|
||||
android:id="@+id/barcodeTextEdit" app:layout_constraintTop_toBottomOf="@+id/imageView"
|
||||
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginTop="8dp" android:hint="Barcode" android:textColorHint="#737373"
|
||||
android:layout_marginStart="5dp" android:layout_marginEnd="5dp"/>
|
||||
android:layout_marginStart="5dp"/>
|
||||
<CheckBox
|
||||
android:text="@string/no_barcode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/noBarcodeCheckBox"
|
||||
app:layout_constraintStart_toEndOf="@+id/barcodeTextEdit"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView" android:layout_marginTop="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
<TextView
|
||||
android:text="@string/category"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -21,83 +21,77 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/scanButton" android:layout_weight="1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/abstractProductView" android:layout_marginTop="16dp"/>
|
||||
app:layout_constraintTop_toBottomOf="@+id/abstractProductView" android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="32dp"/>
|
||||
<Button
|
||||
android:text="@string/no_barcode_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/noBarcodeButton"
|
||||
app:layout_constraintTop_toBottomOf="@+id/abstractProductView"
|
||||
app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="32dp"/>
|
||||
<TextView
|
||||
android:text="@string/date_of_production"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/dateOfProductionTextView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/scanButton"
|
||||
android:layout_marginTop="16dp" app:layout_constraintStart_toStartOf="parent"/>
|
||||
<Button
|
||||
android:text="@string/select"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/selectDateOfProductionButton"
|
||||
app:layout_constraintTop_toBottomOf="@+id/scanButton"
|
||||
app:layout_constraintStart_toEndOf="@+id/dateOfProductionTextView"
|
||||
android:layout_marginTop="48dp" app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
<RadioGroup
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@+id/selectDateOfProductionButton"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="16dp"
|
||||
android:orientation="horizontal" android:id="@+id/radioGroup">
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:orientation="horizontal" android:id="@+id/radioGroup"
|
||||
app:layout_constraintTop_toBottomOf="@+id/dateOfProductionDatePicker" android:layout_marginTop="16dp">
|
||||
<RadioButton
|
||||
android:text="@string/expiry_date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:id="@+id/expiryDateRadio"/>
|
||||
android:layout_height="match_parent" android:id="@+id/expiryDateRadio"/>
|
||||
<RadioButton
|
||||
android:text="@string/shelf_life"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:id="@+id/shelfLifeRadio"/>
|
||||
</RadioGroup>
|
||||
<TextView
|
||||
android:text="Expiry date: "
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/expiryDateTextView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/radioGroup" app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginStart="16dp" android:layout_marginTop="16dp" android:visibility="invisible"/>
|
||||
<Button
|
||||
android:text="Select"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/selectExpiryDateButton"
|
||||
app:layout_constraintTop_toBottomOf="@+id/radioGroup"
|
||||
app:layout_constraintStart_toEndOf="@+id/expiryDateTextView" android:layout_marginStart="16dp"
|
||||
android:visibility="invisible"/>
|
||||
<TextView
|
||||
android:text="Shelf life:"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/shelfLife"
|
||||
app:layout_constraintTop_toBottomOf="@+id/radioGroup"
|
||||
android:layout_marginTop="16dp" app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginStart="16dp" android:visibility="invisible"/>
|
||||
<DatePicker
|
||||
android:layout_width="247dp"
|
||||
android:layout_height="100dp" android:id="@+id/expiryDatePicker"
|
||||
android:datePickerMode="spinner"
|
||||
android:calendarViewShown="false"
|
||||
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.505" android:layout_marginTop="12dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/radioGroup" android:visibility="gone"/>
|
||||
<EditText
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="numberDecimal"
|
||||
android:ems="10"
|
||||
android:id="@+id/shelfLifeTextEdit" app:layout_constraintTop_toBottomOf="@+id/radioGroup"
|
||||
app:layout_constraintStart_toEndOf="@+id/expiryDateTextView" android:layout_marginStart="16dp"
|
||||
android:visibility="invisible"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/amountText"
|
||||
app:layout_constraintTop_toBottomOf="@+id/shelfLifeTextEdit"
|
||||
android:visibility="gone" app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" android:layout_marginTop="16dp"
|
||||
android:text="@string/amount"/>
|
||||
android:hint="@string/shelf_life"/>
|
||||
<EditText
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="numberSigned"
|
||||
android:ems="10"
|
||||
android:id="@+id/amountTextEdit"
|
||||
app:layout_constraintTop_toBottomOf="@+id/selectExpiryDateButton"
|
||||
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/amountText"/>
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:hint="@string/amount" app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/expiryDatePicker" android:layout_marginTop="12dp"/>
|
||||
<Button
|
||||
android:text="@string/saveButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:id="@+id/saveProductButton"
|
||||
app:layout_constraintTop_toBottomOf="@+id/amountTextEdit" app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="16dp"/>
|
||||
<DatePicker
|
||||
android:layout_width="247dp"
|
||||
android:layout_height="100dp" android:id="@+id/dateOfProductionDatePicker"
|
||||
android:datePickerMode="spinner"
|
||||
android:calendarViewShown="false"
|
||||
app:layout_constraintTop_toBottomOf="@+id/dateOfProductionTextView"
|
||||
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginTop="16dp" app:layout_constraintHorizontal_bias="0.505"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
21
app/src/main/res/layout/fragment_expiry_dates.xml
Normal file
21
app/src/main/res/layout/fragment_expiry_dates.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:id="@+id/layout">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/scrollView">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:id="@+id/datesLinearLayout">
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:background="#141218">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/nav_graph_add_abstract_product"
|
||||
app:startDestination="@id/addAbstractProductFragment">
|
||||
|
||||
<fragment android:id="@+id/addAbstractProductFragment"
|
||||
android:name="org.foxarmy.barcodescannerforemployees.fragments.AddAbstractProductFragment"
|
||||
android:label="activity_add_abstract_product" tools:layout="@layout/fragment_add_abstract_product"/>
|
||||
</navigation>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/nav_graph_add_product"
|
||||
app:startDestination="@id/addProductFragment">
|
||||
|
||||
<fragment android:id="@+id/addProductFragment"
|
||||
android:name="org.foxarmy.barcodescannerforemployees.fragments.AddProductFragment"
|
||||
android:label="activity_add_product" tools:layout="@layout/fragment_add_product"/>
|
||||
</navigation>
|
||||
@@ -80,4 +80,13 @@
|
||||
<string name="abstract_product_does_not_exist">Абстрактный продукт с таким штрихкодом не существует. Хотите его добавить?. </string>
|
||||
<string name="drop_filters">Убрать фильтры</string>
|
||||
<string name="category_name_required">Требуется название категории</string>
|
||||
<string name="abstract_product_already_exists">Такой абстрактный продукт в ваше базе данных уже есть</string>
|
||||
<string name="quit">Выйти</string>
|
||||
<string name="edit_existing">Редактировать существующий</string>
|
||||
<string name="no_product_in_online_database">Продукт не найден в онлайн базе данных. Попробуйте снова, если это
|
||||
ошибка сканирования или введите данные вручную
|
||||
</string>
|
||||
<string name="abstract_product_request">Пожалуйста, отсканируйте штрихкод, чтобы добавить продукт</string>
|
||||
<string name="no_barcode">No barcode present</string>
|
||||
<string name="no_barcode_button">No barcode</string>
|
||||
</resources>
|
||||
@@ -78,4 +78,13 @@
|
||||
<string name="abstract_product_does_not_exist">Abstract product with such barcode does not exist. Do you want to add one?</string>
|
||||
<string name="drop_filters">Drop filters</string>
|
||||
<string name="category_name_required">Category name required</string>
|
||||
<string name="abstract_product_already_exists">You\'ve got an abstract product with such barcode in your database.</string>
|
||||
<string name="quit">Quit</string>
|
||||
<string name="edit_existing">Edit existing</string>
|
||||
<string name="no_product_in_online_database">Product not found. Please, try again if you beleive barcode scanned
|
||||
wrongly or type manually
|
||||
</string>
|
||||
<string name="abstract_product_request">Please, scan a barcode in order to add product</string>
|
||||
<string name="no_barcode">No barcode present</string>
|
||||
<string name="no_barcode_button">No barcode</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user