diff --git a/.idea/misc.xml b/.idea/misc.xml
index 96b0eed..f86549b 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -12,16 +12,19 @@
-
+
+
+
-
+
+
diff --git a/app/src/main/java/com/example/acapendulum20/PendulumSettingsFragment.kt b/app/src/main/java/com/example/acapendulum20/PendulumSettingsFragment.kt
new file mode 100644
index 0000000..bc26c8c
--- /dev/null
+++ b/app/src/main/java/com/example/acapendulum20/PendulumSettingsFragment.kt
@@ -0,0 +1,59 @@
+package com.example.acapendulum20
+
+import android.os.Bundle
+import androidx.fragment.app.Fragment
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+
+// TODO: Rename parameter arguments, choose names that match
+// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
+private const val ARG_PARAM1 = "param1"
+private const val ARG_PARAM2 = "param2"
+
+/**
+ * A simple [Fragment] subclass.
+ * Use the [PendulumSettingsFragment.newInstance] factory method to
+ * create an instance of this fragment.
+ */
+class PendulumSettingsFragment : Fragment() {
+ // TODO: Rename and change types of parameters
+ private var param1: String? = null
+ private var param2: String? = null
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ arguments?.let {
+ param1 = it.getString(ARG_PARAM1)
+ param2 = it.getString(ARG_PARAM2)
+ }
+ }
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.fragment_pendulum_settings, container, false)
+ }
+
+ companion object {
+ /**
+ * Use this factory method to create a new instance of
+ * this fragment using the provided parameters.
+ *
+ * @param param1 Parameter 1.
+ * @param param2 Parameter 2.
+ * @return A new instance of fragment PendulumSettingsFragment.
+ */
+ // TODO: Rename and change types and number of parameters
+ @JvmStatic
+ fun newInstance(param1: String, param2: String) =
+ PendulumSettingsFragment().apply {
+ arguments = Bundle().apply {
+ putString(ARG_PARAM1, param1)
+ putString(ARG_PARAM2, param2)
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/acapendulum20/canvas/CanvasPendulum.kt b/app/src/main/java/com/example/acapendulum20/canvas/CanvasPendulum.kt
index 00d8c1b..709673c 100644
--- a/app/src/main/java/com/example/acapendulum20/canvas/CanvasPendulum.kt
+++ b/app/src/main/java/com/example/acapendulum20/canvas/CanvasPendulum.kt
@@ -147,14 +147,15 @@ class Pendulum {
var startPosition: Position = Position(0f, 0f)
var stopPosition: Position = Position(0f, 0f)
- var stringLength = 900f
- //start angle
var startAngle: Double = Math.PI / 12
- var angleVelocity: Float = 0.0f //
- var angleAcceleration: Float = 0.0f //
- var ballRadius: Float = 70.0f //
- var magneticField: Boolean = false
- var gravity = 0.981f
+ var stringLength = 750f
+ var ballRadius: Float = 70.0f
var damping = 0.996f
+
+ var angleVelocity: Float = 0.0f
+ var angleAcceleration: Float = 0.0f
+
+ var gravity = 0.981f
+ var magneticField: Boolean = false
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/acapendulum20/data/MeasurementDao.kt b/app/src/main/java/com/example/acapendulum20/data/MeasurementDao.kt
index df7553d..51fe108 100644
--- a/app/src/main/java/com/example/acapendulum20/data/MeasurementDao.kt
+++ b/app/src/main/java/com/example/acapendulum20/data/MeasurementDao.kt
@@ -3,7 +3,6 @@ package com.example.acapendulum20.data
import androidx.lifecycle.LiveData
import androidx.room.*
import com.example.acapendulum20.model.Measurement
-import com.example.acapendulum20.model.User
@Dao
interface MeasurementDao {
@@ -14,11 +13,12 @@ interface MeasurementDao {
@Update
fun finishMeasurement(measurement: Measurement)
+ @Delete
+ fun deleteMeasurement(measurement: Measurement)
+
@Query("SELECT * FROM measurement_table WHERE owner =:id AND completed = 1")
fun readAllData(id: String): LiveData>
@Query("SELECT * FROM measurement_table ")
fun readAllData(): LiveData>
-
-
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/acapendulum20/fragments/add/AddFragment.kt b/app/src/main/java/com/example/acapendulum20/fragments/add/AddFragment.kt
index cde7400..f593112 100644
--- a/app/src/main/java/com/example/acapendulum20/fragments/add/AddFragment.kt
+++ b/app/src/main/java/com/example/acapendulum20/fragments/add/AddFragment.kt
@@ -1,12 +1,13 @@
package com.example.acapendulum20.fragments.add
+import android.app.DatePickerDialog
import android.os.Bundle
-import android.text.Editable
import android.text.TextUtils
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
@@ -15,8 +16,10 @@ import com.example.acapendulum20.model.User
import com.example.acapendulum20.viewmodel.UserViewmodel
import kotlinx.android.synthetic.main.fragment_add.*
import kotlinx.android.synthetic.main.fragment_add.view.*
+import kotlinx.android.synthetic.main.fragment_start_pendulum.view.*
import java.util.*
+
class AddFragment : Fragment() {
private lateinit var mUserViewModel: UserViewmodel
@@ -30,6 +33,28 @@ class AddFragment : Fragment() {
mUserViewModel = ViewModelProvider(this).get(UserViewmodel::class.java)
+ //dropdown sex
+ val sex = resources.getStringArray(R.array.sex)
+ val arrayAdapterSex = ArrayAdapter(requireContext(), R.layout.dropdown_item, sex)
+ view.chooseSex_et.setAdapter(arrayAdapterSex)
+
+ //dropdown handiness
+ val handiness = resources.getStringArray(R.array.usedHand)
+ val arrayAdapterHandiness = ArrayAdapter(requireContext(), R.layout.dropdown_item, handiness)
+ view.addHandiness_et.setAdapter(arrayAdapterHandiness)
+
+ //Date picker
+ view.addBirthday_et.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 datePickerDialog = DatePickerDialog(requireActivity(), { view, year, monthOfYear, dayOfMonth ->
+ addBirthday_et.text = (dayOfMonth.toString() + "-" + (monthOfYear + 1) + "-" + year) }, year, month, day)
+ datePickerDialog.show()
+ }
+
view.add_btn.setOnClickListener{
insertDataToDatabase()
}
@@ -39,13 +64,13 @@ class AddFragment : Fragment() {
private fun insertDataToDatabase() {
val firstName = addFirstName_et.text.toString()
val lastName = addLastName_et.text.toString()
- val age = addAge_et.text.toString()
- val sex = addSex_et.text.toString()
+ val birthday = addBirthday_et.text.toString()
+ val sex = chooseSex_et.text.toString()
val handiness = addHandiness_et.text.toString()
- if(inputCheck(firstName, lastName, sex, handiness, age)){
+ if(inputCheck(firstName, lastName, sex, handiness, birthday)){
//Create User Object
- val user = User(UUID.randomUUID().toString(), firstName, lastName,Integer.parseInt(age), sex, handiness)
+ val user = User(UUID.randomUUID().toString(), firstName, lastName, birthday, sex, handiness)
//Add Data to Database
mUserViewModel.addUser(user)
Toast.makeText(requireContext(),"Successfully added!", Toast.LENGTH_LONG).show()
diff --git a/app/src/main/java/com/example/acapendulum20/fragments/list/ListAdapter.kt b/app/src/main/java/com/example/acapendulum20/fragments/list/ListAdapter.kt
index 9f772c6..f9a37d1 100644
--- a/app/src/main/java/com/example/acapendulum20/fragments/list/ListAdapter.kt
+++ b/app/src/main/java/com/example/acapendulum20/fragments/list/ListAdapter.kt
@@ -7,10 +7,12 @@ import androidx.navigation.findNavController
import androidx.recyclerview.widget.RecyclerView
import com.example.acapendulum20.R
import com.example.acapendulum20.model.User
+import com.example.acapendulum20.viewmodel.MeasurementViewmodel
import kotlinx.android.synthetic.main.custom_row.view.*
class ListAdapter: RecyclerView.Adapter() {
+
private var userList = emptyList()
class MyViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
@@ -30,7 +32,7 @@ class ListAdapter: RecyclerView.Adapter() {
holder.itemView.id_txt.text = (position+1).toString()
holder.itemView.firstName_txt.text = currentItem.firstName
holder.itemView.lastName_txt.text = currentItem.lastName
- holder.itemView.age_txt.text = currentItem.age.toString()
+ holder.itemView.age_txt.text = currentItem.birthday
holder.itemView.sex_txt.text = currentItem.sex
holder.itemView.handiness_txt.text = currentItem.handiness
diff --git a/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumFragment.kt b/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumFragment.kt
index 85b8b74..cd16d9e 100644
--- a/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumFragment.kt
+++ b/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumFragment.kt
@@ -106,10 +106,11 @@ class PendulumFragment : Fragment() {
val measuredTime = ((endTime - args.measurement.startTime).toDouble()) / 1000
//val measuredVelocity = args.measurement.measuredVelocity
val targetVelocity = args.measurement.targetVelocity
+ val usedHand = args.measurement.usedHand
//println(measuredTime)
if (save === true){
- val measurement = Measurement(args.measurement.id,targetVelocity,maxAttemptTime,velocity,measuredTime,args.measurement.startTime,endTime,true, args.measurement.owner)
+ val measurement = Measurement(args.measurement.id,targetVelocity,maxAttemptTime,velocity,measuredTime,args.measurement.startTime,endTime,true, usedHand,args.measurement.owner)
mMeasurementViewmodel.finishMeasurement(measurement)
}
}
diff --git a/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumSettingsFragment.kt b/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumSettingsFragment.kt
new file mode 100644
index 0000000..986d2ba
--- /dev/null
+++ b/app/src/main/java/com/example/acapendulum20/fragments/pendulum/PendulumSettingsFragment.kt
@@ -0,0 +1,8 @@
+package com.example.acapendulum20.fragments.pendulum
+
+import android.app.DatePickerDialog
+import java.util.*
+
+class PendulumSettingsFragment {
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/acapendulum20/fragments/pendulum/StartPendulumFragment.kt b/app/src/main/java/com/example/acapendulum20/fragments/pendulum/StartPendulumFragment.kt
index ef44426..00e5e7b 100644
--- a/app/src/main/java/com/example/acapendulum20/fragments/pendulum/StartPendulumFragment.kt
+++ b/app/src/main/java/com/example/acapendulum20/fragments/pendulum/StartPendulumFragment.kt
@@ -6,6 +6,7 @@ import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
@@ -19,6 +20,8 @@ import com.example.acapendulum20.model.Measurement
import com.example.acapendulum20.model.User
import com.example.acapendulum20.viewmodel.MeasurementViewmodel
import com.example.acapendulum20.viewmodel.UserViewmodel
+import kotlinx.android.synthetic.main.custom_row_measurement.*
+import kotlinx.android.synthetic.main.fragment_add.view.*
import kotlinx.android.synthetic.main.fragment_start_pendulum.*
import kotlinx.android.synthetic.main.fragment_start_pendulum.view.*
import java.time.Instant
@@ -35,11 +38,17 @@ class StartPendulumFragment: Fragment() {
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
+
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.fragment_start_pendulum, container, false)
mMeasurementViewmodel = ViewModelProvider(this).get(MeasurementViewmodel::class.java)
+ //dropdown handiness
+ val usedHand = resources.getStringArray(R.array.usedHand)
+ val arrayAdapter = ArrayAdapter(requireContext(), R.layout.dropdown_item, usedHand)
+ view.chooseHandiness_et.setAdapter(arrayAdapter)
+
//navigate to pendulumFragment
view.startPendulum_btn.setOnClickListener{
startMeasurement()
@@ -49,15 +58,13 @@ class StartPendulumFragment: Fragment() {
private fun startMeasurement() {
val targetVelocity = (targetVelocity_et.text).toString()
val maxAttemptTime = (maxAttemptTime_et.text).toString()
+ val usedHand = (chooseHandiness_et.text).toString()
val owner = args.owner
- //val startTime = DateTimeFormatter.ISO_INSTANT.format(Instant.now())
val startTime = System.currentTimeMillis()
- //println("${number::class.qualifiedName}") // "kotlin.Int"
-
if(inputCheck(targetVelocity, maxAttemptTime)){
//Create Measurement Object
- val measurement = Measurement(UUID.randomUUID().toString(), targetVelocity.toFloat(),maxAttemptTime.toLong(),0.00f,0.00,startTime,0,false,owner)
+ val measurement = Measurement(UUID.randomUUID().toString(), targetVelocity.toFloat(),maxAttemptTime.toLong(),0.00f,0.00,startTime,0,false, usedHand,owner)
//Add Data to Database
mMeasurementViewmodel.addMeasurement(measurement)
Toast.makeText(requireContext(),"Successfully added!", Toast.LENGTH_LONG).show()
diff --git a/app/src/main/java/com/example/acapendulum20/fragments/update/MeasurementList.kt b/app/src/main/java/com/example/acapendulum20/fragments/update/MeasurementList.kt
index c68e53d..39a5e1a 100644
--- a/app/src/main/java/com/example/acapendulum20/fragments/update/MeasurementList.kt
+++ b/app/src/main/java/com/example/acapendulum20/fragments/update/MeasurementList.kt
@@ -4,15 +4,22 @@ package com.example.acapendulum20.fragments.list
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.lifecycle.ViewModelProvider
+import androidx.lifecycle.get
import androidx.recyclerview.widget.RecyclerView
import com.example.acapendulum20.R
+import com.example.acapendulum20.canvas.CanvasPendulum
import com.example.acapendulum20.model.Measurement
+import com.example.acapendulum20.repository.MeasurementRepository
import kotlinx.android.synthetic.main.custom_row_measurement.view.*
import java.text.SimpleDateFormat
import java.util.*
+import com.example.acapendulum20.viewmodel.MeasurementViewmodel
class MeasurementList: RecyclerView.Adapter() {
+ private lateinit var mMeasurementViewmodel: MeasurementViewmodel
+
private var sessionList = emptyList()
class MyViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
@@ -28,6 +35,7 @@ class MeasurementList: RecyclerView.Adapter() {
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
+
val currentItem = sessionList[position]
fun convertLongToTime(time: Long): String {
@@ -35,14 +43,18 @@ class MeasurementList: RecyclerView.Adapter() {
val format = SimpleDateFormat("dd.MM.yyyy HH:mm")
return format.format(date)
}
-
holder.itemView.nr_txt.text = (position+1).toString()
holder.itemView.dateStart_txt.text = "Start: " + convertLongToTime(currentItem.startTime)
- holder.itemView.dateEnd_txt.text = "End: " + convertLongToTime(currentItem.endTime)
holder.itemView.targetVelocity_txt.text ="target: " + currentItem.targetVelocity.toString() + "cm/s"
holder.itemView.velocity_txt.text ="measured: " + currentItem.measuredVelocity.toString() + "cm/s"
holder.itemView.maxTime_txt.text ="max time: " + currentItem.maxAttemptTime.toString() + "sec"
holder.itemView.time_txt.text ="measured time: " + currentItem.measuredTime.toString() + "sec"
+ holder.itemView.usedHand_txt.text = "used hand: " + currentItem.usedHand
+
+ holder.itemView.deleteMeasurement_btn.setOnClickListener{
+ deleteMeasurement()
+ }
+
}
fun setData(measurement: List){
@@ -50,5 +62,9 @@ class MeasurementList: RecyclerView.Adapter() {
notifyDataSetChanged()
}
+ private fun deleteMeasurement() {
+ mMeasurementViewmodel = ViewModelProvider(this).get(MeasurementViewmodel::class.java)
+ }
+
}
diff --git a/app/src/main/java/com/example/acapendulum20/fragments/update/UpdateFragment.kt b/app/src/main/java/com/example/acapendulum20/fragments/update/UpdateFragment.kt
index a66191e..6d46e79 100644
--- a/app/src/main/java/com/example/acapendulum20/fragments/update/UpdateFragment.kt
+++ b/app/src/main/java/com/example/acapendulum20/fragments/update/UpdateFragment.kt
@@ -1,10 +1,11 @@
package com.example.acapendulum20.fragments.update
import android.app.AlertDialog
+import android.app.DatePickerDialog
import android.os.Bundle
-import android.text.Editable
import android.text.TextUtils
import android.view.*
+import android.widget.ArrayAdapter
import androidx.fragment.app.Fragment
import android.widget.Toast
import androidx.lifecycle.Observer
@@ -14,11 +15,18 @@ import androidx.navigation.fragment.navArgs
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.acapendulum20.R
import com.example.acapendulum20.fragments.list.MeasurementList
+import com.example.acapendulum20.model.Measurement
import com.example.acapendulum20.model.User
import com.example.acapendulum20.viewmodel.MeasurementViewmodel
import com.example.acapendulum20.viewmodel.UserViewmodel
+import kotlinx.android.synthetic.main.fragment_add.*
+import kotlinx.android.synthetic.main.fragment_add.view.*
+import kotlinx.android.synthetic.main.fragment_start_pendulum.*
import kotlinx.android.synthetic.main.fragment_update.*
import kotlinx.android.synthetic.main.fragment_update.view.*
+import kotlinx.coroutines.processNextEventInCurrentThread
+import java.util.*
+import kotlin.system.measureNanoTime
class UpdateFragment : Fragment() {
@@ -34,6 +42,28 @@ class UpdateFragment : Fragment() {
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.fragment_update, container, false)
+ //dropdown sex
+ val sex = resources.getStringArray(R.array.sex)
+ val arrayAdapter = ArrayAdapter(requireContext(), R.layout.dropdown_item, sex)
+ view.updateSex_et.setAdapter(arrayAdapter)
+
+ //dropdown handiness
+ val handiness = resources.getStringArray(R.array.usedHand)
+ val arrayAdapterHandiness = ArrayAdapter(requireContext(), R.layout.dropdown_item, handiness)
+ view.updateHandiness_et.setAdapter(arrayAdapterHandiness)
+
+ //Date picker
+ view.updateBirthday_et.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 datePickerDialog = DatePickerDialog(requireActivity(), { view, year, monthOfYear, dayOfMonth ->
+ updateBirthday_et.text = (dayOfMonth.toString() + "-" + (monthOfYear + 1) + "-" + year) }, year, month, day)
+ datePickerDialog.show()
+ }
+
//Recylerview
val adapter = MeasurementList()
val recyclerView = view.SessionRecyclerview
@@ -49,9 +79,9 @@ class UpdateFragment : Fragment() {
view.updateFirstName_et.setText(args.currentUser.firstName)
view.updateLastName_et.setText(args.currentUser.lastName)
- view.updateAge_et.setText(args.currentUser.age.toString())
- view.updateSex_et.setText(args.currentUser.sex)
- view.updateHandiness_et.setText(args.currentUser.handiness)
+ view.updateBirthday_et.setText(args.currentUser.birthday)
+ view.updateSex_et.hint = args.currentUser.sex
+ view.updateHandiness_et.hint = args.currentUser.handiness
//navigate to fragment_start_pendulum
view.startTest_btn.setOnClickListener{
@@ -74,13 +104,13 @@ class UpdateFragment : Fragment() {
private fun updateItem(){
val firstName = updateFirstName_et.text.toString()
val lastName = updateLastName_et.text.toString()
- val age = Integer.parseInt(updateAge_et.text.toString())
+ val birthday = updateBirthday_et.text.toString()
val sex = updateSex_et.text.toString()
val handiness = updateHandiness_et.text.toString()
- if(inputCheck(firstName, lastName, sex, handiness, updateAge_et.text)){
+ if(inputCheck(firstName, lastName, sex, handiness, birthday)){
// Create User Object
- val updatedUser = User(args.currentUser.id, firstName, lastName, age, sex, handiness)
+ val updatedUser = User(args.currentUser.id, firstName, lastName, birthday, sex, handiness)
// update current User
mUserViewModel.updateUser(updatedUser)
Toast.makeText(requireContext(), "Updated Successfully!", Toast.LENGTH_SHORT).show()
@@ -91,7 +121,7 @@ class UpdateFragment : Fragment() {
}
}
- private fun inputCheck(firstName: String, lastName: String, sex: String, handiness:String, age: Editable): Boolean{
+ private fun inputCheck(firstName: String, lastName: String, sex: String, handiness:String, age: String): Boolean{
return !(TextUtils.isEmpty(firstName) && TextUtils.isEmpty(lastName) && TextUtils.isEmpty(sex) && TextUtils.isEmpty(handiness) && age.isEmpty())
}
@@ -118,4 +148,5 @@ class UpdateFragment : Fragment() {
builder.setMessage("Are you sure you want to delete ${args.currentUser.firstName}?")
builder.create().show()
}
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/acapendulum20/model/Measurement.kt b/app/src/main/java/com/example/acapendulum20/model/Measurement.kt
index 14b2fd8..958e1d1 100644
--- a/app/src/main/java/com/example/acapendulum20/model/Measurement.kt
+++ b/app/src/main/java/com/example/acapendulum20/model/Measurement.kt
@@ -21,5 +21,6 @@ data class Measurement(
val startTime: Long,
val endTime: Long,
val completed: Boolean,
+ val usedHand: String,
val owner: String,
): Parcelable
diff --git a/app/src/main/java/com/example/acapendulum20/model/User.kt b/app/src/main/java/com/example/acapendulum20/model/User.kt
index 1791c4d..bad26da 100644
--- a/app/src/main/java/com/example/acapendulum20/model/User.kt
+++ b/app/src/main/java/com/example/acapendulum20/model/User.kt
@@ -7,12 +7,12 @@ import kotlinx.android.parcel.Parcelize
@Parcelize
@Entity(tableName = "user_table")
-data class User (
+data class User(
@PrimaryKey
val id: String,
val firstName: String,
val lastName: String,
- val age: Int,
+ val birthday: String,
val sex: String,
val handiness: String,
): Parcelable
\ No newline at end of file
diff --git a/app/src/main/java/com/example/acapendulum20/repository/MeasurementRepository.kt b/app/src/main/java/com/example/acapendulum20/repository/MeasurementRepository.kt
index 50f5f09..c3296f5 100644
--- a/app/src/main/java/com/example/acapendulum20/repository/MeasurementRepository.kt
+++ b/app/src/main/java/com/example/acapendulum20/repository/MeasurementRepository.kt
@@ -2,9 +2,7 @@ package com.example.acapendulum20.repository
import androidx.lifecycle.LiveData
import com.example.acapendulum20.data.MeasurementDao
-import com.example.acapendulum20.data.UserDao
import com.example.acapendulum20.model.Measurement
-import com.example.acapendulum20.model.User
class MeasurementRepository(private val measurementDao: MeasurementDao) {
@@ -22,4 +20,9 @@ class MeasurementRepository(private val measurementDao: MeasurementDao) {
return measurementDao.readAllData(id)
}
+ suspend fun deleteMeasurement(measurement: Measurement){
+ measurementDao.deleteMeasurement(measurement)
+ }
+
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/acapendulum20/viewmodel/MeasurementViewmodel.kt b/app/src/main/java/com/example/acapendulum20/viewmodel/MeasurementViewmodel.kt
index 5690123..66d92d4 100644
--- a/app/src/main/java/com/example/acapendulum20/viewmodel/MeasurementViewmodel.kt
+++ b/app/src/main/java/com/example/acapendulum20/viewmodel/MeasurementViewmodel.kt
@@ -1,10 +1,8 @@
package com.example.acapendulum20.viewmodel
import android.app.Application
-import android.content.Context
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
-import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.acapendulum20.data.PendulumDatabase
import com.example.acapendulum20.model.Measurement
@@ -14,7 +12,7 @@ import kotlinx.coroutines.launch
class MeasurementViewmodel(application: Application): AndroidViewModel(application) {
- lateinit var readAllData: LiveData>
+ //lateinit var readAllData: LiveData>
private val repository: MeasurementRepository
init{
@@ -37,4 +35,10 @@ class MeasurementViewmodel(application: Application): AndroidViewModel(applicati
fun readAllDataForUserId(id: String){
readAllData= repository.readAllDataMeasurement(id)
}
+
+ fun deleteMeasurement(measurement: Measurement){
+ viewModelScope.launch(Dispatchers.IO) {
+ repository.deleteMeasurement(measurement)
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/custom_row.xml b/app/src/main/res/layout/custom_row.xml
index 9b85f4f..17cd1b7 100644
--- a/app/src/main/res/layout/custom_row.xml
+++ b/app/src/main/res/layout/custom_row.xml
@@ -47,7 +47,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
- android:text="(30)"
+ android:text="(11.11.2000)"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/lastName_txt"
diff --git a/app/src/main/res/layout/custom_row_measurement.xml b/app/src/main/res/layout/custom_row_measurement.xml
index e460f69..3e6316c 100644
--- a/app/src/main/res/layout/custom_row_measurement.xml
+++ b/app/src/main/res/layout/custom_row_measurement.xml
@@ -11,8 +11,8 @@
@@ -51,27 +50,24 @@
android:id="@+id/targetVelocity_txt"
android:layout_width="165dp"
android:layout_height="24dp"
- android:layout_marginTop="4dp"
android:text="targetVelocity"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHorizontal_bias="0.142"
+ app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/dateStart_txt"
- app:layout_constraintVertical_bias="0.0" />
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_bias="0.35" />
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_bias="0.35000002" />
+ app:layout_constraintTop_toBottomOf="@+id/targetVelocity_txt" />
+ app:layout_constraintTop_toBottomOf="@+id/velocity_txt"
+ app:layout_constraintVertical_bias="0.142" />
+ app:layout_constraintTop_toBottomOf="@+id/maxTime_txt"
+ app:layout_constraintVertical_bias="1.0" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/dropdown_item.xml b/app/src/main/res/layout/dropdown_item.xml
new file mode 100644
index 0000000..dd9b524
--- /dev/null
+++ b/app/src/main/res/layout/dropdown_item.xml
@@ -0,0 +1,9 @@
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_add.xml b/app/src/main/res/layout/fragment_add.xml
index dbbfc8e..10e4a2a 100644
--- a/app/src/main/res/layout/fragment_add.xml
+++ b/app/src/main/res/layout/fragment_add.xml
@@ -7,13 +7,36 @@
android:padding="40dp"
tools:context=".fragments.add.AddFragment">
+
+
+
+
+
+
@@ -24,56 +47,62 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:ems="10"
+ android:hint="last Name"
android:inputType="textPersonName"
- android:hint="Last Name"
app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.525"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/addFirstName_et" />
-
-
+ android:textColor="?attr/editTextColor"
+ android:background="?attr/editTextBackground"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceMediumInverse"
+ app:layout_constraintTop_toBottomOf="@+id/addLastName_et" />
-
+ app:layout_constraintHorizontal_bias="0.525"
+ app:layout_constraintStart_toStartOf="parent" />
-
+ app:layout_constraintTop_toBottomOf="@+id/addBirthday_et"
+
+ tools:ignore="MissingConstraints">
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_pendulum_settings.xml b/app/src/main/res/layout/fragment_pendulum_settings.xml
new file mode 100644
index 0000000..bb0c742
--- /dev/null
+++ b/app/src/main/res/layout/fragment_pendulum_settings.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_start_pendulum.xml b/app/src/main/res/layout/fragment_start_pendulum.xml
index 2d350bc..0e2b25c 100644
--- a/app/src/main/res/layout/fragment_start_pendulum.xml
+++ b/app/src/main/res/layout/fragment_start_pendulum.xml
@@ -46,4 +46,28 @@
app:layout_constraintTop_toBottomOf="@+id/targetVelocity_et"
app:layout_constraintVertical_bias="0.079" />
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_update.xml b/app/src/main/res/layout/fragment_update.xml
index 11f7f7a..2f78d61 100644
--- a/app/src/main/res/layout/fragment_update.xml
+++ b/app/src/main/res/layout/fragment_update.xml
@@ -8,6 +8,29 @@
tools:context=".fragments.update.UpdateFragment"
android:padding="24dp">
+
+
+
+
+
+
+
-
-
-
+ android:textColor="?attr/editTextColor"
+ android:background="?attr/editTextBackground"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceMediumInverse"
+ app:layout_constraintTop_toBottomOf="@+id/updateLastName_et" />
-
+ app:layout_constraintTop_toBottomOf="@+id/updateBirthday_et"
+ tools:ignore="MissingConstraints">
-
+
+
+
+ app:layout_constraintTop_toBottomOf="@+id/update_btn"
+ app:layout_constraintVertical_bias="1.0" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/navigation/my_nav.xml b/app/src/main/res/navigation/my_nav.xml
index 660c6c4..eff76ee 100644
--- a/app/src/main/res/navigation/my_nav.xml
+++ b/app/src/main/res/navigation/my_nav.xml
@@ -55,6 +55,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1838711..8079eeb 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -3,4 +3,16 @@
Hello blank fragment
TextView
+
+
+ - male
+ - female
+ - diverse
+
+
+
+ - right
+ - left
+
+
\ No newline at end of file