mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 20:19:42 +01:00
WIP. open chat when share recording to chat (fails atm)
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
36de155c44
commit
ed96d53049
@ -691,6 +691,8 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
||||
val shareRecordingIntent = Intent(context, ShareRecordingToChatReceiver::class.java)
|
||||
shareRecordingIntent.putExtra(KEY_SYSTEM_NOTIFICATION_ID, systemNotificationId)
|
||||
shareRecordingIntent.putExtra(KEY_SHARE_RECORDING_TO_CHAT_URL, shareToChatUrl)
|
||||
shareRecordingIntent.putExtra(KEY_ROOM_TOKEN, pushMessage.id)
|
||||
shareRecordingIntent.putExtra(KEY_USER_ENTITY, signatureVerification.user)
|
||||
|
||||
val intentFlag: Int = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
|
@ -24,8 +24,10 @@ import android.app.NotificationManager
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import autodagger.AutoInjector
|
||||
import com.nextcloud.talk.activities.MainActivity
|
||||
import com.nextcloud.talk.api.NcApi
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
@ -54,6 +56,8 @@ class ShareRecordingToChatReceiver : BroadcastReceiver() {
|
||||
lateinit var currentUser: User
|
||||
private var systemNotificationId: Int? = null
|
||||
private var link: String? = null
|
||||
var roomToken: String? = null
|
||||
var conversationOfShareTarget: User? = null
|
||||
|
||||
init {
|
||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||
@ -67,6 +71,9 @@ class ShareRecordingToChatReceiver : BroadcastReceiver() {
|
||||
systemNotificationId = intent!!.getIntExtra(KEY_SYSTEM_NOTIFICATION_ID, 0)
|
||||
link = intent.getStringExtra(BundleKeys.KEY_SHARE_RECORDING_TO_CHAT_URL)
|
||||
|
||||
roomToken = intent.getStringExtra(BundleKeys.KEY_ROOM_TOKEN)
|
||||
conversationOfShareTarget = intent.getParcelableExtra<User>(BundleKeys.KEY_USER_ENTITY)
|
||||
|
||||
val id = intent.getLongExtra(KEY_INTERNAL_USER_ID, userManager.currentUser.blockingGet().id!!)
|
||||
currentUser = userManager.getUserWithId(id).blockingGet()
|
||||
|
||||
@ -86,6 +93,7 @@ class ShareRecordingToChatReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onNext(genericOverall: GenericOverall) {
|
||||
cancelNotification(systemNotificationId!!)
|
||||
context.startActivity(createOpenChatIntent())
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
@ -98,6 +106,21 @@ class ShareRecordingToChatReceiver : BroadcastReceiver() {
|
||||
})
|
||||
}
|
||||
|
||||
private fun createOpenChatIntent(): Intent {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
// intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
intent.addFlags(
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
)
|
||||
|
||||
val bundle = Bundle()
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken)
|
||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, conversationOfShareTarget)
|
||||
bundle.putBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)
|
||||
intent.putExtras(bundle)
|
||||
return intent
|
||||
}
|
||||
|
||||
private fun cancelNotification(notificationId: Int) {
|
||||
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.cancel(notificationId)
|
||||
|
Loading…
Reference in New Issue
Block a user