From f4d019f13c0724c7535020f41b3a2aa3e44a57fd Mon Sep 17 00:00:00 2001 From: jmir1 Date: Fri, 15 Oct 2021 23:47:40 +0200 Subject: [PATCH] fix some in-app-language --- .../tachiyomi/data/cache/EpisodeCache.kt | 12 +++++- .../ui/anime/info/AnimeInfoHeaderAdapter.kt | 2 +- .../ui/animecategory/CategoryController.kt | 2 +- .../ui/animelib/AnimelibSettingsSheet.kt | 42 +++++++++---------- .../ui/setting/SettingsAdvancedController.kt | 16 ++++--- app/src/main/res/values/strings.xml | 18 +++++--- 6 files changed, 58 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/EpisodeCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/EpisodeCache.kt index 8579fc233..f2176ea2e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/EpisodeCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/EpisodeCache.kt @@ -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. * diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/anime/info/AnimeInfoHeaderAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/anime/info/AnimeInfoHeaderAdapter.kt index 9e5404334..75dbe584d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/anime/info/AnimeInfoHeaderAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/anime/info/AnimeInfoHeaderAdapter.kt @@ -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 } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/animecategory/CategoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/animecategory/CategoryController.kt index f7c685e37..718c6e3b5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/animecategory/CategoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/animecategory/CategoryController.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/animelib/AnimelibSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/animelib/AnimelibSettingsSheet.kt index 27d792ab9..42fc7bbbc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/animelib/AnimelibSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/animelib/AnimelibSettingsSheet.kt @@ -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 @@ -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)) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index 80163376b..5feb0be8c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -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) } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c841f969b..bac76ab0a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -55,10 +55,13 @@ Alphabetically Total manga Total chapters + Total episodes Last read + Last seen Last checked Next expected update Latest chapter + Latest episode Date fetched Date added Search @@ -119,8 +122,11 @@ Comfortable grid List Downloaded chapters + Downloaded episodes Unread chapters + Unseen episodes Local manga + Local anime Language Show category tabs Show number of items @@ -520,13 +526,14 @@ Requires app restart to take effect Cookies cleared Data - Clear chapter cache + Clear chapter and episode cache Used: %1$s + Used by anime: %1$s, used by manga; %2$s Cache cleared. %1$d files have been deleted An error occurred while clearing cache Clear database - Delete history for manga that are not saved in your library - Are you sure? Read chapters and progress of non-library manga will be lost + Delete history for anime and manga that are not saved in your library + Are you sure? Completed episodes and chapters and progress of non-library entries will be lost Entries deleted Refresh library covers Refresh tracking @@ -561,9 +568,9 @@ Downloaded only Incognito mode - Pauses reading history + Pauses your history Disable incognito mode - Filters all manga in your library + Filters all library entries 1 remaining %1$s remaining @@ -625,6 +632,7 @@ Ongoing Unknown Unknown author + Unknown studio Unknown status Licensed Add to library