From 938917a45a6e58fd14c09bcf7404b8a86086b8a0 Mon Sep 17 00:00:00 2001 From: Deep Vora <70479785+deeppp15@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:31:55 -0500 Subject: [PATCH 1/5] dashboard: smoother notifications translations (fixes #4853) (#4890) Co-authored-by: dogi --- app/build.gradle | 4 +- .../ui/dashboard/DashboardActivity.kt | 21 +++----- .../ui/dashboard/DashboardActivity.kt.lite | 21 +++----- .../notification/AdapterNotification.kt | 51 +++++++++++++++++-- app/src/main/res/values-ar/strings.xml | 3 ++ app/src/main/res/values-es/strings.xml | 3 ++ app/src/main/res/values-fr/strings.xml | 3 ++ app/src/main/res/values-ne/strings.xml | 3 ++ app/src/main/res/values-so/strings.xml | 3 ++ app/src/main/res/values/strings.xml | 3 ++ 10 files changed, 82 insertions(+), 33 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3a349ba87d..758676eb59 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 26 targetSdkVersion 34 - versionCode 2162 - versionName "0.21.62" + versionCode 2163 + versionName "0.21.63" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true 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 386878e70a..038a8af780 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 @@ -161,8 +161,8 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N createDrawer() if (!(user?.id?.startsWith("guest") == true && profileDbHandler.offlineVisits >= 3) && resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { result?.openDrawer() - } //Opens drawer by default - result?.stickyFooter?.setPadding(0, 0, 0, 0) // moves logout button to the very bottom of the drawer. Without it, the "logout" button suspends a little. + } + result?.stickyFooter?.setPadding(0, 0, 0, 0) result?.actionBarDrawerToggle?.isDrawerIndicatorEnabled = true dl = result?.drawerLayout topbarSetting() @@ -469,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", "$title", title) } val tasks = mRealm.where(RealmTeamTask::class.java) @@ -478,18 +478,11 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N .equalTo("assignee", user?.id) .findAll() tasks.forEach { task -> - createNotificationIfNotExists("task", "${task.title} is due in ${formatDate(task.deadline)}", task.id) + createNotificationIfNotExists("task","${task.title} ${formatDate(task.deadline)}", task.id) } val storageRatio = totalAvailableMemoryRatio - when { - storageRatio <= 10 -> { - createNotificationIfNotExists("storage", "${getString(R.string.storage_critically_low)} $storageRatio% ${getString(R.string.available_please_free_up_space)}", "storage") - } - storageRatio <= 40 -> { - createNotificationIfNotExists("storage", "${getString(R.string.storage_running_low)} $storageRatio% ${getString(R.string.available)}", "storage") - } - } + createNotificationIfNotExists("storage", "$storageRatio" , "storage") } private fun updateResourceNotification() { @@ -501,10 +494,10 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N .findFirst() if (existingNotification != null) { - existingNotification.message = "you have $resourceCount resources not downloaded" + existingNotification.message = "$resourceCount" existingNotification.relatedId = "$resourceCount" } else { - createNotificationIfNotExists("resource", "you have $resourceCount resources not downloaded", "$resourceCount") + createNotificationIfNotExists("resource", "$resourceCount", "$resourceCount") } } else { mRealm.where(RealmNotification::class.java) 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 0afa9e382e..1cfba01bbd 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 @@ -161,8 +161,8 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N createDrawer() if (!(user?.id?.startsWith("guest") == true && profileDbHandler.offlineVisits >= 3) && resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { result?.openDrawer() - } //Opens drawer by default - result?.stickyFooter?.setPadding(0, 0, 0, 0) // moves logout button to the very bottom of the drawer. Without it, the "logout" button suspends a little. + } + result?.stickyFooter?.setPadding(0, 0, 0, 0) result?.actionBarDrawerToggle?.isDrawerIndicatorEnabled = true dl = result?.drawerLayout topbarSetting() @@ -469,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", "$title", title) } val tasks = mRealm.where(RealmTeamTask::class.java) @@ -478,18 +478,11 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N .equalTo("assignee", user?.id) .findAll() tasks.forEach { task -> - createNotificationIfNotExists("task", "${task.title} is due in ${formatDate(task.deadline)}", task.id) + createNotificationIfNotExists("task","${task.title} ${formatDate(task.deadline)}", task.id) } val storageRatio = totalAvailableMemoryRatio - when { - storageRatio <= 10 -> { - createNotificationIfNotExists("storage", "${getString(R.string.storage_critically_low)} $storageRatio% ${getString(R.string.available_please_free_up_space)}", "storage") - } - storageRatio <= 40 -> { - createNotificationIfNotExists("storage", "${getString(R.string.storage_running_low)} $storageRatio% ${getString(R.string.available)}", "storage") - } - } + createNotificationIfNotExists("storage", "$storageRatio" , "storage") } private fun updateResourceNotification() { @@ -501,10 +494,10 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N .findFirst() if (existingNotification != null) { - existingNotification.message = "you have $resourceCount resources not downloaded" + existingNotification.message = "$resourceCount" existingNotification.relatedId = "$resourceCount" } else { - createNotificationIfNotExists("resource", "you have $resourceCount resources not downloaded", "$resourceCount") + createNotificationIfNotExists("resource", "$resourceCount", "$resourceCount") } } else { mRealm.where(RealmNotification::class.java) 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..9421f38dfb 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,13 +1,20 @@ package org.ole.planet.myplanet.ui.dashboard.notification +import android.content.Context import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView +import org.ole.planet.myplanet.R import org.ole.planet.myplanet.databinding.RowNotificationsBinding import org.ole.planet.myplanet.model.RealmNotification -class AdapterNotification(var notificationList: List, private val onMarkAsReadClick: (Int) -> Unit, private val onNotificationClick: (RealmNotification) -> Unit) : RecyclerView.Adapter() { +class AdapterNotification( + var notificationList: List, + private val onMarkAsReadClick: (Int) -> Unit, + private val onNotificationClick: (RealmNotification) -> Unit +) : RecyclerView.Adapter() { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolderNotifications { val rowNotificationsBinding = RowNotificationsBinding.inflate(LayoutInflater.from(parent.context), parent, false) return ViewHolderNotifications(rowNotificationsBinding) @@ -25,9 +32,14 @@ class AdapterNotification(var notificationList: List, private notifyDataSetChanged() } - inner class ViewHolderNotifications(private val rowNotificationsBinding: RowNotificationsBinding) : RecyclerView.ViewHolder(rowNotificationsBinding.root) { + inner class ViewHolderNotifications(private val rowNotificationsBinding: RowNotificationsBinding) : + RecyclerView.ViewHolder(rowNotificationsBinding.root) { + fun bind(notification: RealmNotification, position: Int) { - rowNotificationsBinding.title.text = notification.message + val context = rowNotificationsBinding.root.context + val currentNotification = formatNotificationMessage(notification, context) + rowNotificationsBinding.title.text = currentNotification + if (notification.isRead) { rowNotificationsBinding.btnMarkAsRead.visibility = View.GONE rowNotificationsBinding.root.alpha = 0.5f @@ -43,5 +55,38 @@ class AdapterNotification(var notificationList: List, private onNotificationClick(notification) } } + + private fun formatNotificationMessage(notification: RealmNotification, context: Context): String { + return when (notification.type.lowercase()) { + "survey" -> context.getString(R.string.pending_survey_notification) + " ${notification.message}" + "task" -> { + val parts = notification.message.split(" ") + if (parts.size >= 2) { + val taskTitle = parts[0] + val dateValue = parts.subList(1, parts.size).joinToString(" ") + context.getString(R.string.task_notification, taskTitle, dateValue) + } else { + "INVALID" + } + } + "resource" -> { + val resourceCount = notification.message.toIntOrNull() + resourceCount?.let { + context.getString(R.string.resource_notification, it) + } ?: "INVALID" + } + "storage" -> { + val storageValue = notification.message.toIntOrNull() + storageValue?.let { + when { + it <= 10 -> context.getString(R.string.storage_running_low) +" ${it}%" + it <= 40 -> context.getString(R.string.storage_running_low)+ " ${it}%" + else -> "INVALID" + } + } ?: "INVALID" + } + else -> "INVALID" + } + } } } diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index d7d41de74f..2a3b5eea2b 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -744,6 +744,9 @@ \n\nعودة إلى علامة التبويب الرئيسية للوصول إلى "مكتبتي".\n \nملاحظة: قد تحتاج لاستكمال تنزيل الموارد المضافة حديثًا. %s\nالفحص الذاتي + لديك استطلاع قيد الانتظار: + %1$s مستحق في %2$s + لديك %1$d موارد لم يتم تنزيلها درجة الحرارة: %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 12a370c719..9b2cc819ac 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -744,6 +744,9 @@ \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: + %1$s vence el %2$s + Tienes %1$d recursos no descargados 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 1ce823ec45..0efd6a03ee 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -744,6 +744,9 @@ 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 : + %1$s est dû le %2$s + Vous avez %1$d ressources non téléchargées 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 ee8d1f5da4..2a65bedbd0 100644 --- a/app/src/main/res/values-ne/strings.xml +++ b/app/src/main/res/values-ne/strings.xml @@ -744,6 +744,9 @@ \n\nमेरो पुस्तकालयमा पहुँचका लागि होम ट्याबमा फर्कनुहोस्।\n \nनोट: तपाईंले अहिले थपिएका स्रोतहरू डाउनलोड गर्न अझै सक्छ। %s\nस्व-परिक्षण + तपाईंको एउटा पेंडिङ सर्वेक्षण छ: + %1$s %2$s मा समाप्त हुन्छ + तपाईंसँग %1$d स्रोतहरू डाउनलोड गरिएको छैन तापमान: %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 e7d154d6ae..813199cd8e 100644 --- a/app/src/main/res/values-so/strings.xml +++ b/app/src/main/res/values-so/strings.xml @@ -744,6 +744,9 @@ \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: + %1$s waa inuu dhamaadaa %2$s + Waxaad haysataa %1$d agab aan la soo dejisan 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 68c251b4b4..a13d1b6193 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -744,6 +744,9 @@ \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: + %1$s is due in %2$s + You have %1$d resources not downloaded Temperature: %1$s\n Pulse: %2$s\n From bf70e0657b931543c3b62a194d17c168cee7d319 Mon Sep 17 00:00:00 2001 From: Avinash Sharma <133222313+Avinash-Codes@users.noreply.github.com> Date: Tue, 7 Jan 2025 00:07:40 +0530 Subject: [PATCH 2/5] teams: smoother finances button color (fixes #4934) (#4936) Co-authored-by: dogi --- app/build.gradle | 4 ++-- app/src/main/res/layout/fragment_finance.xml | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 758676eb59..b5026d8e7a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 26 targetSdkVersion 34 - versionCode 2163 - versionName "0.21.63" + versionCode 2164 + versionName "0.21.64" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/res/layout/fragment_finance.xml b/app/src/main/res/layout/fragment_finance.xml index 188c639ad7..b95c5ad3e5 100644 --- a/app/src/main/res/layout/fragment_finance.xml +++ b/app/src/main/res/layout/fragment_finance.xml @@ -22,18 +22,25 @@ android:id="@+id/btn_filter" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:background="@color/mainColor" android:layout_gravity="left" android:padding="@dimen/padding_normal" android:text="@string/filter_by_date" + android:textColor="@android:color/white" android:textSize="18sp" android:theme="@style/GuestStyle" />