diff --git a/app/src/gplay/java/com/nextcloud/talk/services/firebase/NCFirebaseMessagingService.kt b/app/src/gplay/java/com/nextcloud/talk/services/firebase/NCFirebaseMessagingService.kt index e36c67fd3..04f61b052 100644 --- a/app/src/gplay/java/com/nextcloud/talk/services/firebase/NCFirebaseMessagingService.kt +++ b/app/src/gplay/java/com/nextcloud/talk/services/firebase/NCFirebaseMessagingService.kt @@ -65,7 +65,6 @@ class NCFirebaseMessagingService : FirebaseMessagingService() { val messageData = Data.Builder() .putString(BundleKeys.KEY_NOTIFICATION_SUBJECT, subject) .putString(BundleKeys.KEY_NOTIFICATION_SIGNATURE, signature) - .putLong(BundleKeys.KEY_NOTIFICATION_SENT_TIME, remoteMessage.sentTime) .build() val notificationWork = OneTimeWorkRequest.Builder(NotificationWorker::class.java).setInputData(messageData) diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt index 8d8e3995e..7cacd379e 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt @@ -53,7 +53,6 @@ import androidx.work.Worker import androidx.work.WorkerParameters import autodagger.AutoInjector import com.bluelinelabs.logansquare.LoganSquare -import com.nextcloud.talk.BuildConfig import com.nextcloud.talk.R import com.nextcloud.talk.activities.CallNotificationActivity import com.nextcloud.talk.activities.MainActivity @@ -136,14 +135,12 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor private var conversationType: String? = "one2one" private var muteCall = false private var importantConversation = false - private var deliveryDelayTime: Long = 0 private lateinit var notificationManager: NotificationManagerCompat override fun doWork(): Result { sharedApplication!!.componentApplication.inject(this) context = applicationContext - calculateDeliveryDelayTime(inputData) initDecryptedData(inputData) initNcApiAndCredentials() @@ -247,9 +244,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor .setSubText(baseUrl) .setShowWhen(true) .setWhen(pushMessage.timestamp) - .setContentTitle( - EmojiCompat.get().process(pushMessage.subject + getDeliveryDelayTimeForDebug()) - ) + .setContentTitle(EmojiCompat.get().process(pushMessage.subject)) .setAutoCancel(true) .setOngoing(true) .setContentIntent(fullScreenPendingIntent) @@ -263,20 +258,6 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor checkIfCallIsActive(signatureVerification, pushMessage) } - /** - * Calculates the time between the sent time (from firebase) and the received time on the device. - * 'deliveryDelayTime' is displayed in debug mode right after the notification message. - * A huge delay means that there might be something wrong on device side. - */ - private fun calculateDeliveryDelayTime(inputData: Data) { - val messageSentTime = inputData.getLong(BundleKeys.KEY_NOTIFICATION_SENT_TIME, 0) - deliveryDelayTime = if (messageSentTime == 0L) { - 0 - } else { - System.currentTimeMillis() - messageSentTime - } - } - private fun initNcApiAndCredentials() { credentials = ApiUtils.getCredentials( signatureVerification.user!!.username, @@ -456,12 +437,12 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor .setAutoCancel(true) if (!TextUtils.isEmpty(pushMessage.subject)) { notificationBuilder.setContentTitle( - EmojiCompat.get().process(pushMessage.subject + getDeliveryDelayTimeForDebug()) + EmojiCompat.get().process(pushMessage.subject) ) } if (!TextUtils.isEmpty(pushMessage.text)) { notificationBuilder.setContentText( - EmojiCompat.get().process(pushMessage.text!! + getDeliveryDelayTimeForDebug()) + EmojiCompat.get().process(pushMessage.text!!) ) } if (Build.VERSION.SDK_INT >= 23) { @@ -625,17 +606,10 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor ) } ) - newStyle.addMessage(pushMessage.text + getDeliveryDelayTimeForDebug(), pushMessage.timestamp, person) + newStyle.addMessage(pushMessage.text, pushMessage.timestamp, person) return newStyle } - private fun getDeliveryDelayTimeForDebug(): String { - if (BuildConfig.DEBUG) { - return " ($deliveryDelayTime ms delay)" - } - return "" - } - @Throws(NumberFormatException::class) private fun parseMessageId(objectId: String): Int { val objectIdParts = objectId.split("/".toRegex()).toTypedArray() @@ -801,7 +775,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor String.format( context!!.resources.getString(R.string.nc_missed_call), currentConversation!!.displayName - ) + getDeliveryDelayTimeForDebug() + ) ) .setSmallIcon(R.drawable.ic_baseline_phone_missed_24) .setOngoing(false) diff --git a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt index 4bf5ed90e..82db195ed 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt @@ -48,7 +48,6 @@ object BundleKeys { const val KEY_MODIFIED_BASE_URL = "KEY_MODIFIED_BASE_URL" const val KEY_NOTIFICATION_SUBJECT = "KEY_NOTIFICATION_SUBJECT" const val KEY_NOTIFICATION_SIGNATURE = "KEY_NOTIFICATION_SIGNATURE" - const val KEY_NOTIFICATION_SENT_TIME = "KEY_NOTIFICATION_SENT_TIME" const val KEY_INTERNAL_USER_ID = "KEY_INTERNAL_USER_ID" const val KEY_CONVERSATION_TYPE = "KEY_CONVERSATION_TYPE" const val KEY_INVITED_PARTICIPANTS = "KEY_INVITED_PARTICIPANTS"