mirror of
https://github.com/markqvist/Sideband.git
synced 2024-12-28 00:49:32 -05:00
Open conversations from notifications on Android
This commit is contained in:
parent
30ccd64535
commit
1e604f15a8
@ -830,12 +830,14 @@ class SidebandApp(MDApp):
|
||||
JString = autoclass('java.lang.String')
|
||||
Intent = autoclass("android.content.Intent")
|
||||
try:
|
||||
data = intent.getExtras().getString("intent_action", "undefined")
|
||||
if data.startswith("conversation."):
|
||||
conv_hexhash = bytes.fromhex(data.replace("conversation.", ""))
|
||||
def cb(dt):
|
||||
self.open_conversation(conv_hexhash)
|
||||
Clock.schedule_once(cb, 0.2)
|
||||
extras = intent.getExtras()
|
||||
if extras:
|
||||
data = extras.getString("intent_action", "undefined")
|
||||
if data.startswith("conversation."):
|
||||
conv_hexhash = bytes.fromhex(data.replace("conversation.", ""))
|
||||
def cb(dt):
|
||||
self.open_conversation(conv_hexhash)
|
||||
Clock.schedule_once(cb, 0.2)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Error while getting intent action data: {e}", RNS.LOG_ERROR)
|
||||
|
@ -116,14 +116,14 @@ class SidebandService():
|
||||
# bitmap_icon = BitmapFactory.decodeFile(large_icon_path)
|
||||
# notification.setLargeIcon(bitmap_icon)
|
||||
|
||||
if not self.notification_intent:
|
||||
notification_intent = Intent(self.app_context, python_act)
|
||||
notification_intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
notification_intent.setAction(Intent.ACTION_MAIN)
|
||||
notification_intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
if context_id != None:
|
||||
notification_intent.putExtra(JString("intent_action"), JString(f"conversation.{context_id}"))
|
||||
self.notification_intent = PendingIntent.getActivity(self.app_context, 0, notification_intent, PendingIntent.FLAG_MUTABLE)
|
||||
notification_intent = Intent(self.app_context, python_act)
|
||||
notification_intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
notification_intent.setAction(Intent.ACTION_MAIN)
|
||||
notification_intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
if context_id != None:
|
||||
cstr = f"conversation.{context_id}"
|
||||
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.setAutoCancel(True)
|
||||
|
Loading…
Reference in New Issue
Block a user