mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-25 18:18:35 +01:00
Refactor tracker name strings
This commit is contained in:
@@ -119,7 +119,7 @@ class LibraryPresenter(
|
||||
val filterCompleted = preferences.filterCompleted().get()
|
||||
val loggedInServices = trackManager.services.filter { trackService -> trackService.isLogged }
|
||||
.associate { trackService ->
|
||||
Pair(trackService.id, preferences.filterTracking(trackService.name).get())
|
||||
Pair(trackService.id, preferences.filterTracking(trackService.id).get())
|
||||
}
|
||||
val isNotAnyLoggedIn = !loggedInServices.values.any()
|
||||
|
||||
|
||||
@@ -9,11 +9,6 @@ import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.data.track.anilist.Anilist
|
||||
import eu.kanade.tachiyomi.data.track.bangumi.Bangumi
|
||||
import eu.kanade.tachiyomi.data.track.kitsu.Kitsu
|
||||
import eu.kanade.tachiyomi.data.track.myanimelist.MyAnimeList
|
||||
import eu.kanade.tachiyomi.data.track.shikimori.Shikimori
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
|
||||
import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog
|
||||
@@ -78,7 +73,7 @@ class LibrarySettingsSheet(
|
||||
private val downloaded = Item.TriStateGroup(R.string.action_filter_downloaded, this)
|
||||
private val unread = Item.TriStateGroup(R.string.action_filter_unread, this)
|
||||
private val completed = Item.TriStateGroup(R.string.completed, this)
|
||||
private val trackFilters: Map<String, Item.TriStateGroup>
|
||||
private val trackFilters: Map<Int, Item.TriStateGroup>
|
||||
|
||||
override val header = null
|
||||
override val items: List<Item>
|
||||
@@ -89,7 +84,7 @@ class LibrarySettingsSheet(
|
||||
.also { services ->
|
||||
val size = services.size
|
||||
trackFilters = services.associate { service ->
|
||||
Pair(service.name, Item.TriStateGroup(getServiceResId(service, size), this))
|
||||
Pair(service.id, Item.TriStateGroup(getServiceResId(service, size), this))
|
||||
}
|
||||
val list: MutableList<Item> = mutableListOf(downloaded, unread, completed)
|
||||
if (size > 1) list.add(Item.Header(R.string.action_filter_tracked))
|
||||
@@ -99,18 +94,7 @@ class LibrarySettingsSheet(
|
||||
}
|
||||
|
||||
private fun getServiceResId(service: TrackService, size: Int): Int {
|
||||
return if (size > 1) getServiceResId(service) else R.string.action_filter_tracked
|
||||
}
|
||||
|
||||
private fun getServiceResId(service: TrackService): Int {
|
||||
return when (service) {
|
||||
is Anilist -> R.string.anilist
|
||||
is MyAnimeList -> R.string.my_anime_list
|
||||
is Kitsu -> R.string.kitsu
|
||||
is Bangumi -> R.string.bangumi
|
||||
is Shikimori -> R.string.shikimori
|
||||
else -> R.string.unknown
|
||||
}
|
||||
return if (size > 1) service.nameRes() else R.string.action_filter_tracked
|
||||
}
|
||||
|
||||
override fun initModels() {
|
||||
|
||||
@@ -71,7 +71,7 @@ class SettingsTrackingController :
|
||||
return initThenAdd(
|
||||
LoginPreference(context).apply {
|
||||
key = Keys.trackUsername(service.id)
|
||||
title = service.name
|
||||
titleRes = service.nameRes()
|
||||
},
|
||||
{
|
||||
onClick {
|
||||
|
||||
@@ -15,18 +15,19 @@ import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class TrackLoginDialog(
|
||||
@StringRes titleRes: Int? = null,
|
||||
titleFormatArgs: Any? = null,
|
||||
@StringRes usernameLabelRes: Int? = null,
|
||||
bundle: Bundle? = null
|
||||
) : LoginDialogPreference(titleRes, titleFormatArgs, usernameLabelRes, bundle) {
|
||||
) : LoginDialogPreference(usernameLabelRes, bundle) {
|
||||
|
||||
private val service = Injekt.get<TrackManager>().getService(args.getInt("key"))!!
|
||||
private val service = Injekt.get<TrackManager>().getService(args.getInt("serviceId"))!!
|
||||
|
||||
constructor(service: TrackService) : this(service, null)
|
||||
|
||||
constructor(service: TrackService, @StringRes usernameLabelRes: Int?) :
|
||||
this(R.string.login_title, service.name, usernameLabelRes, bundleOf("key" to service.id))
|
||||
this(usernameLabelRes, bundleOf("serviceId" to service.id))
|
||||
|
||||
@StringRes
|
||||
override fun getTitleName(): Int = service.nameRes()
|
||||
|
||||
override fun setCredentialsOnView(view: View) {
|
||||
binding?.username?.setText(service.getUsername())
|
||||
|
||||
@@ -14,13 +14,14 @@ import uy.kohesive.injekt.api.get
|
||||
|
||||
class TrackLogoutDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
|
||||
private val service = Injekt.get<TrackManager>().getService(args.getInt("key"))!!
|
||||
private val service = Injekt.get<TrackManager>().getService(args.getInt("serviceId"))!!
|
||||
|
||||
constructor(service: TrackService) : this(bundleOf("key" to service.id))
|
||||
constructor(service: TrackService) : this(bundleOf("serviceId" to service.id))
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val serviceName = activity!!.getString(service.nameRes())
|
||||
return MaterialDialog(activity!!)
|
||||
.title(text = activity!!.getString(R.string.logout_title, service.name))
|
||||
.title(text = activity!!.getString(R.string.logout_title, serviceName))
|
||||
.positiveButton(R.string.logout) {
|
||||
service.logout()
|
||||
(targetController as? Listener)?.trackLogoutDialogClosed(service)
|
||||
|
||||
Reference in New Issue
Block a user