Skip to content

Commit dba83ca

Browse files
mark99ialperozturk96
authored andcommitted
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 <mark-smirnow@yandex.ru>
1 parent e6aab55 commit dba83ca

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidget.kt‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import com.owncloud.android.lib.common.utils.Log_OC
1919
import it.niedermann.owncloud.notes.R
2020
import it.niedermann.owncloud.notes.edit.EditNoteActivity
2121
import it.niedermann.owncloud.notes.persistence.NotesRepository
22-
import it.niedermann.owncloud.notes.shared.util.WidgetUtil
2322
import java.util.concurrent.ExecutorService
2423
import java.util.concurrent.Executors
2524
import androidx.core.net.toUri
@@ -98,9 +97,9 @@ class NoteListWidget : AppWidgetProvider() {
9897
}
9998

10099
val pendingIntentFlags =
101-
WidgetUtil.pendingIntentFlagCompat(PendingIntent.FLAG_UPDATE_CURRENT or Intent.FILL_IN_COMPONENT)
100+
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE or Intent.FILL_IN_COMPONENT
102101
val editNotePendingIntent =
103-
PendingIntent.getActivity(context, 0, editNoteIntent, pendingIntentFlags)
102+
PendingIntent.getActivity(context, appWidgetId, editNoteIntent, pendingIntentFlags)
104103

105104
val views = RemoteViews(context.packageName, R.layout.widget_note_list).apply {
106105
setRemoteAdapter(R.id.note_list_widget_lv, serviceIntent)

0 commit comments

Comments
 (0)