From 9a640a09a49066a8c0ed29c6b9238031ecc7ca63 Mon Sep 17 00:00:00 2001 From: deeppp15 Date: Tue, 17 Dec 2024 17:16:34 -0500 Subject: [PATCH] translated strings and lang check --- .../planet/myplanet/model/RealmNotification.kt | 1 + .../myplanet/ui/dashboard/DashboardActivity.kt | 16 +++++++++++++++- .../ui/dashboard/DashboardActivity.kt.lite | 16 +++++++++++++++- app/src/main/res/values-ar/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-ne/strings.xml | 1 + app/src/main/res/values-so/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 9 files changed, 37 insertions(+), 2 deletions(-) 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 bb061b6ad4..4e8f4c9585 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,4 +14,5 @@ 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 80d1e3d79d..2e7104abd4 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 @@ -10,6 +10,7 @@ import android.graphics.drawable.Drawable import android.os.Bundle import android.os.Handler import android.os.Looper +import android.util.Log import android.view.LayoutInflater import android.view.Menu import android.view.MenuItem @@ -17,6 +18,7 @@ import android.view.View import android.widget.TextView import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatDelegate +import androidx.core.content.ContentProviderCompat.requireContext import androidx.core.content.ContextCompat import androidx.core.content.res.ResourcesCompat import androidx.core.view.MenuItemCompat @@ -467,7 +469,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N val pendingSurveys = getPendingSurveys(user?.id) val surveyTitles = getSurveyTitlesFromSubmissions(pendingSurveys) surveyTitles.forEach { title -> - createNotificationIfNotExists("survey", "you have a pending survey: $title", title) + createNotificationIfNotExists("survey", "${getString(R.string.pending_survey_notification)} $title", title) } val tasks = mRealm.where(RealmTeamTask::class.java) @@ -485,6 +487,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)) createNotificationIfNotExists("storage", "${getString(R.string.storage_running_low)} $storageRatio% ${getString(R.string.available)}", "storage") } } @@ -529,11 +532,21 @@ 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", + "existing notification has ${existingNotification?.message} v/s ${message}" + ) + } + if (existingNotification == null) { mRealm.createObject(RealmNotification::class.java, "${UUID.randomUUID()}").apply { @@ -542,6 +555,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N this.message = message this.relatedId = relatedId this.createdAt = Date() + this.lang= currentLanguage } } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite index ff850517f4..4c603c0a54 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite @@ -10,6 +10,7 @@ import android.graphics.drawable.Drawable import android.os.Bundle import android.os.Handler import android.os.Looper +import android.util.Log import android.view.LayoutInflater import android.view.Menu import android.view.MenuItem @@ -17,6 +18,7 @@ import android.view.View import android.widget.TextView import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatDelegate +import androidx.core.content.ContentProviderCompat.requireContext import androidx.core.content.ContextCompat import androidx.core.content.res.ResourcesCompat import androidx.core.view.MenuItemCompat @@ -235,7 +237,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N Handler(Looper.getMainLooper()).postDelayed({ doubleBackToExitPressedOnce = false }, 2000) } else { // val fragment = supportFragmentManager.findFragmentById(R.id.fragment_container) -// if (fragment is BaseContainerFragment) { +// if (fragment is BaseContainerFragment) { // fragment.handleBackPressed() // } finish() @@ -485,6 +487,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)) createNotificationIfNotExists("storage", "${getString(R.string.storage_running_low)} $storageRatio% ${getString(R.string.available)}", "storage") } } @@ -529,11 +532,21 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N } private fun createNotificationIfNotExists(type: String, message: String, relatedId: String?) { + val currentLanguage = LocaleHelper.getLanguage(requireContext()) + 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", + "existing notification has ${existingNotification?.message} v/s ${message}" + ) + } + if (existingNotification == null) { mRealm.createObject(RealmNotification::class.java, "${UUID.randomUUID()}").apply { @@ -542,6 +555,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N this.message = message this.relatedId = relatedId this.createdAt = Date() + this.lang= currentLanguage } } } diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 405073d31a..900cff3b21 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -733,6 +733,7 @@ \n\nعودة إلى علامة التبويب الرئيسية للوصول إلى "مكتبتي".\n \nملاحظة: قد تحتاج لاستكمال تنزيل الموارد المضافة حديثًا. %s\nالفحص الذاتي + لديك استطلاع قيد الانتظار: درجة الحرارة: %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 23c877cb17..f1ef0de144 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -733,6 +733,7 @@ \n\nRegresa a la pestaña de Inicio para acceder a miBiblioteca.\n \nNota: Es posible que aún necesites descargar los recursos recién agregados. %s\nAutoexamen + tienes una encuesta pendiente: 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 045d857083..145d2582f8 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -733,6 +733,7 @@ Retournez à l\'onglet Accueil pour accéder à votre bibliothèque. Note: Vous devrez peut-être toujours télécharger les nouvelles ressources ajoutées. %s\nAuto-examen + vous avez une enquête en attente : 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 d9920520c4..d0d261b8f3 100644 --- a/app/src/main/res/values-ne/strings.xml +++ b/app/src/main/res/values-ne/strings.xml @@ -733,6 +733,7 @@ \n\nमेरो पुस्तकालयमा पहुँचका लागि होम ट्याबमा फर्कनुहोस्।\n \nनोट: तपाईंले अहिले थपिएका स्रोतहरू डाउनलोड गर्न अझै सक्छ। %s\nस्व-परिक्षण + तपाईंको एउटा पेंडिङ सर्वेक्षण छ: तापमान: %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 2f87ff661c..5f13ad20da 100644 --- a/app/src/main/res/values-so/strings.xml +++ b/app/src/main/res/values-so/strings.xml @@ -733,6 +733,7 @@ \n\nKu noqo tabka Home si aad uga heli karto maktabaddaaga.\n \nNote: Amaan waxaad u baahan tahay inaad ku diyaariyey khadkaan cusub ee la soo kiciyey. %s\nIs-imtixaanid + waxaad leedahay su\'aal weydiin sugaya: 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 c23eed13c0..6e2c1def69 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -732,6 +732,7 @@ \n\nReturn to the Home tab to access myLibrary.\n \nNote: You may still need to download the newly added resources. %s\nSelf Examination + you have a pending survey: Temperature: %1$s\n Pulse: %2$s\n