diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml
index 68444cd86a2..313a0be5e63 100644
--- a/.github/workflows/beta.yml
+++ b/.github/workflows/beta.yml
@@ -12,6 +12,7 @@ jobs:
runs-on: ubuntu-latest
env:
CI: true
+ SKIP_BUILD: false
steps:
- name: Checkout repo
@@ -19,14 +20,12 @@ jobs:
with:
fetch-depth: 0
-
- name: Download last SHA artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow: beta.yml
name: last-sha
path: .
-
continue-on-error: true
- name: Get Commits Since Last Run
@@ -39,7 +38,9 @@ jobs:
fi
echo "Commits since $LAST_SHA:"
# Accumulate commit logs in a shell variable
- COMMIT_LOGS=$(git log $LAST_SHA..HEAD --pretty=format:"● %s ~%an")
+ COMMIT_LOGS=$(git log $LAST_SHA..HEAD --pretty=format:"● %s ~%an [֍](https://github.com/${{ github.repository }}/commit/%H)")
+ # Replace commit messages with pull request links
+ COMMIT_LOGS=$(echo "$COMMIT_LOGS" | sed -E 's/#([0-9]+)/[#\1](https:\/\/github.com\/rebelonion\/Dantotsu\/pull\/\1)/g')
# URL-encode the newline characters for GitHub Actions
COMMIT_LOGS="${COMMIT_LOGS//'%'/'%25'}"
COMMIT_LOGS="${COMMIT_LOGS//$'\n'/'%0A'}"
@@ -65,26 +66,40 @@ jobs:
echo "Version $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
+ - name: List files in the directory
+ run: ls -l
+
- name: Setup JDK 17
+ if: ${{ env.SKIP_BUILD != 'true' }}
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: gradle
-
+
- name: Decode Keystore File
+ if: ${{ github.repository == 'rebelonion/Dantotsu' }}
run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 -d > $GITHUB_WORKSPACE/key.keystore
-
- - name: List files in the directory
- run: ls -l
-
+
- name: Make gradlew executable
+ if: ${{ env.SKIP_BUILD != 'true' }}
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: Build with Gradle
+ if: ${{ env.SKIP_BUILD != 'true' }}
+ run: |
+ if [ "${{ github.repository }}" == "rebelonion/Dantotsu" ]; then
+ ./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 }};
+ else
+ ./gradlew assembleGoogleAlpha;
+ fi
+
- name: Upload a Build Artifact
+ if: ${{ env.SKIP_BUILD != 'true' }}
uses: actions/upload-artifact@v4
with:
name: Dantotsu
@@ -93,25 +108,203 @@ jobs:
path: "app/build/outputs/apk/google/alpha/app-google-alpha.apk"
- name: Upload APK to Discord and Telegram
- if: ${{ github.repository == 'rebelonion/Dantotsu' }}
shell: bash
run: |
- #Discord
+ # Prepare Discord embed
+ fetch_user_details() {
+ local login=$1
+ user_details=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
+ "https://api.github.com/users/$login")
+ name=$(echo "$user_details" | jq -r '.name // .login')
+ login=$(echo "$user_details" | jq -r '.login')
+ avatar_url=$(echo "$user_details" | jq -r '.avatar_url')
+ echo "$name|$login|$avatar_url"
+ }
+
+ # Additional information for the goats
+ declare -A additional_info
+ additional_info["ibo"]="\n Discord: <@951737931159187457>\n AniList: [takarealist112]()"
+ additional_info["aayush262"]="\n Discord: <@918825160654598224>\n AniList: [aayush262]()"
+ additional_info["rebelonion"]="\n Discord: <@714249925248024617>\n AniList: [rebelonion]()\n PornHub: [rebelonion]()"
+
+ # Decimal color codes for contributors
+ declare -A contributor_colors
+ default_color="#ff25f9"
+ contributor_colors["ibo"]="#ff7500"
+ contributor_colors["aayush262"]="#5d689d"
+ contributor_colors["Sadwhy"]="#ff7e95"
+ contributor_colors["rebelonion"]="#d4e5ed"
+ hex_to_decimal() { printf '%d' "0x${1#"#"}"; }
+
+ # Count recent commits and create an associative array
+ declare -A recent_commit_counts
+ while read -r count name; do
+ recent_commit_counts["$name"]=$count
+ done < <(echo "$COMMIT_LOG" | sed 's/%0A/\n/g' | grep -oP '(?<=~)[^[]*' | sort | uniq -c | sort -rn)
+ # Fetch contributors from GitHub
+ contributors=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
+ "https://api.github.com/repos/${{ github.repository }}/contributors")
+
+ # Create a sorted list of contributors based on recent commit counts
+ sorted_contributors=$(for login in $(echo "$contributors" | jq -r '.[].login'); do
+ user_info=$(fetch_user_details "$login")
+ name=$(echo "$user_info" | cut -d'|' -f1)
+ count=${recent_commit_counts["$name"]:-0}
+ echo "$count|$login"
+ done | sort -rn | cut -d'|' -f2)
+
+ # Initialize needed variables
+ developers=""
+ committers_count=0
+ max_commits=0
+ top_contributor=""
+ top_contributor_count=0
+ top_contributor_avatar=""
+ embed_color=$default_color
+
+ # Process contributors in the new order
+ while read -r login; do
+ user_info=$(fetch_user_details "$login")
+ name=$(echo "$user_info" | cut -d'|' -f1)
+ login=$(echo "$user_info" | cut -d'|' -f2)
+ avatar_url=$(echo "$user_info" | cut -d'|' -f3)
+
+ # Only process if they have recent commits
+ commit_count=${recent_commit_counts["$name"]:-0}
+ if [ $commit_count -gt 0 ]; then
+ # Update top contributor information
+ if [ $commit_count -gt $max_commits ]; then
+ max_commits=$commit_count
+ top_contributors=("$login")
+ top_contributor_count=1
+ top_contributor_avatar="$avatar_url"
+ embed_color=$(hex_to_decimal "${contributor_colors[$name]:-$default_color}")
+ elif [ $commit_count -eq $max_commits ]; then
+ top_contributors+=("$login")
+ top_contributor_count=$((top_contributor_count + 1))
+ embed_color=$default_color
+ fi
+
+ # Get commit count for this contributor on the dev branch
+ branch_commit_count=$(git rev-list --count dev --author="$login")
+
+ extra_info="${additional_info[$name]}"
+ if [ -n "$extra_info" ]; then
+ extra_info=$(echo "$extra_info" | sed 's/\\n/\n- /g')
+ fi
+
+ # Construct the developer entry
+ developer_entry="◗ **${name}** ${extra_info}
+ - Github: [${login}](https://github.com/${login})
+ - Commits: ${branch_commit_count}"
+
+ # Add the entry to developers, with a newline if it's not the first entry
+ if [ -n "$developers" ]; then
+ developers="${developers}
+ ${developer_entry}"
+ else
+ developers="${developer_entry}"
+ fi
+ committers_count=$((committers_count + 1))
+ fi
+ done <<< "$sorted_contributors"
+
+ # Set the thumbnail URL and color based on top contributor(s)
+ if [ $top_contributor_count -eq 1 ]; then
+ thumbnail_url="$top_contributor_avatar"
+ else
+ thumbnail_url="https://i.imgur.com/5o3Y9Jb.gif"
+ embed_color=$default_color
+ fi
+
+ # Truncate field values
+ max_length=1000
commit_messages=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g; s/^/\n/')
- # Truncate commit messages if they are too long
- max_length=1900 # Adjust this value as needed
+ if [ ${#developers} -gt $max_length ]; then
+ developers="${developers:0:$max_length}... (truncated)"
+ fi
if [ ${#commit_messages} -gt $max_length ]; then
commit_messages="${commit_messages:0:$max_length}... (truncated)"
fi
- 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-alpha.apk" ${{ secrets.DISCORD_WEBHOOK }}
+
+ # Construct Discord payload
+ discord_data=$(jq -nc \
+ --arg field_value "$commit_messages" \
+ --arg author_value "$developers" \
+ --arg footer_text "Version $VERSION" \
+ --arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \
+ --arg thumbnail_url "$thumbnail_url" \
+ --argjson embed_color "$embed_color" \
+ '{
+ "content": "<@&1225347048321191996>",
+ "embeds": [
+ {
+ "title": "New Alpha-Build dropped",
+ "color": $embed_color,
+ "fields": [
+ {
+ "name": "Commits:",
+ "value": $field_value,
+ "inline": true
+ },
+ {
+ "name": "Developers:",
+ "value": $author_value,
+ "inline": false
+ }
+ ],
+ "footer": {
+ "text": $footer_text
+ },
+ "timestamp": $timestamp,
+ "thumbnail": {
+ "url": $thumbnail_url
+ }
+ }
+ ],
+ "attachments": []
+ }')
+
+ # Send Discord message
+ curl -H "Content-Type: application/json" \
+ -d "$discord_data" \
+ ${{ secrets.DISCORD_WEBHOOK }}
+ echo "You have only send an embed to discord due to SKIP_BUILD being set to true"
- #Telegram
- curl -F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \
- -F "document=@app/build/outputs/apk/google/alpha/app-google-alpha.apk" \
- -F "caption=Alpha-Build: ${VERSION}: ${commit_messages}" \
- https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument
+ # Upload APK to Discord
+ if [ "$SKIP_BUILD" != "true" ]; then
+ curl -F "payload_json=${contentbody}" \
+ -F "dantotsu_debug=@app/build/outputs/apk/google/alpha/app-google-alpha.apk" \
+ ${{ secrets.DISCORD_WEBHOOK }}
+ else
+ echo "Skipping APK upload to Discord due to SKIP_BUILD being set to true"
+ fi
+
+ # Format commit messages for Telegram
+ telegram_commit_messages=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g' | while read -r line; do
+ message=$(echo "$line" | sed -E 's/● (.*) ~(.*) \[֍\]\((.*)\)/● \1 ~\2 ֍<\/a>/')
+ message=$(echo "$message" | sed -E 's/\[#([0-9]+)\]\((https:\/\/github\.com\/[^)]+)\)/#\1<\/a>/g')
+ echo "$message"
+ done)
+ telegram_commit_messages="${telegram_commit_messages}
"
+ # Upload APK to Telegram
+ if [ "$SKIP_BUILD" != "true" ]; then
+ APK_PATH="app/build/outputs/apk/google/alpha/app-google-alpha.apk"
+ response=$(curl -sS -f -X POST \
+ "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument" \
+ -F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \
+ -F "document=@$APK_PATH" \
+ -F "caption=New Alpha-Build dropped 🔥
+
+ Commits:
+ ${telegram_commit_messages}
+ version: ${VERSION}" \
+ -F "parse_mode=HTML")
+ else
+ echo "Skipping Telegram message and APK upload due to SKIP_BUILD being set to true"
+ fi
+
env:
COMMIT_LOG: ${{ env.COMMIT_LOG }}
VERSION: ${{ env.VERSION }}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1104ba865ff..4c267042acc 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -201,7 +201,7 @@
android:name=".others.imagesearch.ImageSearchActivity"
android:parentActivityName=".MainActivity" />
+ val dialogView = DialogUserAgentBinding.inflate(layoutInflater).apply {
+ userAgentTextBox.hint = "Password"
+ subtitle.visibility = View.VISIBLE
+ subtitle.text = getString(R.string.enter_password_to_decrypt_file)
+ }
+ customAlertDialog().apply {
+ setTitle("Enter Password")
+ setCustomView(dialogView.root)
+ setPosButton(R.string.yes) {
+ val editText = dialogView.userAgentTextBox
+ if (editText.text?.isNotBlank() == true) {
+ editText.text?.toString()?.trim()?.toCharArray(password)
+ callback(password)
+ } else {
+ toast("Password cannot be empty")
+ }
+ }
+ setNegButton(R.string.cancel) {
password.fill('0')
- dialog.dismiss()
callback(null)
}
- .create()
-
- dialog.window?.setDimAmount(0.8f)
- dialog.show()
-
- // Override the positive button here
- dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
- val editText = dialog.findViewById(R.id.userAgentTextBox)
- if (editText?.text?.isNotBlank() == true) {
- editText.text?.toString()?.trim()?.toCharArray(password)
- dialog.dismiss()
- callback(password)
- } else {
- toast("Password cannot be empty")
- }
+ show()
}
}
diff --git a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistMutations.kt b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistMutations.kt
index 1ddfbbaaaea..3d7ac85eda1 100644
--- a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistMutations.kt
+++ b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistMutations.kt
@@ -93,30 +93,41 @@ class AnilistMutations {
)
}
- suspend fun postActivity(text: String, edit : Int? = null): String {
+ suspend fun postActivity(text: String, edit: Int? = null): String {
val encodedText = text.stringSanitizer()
- val query = "mutation{SaveTextActivity(${if (edit != null) "id:$edit," else ""} text:$encodedText){siteUrl}}"
+ val query =
+ "mutation{SaveTextActivity(${if (edit != null) "id:$edit," else ""} text:$encodedText){siteUrl}}"
val result = executeQuery(query)
val errors = result?.get("errors")
return errors?.toString()
?: (currContext()?.getString(ani.dantotsu.R.string.success) ?: "Success")
}
- suspend fun postMessage(userId: Int, text: String, edit: Int? = null,isPrivate: Boolean = false): String {
- val encodedText = text.replace("","").stringSanitizer()
- val query = "mutation{SaveMessageActivity(${if (edit != null) "id:$edit," else ""} recipientId:$userId,message:$encodedText,private:$isPrivate){id}}"
+
+ suspend fun postMessage(
+ userId: Int,
+ text: String,
+ edit: Int? = null,
+ isPrivate: Boolean = false
+ ): String {
+ val encodedText = text.replace("", "").stringSanitizer()
+ val query =
+ "mutation{SaveMessageActivity(${if (edit != null) "id:$edit," else ""} recipientId:$userId,message:$encodedText,private:$isPrivate){id}}"
val result = executeQuery(query)
val errors = result?.get("errors")
return errors?.toString()
?: (currContext()?.getString(ani.dantotsu.R.string.success) ?: "Success")
}
- suspend fun postReply(activityId: Int, text: String, edit: Int? = null ): String {
+
+ suspend fun postReply(activityId: Int, text: String, edit: Int? = null): String {
val encodedText = text.stringSanitizer()
- val query = "mutation{SaveActivityReply(${if (edit != null) "id:$edit," else ""} activityId:$activityId,text:$encodedText){id}}"
+ val query =
+ "mutation{SaveActivityReply(${if (edit != null) "id:$edit," else ""} activityId:$activityId,text:$encodedText){id}}"
val result = executeQuery(query)
val errors = result?.get("errors")
return errors?.toString()
?: (currContext()?.getString(ani.dantotsu.R.string.success) ?: "Success")
}
+
suspend fun postReview(summary: String, body: String, mediaId: Int, score: Int): String {
val encodedSummary = summary.stringSanitizer()
val encodedBody = body.stringSanitizer()
@@ -143,7 +154,6 @@ class AnilistMutations {
}
-
private fun String.stringSanitizer(): String {
val sb = StringBuilder()
var i = 0
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 75ab4ee1eef..438dc7ad76e 100644
--- a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt
+++ b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt
@@ -479,6 +479,7 @@ class AnilistQueries {
suspend fun initHomePage(): Map> {
val removeList = PrefManager.getCustomVal("removeList", setOf())
+ val hidePrivate = PrefManager.getVal(PrefName.HidePrivate)
val removedMedia = ArrayList()
val toShow: List =
PrefManager.getVal(PrefName.HomeLayout) // anime continue, anime fav, anime planned, manga continue, manga fav, manga planned, recommendations
@@ -528,7 +529,7 @@ class AnilistQueries {
current?.lists?.forEach { li ->
li.entries?.reversed()?.forEach {
val m = Media(it)
- if (m.id !in removeList) {
+ if (m.id !in removeList && if (hidePrivate) !m.isListPrivate else true) {
m.cameFromContinue = true
subMap[m.id] = m
} else {
@@ -540,7 +541,7 @@ class AnilistQueries {
repeating?.lists?.forEach { li ->
li.entries?.reversed()?.forEach {
val m = Media(it)
- if (m.id !in removeList) {
+ if (m.id !in removeList && if (hidePrivate) !m.isListPrivate else true) {
m.cameFromContinue = true
subMap[m.id] = m
} else {
@@ -579,7 +580,7 @@ class AnilistQueries {
current?.lists?.forEach { li ->
li.entries?.reversed()?.forEach {
val m = Media(it)
- if (m.id !in removeList) {
+ if (m.id !in removeList && if (hidePrivate) !m.isListPrivate else true) {
m.cameFromContinue = true
subMap[m.id] = m
} else {
@@ -612,7 +613,7 @@ class AnilistQueries {
apiMediaList?.edges?.forEach {
it.node?.let { i ->
val m = Media(i).apply { isFav = true }
- if (m.id !in removeList) {
+ if (m.id !in removeList && if (hidePrivate) !m.isListPrivate else true) {
returnArray.add(m)
} else {
removedMedia.add(m)
@@ -1055,172 +1056,110 @@ query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult:
return null
}
- private val onListAnime =
- (if (PrefManager.getVal(PrefName.IncludeAnimeList)) "" else "onList:false").replace(
- "\"",
- ""
- )
- private val isAdult =
- (if (PrefManager.getVal(PrefName.AdultOnly)) "isAdult:true" else "").replace("\"", "")
-
- private fun recentAnimeUpdates(page: Int): String {
- return """Page(page:$page,perPage:50){pageInfo{hasNextPage total}airingSchedules(airingAt_greater:0 airingAt_lesser:${System.currentTimeMillis() / 1000 - 10000} sort:TIME_DESC){episode airingAt media{id idMal status chapters episodes nextAiringEpisode{episode} isAdult type meanScore isFavourite format bannerImage countryOfOrigin coverImage{large} title{english romaji userPreferred} mediaListEntry{progress private score(format:POINT_100) status}}}}"""
+ private fun mediaList(media1: Page?): ArrayList {
+ val combinedList = arrayListOf()
+ media1?.media?.mapTo(combinedList) { Media(it) }
+ return combinedList
}
-
- private fun trendingMovies(page: Int): String {
- return """Page(page:$page,perPage:50){pageInfo{hasNextPage total}media(sort:POPULARITY_DESC, type: ANIME, format: MOVIE, $onListAnime, $isAdult){id idMal status chapters episodes nextAiringEpisode{episode}isAdult type meanScore isFavourite format bannerImage countryOfOrigin coverImage{large}title{english romaji userPreferred}mediaListEntry{progress private score(format:POINT_100)status}}}"""
+ private fun getPreference(pref: PrefName): Boolean = PrefManager.getVal(pref)
+ private fun buildQueryString(sort: String, type: String, format: String? = null, country: String? = null): String {
+ val includeList = if (type == "ANIME" && !getPreference(PrefName.IncludeAnimeList)) "onList:false" else if (type == "MANGA" && !getPreference(PrefName.IncludeMangaList)) "onList:false" else ""
+ val isAdult = if (getPreference(PrefName.AdultOnly)) "isAdult:true" else ""
+ val formatFilter = format?.let { "format: $it, " } ?: ""
+ val countryFilter = country?.let { "countryOfOrigin: $it, " } ?: ""
+
+ return """Page(page:1,perPage:50){
+ pageInfo{hasNextPage total}
+ media(sort:$sort, type:$type, $formatFilter $countryFilter $includeList $isAdult){
+ id idMal status chapters episodes nextAiringEpisode{episode}
+ isAdult type meanScore isFavourite format bannerImage countryOfOrigin
+ coverImage{large} title{english romaji userPreferred}
+ mediaListEntry{progress private score(format:POINT_100) status}
+ }
+ }"""
}
- private fun topRatedAnime(page: Int): String {
- return """Page(page:$page,perPage:50){pageInfo{hasNextPage total}media(sort: SCORE_DESC, type: ANIME, $onListAnime, $isAdult){id idMal status chapters episodes nextAiringEpisode{episode}isAdult type meanScore isFavourite format bannerImage countryOfOrigin coverImage{large}title{english romaji userPreferred}mediaListEntry{progress private score(format:POINT_100)status}}}"""
+ private fun recentAnimeUpdates(page: Int): String {
+ val currentTime = System.currentTimeMillis() / 1000
+ return """Page(page:$page,perPage:50){
+ pageInfo{hasNextPage total}
+ airingSchedules(airingAt_greater:0 airingAt_lesser:${currentTime - 10000} sort:TIME_DESC){
+ episode airingAt media{
+ id idMal status chapters episodes nextAiringEpisode{episode}
+ isAdult type meanScore isFavourite format bannerImage countryOfOrigin
+ coverImage{large} title{english romaji userPreferred}
+ mediaListEntry{progress private score(format:POINT_100) status}
+ }
+ }
+ }"""
}
-
- private fun mostFavAnime(page: Int): String {
- return """Page(page:$page,perPage:50){pageInfo{hasNextPage total}media(sort:FAVOURITES_DESC,type: ANIME, $onListAnime, $isAdult){id idMal status chapters episodes nextAiringEpisode{episode}isAdult type meanScore isFavourite format bannerImage countryOfOrigin coverImage{large}title{english romaji userPreferred}mediaListEntry{progress private score(format:POINT_100)status}}}"""
+ private fun queryAnimeList(): String {
+ return """{
+ recentUpdates:${recentAnimeUpdates(1)}
+ recentUpdates2:${recentAnimeUpdates(2)}
+ trendingMovies:${buildQueryString("POPULARITY_DESC", "ANIME", "MOVIE")}
+ topRated:${buildQueryString("SCORE_DESC", "ANIME")}
+ mostFav:${buildQueryString("FAVOURITES_DESC", "ANIME")}
+ }"""
+ }
+ private fun queryMangaList(): String {
+ return """{
+ trendingManga:${buildQueryString("POPULARITY_DESC", "MANGA", country = "JP")}
+ trendingManhwa:${buildQueryString("POPULARITY_DESC", "MANGA", country = "KR")}
+ trendingNovel:${buildQueryString("POPULARITY_DESC", "MANGA", format = "NOVEL", country = "JP")}
+ topRated:${buildQueryString("SCORE_DESC", "MANGA")}
+ mostFav:${buildQueryString("FAVOURITES_DESC", "MANGA")}
+
+ }"""
}
suspend fun loadAnimeList(): Map> {
val list = mutableMapOf>()
- fun query(): String {
- return """{
- recentUpdates:${recentAnimeUpdates(1)}
- recentUpdates2:${recentAnimeUpdates(2)}
- trendingMovies:${trendingMovies(1)}
- trendingMovies2:${trendingMovies(2)}
- topRated:${topRatedAnime(1)}
- topRated2:${topRatedAnime(2)}
- mostFav:${mostFavAnime(1)}
- mostFav2:${mostFavAnime(2)}
- }""".trimIndent()
- }
- executeQuery(query(), force = true)?.data?.apply {
+
+ fun filterRecentUpdates(
+ page: Page?,
+ ): ArrayList {
val listOnly: Boolean = PrefManager.getVal(PrefName.RecentlyListOnly)
val adultOnly: Boolean = PrefManager.getVal(PrefName.AdultOnly)
val idArr = mutableListOf()
- list["recentUpdates"] = recentUpdates?.airingSchedules?.mapNotNull { i ->
+ return page?.airingSchedules?.mapNotNull { i ->
i.media?.let {
- if (!idArr.contains(it.id))
- if (!listOnly && it.countryOfOrigin == "JP" && Anilist.adult && adultOnly && it.isAdult == true) {
- idArr.add(it.id)
- Media(it)
- } else if (!listOnly && !adultOnly && (it.countryOfOrigin == "JP" && it.isAdult == false)) {
- idArr.add(it.id)
- Media(it)
- } else if ((listOnly && it.mediaListEntry != null)) {
+ if (!idArr.contains(it.id)) {
+ val shouldAdd = when {
+ !listOnly && it.countryOfOrigin == "JP" && Anilist.adult && adultOnly && it.isAdult == true -> true
+ !listOnly && !adultOnly && it.countryOfOrigin == "JP" && it.isAdult == false -> true
+ listOnly && it.mediaListEntry != null -> true
+ else -> false
+ }
+ if (shouldAdd) {
idArr.add(it.id)
Media(it)
} else null
- else null
+ } else null
}
}?.toCollection(ArrayList()) ?: arrayListOf()
-
- 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 {
- if (!idArr.contains(it.id))
- if (!listOnly && it.countryOfOrigin == "JP" && Anilist.adult && adultOnly && it.isAdult == true) {
- idArr.add(it.id)
- Media(it)
- } else if (!listOnly && !adultOnly && (it.countryOfOrigin == "JP" && it.isAdult == false)) {
- idArr.add(it.id)
- Media(it)
- } else if ((listOnly && it.mediaListEntry != null)) {
- idArr.add(it.id)
- Media(it)
- } else null
- else null
- }
- }?.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()
- )
+ }
+ executeQuery(queryAnimeList(), force = true)?.data?.apply {
+ list["recentUpdates"] = filterRecentUpdates(recentUpdates)
+ list["trendingMovies"] = mediaList(trendingMovies)
+ list["topRated"] = mediaList(topRated)
+ list["mostFav"] = mediaList(mostFav)
}
return list
}
-
- private val onListManga =
- (if (PrefManager.getVal(PrefName.IncludeMangaList)) "" else "onList:false").replace(
- "\"",
- ""
- )
-
- private fun trendingManga(page: Int): String {
- return """Page(page:$page,perPage:50){pageInfo{hasNextPage total}media(sort:POPULARITY_DESC, type: MANGA,countryOfOrigin:JP, $onListManga, $isAdult){id idMal status chapters episodes nextAiringEpisode{episode}isAdult type meanScore isFavourite format bannerImage countryOfOrigin coverImage{large}title{english romaji userPreferred}mediaListEntry{progress private score(format:POINT_100)status}}}"""
- }
-
- private fun trendingManhwa(page: Int): String {
- return """Page(page:$page,perPage:50){pageInfo{hasNextPage total}media(sort:POPULARITY_DESC, type: MANGA, countryOfOrigin:KR, $onListManga, $isAdult){id idMal status chapters episodes nextAiringEpisode{episode}isAdult type meanScore isFavourite format bannerImage countryOfOrigin coverImage{large}title{english romaji userPreferred}mediaListEntry{progress private score(format:POINT_100)status}}}"""
- }
-
- private fun trendingNovel(page: Int): String {
- return """Page(page:$page,perPage:50){pageInfo{hasNextPage total}media(sort:POPULARITY_DESC, type: MANGA, format: NOVEL, countryOfOrigin:JP, $onListManga, $isAdult){id idMal status chapters episodes nextAiringEpisode{episode}isAdult type meanScore isFavourite format bannerImage countryOfOrigin coverImage{large}title{english romaji userPreferred}mediaListEntry{progress private score(format:POINT_100)status}}}"""
- }
-
- private fun topRatedManga(page: Int): String {
- return """Page(page:$page,perPage:50){pageInfo{hasNextPage total}media(sort: SCORE_DESC, type: MANGA, $onListManga, $isAdult){id idMal status chapters episodes nextAiringEpisode{episode}isAdult type meanScore isFavourite format bannerImage countryOfOrigin coverImage{large}title{english romaji userPreferred}mediaListEntry{progress private score(format:POINT_100)status}}}"""
- }
-
- private fun mostFavManga(page: Int): String {
- return """Page(page:$page,perPage:50){pageInfo{hasNextPage total}media(sort:FAVOURITES_DESC,type: MANGA, $onListManga, $isAdult){id idMal status chapters episodes nextAiringEpisode{episode}isAdult type meanScore isFavourite format bannerImage countryOfOrigin coverImage{large}title{english romaji userPreferred}mediaListEntry{progress private score(format:POINT_100)status}}}"""
- }
-
suspend fun loadMangaList(): Map> {
val list = mutableMapOf>()
- fun query(): String {
- return """{
- trendingManga:${trendingManga(1)}
- trendingManga2:${trendingManga(2)}
- trendingManhwa:${trendingManhwa(1)}
- trendingManhwa2:${trendingManhwa(2)}
- trendingNovel:${trendingNovel(1)}
- trendingNovel2:${trendingNovel(2)}
- topRated:${topRatedManga(1)}
- topRated2:${topRatedManga(2)}
- mostFav:${mostFavManga(1)}
- mostFav2:${mostFavManga(2)}
- }""".trimIndent()
+ executeQuery(queryMangaList(), force = true)?.data?.apply {
+ list["trendingManga"] = mediaList(trendingManga)
+ list["trendingManhwa"] = mediaList(trendingManhwa)
+ list["trendingNovel"] = mediaList(trendingNovel)
+ list["topRated"] = mediaList(topRated)
+ list["mostFav"] = mediaList(mostFav)
}
-
- executeQuery(query(), force = true)?.data?.apply {
- 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
}
+
suspend fun recentlyUpdated(
greater: Long = 0,
lesser: Long = System.currentTimeMillis() / 1000 - 10000
diff --git a/app/src/main/java/ani/dantotsu/connections/anilist/api/Data.kt b/app/src/main/java/ani/dantotsu/connections/anilist/api/Data.kt
index e6635b9a773..e909a3bc0ce 100644
--- a/app/src/main/java/ani/dantotsu/connections/anilist/api/Data.kt
+++ b/app/src/main/java/ani/dantotsu/connections/anilist/api/Data.kt
@@ -163,13 +163,9 @@ class Query {
@Serializable
data class Data(
@SerialName("recentUpdates") val recentUpdates: ani.dantotsu.connections.anilist.api.Page?,
- @SerialName("recentUpdates2") val recentUpdates2: ani.dantotsu.connections.anilist.api.Page?,
@SerialName("trendingMovies") val trendingMovies: ani.dantotsu.connections.anilist.api.Page?,
- @SerialName("trendingMovies2") val trendingMovies2: ani.dantotsu.connections.anilist.api.Page?,
@SerialName("topRated") val topRated: ani.dantotsu.connections.anilist.api.Page?,
- @SerialName("topRated2") val topRated2: ani.dantotsu.connections.anilist.api.Page?,
@SerialName("mostFav") val mostFav: ani.dantotsu.connections.anilist.api.Page?,
- @SerialName("mostFav2") val mostFav2: ani.dantotsu.connections.anilist.api.Page?,
)
}
@@ -181,15 +177,10 @@ class Query {
@Serializable
data class Data(
@SerialName("trendingManga") val trendingManga: ani.dantotsu.connections.anilist.api.Page?,
- @SerialName("trendingManga2") val trendingManga2: ani.dantotsu.connections.anilist.api.Page?,
@SerialName("trendingManhwa") val trendingManhwa: ani.dantotsu.connections.anilist.api.Page?,
- @SerialName("trendingManhwa2") val trendingManhwa2: ani.dantotsu.connections.anilist.api.Page?,
@SerialName("trendingNovel") val trendingNovel: ani.dantotsu.connections.anilist.api.Page?,
- @SerialName("trendingNovel2") val trendingNovel2: ani.dantotsu.connections.anilist.api.Page?,
@SerialName("topRated") val topRated: ani.dantotsu.connections.anilist.api.Page?,
- @SerialName("topRated2") val topRated2: ani.dantotsu.connections.anilist.api.Page?,
@SerialName("mostFav") val mostFav: ani.dantotsu.connections.anilist.api.Page?,
- @SerialName("mostFav2") val mostFav2: ani.dantotsu.connections.anilist.api.Page?,
)
}
diff --git a/app/src/main/java/ani/dantotsu/download/anime/OfflineAnimeFragment.kt b/app/src/main/java/ani/dantotsu/download/anime/OfflineAnimeFragment.kt
index 3bcdffe1ee5..4f3876fe51b 100644
--- a/app/src/main/java/ani/dantotsu/download/anime/OfflineAnimeFragment.kt
+++ b/app/src/main/java/ani/dantotsu/download/anime/OfflineAnimeFragment.kt
@@ -49,6 +49,7 @@ import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.snackString
import ani.dantotsu.util.Logger
+import ani.dantotsu.util.customAlertDialog
import com.anggrayudi.storage.file.openInputStream
import com.google.android.material.card.MaterialCardView
import com.google.android.material.imageview.ShapeableImageView
@@ -203,25 +204,22 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener {
val type: MediaType = MediaType.ANIME
// Alert dialog to confirm deletion
- val builder =
- androidx.appcompat.app.AlertDialog.Builder(requireContext(), R.style.MyPopup)
- builder.setTitle("Delete ${item.title}?")
- builder.setMessage("Are you sure you want to delete ${item.title}?")
- builder.setPositiveButton("Yes") { _, _ ->
- downloadManager.removeMedia(item.title, type)
- val mediaIds =
- PrefManager.getAnimeDownloadPreferences().all?.filter { it.key.contains(item.title) }?.values
- ?: emptySet()
- if (mediaIds.isEmpty()) {
- snackString("No media found") // if this happens, terrible things have happened
+ requireContext().customAlertDialog().apply {
+ setTitle("Delete ${item.title}?")
+ setMessage("Are you sure you want to delete ${item.title}?")
+ setPosButton(R.string.yes) {
+ downloadManager.removeMedia(item.title, type)
+ val mediaIds = PrefManager.getAnimeDownloadPreferences().all?.filter { it.key.contains(item.title) }?.values ?: emptySet()
+ if (mediaIds.isEmpty()) {
+ snackString("No media found") // if this happens, terrible things have happened
+ }
+ getDownloads()
}
- getDownloads()
- }
- builder.setNegativeButton("No") { _, _ ->
- // Do nothing
+ setNegButton(R.string.no) {
+ // Do nothing
+ }
+ show()
}
- val dialog = builder.show()
- dialog.window?.setDimAmount(0.8f)
true
}
}
diff --git a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt
index 6d88918e6c3..dcb462e80f1 100644
--- a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt
+++ b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt
@@ -46,6 +46,7 @@ import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.snackString
import ani.dantotsu.util.Logger
+import ani.dantotsu.util.customAlertDialog
import com.anggrayudi.storage.file.openInputStream
import com.google.android.material.card.MaterialCardView
import com.google.android.material.imageview.ShapeableImageView
@@ -201,19 +202,15 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
MediaType.NOVEL
}
// Alert dialog to confirm deletion
- val builder =
- androidx.appcompat.app.AlertDialog.Builder(requireContext(), R.style.MyPopup)
- builder.setTitle("Delete ${item.title}?")
- builder.setMessage("Are you sure you want to delete ${item.title}?")
- builder.setPositiveButton("Yes") { _, _ ->
- downloadManager.removeMedia(item.title, type)
- getDownloads()
- }
- builder.setNegativeButton("No") { _, _ ->
- // Do nothing
- }
- val dialog = builder.show()
- dialog.window?.setDimAmount(0.8f)
+ requireContext().customAlertDialog().apply {
+ setTitle("Delete ${item.title}?")
+ setMessage("Are you sure you want to delete ${item.title}?")
+ setPosButton(R.string.yes) {
+ downloadManager.removeMedia(item.title, type)
+ getDownloads()
+ }
+ setNegButton(R.string.no)
+ }.show()
true
}
}
diff --git a/app/src/main/java/ani/dantotsu/download/video/Helper.kt b/app/src/main/java/ani/dantotsu/download/video/Helper.kt
index b207d634617..ab8dd73d4da 100644
--- a/app/src/main/java/ani/dantotsu/download/video/Helper.kt
+++ b/app/src/main/java/ani/dantotsu/download/video/Helper.kt
@@ -3,7 +3,6 @@ package ani.dantotsu.download.video
import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
-import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
@@ -29,10 +28,10 @@ import ani.dantotsu.download.anime.AnimeDownloaderService
import ani.dantotsu.download.anime.AnimeServiceDataSingleton
import ani.dantotsu.media.Media
import ani.dantotsu.media.MediaType
-import ani.dantotsu.parsers.Subtitle
import ani.dantotsu.parsers.Video
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.util.Logger
+import ani.dantotsu.util.customAlertDialog
import eu.kanade.tachiyomi.network.NetworkHelper
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
@@ -72,19 +71,19 @@ object Helper {
episodeImage
)
- val downloadsManger = Injekt.get()
- val downloadCheck = downloadsManger
+ val downloadsManager = Injekt.get()
+ val downloadCheck = downloadsManager
.queryDownload(title, episode, MediaType.ANIME)
if (downloadCheck) {
- AlertDialog.Builder(context, R.style.MyPopup)
- .setTitle("Download Exists")
- .setMessage("A download for this episode already exists. Do you want to overwrite it?")
- .setPositiveButton("Yes") { _, _ ->
+ context.customAlertDialog().apply {
+ setTitle("Download Exists")
+ setMessage("A download for this episode already exists. Do you want to overwrite it?")
+ setPosButton(R.string.yes) {
PrefManager.getAnimeDownloadPreferences().edit()
.remove(animeDownloadTask.getTaskName())
.apply()
- downloadsManger.removeDownload(
+ downloadsManager.removeDownload(
DownloadedType(
title,
episode,
@@ -99,8 +98,9 @@ object Helper {
}
}
}
- .setNegativeButton("No") { _, _ -> }
- .show()
+ setNegButton(R.string.no)
+ show()
+ }
} else {
AnimeServiceDataSingleton.downloadQueue.offer(animeDownloadTask)
if (!AnimeServiceDataSingleton.isServiceRunning) {
diff --git a/app/src/main/java/ani/dantotsu/home/HomeFragment.kt b/app/src/main/java/ani/dantotsu/home/HomeFragment.kt
index a66506d937e..43bf8bea405 100644
--- a/app/src/main/java/ani/dantotsu/home/HomeFragment.kt
+++ b/app/src/main/java/ani/dantotsu/home/HomeFragment.kt
@@ -482,13 +482,12 @@ class HomeFragment : Fragment() {
CoroutineScope(Dispatchers.IO).launch {
model.setListImages()
}
- CoroutineScope(Dispatchers.IO).launch {
- model.initUserStatus()
- }
+
var empty = true
val homeLayoutShow: List =
PrefManager.getVal(PrefName.HomeLayout)
model.initHomePage()
+ model.initUserStatus()
(array.indices).forEach { i ->
if (homeLayoutShow.elementAt(i)) {
empty = false
diff --git a/app/src/main/java/ani/dantotsu/home/LoginFragment.kt b/app/src/main/java/ani/dantotsu/home/LoginFragment.kt
index 5f89464e3ce..13fde1e5479 100644
--- a/app/src/main/java/ani/dantotsu/home/LoginFragment.kt
+++ b/app/src/main/java/ani/dantotsu/home/LoginFragment.kt
@@ -12,12 +12,14 @@ import androidx.documentfile.provider.DocumentFile
import androidx.fragment.app.Fragment
import ani.dantotsu.R
import ani.dantotsu.connections.anilist.Anilist
+import ani.dantotsu.databinding.DialogUserAgentBinding
import ani.dantotsu.databinding.FragmentLoginBinding
import ani.dantotsu.openLinkInBrowser
import ani.dantotsu.settings.saving.internal.PreferenceKeystore
import ani.dantotsu.settings.saving.internal.PreferencePackager
import ani.dantotsu.toast
import ani.dantotsu.util.Logger
+import ani.dantotsu.util.customAlertDialog
import com.google.android.material.textfield.TextInputEditText
class LoginFragment : Fragment() {
@@ -94,38 +96,31 @@ class LoginFragment : Fragment() {
val password = CharArray(16).apply { fill('0') }
// Inflate the dialog layout
- val dialogView =
- LayoutInflater.from(requireActivity()).inflate(R.layout.dialog_user_agent, null)
- dialogView.findViewById(R.id.userAgentTextBox)?.hint = "Password"
- val subtitleTextView = dialogView.findViewById(R.id.subtitle)
- subtitleTextView?.visibility = View.VISIBLE
- subtitleTextView?.text = "Enter your password to decrypt the file"
+ val dialogView = DialogUserAgentBinding.inflate(layoutInflater).apply {
+ userAgentTextBox.hint = "Password"
+ subtitle.visibility = View.VISIBLE
+ subtitle.text = getString(R.string.enter_password_to_decrypt_file)
+ }
- val dialog = AlertDialog.Builder(requireActivity(), R.style.MyPopup)
- .setTitle("Enter Password")
- .setView(dialogView)
- .setPositiveButton("OK", null)
- .setNegativeButton("Cancel") { dialog, _ ->
+ requireActivity().customAlertDialog().apply {
+ setTitle("Enter Password")
+ setCustomView(dialogView.root)
+ setPosButton(R.string.ok){
+ val editText = dialogView.userAgentTextBox
+ if (editText.text?.isNotBlank() == true) {
+ editText.text?.toString()?.trim()?.toCharArray(password)
+ callback(password)
+ } else {
+ toast("Password cannot be empty")
+ }
+ }
+ setNegButton(R.string.cancel) {
password.fill('0')
- dialog.dismiss()
callback(null)
}
- .create()
+ }.show()
- dialog.window?.setDimAmount(0.8f)
- dialog.show()
- // Override the positive button here
- dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
- val editText = dialog.findViewById(R.id.userAgentTextBox)
- if (editText?.text?.isNotBlank() == true) {
- editText.text?.toString()?.trim()?.toCharArray(password)
- dialog.dismiss()
- callback(password)
- } else {
- toast("Password cannot be empty")
- }
- }
}
private fun restartApp() {
diff --git a/app/src/main/java/ani/dantotsu/home/status/Stories.kt b/app/src/main/java/ani/dantotsu/home/status/Stories.kt
index d65228442aa..a017b7ab467 100644
--- a/app/src/main/java/ani/dantotsu/home/status/Stories.kt
+++ b/app/src/main/java/ani/dantotsu/home/status/Stories.kt
@@ -5,7 +5,6 @@ import android.content.Context
import android.content.Intent
import android.content.res.ColorStateList
import android.util.AttributeSet
-import android.view.Gravity
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
@@ -16,7 +15,6 @@ import androidx.core.app.ActivityOptionsCompat
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
-import androidx.core.widget.NestedScrollView
import androidx.fragment.app.FragmentActivity
import ani.dantotsu.R
import ani.dantotsu.blurImage
@@ -32,6 +30,7 @@ import ani.dantotsu.profile.ProfileActivity
import ani.dantotsu.profile.User
import ani.dantotsu.profile.UsersDialogFragment
import ani.dantotsu.profile.activity.ActivityItemBuilder
+import ani.dantotsu.profile.activity.RepliesBottomDialog
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.snackString
diff --git a/app/src/main/java/ani/dantotsu/home/status/UserStatusAdapter.kt b/app/src/main/java/ani/dantotsu/home/status/UserStatusAdapter.kt
index 8aa021049e8..c8db4c99c1e 100644
--- a/app/src/main/java/ani/dantotsu/home/status/UserStatusAdapter.kt
+++ b/app/src/main/java/ani/dantotsu/home/status/UserStatusAdapter.kt
@@ -1,6 +1,5 @@
package ani.dantotsu.home.status
-import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.ViewGroup
@@ -16,7 +15,7 @@ import ani.dantotsu.profile.User
import ani.dantotsu.setAnimation
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.snackString
-import ani.dantotsu.util.MarkdownCreatorActivity
+import ani.dantotsu.util.ActivityMarkdownCreator
class UserStatusAdapter(private val user: ArrayList) :
RecyclerView.Adapter() {
@@ -43,7 +42,7 @@ class UserStatusAdapter(private val user: ArrayList) :
if (user[bindingAdapterPosition].id == Anilist.userid) {
ContextCompat.startActivity(
itemView.context,
- Intent(itemView.context, MarkdownCreatorActivity::class.java)
+ Intent(itemView.context, ActivityMarkdownCreator::class.java)
.putExtra("type", "activity"),
null
)
diff --git a/app/src/main/java/ani/dantotsu/media/CalendarActivity.kt b/app/src/main/java/ani/dantotsu/media/CalendarActivity.kt
index 66cec7e40fe..230f3a4e347 100644
--- a/app/src/main/java/ani/dantotsu/media/CalendarActivity.kt
+++ b/app/src/main/java/ani/dantotsu/media/CalendarActivity.kt
@@ -30,6 +30,7 @@ class CalendarActivity : AppCompatActivity() {
private lateinit var binding: ActivityListBinding
private val scope = lifecycleScope
private var selectedTabIdx = 1
+ private var showOnlyLibrary = false
private val model: OtherDetailsViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
@@ -38,8 +39,6 @@ class CalendarActivity : AppCompatActivity() {
ThemeManager(this).applyTheme()
binding = ActivityListBinding.inflate(layoutInflater)
-
-
val primaryColor = getThemeColor(com.google.android.material.R.attr.colorSurface)
val primaryTextColor = getThemeColor(com.google.android.material.R.attr.colorPrimary)
val secondaryTextColor = getThemeColor(com.google.android.material.R.attr.colorOutline)
@@ -79,6 +78,17 @@ class CalendarActivity : AppCompatActivity() {
override fun onTabReselected(tab: TabLayout.Tab?) {}
})
+ binding.listed.setOnClickListener {
+ showOnlyLibrary = !showOnlyLibrary
+ binding.listed.setImageResource(
+ if (showOnlyLibrary) R.drawable.ic_round_collections_bookmark_24
+ else R.drawable.ic_round_library_books_24
+ )
+ scope.launch {
+ model.loadCalendar(showOnlyLibrary)
+ }
+ }
+
model.getCalendar().observe(this) {
if (it != null) {
binding.listProgressBar.visibility = View.GONE
@@ -97,11 +107,10 @@ class CalendarActivity : AppCompatActivity() {
live.observe(this) {
if (it) {
scope.launch {
- withContext(Dispatchers.IO) { model.loadCalendar() }
+ withContext(Dispatchers.IO) { model.loadCalendar(showOnlyLibrary) }
live.postValue(false)
}
}
}
-
}
}
diff --git a/app/src/main/java/ani/dantotsu/media/OtherDetailsViewModel.kt b/app/src/main/java/ani/dantotsu/media/OtherDetailsViewModel.kt
index 0be0fc2224b..a086a765dda 100644
--- a/app/src/main/java/ani/dantotsu/media/OtherDetailsViewModel.kt
+++ b/app/src/main/java/ani/dantotsu/media/OtherDetailsViewModel.kt
@@ -26,25 +26,50 @@ class OtherDetailsViewModel : ViewModel() {
if (author.value == null) author.postValue(Anilist.query.getAuthorDetails(m))
}
+ private var cachedAllCalendarData: Map>? = null
+ private var cachedLibraryCalendarData: Map>? = null
private val calendar: MutableLiveData