mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 23:59:17 +01:00
Remove repetition in enhanced tracker preference declarations
Also hides entries that aren't relevant (i.e. if you don't have the source installed).
This commit is contained in:
parent
0f45907144
commit
d8b528a4e0
@ -1,7 +1,6 @@
|
|||||||
package eu.kanade.presentation.more.settings.screen
|
package eu.kanade.presentation.more.settings.screen
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
@ -82,6 +81,7 @@ object SettingsTrackingScreen : SearchableSettings {
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val trackPreferences = remember { Injekt.get<TrackPreferences>() }
|
val trackPreferences = remember { Injekt.get<TrackPreferences>() }
|
||||||
val trackManager = remember { Injekt.get<TrackManager>() }
|
val trackManager = remember { Injekt.get<TrackManager>() }
|
||||||
|
val sourceManager = remember { Injekt.get<SourceManager>() }
|
||||||
|
|
||||||
var dialog by remember { mutableStateOf<Any?>(null) }
|
var dialog by remember { mutableStateOf<Any?>(null) }
|
||||||
dialog?.run {
|
dialog?.run {
|
||||||
@ -151,61 +151,19 @@ object SettingsTrackingScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
Preference.PreferenceGroup(
|
Preference.PreferenceGroup(
|
||||||
title = stringResource(R.string.enhanced_services),
|
title = stringResource(R.string.enhanced_services),
|
||||||
preferenceItems = listOf(
|
preferenceItems = listOf(trackManager.komga, trackManager.kavita, trackManager.suwayomi)
|
||||||
Preference.PreferenceItem.TrackingPreference(
|
.filter { service ->
|
||||||
title = stringResource(trackManager.komga.nameRes()),
|
val acceptedSources = service.getAcceptedSources()
|
||||||
service = trackManager.komga,
|
sourceManager.getCatalogueSources().any { it::class.qualifiedName in acceptedSources }
|
||||||
login = {
|
|
||||||
val sourceManager = Injekt.get<SourceManager>()
|
|
||||||
val acceptedSources = trackManager.komga.getAcceptedSources()
|
|
||||||
val hasValidSourceInstalled = sourceManager.getCatalogueSources()
|
|
||||||
.any { it::class.qualifiedName in acceptedSources }
|
|
||||||
|
|
||||||
if (hasValidSourceInstalled) {
|
|
||||||
trackManager.komga.loginNoop()
|
|
||||||
} else {
|
|
||||||
context.toast(context.getString(R.string.enhanced_tracking_warning, context.getString(trackManager.komga.nameRes())), Toast.LENGTH_LONG)
|
|
||||||
}
|
}
|
||||||
},
|
.map { service ->
|
||||||
logout = trackManager.komga::logout,
|
|
||||||
),
|
|
||||||
Preference.PreferenceItem.TrackingPreference(
|
Preference.PreferenceItem.TrackingPreference(
|
||||||
title = stringResource(trackManager.kavita.nameRes()),
|
title = stringResource(service.nameRes()),
|
||||||
service = trackManager.kavita,
|
service = service,
|
||||||
login = {
|
login = service::loginNoop,
|
||||||
val sourceManager = Injekt.get<SourceManager>()
|
logout = service::logout,
|
||||||
val acceptedSources = trackManager.kavita.getAcceptedSources()
|
)
|
||||||
val hasValidSourceInstalled = sourceManager.getCatalogueSources()
|
} + listOf(Preference.PreferenceItem.InfoPreference(stringResource(R.string.enhanced_tracking_info))),
|
||||||
.any { it::class.qualifiedName in acceptedSources }
|
|
||||||
|
|
||||||
if (hasValidSourceInstalled) {
|
|
||||||
trackManager.kavita.loginNoop()
|
|
||||||
} else {
|
|
||||||
context.toast(context.getString(R.string.enhanced_tracking_warning, context.getString(trackManager.kavita.nameRes())), Toast.LENGTH_LONG)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
logout = trackManager.kavita::logout,
|
|
||||||
),
|
|
||||||
|
|
||||||
Preference.PreferenceItem.TrackingPreference(
|
|
||||||
title = stringResource(trackManager.suwayomi.nameRes()),
|
|
||||||
service = trackManager.suwayomi,
|
|
||||||
login = {
|
|
||||||
val sourceManager = Injekt.get<SourceManager>()
|
|
||||||
val acceptedSources = trackManager.suwayomi.getAcceptedSources()
|
|
||||||
val hasValidSourceInstalled = sourceManager.getCatalogueSources()
|
|
||||||
.any { it::class.qualifiedName in acceptedSources }
|
|
||||||
|
|
||||||
if (hasValidSourceInstalled) {
|
|
||||||
trackManager.suwayomi.loginNoop()
|
|
||||||
} else {
|
|
||||||
context.toast(context.getString(R.string.enhanced_tracking_warning, context.getString(trackManager.suwayomi.nameRes())), Toast.LENGTH_LONG)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
logout = trackManager.suwayomi::logout,
|
|
||||||
),
|
|
||||||
Preference.PreferenceItem.InfoPreference(stringResource(R.string.enhanced_tracking_info)),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,6 @@
|
|||||||
<string name="tracking_info">One-way sync to update the chapter progress in tracking services. Set up tracking for individual entries from their tracking button.</string>
|
<string name="tracking_info">One-way sync to update the chapter progress in tracking services. Set up tracking for individual entries from their tracking button.</string>
|
||||||
<string name="enhanced_services">Enhanced services</string>
|
<string name="enhanced_services">Enhanced services</string>
|
||||||
<string name="enhanced_tracking_info">Services that provide enhanced features for specific sources. Entries are automatically tracked when added to your library.</string>
|
<string name="enhanced_tracking_info">Services that provide enhanced features for specific sources. Entries are automatically tracked when added to your library.</string>
|
||||||
<string name="enhanced_tracking_warning">This tracker is only compatible with the %1$s source.</string>
|
|
||||||
<string name="action_track">Track</string>
|
<string name="action_track">Track</string>
|
||||||
|
|
||||||
<!-- Browse section -->
|
<!-- Browse section -->
|
||||||
|
Loading…
Reference in New Issue
Block a user