From cfef250d38d954d4c0eed1b3572710cbbfd769d3 Mon Sep 17 00:00:00 2001 From: leca Date: Tue, 8 Oct 2024 02:28:49 +0300 Subject: [PATCH] cleanup --- .../DBStorageController.kt | 4 -- .../ViewPagerAdapter.kt | 6 +-- .../activities/AddProductActivity.kt | 4 -- .../activities/FullscreenActivity.kt | 2 - .../activities/MainActivity.kt | 11 ----- .../fragments/CategoriesFragment.kt | 40 ------------------- .../shelfContract.kt | 4 -- .../views/AbstractProductView.kt | 5 +-- 8 files changed, 4 insertions(+), 72 deletions(-) delete mode 100644 app/src/main/java/org/foxarmy/barcodescannerforemployees/shelfContract.kt diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/DBStorageController.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/DBStorageController.kt index 3bdabb2..6cb2eab 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/DBStorageController.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/DBStorageController.kt @@ -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) } diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/ViewPagerAdapter.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/ViewPagerAdapter.kt index d907729..5dcc205 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/ViewPagerAdapter.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/ViewPagerAdapter.kt @@ -7,10 +7,10 @@ import androidx.fragment.app.FragmentPagerAdapter class ViewPagerAdapter public constructor(supportFragmentManager: FragmentManager) : FragmentPagerAdapter(supportFragmentManager) { - private final var fragmentList1: ArrayList = ArrayList() - private final var fragmentTitleList1: ArrayList = ArrayList() + private var fragmentList1: ArrayList = ArrayList() + private var fragmentTitleList1: ArrayList = ArrayList() - public override fun getItem(position: Int): Fragment { + override fun getItem(position: Int): Fragment { return fragmentList1.get(position) } diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AddProductActivity.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AddProductActivity.kt index 83bda71..71d1c4b 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AddProductActivity.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AddProductActivity.kt @@ -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") } diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/FullscreenActivity.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/FullscreenActivity.kt index 600c2b3..5ead467 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/FullscreenActivity.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/FullscreenActivity.kt @@ -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() diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/MainActivity.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/MainActivity.kt index 8a87d8e..0ac5ea9 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/MainActivity.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/MainActivity.kt @@ -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() -// } } \ No newline at end of file diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/fragments/CategoriesFragment.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/fragments/CategoriesFragment.kt index 4b39971..5cee199 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/fragments/CategoriesFragment.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/fragments/CategoriesFragment.kt @@ -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(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) diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/shelfContract.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/shelfContract.kt deleted file mode 100644 index 307afc7..0000000 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/shelfContract.kt +++ /dev/null @@ -1,4 +0,0 @@ -package org.foxarmy.barcodescannerforemployees - -import android.provider.BaseColumns - diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/views/AbstractProductView.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/views/AbstractProductView.kt index d3bf0ba..5f7d9ee 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/views/AbstractProductView.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/views/AbstractProductView.kt @@ -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 }