Эх сурвалжийг харах

Add ability to explicitly remove tracking from track search dialog (closes #2532)

arkon 5 жил өмнө
parent
commit
f966187ea4

+ 6 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackPresenter.kt

@@ -91,10 +91,14 @@ class TrackPresenter(
                     .subscribe({ },
                             { error -> context.toast(error.message) }))
         } else {
-            db.deleteTrackForManga(manga, service).executeAsBlocking()
+            unregisterTracking(service)
         }
     }
 
+    fun unregisterTracking(service: TrackService) {
+        db.deleteTrackForManga(manga, service).executeAsBlocking()
+    }
+
     private fun updateRemote(track: Track, service: TrackService) {
         service.update(track)
                 .flatMap { db.insertTrack(track).asRxObservable() }
@@ -127,4 +131,4 @@ class TrackPresenter(
         updateRemote(track, item.service)
     }
 
-}
+}

+ 7 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt

@@ -54,8 +54,10 @@ class TrackSearchDialog : DialogController {
         val dialog = MaterialDialog.Builder(activity!!)
                 .customView(R.layout.track_search_dialog, false)
                 .positiveText(android.R.string.ok)
-                .negativeText(android.R.string.cancel)
                 .onPositive { _, _ -> onPositiveButtonClick() }
+                .negativeText(android.R.string.cancel)
+                .neutralText(R.string.action_remove)
+                .onNeutral { _, _ ->  onRemoveButtonClick() }
                 .build()
 
         if (subscriptions.isUnsubscribed) {
@@ -137,6 +139,10 @@ class TrackSearchDialog : DialogController {
         trackController.presenter.registerTracking(selectedItem, service)
     }
 
+    private fun onRemoveButtonClick() {
+        trackController.presenter.unregisterTracking(service)
+    }
+
     private companion object {
         const val KEY_SERVICE = "service_id"
     }