🚀 Launch 3.1.0+117
This commit is contained in:
@@ -59,7 +59,6 @@ dependencies {
|
|||||||
implementation("com.google.android.material:material:1.12.0")
|
implementation("com.google.android.material:material:1.12.0")
|
||||||
implementation("com.github.bumptech.glide:glide:4.16.0")
|
implementation("com.github.bumptech.glide:glide:4.16.0")
|
||||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
||||||
implementation("com.google.firebase:firebase-messaging-ktx")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flutter {
|
flutter {
|
||||||
|
@@ -117,14 +117,6 @@
|
|||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
|
|
||||||
<service
|
|
||||||
android:name=".service.MessagingService"
|
|
||||||
android:exported="false">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
||||||
</intent-filter>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="dev.solsynth.solian.provider"
|
android:authorities="dev.solsynth.solian.provider"
|
||||||
|
@@ -1,102 +0,0 @@
|
|||||||
package dev.solsynth.solian.service
|
|
||||||
|
|
||||||
import android.app.PendingIntent
|
|
||||||
import android.content.Intent
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.os.Build
|
|
||||||
import androidx.core.app.NotificationCompat
|
|
||||||
import androidx.core.app.NotificationManagerCompat
|
|
||||||
import androidx.core.app.RemoteInput
|
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.bumptech.glide.request.target.CustomTarget
|
|
||||||
import com.bumptech.glide.request.transition.Transition
|
|
||||||
import com.google.firebase.messaging.FirebaseMessagingService
|
|
||||||
import com.google.firebase.messaging.RemoteMessage
|
|
||||||
import dev.solsynth.solian.MainActivity
|
|
||||||
import dev.solsynth.solian.receiver.ReplyReceiver
|
|
||||||
import org.json.JSONObject
|
|
||||||
|
|
||||||
class MessagingService: FirebaseMessagingService() {
|
|
||||||
override fun onMessageReceived(remoteMessage: RemoteMessage) {
|
|
||||||
val type = remoteMessage.data["type"]
|
|
||||||
if (type == "messages.new") {
|
|
||||||
handleMessageNotification(remoteMessage)
|
|
||||||
} else {
|
|
||||||
// Handle other notification types
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleMessageNotification(remoteMessage: RemoteMessage) {
|
|
||||||
val data = remoteMessage.data
|
|
||||||
val metaString = data["meta"] ?: return
|
|
||||||
val meta = JSONObject(metaString)
|
|
||||||
|
|
||||||
val pfp = meta.optString("pfp", null)
|
|
||||||
val roomId = meta.optString("room_id", null)
|
|
||||||
val messageId = meta.optString("message_id", null)
|
|
||||||
|
|
||||||
val notificationId = System.currentTimeMillis().toInt()
|
|
||||||
|
|
||||||
val replyLabel = "Reply"
|
|
||||||
val remoteInput = RemoteInput.Builder("key_text_reply")
|
|
||||||
.setLabel(replyLabel)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
val replyIntent = Intent(this, ReplyReceiver::class.java).apply {
|
|
||||||
putExtra("room_id", roomId)
|
|
||||||
putExtra("message_id", messageId)
|
|
||||||
putExtra("notification_id", notificationId)
|
|
||||||
}
|
|
||||||
|
|
||||||
val pendingIntentFlags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
|
||||||
} else {
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
}
|
|
||||||
|
|
||||||
val replyPendingIntent = PendingIntent.getBroadcast(
|
|
||||||
applicationContext,
|
|
||||||
notificationId,
|
|
||||||
replyIntent,
|
|
||||||
pendingIntentFlags
|
|
||||||
)
|
|
||||||
|
|
||||||
val action = NotificationCompat.Action.Builder(
|
|
||||||
android.R.drawable.ic_menu_send,
|
|
||||||
replyLabel,
|
|
||||||
replyPendingIntent
|
|
||||||
)
|
|
||||||
.addRemoteInput(remoteInput)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
val intent = Intent(this, MainActivity::class.java)
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
||||||
intent.putExtra("room_id", roomId)
|
|
||||||
val pendingIntent = PendingIntent.getActivity(this, 0, intent, pendingIntentFlags)
|
|
||||||
|
|
||||||
val notificationBuilder = NotificationCompat.Builder(this, "messages")
|
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_info)
|
|
||||||
.setContentTitle(remoteMessage.notification?.title)
|
|
||||||
.setContentText(remoteMessage.notification?.body)
|
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
|
||||||
.setContentIntent(pendingIntent)
|
|
||||||
.addAction(action)
|
|
||||||
|
|
||||||
if (pfp != null) {
|
|
||||||
Glide.with(applicationContext)
|
|
||||||
.asBitmap()
|
|
||||||
.load(pfp)
|
|
||||||
.into(object : CustomTarget<Bitmap>() {
|
|
||||||
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
|
||||||
notificationBuilder.setLargeIcon(resource)
|
|
||||||
NotificationManagerCompat.from(applicationContext).notify(notificationId, notificationBuilder.build())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onLoadCleared(placeholder: Drawable?) {}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
NotificationManagerCompat.from(this).notify(notificationId, notificationBuilder.build())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 3.1.0+116
|
version: 3.1.0+117
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.7.2
|
sdk: ^3.7.2
|
||||||
|
Reference in New Issue
Block a user