Skip to content

Commit

Permalink
translated strings and lang check
Browse files Browse the repository at this point in the history
  • Loading branch information
deeppp15 committed Dec 17, 2024
1 parent d23d288 commit 9a640a0
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ open class RealmNotification : RealmObject() {
var createdAt: Date = Date()
var type: String = ""
var relatedId: String? = null
var lang: String? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ 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
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
Expand Down Expand Up @@ -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)
Expand All @@ -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")
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -542,6 +555,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
this.message = message
this.relatedId = relatedId
this.createdAt = Date()
this.lang= currentLanguage
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ 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
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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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")
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -542,6 +555,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
this.message = message
this.relatedId = relatedId
this.createdAt = Date()
this.lang= currentLanguage
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@
<string name="return_to_the_home_tab_to_access_mylibrary">\n\nعودة إلى علامة التبويب الرئيسية للوصول إلى "مكتبتي".\n</string>
<string name="note_you_may_still_need_to_download_the_newly_added_resources">\nملاحظة: قد تحتاج لاستكمال تنزيل الموارد المضافة حديثًا.</string>
<string name="self_examination">%s\nالفحص الذاتي</string>
<string name="pending_survey_notification">لديك استطلاع قيد الانتظار:</string>
<string name="vitals_format">
درجة الحرارة: %1$s\n
النبض: %2$s\n
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@
<string name="return_to_the_home_tab_to_access_mylibrary">\n\nRegresa a la pestaña de Inicio para acceder a miBiblioteca.\n</string>
<string name="note_you_may_still_need_to_download_the_newly_added_resources">\nNota: Es posible que aún necesites descargar los recursos recién agregados.</string>
<string name="self_examination">%s\nAutoexamen</string>
<string name="pending_survey_notification">tienes una encuesta pendiente:</string>
<string name="vitals_format">
Temperatura: %1$s\n
Pulso: %2$s\n
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@
<string name="return_to_the_home_tab_to_access_mylibrary">Retournez à l\'onglet Accueil pour accéder à votre bibliothèque.</string>
<string name="note_you_may_still_need_to_download_the_newly_added_resources">Note: Vous devrez peut-être toujours télécharger les nouvelles ressources ajoutées.</string>
<string name="self_examination">%s\nAuto-examen</string>
<string name="pending_survey_notification">vous avez une enquête en attente :</string>
<string name="vitals_format">
Température : %1$s\n
Pouls : %2$s\n
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ne/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@
<string name="return_to_the_home_tab_to_access_mylibrary">\n\nमेरो पुस्तकालयमा पहुँचका लागि होम ट्याबमा फर्कनुहोस्।\n</string>
<string name="note_you_may_still_need_to_download_the_newly_added_resources">\nनोट: तपाईंले अहिले थपिएका स्रोतहरू डाउनलोड गर्न अझै सक्छ।</string>
<string name="self_examination">%s\nस्व-परिक्षण</string>
<string name="pending_survey_notification">तपाईंको एउटा पेंडिङ सर्वेक्षण छ:</string>
<string name="vitals_format">
तापमान: %1$s\n
नाडी: %2$s\n
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-so/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@
<string name="return_to_the_home_tab_to_access_mylibrary">\n\nKu noqo tabka Home si aad uga heli karto maktabaddaaga.\n</string>
<string name="note_you_may_still_need_to_download_the_newly_added_resources">\nNote: Amaan waxaad u baahan tahay inaad ku diyaariyey khadkaan cusub ee la soo kiciyey.</string>
<string name="self_examination">%s\nIs-imtixaanid</string>
<string name="pending_survey_notification">waxaad leedahay su\'aal weydiin sugaya:</string>
<string name="vitals_format">
Heerkulka: %1$s\n
Garaaca wadnaha: %2$s\n
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@
<string name="return_to_the_home_tab_to_access_mylibrary">\n\nReturn to the Home tab to access myLibrary.\n</string>
<string name="note_you_may_still_need_to_download_the_newly_added_resources">\nNote: You may still need to download the newly added resources.</string>
<string name="self_examination">%s\nSelf Examination</string>
<string name="pending_survey_notification">you have a pending survey:</string>
<string name="vitals_format">
Temperature: %1$s\n
Pulse: %2$s\n
Expand Down

0 comments on commit 9a640a0

Please sign in to comment.