Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: HeroBrine1st/E621
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 769df66155a4863af09ab01a5b94649434b7d0ef
Choose a base ref
..
head repository: HeroBrine1st/E621
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 81277a749a1e43e0e58cfa9acce23fbeaaa50962
Choose a head ref
Showing with 1,175 additions and 471 deletions.
  1. +2 −1 app/.gitignore
  2. +17 −20 app/build.gradle.kts
  3. +1 −1 app/src/main/java/ru/herobrine1st/e621/api/Constants.kt
  4. +11 −0 app/src/main/java/ru/herobrine1st/e621/api/model/File.kt
  5. +27 −11 app/src/main/java/ru/herobrine1st/e621/api/search/PostsSearchOptions.kt
  6. +5 −5 app/src/main/java/ru/herobrine1st/e621/database/Database.kt
  7. +1 −1 app/src/main/java/ru/herobrine1st/e621/database/Migrations.kt
  8. +3 −3 app/src/main/java/ru/herobrine1st/e621/{ → database}/dao/BlacklistDao.kt
  9. +3 −3 app/src/main/java/ru/herobrine1st/e621/{ → database}/dao/VoteDao.kt
  10. +2 −2 app/src/main/java/ru/herobrine1st/e621/{ → database}/entity/BlacklistEntry.kt
  11. +2 −2 app/src/main/java/ru/herobrine1st/e621/{ → database}/entity/Vote.kt
  12. +1 −1 app/src/main/java/ru/herobrine1st/e621/{data → database/repository}/BaseRepository.kt
  13. +1 −1 app/src/main/java/ru/herobrine1st/e621/{data → database/repository}/BaseRepositoryImpl.kt
  14. +1 −1 ...n/java/ru/herobrine1st/e621/{data → database/repository}/authorization/AuthorizationRepository.kt
  15. +1 −1 ...va/ru/herobrine1st/e621/{data → database/repository}/authorization/AuthorizationRepositoryImpl.kt
  16. +4 −4 app/src/main/java/ru/herobrine1st/e621/{data → database/repository}/blacklist/BlacklistRepository.kt
  17. +6 −5 .../main/java/ru/herobrine1st/e621/{data → database/repository}/blacklist/BlacklistRepositoryImpl.kt
  18. +3 −3 app/src/main/java/ru/herobrine1st/e621/{data → database/repository}/vote/VoteRepository.kt
  19. +4 −4 app/src/main/java/ru/herobrine1st/e621/{data → database/repository}/vote/VoteRepositoryImpl.kt
  20. +1 −1 app/src/main/java/ru/herobrine1st/e621/module/APIModule.kt
  21. +1 −1 app/src/main/java/ru/herobrine1st/e621/module/ActivityInjectionCompanion.kt
  22. +2 −2 app/src/main/java/ru/herobrine1st/e621/module/DatabaseModule.kt
  23. +2 −2 app/src/main/java/ru/herobrine1st/e621/navigation/component/BlacklistTogglesDialogComponent.kt
  24. +3 −3 app/src/main/java/ru/herobrine1st/e621/navigation/component/home/HomeComponent.kt
  25. +14 −23 app/src/main/java/ru/herobrine1st/e621/navigation/component/post/PostComponent.kt
  26. +70 −32 app/src/main/java/ru/herobrine1st/e621/navigation/component/posts/PostListingComponent.kt
  27. +2 −7 app/src/main/java/ru/herobrine1st/e621/navigation/component/posts/PostsSource.kt
  28. +2 −4 app/src/main/java/ru/herobrine1st/e621/navigation/component/search/SearchComponent.kt
  29. +5 −4 app/src/main/java/ru/herobrine1st/e621/navigation/component/settings/SettingsBlacklistComponent.kt
  30. +2 −2 ...c/main/java/ru/herobrine1st/e621/navigation/component/settings/SettingsBlacklistEntryComponent.kt
  31. +5 −5 app/src/main/java/ru/herobrine1st/e621/ui/Navigator.kt
  32. +5 −1 app/src/main/java/ru/herobrine1st/e621/ui/component/EndOfPagePlaceholder.kt
  33. +3 −3 app/src/main/java/ru/herobrine1st/e621/ui/screen/post/CommentsBottomSheetContent.kt
  34. +73 −6 app/src/main/java/ru/herobrine1st/e621/ui/screen/posts/Posts.kt
  35. +42 −20 app/src/main/java/ru/herobrine1st/e621/ui/screen/search/Search.kt
  36. +159 −0 app/src/main/java/ru/herobrine1st/paging/CreatePager.kt
  37. +0 −215 app/src/main/java/ru/herobrine1st/paging/Pager.kt
  38. +9 −1 app/src/main/java/ru/herobrine1st/paging/api/LoadState.kt
  39. +11 −1 app/src/main/java/ru/herobrine1st/paging/api/LoadStates.kt
  40. +1 −3 app/src/main/java/ru/herobrine1st/paging/api/PagingConfig.kt
  41. +10 −0 app/src/main/java/ru/herobrine1st/paging/api/PagingItems.kt
  42. +2 −2 app/src/main/java/ru/herobrine1st/paging/api/Snapshot.kt
  43. +79 −1 app/src/main/java/ru/herobrine1st/paging/api/Transformations.kt
  44. +126 −0 app/src/main/java/ru/herobrine1st/paging/contrib/decompose/DecomposeExtensions.kt
  45. +2 −0 app/src/main/java/ru/herobrine1st/paging/internal/Page.kt
  46. +320 −0 app/src/main/java/ru/herobrine1st/paging/internal/Pager.kt
  47. +89 −21 app/src/main/java/ru/herobrine1st/paging/internal/PagingItemsImpl.kt
  48. +7 −5 app/src/main/java/ru/herobrine1st/paging/internal/PagingRequest.kt
  49. +8 −16 app/src/main/java/ru/herobrine1st/paging/internal/{SynchronizedBus.kt → SavedPagerState.kt}
  50. +4 −2 app/src/main/res/values-ru-rRU/strings.xml
  51. +4 −2 app/src/main/res/values/strings.xml
  52. +1 −1 build.gradle.kts
  53. +15 −15 gradle/libs.versions.toml
  54. +1 −1 gradle/wrapper/gradle-wrapper.properties
3 changes: 2 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build
/release
/profileable
/profileable
/nightly
37 changes: 17 additions & 20 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import com.android.build.api.dsl.VariantDimension
import java.io.ByteArrayOutputStream

plugins {
alias(libs.plugins.android.application)
@@ -12,6 +12,11 @@ plugins {
alias(libs.plugins.aboutlibraries)
}

val gitCommitShortHashProvider = providers.exec {
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
isIgnoreExitValue = false
}

android {
compileSdk = libs.versions.android.compileSdk.get().toInt()

@@ -28,8 +33,10 @@ android {

// Application properties
resValue("string", "deep_link_host", "e621.net")
buildConfigField("int", "PAGER_PAGE_SIZE", "500")
buildConfigField("int", "PAGER_PREFETCH_DISTANCE", "50")
// https://issuetracker.google.com/issues/380805025 120 is max
buildConfigField("int", "PAGER_PAGE_SIZE", "100")
buildConfigField("int", "PAGER_PREFETCH_DISTANCE", "25")
buildConfigField("int", "PAGER_MAX_PAGES_IN_MEMORY", "3")
// Replaces all underscores in tags with spaces
buildConfigField("boolean", "HIDE_UNDERSCORES_FROM_USER", "true")
stringBuildConfigField("DATABASE_NAME", "DATABASE")
@@ -80,15 +87,18 @@ android {
matchingFallbacks.add("release")
signingConfig = signingConfigs.getByName("debug")
applicationIdSuffix = ".nightly"
versionNameSuffix = "-${getCommitShortHash()}"
val shortHashResult = gitCommitShortHashProvider.result.get()
shortHashResult.rethrowFailure()
shortHashResult.assertNormalExitValue()
versionNameSuffix = "-${gitCommitShortHashProvider.standardOutput.asText.get().trim()}"
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
freeCompilerArgs = listOf(
"-opt-in=kotlin.RequiresOptIn",
)
@@ -198,18 +208,5 @@ ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}

fun executeCommand(vararg argv: String): String {
val byteArrayOutputStream = ByteArrayOutputStream()
exec {
commandLine = argv.toList()
standardOutput = byteArrayOutputStream
isIgnoreExitValue = false
}
return byteArrayOutputStream.toString()
}

fun getCommitShortHash(revision: String = "HEAD") =
executeCommand("git", "rev-parse", "--short", revision).trim()

fun VariantDimension.stringBuildConfigField(name: String, value: String) =
buildConfigField("String", name, "\"${value.replace("\"", "\\\"")}\"")
2 changes: 1 addition & 1 deletion app/src/main/java/ru/herobrine1st/e621/api/Constants.kt
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
package ru.herobrine1st.e621.api


const val E621_MAX_POSTS_IN_QUERY = 500
const val E621_MAX_POSTS_IN_QUERY = 320

/**
* Maximum count of items in meta-tags like "id:1,2,3,4"
11 changes: 11 additions & 0 deletions app/src/main/java/ru/herobrine1st/e621/api/model/File.kt
Original file line number Diff line number Diff line change
@@ -57,6 +57,17 @@ data class NormalizedFile(
this(name, file.width, file.height, file.normalizedType, 0, file.urls.filterNotNull())

val aspectRatio get() = width.toFloat() / height.toFloat()

companion object {
val STUB = NormalizedFile(
"stub",
0,
0,
FileType.UNDEFINED,
0,
emptyList()
)
}
}

fun NormalizedFile.isOriginal() = name == "original"
Original file line number Diff line number Diff line change
@@ -33,6 +33,13 @@ import ru.herobrine1st.e621.api.model.Rating
import ru.herobrine1st.e621.api.model.Tag
import ru.herobrine1st.e621.util.debug

// A simplification of filetype, as there's actually no need to differ between png and jpg
enum class PostType {
IMAGE, // png, jpg
ANIMATION, // gif
VIDEO // webm
}

@Serializable
data class PostsSearchOptions(
val allOf: Set<Tag> = emptySet(),
@@ -42,8 +49,7 @@ data class PostsSearchOptions(
val orderAscending: Boolean = false,
val rating: Set<Rating> = emptySet(),
val favouritesOf: String? = null, // "favorited_by" in api
val fileType: FileType? = null,
val fileTypeInvert: Boolean = false,
val types: Set<PostType> = emptySet(),
val parent: PostId = PostId.INVALID,
val poolId: PoolId = -1,
) : SearchOptions {
@@ -56,7 +62,21 @@ data class PostsSearchOptions(
cache += noneOf.map { it.asExcluded }
cache += anyOf.map { it.asAlternative }
cache += optimizeRatingSelection(rating)
fileType?.extension?.let { cache += (if (fileTypeInvert) "-" else "") + "type:" + it }
val fileTypes = types.flatMap {
when (it) {
PostType.IMAGE -> listOf(FileType.PNG, FileType.JPG)
PostType.ANIMATION -> listOf(FileType.GIF)
PostType.VIDEO -> listOf(FileType.WEBM)
}
}
// API does not support OR-ing file types. Alternative tags work, but on common conditions,
// so e.g. `~type:png ~type:jpg ~anthro ~feral` returns posts that have `anthro` despite being a video)
// De Morgan's Law is here to save the day
if (fileTypes.size == 1) {
cache += "filetype:${fileTypes.single().extension}"
} else if (fileTypes.size > 1) {
cache += (FileType.entries - fileTypes - FileType.UNDEFINED).map { "-filetype:${it.extension}" }
}
favouritesOf?.let { cache += "fav:$it" }
(if (orderAscending) order.ascendingApiName else order.apiName)?.let { cache += "order:$it" }
if (parent != PostId.INVALID) cache += "parent:${parent.value}"
@@ -107,8 +127,7 @@ data class PostsSearchOptions(
orderAscending = orderAscending,
rating = rating.toSet(),
favouritesOf = favouritesOf,
fileType = fileType,
fileTypeInvert = fileTypeInvert,
types = types,
parent = parent,
poolId = poolId
)
@@ -131,8 +150,7 @@ data class PostsSearchOptions(
var orderAscending: Boolean = false,
var rating: MutableSet<Rating> = mutableSetOf(),
var favouritesOf: String? = null,
var fileType: FileType? = null,
var fileTypeInvert: Boolean = false,
var types: Set<PostType> = mutableSetOf(),
var parent: PostId = PostId.INVALID,
var poolId: PoolId = -1,
) {
@@ -145,8 +163,7 @@ data class PostsSearchOptions(
orderAscending = orderAscending,
rating = rating,
favouritesOf = favouritesOf,
fileType = fileType,
fileTypeInvert = fileTypeInvert,
types = this@Builder.types,
parent = parent,
poolId = poolId
)
@@ -162,8 +179,7 @@ data class PostsSearchOptions(
orderAscending = orderAscending,
rating = rating.toMutableSet(),
favouritesOf = favouritesOf,
fileType = fileType,
fileTypeInvert = fileTypeInvert,
types = types,
parent = parent,
poolId = poolId
)
10 changes: 5 additions & 5 deletions app/src/main/java/ru/herobrine1st/e621/database/Database.kt
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* This file is part of ru.herobrine1st.e621.
*
* ru.herobrine1st.e621 is an android client for https://e621.net
* Copyright (C) 2022-2024 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
* Copyright (C) 2022-2025 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
*
* 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
@@ -23,10 +23,10 @@ package ru.herobrine1st.e621.database
import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.RoomDatabase
import ru.herobrine1st.e621.dao.BlacklistDao
import ru.herobrine1st.e621.dao.VoteDao
import ru.herobrine1st.e621.entity.BlacklistEntry
import ru.herobrine1st.e621.entity.Vote
import ru.herobrine1st.e621.database.dao.BlacklistDao
import ru.herobrine1st.e621.database.dao.VoteDao
import ru.herobrine1st.e621.database.entity.BlacklistEntry
import ru.herobrine1st.e621.database.entity.Vote

private const val VERSION = 3

Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* This file is part of ru.herobrine1st.e621.
*
* ru.herobrine1st.e621 is an android client for https://e621.net
* Copyright (C) 2022-2024 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
* Copyright (C) 2022-2025 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
*
* 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
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* This file is part of ru.herobrine1st.e621.
*
* ru.herobrine1st.e621 is an android client for https://e621.net
* Copyright (C) 2022-2024 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
* Copyright (C) 2022-2025 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
*
* 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
@@ -18,7 +18,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.herobrine1st.e621.dao
package ru.herobrine1st.e621.database.dao

import androidx.room.Dao
import androidx.room.Delete
@@ -27,7 +27,7 @@ import androidx.room.Query
import androidx.room.Transaction
import androidx.room.Update
import kotlinx.coroutines.flow.Flow
import ru.herobrine1st.e621.entity.BlacklistEntry
import ru.herobrine1st.e621.database.entity.BlacklistEntry

@Dao
interface BlacklistDao {
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* This file is part of ru.herobrine1st.e621.
*
* ru.herobrine1st.e621 is an android client for https://e621.net
* Copyright (C) 2022-2024 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
* Copyright (C) 2022-2025 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
*
* 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
@@ -18,14 +18,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.herobrine1st.e621.dao
package ru.herobrine1st.e621.database.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import ru.herobrine1st.e621.entity.Vote
import ru.herobrine1st.e621.database.entity.Vote

@Dao
interface VoteDao {
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* This file is part of ru.herobrine1st.e621.
*
* ru.herobrine1st.e621 is an android client for https://e621.net
* Copyright (C) 2022-2024 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
* Copyright (C) 2022-2025 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
*
* 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
@@ -18,7 +18,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.herobrine1st.e621.entity
package ru.herobrine1st.e621.database.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* This file is part of ru.herobrine1st.e621.
*
* ru.herobrine1st.e621 is an android client for https://e621.net
* Copyright (C) 2022-2024 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
* Copyright (C) 2022-2025 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
*
* 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
@@ -18,7 +18,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.herobrine1st.e621.entity
package ru.herobrine1st.e621.database.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.herobrine1st.e621.data
package ru.herobrine1st.e621.database.repository

interface BaseRepository {
suspend fun <R> withTransaction(block: suspend () -> R): R
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.herobrine1st.e621.data
package ru.herobrine1st.e621.database.repository

import androidx.room.withTransaction
import ru.herobrine1st.e621.database.Database
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.herobrine1st.e621.data.authorization
package ru.herobrine1st.e621.database.repository.authorization

import kotlinx.coroutines.flow.Flow
import ru.herobrine1st.e621.preference.AuthorizationCredentials
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.herobrine1st.e621.data.authorization
package ru.herobrine1st.e621.database.repository.authorization

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* This file is part of ru.herobrine1st.e621.
*
* ru.herobrine1st.e621 is an android client for https://e621.net
* Copyright (C) 2022-2024 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
* Copyright (C) 2022-2025 HeroBrine1st Erquilenne <project-e621-android@herobrine1st.ru>
*
* 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
@@ -18,11 +18,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ru.herobrine1st.e621.data.blacklist
package ru.herobrine1st.e621.database.repository.blacklist

import kotlinx.coroutines.flow.Flow
import ru.herobrine1st.e621.data.BaseRepository
import ru.herobrine1st.e621.entity.BlacklistEntry
import ru.herobrine1st.e621.database.repository.BaseRepository
import ru.herobrine1st.e621.database.entity.BlacklistEntry

interface BlacklistRepository: BaseRepository {
fun getEntriesFlow(): Flow<List<BlacklistEntry>>
Loading