diff --git a/app/build.gradle b/app/build.gradle
index 18f94621..27057384 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -202,6 +202,15 @@ dependencies {
implementation "androidx.camera:camera-video:${camerax_version}"
implementation "androidx.camera:camera-view:${camerax_version}"
implementation "androidx.camera:camera-extensions:${camerax_version}"
+
+
+ implementation 'com.squareup.retrofit2:retrofit:2.9.0'
+ implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
+ implementation 'com.github.bumptech.glide:glide:4.16.0'
+
+
+
}
apply plugin: 'com.google.gms.google-services'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a013a4a0..00c30647 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -64,6 +64,9 @@
+
@@ -85,6 +88,11 @@
+
+
+
diff --git a/app/src/main/java/deakin/gopher/guardian/api/CaretakerApi.kt b/app/src/main/java/deakin/gopher/guardian/api/CaretakerApi.kt
new file mode 100644
index 00000000..db22dc36
--- /dev/null
+++ b/app/src/main/java/deakin/gopher/guardian/api/CaretakerApi.kt
@@ -0,0 +1,20 @@
+@file:Suppress("ktlint:standard:no-wildcard-imports")
+
+package deakin.gopher.guardian.network
+
+import deakin.gopher.guardian.model.login.Role.Caretaker
+import retrofit2.Response
+import retrofit2.http.*
+
+interface CaretakerApi {
+ @GET("caretaker/profile")
+ suspend fun getProfile(
+ @Query("caretakerId") caretakerId: String? = null,
+ @Query("email") email: String? = null,
+ ): Response
+
+ @PUT("caretaker/profile")
+ suspend fun updateProfile(
+ @Body caretaker: deakin.gopher.guardian.model.Caretaker,
+ ): Response
+}
diff --git a/app/src/main/java/deakin/gopher/guardian/model/Caretaker.kt b/app/src/main/java/deakin/gopher/guardian/model/Caretaker.kt
new file mode 100644
index 00000000..f65cafd7
--- /dev/null
+++ b/app/src/main/java/deakin/gopher/guardian/model/Caretaker.kt
@@ -0,0 +1,75 @@
+@file:Suppress("ktlint:standard:no-wildcard-imports")
+
+package deakin.gopher.guardian.model
+
+import com.google.gson.annotations.SerializedName
+import java.io.Serializable
+
+//
+// data class Caretaker(
+// @SerializedName("_id")
+// val id: String?,
+//
+// @SerializedName("fullname")
+// var fullName: String?,
+//
+// @SerializedName("email")
+// val email: String?,
+//
+// @SerializedName("assignedPatients")
+// val assignedPatients: List? = emptyList(),
+//
+// @SerializedName("failedLoginAttempts")
+// val failedLoginAttempts: Int? = 0,
+//
+// @SerializedName("lastPasswordChange")
+// val lastPasswordChange: String? = null,
+//
+// @SerializedName("created_at")
+// val createdAt: String? = null,
+//
+// @SerializedName("updated_at")
+// val updatedAt: String? = null,
+//
+// @SerializedName("role")
+// val role: Role? = null
+// ) : Serializable
+//
+// data class Role(
+// @SerializedName("_id")
+// val id: String?,
+//
+// @SerializedName("name")
+// val name: String?
+// ) : Serializable
+//
+data class Caretaker(
+ @SerializedName("_id")
+ val id: String?,
+ @SerializedName("fullname")
+ var fullName: String?,
+ @SerializedName("address")
+ var address: String? = null,
+ @SerializedName("dob")
+ var dob: String? = null,
+ @SerializedName("phone")
+ var phone: String? = null,
+ @SerializedName("ward")
+ var ward: String? = null,
+ @SerializedName("medicareNumber")
+ var medicareNumber: String? = null,
+ @SerializedName("emergencyContact")
+ var emergencyContact: String? = null,
+ @SerializedName("email")
+ var email: String?,
+ @SerializedName("assignedPatients")
+ val assignedPatients: List? = emptyList(),
+ @SerializedName("failedLoginAttempts")
+ val failedLoginAttempts: Int? = 0,
+ @SerializedName("lastPasswordChange")
+ val lastPasswordChange: String? = null,
+ @SerializedName("created_at")
+ val createdAt: String? = null,
+ @SerializedName("updated_at")
+ val updatedAt: String? = null,
+) : Serializable
diff --git a/app/src/main/java/deakin/gopher/guardian/model/Doctor.kt b/app/src/main/java/deakin/gopher/guardian/model/Doctor.kt
new file mode 100644
index 00000000..80304348
--- /dev/null
+++ b/app/src/main/java/deakin/gopher/guardian/model/Doctor.kt
@@ -0,0 +1,13 @@
+package deakin.gopher.guardian.model
+
+import java.io.Serializable
+
+data class Doctor(
+ var id: String? = null,
+ var fullName: String? = null,
+ var specialization: String? = null,
+ var phone: String? = null,
+ var email: String? = null,
+ var hospital: String? = null,
+ var assignedPatients: List? = null,
+) : Serializable
diff --git a/app/src/main/java/deakin/gopher/guardian/model/Prescription.kt b/app/src/main/java/deakin/gopher/guardian/model/Prescription.kt
new file mode 100644
index 00000000..ca91959a
--- /dev/null
+++ b/app/src/main/java/deakin/gopher/guardian/model/Prescription.kt
@@ -0,0 +1,17 @@
+package deakin.gopher.guardian.model
+
+import java.io.Serializable
+
+data class PrescriptionItem(
+ val name: String,
+ val dose: String,
+ val frequency: String,
+ val durationDays: Int,
+) : Serializable
+
+data class Prescription(
+ val id: String? = null,
+ val patientId: String,
+ val items: List,
+ val notes: String,
+) : Serializable
diff --git a/app/src/main/java/deakin/gopher/guardian/model/PrescriptionResponse.kt b/app/src/main/java/deakin/gopher/guardian/model/PrescriptionResponse.kt
new file mode 100644
index 00000000..b34710fa
--- /dev/null
+++ b/app/src/main/java/deakin/gopher/guardian/model/PrescriptionResponse.kt
@@ -0,0 +1,13 @@
+package deakin.gopher.guardian.model
+
+data class PrescriptionResponse(
+ val prescriptions: List,
+ val pagination: Pagination,
+)
+
+data class Pagination(
+ val total: Int,
+ val page: Int,
+ val pages: Int,
+ val limit: Int,
+)
diff --git a/app/src/main/java/deakin/gopher/guardian/model/login/Role.kt b/app/src/main/java/deakin/gopher/guardian/model/login/Role.kt
index b868e8fe..47885df7 100644
--- a/app/src/main/java/deakin/gopher/guardian/model/login/Role.kt
+++ b/app/src/main/java/deakin/gopher/guardian/model/login/Role.kt
@@ -1,31 +1,79 @@
+// package deakin.gopher.guardian.model.login
+//
+// import deakin.gopher.guardian.R
+// import java.io.Serializable
+//
+// sealed class Role(val name: String) : Serializable {
+// data object Caretaker : Role(R.string.caretaker_role_name.toString().lowercase()) {
+// private fun readResolve(): Any = Caretaker
+// }
+//
+// data object Admin : Role(R.string.company_admin_role_name.toString().lowercase()) {
+// private fun readResolve(): Any = Admin
+// }
+//
+// data object Nurse : Role(R.string.nurse_role_name.toString().lowercase()) {
+// private fun readResolve(): Any = Nurse
+// }
+// data object Doctor : Role("Doctor".toString().lowercase()) {
+// private fun readResolve(): Any = Doctor
+// }
+//
+//
+// companion object {
+// private const val CARETAKER_ROLE = "caretaker"
+// private const val ADMIN_ROLE = "admin"
+// private const val NURSE_ROLE = "nurse"
+// private const val DOCTOR_ROLE = "doctor"
+//
+// fun create(name: String): Role {
+// return when (name.lowercase()) {
+// CARETAKER_ROLE.lowercase() -> Caretaker
+// ADMIN_ROLE.lowercase() -> Admin
+// NURSE_ROLE.lowercase() -> Nurse
+// "doctor" -> Doctor
+// else -> throw IllegalArgumentException("Unknown role: $name")
+// }
+// }
+// }
+// }
+
package deakin.gopher.guardian.model.login
-import deakin.gopher.guardian.R
import java.io.Serializable
sealed class Role(val name: String) : Serializable {
- data object Caretaker : Role(R.string.caretaker_role_name.toString().lowercase()) {
+ data object Caretaker : Role("caretaker") {
private fun readResolve(): Any = Caretaker
}
- data object Admin : Role(R.string.company_admin_role_name.toString().lowercase()) {
+ data object Admin : Role("admin") {
private fun readResolve(): Any = Admin
}
- data object Nurse : Role(R.string.nurse_role_name.toString().lowercase()) {
+ data object Nurse : Role("nurse") {
private fun readResolve(): Any = Nurse
}
+ data object Doctor : Role("doctor") {
+ private fun readResolve(): Any = Doctor
+ }
+
companion object {
private const val CARETAKER_ROLE = "caretaker"
private const val ADMIN_ROLE = "admin"
private const val NURSE_ROLE = "nurse"
+ private const val DOCTOR_ROLE = "doctor"
fun create(name: String): Role {
- return when (name.lowercase()) {
- CARETAKER_ROLE.lowercase() -> Caretaker
- ADMIN_ROLE.lowercase() -> Admin
- NURSE_ROLE.lowercase() -> Nurse
+ val normalized = name.trim().lowercase()
+ android.util.Log.e("RoleDebug", "Received role: '$name' -> normalized: '$normalized'")
+
+ return when (normalized) {
+ CARETAKER_ROLE -> Caretaker
+ ADMIN_ROLE -> Admin
+ NURSE_ROLE -> Nurse
+ DOCTOR_ROLE -> Doctor
else -> throw IllegalArgumentException("Unknown role: $name")
}
}
diff --git a/app/src/main/java/deakin/gopher/guardian/model/login/SessionManager.kt b/app/src/main/java/deakin/gopher/guardian/model/login/SessionManager.kt
index 9f5f0b56..85c86925 100644
--- a/app/src/main/java/deakin/gopher/guardian/model/login/SessionManager.kt
+++ b/app/src/main/java/deakin/gopher/guardian/model/login/SessionManager.kt
@@ -1,3 +1,103 @@
+// package deakin.gopher.guardian.model.login
+//
+// import android.content.Context
+// import android.content.SharedPreferences
+// import android.security.keystore.UserNotAuthenticatedException
+// import com.google.gson.Gson
+// import deakin.gopher.guardian.model.register.User
+// import java.lang.reflect.Type
+//
+// object SessionManager {
+// private const val PREF_NAME = "LoginPref"
+// private const val IS_LOGIN = "IsLoggedIn"
+// private const val KEY_CURRENT_USER: String = "KEY_CURRENT_USER"
+// private const val KEY_TOKEN: String = "KEY_TOKEN"
+// private const val KEY_LAST_ACTIVE_TIME: String = "KEY_LAST_ACTIVE_TIME"
+// private const val KEY_PATIENT_ID = "key_patient_id"
+//
+// private lateinit var pref: SharedPreferences
+// private lateinit var editor: SharedPreferences.Editor
+//
+// // Initialize SharedPreferences
+//
+//
+// fun init(context: Context) {
+// pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
+// editor = pref.edit()
+// }
+//
+// fun createLoginSession(
+// user: User,
+// token: String,
+// ) {
+// setCurrentUser(user)
+// setObject(KEY_TOKEN, token)
+// editor.putBoolean(IS_LOGIN, true)
+// editor.commit()
+// }
+//
+// fun getToken(): String {
+// return getObject(KEY_TOKEN, String::class.java)
+// ?: throw UserNotAuthenticatedException("Token not found")
+// }
+//
+// fun getCurrentUser(): User {
+// return getObject(KEY_CURRENT_USER, User::class.java)
+// ?: throw UserNotAuthenticatedException("User not found")
+// }
+//
+// private fun setCurrentUser(user: User) {
+// setObject(KEY_CURRENT_USER, user)
+// }
+//
+// fun deleteCurrentUser() {
+// deleteObject(KEY_CURRENT_USER)
+// }
+//
+// val isLoggedIn: Boolean
+// get() = pref.getBoolean(IS_LOGIN, false)
+//
+// fun logoutUser() {
+// editor.clear()
+// editor.commit()
+// }
+//
+// fun updateLastActiveTime() {
+// editor.putLong(KEY_LAST_ACTIVE_TIME, System.currentTimeMillis())
+// editor.commit()
+// }
+//
+// fun getLastActiveTime(): Long {
+// return pref.getLong(KEY_LAST_ACTIVE_TIME, 0)
+// }
+// fun getPatientId(): String {
+// return pref.getString(KEY_PATIENT_ID, "") ?: ""
+// }
+//
+// private fun setObject(
+// key: String,
+// `object`: Any?,
+// ) {
+// val objectJson = if (`object` != null) Gson().toJson(`object`) else null
+// editor.putString(key, objectJson).apply()
+// }
+//
+// private fun getObject(
+// key: String,
+// objectType: Type,
+// ): T? {
+// val objectJson = pref.getString(key, null)
+// return if (objectJson != null) {
+// Gson().fromJson(objectJson, objectType)
+// } else {
+// null
+// }
+// }
+//
+// private fun deleteObject(key: String) {
+// editor.remove(key).apply()
+// }
+// }
package deakin.gopher.guardian.model.login
import android.content.Context
@@ -13,13 +113,17 @@ object SessionManager {
private const val KEY_CURRENT_USER: String = "KEY_CURRENT_USER"
private const val KEY_TOKEN: String = "KEY_TOKEN"
private const val KEY_LAST_ACTIVE_TIME: String = "KEY_LAST_ACTIVE_TIME"
+ private const val KEY_PATIENT_ID = "key_patient_id"
private lateinit var pref: SharedPreferences
private lateinit var editor: SharedPreferences.Editor
+ // Initialize SharedPreferences
fun init(context: Context) {
- pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
- editor = pref.edit()
+ if (!this::pref.isInitialized) {
+ pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
+ editor = pref.edit()
+ }
}
fun createLoginSession(
@@ -27,14 +131,14 @@ object SessionManager {
token: String,
) {
setCurrentUser(user)
- setObject(KEY_TOKEN, token)
+ editor.putString(KEY_TOKEN, token) // Store token as plain string
editor.putBoolean(IS_LOGIN, true)
- editor.commit()
+ editor.apply()
}
fun getToken(): String {
- return getObject(KEY_TOKEN, String::class.java)
- ?: throw UserNotAuthenticatedException("Token not found")
+ val token = pref.getString(KEY_TOKEN, null)
+ return token ?: throw UserNotAuthenticatedException("Token not found")
}
fun getCurrentUser(): User {
@@ -55,18 +159,22 @@ object SessionManager {
fun logoutUser() {
editor.clear()
- editor.commit()
+ editor.apply()
}
fun updateLastActiveTime() {
editor.putLong(KEY_LAST_ACTIVE_TIME, System.currentTimeMillis())
- editor.commit()
+ editor.apply()
}
fun getLastActiveTime(): Long {
return pref.getLong(KEY_LAST_ACTIVE_TIME, 0)
}
+ fun getPatientId(): String {
+ return pref.getString(KEY_PATIENT_ID, "") ?: ""
+ }
+
private fun setObject(
key: String,
`object`: Any?,
diff --git a/app/src/main/java/deakin/gopher/guardian/services/NavigationService.kt b/app/src/main/java/deakin/gopher/guardian/services/NavigationService.kt
index 255c2e34..96fa0d6d 100644
--- a/app/src/main/java/deakin/gopher/guardian/services/NavigationService.kt
+++ b/app/src/main/java/deakin/gopher/guardian/services/NavigationService.kt
@@ -5,6 +5,7 @@ import android.content.Intent
import deakin.gopher.guardian.model.login.Role
import deakin.gopher.guardian.view.general.Homepage4admin
import deakin.gopher.guardian.view.general.Homepage4caretaker
+import deakin.gopher.guardian.view.general.Homepage4doctor
import deakin.gopher.guardian.view.general.Homepage4nurse
import deakin.gopher.guardian.view.general.LoginActivity
import deakin.gopher.guardian.view.general.PatientListActivity
@@ -13,104 +14,158 @@ 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 kotlin.jvm.java
+
+// class NavigationService(val activity: Activity) {
+// fun toHomeScreenForRole(role: Role) {
+// when (role) {
+// Role.Caretaker -> {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// Homepage4caretaker::class.java,
+// ),
+// )
+// }
+//
+// Role.Nurse -> {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// Homepage4nurse::class.java,
+// ),
+// )
+// }
+//
+// Role.Admin -> {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// Homepage4admin::class.java,
+// ),
+// )
+// }
+// Role.Doctor -> {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// Homepage4doctor::class.java,
+// ),
+// )
+// }
+// }
+// }
+//
+// fun toRegistration() {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// RegisterActivity::class.java,
+// ),
+// )
+// }
+//
+// fun onSettings() {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// Setting::class.java,
+// ),
+// )
+// }
+//
+// fun onSignOut() {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// LoginActivity::class.java,
+// ),
+// )
+// }
+//
+// fun onLaunchPatientList() {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// PatientListActivity::class.java,
+// ),
+// )
+// }
+//
+// fun onLaunchTasks() {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// TasksListActivity::class.java,
+// ),
+// )
+// }
+//
+// fun onLaunchTaskCreator() {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// TaskAddActivity::class.java,
+// ),
+// )
+// }
+//
+// fun toLogin() {
+// activity.startActivity(
+// Intent(
+// activity.applicationContext,
+// LoginActivity::class.java,
+// ),
+// )
+// }
+//
+// fun toPinCodeActivity(role: Role) {
+// val intent = Intent(activity.applicationContext, PinCodeActivity::class.java)
+// intent.putExtra("role", role)
+// activity.startActivity(intent)
+// }
+// }
class NavigationService(val activity: Activity) {
fun toHomeScreenForRole(role: Role) {
when (role) {
- Role.Caretaker -> {
- activity.startActivity(
- Intent(
- activity.applicationContext,
- Homepage4caretaker::class.java,
- ),
- )
- }
-
- Role.Nurse -> {
- activity.startActivity(
- Intent(
- activity.applicationContext,
- Homepage4nurse::class.java,
- ),
- )
- }
-
- Role.Admin -> {
- activity.startActivity(
- Intent(
- activity.applicationContext,
- Homepage4admin::class.java,
- ),
- )
- }
+ Role.Caretaker -> activity.startActivity(Intent(activity, Homepage4caretaker::class.java))
+ Role.Nurse -> activity.startActivity(Intent(activity, Homepage4nurse::class.java))
+ Role.Admin -> activity.startActivity(Intent(activity, Homepage4admin::class.java))
+ Role.Doctor -> activity.startActivity(Intent(activity, Homepage4doctor::class.java))
}
}
fun toRegistration() {
- activity.startActivity(
- Intent(
- activity.applicationContext,
- RegisterActivity::class.java,
- ),
- )
+ activity.startActivity(Intent(activity, RegisterActivity::class.java))
}
fun onSettings() {
- activity.startActivity(
- Intent(
- activity.applicationContext,
- Setting::class.java,
- ),
- )
+ activity.startActivity(Intent(activity, Setting::class.java))
}
fun onSignOut() {
- activity.startActivity(
- Intent(
- activity.applicationContext,
- LoginActivity::class.java,
- ),
- )
+ activity.startActivity(Intent(activity, LoginActivity::class.java))
}
fun onLaunchPatientList() {
- activity.startActivity(
- Intent(
- activity.applicationContext,
- PatientListActivity::class.java,
- ),
- )
+ activity.startActivity(Intent(activity, PatientListActivity::class.java))
}
fun onLaunchTasks() {
- activity.startActivity(
- Intent(
- activity.applicationContext,
- TasksListActivity::class.java,
- ),
- )
+ activity.startActivity(Intent(activity, TasksListActivity::class.java))
}
fun onLaunchTaskCreator() {
- activity.startActivity(
- Intent(
- activity.applicationContext,
- TaskAddActivity::class.java,
- ),
- )
+ activity.startActivity(Intent(activity, TaskAddActivity::class.java))
}
fun toLogin() {
- activity.startActivity(
- Intent(
- activity.applicationContext,
- LoginActivity::class.java,
- ),
- )
+ activity.startActivity(Intent(activity, LoginActivity::class.java))
}
fun toPinCodeActivity(role: Role) {
- val intent = Intent(activity.applicationContext, PinCodeActivity::class.java)
+ val intent = Intent(activity, PinCodeActivity::class.java)
intent.putExtra("role", role)
activity.startActivity(intent)
}
diff --git a/app/src/main/java/deakin/gopher/guardian/services/api/ApiClient.kt b/app/src/main/java/deakin/gopher/guardian/services/api/ApiClient.kt
index 48eff44c..c969f4d4 100644
--- a/app/src/main/java/deakin/gopher/guardian/services/api/ApiClient.kt
+++ b/app/src/main/java/deakin/gopher/guardian/services/api/ApiClient.kt
@@ -6,8 +6,8 @@ import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
object RetrofitClient {
-// private const val BASE_URL = "http://10.0.2.2:3000/api/v1/"
- private const val BASE_URL = "https://guardian-backend-opal.vercel.app/api/v1/"
+ // private const val BASE_URL = "http://10.0.2.2:3000/api/v1/"
+ private const val BASE_URL = "https://guardian-backend-x5v6.vercel.app/api/v1/"
private val client = OkHttpClient()
private val interceptor = HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
diff --git a/app/src/main/java/deakin/gopher/guardian/services/api/ApiService.kt b/app/src/main/java/deakin/gopher/guardian/services/api/ApiService.kt
index 6eb25811..ae11c7bf 100644
--- a/app/src/main/java/deakin/gopher/guardian/services/api/ApiService.kt
+++ b/app/src/main/java/deakin/gopher/guardian/services/api/ApiService.kt
@@ -1,10 +1,15 @@
+@file:Suppress("ktlint:standard:no-wildcard-imports")
+
package deakin.gopher.guardian.services.api
import deakin.gopher.guardian.model.AddPatientActivityResponse
import deakin.gopher.guardian.model.AddPatientResponse
import deakin.gopher.guardian.model.BaseModel
+import deakin.gopher.guardian.model.Caretaker
import deakin.gopher.guardian.model.Patient
import deakin.gopher.guardian.model.PatientActivity
+import deakin.gopher.guardian.model.Prescription
+import deakin.gopher.guardian.model.PrescriptionResponse
import deakin.gopher.guardian.model.register.AuthResponse
import deakin.gopher.guardian.model.register.RegisterRequest
import okhttp3.MultipartBody
@@ -12,13 +17,17 @@ import okhttp3.RequestBody
import retrofit2.Call
import retrofit2.Response
import retrofit2.http.Body
+import retrofit2.http.DELETE
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Multipart
+import retrofit2.http.PATCH
import retrofit2.http.POST
+import retrofit2.http.PUT
import retrofit2.http.Part
+import retrofit2.http.Path
import retrofit2.http.Query
interface ApiService {
@@ -58,6 +67,24 @@ interface ApiService {
@Header("Authorization") token: String,
): Response>
+ // Fetch caretaker profile
+// @GET("caretaker/profile")
+// suspend fun getCaretakerProfile(): Response
+
+ @GET("caretaker/profile")
+ suspend fun getCaretakerProfile(
+ @Header("Authorization") token: String,
+ @Query("caretakerId") caretakerId: String,
+// @Header("Content-Type") contentType: String = "application/json",
+// caretakerId: String
+ ): Response
+
+ @PUT("caretaker/profile")
+ suspend fun updateCaretakerProfile(
+ @Header("Authorization") token: String,
+ @Body body: Map,
+ ): Response
+
@Multipart
@POST("patients/add")
suspend fun addPatient(
@@ -83,4 +110,60 @@ interface ApiService {
@Header("Authorization") token: String,
@Query("patientId") patientId: String,
): Response>
+
+ @DELETE("patients/{id}")
+ suspend fun deletePatient(
+ @Header("Authorization") token: String,
+ @Path("id") patientId: String,
+ ): Response
+
+ @POST("patients/assign-nurse")
+ suspend fun assignNurse(
+ @Header("Authorization") token: String,
+ @Body body: Map,
+ ): Response
+
+ @GET("patients/{patientId}/prescriptions")
+ fun getPrescriptionsForPatient(
+ @Header("Authorization") token: String,
+ @Path("patientId") patientId: String,
+ ): Call
+
+ @POST("prescriptions")
+ fun createPrescription(
+ @Header("Authorization") token: String,
+ @Body prescription: Prescription,
+ ): Call
+
+ // Get all prescriptions for a patient
+ @GET("patients/{patientId}/prescriptions")
+ fun getPrescriptionsForPatient(
+ @Header("Authorization") token: String,
+ @Path("patientId") patientId: String,
+ @Query("status") status: String? = null,
+ @Query("page") page: Int? = 1,
+ @Query("limit") limit: Int? = 10,
+ ): Call
+
+ // Get a prescription by ID
+ @GET("prescriptions/{id}")
+ fun getPrescriptionById(
+ @Header("Authorization") token: String,
+ @Path("id") prescriptionId: String,
+ ): Call
+
+ // Update a prescription by ID
+ @PATCH("prescriptions/{id}")
+ fun updatePrescription(
+ @Header("Authorization") token: String,
+ @Path("id") prescriptionId: String,
+ @Body updatedFields: Map,
+ ): Call
+
+ // Discontinue a prescription
+ @POST("prescriptions/{id}/discontinue")
+ fun discontinuePrescription(
+ @Header("Authorization") token: String,
+ @Path("id") prescriptionId: String,
+ ): Call
}
diff --git a/app/src/main/java/deakin/gopher/guardian/view/caretaker/CaretakerProfileActivity.kt b/app/src/main/java/deakin/gopher/guardian/view/caretaker/CaretakerProfileActivity.kt
index a3d71b56..b7a63f11 100644
--- a/app/src/main/java/deakin/gopher/guardian/view/caretaker/CaretakerProfileActivity.kt
+++ b/app/src/main/java/deakin/gopher/guardian/view/caretaker/CaretakerProfileActivity.kt
@@ -1,34 +1,311 @@
+//
+//
+// package deakin.gopher.guardian.view.caretaker
+//
+// import android.os.Bundle
+// import android.util.Log
+// import android.view.View
+// import android.widget.TextView
+// import android.widget.Toast
+// import androidx.appcompat.app.AppCompatActivity
+// import androidx.lifecycle.lifecycleScope
+// import com.google.android.material.button.MaterialButton
+// import com.google.android.material.textfield.TextInputEditText
+// import deakin.gopher.guardian.R
+// import deakin.gopher.guardian.model.Caretaker
+// import deakin.gopher.guardian.model.login.SessionManager
+// import deakin.gopher.guardian.services.api.ApiClient
+// import kotlinx.coroutines.launch
+// import retrofit2.HttpException
+//
+// class CaretakerProfileActivity : AppCompatActivity() {
+//
+// private lateinit var txtName: TextInputEditText
+// private lateinit var txtAddress: TextInputEditText
+// private lateinit var txtDoB: TextInputEditText
+// private lateinit var txtPhone: TextInputEditText
+// private lateinit var txtUnderCare: TextInputEditText
+// private lateinit var txtMedicareNumber: TextInputEditText
+// private lateinit var txtEmergencyContact: TextInputEditText
+// private lateinit var backBtn: MaterialButton
+// private lateinit var txtLoading: TextView
+//
+// private lateinit var caretaker: Caretaker
+//
+// override fun onCreate(savedInstanceState: Bundle?) {
+// super.onCreate(savedInstanceState)
+// setContentView(R.layout.activity_caretakerprofile)
+//
+// // Initialize views
+// txtName = findViewById(R.id.txtName)
+// txtAddress = findViewById(R.id.txtAddress)
+// txtDoB = findViewById(R.id.txtDoB)
+// txtPhone = findViewById(R.id.txtPhone)
+// txtUnderCare = findViewById(R.id.txtUnderCare)
+// txtMedicareNumber = findViewById(R.id.txtMedicareNumber)
+// txtEmergencyContact = findViewById(R.id.txtEmegencyContact)
+// backBtn = findViewById(R.id.backBtn)
+// txtLoading = findViewById(R.id.txtLoading)
+//
+// backBtn.setOnClickListener { finish() }
+//
+// // Show loading
+// txtLoading.visibility = View.VISIBLE
+//
+// // Log and display session data
+// logSessionData()
+//
+// // Fetch profile
+// fetchCaretakerProfile()
+// }
+//
+// private fun logSessionData() {
+// try {
+// val user = SessionManager.getCurrentUser()
+// val token = SessionManager.getToken()
+// Log.d("SessionData", "User: $user")
+// Log.d("SessionData", "Token: $token")
+//
+// // Optional: display session data as fallback
+// // txtName.setText(user.name ?: "")
+// // txtAddress.setText(user.address ?: "")
+// // txtDoB.setText(user.dob ?: "")
+// // txtPhone.setText(user.phone ?: "")
+// // txtUnderCare.setText(user.ward ?: "")
+// // txtMedicareNumber.setText(user.medicareNumber ?: "")
+// // txtEmergencyContact.setText(user.EmergencyContact ?: "")
+//
+// } catch (e: Exception) {
+// Log.e("SessionData", "Failed to get session data: ${e.message}")
+// }
+// }
+//
+// private fun fetchCaretakerProfile() {
+// val currentUser = try {
+// SessionManager.getCurrentUser()
+// } catch (e: Exception) {
+// txtLoading.visibility = View.GONE
+// Toast.makeText(this, "User not logged in", Toast.LENGTH_LONG).show()
+// return
+// }
+//
+// val token = try {
+// "Bearer ${SessionManager.getToken()}"
+// } catch (e: Exception) {
+// txtLoading.visibility = View.GONE
+// Toast.makeText(this, "Token not found. Please login again.", Toast.LENGTH_LONG).show()
+// return
+// }
+//
+// val caretakerIdentifier = currentUser.id ?: currentUser.email
+// if (caretakerIdentifier == null) {
+// txtLoading.visibility = View.GONE
+// Toast.makeText(this, "No ID or email found for user", Toast.LENGTH_LONG).show()
+// return
+// }
+//
+// lifecycleScope.launch {
+// try {
+// val response = ApiClient.apiService.getCaretakerProfile(
+// token = token,
+// caretakerId = caretakerIdentifier
+// )
+//
+// txtLoading.visibility = View.GONE
+//
+// Log.d("CaretakerProfile", "Response code: ${response.code()}")
+// Log.d("CaretakerProfile", "Response body: ${response.body()}")
+//
+// if (response.isSuccessful && response.body() != null) {
+// caretaker = response.body()!!
+// bindProfile(caretaker)
+// } else {
+// Log.w("CaretakerProfile", "API returned null or empty, showing session data")
+// Toast.makeText(
+// this@CaretakerProfileActivity,
+// "API data not available, using session data",
+// Toast.LENGTH_LONG
+// ).show()
+// }
+//
+// } catch (e: HttpException) {
+// txtLoading.visibility = View.GONE
+// Log.e("CaretakerProfile", "HTTP exception: ${e.message()}")
+// } catch (e: Exception) {
+// txtLoading.visibility = View.GONE
+// Log.e("CaretakerProfile", "Exception: ${e.message}")
+// }
+// }
+// }
+//
+// private fun bindProfile(c: Caretaker) {
+// txtName.setText(c.fullName ?: "")
+// txtAddress.setText("") // Not provided by API
+// txtDoB.setText("") // Not provided by API
+// txtPhone.setText("") // Not provided by API
+// txtUnderCare.setText(c.assignedPatients?.size?.toString() ?: "0")
+// txtMedicareNumber.setText("")
+// txtEmergencyContact.setText(c.email ?: "")
+//
+// txtName.isEnabled = false
+// txtAddress.isEnabled = false
+// txtDoB.isEnabled = false
+// txtPhone.isEnabled = false
+// txtUnderCare.isEnabled = false
+// txtMedicareNumber.isEnabled = false
+// txtEmergencyContact.isEnabled = false
+// }
+// }
+
package deakin.gopher.guardian.view.caretaker
import android.content.Intent
import android.os.Bundle
-import android.widget.Button
+import android.view.View
import android.widget.ImageView
+import android.widget.TextView
+import android.widget.Toast
+import androidx.activity.result.contract.ActivityResultContracts
+import androidx.appcompat.app.AppCompatActivity
+import androidx.lifecycle.lifecycleScope
+import com.google.android.material.button.MaterialButton
+import com.google.android.material.textfield.TextInputEditText
import deakin.gopher.guardian.R
-import deakin.gopher.guardian.view.general.BaseActivity
-import deakin.gopher.guardian.view.general.Homepage4caretaker
+import deakin.gopher.guardian.model.Caretaker
+import deakin.gopher.guardian.model.login.SessionManager
+import deakin.gopher.guardian.services.api.ApiClient
+import kotlinx.coroutines.launch
+import retrofit2.HttpException
-class CaretakerProfileActivity : BaseActivity() {
- private lateinit var backButton: Button
+class CaretakerProfileActivity : AppCompatActivity() {
+ private lateinit var txtName: TextInputEditText
+ private lateinit var txtAddress: TextInputEditText
+ private lateinit var txtDoB: TextInputEditText
+ private lateinit var txtPhone: TextInputEditText
+ private lateinit var txtUnderCare: TextInputEditText
+ private lateinit var txtMedicareNumber: TextInputEditText
+ private lateinit var txtEmail: TextInputEditText
+ private lateinit var backBtn: MaterialButton
private lateinit var editButton: ImageView
+ private lateinit var txtLoading: TextView
+
+ private lateinit var caretaker: Caretaker
+
+ private val editActivityLauncher =
+ registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
+ if (result.resultCode == RESULT_OK) {
+ val updatedCaretaker =
+ result.data?.getSerializableExtra("updatedCaretaker") as? Caretaker
+ updatedCaretaker?.let {
+ caretaker = it
+ bindProfile(caretaker)
+ Toast.makeText(this, "Profile updated!", Toast.LENGTH_SHORT).show()
+ }
+ }
+ }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_caretakerprofile)
- backButton = findViewById(R.id.backBtn)
+ // Initialize views
+ txtName = findViewById(R.id.txtName)
+ txtAddress = findViewById(R.id.txtAddress)
+ txtDoB = findViewById(R.id.txtDoB)
+ txtPhone = findViewById(R.id.txtPhone)
+ txtUnderCare = findViewById(R.id.txtUnderCare)
+ txtMedicareNumber = findViewById(R.id.txtMedicareNumber)
+ txtEmail = findViewById(R.id.txtEmail)
+ backBtn = findViewById(R.id.backBtn)
editButton = findViewById(R.id.editButton)
+ txtLoading = findViewById(R.id.txtLoading)
- backButton.setOnClickListener {
- val medicalDiagnosticsActivityIntent =
- Intent(this, Homepage4caretaker::class.java)
- startActivity(medicalDiagnosticsActivityIntent)
- }
+ backBtn.setOnClickListener { finish() }
+
+ // Disable edit button until profile loads
+ editButton.isEnabled = false
editButton.setOnClickListener {
- val medicalDiagnosticsActivityIntent =
- Intent(this, EditCaretakerProfileActivity::class.java)
- startActivity(medicalDiagnosticsActivityIntent)
+ val intent = Intent(this, EditCaretakerProfileActivity::class.java)
+ intent.putExtra("caretaker", caretaker)
+ editActivityLauncher.launch(intent)
}
+
+ fetchCaretakerProfile()
+ }
+
+ private fun fetchCaretakerProfile() {
+ txtLoading.visibility = View.VISIBLE
+
+ val token =
+ try {
+ "Bearer ${SessionManager.getToken()}"
+ } catch (e: Exception) {
+ Toast.makeText(this, "User not logged in", Toast.LENGTH_LONG).show()
+ return
+ }
+
+ val currentUser =
+ try {
+ SessionManager.getCurrentUser()
+ } catch (e: Exception) {
+ Toast.makeText(this, "User not found", Toast.LENGTH_LONG).show()
+ return
+ }
+
+ val caretakerId = currentUser.id ?: ""
+
+ lifecycleScope.launch {
+ try {
+ val response =
+ ApiClient.apiService.getCaretakerProfile(
+ token = token,
+ caretakerId = caretakerId,
+ )
+
+ txtLoading.visibility = View.GONE
+
+ if (response.isSuccessful && response.body() != null) {
+ caretaker = response.body()!!
+ bindProfile(caretaker)
+ editButton.isEnabled = true
+ } else {
+ Toast.makeText(
+ this@CaretakerProfileActivity,
+ "Failed to fetch profile: ${response.code()}",
+ Toast.LENGTH_LONG,
+ ).show()
+ }
+ } catch (e: HttpException) {
+ txtLoading.visibility = View.GONE
+ Toast.makeText(
+ this@CaretakerProfileActivity,
+ "HTTP error: ${e.message()}",
+ Toast.LENGTH_LONG,
+ ).show()
+ } catch (e: Exception) {
+ txtLoading.visibility = View.GONE
+ Toast.makeText(
+ this@CaretakerProfileActivity,
+ "Error: ${e.message}",
+ Toast.LENGTH_LONG,
+ ).show()
+ }
+ }
+ }
+
+ private fun bindProfile(c: Caretaker) {
+ txtName.setText(c.fullName ?: "")
+ txtEmail.setText(c.email ?: "")
+ txtUnderCare.setText(c.assignedPatients?.size?.toString() ?: "0")
+
+ // Read-only fields
+ txtName.isEnabled = false
+ txtAddress.isEnabled = false
+ txtDoB.isEnabled = false
+ txtPhone.isEnabled = false
+ txtUnderCare.isEnabled = false
+ txtMedicareNumber.isEnabled = false
+ txtEmail.isEnabled = false
}
}
diff --git a/app/src/main/java/deakin/gopher/guardian/view/caretaker/EditCaretakerProfileActivity.kt b/app/src/main/java/deakin/gopher/guardian/view/caretaker/EditCaretakerProfileActivity.kt
index 58ec8089..5ac2f42c 100644
--- a/app/src/main/java/deakin/gopher/guardian/view/caretaker/EditCaretakerProfileActivity.kt
+++ b/app/src/main/java/deakin/gopher/guardian/view/caretaker/EditCaretakerProfileActivity.kt
@@ -1,28 +1,269 @@
+// package deakin.gopher.guardian.view.caretaker
+//
+// import android.content.Intent
+// import android.os.Bundle
+// import android.widget.ImageView
+// import android.widget.Toast
+// import androidx.appcompat.app.AppCompatActivity
+// import com.google.android.material.button.MaterialButton
+// import com.google.android.material.textfield.TextInputEditText
+// import deakin.gopher.guardian.R
+// import deakin.gopher.guardian.model.Caretaker
+// import deakin.gopher.guardian.model.login.SessionManager
+// import deakin.gopher.guardian.services.api.ApiClient
+// import kotlinx.coroutines.CoroutineScope
+// import kotlinx.coroutines.Dispatchers
+// import kotlinx.coroutines.launch
+// import retrofit2.Response
+//
+// class EditCaretakerProfileActivity : AppCompatActivity() {
+//
+// private lateinit var txtName: TextInputEditText
+// private lateinit var txtEmergencyContact: TextInputEditText
+// private lateinit var txtUnderCare: TextInputEditText
+// private lateinit var imgProfile: ImageView
+// private lateinit var btnSave: MaterialButton
+// private lateinit var backBtn: MaterialButton
+//
+// private lateinit var caretaker: Caretaker
+//
+// override fun onCreate(savedInstanceState: Bundle?) {
+// super.onCreate(savedInstanceState)
+// setContentView(R.layout.activity_edit_caretakerprofile)
+//
+// // Initialize views
+// txtName = findViewById(R.id.txtName)
+// txtEmergencyContact = findViewById(R.id.txtEmegencyContact)
+// txtUnderCare = findViewById(R.id.txtUnderCare)
+// imgProfile = findViewById(R.id.caretakerImage)
+// btnSave = findViewById(R.id.btnSave)
+// backBtn = findViewById(R.id.backBtn)
+//
+// // Get caretaker object from intent
+// caretaker = intent.getSerializableExtra("caretaker") as Caretaker
+// populateUI(caretaker)
+//
+// backBtn.setOnClickListener { finish() }
+//
+// btnSave.setOnClickListener {
+// // Update the editable field
+// caretaker.fullName = txtName.text.toString()
+//
+// // Call API to update caretaker profile
+// updateCaretakerProfile(caretaker)
+// }
+// }
+//
+// /**
+// * Populates UI with caretaker data
+// */
+// private fun populateUI(c: Caretaker) {
+// txtName.setText(c.fullName ?: "")
+// txtEmergencyContact.setText(c.email ?: "")
+// txtUnderCare.setText(c.assignedPatients?.size?.toString() ?: "0")
+// }
+//
+// /**
+// * Updates caretaker profile on the backend
+// */
+// private fun updateCaretakerProfile(caretaker: Caretaker) {
+// // Get token from SessionManager
+// val token = try {
+// "Bearer ${SessionManager.getToken()}"
+// } catch (e: Exception) {
+// Toast.makeText(this, "Token not found. Please login again.", Toast.LENGTH_LONG).show()
+// return
+// }
+//
+// // Request body with only editable fields
+// val requestBody = mapOf(
+// "caretakerId" to (caretaker.id ?: ""),
+// "fullname" to (caretaker.fullName ?: "")
+// )
+//
+// CoroutineScope(Dispatchers.IO).launch {
+// try {
+// val response: Response = ApiClient.apiService.updateCaretakerProfile(token, requestBody)
+// if (response.isSuccessful) {
+// // Return updated caretaker to profile screen
+// val resultIntent = Intent()
+// resultIntent.putExtra("updatedCaretaker", caretaker)
+// setResult(RESULT_OK, resultIntent)
+//
+// runOnUiThread {
+// Toast.makeText(
+// this@EditCaretakerProfileActivity,
+// "Profile updated successfully",
+// Toast.LENGTH_SHORT
+// ).show()
+// }
+//
+// finish()
+// } else {
+// runOnUiThread {
+// Toast.makeText(
+// this@EditCaretakerProfileActivity,
+// "Update failed: ${response.code()}",
+// Toast.LENGTH_LONG
+// ).show()
+// }
+// }
+// } catch (e: Exception) {
+// runOnUiThread {
+// Toast.makeText(
+// this@EditCaretakerProfileActivity,
+// "Error: ${e.message}",
+// Toast.LENGTH_LONG
+// ).show()
+// }
+// }
+// }
+// }
+// }
+
package deakin.gopher.guardian.view.caretaker
import android.content.Intent
import android.os.Bundle
-import android.widget.Button
import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
+import com.google.android.material.button.MaterialButton
+import com.google.android.material.textfield.TextInputEditText
import deakin.gopher.guardian.R
-import deakin.gopher.guardian.view.general.BaseActivity
+import deakin.gopher.guardian.model.Caretaker
+import deakin.gopher.guardian.model.login.SessionManager
+import deakin.gopher.guardian.services.api.ApiClient
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import retrofit2.Response
+
+class EditCaretakerProfileActivity : AppCompatActivity() {
+ private lateinit var txtName: TextInputEditText
+ private lateinit var txtAddress: TextInputEditText
+ private lateinit var txtDoB: TextInputEditText
+ private lateinit var txtPhone: TextInputEditText
+ private lateinit var txtUnderCare: TextInputEditText
+ private lateinit var txtMedicareNumber: TextInputEditText
+ private lateinit var txtEmail: TextInputEditText
+ private lateinit var btnSave: MaterialButton
+ private lateinit var backBtn: MaterialButton
-class EditCaretakerProfileActivity : BaseActivity() {
- private lateinit var saveButton: Button
- val emojiCodePoint = 0x1F97A
- val emojiString = String(Character.toChars(emojiCodePoint))
+ private lateinit var caretaker: Caretaker
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_edit_caretakerprofile)
- saveButton = findViewById(R.id.btnSave)
+ // Initialize fields
+ txtName = findViewById(R.id.txtName)
+ txtAddress = findViewById(R.id.txtAddress)
+ txtDoB = findViewById(R.id.txtDoB)
+ txtPhone = findViewById(R.id.txtPhone)
+ txtUnderCare = findViewById(R.id.txtUnderCare)
+ txtMedicareNumber = findViewById(R.id.txtMedicareNumber)
+ txtEmail = findViewById(R.id.txtEmail)
+ btnSave = findViewById(R.id.btnSave)
+ backBtn = findViewById(R.id.backBtn)
+
+ caretaker = intent.getSerializableExtra("caretaker") as Caretaker
+ populateUI(caretaker)
+
+ backBtn.setOnClickListener { finish() }
+
+ btnSave.setOnClickListener {
+ // Update caretaker object with new values from input fields
+ caretaker.apply {
+ fullName = txtName.text.toString().trim()
+ address = txtAddress.text.toString().trim()
+ dob = txtDoB.text.toString().trim()
+ phone = txtPhone.text.toString().trim()
+ ward = txtUnderCare.text.toString().trim()
+ medicareNumber = txtMedicareNumber.text.toString().trim()
+ email = txtEmail.text.toString().trim()
+ }
+
+ // Validate at least name and phone
+ if (caretaker.fullName.isNullOrEmpty()) {
+ Toast.makeText(this, "Name cannot be empty", Toast.LENGTH_SHORT).show()
+ return@setOnClickListener
+ }
+
+ updateCaretakerProfile(caretaker)
+ }
+ }
+
+ private fun populateUI(c: Caretaker) {
+ txtName.setText(c.fullName ?: "")
+ txtAddress.setText(c.address ?: "")
+ txtDoB.setText(c.dob ?: "")
+ txtPhone.setText(c.phone ?: "")
+ txtUnderCare.setText(c.ward ?: "")
+ txtMedicareNumber.setText(c.medicareNumber ?: "")
+ txtEmail.setText(c.email ?: "")
+
+ // All fields editable
+ txtName.isEnabled = true
+ txtAddress.isEnabled = true
+ txtDoB.isEnabled = true
+ txtPhone.isEnabled = true
+ txtUnderCare.isEnabled = true
+ txtMedicareNumber.isEnabled = true
+ txtEmail.isEnabled = true
+ }
+
+ private fun updateCaretakerProfile(caretaker: Caretaker) {
+ val token =
+ try {
+ "Bearer ${SessionManager.getToken()}"
+ } catch (e: Exception) {
+ Toast.makeText(this, "Token not found. Please login again.", Toast.LENGTH_LONG).show()
+ return
+ }
+
+ val requestBody =
+ mapOf(
+ "caretakerId" to (caretaker.id ?: ""),
+ "fullname" to (caretaker.fullName ?: ""),
+ "address" to (caretaker.address ?: ""),
+ "dob" to (caretaker.dob ?: ""),
+ "phone" to (caretaker.phone ?: ""),
+ "ward" to (caretaker.ward ?: ""),
+ "medicareNumber" to (caretaker.medicareNumber ?: ""),
+ "email" to (caretaker.email ?: ""),
+ )
+
+ CoroutineScope(Dispatchers.IO).launch {
+ try {
+ val response: Response = ApiClient.apiService.updateCaretakerProfile(token, requestBody)
+ if (response.isSuccessful) {
+ runOnUiThread {
+ Toast.makeText(this@EditCaretakerProfileActivity, "Profile updated successfully", Toast.LENGTH_SHORT).show()
+ }
- saveButton.setOnClickListener {
- Toast.makeText(this, "Why Firebase not working? $emojiString", Toast.LENGTH_LONG).show()
- val medicalDiagnosticsActivityIntent =
- Intent(this, CaretakerProfileActivity::class.java)
- startActivity(medicalDiagnosticsActivityIntent)
+ // Return updated caretaker back to profile screen
+ val resultIntent = Intent()
+ resultIntent.putExtra("updatedCaretaker", caretaker)
+ setResult(RESULT_OK, resultIntent)
+ finish()
+ } else {
+ runOnUiThread {
+ Toast.makeText(
+ this@EditCaretakerProfileActivity,
+ "Update failed: ${response.code()}",
+ Toast.LENGTH_LONG,
+ ).show()
+ }
+ }
+ } catch (e: Exception) {
+ runOnUiThread {
+ Toast.makeText(
+ this@EditCaretakerProfileActivity,
+ "Error: ${e.message}",
+ Toast.LENGTH_LONG,
+ ).show()
+ }
+ }
}
}
}
diff --git a/app/src/main/java/deakin/gopher/guardian/view/caretaker/MainActivity.kt b/app/src/main/java/deakin/gopher/guardian/view/caretaker/MainActivity.kt
index 5d7c949b..c9014cf4 100644
--- a/app/src/main/java/deakin/gopher/guardian/view/caretaker/MainActivity.kt
+++ b/app/src/main/java/deakin/gopher/guardian/view/caretaker/MainActivity.kt
@@ -1,3 +1,45 @@
+// package deakin.gopher.guardian
+//
+// import android.os.Bundle
+// import androidx.activity.ComponentActivity
+// import androidx.activity.compose.setContent
+// import androidx.compose.material3.MaterialTheme
+// import androidx.compose.material3.Surface
+// import androidx.navigation.compose.NavHost
+// import androidx.navigation.compose.composable
+// import androidx.navigation.compose.rememberNavController
+// import deakin.gopher.guardian.view.theme.GuardianTheme
+//
+// class MainActivity : ComponentActivity() {
+// override fun onCreate(savedInstanceState: Bundle?) {
+// super.onCreate(savedInstanceState)
+// setContent {
+// GuardianTheme {
+// Surface(color = MaterialTheme.colorScheme.background) {
+// val navController = rememberNavController()
+// NavHost(navController = navController, startDestination = "welcome") {
+// composable("welcome") { WelcomeScreen(navController) }
+// composable("role_selection") { RoleSelectionScreen(navController) }
+// composable("doctor_login") { DoctorLoginPage(navController) }
+// composable("doctor_home") { DoctorHomeScreen(navController) }
+// composable("patient_report") { PatientReportScreen(navController) }
+// composable("medical_summary") {
+// MedicalSummaryScreen(navController, patientName = "William S")
+// }
+// composable("assign_nurse") { AssignNurseScreen(navController) }
+// composable("activity_log") { ActivityLogScreen(navController) }
+// composable("appointment") { AppointmentScreen(navController) }
+// composable("prescription") { PrescriptionScreen(navController) }
+// composable("billing") { BillingScreen(navController) }
+// composable("sign_out") { SignOutScreen(navController) }
+// // 🚨 Removed: composable("edit_profile") { EditCaretakerProfileActivity(navController) }
+// }
+// }
+// }
+// }
+// }
+// }
+
package deakin.gopher.guardian
import android.os.Bundle
@@ -17,66 +59,55 @@ class MainActivity : ComponentActivity() {
GuardianTheme {
Surface(color = MaterialTheme.colorScheme.background) {
val navController = rememberNavController()
- NavHost(navController = navController, startDestination = "welcome") {
- // 1. Welcome
+
+ // Navigation Graph
+ NavHost(
+ navController = navController,
+ startDestination = "welcome",
+ ) {
composable("welcome") {
WelcomeScreen(navController)
}
-
- // 2. Role selection
composable("role_selection") {
RoleSelectionScreen(navController)
}
-
- // 3. Doctor login
composable("doctor_login") {
DoctorLoginPage(navController)
}
-
- // 4. Doctor home page
composable("doctor_home") {
DoctorHomeScreen(navController)
}
-
- // 5. Patient report
composable("patient_report") {
PatientReportScreen(navController)
}
-
- // 6. Medical summary for William S
composable("medical_summary") {
MedicalSummaryScreen(navController, patientName = "William S")
}
-
- // 7. Assign nurse
composable("assign_nurse") {
AssignNurseScreen(navController)
}
-
- // 8. Activity log
composable("activity_log") {
ActivityLogScreen(navController)
}
-
- // 9. Appointment
composable("appointment") {
AppointmentScreen(navController)
}
- // 10. Prescription
+ // Prescription screen (now ready for dynamic patient data later)
composable("prescription") {
PrescriptionScreen(navController)
}
- // 11. Billing
composable("billing") {
BillingScreen(navController)
}
-
- // 12. Sign out
composable("sign_out") {
SignOutScreen(navController)
}
+
+ // Placeholder for edit profile - to be updated later if needed
+ // 🚨 Removed previously to avoid crash
+ // composable("edit_profile") { EditCaretakerProfileActivity(navController) }
}
}
}
diff --git a/app/src/main/java/deakin/gopher/guardian/view/doctor/DoctorProfileActivity.kt b/app/src/main/java/deakin/gopher/guardian/view/doctor/DoctorProfileActivity.kt
new file mode 100644
index 00000000..8bc3b67e
--- /dev/null
+++ b/app/src/main/java/deakin/gopher/guardian/view/doctor/DoctorProfileActivity.kt
@@ -0,0 +1,251 @@
+// package deakin.gopher.guardian.view.doctor
+//
+// import android.content.Intent
+// import android.os.Bundle
+// import android.util.Log
+// import android.view.View
+// import android.widget.ImageView
+// import android.widget.TextView
+// import android.widget.Toast
+// import androidx.activity.result.contract.ActivityResultContracts
+// import androidx.appcompat.app.AppCompatActivity
+// import androidx.lifecycle.lifecycleScope
+// import com.google.android.material.button.MaterialButton
+// import com.google.android.material.textfield.TextInputEditText
+// import deakin.gopher.guardian.R
+// import deakin.gopher.guardian.model.Doctor
+// import deakin.gopher.guardian.model.login.SessionManager
+// import deakin.gopher.guardian.services.api.ApiClient
+// import kotlinx.coroutines.launch
+// import retrofit2.HttpException
+// import kotlin.jvm.java
+//
+// class DoctorProfileActivity : AppCompatActivity() {
+//
+// // UI components
+// private lateinit var txtName: TextInputEditText
+// private lateinit var txtSpecialization: TextInputEditText
+// private lateinit var txtPhone: TextInputEditText
+// private lateinit var txtEmail: TextInputEditText
+// private lateinit var txtAssignedPatients: TextInputEditText
+// private lateinit var txtHospital: TextInputEditText
+// private lateinit var backBtn: MaterialButton
+// private lateinit var editButton: ImageView
+// private lateinit var txtLoading: TextView
+//
+// private lateinit var doctor: Doctor
+//
+// private val editActivityLauncher =
+// registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
+// if (result.resultCode == RESULT_OK) {
+// val updatedDoctor =
+// result.data?.getSerializableExtra("updatedDoctor") as? Doctor
+// updatedDoctor?.let {
+// doctor = it
+// bindProfile(doctor)
+// Toast.makeText(this, "Profile updated!", Toast.LENGTH_SHORT).show()
+// }
+// }
+// }
+//
+// override fun onCreate(savedInstanceState: Bundle?) {
+// super.onCreate(savedInstanceState)
+// setContentView(R.layout.activity_doctor_profile)
+//
+// // Initialize views
+// txtName = findViewById(R.id.txtName)
+// txtSpecialization = findViewById(R.id.txtSpecialization)
+// txtPhone = findViewById(R.id.txtPhone)
+// txtEmail = findViewById(R.id.txtEmail)
+// txtAssignedPatients = findViewById(R.id.txtAssignedPatients)
+// txtHospital = findViewById(R.id.txtHospital)
+// backBtn = findViewById(R.id.backBtn)
+// editButton = findViewById(R.id.editButton)
+// txtLoading = findViewById(R.id.txtLoading)
+//
+// backBtn.setOnClickListener { finish() }
+//
+// // Disable edit button until profile loads
+// editButton.isEnabled = false
+//
+// editButton.setOnClickListener {
+// val intent = Intent(this, EditDoctorProfileActivity::class.java)
+// intent.putExtra("doctor", doctor)
+// editActivityLauncher.launch(intent)
+// }
+//
+// fetchDoctorProfile()
+// }
+//
+// private fun fetchDoctorProfile() {
+// txtLoading.visibility = View.VISIBLE
+//
+// val token = try {
+// "Bearer ${SessionManager.getToken()}"
+// } catch (e: Exception) {
+// txtLoading.visibility = View.GONE
+// Toast.makeText(this, "User not logged in", Toast.LENGTH_LONG).show()
+// return
+// }
+//
+// val currentUser = try {
+// SessionManager.getCurrentUser()
+// } catch (e: Exception) {
+// txtLoading.visibility = View.GONE
+// Toast.makeText(this, "User not found", Toast.LENGTH_LONG).show()
+// return
+// }
+//
+// val doctorId = currentUser.id ?: ""
+//
+// lifecycleScope.launch {
+// try {
+// val response = ApiClient.apiService.getDoctorProfile(
+// token = token,
+// doctorId = doctorId
+// )
+//
+// txtLoading.visibility = View.GONE
+//
+// if (response.isSuccessful && response.body() != null) {
+// doctor = response.body()!!
+// bindProfile(doctor)
+// editButton.isEnabled = true
+// } else {
+// Toast.makeText(
+// this@DoctorProfileActivity,
+// "Failed to fetch profile: ${response.code()}",
+// Toast.LENGTH_LONG
+// ).show()
+// }
+//
+// } catch (e: HttpException) {
+// txtLoading.visibility = View.GONE
+// Log.e("DoctorProfile", "HTTP error: ${e.message()}")
+// Toast.makeText(
+// this@DoctorProfileActivity,
+// "HTTP error: ${e.message()}",
+// Toast.LENGTH_LONG
+// ).show()
+// } catch (e: Exception) {
+// txtLoading.visibility = View.GONE
+// Log.e("DoctorProfile", "Error: ${e.message}")
+// Toast.makeText(
+// this@DoctorProfileActivity,
+// "Error: ${e.message}",
+// Toast.LENGTH_LONG
+// ).show()
+// }
+// }
+// }
+//
+// private fun bindProfile(d: Doctor) {
+// txtName.setText(d.fullName ?: "")
+// txtSpecialization.setText(d.specialization ?: "")
+// txtPhone.setText(d.phone ?: "")
+// txtEmail.setText(d.email ?: "")
+// txtAssignedPatients.setText(d.assignedPatients?.size?.toString() ?: "0")
+// txtHospital.setText(d.hospital ?: "")
+//
+// // Make all fields read-only
+// txtName.isEnabled = false
+// txtSpecialization.isEnabled = false
+// txtPhone.isEnabled = false
+// txtEmail.isEnabled = false
+// txtAssignedPatients.isEnabled = false
+// txtHospital.isEnabled = false
+// }
+// }
+
+package deakin.gopher.guardian.view.doctor
+
+import android.app.Activity
+import android.content.Intent
+import android.os.Bundle
+import android.widget.ImageView
+import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
+import com.google.android.material.button.MaterialButton
+import com.google.android.material.textfield.TextInputEditText
+import deakin.gopher.guardian.R
+import deakin.gopher.guardian.model.Doctor
+
+class DoctorProfileActivity : AppCompatActivity() {
+ private lateinit var txtName: TextInputEditText
+ private lateinit var txtSpecialization: TextInputEditText
+ private lateinit var txtPhone: TextInputEditText
+ private lateinit var txtEmail: TextInputEditText
+ private lateinit var txtHospital: TextInputEditText
+ private lateinit var editButton: ImageView
+ private lateinit var backButton: MaterialButton
+
+ private lateinit var doctor: Doctor
+
+ private val editActivityLauncher =
+ registerForActivityResult(androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult()) { result ->
+ if (result.resultCode == Activity.RESULT_OK) {
+ val updatedDoctor = result.data?.getSerializableExtra("updatedDoctor") as? Doctor
+ updatedDoctor?.let {
+ doctor = it
+ bindProfile(doctor)
+ Toast.makeText(this, "Profile updated!", Toast.LENGTH_SHORT).show()
+ }
+ }
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_doctor_profile)
+
+ // Initialize views
+ txtName = findViewById(R.id.txtName)
+ txtSpecialization = findViewById(R.id.txtSpecialization)
+ txtPhone = findViewById(R.id.txtPhone)
+ txtEmail = findViewById(R.id.txtEmail)
+ txtHospital = findViewById(R.id.txtHospital)
+ editButton = findViewById(R.id.editButton)
+
+ // Create a dummy doctor object (static)
+ doctor =
+ Doctor(
+ fullName = "Dr. John Doe",
+ specialization = "Cardiology",
+ phone = "123-456-7890",
+ email = "john.doe@example.com",
+ hospital = "City Hospital",
+ )
+
+ // Bind profile
+ bindProfile(doctor)
+
+ // Disable edit button until we need it
+ editButton.isEnabled = true
+
+ // Edit button launches EditDoctorProfileActivity
+ editButton.setOnClickListener {
+ val intent = Intent(this, EditDoctorProfileActivity::class.java)
+ intent.putExtra("doctor", doctor)
+ editActivityLauncher.launch(intent)
+ }
+
+ // Back button
+ backButton.setOnClickListener {
+ finish()
+ }
+ }
+
+ private fun bindProfile(d: Doctor) {
+ txtName.setText(d.fullName ?: "")
+ txtSpecialization.setText(d.specialization ?: "")
+ txtPhone.setText(d.phone ?: "")
+ txtEmail.setText(d.email ?: "")
+ txtHospital.setText(d.hospital ?: "")
+
+ // Make fields read-only
+ txtName.isEnabled = false
+ txtSpecialization.isEnabled = false
+ txtPhone.isEnabled = false
+ txtEmail.isEnabled = false
+ txtHospital.isEnabled = false
+ }
+}
diff --git a/app/src/main/java/deakin/gopher/guardian/view/doctor/EditDoctorProfileActivity.kt b/app/src/main/java/deakin/gopher/guardian/view/doctor/EditDoctorProfileActivity.kt
new file mode 100644
index 00000000..3c963bc6
--- /dev/null
+++ b/app/src/main/java/deakin/gopher/guardian/view/doctor/EditDoctorProfileActivity.kt
@@ -0,0 +1,68 @@
+package deakin.gopher.guardian.view.doctor
+
+import android.app.Activity
+import android.os.Bundle
+import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
+import com.google.android.material.button.MaterialButton
+import com.google.android.material.textfield.TextInputEditText
+import deakin.gopher.guardian.R
+import deakin.gopher.guardian.model.Doctor
+
+class EditDoctorProfileActivity : AppCompatActivity() {
+ private lateinit var txtName: TextInputEditText
+ private lateinit var txtSpecialization: TextInputEditText
+ private lateinit var txtPhone: TextInputEditText
+ private lateinit var txtEmail: TextInputEditText
+ private lateinit var txtHospital: TextInputEditText
+ private lateinit var btnSave: MaterialButton
+ private lateinit var btnCancel: MaterialButton
+
+ private lateinit var doctor: Doctor
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_edit_doctor_profile)
+
+ // Get doctor object from intent
+ doctor = intent.getSerializableExtra("doctor") as? Doctor ?: Doctor()
+
+ // Initialize views
+ txtName = findViewById(R.id.txtName)
+ txtSpecialization = findViewById(R.id.txtSpecialization)
+ txtPhone = findViewById(R.id.txtPhone)
+ txtEmail = findViewById(R.id.txtEmail)
+ txtHospital = findViewById(R.id.txtHospital)
+ btnSave = findViewById(R.id.btnSave)
+ btnCancel = findViewById(R.id.btnCancel)
+
+ // Populate fields
+ txtName.setText(doctor.fullName ?: "")
+ txtSpecialization.setText(doctor.specialization ?: "")
+ txtPhone.setText(doctor.phone ?: "")
+ txtEmail.setText(doctor.email ?: "")
+ txtHospital.setText(doctor.hospital ?: "")
+
+ // Save button
+ btnSave.setOnClickListener {
+ doctor.fullName = txtName.text.toString()
+ doctor.specialization = txtSpecialization.text.toString()
+ doctor.phone = txtPhone.text.toString()
+ doctor.email = txtEmail.text.toString()
+ doctor.hospital = txtHospital.text.toString()
+
+ // Return updated doctor object to previous activity
+ val resultIntent = intent
+ resultIntent.putExtra("updatedDoctor", doctor)
+ setResult(Activity.RESULT_OK, resultIntent)
+ Toast.makeText(this, "Profile saved!", Toast.LENGTH_SHORT).show()
+ finish()
+ }
+
+ // Cancel button
+ btnCancel.setOnClickListener {
+ setResult(Activity.RESULT_CANCELED)
+ finish()
+ }
+ }
+}
diff --git a/app/src/main/java/deakin/gopher/guardian/view/general/AddNewPatientActivity.kt b/app/src/main/java/deakin/gopher/guardian/view/general/AddNewPatientActivity.kt
index 6c2a9a15..cca7497c 100644
--- a/app/src/main/java/deakin/gopher/guardian/view/general/AddNewPatientActivity.kt
+++ b/app/src/main/java/deakin/gopher/guardian/view/general/AddNewPatientActivity.kt
@@ -104,6 +104,7 @@ class AddNewPatientActivity : BaseActivity() {
}
val response =
ApiClient.apiService.addPatient(token, namePart, dobPart, genderPart, photoPart)
+
withContext(Dispatchers.Main) {
withContext(Dispatchers.Main) {
binding.progressBar.hide()
diff --git a/app/src/main/java/deakin/gopher/guardian/view/general/Homepage4caretaker.kt b/app/src/main/java/deakin/gopher/guardian/view/general/Homepage4caretaker.kt
index cdcd3d2e..295dc891 100644
--- a/app/src/main/java/deakin/gopher/guardian/view/general/Homepage4caretaker.kt
+++ b/app/src/main/java/deakin/gopher/guardian/view/general/Homepage4caretaker.kt
@@ -11,7 +11,9 @@ import deakin.gopher.guardian.R
import deakin.gopher.guardian.TrainingActivity
import deakin.gopher.guardian.services.EmailPasswordAuthService
import deakin.gopher.guardian.view.caretaker.CaretakerProfileActivity
-import deakin.gopher.guardian.view.falldetection.FallDetectionActivity
+import deakin.gopher.guardian.view.falldetection.FallDetectionActivity // <-- Added import for Prescription
+import deakin.gopher.guardian.view.prescription.PrescriptionActivity
+import kotlin.jvm.java
class Homepage4caretaker : BaseActivity() {
private lateinit var patientListButton: Button
@@ -22,11 +24,14 @@ class Homepage4caretaker : BaseActivity() {
private lateinit var trainingButton: Button
private lateinit var monitorButton: Button
private lateinit var exercisePortalButton: Button
+ private lateinit var prescriptionButton: Button // <-- Added prescription button
@SuppressLint("MissingInflatedId")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_homepage4caretaker)
+
+ // Existing button initializations
patientListButton = findViewById(R.id.patientListButton)
settingsButton = findViewById(R.id.settingsButton3)
signOutButton = findViewById(R.id.sighOutButton)
@@ -35,6 +40,7 @@ class Homepage4caretaker : BaseActivity() {
trainingButton = findViewById(R.id.trainingButton)
monitorButton = findViewById(R.id.monitorButton)
exercisePortalButton = findViewById(R.id.exerciseportal)
+ prescriptionButton = findViewById(R.id.prescriptionButton) // <-- Initialize prescription button
// patient list button
patientListButton.setOnClickListener {
@@ -65,12 +71,14 @@ class Homepage4caretaker : BaseActivity() {
finish()
}
+ // profile button
profileButton.setOnClickListener {
val medicalDiagnosticsActivityIntent =
Intent(this@Homepage4caretaker, CaretakerProfileActivity::class.java)
startActivity(medicalDiagnosticsActivityIntent)
}
+ // monitor button
monitorButton.setOnClickListener {
startFallDetectionActivity()
}
@@ -82,12 +90,19 @@ class Homepage4caretaker : BaseActivity() {
)
}
- // exercise portal button
+ // exercise portal button
exercisePortalButton.setOnClickListener {
startActivity(
Intent(this@Homepage4caretaker, PatientExerciseModules::class.java),
)
}
+
+ // prescription button
+ prescriptionButton.setOnClickListener {
+ val prescriptionIntent =
+ Intent(this@Homepage4caretaker, PrescriptionActivity::class.java)
+ startActivity(prescriptionIntent)
+ }
}
@OptIn(UnstableApi::class)
diff --git a/app/src/main/java/deakin/gopher/guardian/view/general/Homepage4doctor.kt b/app/src/main/java/deakin/gopher/guardian/view/general/Homepage4doctor.kt
new file mode 100644
index 00000000..db104d4c
--- /dev/null
+++ b/app/src/main/java/deakin/gopher/guardian/view/general/Homepage4doctor.kt
@@ -0,0 +1,77 @@
+package deakin.gopher.guardian.view.general
+
+import android.annotation.SuppressLint
+import android.content.Intent
+import android.os.Bundle
+import android.widget.Button
+import androidx.annotation.OptIn
+import androidx.media3.common.util.UnstableApi
+import deakin.gopher.guardian.R
+import deakin.gopher.guardian.services.EmailPasswordAuthService
+import deakin.gopher.guardian.view.doctor.DoctorProfileActivity
+import deakin.gopher.guardian.view.falldetection.FallDetectionActivity
+import deakin.gopher.guardian.view.prescription.PrescriptionActivity
+
+class Homepage4doctor : BaseActivity() {
+ private lateinit var patientListButton: Button
+ private lateinit var settingsButton: Button
+ private lateinit var signOutButton: Button
+ private lateinit var profileButton: Button
+ private lateinit var prescriptionButton: Button
+
+ @SuppressLint("MissingInflatedId")
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_homepage4doctor)
+
+ // Button initializations
+ patientListButton = findViewById(R.id.patientListButton)
+ settingsButton = findViewById(R.id.settingsButton3)
+ signOutButton = findViewById(R.id.signOutButton)
+ profileButton = findViewById(R.id.doctor_profile)
+ prescriptionButton = findViewById(R.id.prescriptionButton)
+
+ // Patient list button
+ patientListButton.setOnClickListener {
+ val medicalDiagnosticsActivityIntent =
+ Intent(this@Homepage4doctor, PatientListActivity::class.java)
+ medicalDiagnosticsActivityIntent.putExtra("userType", "doctor")
+ startActivity(medicalDiagnosticsActivityIntent)
+ }
+
+ // Settings button
+ settingsButton.setOnClickListener {
+ val medicalDiagnosticsActivityIntent =
+ Intent(this@Homepage4doctor, Setting::class.java)
+ medicalDiagnosticsActivityIntent.putExtra("userType", "doctor")
+ startActivity(medicalDiagnosticsActivityIntent)
+ }
+
+ // Sign out button
+ signOutButton.setOnClickListener {
+ EmailPasswordAuthService.signOut(this)
+ finish()
+ }
+
+ // Profile button
+ profileButton.setOnClickListener {
+ val medicalDiagnosticsActivityIntent =
+ Intent(this@Homepage4doctor, DoctorProfileActivity::class.java)
+ startActivity(medicalDiagnosticsActivityIntent)
+ }
+
+ // Prescription button
+ prescriptionButton.setOnClickListener {
+ val prescriptionIntent =
+ Intent(this@Homepage4doctor, PrescriptionActivity::class.java)
+ startActivity(prescriptionIntent)
+ }
+ }
+
+ @OptIn(UnstableApi::class)
+ fun startFallDetectionActivity() {
+ val fallDetectionActivityIntent =
+ Intent(this@Homepage4doctor, FallDetectionActivity::class.java)
+ startActivity(fallDetectionActivityIntent)
+ }
+}
diff --git a/app/src/main/java/deakin/gopher/guardian/view/general/MainActivity.kt b/app/src/main/java/deakin/gopher/guardian/view/general/MainActivity.kt
index 5304cba6..1e4af339 100644
--- a/app/src/main/java/deakin/gopher/guardian/view/general/MainActivity.kt
+++ b/app/src/main/java/deakin/gopher/guardian/view/general/MainActivity.kt
@@ -1,3 +1,60 @@
+// package deakin.gopher.guardian.view.general
+//
+// import android.content.Intent
+// import android.os.Bundle
+// import android.util.Log
+// import android.widget.Button
+// import com.google.android.gms.tasks.Task
+// import com.google.firebase.messaging.FirebaseMessaging
+// import deakin.gopher.guardian.R
+// import deakin.gopher.guardian.model.login.Role
+// import deakin.gopher.guardian.model.login.SessionManager
+//
+// class MainActivity : BaseActivity() {
+// override fun onCreate(savedInstanceState: Bundle?) {
+// super.onCreate(savedInstanceState)
+// setContentView(R.layout.activity_main)
+// val getStartedButton = findViewById