@@ -236,7 +236,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
236
236
} else if (itemId == R .id .menu_title ) {
237
237
showEditTitleDialog ();
238
238
return true ;
239
- } else if (itemId == R .id .menu_move ) {
239
+ } else if (itemId == R .id .menu_remove_checked_items ) {
240
+ removeCheckedItems ();
241
+ return true ;
242
+ } else if (itemId == R .id .menu_move ) {
240
243
executor .submit (() -> AccountPickerDialogFragment
241
244
.newInstance (new ArrayList <>(repo .getAccounts ()), note .getAccountId ())
242
245
.show (requireActivity ().getSupportFragmentManager (), BaseNoteFragment .class .getSimpleName ()));
@@ -345,7 +348,7 @@ private void showCategorySelector() {
345
348
}
346
349
347
350
/**
348
- * Opens a dialog in order to chose a category
351
+ * Opens a dialog in order to edit the title
349
352
*/
350
353
public void showEditTitleDialog () {
351
354
saveNote (null );
@@ -360,6 +363,28 @@ public void showEditTitleDialog() {
360
363
editTitleFragment .show (manager , fragmentId );
361
364
}
362
365
366
+ /**
367
+ * Removes all checked items from a note
368
+ *
369
+ * @return
370
+ */
371
+ public String removeCheckedItems () {
372
+ Log .d (TAG , "removeCheckedItems()" );
373
+ if (note != null ) {
374
+ final var oldContent = note .getContent ();
375
+ final var newContent = NoteUtil .getContentWithoutCheckedItems (oldContent );
376
+ if (!oldContent .equals (newContent )) {
377
+ note .setContent (newContent );
378
+ }
379
+
380
+ return newContent ;
381
+ } else {
382
+ Log .e (TAG , "note is null" );
383
+ }
384
+
385
+ return "" ;
386
+ }
387
+
363
388
@ Override
364
389
public void onCategoryChosen (String category ) {
365
390
repo .setCategory (localAccount , note .getId (), category );
0 commit comments