This commit is contained in:
leca 2024-09-27 15:58:34 +03:00
parent 8496a6f2f4
commit daed52e004
14 changed files with 233 additions and 135 deletions

View File

@ -4,6 +4,14 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-09-26T16:53:52.475667960Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=RF8X50341NV" />
</handle>
</Target>
</DropdownSelection>
<DialogSelection />
</SelectionState> </SelectionState>
</selectionStates> </selectionStates>
</component> </component>

View File

@ -43,6 +43,7 @@ dependencies {
implementation(libs.androidx.constraintlayout) implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.navigation.fragment.ktx) implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx) implementation(libs.androidx.navigation.ui.ktx)
implementation(libs.firebase.crashlytics.buildtools)
testImplementation(libs.junit) testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core) androidTestImplementation(libs.androidx.espresso.core)

View File

@ -3,6 +3,11 @@
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:name="android.hardware.camera" android:required="true"/> <uses-feature android:name="android.hardware.camera" android:required="true"/>
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
@ -12,7 +17,17 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.BarcodeScannerForEmployees" android:theme="@style/Theme.BarcodeScannerForEmployees"
android:authorities="org.foxarmy.barcodescannerforemployees.providers"
tools:targetApi="31"> tools:targetApi="31">
<provider
android:authorities="com.google.firebase.components.MainActivity.provider"
android:name="androidx.core.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_path"/>
</provider>
<meta-data <meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES" android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="barcode_ui" > android:value="barcode_ui" >
@ -23,10 +38,8 @@
android:theme="@style/Theme.BarcodeScannerForEmployees"> android:theme="@style/Theme.BarcodeScannerForEmployees">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>
</manifest> </manifest>

View File

@ -1,9 +1,14 @@
package org.foxarmy.barcodescannerforemployees package org.foxarmy.barcodescannerforemployees
import android.content.Context import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Log
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import android.widget.Toast
import java.io.File
/** /**
* TODO: document your custom view class. * TODO: document your custom view class.
@ -16,10 +21,21 @@ class AbstractProductView: LinearLayout {
constructor(context: Context, productImageFile: String, productName: String, netWeight: Double, category: Int) : super(context) { constructor(context: Context, productImageFile: String, productName: String, netWeight: Double, category: Int) : super(context) {
// this.layerType =
// setLayerType()
this.orientation = LinearLayout.VERTICAL this.orientation = LinearLayout.VERTICAL
// productImage.set
val imageFile = File(File(context.filesDir, "pictures"), productImageFile)
val image: ByteArray = imageFile.readBytes()
if (image.isEmpty()) {
Toast.makeText(context, image.size.toString(), Toast.LENGTH_LONG).show()
}
try {
Log.d("org.foxarmy.barcodescannerforemployees", "[ХУЙ]" + imageFile.absolutePath)
val bitmap: Bitmap = BitmapFactory.decodeFile(imageFile.absolutePath)
} catch (e:Exception) {
Log.d("org.foxarmy.barcodescannerforemployees", "[ХУЙ] " + e)
}
// productImage.setImageBitmap(bitmap)
productNameField.setText(productName) productNameField.setText(productName)
netWeightField.setText(netWeight.toString()) netWeightField.setText(netWeight.toString())

View File

@ -1,24 +1,20 @@
package org.foxarmy.barcodescannerforemployees package org.foxarmy.barcodescannerforemployees
//import com.google.mlkit.vision.codescanner.GmsBarcodeScannerOptions //import com.google.mlkit.vision.codescanner.GmsBarcodeScannerOptions
import android.app.Activity import android.os.Build
import android.content.Intent
import android.graphics.Bitmap
import android.os.Bundle import android.os.Bundle
import android.provider.MediaStore import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi
import androidx.core.content.FileProvider
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import com.google.mlkit.vision.barcode.common.Barcode import com.google.firebase.components.BuildConfig
import com.google.mlkit.vision.codescanner.GmsBarcodeScannerOptions
import com.google.mlkit.vision.codescanner.GmsBarcodeScanning
import org.foxarmy.barcodescannerforemployees.databinding.AddProductFragmentBinding import org.foxarmy.barcodescannerforemployees.databinding.AddProductFragmentBinding
import java.io.File import java.io.File
import java.io.FileOutputStream
import java.nio.ByteBuffer
import java.security.MessageDigest import java.security.MessageDigest
@ -29,74 +25,126 @@ fun String.md5(): String {
return digest.toHexString() return digest.toHexString()
} }
/**
* A simple [Fragment] subclass as the default destination in the navigation.
*/
class AddProductFragment : Fragment() { class AddProductFragment : Fragment() {
private var _binding: AddProductFragmentBinding? = null private var _binding: AddProductFragmentBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!! private val binding get() = _binding!!
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View { ): View {
_binding = AddProductFragmentBinding.inflate(inflater, container, false) _binding = AddProductFragmentBinding.inflate(inflater, container, false)
return binding.root return binding.root
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { val takePicture = registerForActivityResult(ActivityResultContracts.TakePicture()) { success: Boolean ->
super.onActivityResult(requestCode, resultCode, data) if (success) {
when (requestCode) { Log.i("QWERTYUIOP", "Done")
200 -> {
if (resultCode == Activity.RESULT_OK && data != null) {
val picture = (data.extras?.get("data") as Bitmap)
binding.imageView.setImageBitmap(picture)
val picturesPath = context?.filesDir
val dir = File(picturesPath, "pictures")
dir.mkdirs()
val filename = picture.toString().md5()
val file = File(dir, filename)
FileOutputStream(file).use {
val b = ByteBuffer.allocate(picture.byteCount)
picture.copyPixelsToBuffer(b)
it.write(b.array())
}
}
}
}
}
val requestPermissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission()
) { isGranted ->
if (isGranted) {
val cameraIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
startActivityForResult(cameraIntent, 200)
} else { } else {
Toast.makeText( Log.e("QWERTYUIOP", "Xuinya")
requireContext(),
"I need permission for camera in order to take a picture!",
Toast.LENGTH_LONG
).show()
} }
} }
fun getPicture () {
val imageFile = File(requireContext().filesDir, "image.png")
val imageUri = FileProvider.getUriForFile(requireActivity(), BuildConfig.APPLICATION_ID + "." + requireActivity().localClassName + ".provider", imageFile)
takePicture.launch(imageUri)
}
val requestPermissionLauncher =
registerForActivityResult(
ActivityResultContracts.RequestPermission()
) { isGranted: Boolean ->
if (isGranted) {
Toast.makeText(requireContext(), "Granted", Toast.LENGTH_LONG).show()
// getFuckingPicture()
} else {
Toast.makeText(requireContext(), "I need permission in order to take a picture", Toast.LENGTH_LONG).show()
}
}
@RequiresApi(Build.VERSION_CODES.R)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.saveButton.setOnClickListener { binding.takePictureButton.setOnClickListener {
// requestPermissionLauncher.launch(android.Manifest.permission.CAMERA)
try {
getPicture()
} catch (e:Exception) {
Log.e("QWERTYUIOP", e.message.toString())
}
// try {
// when{
// ContextCompat.checkSelfPermission(requireContext(), android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED -> {
// getFuckingPicture()
// } else -> {
//// requestPermissionLauncher.launch(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
//// ActivityCompat.requestPermissions(requireActivity(), arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE), 200)
//
// Log.e("QWERTYUIOP", "хуй соси губой тряси")
// }
// }
//
// } catch (e:Exception) {
// Log.e("QWERTYUIOP", e.message.toString())
// }
}
/*
binding.saveButton.setOnClickListener {
val productName = binding.productName.text.toString()
val netWeight = binding.netWeight.text
if (picture == null) {
Toast.makeText(context, "Please, make a picture of a product!", Toast.LENGTH_SHORT).show()
return@setOnClickListener
}
if (productName == "") {
Toast.makeText(context, "Please, write a name of a product!", Toast.LENGTH_SHORT).show()
return@setOnClickListener
}
if (netWeight.toString() == "" || netWeight.toString().toDoubleOrNull() == null) {
Toast.makeText(context, "Please, write a valid net weight of a product!", Toast.LENGTH_SHORT).show()
}
val appFiles = context?.filesDir
val picturesDir = File(appFiles, "pictures")
picturesDir.mkdirs()
val imageFilename = picture.toString().md5() + ".png"
val imageFile = File(picturesDir, imageFilename)
val stream = FileOutputStream(imageFile)
picture!!.compress(Bitmap.CompressFormat.PNG, 100, stream)
stream.use {
val buffer = ByteBuffer.allocate(picture!!.byteCount)
picture!!.copyPixelsToBuffer(buffer)
it.write(buffer.array())
}
val db = DBStorageController(requireContext()).writableDatabase
val values = ContentValues().apply {
put(ProductContract.ProductEntry.PRODUCT_NAME, productName)
put(ProductContract.ProductEntry.PRODUCT_NET_WEIGHT, netWeight.toString())
put(ProductContract.ProductEntry.IMAGE_FILENAME, imageFilename)
}
db.insert(ProductContract.ProductEntry.TABLE_NAME, null, values)
} }
binding.takePictureButton.setOnClickListener { binding.takePictureButton.setOnClickListener {
requestPermissionLauncher.launch(android.Manifest.permission.CAMERA) requestPermissionLauncher.launch(android.Manifest.permission.CAMERA)
// val imageUri: Uri = Uri.fromFile(File(File(context?.filesDir, "pictures"), "test.jpg"))
// val imageUri = Uri.parse("pictures/test.jpg")
// val picturesDir = File(context?.filesDir, "pictures")
// picturesDir.mkdirs()
// val uri = Uri.fromFile(File(picturesDir, "test.jpg"))
// Log.d("", uri.toString())
// takePicture.launch(uri)
} }
binding.scanButton.setOnClickListener { binding.scanButton.setOnClickListener {
@ -109,6 +157,8 @@ class AddProductFragment : Fragment() {
scanner.startScan() scanner.startScan()
.addOnSuccessListener { barcode -> .addOnSuccessListener { barcode ->
binding.productName.setText(barcode.rawValue) binding.productName.setText(barcode.rawValue)
// val url = URL()
} }
.addOnFailureListener { e -> .addOnFailureListener { e ->
Toast.makeText( Toast.makeText(
@ -118,6 +168,7 @@ class AddProductFragment : Fragment() {
).show() ).show()
} }
} }
*/
} }
override fun onDestroyView() { override fun onDestroyView() {

View File

@ -14,17 +14,43 @@ object ProductContract {
} }
} }
const val SQL_CREATE_ENTRIES = object ShelfContract {
object ShelfEntry : BaseColumns {
const val TABLE_NAME = "shelf"
const val PRODUCT_ID = "product_id"
const val EXPIRE_DATE = "expire_date"
}
}
object CategoriesContract {
object CategoryEntry : BaseColumns {
const val TABLE_NAME = "categories"
const val CATEGORY_NAME = "category_name"
}
}
const val SQL_CREATE_PRODUCT_TABLE =
"CREATE TABLE ${ProductContract.ProductEntry.TABLE_NAME} (" + "CREATE TABLE ${ProductContract.ProductEntry.TABLE_NAME} (" +
"${BaseColumns._ID} INTEGER PRIMARY KEY," + "${BaseColumns._ID} INTEGER PRIMARY KEY," +
"${ProductContract.ProductEntry.PRODUCT_NAME} TEXT," + "${ProductContract.ProductEntry.PRODUCT_NAME} TEXT," +
"${ProductContract.ProductEntry.PRODUCT_NET_WEIGHT} TEXT" + "${ProductContract.ProductEntry.PRODUCT_NET_WEIGHT} REAL," +
"${ProductContract.ProductEntry.IMAGE_FILENAME} TEXT)" "${ProductContract.ProductEntry.IMAGE_FILENAME} TEXT)"
const val SQL_CREATE_SHELF_TABLE =
"CREATE TABLE ${ShelfContract.ShelfEntry.TABLE_NAME} (" +
"${ShelfContract.ShelfEntry.PRODUCT_ID} INTEGER," +
"${ShelfContract.ShelfEntry.EXPIRE_DATE} DATE)"
const val SQL_CREATE_CATEGORIES_TABLE =
"CREATE TABLE ${CategoriesContract.CategoryEntry.TABLE_NAME} (" +
"${CategoriesContract.CategoryEntry.CATEGORY_NAME} TEXT)"
class DBStorageController(context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) { class DBStorageController(context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
override fun onCreate(db: SQLiteDatabase) { override fun onCreate(db: SQLiteDatabase) {
db.execSQL(SQL_CREATE_ENTRIES) db.execSQL(SQL_CREATE_PRODUCT_TABLE)
db.execSQL(SQL_CREATE_SHELF_TABLE)
db.execSQL(SQL_CREATE_CATEGORIES_TABLE)
} }
override fun onUpgrade(p0: SQLiteDatabase?, p1: Int, p2: Int) { override fun onUpgrade(p0: SQLiteDatabase?, p1: Int, p2: Int) {
@ -34,6 +60,6 @@ class DBStorageController(context: Context) : SQLiteOpenHelper (context, DATABAS
companion object { companion object {
// If you change the database schema, you must increment the database version. // If you change the database schema, you must increment the database version.
const val DATABASE_VERSION = 1 const val DATABASE_VERSION = 1
const val DATABASE_NAME = "FeedReader.db" const val DATABASE_NAME = "database.db"
} }
} }

View File

@ -19,33 +19,6 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val dbHelper = DBStorageController(applicationContext) val dbHelper = DBStorageController(applicationContext)
// val db = dbHelper.writableDatabase
//
// val values = ContentValues().apply {
// put(ProductContract.ProductEntry.PRODUCT_NAME, "Имя продукта")
// put(ProductContract.ProductEntry.PRODUCT_NET_WEIGHT, "0г")
// put(ProductContract.ProductEntry.IMAGE_FILENAME, "image.png")
// }
//
// val netRowId = db?.insert(ProductContract.ProductEntry.TABLE_NAME, null, values)
// val db2 = dbHelper.readableDatabase
//
// val projection = arrayOf(BaseColumns._ID, ProductContract.ProductEntry.PRODUCT_NAME, ProductContract.ProductEntry.PRODUCT_NET_WEIGHT, ProductContract.ProductEntry.IMAGE_FILENAME)
//
// val selection = "${ProductContract.ProductEntry.PRODUCT_NAME} = ?"
// val selectionArgs = arrayOf("Имя продукта")
//
// val cursor = db2.query(
// ProductContract.ProductEntry.TABLE_NAME,
// null,
// selection,
// selectionArgs,
// null,
// null,
// null
// )
binding = ActivityMainBinding.inflate(layoutInflater) binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
@ -56,24 +29,16 @@ class MainActivity : AppCompatActivity() {
setupActionBarWithNavController(navController, appBarConfiguration) setupActionBarWithNavController(navController, appBarConfiguration)
binding.addProductFab.setOnClickListener { view -> binding.addProductFab.setOnClickListener { view ->
// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
// .setAction("Action", null)
// .setAnchorView(R.id.add_product_fab).show()
// Toast.makeText(applicationContext, "Test", Toast.LENGTH_SHORT).show()
navController.navigate(R.id.AddProductFragment) navController.navigate(R.id.AddProductFragment)
} }
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater.inflate(R.menu.menu_main, menu) menuInflater.inflate(R.menu.menu_main, menu)
return true return true
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
return when (item.itemId) { return when (item.itemId) {
R.id.action_settings -> true R.id.action_settings -> true
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)

View File

@ -1,12 +0,0 @@
package org.foxarmy.barcodescannerforemployees
import android.provider.BaseColumns
//object ProductContract {
// object ProductEntry :BaseColumns {
// const val TABLE_NAME = "products"
// const val PRODUCT_NAME = "name"
// const val PRODUCT_NET_WEIGHT = "net_weight"
// const val IMAGE_FILENAME = "image_filename"
// }
//}

View File

@ -1,6 +1,7 @@
package org.foxarmy.barcodescannerforemployees package org.foxarmy.barcodescannerforemployees
import android.os.Bundle import android.os.Bundle
import android.provider.BaseColumns
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -29,14 +30,32 @@ class StorageFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val db = DBStorageController(requireContext()).readableDatabase
val projection = arrayOf(BaseColumns._ID, ProductContract.ProductEntry.PRODUCT_NAME, ProductContract.ProductEntry.PRODUCT_NET_WEIGHT, ProductContract.ProductEntry.IMAGE_FILENAME)
val selection = "${ProductContract.ProductEntry.PRODUCT_NAME} = ?"
val selectionArgs = arrayOf("test")
val cursor = db.query(ProductContract.ProductEntry.TABLE_NAME, projection, selection, selectionArgs, null, null, null)
with (cursor) {
while(moveToNext()) {
val productName = getString(getColumnIndexOrThrow(ProductContract.ProductEntry.PRODUCT_NAME))
val netWeight = getDouble(getColumnIndexOrThrow(ProductContract.ProductEntry.PRODUCT_NET_WEIGHT))
val pictureFilename = getString(getColumnIndexOrThrow(ProductContract.ProductEntry.IMAGE_FILENAME))
getView()?.findViewById<ConstraintLayout>(R.id.storageLayout)?.addView( getView()?.findViewById<ConstraintLayout>(R.id.storageLayout)?.addView(
AbstractProductView( AbstractProductView(
requireContext(), requireContext(),
productImageFile = "test1", productImageFile = pictureFilename,
productName = "test2", productName = productName,
netWeight = 1.1, netWeight = netWeight,
category = 1 category = 1
) )
) )
} }
} }
}
}

View File

@ -2,10 +2,3 @@ package org.foxarmy.barcodescannerforemployees
import android.provider.BaseColumns import android.provider.BaseColumns
object ShelfContract {
object ShelfEntry : BaseColumns {
const val TABLE_NAME = "shelf"
const val PRODUCT_ID = "product_id"
const val EXPIRE_DATE = "expire_date"
}
}

View File

@ -16,7 +16,7 @@
android:layout_height="50dp" android:layout_height="50dp"
android:text="@string/scan_label" android:text="@string/scan_label"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextText" app:layout_constraintTop_toBottomOf="@+id/netWeight"
android:layout_marginTop="25dp"/> android:layout_marginTop="25dp"/>
<ImageView <ImageView
android:src="@android:drawable/ic_menu_camera" android:src="@android:drawable/ic_menu_camera"
@ -35,7 +35,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:layout_marginStart="8dp" android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/editTextText" app:layout_constraintBottom_toTopOf="@+id/netWeight"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
android:visibility="visible" android:hint="@string/product_name_label" android:textColorHint="#737373" android:visibility="visible" android:hint="@string/product_name_label" android:textColorHint="#737373"
app:layout_constraintTop_toBottomOf="@+id/imageView"/> app:layout_constraintTop_toBottomOf="@+id/imageView"/>
@ -44,7 +44,7 @@
android:layout_height="50dp" android:layout_height="50dp"
android:inputType="text" android:inputType="text"
android:ems="10" android:ems="10"
android:id="@+id/editTextText" android:id="@+id/netWeight"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
@ -55,13 +55,13 @@
android:text="@string/saveButton" android:text="@string/saveButton"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="50dp" android:id="@+id/saveButton" android:layout_height="50dp" android:id="@+id/saveButton"
app:layout_constraintTop_toBottomOf="@+id/editTextText" app:layout_constraintTop_toBottomOf="@+id/netWeight"
android:layout_marginTop="25dp" app:layout_constraintEnd_toEndOf="parent"/> android:layout_marginTop="25dp" app:layout_constraintEnd_toEndOf="parent"/>
<Button <Button
android:text="@string/takePicture" android:text="@string/takePicture"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="55dp" android:id="@+id/takePictureButton" android:layout_height="55dp" android:id="@+id/takePictureButton"
app:layout_constraintTop_toBottomOf="@+id/editTextText" app:layout_constraintTop_toBottomOf="@+id/netWeight"
android:layout_marginTop="24dp" app:layout_constraintStart_toEndOf="@+id/scan_button" android:layout_marginTop="24dp" app:layout_constraintStart_toEndOf="@+id/scan_button"
android:layout_marginStart="33dp" app:layout_constraintEnd_toStartOf="@+id/saveButton" android:layout_marginStart="33dp" app:layout_constraintEnd_toStartOf="@+id/saveButton"
android:layout_marginEnd="6dp" app:layout_constraintHorizontal_bias="0.0"/> android:layout_marginEnd="6dp" app:layout_constraintHorizontal_bias="0.0"/>

View File

@ -7,11 +7,9 @@
<string name="scan_label">Scan</string> <string name="scan_label">Scan</string>
<string name="previous">Previous</string> <string name="previous">Previous</string>
<string name="product_name_label">Product name</string> <string name="product_name_label">Product name</string>
<string name="netWeight">Net weight</string> <string name="netWeight">Net weight (g)</string>
<string name="saveButton">Save</string> <string name="saveButton">Save</string>
<string name="takePicture">Take picture</string> <string name="takePicture">Take picture</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="productName">Product name</string> <string name="productName">Product name</string>
<string name="productType">Product type</string> <string name="productType">Product type</string>
<string name="imageOfAProduct">Image of a product</string> <string name="imageOfAProduct">Image of a product</string>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="external"
path="." />
<external-files-path
name="external_files"
path="." />
<cache-path
name="cache"
path="." />
<external-cache-path
name="external_cache"
path="." />
<files-path
name="files"
path="." />
</paths>

View File

@ -12,6 +12,7 @@ material = "1.12.0"
constraintlayout = "2.1.4" constraintlayout = "2.1.4"
navigationFragmentKtx = "2.8.0" navigationFragmentKtx = "2.8.0"
navigationUiKtx = "2.8.0" navigationUiKtx = "2.8.0"
firebaseCrashlyticsBuildtools = "3.0.2"
[libraries] [libraries]
androidx-camera-view = { module = "androidx.camera:camera-view", version.ref = "cameraView" } androidx-camera-view = { module = "androidx.camera:camera-view", version.ref = "cameraView" }
@ -25,6 +26,7 @@ material = { group = "com.google.android.material", name = "material", version.r
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
androidx-navigation-fragment-ktx = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigationFragmentKtx" } androidx-navigation-fragment-ktx = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigationFragmentKtx" }
androidx-navigation-ui-ktx = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigationUiKtx" } androidx-navigation-ui-ktx = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigationUiKtx" }
firebase-crashlytics-buildtools = { group = "com.google.firebase", name = "firebase-crashlytics-buildtools", version.ref = "firebaseCrashlyticsBuildtools" }
[plugins] [plugins]
android-application = { id = "com.android.application", version.ref = "agp" } android-application = { id = "com.android.application", version.ref = "agp" }