Skip to content

Commit 1ece254

Browse files
authored
SES-4622 : Opening a Notification can scroll conversation to top [Crash fix] (#1574)
* added extension function to defer scrolling * Added fallback address when extras get stripped * update intent flags
1 parent 10b2666 commit 1ece254

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,22 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
283283
}
284284

285285
private val address: Address.Conversable by lazy {
286-
requireNotNull(IntentCompat.getParcelableExtra(intent, ADDRESS, Address.Conversable::class.java)) {
287-
"Address must be provided in the intent extras"
286+
val fromExtras =
287+
IntentCompat.getParcelableExtra(intent, ADDRESS, Address.Conversable::class.java)
288+
if (fromExtras != null) {
289+
return@lazy fromExtras
288290
}
291+
292+
// Fallback: parse from URI
293+
val serialized = intent.data?.getQueryParameter(ADDRESS)
294+
if (!serialized.isNullOrEmpty()) {
295+
val parsed = fromSerialized(serialized)
296+
if (parsed is Address.Conversable) {
297+
return@lazy parsed
298+
}
299+
}
300+
301+
throw IllegalArgumentException("Address must be provided in the intent extras or URI")
289302
}
290303

291304
private val viewModel: ConversationViewModel by viewModels(extrasProducer = {

app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationItem.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,21 @@ public long getThreadId() {
7272
}
7373

7474
public PendingIntent getPendingIntent(Context context) {
75-
76-
Recipient notifyRecipients = threadRecipient != null ? threadRecipient : conversationRecipient;
75+
Recipient notifyRecipients = getRecipient();
7776
final Intent intent = ConversationActivityV2.Companion.createIntent(context, (Address.Conversable) notifyRecipients.getAddress());
78-
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
77+
intent.setData(Uri.parse("custom://" + System.currentTimeMillis())
78+
.buildUpon()
79+
.appendQueryParameter("address", notifyRecipients.getAddress().toString())
80+
.build());
7981

8082
int intentFlags = PendingIntent.FLAG_UPDATE_CURRENT;
8183
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
8284
intentFlags |= PendingIntent.FLAG_MUTABLE;
8385
}
8486

8587
return TaskStackBuilder.create(context)
86-
.addNextIntentWithParentStack(intent)
87-
.getPendingIntent(0, intentFlags);
88+
.addNextIntentWithParentStack(intent)
89+
.getPendingIntent(0, intentFlags);
8890
}
8991

9092
public long getId() {

0 commit comments

Comments
 (0)