mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-25 14:50:37 +01: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')
|
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 data.startswith("conversation."):
|
if extras:
|
||||||
conv_hexhash = bytes.fromhex(data.replace("conversation.", ""))
|
data = extras.getString("intent_action", "undefined")
|
||||||
def cb(dt):
|
if data.startswith("conversation."):
|
||||||
self.open_conversation(conv_hexhash)
|
conv_hexhash = bytes.fromhex(data.replace("conversation.", ""))
|
||||||
Clock.schedule_once(cb, 0.2)
|
def cb(dt):
|
||||||
|
self.open_conversation(conv_hexhash)
|
||||||
|
Clock.schedule_once(cb, 0.2)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log(f"Error while getting intent action data: {e}", RNS.LOG_ERROR)
|
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)
|
# 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:
|
cstr = f"conversation.{context_id}"
|
||||||
notification_intent.putExtra(JString("intent_action"), JString(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_MUTABLE)
|
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
Block a user