From 0f9bf3c5b1dd78ed449cc435aeb734ec2d09e7b1 Mon Sep 17 00:00:00 2001 From: rebel onion <87634197+rebelonion@users.noreply.github.com> Date: Wed, 20 Mar 2024 01:33:54 -0500 Subject: [PATCH 01/71] chore: Update stable.md --- stable.md | 61 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/stable.md b/stable.md index d7fc24f9..6ccecf07 100644 --- a/stable.md +++ b/stable.md @@ -1,29 +1,52 @@ -# 2.2.0 +# 3.0.0 -- **Important:** - - All settings will be reset due to the new settings system. Sorry for the inconvenience! +- **Many New Features:** + - ### Comment section + - Hosted by Dantotsu + - Tied to your Anilist account + - Features Reddit-style voting + - Tags for episodes/chapters + - Accepts markdown/discord formatting -- **New Features:** - - Import/Export settings - - New source organization system in extension settings - - Filter sources by language - - Defaulting to the external casting system (internal cast can be enabled in settings) - - sub/dub toggle for some sources (requires source settings page to be opened at least once) - - SoftSub downloads (when available) + - Profile pages + - Bio + - User favorites + - User activities + - User Lists + - Followers/Following + - Detailed user statistics + - Ability to compare stats to your account + + - Anilist Feeds + - Followed users feed + - Global feed + - Like/see who liked Activity + - Replying not implemented yet + + - Anilist Notifications + - Ability to filter by types in settings + - Past notification page + + - Staff info page + - New theme - Various UI uplifts - - Many small features (see beta changelogs) - - New easter egg :3 + - Filter User's lists by genre + - New Notification manager option for more reliable checking + - Can open a settings file outside of the app + - Can open profile links - **Bugfixes:** - - Many source fixes - - Better information on Anilist rate limiting - - User will get a notification when rate limited - - Rate limiting less likely to occur (especially on app startup) + - Some source fixes + - Genre/tag sorting is now alphabetic + - Fix the auto play not working for some people - Various bug/crash fixes - General theme tweaks - - Popups will now follow OLED mode - - Fix for file permissions on older Android versions - - Many small bug fixes (see beta changelogs) + - Subscriptions not working + - Many other bug fixes (It's been so long I forgor 💀) + + - A Special Thanks to all those who contributed <3 - **Like what you see?** - Consider supporting me on [Github](https://github.com/sponsors/rebelonion) or [Buy Me a Coffee](https://www.buymeacoffee.com/rebelonion)! + +![alt text](https://media1.tenor.com/m/P7hCyZlzDH4AAAAC/wink-anime.gif) From b5b7dac247be4aeada772b23d10989af8ee6108c Mon Sep 17 00:00:00 2001 From: rebel onion <87634197+rebelonion@users.noreply.github.com> Date: Thu, 4 Apr 2024 04:02:11 -0500 Subject: [PATCH 02/71] Update beta.yml --- .github/workflows/beta.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index a1277018..ef708935 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -75,18 +75,20 @@ jobs: - name: List files in the directory run: ls -l - + - name: Make gradlew executable run: chmod +x ./gradlew - name: Build with Gradle run: ./gradlew assembleGoogleAlpha -Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/key.keystore -Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} -Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} -Pandroid.injected.signing.key.password=${{ secrets.KEY_PASSWORD }} - - name: Upload a Build Artifact + - name: Upload Build Artifacts uses: actions/upload-artifact@v4.3.1 with: - name: Dantotsu - path: "app/build/outputs/apk/google/alpha/app-google-alpha.apk" + name: APKs + path: | + app/build/outputs/apk/google/alpha/*/*.apk + app/build/outputs/apk/google/alpha/*/*/*.apk - name: Upload APK to Discord and Telegram if: ${{ github.repository == 'rebelonion/Dantotsu' }} @@ -99,12 +101,12 @@ jobs: if [ ${#commit_messages} -gt $max_length ]; then commit_messages="${commit_messages:0:$max_length}... (truncated)" fi - contentbody=$( jq -nc --arg msg "Alpha-Build: <@714249925248024617> **$VERSION**:" --arg commits "$commit_messages" '{"content": ($msg + "\n" + $commits)}' ) - curl -F "payload_json=${contentbody}" -F "dantotsu_debug=@app/build/outputs/apk/google/alpha/app-google-alpha.apk" ${{ secrets.DISCORD_WEBHOOK }} + contentbody=$( jq -nc --arg msg "Alpha-Build: <@&1225347048321191996> **$VERSION**:" --arg commits "$commit_messages" '{"content": ($msg + "\n" + $commits)}' ) + curl -F "payload_json=${contentbody}" -F "dantotsu_debug=@app/build/outputs/apk/google/alpha/app-google-universal-alpha.apk" ${{ secrets.DISCORD_WEBHOOK }} #Telegram curl -F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \ - -F "document=@app/build/outputs/apk/google/alpha/app-google-alpha.apk" \ + -F "document=@app/build/outputs/apk/google/alpha/app-google-universal-alpha.apk" \ -F "caption=Alpha-Build: ${VERSION}: ${commit_messages}" \ https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument From 1dd3bddeb9616c64e0c4a4409698e7aae6d33273 Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Mon, 20 May 2024 07:28:35 -0500 Subject: [PATCH 03/71] fix: show only trusted --- .../ani/dantotsu/connections/github/Forks.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/connections/github/Forks.kt b/app/src/main/java/ani/dantotsu/connections/github/Forks.kt index d9ae6424..5e5301dc 100644 --- a/app/src/main/java/ani/dantotsu/connections/github/Forks.kt +++ b/app/src/main/java/ani/dantotsu/connections/github/Forks.kt @@ -1,26 +1,27 @@ package ani.dantotsu.connections.github -import ani.dantotsu.Mapper -import ani.dantotsu.client import ani.dantotsu.settings.Developer import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonArray -import kotlinx.serialization.json.decodeFromJsonElement class Forks { fun getForks(): Array { var forks = arrayOf() runBlocking(Dispatchers.IO) { - val res = - client.get("https://api.github.com/repos/rebelonion/Dantotsu/forks?sort=stargazers") - .parsed().map { - Mapper.json.decodeFromJsonElement(it) - } - res.forEach { + val trustedForks = arrayOf( + GithubResponse( + "Awery", + GithubResponse.Owner( + "MrBoomDeveloper", + "https://avatars.githubusercontent.com/u/92123190?v=4" + ), + "https://github.com/MrBoomDeveloper/Awery" + ), + ) + trustedForks.forEach { forks = forks.plus( Developer( it.name, From 2c3eb82e4b84210f45ff4a33ef968c568da1cb1d Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Mon, 20 May 2024 07:29:02 -0500 Subject: [PATCH 04/71] fix: show subscription name --- .../subscription/SubscriptionNotificationTask.kt | 3 +++ .../java/ani/dantotsu/parsers/ExtensionTestItem.kt | 12 ++---------- .../profile/activity/NotificationActivity.kt | 2 +- app/src/main/res/layout/item_notification.xml | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionNotificationTask.kt b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionNotificationTask.kt index 7ea81ae8..c138c29b 100644 --- a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionNotificationTask.kt +++ b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionNotificationTask.kt @@ -238,6 +238,9 @@ class SubscriptionNotificationTask : Task { if (newStore.size >= 100) { newStore.remove(newStore.minByOrNull { it.time }) } + if (newStore.any { it.title == notification.title && it.content == notification.content}) { + return + } newStore.add(notification) PrefManager.setVal(PrefName.SubscriptionNotificationStore, newStore) } diff --git a/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt b/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt index c87bf268..50e7af13 100644 --- a/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt +++ b/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt @@ -161,11 +161,7 @@ class ExtensionTestItem( serverResult() } - withContext(Dispatchers.Main) { - if (::binding.isInitialized ) - binding.extensionLoading.isVisible = false - isRunning = false - } + done() } private suspend fun runNovelTest(extension: NovelParser) { @@ -192,11 +188,7 @@ class ExtensionTestItem( serverResult() } - withContext(Dispatchers.Main) { - if (::binding.isInitialized ) - binding.extensionLoading.isVisible = false - isRunning = false - } + done() } private fun done() { diff --git a/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt b/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt index 30b0c525..372d5e80 100644 --- a/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt @@ -233,7 +233,7 @@ class NotificationActivity : AppCompatActivity() { commentId = it.mediaId, mediaId = it.mediaId, notificationType = it.type, - context = it.content, + context = it.title + ": " + it.content, createdAt = (it.time / 1000L).toInt(), ) newNotifications += notification diff --git a/app/src/main/res/layout/item_notification.xml b/app/src/main/res/layout/item_notification.xml index 8381200d..e194392b 100644 --- a/app/src/main/res/layout/item_notification.xml +++ b/app/src/main/res/layout/item_notification.xml @@ -92,7 +92,7 @@ android:layout_height="wrap_content" android:ellipsize="end" android:fontFamily="@font/poppins_bold" - android:maxLines="3" + android:maxLines="4" android:textSize="14dp" android:transitionName="mediaTitle" tools:ignore="SpUsage" From ea045c185da0025f9a2bc6251c30a8d9145aca65 Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Mon, 20 May 2024 08:34:46 -0500 Subject: [PATCH 05/71] fix: keep ui on the main thread --- .../main/java/ani/dantotsu/parsers/ExtensionTestItem.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt b/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt index 50e7af13..6a5f3753 100644 --- a/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt +++ b/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt @@ -191,10 +191,12 @@ class ExtensionTestItem( done() } - private fun done() { + private suspend fun done() { if (::binding.isInitialized.not()) return - binding.extensionLoading.isVisible = false - isRunning = false + withContext(Dispatchers.Main) { + binding.extensionLoading.isVisible = false + isRunning = false + } } private fun pingResult() { From 212bce09c843301851d799a738b72be8c5341193 Mon Sep 17 00:00:00 2001 From: Itsmechinmoy <167056923+itsmechinmoy@users.noreply.github.com> Date: Mon, 20 May 2024 19:12:32 +0530 Subject: [PATCH 06/71] Invisible Status Discord Rpc (#394) * Update SettingsAccountActivity.kt * Create discord_status_invisible.xml * Update discord_status_invisible.xml * Update discord_status_invisible.xml * Update SettingsAccountActivity.kt * Update SettingsAccountActivity.kt --- .../settings/SettingsAccountActivity.kt | 8 +++++++- .../res/drawable/discord_status_invisible.xml | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable/discord_status_invisible.xml diff --git a/app/src/main/java/ani/dantotsu/settings/SettingsAccountActivity.kt b/app/src/main/java/ani/dantotsu/settings/SettingsAccountActivity.kt index 362afcbb..7bebb68f 100644 --- a/app/src/main/java/ani/dantotsu/settings/SettingsAccountActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/SettingsAccountActivity.kt @@ -147,6 +147,7 @@ class SettingsAccountActivity : AppCompatActivity() { "online" -> R.drawable.discord_status_online "idle" -> R.drawable.discord_status_idle "dnd" -> R.drawable.discord_status_dnd + "invisible" -> R.drawable.discord_status_invisible else -> R.drawable.discord_status_online } settingsImageSwitcher.setImageResource(initialStatus) @@ -167,6 +168,11 @@ class SettingsAccountActivity : AppCompatActivity() { } R.drawable.discord_status_dnd -> { + status = "invisible" + R.drawable.discord_status_invisible + } + + R.drawable.discord_status_invisible -> { status = "online" R.drawable.discord_status_online } @@ -198,4 +204,4 @@ class SettingsAccountActivity : AppCompatActivity() { } } -} \ No newline at end of file +} diff --git a/app/src/main/res/drawable/discord_status_invisible.xml b/app/src/main/res/drawable/discord_status_invisible.xml new file mode 100644 index 00000000..3f33180a --- /dev/null +++ b/app/src/main/res/drawable/discord_status_invisible.xml @@ -0,0 +1,17 @@ + + + + + + From c2a10c233d112875d757dd83ee55d71fc2209a7f Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Mon, 20 May 2024 11:14:00 -0500 Subject: [PATCH 07/71] fix: null safe cast --- .../connections/anilist/AnilistQueries.kt | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt index 168eb619..468795c8 100644 --- a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt +++ b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt @@ -1091,11 +1091,11 @@ query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult: } else null else null } - } as ArrayList + }?.toCollection(ArrayList()) ?: arrayListOf() - list["trendingMovies"] = trendingMovies?.media?.map { Media(it) } as ArrayList - list["topRated"] = topRated?.media?.map { Media(it) } as ArrayList - list["mostFav"] = mostFav?.media?.map { Media(it) } as ArrayList + list["trendingMovies"] = trendingMovies?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf() + list["topRated"] = topRated?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf() + list["mostFav"] = mostFav?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf() list["recentUpdates"]?.addAll(recentUpdates2?.airingSchedules?.mapNotNull { i -> i.media?.let { @@ -1112,10 +1112,10 @@ query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult: } else null else null } - } as ArrayList) - list["trendingMovies"]?.addAll(trendingMovies2?.media?.map { Media(it) } as ArrayList) - list["topRated"]?.addAll(topRated2?.media?.map { Media(it) } as ArrayList) - list["mostFav"]?.addAll(mostFav2?.media?.map { Media(it) } as ArrayList) + }?.toCollection(ArrayList()) ?: arrayListOf()) + list["trendingMovies"]?.addAll(trendingMovies2?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf()) + list["topRated"]?.addAll(topRated2?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf()) + list["mostFav"]?.addAll(mostFav2?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf()) } return list } @@ -1164,19 +1164,20 @@ query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult: } executeQuery(query(), force = true)?.data?.apply { - list["trendingManga"] = trendingManga?.media?.map { Media(it) } as ArrayList - list["trendingManhwa"] = trendingManhwa?.media?.map { Media(it) } as ArrayList - list["trendingNovel"] = trendingNovel?.media?.map { Media(it) } as ArrayList - list["topRated"] = topRated?.media?.map { Media(it) } as ArrayList - list["mostFav"] = mostFav?.media?.map { Media(it) } as ArrayList - list["trendingManga"]?.addAll(trendingManga2?.media?.map { Media(it) } as ArrayList) - list["trendingManhwa"]?.addAll(trendingManhwa2?.media?.map { Media(it) } as ArrayList) - list["trendingNovel"]?.addAll(trendingNovel2?.media?.map { Media(it) } as ArrayList) - list["topRated"]?.addAll(topRated2?.media?.map { Media(it) } as ArrayList) - list["mostFav"]?.addAll(mostFav2?.media?.map { Media(it) } as ArrayList) + list["trendingManga"] = trendingManga?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf() + list["trendingManhwa"] = trendingManhwa?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf() + list["trendingNovel"] = trendingNovel?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf() + list["topRated"] = topRated?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf() + list["mostFav"] = mostFav?.media?.map { Media(it) }?.toCollection(ArrayList()) ?: arrayListOf() + list["trendingManga"]?.addAll(trendingManga2?.media?.map { Media(it) }?.toList() ?: arrayListOf()) + list["trendingManhwa"]?.addAll(trendingManhwa2?.media?.map { Media(it) }?.toList() ?: arrayListOf()) + list["trendingNovel"]?.addAll(trendingNovel2?.media?.map { Media(it) }?.toList() ?: arrayListOf()) + list["topRated"]?.addAll(topRated2?.media?.map { Media(it) }?.toList() ?: arrayListOf()) + list["mostFav"]?.addAll(mostFav2?.media?.map { Media(it) }?.toList() ?: arrayListOf()) } + return list } From 10df1986e80deccb83176246fe016565f8511c19 Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Mon, 20 May 2024 11:15:11 -0500 Subject: [PATCH 08/71] feat: video fixing options --- .../addons/download/DownloadAddonApiV2.kt | 6 ++ .../ani/dantotsu/download/DownloadsManager.kt | 2 +- .../download/anime/AnimeDownloaderService.kt | 3 +- .../media/anime/AnimeWatchFragment.kt | 90 +++++++++++++++++++ .../dantotsu/media/anime/EpisodeAdapters.kt | 10 +++ app/src/main/res/values/strings.xml | 4 +- 6 files changed, 112 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/addons/download/DownloadAddonApiV2.kt b/app/src/main/java/ani/dantotsu/addons/download/DownloadAddonApiV2.kt index b12f4bee..a54d1886 100644 --- a/app/src/main/java/ani/dantotsu/addons/download/DownloadAddonApiV2.kt +++ b/app/src/main/java/ani/dantotsu/addons/download/DownloadAddonApiV2.kt @@ -9,6 +9,8 @@ interface DownloadAddonApiV2 { fun setDownloadPath(context: Context, uri: Uri): String + fun getReadPath(context: Context, uri: Uri): String + suspend fun executeFFProbe( videoUrl: String, headers: Map = emptyMap(), @@ -24,6 +26,10 @@ interface DownloadAddonApiV2 { statCallback: (Double) -> Unit ): Long + suspend fun customFFMpeg(command: String, videoUrls: List, logCallback: (String) -> Unit): Long + + suspend fun customFFProbe(command: String, videoUrls: List, logCallback: (String) -> Unit) + fun getState(sessionId: Long): String fun getStackTrace(sessionId: Long): String? diff --git a/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt b/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt index eb2391ce..6d3a25cf 100644 --- a/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt +++ b/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt @@ -379,7 +379,7 @@ class DownloadsManager(private val context: Context) { private const val RESERVED_CHARS = "|\\?*<\":>+[]/'" fun String?.findValidName(): String { - return this?.filterNot { RESERVED_CHARS.contains(it) } ?: "" + return this?.replace("/","_")?.filterNot { RESERVED_CHARS.contains(it) } ?: "" } data class DownloadedType( diff --git a/app/src/main/java/ani/dantotsu/download/anime/AnimeDownloaderService.kt b/app/src/main/java/ani/dantotsu/download/anime/AnimeDownloaderService.kt index ac631b90..237d3b53 100644 --- a/app/src/main/java/ani/dantotsu/download/anime/AnimeDownloaderService.kt +++ b/app/src/main/java/ani/dantotsu/download/anime/AnimeDownloaderService.kt @@ -26,6 +26,7 @@ import ani.dantotsu.download.DownloadedType import ani.dantotsu.download.DownloadsManager import ani.dantotsu.download.DownloadsManager.Companion.getSubDirectory import ani.dantotsu.download.anime.AnimeDownloaderService.AnimeDownloadTask.Companion.getTaskName +import ani.dantotsu.download.findValidName import ani.dantotsu.media.Media import ani.dantotsu.media.MediaType import ani.dantotsu.media.anime.AnimeWatchFragment @@ -224,7 +225,7 @@ class AnimeDownloaderService : Service() { task.episode ) ?: throw Exception("Failed to create output directory") - outputDir.findFile("${task.getTaskName()}.mkv")?.delete() + outputDir.findFile("${task.getTaskName().findValidName()}.mkv")?.delete() val outputFile = outputDir.createFile("video/x-matroska", "${task.getTaskName()}.mkv") ?: throw Exception("Failed to create output file") diff --git a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt index 4c155b48..363d233a 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt @@ -30,11 +30,14 @@ import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 import ani.dantotsu.FileUrl import ani.dantotsu.R +import ani.dantotsu.addons.download.DownloadAddonManager import ani.dantotsu.databinding.FragmentAnimeWatchBinding import ani.dantotsu.download.DownloadedType import ani.dantotsu.download.DownloadsManager import ani.dantotsu.download.DownloadsManager.Companion.compareName +import ani.dantotsu.download.DownloadsManager.Companion.getSubDirectory import ani.dantotsu.download.anime.AnimeDownloaderService +import ani.dantotsu.download.findValidName import ani.dantotsu.dp import ani.dantotsu.isOnline import ani.dantotsu.media.Media @@ -54,15 +57,20 @@ import ani.dantotsu.settings.extensionprefs.AnimeSourcePreferencesFragment import ani.dantotsu.settings.saving.PrefManager import ani.dantotsu.settings.saving.PrefName import ani.dantotsu.snackString +import ani.dantotsu.toast +import ani.dantotsu.util.Logger import ani.dantotsu.util.StoragePermissions.Companion.accessAlertDialog import ani.dantotsu.util.StoragePermissions.Companion.hasDirAccess +import com.anggrayudi.storage.file.extension import com.google.android.material.appbar.AppBarLayout import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.launch +import tachiyomi.core.util.lang.launchIO import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import kotlin.math.ceil @@ -492,6 +500,88 @@ class AnimeWatchFragment : Fragment() { } } + @kotlin.OptIn(DelicateCoroutinesApi::class) + fun fixDownload(i: String) { + toast(R.string.running_fixes) + launchIO { + try { + val context = context ?: throw Exception("Context is null") + val directory = + getSubDirectory(context, MediaType.ANIME, false, media.mainName(), i) + ?: throw Exception("Directory is null") + val files = directory.listFiles() + val videoFiles = files.filter { it.extension == "mp4" || it.extension == "mkv" } + if (videoFiles.size != 1) { + val biggest = + videoFiles.filter { it.length() > 1000 }.maxByOrNull { it.length() } + ?: throw Exception("No video files found") + val newName = + AnimeDownloaderService.AnimeDownloadTask.getTaskName(media.mainName(), i) + .findValidName() + "." + biggest.extension + videoFiles.forEach { + if (it != biggest) { + it.delete() + } + } + if (newName != biggest.name) { + biggest.renameTo(newName) + } + toast(context.getString(R.string.success) + " (1)") + } else { + val tempFile = + directory.createFile("video/x-matroska", "temp.mkv") + ?: throw Exception("Temp file is null") + val ffExtension = Injekt.get().extension?.extension!! + val tempPath = ffExtension.setDownloadPath( + context, + tempFile.uri + ) + val videoPath = ffExtension.getReadPath( + context, + videoFiles[0].uri + ) + + val id = ffExtension.customFFMpeg( + "1", listOf(videoPath, tempPath) + ) { log -> + Logger.log(log) + } + val timeOut = System.currentTimeMillis() + 1000 * 60 * 10 + while (ffExtension.getState(id) != "COMPLETED") { + if (ffExtension.getState(id) == "FAILED") { + Logger.log("Failed to fix download") + ffExtension.getStackTrace(id)?.let { + Logger.log(it) + } + toast(R.string.failed_to_fix) + return@launchIO + } + if (System.currentTimeMillis() > timeOut) { + Logger.log("Failed to fix download: Timeout") + toast(R.string.failed_to_fix) + return@launchIO + } + } + if (ffExtension.hadError(id)) { + Logger.log("Failed to fix download: ${ffExtension.getStackTrace(id)}") + toast(R.string.failed_to_fix) + return@launchIO + } + val name = videoFiles[0].name + if (videoFiles[0].delete().not()) { + toast(R.string.delete_fail) + return@launchIO + } + tempFile.renameTo(name!!) + toast(context.getString(R.string.success) + " (2)") + } + } catch (e: Exception) { + toast(getString(R.string.error_msg, e.message)) + Logger.log(e) + } + } + } + private val downloadStatusReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if (!this@AnimeWatchFragment::episodeAdapter.isInitialized) return diff --git a/app/src/main/java/ani/dantotsu/media/anime/EpisodeAdapters.kt b/app/src/main/java/ani/dantotsu/media/anime/EpisodeAdapters.kt index 27bd887a..14be291a 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/EpisodeAdapters.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/EpisodeAdapters.kt @@ -334,6 +334,16 @@ class EpisodeAdapter( } } } + binding.itemDownload.setOnLongClickListener { + if (0 <= bindingAdapterPosition && bindingAdapterPosition < arr.size) { + val episodeNumber = arr[bindingAdapterPosition].number + if (downloadedEpisodes.contains(episodeNumber)) { + fragment.fixDownload(episodeNumber) + } + } + + true + } binding.itemEpisodeDesc.setOnClickListener { if (binding.itemEpisodeDesc.maxLines == 3) binding.itemEpisodeDesc.maxLines = 100 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9b7b1eda..f699531f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -811,7 +811,7 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc Are you sure you want to purge all %1$s downloads? Failed to delete because of… %1$s - + Failed to delete Hide replies View reply View replies @@ -1017,4 +1017,6 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc Video Search Test: %1$s Image Search Test: %1$s Book Search Test: %1$s + Failed to fix + Running Fixes… From fe1a7af7acad7e141802dd592a8f9d3867f7fb4d Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Mon, 20 May 2024 11:49:57 -0500 Subject: [PATCH 09/71] feat: test ms response --- .../ani/dantotsu/parsers/ExtensionTestItem.kt | 97 ++++++++++++------- .../ExtensionTestSettingsBottomDialog.kt | 22 +++++ .../dantotsu/parsers/ParserTestActivity.kt | 9 +- .../bottom_sheet_extension_test_settings.xml | 49 ++++++++++ app/src/main/res/values/strings.xml | 1 + 5 files changed, 139 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt b/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt index 6a5f3753..073c466c 100644 --- a/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt +++ b/app/src/main/java/ani/dantotsu/parsers/ExtensionTestItem.kt @@ -1,5 +1,6 @@ package ani.dantotsu.parsers +import android.annotation.SuppressLint import android.content.Context import android.view.View import androidx.core.view.isVisible @@ -17,16 +18,16 @@ class ExtensionTestItem( private var extensionType: String, private var testType: String, private var extension: BaseParser, - private var searchString: String = "Chainsaw Man" + private var searchString: String ) : BindableItem() { private lateinit var binding: ItemExtensionTestBinding private lateinit var context: Context private var job: Job? = null private var isRunning = false private var pingResult: Triple? = null - private var searchResultSize: Int? = null - private var episodeResultSize: Int? = null - private var serverResultSize: Int? = null + private var searchResultData: TestResult = TestResult() + private var episodeResultData: TestResult = TestResult() + private var serverResultData: TestResult = TestResult() override fun bind(viewBinding: ItemExtensionTestBinding, position: Int) { binding = viewBinding @@ -36,6 +37,7 @@ class ExtensionTestItem( binding.extensionLoading.isVisible = isRunning hideAllResults() + println(searchString) pingResult() searchResult() episodeResult() @@ -65,9 +67,9 @@ class ExtensionTestItem( fun startTest() { pingResult = null - searchResultSize = null - episodeResultSize = null - serverResultSize = null + searchResultData = TestResult() + episodeResultData = TestResult() + serverResultData = TestResult() isRunning = true hideAllResults() job?.cancel() @@ -101,26 +103,32 @@ class ExtensionTestItem( done() return } + val searchStart = System.currentTimeMillis() val searchResult = extension.search(searchString) - searchResultSize = searchResult.size + searchResultData.time = (System.currentTimeMillis() - searchStart).toInt() + searchResultData.size = searchResult.size withContext(Dispatchers.Main) { searchResult() } - if (searchResultSize == 0 || testType == "basic") { + if (searchResultData.size == 0 || testType == "basic") { done() return } + val episodeResultTime = System.currentTimeMillis() val episodeResult = extension.loadEpisodes("", null, searchResult.first().sAnime!!) - episodeResultSize = episodeResult.size + episodeResultData.time = (System.currentTimeMillis() - episodeResultTime).toInt() + episodeResultData.size = episodeResult.size withContext(Dispatchers.Main) { episodeResult() } - if (episodeResultSize == 0) { + if (episodeResultData.size == 0) { done() return } + val serverResultTime = System.currentTimeMillis() val serverResult = extension.loadVideoServers("", null, episodeResult.first().sEpisode!!) - serverResultSize = serverResult.size + serverResultData.time = (System.currentTimeMillis() - serverResultTime).toInt() + serverResultData.size = serverResult.size withContext(Dispatchers.Main) { serverResult() } @@ -137,26 +145,32 @@ class ExtensionTestItem( done() return } + val searchStart = System.currentTimeMillis() val searchResult = extension.search(searchString) - searchResultSize = searchResult.size + searchResultData.time = (System.currentTimeMillis() - searchStart).toInt() + searchResultData.size = searchResult.size withContext(Dispatchers.Main) { searchResult() } - if (searchResultSize == 0 || testType == "basic") { + if (searchResultData.size == 0 || testType == "basic") { done() return } + val episodeResultStart = System.currentTimeMillis() val chapterResult = extension.loadChapters("", null, searchResult.first().sManga!!) - episodeResultSize = chapterResult.size + episodeResultData.time = (System.currentTimeMillis() - episodeResultStart).toInt() + episodeResultData.size = chapterResult.size withContext(Dispatchers.Main) { episodeResult() } - if (episodeResultSize == 0) { + if (episodeResultData.size == 0) { done() return } + val serverResultStart = System.currentTimeMillis() val serverResult = extension.loadImages("", chapterResult.first().sChapter) - serverResultSize = serverResult.size + serverResultData.time = (System.currentTimeMillis() - serverResultStart).toInt() + serverResultData.size = serverResult.size withContext(Dispatchers.Main) { serverResult() } @@ -172,17 +186,21 @@ class ExtensionTestItem( done() return } + val searchStart = System.currentTimeMillis() val searchResult = extension.search(searchString) - searchResultSize = searchResult.size + searchResultData.time = (System.currentTimeMillis() - searchStart).toInt() + searchResultData.size = searchResult.size withContext(Dispatchers.Main) { searchResult() } - if (searchResultSize == 0 || testType == "basic") { + if (searchResultData.size == 0 || testType == "basic") { done() return } + val chapterResultTime = System.currentTimeMillis() val chapterResult = extension.loadBook(searchResult.first().link, null) - episodeResultSize = chapterResult.links.size + episodeResultData.time = (System.currentTimeMillis() - chapterResultTime).toInt() + episodeResultData.size = chapterResult.links.size withContext(Dispatchers.Main) { episodeResult() serverResult() @@ -236,9 +254,10 @@ class ExtensionTestItem( ) } + @SuppressLint("SetTextI18n") private fun searchResult() { if (::binding.isInitialized.not()) return - if (searchResultSize == null) { + if (searchResultData.time == 0) { binding.searchResultText.isVisible = false return } @@ -246,7 +265,7 @@ class ExtensionTestItem( context.getThemeColor(com.google.android.material.R.attr.colorPrimary) ) binding.searchResultText.isVisible = true - if (searchResultSize == 0) { + if (searchResultData.size == 0) { val text = context.getString(R.string.title_search_test, context.getString(R.string.no_results_found)) binding.searchResultText.text = text @@ -259,16 +278,17 @@ class ExtensionTestItem( return } val text = context.getString(R.string.title_search_test, - context.getString(R.string.results_found, searchResultSize.toString())) - binding.searchResultText.text = text + context.getString(R.string.results_found, searchResultData.size.toString())) + binding.searchResultText.text = text + "\n${searchResultData.time}ms" binding.searchResultText.setCompoundDrawablesWithIntrinsicBounds( R.drawable.ic_circle_check, 0, 0, 0 ) } + @SuppressLint("SetTextI18n") private fun episodeResult() { if (::binding.isInitialized.not()) return - if (episodeResultSize == null) { + if (episodeResultData.time == 0) { binding.episodeResultText.isVisible = false return } @@ -276,7 +296,7 @@ class ExtensionTestItem( context.getThemeColor(com.google.android.material.R.attr.colorPrimary) ) binding.episodeResultText.isVisible = true - if (episodeResultSize == 0) { + if (episodeResultData.size == 0) { val text = when(extensionType) { "anime" -> context.getString(R.string.episode_search_test, context.getString(R.string.no_results_found)) @@ -296,18 +316,19 @@ class ExtensionTestItem( } val text = when(extensionType) { "anime" -> context.getString(R.string.episode_search_test, - context.getString(R.string.results_found, episodeResultSize.toString())) + context.getString(R.string.results_found, episodeResultData.size.toString())) "manga" -> context.getString(R.string.chapter_search_test, - context.getString(R.string.results_found, episodeResultSize.toString())) + context.getString(R.string.results_found, episodeResultData.size.toString())) else -> context.getString(R.string.book_search_test, - context.getString(R.string.results_found, episodeResultSize.toString())) + context.getString(R.string.results_found, episodeResultData.size.toString())) } - binding.episodeResultText.text = text + binding.episodeResultText.text = text + "\n${episodeResultData.time}ms" binding.episodeResultText.setCompoundDrawablesWithIntrinsicBounds( R.drawable.ic_circle_check, 0, 0, 0 ) } + @SuppressLint("SetTextI18n") private fun serverResult() { if (::binding.isInitialized.not()) return if (extensionType == "novel") { @@ -318,7 +339,7 @@ class ExtensionTestItem( ) return } - if (serverResultSize == null) { + if (serverResultData.time == 0) { binding.serverResultText.isVisible = false return } @@ -326,7 +347,7 @@ class ExtensionTestItem( context.getThemeColor(com.google.android.material.R.attr.colorPrimary) ) binding.serverResultText.isVisible = true - if (serverResultSize == 0) { + if (serverResultData.size == 0) { val text = when(extensionType) { "anime" -> context.getString(R.string.video_search_test, context.getString(R.string.no_results_found)) @@ -335,7 +356,7 @@ class ExtensionTestItem( else -> context.getString(R.string.book_search_test, context.getString(R.string.no_results_found)) } - binding.serverResultText.text = text + binding.serverResultText.text = text + "\n${serverResultData.time}ms" binding.serverResultText.setCompoundDrawablesWithIntrinsicBounds( R.drawable.ic_circle_cancel, 0, 0, 0 ) @@ -346,11 +367,11 @@ class ExtensionTestItem( } val text = when(extensionType) { "anime" -> context.getString(R.string.video_search_test, - context.getString(R.string.results_found, serverResultSize.toString())) + context.getString(R.string.results_found, serverResultData.size.toString())) "manga" -> context.getString(R.string.image_search_test, - context.getString(R.string.results_found, serverResultSize.toString())) + context.getString(R.string.results_found, serverResultData.size.toString())) else -> context.getString(R.string.book_search_test, - context.getString(R.string.results_found, serverResultSize.toString())) + context.getString(R.string.results_found, serverResultData.size.toString())) } binding.serverResultText.text = text binding.serverResultText.setCompoundDrawablesWithIntrinsicBounds( @@ -358,4 +379,8 @@ class ExtensionTestItem( ) } + data class TestResult( + var size: Int = 0, + var time: Int = 0, + ) } \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/parsers/ExtensionTestSettingsBottomDialog.kt b/app/src/main/java/ani/dantotsu/parsers/ExtensionTestSettingsBottomDialog.kt index fcedad3f..1b7777ea 100644 --- a/app/src/main/java/ani/dantotsu/parsers/ExtensionTestSettingsBottomDialog.kt +++ b/app/src/main/java/ani/dantotsu/parsers/ExtensionTestSettingsBottomDialog.kt @@ -5,6 +5,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.widget.addTextChangedListener import androidx.recyclerview.widget.LinearLayoutManager import ani.dantotsu.BottomSheetDialogFragment import ani.dantotsu.databinding.BottomSheetExtensionTestSettingsBinding @@ -39,6 +40,26 @@ class ExtensionTestSettingsBottomDialog : BottomSheetDialogFragment() { LinearLayoutManager.VERTICAL, false ) + binding.searchViewText.setText(searchQuery) + binding.searchViewText.addTextChangedListener { + searchQuery = it.toString() + } + binding.extensionTypeRadioGroup.check( + when (extensionType) { + "anime" -> binding.animeRadioButton.id + "manga" -> binding.mangaRadioButton.id + "novel" -> binding.novelsRadioButton.id + else -> binding.animeRadioButton.id + } + ) + binding.testTypeRadioGroup.check( + when (testType) { + "ping" -> binding.pingRadioButton.id + "basic" -> binding.basicRadioButton.id + "full" -> binding.fullRadioButton.id + else -> binding.pingRadioButton.id + } + ) binding.animeRadioButton.setOnCheckedChangeListener { _, b -> if (b) { extensionType = "anime" @@ -112,6 +133,7 @@ class ExtensionTestSettingsBottomDialog : BottomSheetDialogFragment() { var extensionType = "anime" var testType = "ping" + var searchQuery = "Chainsaw Man" var extensionsToTest: MutableList = mutableListOf() } } \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/parsers/ParserTestActivity.kt b/app/src/main/java/ani/dantotsu/parsers/ParserTestActivity.kt index 7be91fe2..7d7f67f5 100644 --- a/app/src/main/java/ani/dantotsu/parsers/ParserTestActivity.kt +++ b/app/src/main/java/ani/dantotsu/parsers/ParserTestActivity.kt @@ -66,7 +66,8 @@ class ParserTestActivity : AppCompatActivity() { ExtensionTestItem( "anime", ExtensionTestSettingsBottomDialog.testType, - it + it, + ExtensionTestSettingsBottomDialog.searchQuery ) ) } @@ -81,7 +82,8 @@ class ParserTestActivity : AppCompatActivity() { ExtensionTestItem( "manga", ExtensionTestSettingsBottomDialog.testType, - it + it, + ExtensionTestSettingsBottomDialog.searchQuery ) ) } @@ -96,7 +98,8 @@ class ParserTestActivity : AppCompatActivity() { ExtensionTestItem( "novel", ExtensionTestSettingsBottomDialog.testType, - it + it, + ExtensionTestSettingsBottomDialog.searchQuery ) ) } diff --git a/app/src/main/res/layout/bottom_sheet_extension_test_settings.xml b/app/src/main/res/layout/bottom_sheet_extension_test_settings.xml index bacd922a..55df828e 100644 --- a/app/src/main/res/layout/bottom_sheet_extension_test_settings.xml +++ b/app/src/main/res/layout/bottom_sheet_extension_test_settings.xml @@ -3,6 +3,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools" + xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_marginVertical="16dp" android:orientation="vertical"> @@ -16,6 +17,7 @@ android:textSize="16sp" /> @@ -57,6 +59,7 @@ android:textSize="16sp" /> @@ -87,6 +90,52 @@ + + + + + + + Book Search Test: %1$s Failed to fix Running Fixes… + Test Search From b3ed8acd5b480b005971b71cc6168b8262bb8acd Mon Sep 17 00:00:00 2001 From: rebel onion <87634197+rebelonion@users.noreply.github.com> Date: Tue, 21 May 2024 08:33:08 -0500 Subject: [PATCH 10/71] Update LICENSE.md --- LICENSE.md | 675 +---------------------------------------------------- 1 file changed, 9 insertions(+), 666 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index f288702d..8f34e383 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,674 +1,17 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 +## Unabandon Public License (UPL) - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +**Preamble** - Preamble +This Unabandon Public License (UPL) is designed to ensure the continued development and public availability of source code based on works released under the GNU General Public License Version 3 (GPLv3) while upholding the core principles of GPLv3. This license extends GPLv3 by mandating public accessibility of source code for any derivative works. - The GNU General Public License is a free, copyleft license for -software and other kinds of works. +**Body** - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. +1. **Incorporation of GPLv3:** This UPL incorporates all terms and conditions of the GNU General Public License Version 3 (GPLv3) as published by the Free Software Foundation. You can find the complete text of GPLv3 at [https://www.gnu.org/licenses/licenses.en.html](https://www.gnu.org/licenses/licenses.en.html). - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. +2. **Public Source Requirement:** In addition to the terms of GPLv3, the source code for any software distributed under this license, including modifications and derivative works, must be publicly available. Public availability means the source code must be accessible to anyone through a publicly accessible repository or download link without any access restrictions or fees. - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. +3. **Source Code Availability:** The source code must be made publicly available using a recognized open-source hosting platform (e.g., GitHub, GitLab) or be downloadable from a publicly accessible website. The chosen method must clearly identify the source code and its corresponding licensed work. - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. +**Termination** - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. +This UPL terminates automatically if the terms and conditions are not followed by the licensee. From 66805bdf05696bdf67c79393cb31d786b07a6a5e Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Tue, 21 May 2024 11:28:46 -0500 Subject: [PATCH 11/71] fix: list view crash --- .../ani/dantotsu/home/AnimePageAdapter.kt | 4 +-- .../java/ani/dantotsu/home/HomeFragment.kt | 8 ++--- .../ani/dantotsu/home/MangaPageAdapter.kt | 4 +-- .../dantotsu/media/MediaListViewActivity.kt | 7 +++- .../ExtensionTestSettingsBottomDialog.kt | 2 +- .../res/layout/activity_media_list_view.xml | 36 +++++++++---------- 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt index 605d1cab..df0e0939 100644 --- a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt @@ -268,11 +268,11 @@ class AnimePageAdapter : RecyclerView.Adapter), + .putExtra("title", string), null ) } diff --git a/app/src/main/java/ani/dantotsu/home/HomeFragment.kt b/app/src/main/java/ani/dantotsu/home/HomeFragment.kt index bedc73ea..fc729b9d 100644 --- a/app/src/main/java/ani/dantotsu/home/HomeFragment.kt +++ b/app/src/main/java/ani/dantotsu/home/HomeFragment.kt @@ -233,10 +233,10 @@ class HomeFragment : Fragment() { false ) more.setOnClickListener { i -> + MediaListViewActivity.passedMedia = it ContextCompat.startActivity( i.context, Intent(i.context, MediaListViewActivity::class.java) - .putExtra("title", string) - .putExtra("media", it), + .putExtra("title", string), null ) } @@ -393,11 +393,11 @@ class HomeFragment : Fragment() { true } binding.homeHiddenItemsMore.setSafeOnClickListener { _ -> + MediaListViewActivity.passedMedia = it ContextCompat.startActivity( requireActivity(), Intent(requireActivity(), MediaListViewActivity::class.java) - .putExtra("title", getString(R.string.hidden)) - .putExtra("media", it), + .putExtra("title", getString(R.string.hidden)), null ) } diff --git a/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt b/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt index e26c7347..2e3e6a8c 100644 --- a/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt @@ -271,10 +271,10 @@ class MangaPageAdapter : RecyclerView.Adapter), + .putExtra("title", string), null ) } diff --git a/app/src/main/java/ani/dantotsu/media/MediaListViewActivity.kt b/app/src/main/java/ani/dantotsu/media/MediaListViewActivity.kt index 32011d0f..60a9e898 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaListViewActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaListViewActivity.kt @@ -52,7 +52,8 @@ class MediaListViewActivity: AppCompatActivity() { binding.listAppBar.setBackgroundColor(primaryColor) binding.listTitle.setTextColor(primaryTextColor) val screenWidth = resources.displayMetrics.run { widthPixels / density } - val mediaList = intent.getSerialized("media") as? ArrayList ?: ArrayList() + val mediaList = passedMedia ?: intent.getSerialized("media") as? ArrayList ?: ArrayList() + if (passedMedia != null) passedMedia = null val view = PrefManager.getCustomVal("mediaView", 0) var mediaView: View = when (view) { 1 -> binding.mediaList @@ -85,4 +86,8 @@ class MediaListViewActivity: AppCompatActivity() { if (view == 1) 1 else (screenWidth / 120f).toInt() ) } + + companion object { + var passedMedia: ArrayList? = null + } } diff --git a/app/src/main/java/ani/dantotsu/parsers/ExtensionTestSettingsBottomDialog.kt b/app/src/main/java/ani/dantotsu/parsers/ExtensionTestSettingsBottomDialog.kt index 1b7777ea..5bd6bb85 100644 --- a/app/src/main/java/ani/dantotsu/parsers/ExtensionTestSettingsBottomDialog.kt +++ b/app/src/main/java/ani/dantotsu/parsers/ExtensionTestSettingsBottomDialog.kt @@ -132,7 +132,7 @@ class ExtensionTestSettingsBottomDialog : BottomSheetDialogFragment() { } var extensionType = "anime" - var testType = "ping" + var testType = "basic" var searchQuery = "Chainsaw Man" var extensionsToTest: MutableList = mutableListOf() } diff --git a/app/src/main/res/layout/activity_media_list_view.xml b/app/src/main/res/layout/activity_media_list_view.xml index 987a3b34..04a8af11 100644 --- a/app/src/main/res/layout/activity_media_list_view.xml +++ b/app/src/main/res/layout/activity_media_list_view.xml @@ -1,14 +1,11 @@ - - - - - - - - + + + From fd42533b40741cd42ca2983d1851db4dbeb56e38 Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Tue, 21 May 2024 12:20:31 -0500 Subject: [PATCH 12/71] fix: attribution --- .../java/ani/dantotsu/addons/torrent/TorrentService.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/ani/dantotsu/addons/torrent/TorrentService.kt b/app/src/main/java/ani/dantotsu/addons/torrent/TorrentService.kt index 582bbf83..295ae176 100644 --- a/app/src/main/java/ani/dantotsu/addons/torrent/TorrentService.kt +++ b/app/src/main/java/ani/dantotsu/addons/torrent/TorrentService.kt @@ -1,3 +1,10 @@ +/** + * modified source from + * https://github.com/rebelonion/Dantotsu/pull/305 + * and https://github.com/LuftVerbot/kuukiyomi + * all credits to the original authors + */ + package ani.dantotsu.addons.torrent import android.app.ActivityManager From 039e3d63fe053c0d97cae820d247e093a88b6e36 Mon Sep 17 00:00:00 2001 From: aayush262 Date: Wed, 22 May 2024 00:20:40 +0530 Subject: [PATCH 13/71] feat: banner and cover for airing notifications --- .../ani/dantotsu/connections/anilist/api/Notification.kt | 2 ++ .../notifications/subscription/SubscriptionHelper.kt | 6 ++++-- .../subscription/SubscriptionNotificationTask.kt | 8 ++++---- .../notifications/subscription/SubscriptionStore.kt | 2 ++ .../ani/dantotsu/profile/activity/NotificationActivity.kt | 2 ++ .../ani/dantotsu/profile/activity/NotificationItem.kt | 8 ++++---- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/connections/anilist/api/Notification.kt b/app/src/main/java/ani/dantotsu/connections/anilist/api/Notification.kt index ac404203..3928cf86 100644 --- a/app/src/main/java/ani/dantotsu/connections/anilist/api/Notification.kt +++ b/app/src/main/java/ani/dantotsu/connections/anilist/api/Notification.kt @@ -111,6 +111,8 @@ data class Notification( val thread: Thread? = null, @SerialName("comment") val comment: ThreadComment? = null, + val image: String? = null, + val banner: String? = null, ) : java.io.Serializable @Serializable diff --git a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt index 08104de1..f03b1148 100644 --- a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt +++ b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt @@ -146,7 +146,8 @@ class SubscriptionHelper { val isAdult: Boolean, val id: Int, val name: String, - val image: String? + val image: String?, + val banner: String? = null ) : java.io.Serializable private const val SUBSCRIPTIONS = "subscriptions" @@ -188,7 +189,8 @@ class SubscriptionHelper { media.isAdult, media.id, media.userPreferredName, - media.cover + media.cover, + media.banner ) data[media.id] = new } diff --git a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionNotificationTask.kt b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionNotificationTask.kt index c138c29b..efdb1bda 100644 --- a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionNotificationTask.kt +++ b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionNotificationTask.kt @@ -122,7 +122,9 @@ class SubscriptionNotificationTask : Task { SubscriptionStore( media.name, text.first, - media.id + media.id, + image = media.image, + banner = media.banner ) ) PrefManager.setVal(PrefName.UnreadCommentNotifications, @@ -238,9 +240,7 @@ class SubscriptionNotificationTask : Task { if (newStore.size >= 100) { newStore.remove(newStore.minByOrNull { it.time }) } - if (newStore.any { it.title == notification.title && it.content == notification.content}) { - return - } + newStore.add(notification) PrefManager.setVal(PrefName.SubscriptionNotificationStore, newStore) } diff --git a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionStore.kt b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionStore.kt index dfb910f5..381f2f75 100644 --- a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionStore.kt +++ b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionStore.kt @@ -9,6 +9,8 @@ data class SubscriptionStore( val mediaId: Int, val type: String = "SUBSCRIPTION", val time: Long = System.currentTimeMillis(), + val image: String? = "", + val banner: String? = "", ) : java.io.Serializable { companion object { private const val serialVersionUID = 1L diff --git a/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt b/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt index 372d5e80..def4e73f 100644 --- a/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt @@ -235,6 +235,8 @@ class NotificationActivity : AppCompatActivity() { notificationType = it.type, context = it.title + ": " + it.content, createdAt = (it.time / 1000L).toInt(), + image = it.image, + banner = it.banner ) newNotifications += notification } diff --git a/app/src/main/java/ani/dantotsu/profile/activity/NotificationItem.kt b/app/src/main/java/ani/dantotsu/profile/activity/NotificationItem.kt index 23224184..d0e932d9 100644 --- a/app/src/main/java/ani/dantotsu/profile/activity/NotificationItem.kt +++ b/app/src/main/java/ani/dantotsu/profile/activity/NotificationItem.kt @@ -32,12 +32,12 @@ class NotificationItem( return ItemNotificationBinding.bind(view) } - private fun image(user: Boolean = false, commentNotification: Boolean = false) { + private fun image(user: Boolean = false, commentNotification: Boolean = false, newRelease: Boolean = false) { val cover = if (user) notification.user?.bannerImage ?: notification.user?.avatar?.medium else notification.media?.bannerImage ?: notification.media?.coverImage?.large - blurImage(binding.notificationBannerImage, cover) + blurImage(binding.notificationBannerImage, if (newRelease) notification.banner else cover) val defaultHeight = 153.toPx @@ -64,7 +64,7 @@ class NotificationItem( binding.notificationCover.visibility = View.VISIBLE binding.notificationCoverUser.visibility = View.VISIBLE binding.notificationCoverUserContainer.visibility = View.GONE - binding.notificationCover.loadImage(notification.media?.coverImage?.large) + binding.notificationCover.loadImage(if (newRelease) notification.image else notification.media?.coverImage?.large) binding.notificationBannerImage.layoutParams.height = defaultHeight binding.notificationGradiant.layoutParams.height = defaultHeight (binding.notificationTextContainer.layoutParams as ViewGroup.MarginLayoutParams).marginStart = @@ -334,7 +334,7 @@ class NotificationItem( } NotificationType.SUBSCRIPTION -> { - image(user = true, commentNotification = true) + image(newRelease = true) binding.notificationCoverUser.setOnClickListener { clickCallback( notification.mediaId ?: 0, null, NotificationClickType.MEDIA From 48ccb2c581b88a04928e9470e5c623b14347e16c Mon Sep 17 00:00:00 2001 From: aayush262 Date: Wed, 22 May 2024 00:20:59 +0530 Subject: [PATCH 14/71] feat : qol things --- app/src/main/java/ani/dantotsu/Functions.kt | 9 +++ .../ani/dantotsu/connections/github/Forks.kt | 55 ------------------- .../ani/dantotsu/media/MediaInfoFragment.kt | 19 +------ .../java/ani/dantotsu/media/ReviewActivity.kt | 14 +---- .../java/ani/dantotsu/media/ReviewAdapter.kt | 46 +++++++++++++++- .../ani/dantotsu/media/ReviewViewActivity.kt | 18 ++++++ .../dantotsu/media/comments/CommentItem.kt | 12 ++-- .../ani/dantotsu/profile/ProfileActivity.kt | 23 +++----- .../dantotsu/settings/ForksDialogFragment.kt | 12 +++- 9 files changed, 98 insertions(+), 110 deletions(-) delete mode 100644 app/src/main/java/ani/dantotsu/connections/github/Forks.kt diff --git a/app/src/main/java/ani/dantotsu/Functions.kt b/app/src/main/java/ani/dantotsu/Functions.kt index 57419e43..fb676247 100644 --- a/app/src/main/java/ani/dantotsu/Functions.kt +++ b/app/src/main/java/ani/dantotsu/Functions.kt @@ -84,6 +84,7 @@ import androidx.core.view.updateLayoutParams import androidx.core.view.updatePadding import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentManager import androidx.lifecycle.MutableLiveData import androidx.recyclerview.widget.RecyclerView @@ -96,6 +97,7 @@ import ani.dantotsu.connections.crashlytics.CrashlyticsInterface import ani.dantotsu.databinding.ItemCountDownBinding import ani.dantotsu.media.Media import ani.dantotsu.notifications.IncognitoNotificationClickReceiver +import ani.dantotsu.others.ImageViewDialog import ani.dantotsu.others.SpoilerPlugin import ani.dantotsu.parsers.ShowResponse import ani.dantotsu.settings.saving.PrefManager @@ -1392,6 +1394,13 @@ fun Context.getThemeColor(@AttrRes attribute: Int): Int { theme.resolveAttribute(attribute, typedValue, true) return typedValue.data } +fun ImageView.openImage(title: String, image: String) { + setOnLongClickListener{ + ImageViewDialog.newInstance( + context as FragmentActivity, title, image + ) + } +} /** * Builds the markwon instance with all the plugins * @return the markwon instance diff --git a/app/src/main/java/ani/dantotsu/connections/github/Forks.kt b/app/src/main/java/ani/dantotsu/connections/github/Forks.kt deleted file mode 100644 index 5e5301dc..00000000 --- a/app/src/main/java/ani/dantotsu/connections/github/Forks.kt +++ /dev/null @@ -1,55 +0,0 @@ -package ani.dantotsu.connections.github - -import ani.dantotsu.settings.Developer -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.runBlocking -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -class Forks { - - fun getForks(): Array { - var forks = arrayOf() - runBlocking(Dispatchers.IO) { - val trustedForks = arrayOf( - GithubResponse( - "Awery", - GithubResponse.Owner( - "MrBoomDeveloper", - "https://avatars.githubusercontent.com/u/92123190?v=4" - ), - "https://github.com/MrBoomDeveloper/Awery" - ), - ) - trustedForks.forEach { - forks = forks.plus( - Developer( - it.name, - it.owner.avatarUrl, - it.owner.login, - it.htmlUrl - ) - ) - } - } - return forks - } - - - @Serializable - data class GithubResponse( - @SerialName("name") - val name: String, - val owner: Owner, - @SerialName("html_url") - val htmlUrl: String, - ) { - @Serializable - data class Owner( - @SerialName("login") - val login: String, - @SerialName("avatar_url") - val avatarUrl: String - ) - } -} \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt b/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt index 6cafbc05..216c937f 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt @@ -528,26 +528,11 @@ class MediaInfoFragment : Fragment() { parent, false ).apply { - fun onUserClick(userId: Int) { - val review = media.review!!.find { i -> i.id == userId } - if (review != null) { - startActivity( - Intent(requireContext(), ReviewViewActivity::class.java) - .putExtra("review", review) - ) - } - } val adapter = GroupieAdapter() - media.review!!.forEach { - adapter.add(ReviewAdapter(it, ::onUserClick)) - } + media.review!!.forEach { adapter.add(ReviewAdapter(it)) } itemTitle.setText(R.string.reviews) itemRecycler.adapter = adapter - itemRecycler.layoutManager = LinearLayoutManager( - requireContext(), - LinearLayoutManager.VERTICAL, - false - ) + itemRecycler.layoutManager = LinearLayoutManager(requireContext()) itemMore.visibility = View.VISIBLE itemMore.setSafeOnClickListener { startActivity( diff --git a/app/src/main/java/ani/dantotsu/media/ReviewActivity.kt b/app/src/main/java/ani/dantotsu/media/ReviewActivity.kt index caefe07b..d3747765 100644 --- a/app/src/main/java/ani/dantotsu/media/ReviewActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/ReviewActivity.kt @@ -122,19 +122,7 @@ class ReviewActivity : AppCompatActivity() { private fun fillList() { adapter.clear() reviews.forEach { - adapter.add( - ReviewAdapter( - it, - this::onUserClick - ) - ) - } - } - - private fun onUserClick(userId: Int) { - val review = reviews.find { it.id == userId } - if (review != null) { - startActivity(Intent(this, ReviewViewActivity::class.java).putExtra("review", review)) + adapter.add(ReviewAdapter(it)) } } } \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/media/ReviewAdapter.kt b/app/src/main/java/ani/dantotsu/media/ReviewAdapter.kt index e88238c7..8bb0a138 100644 --- a/app/src/main/java/ani/dantotsu/media/ReviewAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/ReviewAdapter.kt @@ -1,12 +1,24 @@ package ani.dantotsu.media +import android.app.Activity +import android.content.Intent import android.view.View +import androidx.activity.ComponentActivity +import androidx.core.app.ActivityOptionsCompat +import androidx.core.content.ContextCompat +import androidx.core.util.Pair +import androidx.core.view.ViewCompat +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentActivity import ani.dantotsu.R import ani.dantotsu.connections.anilist.Anilist import ani.dantotsu.connections.anilist.api.Query import ani.dantotsu.databinding.ItemReviewsBinding import ani.dantotsu.loadImage +import ani.dantotsu.openImage +import ani.dantotsu.others.ImageViewDialog +import ani.dantotsu.profile.ProfileActivity import ani.dantotsu.profile.activity.ActivityItemBuilder import ani.dantotsu.toast import com.xwray.groupie.viewbinding.BindableItem @@ -18,19 +30,49 @@ import kotlinx.coroutines.withContext class ReviewAdapter( private var review: Query.Review, - val clickCallback: (Int) -> Unit ) : BindableItem() { private lateinit var binding: ItemReviewsBinding override fun bind(viewBinding: ItemReviewsBinding, position: Int) { binding = viewBinding + val context = binding.root.context binding.reviewUserName.text = review.user?.name binding.reviewUserAvatar.loadImage(review.user?.avatar?.medium) binding.reviewText.text = review.summary binding.reviewPostTime.text = ActivityItemBuilder.getDateTime(review.createdAt) val text = "[${review.score/ 10.0f}]" binding.reviewTag.text = text - binding.root.setOnClickListener { clickCallback(review.id) } + binding.root.setOnClickListener { + ContextCompat.startActivity( + context, + Intent(context, ReviewViewActivity::class.java) + .putExtra("review", review), + null + ) + } + binding.reviewUserName.setOnClickListener { + ContextCompat.startActivity( + context, + Intent(context, ProfileActivity::class.java) + .putExtra("userId", review.user?.id), + null + ) + } + binding.reviewUserAvatar.setOnClickListener { + ContextCompat.startActivity( + context, + Intent(context, ProfileActivity::class.java) + .putExtra("userId", review.user?.id), + null + ) + } + binding.reviewUserAvatar.openImage( + context.getString( + R.string.avatar, + review.user?.name + ), + review.user?.avatar?.medium ?: "" + ) userVote(review.userRating) enableVote() binding.reviewTotalVotes.text = review.rating.toString() diff --git a/app/src/main/java/ani/dantotsu/media/ReviewViewActivity.kt b/app/src/main/java/ani/dantotsu/media/ReviewViewActivity.kt index 7d33481b..5e64d33c 100644 --- a/app/src/main/java/ani/dantotsu/media/ReviewViewActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/ReviewViewActivity.kt @@ -1,5 +1,6 @@ package ani.dantotsu.media +import android.content.Intent import android.os.Bundle import android.view.View import android.view.ViewGroup @@ -18,6 +19,9 @@ import ani.dantotsu.getThemeColor import ani.dantotsu.initActivity import ani.dantotsu.loadImage import ani.dantotsu.navBarHeight +import ani.dantotsu.openImage +import ani.dantotsu.others.ImageViewDialog +import ani.dantotsu.profile.ProfileActivity import ani.dantotsu.profile.activity.ActivityItemBuilder import ani.dantotsu.statusBarHeight import ani.dantotsu.themes.ThemeManager @@ -47,6 +51,20 @@ class ReviewViewActivity : AppCompatActivity() { binding.userName.text = review.user?.name binding.userAvatar.loadImage(review.user?.avatar?.medium) binding.userTime.text = ActivityItemBuilder.getDateTime(review.createdAt) + binding.userContainer.setOnClickListener { + startActivity(Intent(this, ProfileActivity::class.java) + .putExtra("userId", review.user?.id) + ) + } + binding.userAvatar.openImage( + binding.root.context.getString(R.string.avatar, review.user?.name), + review.user?.avatar?.medium ?: "" + ) + binding.userAvatar.setOnClickListener { + startActivity(Intent(this, ProfileActivity::class.java) + .putExtra("userId", review.user?.id) + ) + } binding.profileUserBio.settings.loadWithOverviewMode = true binding.profileUserBio.settings.useWideViewPort = true binding.profileUserBio.setInitialScale(1) diff --git a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt index 643787fc..6c552090 100644 --- a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt +++ b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt @@ -14,6 +14,7 @@ import ani.dantotsu.copyToClipboard import ani.dantotsu.databinding.ItemCommentsBinding import ani.dantotsu.getAppString import ani.dantotsu.loadImage +import ani.dantotsu.openImage import ani.dantotsu.others.ImageViewDialog import ani.dantotsu.profile.ProfileActivity import ani.dantotsu.setAnimation @@ -251,13 +252,10 @@ class CommentItem( } } commentTotalVotes.text = (comment.upvotes - comment.downvotes).toString() - commentUserAvatar.setOnLongClickListener { - ImageViewDialog.newInstance( - commentsFragment.activity, - commentsFragment.activity.getString(R.string.avatar, comment.username), - comment.profilePictureUrl - ) - } + commentUserAvatar.openImage( + commentsFragment.activity.getString(R.string.avatar, comment.username), + comment.profilePictureUrl ?: "" + ) comment.profilePictureUrl?.let { commentUserAvatar.loadImage(it) } commentUserName.text = comment.username val userColor = "[${levelColor.second}]" diff --git a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt index 578db054..5433df6a 100644 --- a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt @@ -28,6 +28,7 @@ import ani.dantotsu.initActivity import ani.dantotsu.loadImage import ani.dantotsu.media.user.ListActivity import ani.dantotsu.navBarHeight +import ani.dantotsu.openImage import ani.dantotsu.openLinkInBrowser import ani.dantotsu.others.ImageViewDialog import ani.dantotsu.profile.activity.FeedFragment @@ -171,13 +172,10 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene } profileUserAvatar.loadImage(user.avatar?.medium) - profileUserAvatar.setOnLongClickListener { - ImageViewDialog.newInstance( - context, - getString(R.string.avatar, user.name), - user.avatar?.medium - ) - } + profileUserAvatar.openImage( + context.getString(R.string.avatar, user.name), + user.avatar?.medium ?: "" + ) profileUserName.text = user.name val bannerAnimations: ImageView= if (PrefManager.getVal(PrefName.BannerAnimations)) profileBannerImage else profileBannerImageNoKen @@ -192,13 +190,10 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene profileMenuButton.updateLayoutParams { topMargin += statusBarHeight } profileButtonContainer.updateLayoutParams { topMargin += statusBarHeight } - profileBannerImage.setOnLongClickListener { - ImageViewDialog.newInstance( - context, - getString(R.string.banner, user.name), - user.bannerImage - ) - } + profileBannerImage.openImage( + context.getString(R.string.banner, user.name), + user.bannerImage ?: user.avatar?.medium ?: "" + ) mMaxScrollSize = profileAppBar.totalScrollRange profileAppBar.addOnOffsetChangedListener(context) diff --git a/app/src/main/java/ani/dantotsu/settings/ForksDialogFragment.kt b/app/src/main/java/ani/dantotsu/settings/ForksDialogFragment.kt index 74d00972..7485c7e6 100644 --- a/app/src/main/java/ani/dantotsu/settings/ForksDialogFragment.kt +++ b/app/src/main/java/ani/dantotsu/settings/ForksDialogFragment.kt @@ -7,7 +7,6 @@ import android.view.ViewGroup import androidx.recyclerview.widget.LinearLayoutManager import ani.dantotsu.BottomSheetDialogFragment import ani.dantotsu.R -import ani.dantotsu.connections.github.Forks import ani.dantotsu.databinding.BottomSheetDevelopersBinding class ForksDialogFragment : BottomSheetDialogFragment() { @@ -26,7 +25,16 @@ class ForksDialogFragment : BottomSheetDialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding.devsTitle.setText(R.string.forks) - binding.devsRecyclerView.adapter = DevelopersAdapter(Forks().getForks()) + binding.devsRecyclerView.adapter = DevelopersAdapter( + arrayOf( + Developer( + "Awery", + "https://avatars.githubusercontent.com/u/92123190?v=4", + "MrBoomDeveloper", + "https://github.com/MrBoomDeveloper/Awery" + ), + ) + ) binding.devsRecyclerView.layoutManager = LinearLayoutManager(requireContext()) } From 143eed8cb2efdb8764ab335447cd026d7df290df Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Wed, 22 May 2024 05:08:43 -0500 Subject: [PATCH 15/71] feat: add calculator to app --- app/src/main/AndroidManifest.xml | 2 + .../main/java/ani/dantotsu/MainActivity.kt | 15 + .../subscription/SubscriptionHelper.kt | 6 +- .../ani/dantotsu/others/calc/CalcActivity.kt | 120 ++++++ .../ani/dantotsu/others/calc/CalcStack.kt | 103 +++++ .../settings/SettingsCommonActivity.kt | 49 ++- .../dantotsu/settings/saving/Preferences.kt | 1 + .../java/ani/dantotsu/util/NumberConverter.kt | 51 +++ .../res/drawable/rounded_bottom_corners.xml | 9 + .../main/res/drawable/rounded_top_corners.xml | 9 + app/src/main/res/layout/activity_calc.xml | 383 ++++++++++++++++++ .../main/res/layout/dialog_set_password.xml | 25 ++ app/src/main/res/values/colors.xml | 4 +- app/src/main/res/values/strings.xml | 4 + 14 files changed, 776 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/ani/dantotsu/others/calc/CalcActivity.kt create mode 100644 app/src/main/java/ani/dantotsu/others/calc/CalcStack.kt create mode 100644 app/src/main/java/ani/dantotsu/util/NumberConverter.kt create mode 100644 app/src/main/res/drawable/rounded_bottom_corners.xml create mode 100644 app/src/main/res/drawable/rounded_top_corners.xml create mode 100644 app/src/main/res/layout/activity_calc.xml create mode 100644 app/src/main/res/layout/dialog_set_password.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 738d7be6..43c9c29f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -129,6 +129,8 @@ + diff --git a/app/src/main/java/ani/dantotsu/MainActivity.kt b/app/src/main/java/ani/dantotsu/MainActivity.kt index 4b7f153e..f9740533 100644 --- a/app/src/main/java/ani/dantotsu/MainActivity.kt +++ b/app/src/main/java/ani/dantotsu/MainActivity.kt @@ -48,6 +48,7 @@ import ani.dantotsu.home.NoInternet import ani.dantotsu.media.MediaDetailsActivity import ani.dantotsu.notifications.TaskScheduler import ani.dantotsu.others.CustomBottomDialog +import ani.dantotsu.others.calc.CalcActivity import ani.dantotsu.profile.ProfileActivity import ani.dantotsu.profile.activity.FeedActivity import ani.dantotsu.profile.activity.NotificationActivity @@ -100,6 +101,20 @@ class MainActivity : AppCompatActivity() { setContentView(binding.root) TaskScheduler.scheduleSingleWork(this) + if (!CalcActivity.hasPermission) { + val pin: String = PrefManager.getVal(PrefName.AppPassword) + if (pin.isNotEmpty()) { + ContextCompat.startActivity( + this@MainActivity, + Intent(this@MainActivity, CalcActivity::class.java) + .putExtra("code", pin) + .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK), + null + ) + finish() + return + } + } val action = intent.action val type = intent.type diff --git a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt index f03b1148..e9156ed7 100644 --- a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt +++ b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt @@ -148,7 +148,11 @@ class SubscriptionHelper { val name: String, val image: String?, val banner: String? = null - ) : java.io.Serializable + ) : java.io.Serializable { + companion object { + private const val serialVersionUID = 1L + } + } private const val SUBSCRIPTIONS = "subscriptions" diff --git a/app/src/main/java/ani/dantotsu/others/calc/CalcActivity.kt b/app/src/main/java/ani/dantotsu/others/calc/CalcActivity.kt new file mode 100644 index 00000000..2aa70813 --- /dev/null +++ b/app/src/main/java/ani/dantotsu/others/calc/CalcActivity.kt @@ -0,0 +1,120 @@ +package ani.dantotsu.others.calc + +import android.content.Intent +import android.os.Bundle +import android.text.Spannable +import android.text.SpannableString +import android.text.style.ForegroundColorSpan +import android.view.ViewGroup +import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat +import androidx.core.view.updateLayoutParams +import ani.dantotsu.MainActivity +import ani.dantotsu.R +import ani.dantotsu.databinding.ActivityCalcBinding +import ani.dantotsu.getThemeColor +import ani.dantotsu.initActivity +import ani.dantotsu.navBarHeight +import ani.dantotsu.statusBarHeight +import ani.dantotsu.themes.ThemeManager +import ani.dantotsu.util.NumberConverter.Companion.toBinary +import ani.dantotsu.util.NumberConverter.Companion.toHex + +class CalcActivity : AppCompatActivity() { + private lateinit var binding: ActivityCalcBinding + private lateinit var code: String + private val stack = CalcStack() + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + ThemeManager(this).applyTheme() + initActivity(this) + binding = ActivityCalcBinding.inflate(layoutInflater) + binding.mainContainer.updateLayoutParams { + topMargin += statusBarHeight + bottomMargin = navBarHeight + } + setContentView(binding.root) + code = intent.getStringExtra("code") ?: "0" + + binding.apply { + button0.setOnClickListener { stack.add('0'); updateDisplay() } + button1.setOnClickListener { stack.add('1'); updateDisplay() } + button2.setOnClickListener { stack.add('2'); updateDisplay() } + button3.setOnClickListener { stack.add('3'); updateDisplay() } + button4.setOnClickListener { stack.add('4'); updateDisplay() } + button5.setOnClickListener { stack.add('5'); updateDisplay() } + button6.setOnClickListener { stack.add('6'); updateDisplay() } + button7.setOnClickListener { stack.add('7'); updateDisplay() } + button8.setOnClickListener { stack.add('8'); updateDisplay() } + button9.setOnClickListener { stack.add('9'); updateDisplay() } + buttonDot.setOnClickListener { stack.add('.'); updateDisplay() } + buttonAdd.setOnClickListener { stack.add('+'); updateDisplay() } + buttonSubtract.setOnClickListener { stack.add('-'); updateDisplay() } + buttonMultiply.setOnClickListener { stack.add('*'); updateDisplay() } + buttonDivide.setOnClickListener { stack.add('/'); updateDisplay() } + buttonEquals.setOnClickListener { + try { + val ans = stack.evaluate() + updateDisplay() + binding.displayBinary.text = ans.toBinary() + binding.displayHex.text = ans.toHex() + } catch (e: Exception) { + display.text = getString(R.string.error) + } + } + buttonClear.setOnClickListener { + stack.clear() + binding.displayBinary.text = "" + binding.displayHex.text = "" + binding.display.text = "0" + } + buttonBackspace.setOnClickListener { + stack.remove() + updateDisplay() + } + display.text = "0" + } + } + + private fun success() { + hasPermission = true + ContextCompat.startActivity( + this, + Intent(this, MainActivity::class.java) + .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK), + null + ) + } + + private fun updateDisplay() { + if (stack.getExpression().isEmpty()) { + binding.display.text = "0" + return + } + val expression = stack.getExpression().replace("*", "×").replace("/", "÷") + val spannable = SpannableString(expression) + + val operators = arrayOf('+', '-', '×', '÷') + + expression.forEachIndexed { index, char -> + if (char in operators) { + val color = getThemeColor(com.google.android.material.R.attr.colorSecondary) + spannable.setSpan( + ForegroundColorSpan(color), + index, + index + 1, + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE + ) + } + } + binding.display.text = spannable + val text = binding.display.text.toString() + if (text == code) { + success() + } + } + + companion object { + var hasPermission = false + } +} \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/others/calc/CalcStack.kt b/app/src/main/java/ani/dantotsu/others/calc/CalcStack.kt new file mode 100644 index 00000000..563e9083 --- /dev/null +++ b/app/src/main/java/ani/dantotsu/others/calc/CalcStack.kt @@ -0,0 +1,103 @@ +package ani.dantotsu.others.calc + +import java.util.Stack + +class CalcStack { + private var expression: String = "" + private val maxExpressionLength = 256 + + fun evaluate(): Double { + val ops = Stack() + val values = Stack() + + var i = 0 + while (i < expression.length) { + when { + expression[i] == ' ' -> i++ + expression[i].isDigit() || expression[i] == '.' -> { + var value = 0.0 + var isDecimal = false + var decimalFactor = 0.1 + while (i < expression.length && (expression[i].isDigit() || expression[i] == '.' && !isDecimal)) { + if (expression[i] == '.') { + isDecimal = true + } else if (!isDecimal) { + value = value * 10 + (expression[i] - '0') + } else { + value += (expression[i] - '0') * decimalFactor + decimalFactor *= 0.1 + } + i++ + } + values.push(value) + i-- // to compensate the additional i++ in the loop + } + + else -> { + while (!ops.isEmpty() && precedence(ops.peek()) >= precedence(expression[i])) { + val val2 = values.pop() + val val1 = values.pop() + val op = ops.pop() + values.push(applyOp(val1, val2, op)) + } + ops.push(expression[i]) + } + } + i++ + } + + while (!ops.isEmpty()) { + val val2 = values.pop() + val val1 = values.pop() + val op = ops.pop() + values.push(applyOp(val1, val2, op)) + } + + + val ans = values.pop() + expression = ans.toString() + return ans + } + + fun add(c: Char) { + if (expression.length >= maxExpressionLength) return + expression += c + } + + fun clear() { + expression = "" + } + + fun remove() { + if (expression.isNotEmpty()) { + expression = expression.substring(0, expression.length - 1) + } + } + + fun getExpression(): String { + return expression + } + + + private fun precedence(op: Char): Int { + return when (op) { + '+', '-' -> 1 + '*', '/' -> 2 + else -> -1 + } + } + + private fun applyOp(a: Double, b: Double, op: Char): Double { + return when (op) { + '+' -> a + b + '-' -> a - b + '*' -> a * b + '/' -> { + if (b == 0.0) throw UnsupportedOperationException("Cannot divide by zero.") + a / b + } + + else -> 0.0 + } + } +} \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/settings/SettingsCommonActivity.kt b/app/src/main/java/ani/dantotsu/settings/SettingsCommonActivity.kt index 4f8b1558..0f99190f 100644 --- a/app/src/main/java/ani/dantotsu/settings/SettingsCommonActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/SettingsCommonActivity.kt @@ -4,12 +4,11 @@ import android.app.AlertDialog import android.content.Intent import android.net.Uri import android.os.Bundle -import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.inputmethod.EditorInfo import android.widget.ArrayAdapter -import android.widget.TextView +import android.widget.EditText import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity import androidx.core.view.updateLayoutParams @@ -41,6 +40,7 @@ import kotlinx.coroutines.launch import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get + class SettingsCommonActivity : AppCompatActivity() { private lateinit var binding: ActivitySettingsCommonBinding private lateinit var launcher: LauncherWrapper @@ -169,6 +169,51 @@ class SettingsCommonActivity : AppCompatActivity() { dialog.window?.setDimAmount(0.8f) } ), + Settings( + type = 1, + name = getString(R.string.app_lock), + desc = getString(R.string.app_lock_desc), + icon = R.drawable.ic_round_lock_open_24, + onClick = { + val passwordDialog = AlertDialog.Builder(context, R.style.MyPopup) + .setTitle(R.string.download_manager) + .setView(R.layout.dialog_set_password) + .setPositiveButton(R.string.ok) { dialog, _ -> + val passwordInput = + (dialog as AlertDialog).findViewById(R.id.passwordInput) + val confirmPasswordInput = + dialog.findViewById(R.id.confirmPasswordInput) + + val password = passwordInput?.text.toString() + val confirmPassword = confirmPasswordInput?.text.toString() + + if (password == confirmPassword && password.isNotEmpty()) { + PrefManager.setVal(PrefName.AppPassword, password) + toast(R.string.success) + dialog.dismiss() + } else { + toast(R.string.password_mismatch) + } + } + .setNegativeButton(R.string.cancel) { dialog, _ -> + dialog.dismiss() + } + .setNeutralButton(R.string.remove) { dialog, _ -> + PrefManager.setVal(PrefName.AppPassword, "") + toast(R.string.success) + dialog.dismiss() + } + .create() + + passwordDialog.window?.setDimAmount(0.8f) + passwordDialog.setOnShowListener { + passwordDialog.findViewById(R.id.passwordInput) + ?.requestFocus() + } + passwordDialog.show() + } + + ), Settings( type = 1, name = getString(R.string.backup_restore), diff --git a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt index df6ed929..1d69ebad 100644 --- a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt +++ b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt @@ -201,4 +201,5 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files AnilistUserId(Pref(Location.Protected, String::class, "")), MALCodeChallenge(Pref(Location.Protected, String::class, "")), MALToken(Pref(Location.Protected, MAL.ResponseToken::class, "")), + AppPassword(Pref(Location.Protected, String::class, "")), } \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/util/NumberConverter.kt b/app/src/main/java/ani/dantotsu/util/NumberConverter.kt new file mode 100644 index 00000000..49d41de7 --- /dev/null +++ b/app/src/main/java/ani/dantotsu/util/NumberConverter.kt @@ -0,0 +1,51 @@ +package ani.dantotsu.util + +import java.util.Locale + +class NumberConverter { + companion object { + fun Number.toBinary(): String { + return when (this) { + is Int -> Integer.toBinaryString(this) + is Long -> java.lang.Long.toBinaryString(this) + is Short -> Integer.toBinaryString(this.toInt()) + is Byte -> Integer.toBinaryString(this.toInt()) + is Double -> doubleToBinary(this) + is Float -> floatToBinary(this) + else -> throw IllegalArgumentException("Unsupported number type") + } + } + + fun Number.toHex(): String { + return when (this) { + is Int -> Integer.toHexString(this) + is Long -> java.lang.Long.toHexString(this) + is Short -> Integer.toHexString(this.toInt()) + is Byte -> Integer.toHexString(this.toInt()) + is Double -> doubleToHex(this) + is Float -> floatToHex(this) + else -> throw IllegalArgumentException("Unsupported number type") + } + } + + private fun doubleToHex(number: Double): String { + val longBits = java.lang.Double.doubleToLongBits(number) + return "0x" + java.lang.Long.toHexString(longBits).uppercase(Locale.ROOT) + } + + private fun floatToHex(number: Float): String { + val intBits = java.lang.Float.floatToIntBits(number) + return "0x" + Integer.toHexString(intBits).uppercase(Locale.ROOT) + } + + private fun doubleToBinary(number: Double): String { + val longBits = java.lang.Double.doubleToLongBits(number) + return java.lang.Long.toBinaryString(longBits) + } + + private fun floatToBinary(number: Float): String { + val intBits = java.lang.Float.floatToIntBits(number) + return Integer.toBinaryString(intBits) + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_bottom_corners.xml b/app/src/main/res/drawable/rounded_bottom_corners.xml new file mode 100644 index 00000000..1b49936e --- /dev/null +++ b/app/src/main/res/drawable/rounded_bottom_corners.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/drawable/rounded_top_corners.xml b/app/src/main/res/drawable/rounded_top_corners.xml new file mode 100644 index 00000000..2fc6c2a4 --- /dev/null +++ b/app/src/main/res/drawable/rounded_top_corners.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/layout/activity_calc.xml b/app/src/main/res/layout/activity_calc.xml new file mode 100644 index 00000000..291fccd0 --- /dev/null +++ b/app/src/main/res/layout/activity_calc.xml @@ -0,0 +1,383 @@ + + + + + + + + + + + + + + + + + + + + +