From 487aa2a08e546f58b1f43b64dc999c619254412b Mon Sep 17 00:00:00 2001 From: Alejandro Date: Thu, 4 Jan 2024 13:39:55 -0300 Subject: [PATCH 1/3] Add format storage value --- .../sphinx/wrapper_common/StoragePercentage.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sphinx/application/common/wrappers/wrapper-common/src/main/java/chat/sphinx/wrapper_common/StoragePercentage.kt b/sphinx/application/common/wrappers/wrapper-common/src/main/java/chat/sphinx/wrapper_common/StoragePercentage.kt index 64d5b85a9c..67cb144249 100644 --- a/sphinx/application/common/wrappers/wrapper-common/src/main/java/chat/sphinx/wrapper_common/StoragePercentage.kt +++ b/sphinx/application/common/wrappers/wrapper-common/src/main/java/chat/sphinx/wrapper_common/StoragePercentage.kt @@ -7,12 +7,18 @@ fun calculateStoragePercentage(storageData: StorageData): StoragePercentage { storageData.video.totalSize.value + storageData.audio.totalSize.value + storageData.files.totalSize.value + // Helper function to format the storage value + fun formatStorageValue(value: Long): Float { + val formattedString = value.toString().replace(",", "") + return String.format("%.3f", formattedString.toFloat() / totalStorage).toFloat() + } + return StoragePercentage( - freeStorage = String.format("%.3f", freeStorage.toFloat() / totalStorage).toFloat(), - image = String.format("%.3f", storageData.images.totalSize.value.toFloat() / totalStorage).toFloat(), - video = String.format("%.3f", storageData.video.totalSize.value.toFloat() / totalStorage).toFloat(), - audio = String.format("%.3f", storageData.audio.totalSize.value.toFloat() / totalStorage).toFloat(), - files = String.format("%.3f", storageData.files.totalSize.value.toFloat() / totalStorage).toFloat() + freeStorage = formatStorageValue(freeStorage), + image = formatStorageValue(storageData.images.totalSize.value), + video = formatStorageValue(storageData.video.totalSize.value), + audio = formatStorageValue(storageData.audio.totalSize.value), + files = formatStorageValue(storageData.files.totalSize.value) ) } From 4193fd9c7b2565603e139b07d790994a9bc4da34 Mon Sep 17 00:00:00 2001 From: Tomas Timinskas Date: Fri, 5 Jan 2024 11:16:07 -0300 Subject: [PATCH 2/3] Fix for crash on calculate storage --- .../sphinx/wrapper_common/StoragePercentage.kt | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/sphinx/application/common/wrappers/wrapper-common/src/main/java/chat/sphinx/wrapper_common/StoragePercentage.kt b/sphinx/application/common/wrappers/wrapper-common/src/main/java/chat/sphinx/wrapper_common/StoragePercentage.kt index 67cb144249..81bab0011e 100644 --- a/sphinx/application/common/wrappers/wrapper-common/src/main/java/chat/sphinx/wrapper_common/StoragePercentage.kt +++ b/sphinx/application/common/wrappers/wrapper-common/src/main/java/chat/sphinx/wrapper_common/StoragePercentage.kt @@ -1,5 +1,7 @@ package chat.sphinx.wrapper_common +import java.util.Locale + fun calculateStoragePercentage(storageData: StorageData): StoragePercentage { val freeStorage = storageData.freeStorage?.value ?: 0L @@ -7,18 +9,12 @@ fun calculateStoragePercentage(storageData: StorageData): StoragePercentage { storageData.video.totalSize.value + storageData.audio.totalSize.value + storageData.files.totalSize.value - // Helper function to format the storage value - fun formatStorageValue(value: Long): Float { - val formattedString = value.toString().replace(",", "") - return String.format("%.3f", formattedString.toFloat() / totalStorage).toFloat() - } - return StoragePercentage( - freeStorage = formatStorageValue(freeStorage), - image = formatStorageValue(storageData.images.totalSize.value), - video = formatStorageValue(storageData.video.totalSize.value), - audio = formatStorageValue(storageData.audio.totalSize.value), - files = formatStorageValue(storageData.files.totalSize.value) + freeStorage = String.format(Locale.ENGLISH, "%.3f", freeStorage.toFloat() / totalStorage).toFloat(), + image = String.format(Locale.ENGLISH, "%.3f", storageData.images.totalSize.value.toFloat() / totalStorage).toFloat(), + video = String.format(Locale.ENGLISH, "%.3f", storageData.video.totalSize.value.toFloat() / totalStorage).toFloat(), + audio = String.format(Locale.ENGLISH, "%.3f", storageData.audio.totalSize.value.toFloat() / totalStorage).toFloat(), + files = String.format(Locale.ENGLISH, "%.3f", storageData.files.totalSize.value.toFloat() / totalStorage).toFloat() ) } From c8f4845497742cc3f47f10426ad3454f7eb150ea Mon Sep 17 00:00:00 2001 From: Tomas Timinskas Date: Fri, 5 Jan 2024 12:04:39 -0300 Subject: [PATCH 3/3] Fix on push notification title --- .../SphinxFirebaseMessagingService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/service/features/notifications/feature-service-notification-firebase/src/main/java/chat/sphinx/feature_service_notification_firebase/SphinxFirebaseMessagingService.kt b/sphinx/service/features/notifications/feature-service-notification-firebase/src/main/java/chat/sphinx/feature_service_notification_firebase/SphinxFirebaseMessagingService.kt index 596a7fee7e..51e8b4d1a2 100644 --- a/sphinx/service/features/notifications/feature-service-notification-firebase/src/main/java/chat/sphinx/feature_service_notification_firebase/SphinxFirebaseMessagingService.kt +++ b/sphinx/service/features/notifications/feature-service-notification-firebase/src/main/java/chat/sphinx/feature_service_notification_firebase/SphinxFirebaseMessagingService.kt @@ -59,7 +59,7 @@ internal class SphinxFirebaseMessagingService: FirebaseMessagingService() { // Extract data from the message // Extract data from the message - val title: String = p0.data["message"] ?: "" + val title: String = p0.data["title"] ?: "" val messageBody: String = p0.data["body"] ?: "" val chatId: Long? = (p0.data["chat_id"] ?: "").toLongOrNull()