Skip to content

Commit

Permalink
WIP Got it working
Browse files Browse the repository at this point in the history
Signed-off-by: rapterjet2004 <[email protected]>
  • Loading branch information
rapterjet2004 committed Oct 20, 2023
1 parent a30d5cb commit 4516b33
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
android:exported="true"
android:windowSoftInputMode="adjustResize"
android:allowEmbedded="true"
android:resizeableActivity="true">
android:resizeableActivity="true"
android:documentLaunchMode="always">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down Expand Up @@ -225,8 +226,7 @@
<activity
android:name=".chat.ChatActivity"
android:theme="@style/AppTheme"
android:allowEmbedded="true"
android:resizeableActivity="true"/>
/>

<activity
android:name=".openconversations.ListOpenConversationsActivity"
Expand Down
41 changes: 22 additions & 19 deletions app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ import androidx.core.app.NotificationManagerCompat
import androidx.core.app.Person
import androidx.core.app.RemoteInput
import androidx.core.content.ContextCompat
import androidx.core.content.LocusIdCompat
import androidx.core.content.pm.ShortcutInfoCompat
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.graphics.drawable.IconCompat
import androidx.core.graphics.drawable.toBitmap
import androidx.emoji2.text.EmojiCompat
Expand Down Expand Up @@ -440,7 +442,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor

val autoCancelOnClick = TYPE_RECORDING != pushMessage.type

val notificationBuilder = NotificationCompat.Builder(context!!, "1")
val notificationBuilder = NotificationCompat.Builder(context!!, "4")
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(category)
.setLargeIcon(getLargeIcon())
Expand Down Expand Up @@ -563,7 +565,8 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
val person = Person.Builder()
.setKey(signatureVerification.user!!.id.toString() + "@" + notificationUser.id)
.setName(EmojiCompat.get().process(notificationUser.name!!))
.setBot("bot" == userType)
.setImportant(true)
.setBot(true)
notificationBuilder.setOnlyAlertOnce(true)

if ("user" == userType || "guest" == userType) {
Expand Down Expand Up @@ -632,28 +635,27 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
private fun setBubble(notificationBuilder: NotificationCompat.Builder) {
val intent = getIntentToOpenConversation()

val shortcutId = "1_2_3"
val shortcut =
ShortcutInfoCompat.Builder(context!!, shortcutId)
.setCategories(setOf(Notification.CATEGORY_CALL)) // this function is only called for messages
.setIntent(Intent(Intent.ACTION_DEFAULT))
.setLongLived(true)
.setShortLabel("testing Bubble")
.build()
val shortcutId = System.currentTimeMillis().toString()

val shortCutInfo = ShortcutInfoCompat.Builder(context!!, shortcutId)
.setCategories(setOf(Notification.CATEGORY_MESSAGE))
.setIntent(Intent(Intent.ACTION_DEFAULT))
.setLongLived(true)
.setShortLabel("testing Bubble")
.build()

val bubbleData = intent?.let {
BubbleMetadata.Builder(it, IconCompat.createWithResource(context!!, R.drawable.ic_logo))
.setDesiredHeight(600)
.setIntent(intent)
.setAutoExpandBubble(true)
.setSuppressNotification(true)
ShortcutManagerCompat.pushDynamicShortcut(context!!, shortCutInfo)

val bubbleData =
BubbleMetadata.Builder(intent!!, IconCompat.createWithBitmap(getLargeIcon()))
.setDesiredHeight(DESIRED_SIZE)
.build() // eventually change the icon to the avatar of the conversation
// also this will eventually need to be set up to only show for important conversations
}
// also this will eventually need to be set up to only show for important conversations

notificationBuilder
.setBubbleMetadata(bubbleData)
.setShortcutId(shortcutId)
.setShortcutInfo(shortcut)
.setLocusId(LocusIdCompat(shortcutId))
}

private fun addReplyAction(notificationBuilder: NotificationCompat.Builder, systemNotificationId: Int) {
Expand Down Expand Up @@ -1031,5 +1033,6 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
private const val TIMER_COUNT = 12
private const val TIMER_DELAY: Long = 5
private const val GET_ROOM_RETRY_COUNT: Long = 3
private const val DESIRED_SIZE = 600
}
}

0 comments on commit 4516b33

Please sign in to comment.