This commit is contained in:
leca 2024-10-08 02:28:49 +03:00
parent 5fb481a0d5
commit cfef250d38
8 changed files with 4 additions and 72 deletions

View File

@ -4,7 +4,6 @@ import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.provider.BaseColumns
import android.util.Log
import java.io.File
object ProductContract {
@ -54,7 +53,6 @@ const val SQL_CREATE_CATEGORIES_TABLE =
class DBStorageController(context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
override fun onCreate(db: SQLiteDatabase) {
Log.d("QWERTYUIOP", SQL_CREATE_PRODUCT_TABLE)
db.execSQL(SQL_CREATE_PRODUCT_TABLE)
db.execSQL(SQL_CREATE_SHELF_TABLE)
db.execSQL(SQL_CREATE_CATEGORIES_TABLE)
@ -88,13 +86,11 @@ class DBStorageController(context: Context) : SQLiteOpenHelper(context, DATABASE
imageHash = productImageHash
}
}
Log.d("QWERTYUIOP", "Deleting image with hash: $imageHash and $id")
val picturesDir = File(context.filesDir, "pictures")
val thumbnailsDir = File(context.cacheDir, "thumbnails")
File(picturesDir, "$imageHash.png").delete()
File(thumbnailsDir, "$imageHash.webp").delete()
Log.d("QWERTYUIOP", BaseColumns._ID + "=" + id)
db.delete(ProductContract.ProductEntry.TABLE_NAME, BaseColumns._ID + "=" + id, null)
}

View File

@ -7,10 +7,10 @@ import androidx.fragment.app.FragmentPagerAdapter
class ViewPagerAdapter
public constructor(supportFragmentManager: FragmentManager) : FragmentPagerAdapter(supportFragmentManager) {
private final var fragmentList1: ArrayList<Fragment> = ArrayList()
private final var fragmentTitleList1: ArrayList<String> = ArrayList()
private var fragmentList1: ArrayList<Fragment> = ArrayList()
private var fragmentTitleList1: ArrayList<String> = ArrayList()
public override fun getItem(position: Int): Fragment {
override fun getItem(position: Int): Fragment {
return fragmentList1.get(position)
}

View File

@ -80,15 +80,12 @@ class AddProductActivity : AppCompatActivity() {
put(ProductContract.ProductEntry.CATEGORY, categorySpinner.selectedItemPosition)
}
Log.d("QWERTYUIOP", "SIP ${categorySpinner.selectedItemPosition}")
db.insert(ProductContract.ProductEntry.TABLE_NAME, null, values)
finish()
}
takePictureButton.setOnClickListener {
Log.d("QWERTYUIOP", "test")
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
@ -154,7 +151,6 @@ class AddProductActivity : AppCompatActivity() {
generateThumbnailForImage(this, imageHash)
imageView.setImageURI(getImageUri(this, pictureFile))
Log.i("QWERTYUIOP", "Picture saved")
} else {
Log.e("QWERTYUIOP", "Cannot save a picture")
}

View File

@ -33,9 +33,7 @@ class FullscreenActivity : Activity() {
val picturesDir = File(filesDir, "pictures")
picturesDir.mkdirs()
Log.d("QWERTYUIOP", imageHash.toString())
val fullscreenImageFile = File(picturesDir, "$imageHash.png")
// crash. change activity
fullscreenImageView.setImageURI(getImageUri(this, fullscreenImageFile))
fullscreenImageView.setOnClickListener {
this.finish()

View File

@ -15,7 +15,6 @@ import org.foxarmy.barcodescannerforemployees.fragments.StorageFragment
class MainActivity : AppCompatActivity() {
// private lateinit var appBarConfiguration: AppBarConfiguration
private lateinit var binding: ActivityMainBinding
public lateinit var adapter: ViewPagerAdapter
@ -29,10 +28,6 @@ class MainActivity : AppCompatActivity() {
setupViewPager(binding.tabViewpager)
binding.tabTablayout.setupWithViewPager(binding.tabViewpager)
// val navController = findNavController(R.id.nav_host_fragment_content_storage)
// appBarConfiguration = AppBarConfiguration(navController.graph)
// setupActionBarWithNavController(navController, appBarConfiguration)
binding.newElementFab.setOnClickListener { view ->
val currentPosition = binding.tabTablayout.selectedTabPosition
val fragment = adapter.getItem(currentPosition)
@ -92,10 +87,4 @@ class MainActivity : AppCompatActivity() {
else -> super.onOptionsItemSelected(item)
}
}
// override fun onSupportNavigateUp(): Boolean {
// val navController = findNavController(R.id.nav_host_fragment_content_storage)
// return navController.navigateUp(appBarConfiguration)
// || super.onSupportNavigateUp()
// }
}

View File

@ -14,15 +14,10 @@ import org.foxarmy.barcodescannerforemployees.R
import org.foxarmy.barcodescannerforemployees.views.CategoryView
class CategoriesFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_categories, container, false)
}
@ -57,41 +52,6 @@ class CategoriesFragment : Fragment() {
}
}
}
// public fun updateContent() {
//
// val grv = getView()?.findViewById<GridLayout>(R.id.contentGridLayout)
// grv?.removeAllViews()
//
// val db = DBStorageController(requireContext()).readableDatabase
// val projection = arrayOf(
// BaseColumns._ID,
// ProductContract.ProductEntry.PRODUCT_NAME,
// ProductContract.ProductEntry.PRODUCT_NET_WEIGHT,
// ProductContract.ProductEntry.IMAGE_FILENAME
// )
//
// val cursor = db.query(ProductContract.ProductEntry.TABLE_NAME, projection, null, null, null, null, null)
//
// with (cursor) {
// while(moveToNext()) {
// val productId = getInt(getColumnIndexOrThrow(BaseColumns._ID))
// val productName = getString(getColumnIndexOrThrow(ProductContract.ProductEntry.PRODUCT_NAME))
// val netWeight = getDouble(getColumnIndexOrThrow(ProductContract.ProductEntry.PRODUCT_NET_WEIGHT))
// val productImageHash = getString(getColumnIndexOrThrow(ProductContract.ProductEntry.IMAGE_FILENAME))
//
// val product = AbstractProduct(productId, productName, netWeight, productImageHash, 1)
//
// generateThumbnailForImage(context!!, productImageHash)
//
// val abstractProduct = AbstractProductView(
// requireActivity(),
// requireContext(),
// product
// )
// grv?.addView(abstractProduct)
// }
// }
// }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

View File

@ -1,4 +0,0 @@
package org.foxarmy.barcodescannerforemployees
import android.provider.BaseColumns

View File

@ -4,7 +4,6 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.widget.ImageView
import android.widget.LinearLayout
@ -25,7 +24,7 @@ class AbstractProductView: LinearLayout {
private var netWeightField: TextView
private var categoryField: TextView
private var unitField: TextView
public var product: AbstractProduct
var product: AbstractProduct
var isProductSelected = false
constructor(activity: Activity, context: Context, product: AbstractProduct) : super(context) {
@ -67,8 +66,6 @@ class AbstractProductView: LinearLayout {
productLayout.setOnLongClickListener {
isProductSelected = !isProductSelected
Log.d("QWERTYUIOP", "Changed to value $isProductSelected")
this.background = ContextCompat.getDrawable(context, if (isProductSelected) R.drawable.outline_selected else R.drawable.outline)
true
}