Skip to content

Commit

Permalink
Merge branch 'master' into 4944-headings-teams-enterprise
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Jan 6, 2025
2 parents 5a14b3c + f452edc commit a469adb
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class SettingActivity : AppCompatActivity() {
else -> 2
}

val builder = AlertDialog.Builder(context, R.style.CustomAlertDialogStyle)
val builder = AlertDialog.Builder(context, R.style.AlertDialogTheme)
.setTitle(context.getString(R.string.select_theme_mode))
.setSingleChoiceItems(ArrayAdapter(context, R.layout.checked_list_item, options), checkedItem) { dialog, which ->
val selectedMode = when (which) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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() {
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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() {
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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<RealmNotification>, private val onMarkAsReadClick: (Int) -> Unit, private val onNotificationClick: (RealmNotification) -> Unit) : RecyclerView.Adapter<AdapterNotification.ViewHolderNotifications>() {
class AdapterNotification(
var notificationList: List<RealmNotification>,
private val onMarkAsReadClick: (Int) -> Unit,
private val onNotificationClick: (RealmNotification) -> Unit
) : RecyclerView.Adapter<AdapterNotification.ViewHolderNotifications>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolderNotifications {
val rowNotificationsBinding = RowNotificationsBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolderNotifications(rowNotificationsBinding)
Expand All @@ -25,9 +32,14 @@ class AdapterNotification(var notificationList: List<RealmNotification>, 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
Expand All @@ -43,5 +55,38 @@ class AdapterNotification(var notificationList: List<RealmNotification>, 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"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ole.planet.myplanet.ui.viewer

import android.content.pm.ActivityInfo
import android.graphics.Bitmap
import android.net.Uri
import android.os.Build
Expand Down Expand Up @@ -27,7 +28,6 @@ class WebViewActivity : AppCompatActivity() {
val title: String? = intent.getStringExtra("title")
link = intent.getStringExtra("link") ?: ""
val resourceId = intent.getStringExtra("RESOURCE_ID")

clearCookie()
if (!TextUtils.isEmpty(title)) {
activityWebViewBinding.contentWebView.webTitle.text = title
Expand All @@ -43,6 +43,7 @@ class WebViewActivity : AppCompatActivity() {
val indexFile = File(directory, "index.html")

if (indexFile.exists()) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
activityWebViewBinding.contentWebView.wv.loadUrl("file://${indexFile.absolutePath}")
}
} else {
Expand Down
29 changes: 12 additions & 17 deletions app/src/main/res/layout/edit_profile_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,23 @@
android:layout_height="wrap_content"
android:layout_margin="@dimen/_10dp"
android:orientation="horizontal"
android:weightSum="3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lt1">

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ltEmail"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:layout_weight="1.2"
android:layout_marginEnd="4dp"
android:textColorHint="@color/hint_color"
app:boxBackgroundColor="@color/md_white_1000"
app:boxStrokeColor="@color/md_white_1000"
app:boxStrokeWidth="0dp"
app:boxStrokeWidthFocused="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/userProfile">
app:boxStrokeWidthFocused="0dp">

<EditText
android:id="@+id/email"
Expand All @@ -164,18 +163,16 @@

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ltPhoneNumber"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:layout_marginHorizontal="4dp"
android:textColorHint="@color/hint_color"
app:boxBackgroundColor="@color/md_white_1000"
app:boxStrokeColor="@color/md_white_1000"
app:boxStrokeWidth="0dp"
app:boxStrokeWidthFocused="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/userProfile">
app:boxStrokeWidthFocused="0dp">

<EditText
android:id="@+id/phoneNumber"
Expand All @@ -195,18 +192,16 @@

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ltInputName"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:layout_weight="0.8"
android:layout_marginStart="4dp"
app:boxBackgroundColor="@color/md_white_1000"
app:boxStrokeColor="@color/md_white_1000"
app:boxStrokeWidth="0dp"
app:boxStrokeWidthFocused="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ltNames">
app:boxStrokeWidthFocused="0dp">

<TextView
android:id="@+id/dateOfBirth"
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/fragment_finance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
<Button
android:id="@+id/btn_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:background="@color/mainColor"
android:layout_gravity="left"
android:padding="@dimen/padding_normal"
android:text="@string/date_reset"
android:textColor="@android:color/white"
android:textSize="18sp"
android:theme="@style/GuestStyle" />
</LinearLayout>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@
<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="task_notification">%1$s مستحق في %2$s</string>
<string name="resource_notification">لديك %1$d موارد لم يتم تنزيلها</string>
<string name="vitals_format">
درجة الحرارة: %1$s\n
النبض: %2$s\n
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@
<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="task_notification">%1$s vence el %2$s</string>
<string name="resource_notification">Tienes %1$d recursos no descargados</string>
<string name="vitals_format">
Temperatura: %1$s\n
Pulso: %2$s\n
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@
<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="task_notification">%1$s est dû le %2$s</string>
<string name="resource_notification">Vous avez %1$d ressources non téléchargées</string>
<string name="vitals_format">
Température : %1$s\n
Pouls : %2$s\n
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-ne/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@
<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="task_notification">%1$s %2$s मा समाप्त हुन्छ</string>
<string name="resource_notification">तपाईंसँग %1$d स्रोतहरू डाउनलोड गरिएको छैन</string>
<string name="vitals_format">
तापमान: %1$s\n
नाडी: %2$s\n
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-so/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@
<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="task_notification">%1$s waa inuu dhamaadaa %2$s</string>
<string name="resource_notification">Waxaad haysataa %1$d agab aan la soo dejisan</string>
<string name="vitals_format">
Heerkulka: %1$s\n
Garaaca wadnaha: %2$s\n
Expand Down
Loading

0 comments on commit a469adb

Please sign in to comment.