Open conversations from notifications on Android
This commit is contained in:
parent
30ccd64535
commit
1e604f15a8
|
@ -830,7 +830,9 @@ class SidebandApp(MDApp):
|
||||||
JString = autoclass('java.lang.String')
|
JString = autoclass('java.lang.String')
|
||||||
Intent = autoclass("android.content.Intent")
|
Intent = autoclass("android.content.Intent")
|
||||||
try:
|
try:
|
||||||
data = intent.getExtras().getString("intent_action", "undefined")
|
extras = intent.getExtras()
|
||||||
|
if extras:
|
||||||
|
data = extras.getString("intent_action", "undefined")
|
||||||
if data.startswith("conversation."):
|
if data.startswith("conversation."):
|
||||||
conv_hexhash = bytes.fromhex(data.replace("conversation.", ""))
|
conv_hexhash = bytes.fromhex(data.replace("conversation.", ""))
|
||||||
def cb(dt):
|
def cb(dt):
|
||||||
|
|
|
@ -116,14 +116,14 @@ class SidebandService():
|
||||||
# bitmap_icon = BitmapFactory.decodeFile(large_icon_path)
|
# bitmap_icon = BitmapFactory.decodeFile(large_icon_path)
|
||||||
# notification.setLargeIcon(bitmap_icon)
|
# notification.setLargeIcon(bitmap_icon)
|
||||||
|
|
||||||
if not self.notification_intent:
|
|
||||||
notification_intent = Intent(self.app_context, python_act)
|
notification_intent = Intent(self.app_context, python_act)
|
||||||
notification_intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
notification_intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||||
notification_intent.setAction(Intent.ACTION_MAIN)
|
notification_intent.setAction(Intent.ACTION_MAIN)
|
||||||
notification_intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
notification_intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||||
if context_id != None:
|
if context_id != None:
|
||||||
notification_intent.putExtra(JString("intent_action"), JString(f"conversation.{context_id}"))
|
cstr = f"conversation.{context_id}"
|
||||||
self.notification_intent = PendingIntent.getActivity(self.app_context, 0, notification_intent, PendingIntent.FLAG_MUTABLE)
|
notification_intent.putExtra(JString("intent_action"), JString(cstr))
|
||||||
|
self.notification_intent = PendingIntent.getActivity(self.app_context, 0, notification_intent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
|
|
||||||
notification.setContentIntent(self.notification_intent)
|
notification.setContentIntent(self.notification_intent)
|
||||||
notification.setAutoCancel(True)
|
notification.setAutoCancel(True)
|
||||||
|
|
Loading…
Reference in New Issue