@@ -231,6 +231,7 @@ public static RemoteViews buildRemoteViews(final Context context,
231231 PendingIntent openConfigPendingIntent = getThePendingIntentForActivity (configIntent , context );
232232 rv .setOnClickPendingIntent (R .id .widgetConfigButton , openConfigPendingIntent );
233233
234+ // + button to create a new note from the widget
234235 final Intent createIntent = new Intent ();
235236 createIntent
236237 .setFlags (Intent .FLAG_ACTIVITY_NEW_TASK | Intent .FLAG_ACTIVITY_CLEAR_TASK )
@@ -240,8 +241,15 @@ public static RemoteViews buildRemoteViews(final Context context,
240241 .setData (Uri .withAppendedPath (Task .URI , "/widget/" + appWidgetId + "/-1" ))
241242 .putExtra (TaskDetailFragment .ARG_ITEM_LIST_ID , listId );
242243
243- PendingIntent createPendingIntent = getThePendingIntentForActivity (createIntent , context );
244- rv .setOnClickPendingIntent (R .id .createNoteButton , createPendingIntent );
244+ if (listId > 0 ) {
245+ rv .setViewVisibility (R .id .createNoteButton , View .VISIBLE );
246+ PendingIntent createPendingIntent = getThePendingIntentForActivity (createIntent , context );
247+ rv .setOnClickPendingIntent (R .id .createNoteButton , createPendingIntent );
248+ } else {
249+ // the widget is showing notes from all lists: hide the + button,
250+ // because it would not find a valid list to add a note to
251+ rv .setViewVisibility (R .id .createNoteButton , View .GONE );
252+ }
245253
246254 return rv ;
247255 }
0 commit comments