mirror of
https://github.com/a-mayb3/KanbanCloneAndroid.git
synced 2026-03-21 10:05:39 +01:00
Compare commits
2 commits
110f356d78
...
31a1d96236
| Author | SHA1 | Date | |
|---|---|---|---|
| 31a1d96236 | |||
| d1c02510d1 |
5 changed files with 276 additions and 12 deletions
|
|
@ -1,13 +1,34 @@
|
||||||
package com.campusaula.edbole.kanban_clone_android.ui
|
package com.campusaula.edbole.kanban_clone_android.ui
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.AutoCompleteTextView
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.MultiAutoCompleteTextView
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.campusaula.edbole.kanban_clone_android.R
|
import com.campusaula.edbole.kanban_clone_android.R
|
||||||
|
import com.campusaula.edbole.kanban_clone_android.kanban.ProjectCreate
|
||||||
|
import com.campusaula.edbole.kanban_clone_android.network.ApiService
|
||||||
|
import com.campusaula.edbole.kanban_clone_android.network.RetrofitInstance
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
|
||||||
class CreateProjectActivity : AppCompatActivity() {
|
class CreateProjectActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private lateinit var api: ApiService
|
||||||
|
|
||||||
|
private lateinit var returnActionButton : FloatingActionButton
|
||||||
|
private lateinit var newProjectName : AutoCompleteTextView
|
||||||
|
private lateinit var newProjectDescription : AutoCompleteTextView
|
||||||
|
private lateinit var newProjectCreateButton : Button
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
@ -17,5 +38,51 @@ class CreateProjectActivity : AppCompatActivity() {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api = RetrofitInstance.getRetrofit(applicationContext).create(ApiService::class.java)
|
||||||
|
|
||||||
|
returnActionButton = findViewById(R.id.returnActionButton)
|
||||||
|
returnActionButton.setOnClickListener { finish() }
|
||||||
|
|
||||||
|
newProjectName = findViewById(R.id.newProjectName)
|
||||||
|
newProjectDescription = findViewById(R.id.newProjectDescription)
|
||||||
|
|
||||||
|
newProjectCreateButton = findViewById(R.id.newProjectCreateButton)
|
||||||
|
newProjectCreateButton.setOnClickListener {
|
||||||
|
val projectName = newProjectName.text.toString()
|
||||||
|
val projectDescription = newProjectDescription.text.toString()
|
||||||
|
|
||||||
|
if (projectName.isEmpty() || projectDescription.isEmpty()) {
|
||||||
|
Toast
|
||||||
|
.makeText(this, "Please fill in all fields", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
|
||||||
|
val projectCreate : ProjectCreate = ProjectCreate(projectName, projectDescription)
|
||||||
|
val response = api.createProject(projectCreate)
|
||||||
|
|
||||||
|
if (response.isSuccessful){
|
||||||
|
Toast
|
||||||
|
.makeText(this@CreateProjectActivity, "Project created successfully", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
Log.d("CreateProjectActivity", "Created project: ${response.body()}")
|
||||||
|
startActivity(Intent(this@CreateProjectActivity, MainActivity::class.java))
|
||||||
|
} else {
|
||||||
|
Log.e("CreateProjectActivity", "Error creating project: ${response.code()} - ${response.message()}")
|
||||||
|
Toast
|
||||||
|
.makeText(this@CreateProjectActivity, "Error creating project", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
package com.campusaula.edbole.kanban_clone_android.ui
|
package com.campusaula.edbole.kanban_clone_android.ui
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.health.connect.datatypes.units.Percentage
|
import android.health.connect.datatypes.units.Percentage
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.widget.Button
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.campusaula.edbole.kanban_clone_android.R
|
import com.campusaula.edbole.kanban_clone_android.R
|
||||||
import com.campusaula.edbole.kanban_clone_android.kanban.Project
|
import com.campusaula.edbole.kanban_clone_android.kanban.Project
|
||||||
import com.campusaula.edbole.kanban_clone_android.kanban.Task
|
import com.campusaula.edbole.kanban_clone_android.kanban.Task
|
||||||
|
|
@ -22,10 +25,17 @@ class ProjectDetailActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var api: ApiService
|
private lateinit var api: ApiService
|
||||||
|
|
||||||
|
private lateinit var returnActionButton: FloatingActionButton
|
||||||
|
private lateinit var addTaskButton: Button
|
||||||
|
private lateinit var addCollaboratorButton: Button
|
||||||
|
|
||||||
|
private lateinit var collaboratorListRecycler: RecyclerView
|
||||||
|
// private lateinit var collaboratorListAdapter: CollaboratorListAdapter
|
||||||
|
|
||||||
private lateinit var projectTitleText : TextView
|
private lateinit var projectTitleText : TextView
|
||||||
private lateinit var projectDescriptionText : TextView
|
private lateinit var projectDescriptionText : TextView
|
||||||
private lateinit var completedPercentageText: TextView
|
private lateinit var completedPercentageText: TextView
|
||||||
private lateinit var returnActionButton: FloatingActionButton
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
@ -36,14 +46,36 @@ class ProjectDetailActivity : AppCompatActivity() {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
api = RetrofitInstance.getRetrofit(applicationContext).create(ApiService::class.java)
|
api = RetrofitInstance.getRetrofit(applicationContext).create(ApiService::class.java)
|
||||||
|
val projectId = intent.getIntExtra("project_id", -1)
|
||||||
|
|
||||||
projectTitleText = findViewById(R.id.projectTitleText)
|
projectTitleText = findViewById(R.id.projectTitleText)
|
||||||
projectDescriptionText = findViewById(R.id.projectDescriptionText)
|
projectDescriptionText = findViewById(R.id.projectDescriptionText)
|
||||||
completedPercentageText = findViewById(R.id.completedPercentageText)
|
completedPercentageText = findViewById(R.id.completedPercentageText)
|
||||||
|
|
||||||
returnActionButton = findViewById(R.id.returnActionButton)
|
returnActionButton = findViewById(R.id.returnActionButton)
|
||||||
returnActionButton.setOnClickListener { finish() }
|
returnActionButton.setOnClickListener { finish() }
|
||||||
|
|
||||||
val projectId : Int = intent.getIntExtra("project_id", -1)
|
addTaskButton = findViewById(R.id.addTaskButton)
|
||||||
|
// addTaskButton.setOnClickListener {
|
||||||
|
// val intent: Intent = Intent(this, CreateTaskActivity::class.java)
|
||||||
|
// intent.putExtra("project_id", projectId)
|
||||||
|
// startActivity(intent)
|
||||||
|
// }
|
||||||
|
|
||||||
|
addCollaboratorButton = findViewById(R.id.addCollaboratorButton)
|
||||||
|
// addCollaboratorButton.setOnClickListener {
|
||||||
|
// val intent: Intent = Intent(this, AddCollaboratorActivity::class.java)
|
||||||
|
// intent.putExtra("project_id", projectId)
|
||||||
|
// startActivity(intent)
|
||||||
|
// }
|
||||||
|
|
||||||
|
collaboratorListRecycler = findViewById(R.id.collaboratorListRecycler)
|
||||||
|
// collaboratorListAdapter =
|
||||||
|
collaboratorListRecycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this)
|
||||||
|
|
||||||
|
|
||||||
if (projectId > 0) {
|
if (projectId > 0) {
|
||||||
Log.d("ProjectDetailActivity", "Received project ID: $projectId")
|
Log.d("ProjectDetailActivity", "Received project ID: $projectId")
|
||||||
|
|
@ -83,10 +115,13 @@ class ProjectDetailActivity : AppCompatActivity() {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Log.e("ProjectDetailActivity", "No project ID found in intent")
|
Log.e("ProjectDetailActivity", "No project ID found in intent")
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -33,12 +33,12 @@ class ProjectItemAdapter(
|
||||||
override fun getItemCount(): Int = items.size
|
override fun getItemCount(): Int = items.size
|
||||||
|
|
||||||
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
private val nameTv: TextView = itemView.findViewById(R.id.projectName)
|
private val nameTextView: TextView = itemView.findViewById(R.id.projectName)
|
||||||
private val descTv: TextView = itemView.findViewById(R.id.projectDescription)
|
private val descriptionTextView: TextView = itemView.findViewById(R.id.projectDescription)
|
||||||
|
|
||||||
fun bind(project: Project) {
|
fun bind(project: Project) {
|
||||||
nameTv.text = project.id.toString() + " " + project.name
|
nameTextView.text = project.name
|
||||||
descTv.text = project.description
|
descriptionTextView.text = project.description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,89 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.CreateProjectActivity">
|
tools:context=".ui.CreateProjectActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:contentDescription="return back to home"
|
||||||
|
android:focusable="true"
|
||||||
|
app:srcCompat="@android:drawable/ic_menu_revert"
|
||||||
|
android:id="@+id/returnActionButton"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="Create a new project..."
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/activityTitle"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:textSize="24dp"
|
||||||
|
android:layout_marginTop="4dp" />
|
||||||
|
|
||||||
|
<MultiAutoCompleteTextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="500dp"
|
||||||
|
android:id="@+id/newProjectDescription"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/newProjectDescriptionLabel"
|
||||||
|
android:hint="This is my new super-special project that will change the world!!!"
|
||||||
|
android:textAlignment="textStart"
|
||||||
|
android:gravity="start|top"
|
||||||
|
android:padding="12dp" />
|
||||||
|
|
||||||
|
<AutoCompleteTextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/newProjectName"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/newProjectNameLabel"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:hint="My new project!"
|
||||||
|
android:padding="12dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="Project name:"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/newProjectNameLabel"
|
||||||
|
tools:layout_editor_absoluteX="0dp"
|
||||||
|
android:labelFor="@id/activityTitle"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/activityTitle"
|
||||||
|
android:layout_marginTop="16dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="Project description:"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/newProjectDescriptionLabel"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/newProjectName"
|
||||||
|
android:layout_marginTop="20dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:text="Create new project"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/newProjectCreateButton"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/newProjectDescription"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:layout_margin="12dp" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
@ -38,19 +38,96 @@
|
||||||
android:id="@+id/completedPercentageText"
|
android:id="@+id/completedPercentageText"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/projectTitleText"
|
app:layout_constraintTop_toBottomOf="@+id/projectTitleText"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:paddingRight="12dp"
|
android:paddingRight="12dp"
|
||||||
android:paddingLeft="12dp" />
|
android:paddingLeft="12dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textSize="18dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/projectDescriptionText"
|
android:id="@+id/projectDescriptionText"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/completedPercentageText"
|
app:layout_constraintTop_toBottomOf="@+id/projectDescriptionLabel"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:text="Project description"
|
android:text="Project description"
|
||||||
android:padding="12dp" />
|
android:padding="12dp"
|
||||||
|
android:gravity="start|top" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="Project description:"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/projectDescriptionLabel"
|
||||||
|
tools:layout_editor_absoluteX="0dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/completedPercentageText"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingRight="12dp"
|
||||||
|
android:labelFor="@id/projectDescriptionText"
|
||||||
|
android:textSize="18dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/projectDescriptionText"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:id="@+id/taskLinearLayout">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="Tasks:"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/taskListTitle"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:textSize="18dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:text="Add a task..."
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/addTaskButton"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="12dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:layout_editor_absoluteX="0dp"
|
||||||
|
android:id="@+id/collaboratorsLinearLayout"
|
||||||
|
android:gravity="top|center_vertical"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/taskLinearLayout"
|
||||||
|
android:layout_marginTop="24dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="Collaborators:"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/collaboratorListTitle"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:textSize="18dp" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/collaboratorListRecycler" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:text="Add a new collaborator..."
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/addCollaboratorButton"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="12dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue