Compare commits

...

3 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] 404568ed8f fix: use single-intent shortcut so FLAG_ACTIVITY_NEW_DOCUMENT task matching works
FLAG_ACTIVITY_NEW_DOCUMENT document-task matching (same URI → reuse
existing task) only works with single-intent startActivity(). When
ShortcutInfoCompat.setIntents() passes a multi-intent array, Android
internally calls startActivities(), which does not honour the document-
task model: different shortcuts end up sharing a task, and opening the
same app from chat and from a shortcut creates duplicate tasks.

Fix: replace setIntents(getWebxdcIntentWithParentStack()) with
setIntent(getWebxdcIntent()) so the shortcut fires the exact same
single intent as a direct open. The now-unused
getWebxdcIntentWithParentStack helper and TaskStackBuilder import
are removed.
2026-06-09 22:54:12 +00:00
copilot-swe-agent[bot] d7755a9b3e fix: prevent duplicate WebxdcActivity tasks, fix shortcut task isolation
- Set unique data URI (webxdc://accountId/msgId) on every WebxdcActivity
  intent so FLAG_ACTIVITY_NEW_DOCUMENT can identify the document uniquely
- Drop FLAG_ACTIVITY_MULTIPLE_TASK: same URI → existing task brought to
  front instead of spawning a duplicate
- Apply FLAG_ACTIVITY_NEW_DOCUMENT to shortcuts too (was openInSeparateTask=false),
  so each distinct shortcut (different app) opens in its own task
- Remove the now-unnecessary openInSeparateTask parameter
2026-06-09 22:41:12 +00:00
copilot-swe-agent[bot] 8340276d03 Allow separate Webxdc tasks 2026-06-09 22:16:35 +00:00
@@ -28,7 +28,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.ActionBar;
import androidx.core.app.TaskStackBuilder;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.drawable.IconCompat;
@@ -133,30 +132,20 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
private static Intent getWebxdcIntent(
Context context, int msgId, boolean hideActionBar, String href) {
DcContext dcContext = DcHelper.getContext(context);
int accountId = dcContext.getAccountId();
Intent intent = new Intent(context, WebxdcActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra(EXTRA_ACCOUNT_ID, dcContext.getAccountId());
// Unique URI per webxdc instance so FLAG_ACTIVITY_NEW_DOCUMENT can identify the document:
// same app → same URI → existing task reused; different apps → different URIs → separate tasks.
intent.setData(Uri.parse("webxdc://" + accountId + "/" + msgId));
intent.putExtra(EXTRA_ACCOUNT_ID, accountId);
intent.putExtra(EXTRA_APP_MSG_ID, msgId);
intent.putExtra(EXTRA_HIDE_ACTION_BAR, hideActionBar);
intent.putExtra(EXTRA_HREF, href);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
return intent;
}
private static Intent[] getWebxdcIntentWithParentStack(Context context, int msgId) {
DcContext dcContext = DcHelper.getContext(context);
final Intent chatIntent =
new Intent(context, ConversationActivity.class)
.putExtra(ConversationActivity.CHAT_ID_EXTRA, dcContext.getMsg(msgId).getChatId())
.setAction(Intent.ACTION_VIEW);
final Intent webxdcIntent = getWebxdcIntent(context, msgId, false, "");
return TaskStackBuilder.create(context)
.addNextIntentWithParentStack(chatIntent)
.addNextIntent(webxdcIntent)
.getIntents();
}
@Override
protected boolean immersiveMode() {
@@ -554,7 +543,7 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
IconCompat.createWithBitmap(
bitmap)) // createWithAdaptiveBitmap() removes decorations but cuts out a too
// small circle and defamiliarize the icon too much
.setIntents(getWebxdcIntentWithParentStack(context, msgId))
.setIntent(getWebxdcIntent(context, msgId, false, ""))
.build();
Toast.makeText(context, R.string.one_moment, Toast.LENGTH_SHORT).show();