Dan Kendalls' Fluff

Fixing KDE Connect's Windows Notification Custom Actions

Today I forked KDE Connect, one of those excellent if rough round the edges projects I use everyday bring your phone (Android or iOS!!!) and desktop (Windows, macOS, GNU/Linux) together with features like notification syncing, remote control, file transfers, clipboard sharing, and much more that I never use.

I have taken the time to fix something that has been broken for a long time: custom notification actions on Windows.

In the current release, you can trigger notification actions on Linux, but not on Windows, as custom notifications are not exposed through the Win32 toast API.

I actually had some prior experience with this at university, Nottingham Trent, where I used BurntToast to post Windows notifications for a simple Android app I made that converted cooking times between microwave power levels. Most ready meals only listed instructions for 800 W or 900 W microwaves, so I had an inkling of the arguments Windows toasts accepted.

It turned out there were also compatibility issues with KDE Connect's own Android client. Luckily, I already had the required toolchains configured from yesterday's excursions.

Desktop Changes

The Windows desktop fork now:

Android Change

The Android fork contains one functional code change:

if (a.title.toString() == title)

Previously, it used:

if (a.title == title)

Android notification action titles are CharSequence objects and may actually be styled objects such as SpannableString. KDE Connect sends the displayed title over the network as a plain JSON String.

Although both values display identical text, comparing a styled CharSequence directly with a plain String will fail obviously as they are not the same.

Converting the Android title with toString() makes the comparison text based (always be based), allowing the Windows toast and desktop history buttons to invoke the correct Android PendingIntent.

Submitted

I have submitted my changes to KDE. If they are not accepted, at least there is now a build that does this. <3

Repos:

invent.kde.org/unenvied/kdeconnect-kde-fork

invent.kde.org/unenvied/kdeconnect-android

Peace ✌️