Przeglądaj źródła

Allow to mark all previous chapters as read

inorichi 9 lat temu
rodzic
commit
4bf15a5a2c

+ 5 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.java

@@ -254,6 +254,11 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
         return true;
     }
 
+    public boolean onMarkPreviousAsRead(Chapter chapter) {
+        getPresenter().markPreviousChaptersAsRead(chapter);
+        return true;
+    }
+
     protected boolean onDownload(Observable<Chapter> chapters) {
         DownloadService.start(getActivity());
 

+ 2 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersHolder.java

@@ -99,6 +99,8 @@ public class ChaptersHolder extends FlexibleViewHolder {
                     return adapter.getFragment().onDownload(chapter);
                 case R.id.action_delete:
                     return adapter.getFragment().onDelete(chapter);
+                case R.id.action_mark_previous_as_read:
+                    return adapter.getFragment().onMarkPreviousAsRead(item);
             }
             return false;
         });

+ 9 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.java

@@ -207,6 +207,15 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
                 .subscribe());
     }
 
+    public void markPreviousChaptersAsRead(Chapter selected) {
+        Observable.from(chapters)
+                .filter(c -> c.chapter_number > -1 && c.chapter_number < selected.chapter_number)
+                .doOnNext(c -> c.read = true)
+                .toList()
+                .flatMap(chapters -> db.insertChapters(chapters).asRxObservable())
+                .subscribe();
+    }
+
     public void downloadChapters(Observable<Chapter> selectedChapters) {
         add(selectedChapters
                 .toList()

+ 5 - 0
app/src/main/res/menu/chapter_single.xml

@@ -22,4 +22,9 @@
         android:title="@string/action_mark_as_unread"
         android:icon="@drawable/ic_action_undone_all"
         app:showAsAction="ifRoom"/>
+
+    <item
+        android:id="@+id/action_mark_previous_as_read"
+        android:title="@string/action_mark_previous_as_read"/>
+
 </menu>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -19,6 +19,7 @@
     <string name="action_select_all">Select all</string>
     <string name="action_mark_as_read">Mark as read</string>
     <string name="action_mark_as_unread">Mark as unread</string>
+    <string name="action_mark_previous_as_read">Mark previous as read</string>
     <string name="action_download">Download</string>
     <string name="action_delete">Delete</string>
     <string name="action_update">Update</string>