From eb00da0a8ef8be30e882b390ecd74fa1cf12eddd Mon Sep 17 00:00:00 2001 From: Feyzu Date: Fri, 8 Jul 2022 19:51:40 +0200 Subject: [PATCH] Pendel Logic READY Pendelsession information save in profile in progress new fragment "fragment_start_pendulum" --- .idea/deploymentTargetDropDown.xml | 17 +++ .idea/misc.xml | 4 +- app/build.gradle | 12 +- .../example/acapendulum20/StartPendulum.kt | 59 ++++++++ .../acapendulum20/canvas/CanvasPendulum.kt | 128 +++++++++++------- .../acapendulum20/data/MeasurementDao.kt | 4 + .../acapendulum20/data/MeasurementDatabase.kt | 4 + .../example/acapendulum20/data/SessionDao.kt | 4 + .../acapendulum20/data/SessionDatabase.kt | 4 + .../com/example/acapendulum20/data/UserDao.kt | 10 +- .../fragments/add/AddFragment.kt | 3 +- .../fragments/list/ListAdapter.kt | 2 +- .../fragments/list/ListFragment.kt | 2 +- .../fragments/pendulum/PendulumFragment.kt | 20 +-- .../fragments/update/UpdateFragment.kt | 6 +- .../acapendulum20/model/Measurement.kt | 27 ++++ .../example/acapendulum20/model/Session.kt | 21 +++ .../com/example/acapendulum20/model/User.kt | 4 +- .../repository/MeasurementRepository.kt | 4 + .../repository/SessionRepository.kt | 4 + .../viewmodel/MeasurementViewmodel.kt | 4 + .../viewmodel/SessionViewmodel.kt | 4 + app/src/main/res/layout/fragment_pendulum.xml | 114 ++++++---------- .../res/layout/fragment_start_pendulum.xml | 46 +++++++ app/src/main/res/layout/fragment_update.xml | 17 ++- app/src/main/res/navigation/my_nav.xml | 18 ++- build.gradle | 4 +- 27 files changed, 383 insertions(+), 163 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 app/src/main/java/com/example/acapendulum20/StartPendulum.kt create mode 100644 app/src/main/java/com/example/acapendulum20/data/MeasurementDao.kt create mode 100644 app/src/main/java/com/example/acapendulum20/data/MeasurementDatabase.kt create mode 100644 app/src/main/java/com/example/acapendulum20/data/SessionDao.kt create mode 100644 app/src/main/java/com/example/acapendulum20/data/SessionDatabase.kt create mode 100644 app/src/main/java/com/example/acapendulum20/model/Measurement.kt create mode 100644 app/src/main/java/com/example/acapendulum20/model/Session.kt create mode 100644 app/src/main/java/com/example/acapendulum20/repository/MeasurementRepository.kt create mode 100644 app/src/main/java/com/example/acapendulum20/repository/SessionRepository.kt create mode 100644 app/src/main/java/com/example/acapendulum20/viewmodel/MeasurementViewmodel.kt create mode 100644 app/src/main/java/com/example/acapendulum20/viewmodel/SessionViewmodel.kt create mode 100644 app/src/main/res/layout/fragment_start_pendulum.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..df0740d --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index e7f70de..726c172 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -13,9 +13,11 @@ - + + + diff --git a/app/build.gradle b/app/build.gradle index 225cc27..cf3489c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -59,8 +59,8 @@ dependencies { // Navigation Component - implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2' - implementation 'androidx.navigation:navigation-ui-ktx:2.4.2' + implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0' + implementation 'androidx.navigation:navigation-ui-ktx:2.5.0' // Room components implementation "androidx.room:room-runtime:2.4.2" @@ -70,13 +70,13 @@ dependencies { // Lifecycle components implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" - implementation "androidx.lifecycle:lifecycle-common-java8:2.4.1" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1" + implementation "androidx.lifecycle:lifecycle-common-java8:2.5.0" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" // Kotlin components implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.20" - api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1" - api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2" + api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1" + api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1" } \ No newline at end of file diff --git a/app/src/main/java/com/example/acapendulum20/StartPendulum.kt b/app/src/main/java/com/example/acapendulum20/StartPendulum.kt new file mode 100644 index 0000000..3f376ad --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/StartPendulum.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 [StartPendulum.newInstance] factory method to + * create an instance of this fragment. + */ +class StartPendulum : 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_start_pendulum, 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 StartPendulum. + */ + // TODO: Rename and change types and number of parameters + @JvmStatic + fun newInstance(param1: String, param2: String) = + StartPendulum().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 06781e8..a4fcae1 100644 --- a/app/src/main/java/com/example/acapendulum20/canvas/CanvasPendulum.kt +++ b/app/src/main/java/com/example/acapendulum20/canvas/CanvasPendulum.kt @@ -1,17 +1,11 @@ package com.example.acapendulum20.canvas -import android.R import android.content.Context -import android.content.res.Resources -import android.graphics.BitmapFactory import android.graphics.Canvas import android.graphics.Color import android.graphics.Paint import android.util.AttributeSet import android.view.View -import android.widget.ImageView -import android.widget.LinearLayout -import kotlin.math.PI import kotlin.math.cos import kotlin.math.sin @@ -34,97 +28,139 @@ class CanvasPendulum @JvmOverloads constructor( //println("ONDRAW") //draw line - mPendulum.startPosition.x = (width/2).toFloat() + mPendulum.startPosition.x = (width / 2).toFloat() paint.isAntiAlias = true paint.style = Paint.Style.STROKE paint.color = Color.RED paint.strokeWidth = 10f - this.canvas.drawLine(mPendulum.startPosition.x, mPendulum.startPosition.y, mPendulum.stopPosition.x, mPendulum.stopPosition.y, paint) + this.canvas.drawLine( + mPendulum.startPosition.x, + mPendulum.startPosition.y, + mPendulum.stopPosition.x, + mPendulum.stopPosition.y, + paint + ) //draw circle paint.style = Paint.Style.FILL_AND_STROKE paint.strokeWidth = 1f paint.color = Color.GRAY - canvas?.drawCircle(mPendulum.stopPosition.x, mPendulum.stopPosition.y, mPendulum.ballr, paint) - - //draw magnet as black circle - paint.style = Paint.Style.FILL_AND_STROKE - paint.strokeWidth = 1f - paint.color = Color.DKGRAY - canvas?.drawCircle((width/2).toFloat(),1150f, 30f, paint) + canvas?.drawCircle( + mPendulum.stopPosition.x, + mPendulum.stopPosition.y, + mPendulum.ballr, + paint + ) //draw sensor left paint.style = Paint.Style.FILL_AND_STROKE paint.strokeWidth = 1f paint.color = Color.RED - if (mPendulum.angleVelocity > 0 ){ - if (mPendulum.stopPosition.x < (width/3) - 30f && mPendulum.stopPosition.x +30 > (width/3) - 30f - mPendulum.ballr){ + if (mPendulum.angleVelocity > 0) { + if (mPendulum.stopPosition.x < (width / 3) - 30f && mPendulum.stopPosition.x + 30 > (width / 3) - 30f - mPendulum.ballr) { paint.style = Paint.Style.FILL_AND_STROKE paint.strokeWidth = 10f paint.color = Color.GREEN } } - canvas?.drawCircle((width/3).toFloat(),910f, 30f, paint) + canvas?.drawCircle((width / 3).toFloat(), 910f, 30f, paint) //draw sensor right paint.style = Paint.Style.FILL_AND_STROKE - paint.strokeWidth = 10f + paint.strokeWidth = 1f paint.color = Color.RED - if (mPendulum.angleVelocity < 0 ){ - if (mPendulum.stopPosition.x > (width/1.5) - 30f && mPendulum.stopPosition.x +30 < (width/1.5) + 30f + mPendulum.ballr){ + if (mPendulum.angleVelocity < 0) { + if (mPendulum.stopPosition.x > (width / 1.5) - 30f && mPendulum.stopPosition.x + 30 < (width / 1.5) + 30f + mPendulum.ballr) { paint.style = Paint.Style.FILL_AND_STROKE paint.strokeWidth = 10f paint.color = Color.GREEN } } - canvas?.drawCircle((width/1.5).toFloat(),910f, 30f, paint) + canvas?.drawCircle((width / 1.5).toFloat(), 910f, 30f, paint) startPendulum() invalidate() } fun startPendulum() { - val gravity = 0.981f - val damping = 0.996f - - mPendulum.angleAcceleration = ((-1 * gravity / mPendulum.r) * (mPendulum.angle)).toFloat() - mPendulum.angleVelocity += mPendulum.angleAcceleration - mPendulum.angleVelocity *= damping - mPendulum.angle += mPendulum.angleVelocity - //Polar to cartesian conversion - mPendulum.stopPosition.x = mPendulum.r * (sin(mPendulum.angle)).toFloat() - mPendulum.stopPosition.y = mPendulum.r * (cos(mPendulum.angle)).toFloat() - //Origin transition - mPendulum.stopPosition.x += mPendulum.startPosition.x - } + if (mPendulum.magneticField) { + + var gravity = 0.981f + var damping = 0.996f + + if (mPendulum.stopPosition.x > canvas.width / 4.toFloat() && mPendulum.stopPosition.x <= canvas.width * 0.75.toFloat()) { + gravity = 1.981f + + if (mPendulum.stopPosition.x > canvas.width / 3.toFloat() && mPendulum.stopPosition.x <= canvas.width / 1.5.toFloat()) { + gravity = 2.981f - fun startMagnet(){ - //if Circle = sensor -> circle/angleVelocity ++ - if (mPendulum.stopPosition.x == canvas.width/2f) { - mPendulum.angleVelocity = 0f + if (mPendulum.stopPosition.x >= canvas.width / 2.toFloat() - 3 && mPendulum.stopPosition.x <= canvas.width / 2.toFloat() + 3) { + damping = 0.3f + } + } + } + + mPendulum.angleAcceleration = + ((-1 * gravity / mPendulum.r) * (mPendulum.angle)).toFloat() + mPendulum.angleVelocity += mPendulum.angleAcceleration + mPendulum.angleVelocity *= damping + mPendulum.angle += mPendulum.angleVelocity + //Polar to cartesian conversion + mPendulum.stopPosition.x = mPendulum.r * (sin(mPendulum.angle)).toFloat() + mPendulum.stopPosition.y = mPendulum.r * (cos(mPendulum.angle)).toFloat() + //Origin transition + mPendulum.stopPosition.x += mPendulum.startPosition.x + } + + if (!mPendulum.magneticField) { + val gravity = 0.981f + val damping = 0.996f + + mPendulum.angleAcceleration = + ((-1 * gravity / mPendulum.r) * (mPendulum.angle)).toFloat() + mPendulum.angleVelocity += mPendulum.angleAcceleration + mPendulum.angleVelocity *= damping + mPendulum.angle += mPendulum.angleVelocity + //Polar to cartesian conversion + mPendulum.stopPosition.x = mPendulum.r * (sin(mPendulum.angle)).toFloat() + mPendulum.stopPosition.y = mPendulum.r * (cos(mPendulum.angle)).toFloat() + //Origin transition + mPendulum.stopPosition.x += mPendulum.startPosition.x } + } - fun stopMagnet(){ + fun startMagnet(magnet: Boolean) { + println("startMagnet") + println(magnet) + mPendulum.magneticField = magnet + } + fun stopMagnet(magnet: Boolean) { + println("stopMagnet") + println(magnet) + mPendulum.magneticField = magnet } } -class Position(var x: Float, var y: Float){ +class Position(var x: Float, var y: Float) { } class Pendulum { var startPosition: Position = Position(0f, 0f) - var stopPosition: Position = Position(0f,0f) + var stopPosition: Position = Position(0f, 0f) var r = 800f + //PI/6 Max ausschwingen - var angle : Double = Math.PI/6 - var angleVelocity : Float = 0.0f // - var angleAcceleration : Float = 0.0f // - var ballr : Float = 70.0f // + var angle: Double = Math.PI / 12 + var angleVelocity: Float = 0.0f // + var angleAcceleration: Float = 0.0f // + var ballr: Float = 70.0f // + + 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 new file mode 100644 index 0000000..75b3b54 --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/data/MeasurementDao.kt @@ -0,0 +1,4 @@ +package com.example.acapendulum20.data + +class MeasurementDao { +} \ No newline at end of file diff --git a/app/src/main/java/com/example/acapendulum20/data/MeasurementDatabase.kt b/app/src/main/java/com/example/acapendulum20/data/MeasurementDatabase.kt new file mode 100644 index 0000000..61bb5d7 --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/data/MeasurementDatabase.kt @@ -0,0 +1,4 @@ +package com.example.acapendulum20.data + +class MeasurementDatabase { +} \ No newline at end of file diff --git a/app/src/main/java/com/example/acapendulum20/data/SessionDao.kt b/app/src/main/java/com/example/acapendulum20/data/SessionDao.kt new file mode 100644 index 0000000..4f36b1c --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/data/SessionDao.kt @@ -0,0 +1,4 @@ +package com.example.acapendulum20.data + +class SessionDao { +} \ No newline at end of file diff --git a/app/src/main/java/com/example/acapendulum20/data/SessionDatabase.kt b/app/src/main/java/com/example/acapendulum20/data/SessionDatabase.kt new file mode 100644 index 0000000..60099bd --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/data/SessionDatabase.kt @@ -0,0 +1,4 @@ +package com.example.acapendulum20.data + +class SessionDatabase { +} \ No newline at end of file diff --git a/app/src/main/java/com/example/acapendulum20/data/UserDao.kt b/app/src/main/java/com/example/acapendulum20/data/UserDao.kt index 76ae01f..3f73304 100644 --- a/app/src/main/java/com/example/acapendulum20/data/UserDao.kt +++ b/app/src/main/java/com/example/acapendulum20/data/UserDao.kt @@ -8,18 +8,18 @@ import com.example.acapendulum20.model.User interface UserDao { @Insert(onConflict = OnConflictStrategy.IGNORE ) - suspend fun addUser(user: User) + fun addUser(user: User) @Update - suspend fun updateUser(user: User) + fun updateUser(user: User) @Delete - suspend fun deleteUser(user: User) + fun deleteUser(user: User) @Query("DELETE FROM user_table") - suspend fun deleteAllUsers() + fun deleteAllUsers() - @Query("SELECT * FROM user_table ORDER BY id ASC") + @Query("SELECT * FROM user_table ORDER BY lastName ASC") 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 e09187b..769cd97 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 @@ -15,6 +15,7 @@ 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 java.util.* class AddFragment : Fragment() { @@ -45,7 +46,7 @@ class AddFragment : Fragment() { if(inputCheck(firstName, lastName, sex, handiness, age)){ //Create User Objeect - val user = User(0, firstName, lastName,Integer.parseInt(age.toString()), sex, handiness) + val user = User(UUID.randomUUID().toString(), firstName, lastName,Integer.parseInt(age.toString()), 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 4d6d5f4..9f772c6 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 @@ -27,7 +27,7 @@ class ListAdapter: RecyclerView.Adapter() { override fun onBindViewHolder(holder: MyViewHolder, position: Int) { val currentItem = userList[position] - holder.itemView.id_txt.text = currentItem.id.toString() + 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() diff --git a/app/src/main/java/com/example/acapendulum20/fragments/list/ListFragment.kt b/app/src/main/java/com/example/acapendulum20/fragments/list/ListFragment.kt index 842b09e..737fdbf 100644 --- a/app/src/main/java/com/example/acapendulum20/fragments/list/ListFragment.kt +++ b/app/src/main/java/com/example/acapendulum20/fragments/list/ListFragment.kt @@ -65,7 +65,7 @@ class ListFragment : Fragment() { mUserViewModel.deleteAllUsers() Toast.makeText( requireContext(), - "Succesfully removed everything!", + "Successfully removed everything!", Toast.LENGTH_SHORT ).show() } 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 54bbb75..f75d0fb 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 @@ -2,16 +2,15 @@ package com.example.acapendulum20.fragments.pendulum import android.annotation.SuppressLint import android.os.Bundle -import android.os.SystemClock import android.view.LayoutInflater import android.view.MotionEvent import android.view.View +import android.view.View.OnTouchListener import android.view.ViewGroup import android.widget.Button import androidx.fragment.app.Fragment import com.example.acapendulum20.R import com.example.acapendulum20.canvas.CanvasPendulum -import java.util.* class PendulumFragment : Fragment() { @@ -35,29 +34,20 @@ class PendulumFragment : Fragment() { button.setOnTouchListener(object : View.OnTouchListener{ - var pushed = false override fun onTouch(v: View?, event: MotionEvent?): Boolean { - var steps: Int - var startTime: Long if (event?.action == MotionEvent.ACTION_DOWN){ - startTime = SystemClock.elapsedRealtime() - pushed = true - do { - mCanvasPendulum.startMagnet() - steps =- 1 - }while (pushed) + println("button action DOWN") + mCanvasPendulum.startMagnet(true) } if (event?.action == MotionEvent.ACTION_UP){ - pushed = false - mCanvasPendulum.stopMagnet() - println("button action up") + println("button action UP") + mCanvasPendulum.stopMagnet(false) } return true } }) - //System.currentTimeMillis() //System.nanoTime() 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 9045556..afc0241 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 @@ -29,7 +29,7 @@ class UpdateFragment : Fragment() { // Inflate the layout for this fragment val view = inflater.inflate(R.layout.fragment_update, container, false) - mUserViewModel = ViewModelProvider(this).get(UserViewmodel::class.java) + mUserViewModel = ViewModelProvider(this)[UserViewmodel::class.java] view.updateFirstName_et.setText(args.currentUser.firstName) view.updateLastName_et.setText(args.currentUser.lastName) @@ -37,9 +37,9 @@ class UpdateFragment : Fragment() { view.updateSex_et.setText(args.currentUser.sex) view.updateHandiness_et.setText(args.currentUser.handiness) - //navigate to fragment_pendulum + //navigate to fragment_start_pendulum view.startTest_btn.setOnClickListener{ - findNavController().navigate(R.id.action_updateFragment_to_pendulumFragment) + findNavController().navigate(R.id.action_updateFragment_to_startPendulum) } //navigate to fragment_update diff --git a/app/src/main/java/com/example/acapendulum20/model/Measurement.kt b/app/src/main/java/com/example/acapendulum20/model/Measurement.kt new file mode 100644 index 0000000..3779b30 --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/model/Measurement.kt @@ -0,0 +1,27 @@ +package com.example.acapendulum20.model + +import android.os.Parcelable +import androidx.room.Entity +import androidx.room.PrimaryKey +import androidx.room.ForeignKey +import com.example.acapendulum20.data.UserDao +import com.example.acapendulum20.data.UserDao_Impl +import kotlinx.android.parcel.Parcelize + +@Parcelize +@Entity(tableName = "measurement_table", foreignKeys = [ForeignKey(entity = Session::class, + parentColumns = arrayOf("id"), + childColumns = arrayOf("sessionRef"), + onDelete = ForeignKey.CASCADE)] +) +data class Measurement ( + @PrimaryKey + val id: String, + val testNr: Int, + val targetVelocity: Int, + val maxAttemptTime: Int, + val attemptTime: Int, + val sessionRef: String, + + ): Parcelable + diff --git a/app/src/main/java/com/example/acapendulum20/model/Session.kt b/app/src/main/java/com/example/acapendulum20/model/Session.kt new file mode 100644 index 0000000..6fe8337 --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/model/Session.kt @@ -0,0 +1,21 @@ +package com.example.acapendulum20.model + +import android.os.Parcelable +import androidx.room.Entity +import androidx.room.ForeignKey +import androidx.room.PrimaryKey +import kotlinx.android.parcel.Parcelize + +@Parcelize +@Entity(tableName = "session_table", foreignKeys = [ForeignKey(entity = User::class, + parentColumns = arrayOf("id"), + childColumns = arrayOf("userRef"), + onDelete = ForeignKey.CASCADE)]) +data class Session ( + @PrimaryKey + val id: String, + val sessionStart: Long, + val sessionEnd: Long, + val userRef: String, + + ): Parcelable \ No newline at end of file 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 b9eda8d..9f681a0 100644 --- a/app/src/main/java/com/example/acapendulum20/model/User.kt +++ b/app/src/main/java/com/example/acapendulum20/model/User.kt @@ -8,8 +8,8 @@ import kotlinx.android.parcel.Parcelize @Parcelize @Entity(tableName = "user_table") data class User ( - @PrimaryKey(autoGenerate = true) - val id: Int, + @PrimaryKey + val id: String, val firstName: String, val lastName: String, val age: Int, diff --git a/app/src/main/java/com/example/acapendulum20/repository/MeasurementRepository.kt b/app/src/main/java/com/example/acapendulum20/repository/MeasurementRepository.kt new file mode 100644 index 0000000..06e79c0 --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/repository/MeasurementRepository.kt @@ -0,0 +1,4 @@ +package com.example.acapendulum20.repository + +class MeasurementRepository { +} \ No newline at end of file diff --git a/app/src/main/java/com/example/acapendulum20/repository/SessionRepository.kt b/app/src/main/java/com/example/acapendulum20/repository/SessionRepository.kt new file mode 100644 index 0000000..2e07b70 --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/repository/SessionRepository.kt @@ -0,0 +1,4 @@ +package com.example.acapendulum20.repository + +class SessionRepository { +} \ 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 new file mode 100644 index 0000000..3ac17ba --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/viewmodel/MeasurementViewmodel.kt @@ -0,0 +1,4 @@ +package com.example.acapendulum20.viewmodel + +class MeasurementViewmodel { +} \ No newline at end of file diff --git a/app/src/main/java/com/example/acapendulum20/viewmodel/SessionViewmodel.kt b/app/src/main/java/com/example/acapendulum20/viewmodel/SessionViewmodel.kt new file mode 100644 index 0000000..6628171 --- /dev/null +++ b/app/src/main/java/com/example/acapendulum20/viewmodel/SessionViewmodel.kt @@ -0,0 +1,4 @@ +package com.example.acapendulum20.viewmodel + +class SessionViewmodel { +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_pendulum.xml b/app/src/main/res/layout/fragment_pendulum.xml index 9a93195..cde467e 100644 --- a/app/src/main/res/layout/fragment_pendulum.xml +++ b/app/src/main/res/layout/fragment_pendulum.xml @@ -10,95 +10,67 @@ - - + app:layout_constraintEnd_toStartOf="@+id/activate_btn" + app:layout_constraintHorizontal_bias="0.548" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.791" /> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="1.0" + app:layout_constraintStart_toEndOf="@+id/speichern_btn" + app:layout_constraintTop_toBottomOf="@+id/timer_view" + app:layout_constraintVertical_bias="0.933" /> + app:layout_constraintEnd_toStartOf="@+id/speichern_btn" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/actV_view" + app:layout_constraintVertical_bias="0.965" /> - - - - - - + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.483" + app:layout_constraintStart_toEndOf="@+id/activate_btn" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.789" />