Skip to content

Improve ringtone selection - #7039

Merged
AndyScherzinger merged 7 commits into
masterfrom
fixCallRingtoneSelection
Nov 19, 2026
Merged

AndyScherzinger merged 7 commits into
masterfrom
fixCallRingtoneSelection

Conversation

@mahibi

@mahibi mahibi commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes choosing sounds for calls and messages in Settings → Notifications.

Problem 1

  • On Samsung (One UI), the system channel settings only offer notification sounds for the calls channel. They ignore that the channel uses USAGE_NOTIFICATION_RINGTONE, so no real call ringtone can be selected.

Problem 2

  • The bundled default sounds ("Librem by feandesign") are app resources, not system sounds. Neither the channel settings nor the system ringtone picker offer them, so once another sound is chosen there's no way back.

Solution

The app now lets the user pick the sound itself instead of relying on the system channel settings:

  • Tapping "Calls" or "Messages" opens a dialog with:
    • Librem by feandesign (bundled default)
    • the currently selected custom sound, if any
    • No sound
    • Other sound… (opens the system picker with the right type, so ringtones
      are offered for calls)
  • The current selection is shown and a sound plays as a preview when tapped.
  • A "Notification settings" button opens the system channel settings for
    everything else.
  • If a channel is disabled, the row shows "Disabled" and tapping it opens the
    system channel settings.

Android doesn't let an app change the sound of an existing notification
channel, and a deleted channel recreated with the same id gets its old settings
back. So when the sound changes, a new channel is created under a versioned id
(<channel>__<timestamp>) and then the old one is deleted. The other settings
of the channel (importance, vibration, lights, badge, lock screen visibility)
are copied to the new channel, so only the sound changes. Signal and Telegram
use the same workaround.

🖼️ Screenshots

Initial dialog Built in ringtone picker (here: Motorola) Dialog after picking some other ringtone
grafik grafik grafik

🚧 TODO

  • Test on different devices: pick a ringtone/sound, go back to Librem, check that the channel's other settings are kept
  • Check whether changing the message sound drops per-conversation notification customizations

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@mahibi mahibi self-assigned this Nov 12, 2026
@mahibi mahibi added this to the 26.0.0 milestone Nov 12, 2026
@mahibi mahibi changed the title Fix call ringtone selection Improve call ringtone selection Nov 12, 2026
@mahibi
mahibi marked this pull request as ready for review November 12, 2026 15:00
@mahibi
mahibi requested a review from rapterjet2004 November 12, 2026 15:00
@mahibi
mahibi marked this pull request as draft November 12, 2026 17:51
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

📱 QA build

Download app-qa-debug.apk
QR code Open the QR code for this download
Commit 4316cbd
Version 7039
Available until 7 days after this build

The QA build installs alongside a released Nextcloud app, so you can keep
using your existing install while testing.

Downloading the file requires a GitHub account, so open this link on the
device you want to test on, or transfer the APK to it.

@mahibi
mahibi force-pushed the fixCallRingtoneSelection branch from c25621d to 5fa6450 Compare November 17, 2026 10:27
@mahibi
mahibi marked this pull request as ready for review November 17, 2026 10:37
@mahibi mahibi changed the title Improve call ringtone selection Improve ringtone selection Nov 17, 2026
@mahibi
mahibi marked this pull request as draft November 17, 2026 10:52
On some OEMs (e.g. Samsung) the system notification channel settings only
offer notification sounds for the calls channel, even though it uses
USAGE_NOTIFICATION_RINGTONE, so no call ringtone could be selected.

Open an in-app ringtone picker with TYPE_RINGTONE instead (as done by
Signal). As the sound of an existing channel can't be changed by the app,
the calls channel is recreated under a new versioned id
(NOTIFICATION_CHANNEL_CALLS_V5__<timestamp>) keeping its other settings.
The system channel settings are still opened if the channel is disabled
or no ringtone picker is available.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
The app ships its own default sounds ("Librem by feandesign") for calls and
messages. These are app resources, not system sounds, so neither the system
channel settings nor the system ringtone picker offer them. Once a user
picked another call ringtone or message sound, there was no way back to the
bundled default.

Tapping the call or message sound now shows a dialog offering the bundled
default or "Other sound…", which opens the system picker. The picker's
"Default" entry now refers to the phone's default ringtone/notification
sound, so it means the same on all devices.

Message sounds are chosen in-app like call ringtones. As the sound of an
existing channel can't be changed by the app, the messages channel is
recreated under a versioned id (NOTIFICATION_CHANNEL_MESSAGES_V4__<timestamp>)
the same way as the calls channel, sharing the recreation logic.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
…ings

Copying the old channel's settings into the recreated channel was not
reliable: the vibration pattern overwrote the copied vibration flag, and
settings like bypassing Do Not Disturb or lock screen visibility are reset
by the system when an app creates a channel anyway. As changing the sound
is rare, the channel is now simply recreated with the app defaults and the
new sound, reusing the existing channel creation code.

The new channel is created before the old one is deleted, so there is no
moment without a channel, and the newest versioned channel is used if more
than one exists.

Also avoid crashes when a ringtone can't be resolved for its title, and
when the system channel settings can't be opened.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Some ringtone pickers return RESULT_OK without EXTRA_RINGTONE_PICKED_URI.
This was read as "silent" and muted calls or messages although the user
never chose silent. Such results are now ignored like a cancel.

The system may reject a channel sound the app is not allowed to read with a
SecurityException, which crashed the settings screen. Now the old channel
is kept, the preference is not changed and an error toast is shown.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
- Catch all runtime exceptions when creating the replacement channel. Some
  OEMs throw IllegalArgumentException for invalid sounds, and file:// uris
  from third-party pickers can throw as well, which crashed the settings
  screen. The old channel is kept and an error toast is shown.
- Use one update function per sound for both the picker result and the
  sound dialog, so both paths can't diverge.
- Take the preview's audio usage from NotificationUtils, so the preview
  plays on the same volume stream as the real notification.
- Only refresh the sound labels after a change, instead of re-running the
  whole setup, which re-registered click listeners and could re-trigger
  the notification warning blink animation.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Changing the call or message sound replaces the notification channel under
a new id, because Android doesn't let an app change the sound of an existing
channel. Until now the new channel started with the app defaults, so any
settings the user had changed in the system settings (importance, vibration,
lights, badge, lock screen visibility) were lost with every sound change.

The settings of the current channel are now copied to the new one, as Signal
does. The vibration flag is set after the vibration pattern, because setting
the pattern also changes the flag. Some settings may still be ignored by the
system for new channels, e.g. bypassing Do Not Disturb without policy access.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
… screen

The settings screen was migrated to Compose, so the sound dialog is now a
composable and the sound change runs in the SettingsViewModel on a
coroutine. The system ringtone picker is opened through an
ActivityResultContract, and the system notification settings open the
current, versioned channel.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@mahibi
mahibi force-pushed the fixCallRingtoneSelection branch from 5fa6450 to 4316cbd Compare November 17, 2026 19:23
@mahibi
mahibi marked this pull request as ready for review November 17, 2026 19:23
@mahibi mahibi added the 3. to review Waiting for reviews label Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Codacy

Lint

TypemasterPR
Warnings1716
Errors00

SpotBugs

CategoryBaseNew
Bad practice77
Correctness88
Dodgy code4040
Internationalization33
Malicious code vulnerability33
Performance77
Security1111
Total7979

@AndyScherzinger
AndyScherzinger merged commit 647e07a into master Nov 19, 2026
21 of 23 checks passed
@AndyScherzinger
AndyScherzinger deleted the fixCallRingtoneSelection branch November 19, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants