diff --git a/app/src/main/java/org/ole/planet/myplanet/model/RealmNotification.kt b/app/src/main/java/org/ole/planet/myplanet/model/RealmNotification.kt index 4e8f4c9585..bb061b6ad4 100644 --- a/app/src/main/java/org/ole/planet/myplanet/model/RealmNotification.kt +++ b/app/src/main/java/org/ole/planet/myplanet/model/RealmNotification.kt @@ -14,5 +14,4 @@ open class RealmNotification : RealmObject() { var createdAt: Date = Date() var type: String = "" var relatedId: String? = null - var lang: String? = null } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt index 2e7104abd4..854f542444 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt @@ -44,6 +44,7 @@ import kotlinx.coroutines.launch import org.json.JSONArray import org.ole.planet.myplanet.BuildConfig import org.ole.planet.myplanet.MainApplication +import org.ole.planet.myplanet.MainApplication.Companion.context import org.ole.planet.myplanet.R import org.ole.planet.myplanet.base.BaseContainerFragment import org.ole.planet.myplanet.base.BaseResourceFragment @@ -311,7 +312,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N val hasUnfinishedSurvey = mRealm.where(RealmStepExam::class.java) .equalTo("courseId", courseId) - .equalTo("type", "surveys") + .equalTo("type", "survey") .findAll() .any { survey -> !TakeCourseFragment.existsSubmission(mRealm, survey.id, "survey") } @@ -468,6 +469,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N val pendingSurveys = getPendingSurveys(user?.id) val surveyTitles = getSurveyTitlesFromSubmissions(pendingSurveys) + Log.d("noti","Found survey tiles : $surveyTitles") surveyTitles.forEach { title -> createNotificationIfNotExists("survey", "${getString(R.string.pending_survey_notification)} $title", title) } @@ -477,8 +479,9 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N .equalTo("completed", false) .equalTo("assignee", user?.id) .findAll() + tasks.forEach { task -> - createNotificationIfNotExists("task", "${task.title} is due in ${formatDate(task.deadline)}", task.id) + createNotificationIfNotExists("task", context.getString(R.string.task_notification, task.title, formatDate(task.deadline)), task.id) } val storageRatio = totalAvailableMemoryRatio @@ -487,7 +490,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N createNotificationIfNotExists("storage", "${getString(R.string.storage_critically_low)} $storageRatio% ${getString(R.string.available_please_free_up_space)}", "storage") } storageRatio <= 40 -> { - Log.d("lang", "lang is "+getString(R.string.storage_running_low)) + Log.d("noti", "lang is "+getString(R.string.storage_running_low)) createNotificationIfNotExists("storage", "${getString(R.string.storage_running_low)} $storageRatio% ${getString(R.string.available)}", "storage") } } @@ -532,17 +535,14 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N } private fun createNotificationIfNotExists(type: String, message: String, relatedId: String?) { - val currentLanguage = LocaleHelper.getLanguage(this) - val existingNotification = mRealm.where(RealmNotification::class.java) .equalTo("userId", user?.id) .equalTo("type", type) .equalTo("relatedId", relatedId) - .equalTo("lang", currentLanguage) .findFirst() if (existingNotification != null) { Log.d( - "lang", + "noti", "existing notification has ${existingNotification?.message} v/s ${message}" ) } @@ -555,7 +555,6 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N this.message = message this.relatedId = relatedId this.createdAt = Date() - this.lang= currentLanguage } } } @@ -571,8 +570,9 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N private fun getSurveyTitlesFromSubmissions(submissions: List): List { val titles = mutableListOf() submissions.forEach { submission -> + val examId = submission.parentId?.split("@")?.firstOrNull() ?: "" val exam = mRealm.where(RealmStepExam::class.java) - .equalTo("id", submission.parentId) + .equalTo("id", examId) .findFirst() exam?.name?.let { titles.add(it) } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/AdapterNotification.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/AdapterNotification.kt index 6c0388304a..483836cd61 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/AdapterNotification.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/AdapterNotification.kt @@ -1,5 +1,6 @@ package org.ole.planet.myplanet.ui.dashboard.notification +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -27,7 +28,14 @@ class AdapterNotification(var notificationList: List, private inner class ViewHolderNotifications(private val rowNotificationsBinding: RowNotificationsBinding) : RecyclerView.ViewHolder(rowNotificationsBinding.root) { fun bind(notification: RealmNotification, position: Int) { + Log.d("noti","current notification ${notification.type}") rowNotificationsBinding.title.text = notification.message + /* + * changes here gett the storage stuff and paste it herer + * types of notification types- resource, storage, survey, sync + * + * + * */ if (notification.isRead) { rowNotificationsBinding.btnMarkAsRead.visibility = View.GONE rowNotificationsBinding.root.alpha = 0.5f diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 900cff3b21..2cf7c40cfc 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -734,6 +734,7 @@ \nملاحظة: قد تحتاج لاستكمال تنزيل الموارد المضافة حديثًا. %s\nالفحص الذاتي لديك استطلاع قيد الانتظار: + %1$s مستحق في %2$s درجة الحرارة: %1$s\n النبض: %2$s\n diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index f1ef0de144..f6bf02ce71 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -734,6 +734,7 @@ \nNota: Es posible que aún necesites descargar los recursos recién agregados. %s\nAutoexamen tienes una encuesta pendiente: + %1$s vence el %2$s Temperatura: %1$s\n Pulso: %2$s\n diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 145d2582f8..ed88195a21 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -734,6 +734,7 @@ Note: Vous devrez peut-être toujours télécharger les nouvelles ressources ajoutées. %s\nAuto-examen vous avez une enquête en attente : + %1$s est dû le %2$s Température : %1$s\n Pouls : %2$s\n diff --git a/app/src/main/res/values-ne/strings.xml b/app/src/main/res/values-ne/strings.xml index d0d261b8f3..a4000d403e 100644 --- a/app/src/main/res/values-ne/strings.xml +++ b/app/src/main/res/values-ne/strings.xml @@ -734,6 +734,7 @@ \nनोट: तपाईंले अहिले थपिएका स्रोतहरू डाउनलोड गर्न अझै सक्छ। %s\nस्व-परिक्षण तपाईंको एउटा पेंडिङ सर्वेक्षण छ: + %1$s %2$s मा समाप्त हुन्छ तापमान: %1$s\n नाडी: %2$s\n diff --git a/app/src/main/res/values-so/strings.xml b/app/src/main/res/values-so/strings.xml index 5f13ad20da..95f03fd039 100644 --- a/app/src/main/res/values-so/strings.xml +++ b/app/src/main/res/values-so/strings.xml @@ -734,6 +734,7 @@ \nNote: Amaan waxaad u baahan tahay inaad ku diyaariyey khadkaan cusub ee la soo kiciyey. %s\nIs-imtixaanid waxaad leedahay su\'aal weydiin sugaya: + %1$s waa inuu dhamaadaa %2$s Heerkulka: %1$s\n Garaaca wadnaha: %2$s\n diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6e2c1def69..c55acf047a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -733,6 +733,7 @@ \nNote: You may still need to download the newly added resources. %s\nSelf Examination you have a pending survey: + %1$s is due in %2$s Temperature: %1$s\n Pulse: %2$s\n