Skip to content
This repository was archived by the owner on Sep 22, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@
<activity android:name=".view.FallDetection.FallDetectionActivity" />
<activity android:name=".view.FallDetection.FallAlertActivity" />
<activity android:name="deakin.gopher.guardian.view.caretaker.notifications.confirmincident.CallAmbulanceActivity" />
<activity android:name=".view.general.DashboardActivity"/>
<activity android:name=".view.general.DoctorPortalActivity" />


<service
Expand All @@ -207,6 +209,9 @@
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />

<activity android:name=".view.general.DashboardActivity"/>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ sealed class RoleName(val name: String) : Serializable {
data object Nurse : RoleName(R.string.nurse_role_name.toString()) {
private fun readResolve(): Any = Nurse
}

data object Doctor : RoleName(R.string.doctor_role_name.toString()) {
private fun readResolve(): Any = Doctor
}





}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import deakin.gopher.guardian.view.general.Homepage4admin
import deakin.gopher.guardian.view.general.Homepage4caretaker
import deakin.gopher.guardian.view.general.Homepage4nurse
import deakin.gopher.guardian.view.general.LoginActivity
import deakin.gopher.guardian.view.general.PinCodeActivity
import deakin.gopher.guardian.view.general.RegisterActivity
import deakin.gopher.guardian.view.general.Setting
import deakin.gopher.guardian.view.general.TaskAddActivity
import deakin.gopher.guardian.view.general.TasksListActivity
import deakin.gopher.guardian.view.general.DashboardActivity
import deakin.gopher.guardian.view.general.DoctorPortalActivity


class NavigationService(val activity: Activity) {
fun toHomeScreenForRole(roleName: RoleName) {
Expand All @@ -33,6 +35,16 @@ class NavigationService(val activity: Activity) {
),
)
}
RoleName.Doctor -> {
activity.startActivity(
Intent(
activity.applicationContext,
DoctorPortalActivity::class.java,
),
)
}



RoleName.Admin -> {
activity.startActivity(
Expand Down Expand Up @@ -100,7 +112,8 @@ class NavigationService(val activity: Activity) {
}

fun toPinCodeActivity(roleName: RoleName) {
val intent = Intent(activity.applicationContext, PinCodeActivity::class.java)
val intent = Intent(activity.applicationContext, DashboardActivity::class.java)

intent.putExtra("role", roleName)
activity.startActivity(intent)
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/deakin/gopher/guardian/util/SecurityUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package deakin.gopher.guardian.utils

import java.security.MessageDigest

object SecurityUtils {
fun hashPassword(password: String): String {
val digest = MessageDigest.getInstance("SHA-256")
val bytes = digest.digest(password.toByteArray())
return bytes.joinToString("") { "%02x".format(it) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package deakin.gopher.guardian.view.general

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import deakin.gopher.guardian.R

// Define the data class for tasks
data class Task(val id: Int, val name: String, val status: String)

class DashboardActivity : AppCompatActivity() {

// Sample static tasks list
private val tasks = mutableListOf(
Task(1, "Check patient vitals", "Pending"),
Task(2, "Assist with mobility", "In Progress"),
Task(3, "Administer medication", "Completed")
)

// Declare views
private lateinit var taskSummary: TextView
private lateinit var viewTasksBtn: Button
private lateinit var sortSpinner: Spinner

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_dashboard)

// Initialize views
taskSummary = findViewById(R.id.taskSummary)
viewTasksBtn = findViewById(R.id.buttonViewTasks)
sortSpinner = findViewById(R.id.sortSpinner)

// Spinner setup
val sortOptions = arrayOf("None", "Status", "Task Name")
val spinnerAdapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, sortOptions)
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
sortSpinner.adapter = spinnerAdapter

// Spinner change listener
sortSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
val selected = sortOptions[position]
val sortedTasks = when (selected) {
"Status" -> tasks.sortedBy { it.status }
"Task Name" -> tasks.sortedBy { it.name }
else -> tasks
}

updateTaskSummary(sortedTasks)
}

override fun onNothingSelected(parent: AdapterView<*>) {}
}

// Show initial summary
updateTaskSummary(tasks)

// View all tasks button navigation
viewTasksBtn.setOnClickListener {
startActivity(Intent(this, TasksListActivity::class.java))
}
}

// Helper method to update summary
private fun updateTaskSummary(sortedTasks: List<Task>) {
val total = sortedTasks.size
val pending = sortedTasks.count { it.status == "Pending" }
val inProgress = sortedTasks.count { it.status == "In Progress" }
val completed = sortedTasks.count { it.status == "Completed" }

taskSummary.text = "Total Tasks: $total\nPending: $pending | In Progress: $inProgress | Completed: $completed"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package deakin.gopher.guardian.view.general

import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import deakin.gopher.guardian.R

class DoctorPortalActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_doctor_portal)

val welcomeTextView: TextView = findViewById(R.id.doctorWelcomeText)
welcomeTextView.text = "Welcome Doctor!"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import deakin.gopher.guardian.view.show
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import deakin.gopher.guardian.utils.SecurityUtils
import android.util.Log



class LoginActivity : BaseActivity() {
private var userRole: RoleName = RoleName.Caretaker
Expand All @@ -63,6 +67,7 @@ class LoginActivity : BaseActivity() {
R.id.admin_radioButton -> RoleName.Admin
R.id.caretaker_radioButton -> RoleName.Caretaker
R.id.nurse_radioButton -> RoleName.Nurse
R.id.doctor_radioButton -> RoleName.Doctor
else -> RoleName.Caretaker
}
}
Expand All @@ -77,6 +82,9 @@ class LoginActivity : BaseActivity() {
progressBar.show()
val emailInput = mEmail.text.toString().trim { it <= ' ' }
val passwordInput = mPassword.text.toString().trim { it <= ' ' }
val hashedPasswordInput = SecurityUtils.hashPassword(passwordInput)
Log.d("HashedPassword", "Hashed value: $hashedPasswordInput")


val loginValidationError = validateInputs(emailInput)

Expand All @@ -90,7 +98,8 @@ class LoginActivity : BaseActivity() {
return@setOnClickListener
}

val call = ApiClient.apiService.login(emailInput, passwordInput)
val call = ApiClient.apiService.login(emailInput, hashedPasswordInput)


call.enqueue(
object : Callback<AuthResponse> {
Expand All @@ -104,7 +113,8 @@ class LoginActivity : BaseActivity() {
val user = response.body()!!.user
val token = response.body()!!.token
SessionManager.createLoginSession(user, token)
NavigationService(this@LoginActivity).toPinCodeActivity(userRole)
NavigationService(this@LoginActivity).toHomeScreenForRole(userRole)

} else {
// Handle error
val errorResponse =
Expand Down
Loading