Skip to content

Commit

Permalink
fix: review comments (remove name of companion object)
Browse files Browse the repository at this point in the history
fix: trim preferred dub team name, because some keyboards may add whitespace after coma symbol
fix: phrasing for summary of ignore subs setting
  • Loading branch information
danya140 committed Apr 8, 2024
1 parent db5adf0 commit e117130
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ class Animelib : ConfigurableAnimeSource, AnimeHttpSource() {
private val playlistUtils by lazy { PlaylistUtils(client, headers) }
private val dateFormatter by lazy { SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH) }

// =============================== Preference ===============================
private val preferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
}

companion object Constants {
companion object {
private const val PREF_QUALITY_KEY = "pref_quality"
private val PREF_QUALITY_ENTRIES = arrayOf("360", "720", "1080", "2160")

Expand All @@ -74,6 +69,11 @@ class Animelib : ConfigurableAnimeSource, AnimeHttpSource() {
private val ATOB_REGEX = Regex("atob\\([^\"]")
}

// =============================== Preference ===============================
private val preferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
}

override fun setupPreferenceScreen(screen: PreferenceScreen) {
ListPreference(screen.context).apply {
key = PREF_SERVER_KEY
Expand Down Expand Up @@ -138,7 +138,7 @@ class Animelib : ConfigurableAnimeSource, AnimeHttpSource() {
SwitchPreferenceCompat(screen.context).apply {
key = PREF_IGNORE_SUBS_KEY
title = "Игнорировать субтитры"
summary = "Исключает из списка озвучек субтитры"
summary = "Исключает видео с субтитрами"
setDefaultValue(PREF_IGNORE_SUBS_DEFAULT)

setOnPreferenceChangeListener { _, newValue ->
Expand Down Expand Up @@ -199,7 +199,7 @@ class Animelib : ConfigurableAnimeSource, AnimeHttpSource() {
val teams = preferences.getString(PREF_DUB_TEAM_KEY, "")?.split(',')

val preferredTeams = episodeData.data.players?.filter { videoInfo ->
teams.isNullOrEmpty() || teams.any { videoInfo.team.name.contains(it, true) }
teams.isNullOrEmpty() || teams.any { videoInfo.team.name.contains(it.trim(), true) }
} ?: episodeData.data.players

val useMaxQuality = preferences.getBoolean(
Expand Down

0 comments on commit e117130

Please sign in to comment.