fix some in-app-language

This commit is contained in:
jmir1 2021-10-15 23:47:40 +02:00
parent 4e114d30a6
commit f4d019f13c
6 changed files with 58 additions and 34 deletions

View file

@ -37,7 +37,7 @@ class EpisodeCache(private val context: Context) {
const val PARAMETER_VALUE_COUNT = 1
/** The maximum number of bytes this cache should use to store. */
const val PARAMETER_CACHE_SIZE = 100L * 1024 * 1024
const val PARAMETER_CACHE_SIZE = 1000L * 1024 * 1024
}
/** Google Json class used for parsing JSON files. */
@ -69,6 +69,16 @@ class EpisodeCache(private val context: Context) {
val readableSize: String
get() = Formatter.formatFileSize(context, realSize)
fun clear(): Int {
var deletedFiles = 0
cacheDir.listFiles()?.forEach {
if (removeFileFromCache(it.name)) {
deletedFiles++
}
}
return deletedFiles
}
/**
* Remove file from cache.
*

View file

@ -235,7 +235,7 @@ class AnimeInfoHeaderAdapter(
// Update author TextView.
binding.mangaAuthor.text = if (anime.author.isNullOrBlank()) {
view.context.getString(R.string.unknown_author)
view.context.getString(R.string.unknown_studio)
} else {
anime.author
}

View file

@ -64,7 +64,7 @@ class CategoryController :
* Returns the toolbar title to show when this controller is attached.
*/
override fun getTitle(): String? {
return resources?.getString(R.string.action_edit_categories)
return resources?.getString(R.string.action_edit_anime_categories)
}
override fun createBinding(inflater: LayoutInflater) = CategoriesControllerBinding.inflate(inflater)

View file

@ -88,7 +88,7 @@ class AnimelibSettingsSheet(
inner class FilterGroup : Group {
private val downloaded = Item.TriStateGroup(R.string.action_filter_downloaded, this)
private val unread = Item.TriStateGroup(R.string.action_filter_unread, this)
private val unread = Item.TriStateGroup(R.string.action_filter_unseen, this)
private val completed = Item.TriStateGroup(R.string.completed, this)
private val trackFilters: Map<Int, Item.TriStateGroup>
@ -177,17 +177,17 @@ class AnimelibSettingsSheet(
inner class SortGroup : Group {
private val alphabetically = Item.MultiSort(R.string.action_sort_alpha, this)
private val total = Item.MultiSort(R.string.action_sort_total, this)
private val lastRead = Item.MultiSort(R.string.action_sort_last_read, this)
private val total = Item.MultiSort(R.string.action_sort_total_episodes, this)
private val lastSeen = Item.MultiSort(R.string.action_sort_last_seen, this)
private val lastChecked = Item.MultiSort(R.string.action_sort_last_checked, this)
private val unread = Item.MultiSort(R.string.action_filter_unread, this)
private val latestChapter = Item.MultiSort(R.string.action_sort_latest_chapter, this)
private val chapterFetchDate = Item.MultiSort(R.string.action_sort_chapter_fetch_date, this)
private val unseen = Item.MultiSort(R.string.action_filter_unseen, this)
private val latestEpisode = Item.MultiSort(R.string.action_sort_latest_episode, this)
private val episodeFetchDate = Item.MultiSort(R.string.action_sort_chapter_fetch_date, this)
private val dateAdded = Item.MultiSort(R.string.action_sort_date_added, this)
override val header = null
override val items =
listOf(alphabetically, lastRead, lastChecked, unread, total, latestChapter, chapterFetchDate, dateAdded)
listOf(alphabetically, lastSeen, lastChecked, unseen, total, latestEpisode, episodeFetchDate, dateAdded)
override val footer = null
override fun initModels() {
@ -200,17 +200,17 @@ class AnimelibSettingsSheet(
alphabetically.state =
if (sorting == SortModeSetting.ALPHABETICAL) order else Item.MultiSort.SORT_NONE
lastRead.state =
lastSeen.state =
if (sorting == SortModeSetting.LAST_READ) order else Item.MultiSort.SORT_NONE
lastChecked.state =
if (sorting == SortModeSetting.LAST_CHECKED) order else Item.MultiSort.SORT_NONE
unread.state =
unseen.state =
if (sorting == SortModeSetting.UNREAD) order else Item.MultiSort.SORT_NONE
total.state =
if (sorting == SortModeSetting.TOTAL_CHAPTERS) order else Item.MultiSort.SORT_NONE
latestChapter.state =
latestEpisode.state =
if (sorting == SortModeSetting.LATEST_CHAPTER) order else Item.MultiSort.SORT_NONE
chapterFetchDate.state =
episodeFetchDate.state =
if (sorting == SortModeSetting.DATE_FETCHED) order else Item.MultiSort.SORT_NONE
dateAdded.state =
if (sorting == SortModeSetting.DATE_ADDED) order else Item.MultiSort.SORT_NONE
@ -257,12 +257,12 @@ class AnimelibSettingsSheet(
private fun setSortModePreference(item: Item) {
val flag = when (item) {
alphabetically -> SortModeSetting.ALPHABETICAL
lastRead -> SortModeSetting.LAST_READ
lastSeen -> SortModeSetting.LAST_READ
lastChecked -> SortModeSetting.LAST_CHECKED
unread -> SortModeSetting.UNREAD
unseen -> SortModeSetting.UNREAD
total -> SortModeSetting.TOTAL_CHAPTERS
latestChapter -> SortModeSetting.LATEST_CHAPTER
chapterFetchDate -> SortModeSetting.DATE_FETCHED
latestEpisode -> SortModeSetting.LATEST_CHAPTER
episodeFetchDate -> SortModeSetting.DATE_FETCHED
dateAdded -> SortModeSetting.DATE_ADDED
else -> throw NotImplementedError("Unknown display mode")
}
@ -364,18 +364,18 @@ class AnimelibSettingsSheet(
}
inner class BadgeGroup : Group {
private val downloadBadge = Item.CheckboxGroup(R.string.action_display_download_badge, this)
private val unreadBadge = Item.CheckboxGroup(R.string.action_display_unread_badge, this)
private val localBadge = Item.CheckboxGroup(R.string.action_display_local_badge, this)
private val downloadBadge = Item.CheckboxGroup(R.string.action_display_download_badge_anime, this)
private val unseenBadge = Item.CheckboxGroup(R.string.action_display_unseen_badge, this)
private val localBadge = Item.CheckboxGroup(R.string.action_display_local_badge_anime, this)
private val languageBadge = Item.CheckboxGroup(R.string.action_display_language_badge, this)
override val header = Item.Header(R.string.badges_header)
override val items = listOf(downloadBadge, unreadBadge, localBadge, languageBadge)
override val items = listOf(downloadBadge, unseenBadge, localBadge, languageBadge)
override val footer = null
override fun initModels() {
downloadBadge.checked = preferences.downloadBadge().get()
unreadBadge.checked = preferences.unreadBadge().get()
unseenBadge.checked = preferences.unreadBadge().get()
localBadge.checked = preferences.localBadge().get()
languageBadge.checked = preferences.languageBadge().get()
}
@ -385,7 +385,7 @@ class AnimelibSettingsSheet(
item.checked = !item.checked
when (item) {
downloadBadge -> preferences.downloadBadge().set((item.checked))
unreadBadge -> preferences.unreadBadge().set((item.checked))
unseenBadge -> preferences.unreadBadge().set((item.checked))
localBadge -> preferences.localBadge().set((item.checked))
languageBadge -> preferences.languageBadge().set((item.checked))
}

View file

@ -13,6 +13,8 @@ import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.animelib.AnimelibUpdateService
import eu.kanade.tachiyomi.data.cache.ChapterCache
import eu.kanade.tachiyomi.data.cache.EpisodeCache
import eu.kanade.tachiyomi.data.database.AnimeDatabaseHelper
import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Target
@ -49,8 +51,10 @@ class SettingsAdvancedController : SettingsController() {
private val network: NetworkHelper by injectLazy()
private val chapterCache: ChapterCache by injectLazy()
private val episodeCache: EpisodeCache by injectLazy()
private val db: DatabaseHelper by injectLazy()
private val animedb: AnimeDatabaseHelper by injectLazy()
@SuppressLint("BatteryLife")
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
@ -130,9 +134,9 @@ class SettingsAdvancedController : SettingsController() {
preference {
key = CLEAR_CACHE_KEY
titleRes = R.string.pref_clear_chapter_cache
summary = context.getString(R.string.used_cache, chapterCache.readableSize)
summary = context.getString(R.string.used_cache_both, episodeCache.readableSize, chapterCache.readableSize)
onClick { clearChapterCache() }
onClick { clearChapterAndEpisodeCache() }
}
preference {
key = "pref_clear_database"
@ -270,15 +274,15 @@ class SettingsAdvancedController : SettingsController() {
}
}
private fun clearChapterCache() {
private fun clearChapterAndEpisodeCache() {
if (activity == null) return
launchIO {
try {
val deletedFiles = chapterCache.clear()
val deletedFiles = chapterCache.clear() + episodeCache.clear()
withUIContext {
activity?.toast(resources?.getString(R.string.cache_deleted, deletedFiles))
findPreference(CLEAR_CACHE_KEY)?.summary =
resources?.getString(R.string.used_cache, chapterCache.readableSize)
resources?.getString(R.string.used_cache_both, episodeCache.readableSize, chapterCache.readableSize)
}
} catch (e: Throwable) {
withUIContext { activity?.toast(R.string.cache_delete_error) }
@ -300,7 +304,9 @@ class SettingsAdvancedController : SettingsController() {
private fun clearDatabase() {
db.deleteMangasNotInLibrary().executeAsBlocking()
animedb.deleteAnimesNotInAnimelib().executeAsBlocking()
db.deleteHistoryNoLastRead().executeAsBlocking()
animedb.deleteHistoryNoLastSeen().executeAsBlocking()
activity?.toast(R.string.clear_database_completed)
}
}

View file

@ -55,10 +55,13 @@
<string name="action_sort_alpha">Alphabetically</string>
<string name="action_sort_count">Total manga</string>
<string name="action_sort_total">Total chapters</string>
<string name="action_sort_total_episodes">Total episodes</string>
<string name="action_sort_last_read">Last read</string>
<string name="action_sort_last_seen">Last seen</string>
<string name="action_sort_last_checked">Last checked</string>
<string name="action_sort_next_updated">Next expected update</string>
<string name="action_sort_latest_chapter">Latest chapter</string>
<string name="action_sort_latest_episode">Latest episode</string>
<string name="action_sort_chapter_fetch_date">Date fetched</string>
<string name="action_sort_date_added">Date added</string>
<string name="action_search">Search</string>
@ -119,8 +122,11 @@
<string name="action_display_comfortable_grid">Comfortable grid</string>
<string name="action_display_list">List</string>
<string name="action_display_download_badge">Downloaded chapters</string>
<string name="action_display_download_badge_anime">Downloaded episodes</string>
<string name="action_display_unread_badge">Unread chapters</string>
<string name="action_display_unseen_badge">Unseen episodes</string>
<string name="action_display_local_badge">Local manga</string>
<string name="action_display_local_badge_anime">Local anime</string>
<string name="action_display_language_badge">Language</string>
<string name="action_display_show_tabs">Show category tabs</string>
<string name="action_display_show_number_of_items">Show number of items</string>
@ -520,13 +526,14 @@
<string name="requires_app_restart">Requires app restart to take effect</string>
<string name="cookies_cleared">Cookies cleared</string>
<string name="label_data">Data</string>
<string name="pref_clear_chapter_cache">Clear chapter cache</string>
<string name="pref_clear_chapter_cache">Clear chapter and episode cache</string>
<string name="used_cache">Used: %1$s</string>
<string name="used_cache_both">Used by anime: %1$s, used by manga; %2$s</string>
<string name="cache_deleted">Cache cleared. %1$d files have been deleted</string>
<string name="cache_delete_error">An error occurred while clearing cache</string>
<string name="pref_clear_database">Clear database</string>
<string name="pref_clear_database_summary">Delete history for manga that are not saved in your library</string>
<string name="clear_database_confirmation">Are you sure? Read chapters and progress of non-library manga will be lost</string>
<string name="pref_clear_database_summary">Delete history for anime and manga that are not saved in your library</string>
<string name="clear_database_confirmation">Are you sure? Completed episodes and chapters and progress of non-library entries will be lost</string>
<string name="clear_database_completed">Entries deleted</string>
<string name="pref_refresh_library_covers">Refresh library covers</string>
<string name="pref_refresh_library_tracking">Refresh tracking</string>
@ -561,9 +568,9 @@
<!-- More -->
<string name="label_downloaded_only">Downloaded only</string>
<string name="pref_incognito_mode">Incognito mode</string>
<string name="pref_incognito_mode_summary">Pauses reading history</string>
<string name="pref_incognito_mode_summary">Pauses your history</string>
<string name="notification_incognito_text">Disable incognito mode</string>
<string name="downloaded_only_summary">Filters all manga in your library</string>
<string name="downloaded_only_summary">Filters all library entries</string>
<plurals name="download_queue_summary">
<item quantity="one">1 remaining</item>
<item quantity="other">%1$s remaining</item>
@ -625,6 +632,7 @@
<string name="ongoing">Ongoing</string>
<string name="unknown">Unknown</string>
<string name="unknown_author">Unknown author</string>
<string name="unknown_studio">Unknown studio</string>
<string name="unknown_status">Unknown status</string>
<string name="licensed">Licensed</string>
<string name="add_to_library">Add to library</string>