From a51e025c0373ed390a74ba7339a5ba504abfbd40 Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX <1173913+AbandonedCart@users.noreply.github.com> Date: Sun, 7 Apr 2024 22:28:34 -0400 Subject: [PATCH] fix: address possible format issues (#331) * fix: address possible format issued * fix: improve results and logging * fix: not everything is a title Fixed the book title style of capitalization Toast and Snackbar messages appear for less than 3 seconds. Why are they paragraphs? * Fix: the other half of the file Probably missed a few, but this fixes the rest of the obvious ones (including a double negative) --- app/src/main/java/ani/dantotsu/Functions.kt | 6 +-- .../connections/bakaupdates/MangaUpdates.kt | 25 ++++++++-- app/src/main/res/values/strings.xml | 49 ++++++++++--------- 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/Functions.kt b/app/src/main/java/ani/dantotsu/Functions.kt index bd2e047e..98264c6c 100644 --- a/app/src/main/java/ani/dantotsu/Functions.kt +++ b/app/src/main/java/ani/dantotsu/Functions.kt @@ -993,8 +993,8 @@ fun countDown(media: Media, view: ViewGroup) { fun sinceWhen(media: Media, view: ViewGroup) { if (media.status != "RELEASING" && media.status != "HIATUS") return CoroutineScope(Dispatchers.IO).launch { - MangaUpdates().search(media.name ?: media.nameRomaji, media.startDate)?.let { - val latestChapter = MangaUpdates.getLatestChapter(it) + MangaUpdates().search(media.mangaName(), media.startDate)?.let { + val latestChapter = MangaUpdates.getLatestChapter(view.context, it) val timeSince = (System.currentTimeMillis() - (it.metadata.series.lastUpdated!!.timestamp * 1000)) / 1000 @@ -1436,4 +1436,4 @@ fun buildMarkwon( })) .build() return markwon -} \ No newline at end of file +} diff --git a/app/src/main/java/ani/dantotsu/connections/bakaupdates/MangaUpdates.kt b/app/src/main/java/ani/dantotsu/connections/bakaupdates/MangaUpdates.kt index 9f24cfe7..426abc51 100644 --- a/app/src/main/java/ani/dantotsu/connections/bakaupdates/MangaUpdates.kt +++ b/app/src/main/java/ani/dantotsu/connections/bakaupdates/MangaUpdates.kt @@ -1,8 +1,15 @@ package ani.dantotsu.connections.bakaupdates +import android.content.Context +import ani.dantotsu.R import ani.dantotsu.client import ani.dantotsu.connections.anilist.api.FuzzyDate import ani.dantotsu.tryWithSuspend +import ani.dantotsu.util.Logger +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.coroutineScope import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import okio.ByteString.Companion.encode @@ -34,6 +41,13 @@ class MangaUpdates { } } val res = client.post(apiUrl, json = query).parsed() + coroutineScope { + res.results?.map { + async(Dispatchers.IO) { + Logger.log(it.toString()) + } + } + }?.awaitAll() res.results?.first { it.metadata.series.lastUpdated?.timestamp != null && (it.metadata.series.latestChapter != null @@ -43,9 +57,14 @@ class MangaUpdates { } companion object { - fun getLatestChapter(results: MangaUpdatesResponse.Results): String { - return results.metadata.series.latestChapter?.toString() - ?: results.record.chapter!!.substringAfterLast("-").trim() + fun getLatestChapter(context: Context, results: MangaUpdatesResponse.Results): String { + return results.metadata.series.latestChapter?.let { + context.getString(R.string.chapter_number, it) + } ?: results.record.chapter!!.substringAfterLast("-").trim().let { chapter -> + chapter.takeIf { + it.toIntOrNull() == null + } ?: context.getString(R.string.chapter_number, chapter.toInt()) + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ee43d4b7..44ce511e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -435,9 +435,9 @@ View My AniList DAMN! YOU TRULY ARE JOBLESS\nYOU REACHED THE END - Couldn\'t find any File Manager to open SD card + Couldn\'t find a File Manager to open SD card Error loading data %1$s - You Long Click the button to check for App Update + Long click to check for app updates Saved to:\n%s Setting progress to %1$d Please Login into AniList account! @@ -458,27 +458,27 @@ Make the skip time stamp button disappear after 5 seconds Copied to Clipboard This is the 1st Episode! - You can long click List Editor button to Reset Auto Update - Autoplay cancelled, no Interaction for more than 1 Hour. + Long click \"List Editor\" button to reset Auto Update + Autoplay cancelled, no interaction for more than 1 Hour. Couldn\'t auto select the server, Please try again! No streams available! Try another source. - Logging in MAL + Logging into MAL Getting User Data - No next Episode Found! - Try Enabling Banner Animations from Settings + No next episode found! + Try enabling \"Banner Animations\" in settings Please Login with Anilist! - Auto Update Progress has now been Reset-ed - Can\'t Wait, huh? fine X( + Auto Update progress has now been reset-ed + Can\'t wait, huh? fine X( Downloading… Next Chapter Not Found - This is the 1st Chapter! + This is the 1st chapter! Adult Stuff?( ͡° ͜ʖ ͡° ) What did you even open? - Error getting Data from Anilist. - Empty Response, Does your internet perhaps suck? - Error loading MAL User Data + Error getting data from Anilist. + Empty response! Does your internet suck, perhaps? + Error loading MAL user data Failed to load data from MAL - Error loading Anilist User Data + Error loading Anilist user data Couldn\'t find episode : %1$s List Updated Deleted from List @@ -491,7 +491,7 @@ Started Downloading\n%1$s Please install 1DM Please install ADM - Error getting Image Data + Error getting image data Loading Image Failed Copied device info Seems like Anilist is down, maybe try using a VPN or you can wait for it to come back. @@ -499,11 +499,12 @@ Wasn\'t able to get access Mal Login : Uri not Found Mal Login : codeChallenge not found - Mal Login : Code not present in Redirected URI - Refresh Token : Failed to load Saved Token + Mal Login : Code not present in redirected URI + Refresh Token : Failed to load saved token Refreshing Token Failed Episode %1$d will be released in - Chapter %1$s has been available for + Chapter %1$d + %1$s has been available for %1$d days %2$d hrs %3$d mins %4$d secs Score @@ -542,7 +543,7 @@ "Episode %1$s" "Chapter " "Chapter %1$s" - - just got released! + - Newly released! Checking Subscriptions %1$s\'s %2$s List @@ -566,7 +567,7 @@ Reset Close No Chapter - Turn on 18+ Content from your Anilist Settings + Turn on 18+ content from your Anilist settings Available Let\'s Go Cope @@ -632,10 +633,10 @@ How to enable NSFW content? You can enable NSFW content by enabling 18+ contents from this [link](https://anilist.co/settings/media). You also have to enable NSFW extensions in \`Settings > Extensions > NSFW extensions\` - How to import my MAL/Kitsu list to Anilist? + How to import my MAL/Kitsu lists to Anilist? Here is how you do it,\n\nExport:\n\n1. Go to this [link](https://malscraper.azurewebsites.net).\n2. Give your Kitsu/MAL username and download both anime and manga list. (They will be in XML format)\nNote: You have to write the username of the tracker you selected\n\nImport:\n\n1. After exporting your anime and manga list from Kitsu/MAL, now go [here](https://anilist.co/settings/import) \n2. Select/drop the anime XML file on the box above.\n|→Select/drop the manga XML file on the box below. - How to import my Anilist/Kitsu list to MAL? + How to import my Anilist/Kitsu lists to MAL? Here is how you do it,\n\nExport:\n\n1. Go to this [link](https://malscraper.azurewebsites.net/). \n2. Give your Anilist username/Kitsu ID in the \'Username/Kitsu User ID\' box. \n3. Select list type and enable \'update_on_import\'. \n4. Download the file; it will be in .xml format. Be sure to download both Anime and Manga lists.\n\nImport:\n1. To import it in your MAL account, go to this [link](https://myanimelist.net/import.php) and choose \'MyAnimeList Import\' as import type. \n2. Press on \'Choose File\'and select the downloaded anime/manga list XML file. \n3. Press on \'Import Data\'. \nCongratulations, you just imported the selected list to your MAL account. Why can\'t I find a specific anime/manga title? @@ -647,10 +648,10 @@ How to read coloured mangas? Are you in search of coloured manga? Sorry to break it to you but an extremely small amount of mangas have coloured version. Those which has a coloured version is also available in Dantotsu. Let\'s say you want to read the coloured version of chainsaw man. Then follow the below steps ↓\n\n1) Go to Chainsaw Man\n2) Press on \'Read\'\n3) Select any working source\n4) Press on \'Wrong Title\'\n5) Select the colored version chainsaw man\n6) Enjoy\n\nNote: Many sources don\'t have the coloured version available even if it\'s available somewhere on the internet. So try a different source. If none of the sources have it, then a coloured version of your desired manga simply doesn\'t exist. - Handshake fails? Why are no timestamps not loading? + Handshake fails? Why are no timestamps loading? You can fix this issue by enabling \'Proxy\' from \n\`Settings > Anime > Player Settings > Timestamps > Proxy\`.\nIf the timestamps are still not loading but the handshake failed popup is fixed, then the episode you are watching just doesn\'t have timestamps yet for it. - Can\'t find anything on a source? + Can\'t find anything in a source? Some basic fixes would be : \n\n• Update your extensions if there are any. \n• Open Web View and wait for it to load. After loading has completed, go back. (If Web View shows error 404 or something similar, chances are that your source is down)\n• Use a different DNS from your settings, preferably, Libre. \n• Try a trustworthy VPN. (You\'ll have to repeat step 1 after this) \n\nIf none of the steps above work then use a different source or join our [discord](https://discord.gg/invite/4HPZ5nAWwM) for help. Some useful tips and tricks