Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FILE_PATHS
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_BREAKOUT_ROOM
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_MODERATOR
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_OPENED_VIA_NOTIFICATION
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_RECORDING_STATE
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_START_CALL_AFTER_ROOM_SWITCH
Expand Down Expand Up @@ -367,6 +368,7 @@ class ChatActivity :
var sessionIdAfterRoomJoined: String? = null
lateinit var roomToken: String
var conversationThreadId: Long? = null
var openedViaNotification: Boolean = false
var conversationThreadInfo: ThreadInfo? = null
var conversationUser: User? = null
lateinit var spreedCapabilities: SpreedCapability
Expand Down Expand Up @@ -409,12 +411,11 @@ class ChatActivity :

private val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
if (isChatThread()) {
if (!openedViaNotification && isChatThread()) {
isEnabled = false
onBackPressedDispatcher.onBackPressed()
} else {
val intent = Intent(this@ChatActivity, ConversationsListActivity::class.java)
intent.putExtras(Bundle())
startActivity(intent)
}
}
Expand Down Expand Up @@ -595,6 +596,8 @@ class ChatActivity :
null
}

openedViaNotification = extras?.getBoolean(KEY_OPENED_VIA_NOTIFICATION) ?: false

sharedText = extras?.getString(BundleKeys.KEY_SHARED_TEXT).orEmpty()

Log.d(TAG, " roomToken = $roomToken")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ONE_TO_ONE
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SHARE_RECORDING_TO_CHAT_URL
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SYSTEM_NOTIFICATION_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_THREAD_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_OPENED_VIA_NOTIFICATION
import com.nextcloud.talk.utils.preferences.AppPreferences
import io.reactivex.Observable
import io.reactivex.Observer
Expand Down Expand Up @@ -397,6 +399,10 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
val ncNotification = notificationOverall.ocs!!.notification
if (ncNotification != null) {
enrichPushMessageByNcNotificationData(ncNotification)

val threadId = parseThreadId(ncNotification.objectId)
threadId?.let { intent.putExtra(KEY_THREAD_ID, it) }

showNotification(intent, ncNotification)
}
}
Expand Down Expand Up @@ -827,6 +833,8 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
}
}

private fun parseThreadId(objectId: String?): Long? = objectId?.split("/")?.getOrNull(2)?.toLongOrNull()

private fun sendNotification(notificationId: Int, notification: Notification) {
Log.d(TAG, "show notification with id $notificationId")
if (ActivityCompat.checkSelfPermission(
Expand Down Expand Up @@ -982,6 +990,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
val bundle = Bundle()
bundle.putString(KEY_ROOM_TOKEN, pushMessage.id)
bundle.putLong(KEY_INTERNAL_USER_ID, signatureVerification.user!!.id!!)
bundle.putBoolean(KEY_OPENED_VIA_NOTIFICATION, true)
intent.putExtras(bundle)
return intent
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ object BundleKeys {
const val KEY_FOCUS_INPUT: String = "KEY_FOCUS_INPUT"
const val KEY_THREAD_ID = "KEY_THREAD_ID"
const val KEY_FROM_QR: String = "KEY_FROM_QR"
const val KEY_OPENED_VIA_NOTIFICATION: String = "KEY_OPENED_VIA_NOTIFICATION"
}
Loading