mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 19:15:10 +01:00
Tracking updates
Tracked no longer shows manga tracking for services you've logged out of Added logout button to tracking settings If there's a single result in the track dialog for manga, it is selected so all you need to do it press "Track"
This commit is contained in:
parent
1039601bc1
commit
afe69fa2ed
@ -76,6 +76,7 @@ android {
|
||||
dimension "default"
|
||||
}
|
||||
dev {
|
||||
resConfigs "en"
|
||||
dimension "default"
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.library
|
||||
|
||||
import android.os.Bundle
|
||||
import com.jakewharton.rxrelay.BehaviorRelay
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
@ -11,6 +12,7 @@ import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
@ -62,6 +64,7 @@ class LibraryPresenter(
|
||||
|
||||
private val context = preferences.context
|
||||
|
||||
private val loggedServices by lazy { Injekt.get<TrackManager>().services.filter { it.isLogged } }
|
||||
/**
|
||||
* Categories of the library.
|
||||
*/
|
||||
@ -141,9 +144,13 @@ class LibraryPresenter(
|
||||
|
||||
if (filterTracked != STATE_IGNORE) {
|
||||
val db = Injekt.get<DatabaseHelper>()
|
||||
val tracks = db.getTracks(item.manga).executeAsBlocking().size
|
||||
if (filterTracked == STATE_INCLUDE && tracks == 0) return@f false
|
||||
if (filterTracked == STATE_EXCLUDE && tracks > 0) return@f false
|
||||
val tracks = db.getTracks(item.manga).executeAsBlocking()
|
||||
|
||||
val trackCount = loggedServices.count { service ->
|
||||
tracks.any { it.sync_id == service.id }
|
||||
}
|
||||
if (filterTracked == STATE_INCLUDE && trackCount == 0) return@f false
|
||||
if (filterTracked == STATE_EXCLUDE && trackCount > 0) return@f false
|
||||
}
|
||||
// Filter when there are no downloads.
|
||||
if (filterDownloaded != STATE_IGNORE) {
|
||||
|
@ -136,6 +136,11 @@ class TrackSearchDialog : DialogController {
|
||||
view.progress.visibility = View.INVISIBLE
|
||||
view.track_search_list.visibility = View.VISIBLE
|
||||
adapter?.setItems(results)
|
||||
if (results.size == 1 && !wasPreviouslyTracked) {
|
||||
selectedItem = adapter?.getItem(0)
|
||||
(dialog as? MaterialDialog)?.positiveButton(R.string.action_track)
|
||||
(dialog as? MaterialDialog)?.setActionButtonEnabled(WhichButton.POSITIVE, true)
|
||||
}
|
||||
}
|
||||
|
||||
fun onSearchResultsError() {
|
||||
|
@ -26,16 +26,24 @@ abstract class LoginDialogPreference(bundle: Bundle? = null) : DialogController(
|
||||
|
||||
var requestSubscription: Subscription? = null
|
||||
|
||||
open var canLogout = false
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val dialog = MaterialDialog(activity!!)
|
||||
.customView(R.layout.pref_account_login, scrollable = false)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
val dialog = MaterialDialog(activity!!).apply {
|
||||
customView(R.layout.pref_account_login, scrollable = false)
|
||||
positiveButton(android.R.string.cancel)
|
||||
if (canLogout) {
|
||||
negativeButton(R.string.logout) { logout() }
|
||||
}
|
||||
}
|
||||
|
||||
onViewCreated(dialog.view)
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
open fun logout() { }
|
||||
|
||||
fun onViewCreated(view: View) {
|
||||
v = view.apply {
|
||||
show_password.setOnCheckedChangeListener { _, isChecked ->
|
||||
|
@ -16,6 +16,8 @@ class TrackLoginDialog(bundle: Bundle? = null) : LoginDialogPreference(bundle) {
|
||||
|
||||
private val service = Injekt.get<TrackManager>().getService(args.getInt("key"))!!
|
||||
|
||||
override var canLogout = true
|
||||
|
||||
constructor(service: TrackService) : this(Bundle().apply { putInt("key", service.id) })
|
||||
|
||||
override fun setCredentialsOnView(view: View) = with(view) {
|
||||
@ -49,6 +51,13 @@ class TrackLoginDialog(bundle: Bundle? = null) : LoginDialogPreference(bundle) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun logout() {
|
||||
if (service.isLogged) {
|
||||
service.logout()
|
||||
activity?.toast(R.string.logout_success)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDialogClosed() {
|
||||
super.onDialogClosed()
|
||||
(targetController as? Listener)?.trackDialogClosed(service)
|
||||
|
46
app/src/main/res/layout/search_activity.xml
Normal file
46
app/src/main/res/layout/search_activity.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/search_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<eu.kanade.tachiyomi.widget.ElevationAppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/sToolbar"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="?attr/actionBarTheme"/>
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/sTabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/Theme.ActionBar.Tab"
|
||||
app:tabIndicatorColor="@android:color/white"
|
||||
app:tabGravity="center"
|
||||
app:tabMode="scrollable"
|
||||
app:tabMinWidth="75dp"/>
|
||||
|
||||
</eu.kanade.tachiyomi.widget.ElevationAppBarLayout>
|
||||
|
||||
<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
|
||||
android:id="@+id/controller_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
@ -386,7 +386,9 @@
|
||||
<string name="password">Password</string>
|
||||
<string name="show_password">Show password</string>
|
||||
<string name="login">Login</string>
|
||||
<string name="logout">Logout</string>
|
||||
<string name="login_success">Successfully logged in</string>
|
||||
<string name="logout_success">You are now logged out</string>
|
||||
<string name="invalid_login">Could not log in</string>
|
||||
<string name="unknown_error">Unknown error</string>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user