Huge load of shit, hope I'll be able to do it normally
This commit is contained in:
		@@ -36,6 +36,14 @@
 | 
			
		||||
                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.FullscreenActivity"
 | 
			
		||||
                android:configChanges="orientation|keyboardHidden|screenSize"
 | 
			
		||||
@@ -49,7 +57,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.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(
 | 
			
		||||
 
 | 
			
		||||
@@ -77,7 +77,6 @@ class AddProductActivity : AppCompatActivity() {
 | 
			
		||||
            update()
 | 
			
		||||
        } else {
 | 
			
		||||
            product = Product(0, 0, 0, 0, 0)
 | 
			
		||||
            abstractProduct = AbstractProduct(0, "", "", 0.0, "", 0, 0)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        scanButton.setOnClickListener {
 | 
			
		||||
@@ -111,6 +110,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
 | 
			
		||||
@@ -145,6 +149,12 @@ 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 fun update () {
 | 
			
		||||
@@ -158,14 +168,6 @@ class AddProductActivity : AppCompatActivity() {
 | 
			
		||||
            shelfLifeTextEdit.visibility = View.VISIBLE
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val dateOfProduction = SimpleDateFormat("dd.MM.yyyy").format(product!!.dateOfProduction * 1000).split(".")
 | 
			
		||||
 | 
			
		||||
        dateOfProductionDatePicker.updateDate(dateOfProduction[2].toInt(), dateOfProduction[1].toInt(), dateOfProduction[0].toInt())
 | 
			
		||||
 | 
			
		||||
        val expiryDate = SimpleDateFormat("dd.MM.yyyy").format(product!!.dateOfExpiry * 1000).split(".")
 | 
			
		||||
 | 
			
		||||
        expiryDatePicker.updateDate(expiryDate[2].toInt(), expiryDate[1].toInt(), expiryDate[0].toInt())
 | 
			
		||||
 | 
			
		||||
        if (amountTextEdit.text.toString() == "") {
 | 
			
		||||
            amountTextEdit.setText(product!!.amount.toString())
 | 
			
		||||
        } else {
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,33 @@
 | 
			
		||||
package org.foxarmy.barcodescannerforemployees.activities
 | 
			
		||||
 | 
			
		||||
import android.content.Intent
 | 
			
		||||
import android.os.Bundle
 | 
			
		||||
import androidx.appcompat.app.AppCompatActivity
 | 
			
		||||
import androidx.core.content.ContextCompat
 | 
			
		||||
import org.foxarmy.barcodescannerforemployees.databinding.ActivityExpiryCalendarBinding
 | 
			
		||||
 | 
			
		||||
class ExpiryCalendarActivity : AppCompatActivity() {
 | 
			
		||||
    private lateinit var binding: ActivityExpiryCalendarBinding
 | 
			
		||||
 | 
			
		||||
    override fun onCreate(savedInstanceState: Bundle?) {
 | 
			
		||||
        super.onCreate(savedInstanceState)
 | 
			
		||||
 | 
			
		||||
        binding = ActivityExpiryCalendarBinding.inflate(layoutInflater)
 | 
			
		||||
        setContentView(binding.root)
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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)
 | 
			
		||||
 | 
			
		||||
//        val shelfFragment = ShelfFragment.newInstance(date)
 | 
			
		||||
//        val ft = supportFragmentManager.beginTransaction()
 | 
			
		||||
//        ft.replace(R.id.include_content, shelfFragment)
 | 
			
		||||
//        ft.commit()
 | 
			
		||||
//        ft.addToBackStack(null)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,26 @@
 | 
			
		||||
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")
 | 
			
		||||
 | 
			
		||||
//        binding.root.addView(ShelfFragment.newInstance(date).view!!.rootView)
 | 
			
		||||
        val ft = supportFragmentManager.beginTransaction()
 | 
			
		||||
        ft.replace(R.id.content, ShelfFragment.newInstance(date))
 | 
			
		||||
        ft.commit()
 | 
			
		||||
        setContentView(binding.root)
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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,37 @@
 | 
			
		||||
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.DBStorageController
 | 
			
		||||
import org.foxarmy.barcodescannerforemployees.databinding.FragmentExpiryDatesBinding
 | 
			
		||||
import org.foxarmy.barcodescannerforemployees.views.ExpiryGroupView
 | 
			
		||||
 | 
			
		||||
class ExpiryDatesFragment : Fragment() {
 | 
			
		||||
    private lateinit var binding: FragmentExpiryDatesBinding
 | 
			
		||||
 | 
			
		||||
    override fun onCreateView(
 | 
			
		||||
        inflater: LayoutInflater, container: ViewGroup?,
 | 
			
		||||
        savedInstanceState: Bundle?
 | 
			
		||||
    ): View {
 | 
			
		||||
        binding = FragmentExpiryDatesBinding.inflate(layoutInflater)
 | 
			
		||||
 | 
			
		||||
        fillUp()
 | 
			
		||||
 | 
			
		||||
        return binding.root
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private fun fillUp() {
 | 
			
		||||
        val dates = DBStorageController(requireContext()).findAllExpiryDates(DBStorageController(requireContext()).readableDatabase)
 | 
			
		||||
 | 
			
		||||
        val container = binding.datesLinearLayout
 | 
			
		||||
 | 
			
		||||
        dates.forEach { date ->
 | 
			
		||||
            val newDate = ExpiryGroupView(requireActivity(), requireContext(), date)
 | 
			
		||||
            container.addView(newDate)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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()
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										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/content_expiry_calendar" 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>
 | 
			
		||||
@@ -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>
 | 
			
		||||
							
								
								
									
										14
									
								
								app/src/main/res/layout/content_expiry_calendar.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								app/src/main/res/layout/content_expiry_calendar.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
<?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/expiryCalendarContent">
 | 
			
		||||
 | 
			
		||||
    <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_expiry_calendar"
 | 
			
		||||
            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>
 | 
			
		||||
@@ -48,7 +48,7 @@
 | 
			
		||||
        </RadioGroup>
 | 
			
		||||
        <DatePicker
 | 
			
		||||
                android:layout_width="247dp"
 | 
			
		||||
                android:layout_height="78dp" android:id="@+id/expiryDatePicker"
 | 
			
		||||
                android:layout_height="100dp" android:id="@+id/expiryDatePicker"
 | 
			
		||||
                android:datePickerMode="spinner"
 | 
			
		||||
                android:calendarViewShown="false"
 | 
			
		||||
                app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
 | 
			
		||||
@@ -80,7 +80,7 @@
 | 
			
		||||
                app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="16dp"/>
 | 
			
		||||
        <DatePicker
 | 
			
		||||
                android:layout_width="247dp"
 | 
			
		||||
                android:layout_height="78dp" android:id="@+id/dateOfProductionDatePicker"
 | 
			
		||||
                android:layout_height="100dp" android:id="@+id/dateOfProductionDatePicker"
 | 
			
		||||
                android:datePickerMode="spinner"
 | 
			
		||||
                android:calendarViewShown="false"
 | 
			
		||||
                app:layout_constraintTop_toBottomOf="@+id/dateOfProductionTextView"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										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>
 | 
			
		||||
@@ -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"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								app/src/main/res/navigation/nav_graph_expiry_calendar.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/src/main/res/navigation/nav_graph_expiry_calendar.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<?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/navigation_graph_expiry_calendar"
 | 
			
		||||
            app:startDestination="@id/expiryDatesFragment">
 | 
			
		||||
 | 
			
		||||
    <fragment android:id="@+id/expiryDatesFragment"
 | 
			
		||||
              android:name="org.foxarmy.barcodescannerforemployees.fragments.ExpiryDatesFragment"
 | 
			
		||||
              android:label="expiry dates" tools:layout="@layout/fragment_expiry_dates"/>
 | 
			
		||||
</navigation>
 | 
			
		||||
@@ -86,4 +86,5 @@
 | 
			
		||||
    <string name="no_product_in_online_database">Продукт не найден в онлайн базе данных. Попробуйте снова, если это
 | 
			
		||||
        ошибка сканирования или введите данные вручную
 | 
			
		||||
    </string>
 | 
			
		||||
    <string name="abstract_product_request">Пожалуйста, отсканируйте штрихкод, чтобы добавить продукт</string>
 | 
			
		||||
</resources>
 | 
			
		||||
@@ -84,4 +84,5 @@
 | 
			
		||||
    <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>
 | 
			
		||||
</resources>
 | 
			
		||||
		Reference in New Issue
	
	Block a user