Fix Notifications for ConversationInfor
This commit is contained in:
parent
5627f6a438
commit
11e7e58109
|
@ -23,6 +23,13 @@ import io.flutter.FlutterInjector
|
|||
import org.json.JSONObject
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.io.FileInputStream
|
||||
|
||||
|
||||
import java.io.File
|
||||
|
||||
|
||||
|
||||
|
||||
class FlwtchWorker(context: Context, parameters: WorkerParameters) :
|
||||
CoroutineWorker(context, parameters) {
|
||||
|
@ -138,7 +145,19 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
|
|||
Log.i(TAG, "notification for " + evt.EventType + " " + handle + " " + conversationId + " " + channelId)
|
||||
Log.i(TAG, data.toString());
|
||||
val key = loader.getLookupKeyForAsset(data.getString("picture"))//"assets/profiles/001-centaur.png")
|
||||
val fh = applicationContext.assets.open(key)
|
||||
var fh : java.io.InputStream? = null;
|
||||
try {
|
||||
fh = applicationContext.assets.open(key)
|
||||
} catch (e: Exception) {
|
||||
Log.d("FlwtchWorker->ContactInfo", e.toString() + " :: " + e.getStackTrace());
|
||||
}
|
||||
|
||||
try {
|
||||
val file = File(data.getString("picture"))
|
||||
fh = FileInputStream(file)
|
||||
} catch (e: Exception) {
|
||||
Log.d("FlwtchWorker->ContactInfo", e.toString() + " :: " + e.getStackTrace());
|
||||
}
|
||||
|
||||
val clickIntent = Intent(applicationContext, MainActivity::class.java).also { intent ->
|
||||
intent.action = Intent.ACTION_RUN
|
||||
|
@ -146,12 +165,12 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
|
|||
intent.putExtra("ProfileOnion", data.getString("ProfileOnion"))
|
||||
intent.putExtra("Handle", handle)
|
||||
}
|
||||
|
||||
val image : android.graphics.Bitmap? = if (fh != null) BitmapFactory.decodeStream(fh ) else null;
|
||||
val newNotification = NotificationCompat.Builder(applicationContext, channelId)
|
||||
.setContentTitle(data.getString("Nick"))
|
||||
.setContentText((notificationConversationInfo
|
||||
?: "New Message From %1").replace("%1", data.getString("Nick")))
|
||||
.setLargeIcon(BitmapFactory.decodeStream(fh))
|
||||
.setLargeIcon(image)
|
||||
.setSmallIcon(R.mipmap.knott_transparent)
|
||||
.setContentIntent(PendingIntent.getActivity(applicationContext, 1, clickIntent, flags))
|
||||
.setAutoCancel(true)
|
||||
|
|
Loading…
Reference in New Issue