Skip to content

Fix: Sync Media Fail Notifications are expandable and copyable - #20976

Closed
LUwUcifer wants to merge 2 commits into
ankidroid:mainfrom
LUwUcifer:syncmediaworker-notif
Closed

Fix: Sync Media Fail Notifications are expandable and copyable#20976
LUwUcifer wants to merge 2 commits into
ankidroid:mainfrom
LUwUcifer:syncmediaworker-notif

Conversation

@LUwUcifer

Copy link
Copy Markdown
Contributor

Purpose / Description

SyncMediaWorker fail throwable notification could not be expanded or opened

Fixes

Approach

  1. Adds attribute .bigText to make text expandable
  2. Adds addAction for a button that copies error message and instantly closes the message upon the action
  3. Uses a custom receiver for serving pendingIntent required for addAction

How Has This Been Tested?

Tested on local device

Learning (optional, can help others)

  1. https://stackoverflow.com/questions/14291436/copy-to-clipboard-by-notification-action#14294660
  2. https://developer.android.com/develop/ui/views/touch-and-input/copy-paste#Copying
  3. https://developer.android.com/develop/ui/views/notifications/build-notification#Actions

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@LUwUcifer

Copy link
Copy Markdown
Contributor Author

Second commit may not be fully optimised, requesting review

@LUwUcifer
LUwUcifer force-pushed the syncmediaworker-notif branch from b4b1ea1 to aacfdcb Compare May 7, 2026 14:39
@BrayanDSO

Copy link
Copy Markdown
Member

How Has This Been Tested?

Tested on local device

Describe that appropriately and/or send a video or screenshot

@BrayanDSO BrayanDSO added Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels May 8, 2026
@LUwUcifer

Copy link
Copy Markdown
Contributor Author

IMG_20260508_164622.jpg

@LUwUcifer

LUwUcifer commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

bigText allows for display of the entire error message, copy to clipboard - copies to clipboard

@github-actions

Copy link
Copy Markdown
Contributor

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions Bot added the Stale label May 22, 2026
@LUwUcifer

Copy link
Copy Markdown
Contributor Author

@BrayanDSO

@github-actions github-actions Bot removed the Stale label May 22, 2026
@BrayanDSO BrayanDSO removed the Needs Author Reply Waiting for a reply from the original author label May 22, 2026
@david-allison

Copy link
Copy Markdown
Member

This still has a flagged security vulnerability:

https://github.com/ankidroid/Anki-Android/security/code-scanning/35

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label May 22, 2026
@LUwUcifer

Copy link
Copy Markdown
Contributor Author

Hey david I saw that persisting error but couldn't figure out how to rectify it as other examples of usages of intent within the project follow the same syntax, I'll need some guidance on the same

Comment thread AnkiDroid/src/main/java/com/ichi2/anki/worker/SyncMediaWorker.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/worker/SyncMediaWorker.kt
@LUwUcifer
LUwUcifer force-pushed the syncmediaworker-notif branch from 1c3d1a4 to aacfdcb Compare May 30, 2026 01:25
@david-allison david-allison added Needs Review and removed Needs Author Reply Waiting for a reply from the original author labels May 30, 2026

@david-allison david-allison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers!

Comment thread AnkiDroid/src/main/java/com/ichi2/anki/receiver/CopyToClipboardReceiver.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/receiver/CopyToClipboardReceiver.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/worker/SyncMediaWorker.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/worker/SyncMediaWorker.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/worker/SyncMediaWorker.kt Outdated
@LUwUcifer
LUwUcifer force-pushed the syncmediaworker-notif branch from acf305a to dd26d8f Compare June 2, 2026 04:24
@LUwUcifer
LUwUcifer force-pushed the syncmediaworker-notif branch from dd26d8f to 5aed42f Compare June 2, 2026 04:34
private fun getCopyToClipboardIntent(text: String): PendingIntent {
val intent =
Intent(applicationContext, CopyToClipboardReceiver::class.java).apply {
putExtra(CopyToClipboardReceiver.EXTRA_SYNC_ERROR_LOG, text)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a limit to text, about 1MB, it needs to be checked and trimmed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that issue ever arise given error messages are exclusively provided from the backend?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlikely, most likely from a StackOverflowError

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this was handled

@david-allison david-allison added Needs Author Reply Waiting for a reply from the original author and removed Has Conflicts labels Jun 3, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions Bot added the Stale label Jun 19, 2026
@github-actions github-actions Bot closed this Jun 26, 2026
@LUwUcifer

Copy link
Copy Markdown
Contributor Author

Should be fine now, I didn't implement support for other languages/runes since I assume stacktrace will necessarily be in english, lmk if i should

)
addAction(
R.drawable.baseline_content_copy_24,
with(applicationContext) { TR.sentenceCase.copyToClipboard },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Application context over context?

private fun getCopyToClipboardIntent(text: String): PendingIntent {
val intent =
Intent(applicationContext, CopyToClipboardReceiver::class.java).apply {
putExtra(CopyToClipboardReceiver.EXTRA_SYNC_ERROR_LOG, text)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this was handled

@david-allison

Copy link
Copy Markdown
Member

Hmm... Can't reopen this

david-allison added a commit to david-allison/Anki-Android that referenced this pull request Aug 12, 2026
Includes review follow-ups from ankidroid#20976: an immutable PendingIntent,
error text trimmed to fit the Binder transaction buffer, and
regression tests

Co-authored-by: David Allison <davidallisongithub@gmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Has Conflicts Needs Author Reply Waiting for a reply from the original author Needs Review Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SyncMediaWorker fail throwable notification cannot be expanded or opened

3 participants