From dba83caa7948ca994d76a986f35d797e24c249d1 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 9 Oct 2026 01:51:54 +0300 Subject: [PATCH] fix(widget): open the tapped note from the note list widget The note list widget used WidgetUtil.pendingIntentFlagCompat() for its PendingIntent template, which adds FLAG_IMMUTABLE on Android 14+ (API 34+). An immutable PendingIntent cannot be modified at send time, so the per-item fill-in intent carrying the note id was discarded and EditNoteActivity received an intent without PARAM_NOTE_ID, falling back to creating a new note instead of opening the tapped one. Use FLAG_MUTABLE explicitly (as SingleNoteWidget already does) so the fill-in intent with the note id is applied, and use the appWidgetId as PendingIntent request code so widget instances no longer share one PendingIntent. Affected devices: Android 14 and newer (API 34+). On Android 12-13 pendingIntentFlagCompat() returned FLAG_MUTABLE and on Android 11 and below no flag was added, so the fill-in intent worked there. AI-assistant: Cline Extension 1.x (GLM-5.3) Signed-off-by: Mark --- .../owncloud/notes/widget/notelist/NoteListWidget.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidget.kt b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidget.kt index fd15fa597..abfae68de 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidget.kt +++ b/app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidget.kt @@ -19,7 +19,6 @@ import com.owncloud.android.lib.common.utils.Log_OC import it.niedermann.owncloud.notes.R import it.niedermann.owncloud.notes.edit.EditNoteActivity import it.niedermann.owncloud.notes.persistence.NotesRepository -import it.niedermann.owncloud.notes.shared.util.WidgetUtil import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import androidx.core.net.toUri @@ -98,9 +97,9 @@ class NoteListWidget : AppWidgetProvider() { } val pendingIntentFlags = - WidgetUtil.pendingIntentFlagCompat(PendingIntent.FLAG_UPDATE_CURRENT or Intent.FILL_IN_COMPONENT) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE or Intent.FILL_IN_COMPONENT val editNotePendingIntent = - PendingIntent.getActivity(context, 0, editNoteIntent, pendingIntentFlags) + PendingIntent.getActivity(context, appWidgetId, editNoteIntent, pendingIntentFlags) val views = RemoteViews(context.packageName, R.layout.widget_note_list).apply { setRemoteAdapter(R.id.note_list_widget_lv, serviceIntent)