From d3a73fc22849a915483bea03fcd7c20834b1f4d8 Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 22 Jan 2023 16:12:29 +0100 Subject: [PATCH] Move Category `model` and `repository` to domain and data layer (#8967) To keep the commit from being 100+ files the interactors wasn't moved. The domain module like the data module uses `tachiyomi` instead of `eu.kanade.tachiyomi` for package names --- app/build.gradle.kts | 1 + .../java/eu/kanade/domain/DomainModule.kt | 4 ++-- .../interactor/CreateCategoryWithName.kt | 4 ++-- .../category/interactor/DeleteCategory.kt | 4 ++-- .../category/interactor/GetCategories.kt | 4 ++-- .../category/interactor/RenameCategory.kt | 6 +++--- .../category/interactor/ReorderCategory.kt | 6 +++--- .../category/interactor/ResetCategoryFlags.kt | 2 +- .../interactor/SetDisplayModeForCategory.kt | 6 +++--- .../interactor/SetSortModeForCategory.kt | 6 +++--- .../category/interactor/UpdateCategory.kt | 4 ++-- .../library/model/LibraryDisplayMode.kt | 2 +- .../domain/library/model/LibrarySort.kt | 2 +- .../category/CategoryExtensions.kt | 2 +- .../presentation/category/CategoryScreen.kt | 2 +- .../category/components/CategoryContent.kt | 2 +- .../category/components/CategoryDialogs.kt | 7 +++++-- .../category/components/CategoryListItem.kt | 2 +- .../components/ChangeCategoryDialog.kt | 2 +- .../library/components/LibraryContent.kt | 2 +- .../library/components/LibraryTabs.kt | 2 +- .../more/settings/screen/Commons.kt | 2 +- .../settings/screen/SettingsDownloadScreen.kt | 2 +- .../settings/screen/SettingsLibraryScreen.kt | 2 +- .../tachiyomi/data/backup/BackupManager.kt | 2 +- .../data/backup/models/BackupCategory.kt | 2 +- .../data/library/LibraryUpdateService.kt | 2 +- .../source/browse/BrowseSourceScreenModel.kt | 2 +- .../ui/category/CategoryScreenModel.kt | 2 +- .../ui/library/LibraryScreenModel.kt | 2 +- .../ui/library/LibrarySettingsSheet.kt | 2 +- .../kanade/tachiyomi/ui/library/LibraryTab.kt | 2 +- .../kanade/tachiyomi/ui/main/MainActivity.kt | 2 +- .../tachiyomi/ui/manga/MangaScreenModel.kt | 2 +- data/build.gradle.kts | 1 + data/src/main/AndroidManifest.xml | 4 +--- .../data/category/CategoryMapper.kt | 4 ++-- .../data/category/CategoryRepositoryImpl.kt | 8 +++---- domain/.gitignore | 1 + domain/build.gradle.kts | 19 +++++++++++++++++ domain/consumer-rules.pro | 0 domain/proguard-rules.pro | 21 +++++++++++++++++++ domain/src/main/AndroidManifest.xml | 2 ++ .../domain/category/model/Category.kt | 6 +----- .../domain/category/model/CategoryUpdate.kt | 2 +- .../category/repository/CategoryRepository.kt | 6 +++--- settings.gradle.kts | 1 + 47 files changed, 108 insertions(+), 65 deletions(-) rename {app/src/main/java/eu/kanade => data/src/main/java/tachiyomi}/data/category/CategoryMapper.kt (71%) rename {app/src/main/java/eu/kanade => data/src/main/java/tachiyomi}/data/category/CategoryRepositoryImpl.kt (92%) create mode 100644 domain/.gitignore create mode 100644 domain/build.gradle.kts create mode 100644 domain/consumer-rules.pro create mode 100644 domain/proguard-rules.pro create mode 100644 domain/src/main/AndroidManifest.xml rename {app/src/main/java/eu/kanade => domain/src/main/java/tachiyomi}/domain/category/model/Category.kt (66%) rename {app/src/main/java/eu/kanade => domain/src/main/java/tachiyomi}/domain/category/model/CategoryUpdate.kt (77%) rename {app/src/main/java/eu/kanade => domain/src/main/java/tachiyomi}/domain/category/repository/CategoryRepository.kt (80%) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5359ed226..0a4179758 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -142,6 +142,7 @@ dependencies { implementation(project(":core")) implementation(project(":source-api")) implementation(project(":data")) + implementation(project(":domain")) // Compose implementation(platform(compose.bom)) diff --git a/app/src/main/java/eu/kanade/domain/DomainModule.kt b/app/src/main/java/eu/kanade/domain/DomainModule.kt index e007f4950..eaea7ca99 100644 --- a/app/src/main/java/eu/kanade/domain/DomainModule.kt +++ b/app/src/main/java/eu/kanade/domain/DomainModule.kt @@ -1,6 +1,5 @@ package eu.kanade.domain -import eu.kanade.data.category.CategoryRepositoryImpl import eu.kanade.data.chapter.ChapterRepositoryImpl import eu.kanade.data.history.HistoryRepositoryImpl import eu.kanade.data.manga.MangaRepositoryImpl @@ -18,7 +17,6 @@ import eu.kanade.domain.category.interactor.SetDisplayModeForCategory import eu.kanade.domain.category.interactor.SetMangaCategories import eu.kanade.domain.category.interactor.SetSortModeForCategory import eu.kanade.domain.category.interactor.UpdateCategory -import eu.kanade.domain.category.repository.CategoryRepository import eu.kanade.domain.chapter.interactor.GetChapter import eu.kanade.domain.chapter.interactor.GetChapterByMangaId import eu.kanade.domain.chapter.interactor.SetMangaDefaultChapterFlags @@ -67,6 +65,8 @@ import eu.kanade.domain.track.interactor.InsertTrack import eu.kanade.domain.track.repository.TrackRepository import eu.kanade.domain.updates.interactor.GetUpdates import eu.kanade.domain.updates.repository.UpdatesRepository +import tachiyomi.data.category.CategoryRepositoryImpl +import tachiyomi.domain.category.repository.CategoryRepository import uy.kohesive.injekt.api.InjektModule import uy.kohesive.injekt.api.InjektRegistrar import uy.kohesive.injekt.api.addFactory diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt b/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt index 7daafb71b..07e32d434 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt @@ -1,11 +1,11 @@ package eu.kanade.domain.category.interactor -import eu.kanade.domain.category.model.Category -import eu.kanade.domain.category.repository.CategoryRepository import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.tachiyomi.util.lang.withNonCancellableContext import eu.kanade.tachiyomi.util.system.logcat import logcat.LogPriority +import tachiyomi.domain.category.model.Category +import tachiyomi.domain.category.repository.CategoryRepository class CreateCategoryWithName( private val categoryRepository: CategoryRepository, diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/DeleteCategory.kt b/app/src/main/java/eu/kanade/domain/category/interactor/DeleteCategory.kt index 54f622e23..66af386b8 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/DeleteCategory.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/DeleteCategory.kt @@ -1,10 +1,10 @@ package eu.kanade.domain.category.interactor -import eu.kanade.domain.category.model.CategoryUpdate -import eu.kanade.domain.category.repository.CategoryRepository import eu.kanade.tachiyomi.util.lang.withNonCancellableContext import eu.kanade.tachiyomi.util.system.logcat import logcat.LogPriority +import tachiyomi.domain.category.model.CategoryUpdate +import tachiyomi.domain.category.repository.CategoryRepository class DeleteCategory( private val categoryRepository: CategoryRepository, diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/GetCategories.kt b/app/src/main/java/eu/kanade/domain/category/interactor/GetCategories.kt index a13fb7e89..379d7d737 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/GetCategories.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/GetCategories.kt @@ -1,8 +1,8 @@ package eu.kanade.domain.category.interactor -import eu.kanade.domain.category.model.Category -import eu.kanade.domain.category.repository.CategoryRepository import kotlinx.coroutines.flow.Flow +import tachiyomi.domain.category.model.Category +import tachiyomi.domain.category.repository.CategoryRepository class GetCategories( private val categoryRepository: CategoryRepository, diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/RenameCategory.kt b/app/src/main/java/eu/kanade/domain/category/interactor/RenameCategory.kt index b298ac020..1053cdd80 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/RenameCategory.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/RenameCategory.kt @@ -1,11 +1,11 @@ package eu.kanade.domain.category.interactor -import eu.kanade.domain.category.model.Category -import eu.kanade.domain.category.model.CategoryUpdate -import eu.kanade.domain.category.repository.CategoryRepository import eu.kanade.tachiyomi.util.lang.withNonCancellableContext import eu.kanade.tachiyomi.util.system.logcat import logcat.LogPriority +import tachiyomi.domain.category.model.Category +import tachiyomi.domain.category.model.CategoryUpdate +import tachiyomi.domain.category.repository.CategoryRepository class RenameCategory( private val categoryRepository: CategoryRepository, diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/ReorderCategory.kt b/app/src/main/java/eu/kanade/domain/category/interactor/ReorderCategory.kt index 3687e4880..5df5940d9 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/ReorderCategory.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/ReorderCategory.kt @@ -1,13 +1,13 @@ package eu.kanade.domain.category.interactor -import eu.kanade.domain.category.model.Category -import eu.kanade.domain.category.model.CategoryUpdate -import eu.kanade.domain.category.repository.CategoryRepository import eu.kanade.tachiyomi.util.lang.withNonCancellableContext import eu.kanade.tachiyomi.util.system.logcat import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import logcat.LogPriority +import tachiyomi.domain.category.model.Category +import tachiyomi.domain.category.model.CategoryUpdate +import tachiyomi.domain.category.repository.CategoryRepository import java.util.Collections class ReorderCategory( diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/ResetCategoryFlags.kt b/app/src/main/java/eu/kanade/domain/category/interactor/ResetCategoryFlags.kt index 773301967..2c75493bd 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/ResetCategoryFlags.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/ResetCategoryFlags.kt @@ -1,8 +1,8 @@ package eu.kanade.domain.category.interactor -import eu.kanade.domain.category.repository.CategoryRepository import eu.kanade.domain.library.model.plus import eu.kanade.domain.library.service.LibraryPreferences +import tachiyomi.domain.category.repository.CategoryRepository class ResetCategoryFlags( private val preferences: LibraryPreferences, diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/SetDisplayModeForCategory.kt b/app/src/main/java/eu/kanade/domain/category/interactor/SetDisplayModeForCategory.kt index 464455621..09c46b925 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/SetDisplayModeForCategory.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/SetDisplayModeForCategory.kt @@ -1,11 +1,11 @@ package eu.kanade.domain.category.interactor -import eu.kanade.domain.category.model.Category -import eu.kanade.domain.category.model.CategoryUpdate -import eu.kanade.domain.category.repository.CategoryRepository import eu.kanade.domain.library.model.LibraryDisplayMode import eu.kanade.domain.library.model.plus import eu.kanade.domain.library.service.LibraryPreferences +import tachiyomi.domain.category.model.Category +import tachiyomi.domain.category.model.CategoryUpdate +import tachiyomi.domain.category.repository.CategoryRepository class SetDisplayModeForCategory( private val preferences: LibraryPreferences, diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/SetSortModeForCategory.kt b/app/src/main/java/eu/kanade/domain/category/interactor/SetSortModeForCategory.kt index d9c9ad6cc..e58652241 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/SetSortModeForCategory.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/SetSortModeForCategory.kt @@ -1,11 +1,11 @@ package eu.kanade.domain.category.interactor -import eu.kanade.domain.category.model.Category -import eu.kanade.domain.category.model.CategoryUpdate -import eu.kanade.domain.category.repository.CategoryRepository import eu.kanade.domain.library.model.LibrarySort import eu.kanade.domain.library.model.plus import eu.kanade.domain.library.service.LibraryPreferences +import tachiyomi.domain.category.model.Category +import tachiyomi.domain.category.model.CategoryUpdate +import tachiyomi.domain.category.repository.CategoryRepository class SetSortModeForCategory( private val preferences: LibraryPreferences, diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/UpdateCategory.kt b/app/src/main/java/eu/kanade/domain/category/interactor/UpdateCategory.kt index 0fccd6a18..265017ab2 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/UpdateCategory.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/UpdateCategory.kt @@ -1,8 +1,8 @@ package eu.kanade.domain.category.interactor -import eu.kanade.domain.category.model.CategoryUpdate -import eu.kanade.domain.category.repository.CategoryRepository import eu.kanade.tachiyomi.util.lang.withNonCancellableContext +import tachiyomi.domain.category.model.CategoryUpdate +import tachiyomi.domain.category.repository.CategoryRepository class UpdateCategory( private val categoryRepository: CategoryRepository, diff --git a/app/src/main/java/eu/kanade/domain/library/model/LibraryDisplayMode.kt b/app/src/main/java/eu/kanade/domain/library/model/LibraryDisplayMode.kt index d96e1ff81..37c53c64f 100644 --- a/app/src/main/java/eu/kanade/domain/library/model/LibraryDisplayMode.kt +++ b/app/src/main/java/eu/kanade/domain/library/model/LibraryDisplayMode.kt @@ -1,6 +1,6 @@ package eu.kanade.domain.library.model -import eu.kanade.domain.category.model.Category +import tachiyomi.domain.category.model.Category sealed class LibraryDisplayMode( override val flag: Long, diff --git a/app/src/main/java/eu/kanade/domain/library/model/LibrarySort.kt b/app/src/main/java/eu/kanade/domain/library/model/LibrarySort.kt index e7a74ce86..cf1b56799 100644 --- a/app/src/main/java/eu/kanade/domain/library/model/LibrarySort.kt +++ b/app/src/main/java/eu/kanade/domain/library/model/LibrarySort.kt @@ -1,6 +1,6 @@ package eu.kanade.domain.library.model -import eu.kanade.domain.category.model.Category +import tachiyomi.domain.category.model.Category data class LibrarySort( val type: Type, diff --git a/app/src/main/java/eu/kanade/presentation/category/CategoryExtensions.kt b/app/src/main/java/eu/kanade/presentation/category/CategoryExtensions.kt index 8d9bdb42c..0f2ade48e 100644 --- a/app/src/main/java/eu/kanade/presentation/category/CategoryExtensions.kt +++ b/app/src/main/java/eu/kanade/presentation/category/CategoryExtensions.kt @@ -3,8 +3,8 @@ package eu.kanade.presentation.category import android.content.Context import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource -import eu.kanade.domain.category.model.Category import eu.kanade.tachiyomi.R +import tachiyomi.domain.category.model.Category val Category.visualName: String @Composable diff --git a/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt b/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt index 53d53ab2d..5de8d923a 100644 --- a/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt @@ -7,7 +7,6 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import eu.kanade.domain.category.model.Category import eu.kanade.presentation.category.components.CategoryContent import eu.kanade.presentation.category.components.CategoryFloatingActionButton import eu.kanade.presentation.components.AppBar @@ -18,6 +17,7 @@ import eu.kanade.presentation.util.plus import eu.kanade.presentation.util.topSmallPaddingValues import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.category.CategoryScreenState +import tachiyomi.domain.category.model.Category @Composable fun CategoryScreen( diff --git a/app/src/main/java/eu/kanade/presentation/category/components/CategoryContent.kt b/app/src/main/java/eu/kanade/presentation/category/components/CategoryContent.kt index 13e6823cf..01e579663 100644 --- a/app/src/main/java/eu/kanade/presentation/category/components/CategoryContent.kt +++ b/app/src/main/java/eu/kanade/presentation/category/components/CategoryContent.kt @@ -7,9 +7,9 @@ import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import eu.kanade.domain.category.model.Category import eu.kanade.presentation.components.LazyColumn import eu.kanade.presentation.util.padding +import tachiyomi.domain.category.model.Category @Composable fun CategoryContent( diff --git a/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt b/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt index bd0596289..3960a992e 100644 --- a/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt +++ b/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt @@ -14,10 +14,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.res.stringResource -import eu.kanade.domain.category.model.Category -import eu.kanade.domain.category.model.anyWithName import eu.kanade.tachiyomi.R import kotlinx.coroutines.delay +import tachiyomi.domain.category.model.Category import kotlin.time.Duration.Companion.seconds @Composable @@ -164,3 +163,7 @@ fun CategoryDeleteDialog( }, ) } + +internal fun List.anyWithName(name: String): Boolean { + return any { name == it.name } +} diff --git a/app/src/main/java/eu/kanade/presentation/category/components/CategoryListItem.kt b/app/src/main/java/eu/kanade/presentation/category/components/CategoryListItem.kt index 283692e95..27e2695b4 100644 --- a/app/src/main/java/eu/kanade/presentation/category/components/CategoryListItem.kt +++ b/app/src/main/java/eu/kanade/presentation/category/components/CategoryListItem.kt @@ -20,9 +20,9 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import eu.kanade.domain.category.model.Category import eu.kanade.presentation.util.padding import eu.kanade.tachiyomi.R +import tachiyomi.domain.category.model.Category @Composable fun CategoryListItem( diff --git a/app/src/main/java/eu/kanade/presentation/components/ChangeCategoryDialog.kt b/app/src/main/java/eu/kanade/presentation/components/ChangeCategoryDialog.kt index 4fb72fc43..b6689a068 100644 --- a/app/src/main/java/eu/kanade/presentation/components/ChangeCategoryDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/components/ChangeCategoryDialog.kt @@ -22,10 +22,10 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import eu.kanade.core.prefs.CheckboxState -import eu.kanade.domain.category.model.Category import eu.kanade.presentation.category.visualName import eu.kanade.presentation.util.padding import eu.kanade.tachiyomi.R +import tachiyomi.domain.category.model.Category @Composable fun ChangeCategoryDialog( diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt index 28ce0bdac..2248d5a6c 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt @@ -15,7 +15,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalLayoutDirection import eu.kanade.core.prefs.PreferenceMutableState -import eu.kanade.domain.category.model.Category import eu.kanade.domain.library.model.LibraryDisplayMode import eu.kanade.domain.library.model.LibraryManga import eu.kanade.presentation.components.PullRefresh @@ -23,6 +22,7 @@ import eu.kanade.presentation.components.rememberPagerState import eu.kanade.tachiyomi.ui.library.LibraryItem import kotlinx.coroutines.delay import kotlinx.coroutines.launch +import tachiyomi.domain.category.model.Category import kotlin.time.Duration.Companion.seconds @Composable diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryTabs.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryTabs.kt index c5ed121c1..df3dd4cd7 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryTabs.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryTabs.kt @@ -6,11 +6,11 @@ import androidx.compose.material3.ScrollableTabRow import androidx.compose.material3.Tab import androidx.compose.runtime.Composable import androidx.compose.ui.unit.dp -import eu.kanade.domain.category.model.Category import eu.kanade.presentation.category.visualName import eu.kanade.presentation.components.Divider import eu.kanade.presentation.components.TabIndicator import eu.kanade.presentation.components.TabText +import tachiyomi.domain.category.model.Category @Composable fun LibraryTabs( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/Commons.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/Commons.kt index b82df6918..641a48f35 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/Commons.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/Commons.kt @@ -4,9 +4,9 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource -import eu.kanade.domain.category.model.Category import eu.kanade.presentation.category.visualName import eu.kanade.tachiyomi.R +import tachiyomi.domain.category.model.Category /** * Returns a string of categories name for settings subtitle diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt index f42b83eef..0dc0be3ca 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsDownloadScreen.kt @@ -20,7 +20,6 @@ import androidx.compose.ui.util.fastMap import androidx.core.net.toUri import com.hippo.unifile.UniFile import eu.kanade.domain.category.interactor.GetCategories -import eu.kanade.domain.category.model.Category import eu.kanade.domain.download.service.DownloadPreferences import eu.kanade.presentation.category.visualName import eu.kanade.presentation.more.settings.Preference @@ -28,6 +27,7 @@ import eu.kanade.presentation.more.settings.widget.TriStateListDialog import eu.kanade.presentation.util.collectAsState import eu.kanade.tachiyomi.R import kotlinx.coroutines.runBlocking +import tachiyomi.domain.category.model.Category import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.io.File diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt index 80ced0194..67a7682b3 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt @@ -38,7 +38,6 @@ import cafe.adriel.voyager.navigator.currentOrThrow import com.commandiron.wheel_picker_compose.WheelPicker import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.interactor.ResetCategoryFlags -import eu.kanade.domain.category.model.Category import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.presentation.category.visualName import eu.kanade.presentation.more.settings.Preference @@ -57,6 +56,7 @@ import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.ui.category.CategoryScreen import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import tachiyomi.domain.category.model.Category import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt index f8441933b..10146fd6f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt @@ -6,7 +6,6 @@ import android.net.Uri import com.hippo.unifile.UniFile import eu.kanade.domain.backup.service.BackupPreferences import eu.kanade.domain.category.interactor.GetCategories -import eu.kanade.domain.category.model.Category import eu.kanade.domain.history.model.HistoryUpdate import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.manga.interactor.GetFavorites @@ -45,6 +44,7 @@ import tachiyomi.data.DatabaseHandler import tachiyomi.data.Manga_sync import tachiyomi.data.Mangas import tachiyomi.data.updateStrategyAdapter +import tachiyomi.domain.category.model.Category import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.io.FileOutputStream diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupCategory.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupCategory.kt index d58a85ce9..8d93a0b32 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupCategory.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupCategory.kt @@ -1,8 +1,8 @@ package eu.kanade.tachiyomi.data.backup.models -import eu.kanade.domain.category.model.Category import kotlinx.serialization.Serializable import kotlinx.serialization.protobuf.ProtoNumber +import tachiyomi.domain.category.model.Category @Serializable class BackupCategory( diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index eb7970436..059f47c7b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -8,7 +8,6 @@ import android.os.PowerManager import androidx.core.content.ContextCompat import eu.kanade.data.chapter.NoChaptersException import eu.kanade.domain.category.interactor.GetCategories -import eu.kanade.domain.category.model.Category import eu.kanade.domain.chapter.interactor.GetChapterByMangaId import eu.kanade.domain.chapter.interactor.SyncChaptersWithSource import eu.kanade.domain.chapter.interactor.SyncChaptersWithTrackServiceTwoWay @@ -65,6 +64,7 @@ import kotlinx.coroutines.supervisorScope import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.sync.withPermit import logcat.LogPriority +import tachiyomi.domain.category.model.Category import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.io.File diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt index 30ce4e2a0..55ca4b9d7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt @@ -19,7 +19,6 @@ import eu.kanade.core.prefs.asState import eu.kanade.core.prefs.mapAsCheckboxState import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.interactor.SetMangaCategories -import eu.kanade.domain.category.model.Category import eu.kanade.domain.chapter.interactor.GetChapterByMangaId import eu.kanade.domain.chapter.interactor.SetMangaDefaultChapterFlags import eu.kanade.domain.chapter.interactor.SyncChaptersWithTrackServiceTwoWay @@ -71,6 +70,7 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import logcat.LogPriority +import tachiyomi.domain.category.model.Category import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.util.Date diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryScreenModel.kt index 643362c4b..f929d4b23 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryScreenModel.kt @@ -9,13 +9,13 @@ import eu.kanade.domain.category.interactor.DeleteCategory import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.interactor.RenameCategory import eu.kanade.domain.category.interactor.ReorderCategory -import eu.kanade.domain.category.model.Category import eu.kanade.tachiyomi.R import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch +import tachiyomi.domain.category.model.Category import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt index 89e07cba3..1dd26c932 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt @@ -18,7 +18,6 @@ import eu.kanade.core.util.fastPartition import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.interactor.SetMangaCategories -import eu.kanade.domain.category.model.Category import eu.kanade.domain.chapter.interactor.GetChapterByMangaId import eu.kanade.domain.chapter.interactor.SetReadStatus import eu.kanade.domain.chapter.model.Chapter @@ -58,6 +57,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.update +import tachiyomi.domain.category.model.Category import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.text.Collator diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt index c199ede99..8cf03f52a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt @@ -7,7 +7,6 @@ import android.view.View import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.category.interactor.SetDisplayModeForCategory import eu.kanade.domain.category.interactor.SetSortModeForCategory -import eu.kanade.domain.category.model.Category import eu.kanade.domain.library.model.LibraryDisplayMode import eu.kanade.domain.library.model.LibrarySort import eu.kanade.domain.library.model.display @@ -23,6 +22,7 @@ import eu.kanade.tachiyomi.widget.sheet.TabbedBottomSheetDialog import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job +import tachiyomi.domain.category.model.Category import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt index b9860d842..57c4b1a93 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt @@ -28,7 +28,6 @@ import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.navigator.currentOrThrow import cafe.adriel.voyager.navigator.tab.LocalTabNavigator import cafe.adriel.voyager.navigator.tab.TabOptions -import eu.kanade.domain.category.model.Category import eu.kanade.domain.library.model.LibraryManga import eu.kanade.domain.library.model.display import eu.kanade.domain.manga.model.Manga @@ -57,6 +56,7 @@ import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.launch +import tachiyomi.domain.category.model.Category object LibraryTab : Tab { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index a6b45fe13..fd51a9d4d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -51,7 +51,6 @@ import cafe.adriel.voyager.navigator.NavigatorDisposeBehavior import cafe.adriel.voyager.navigator.currentOrThrow import com.google.accompanist.systemuicontroller.rememberSystemUiController import eu.kanade.domain.base.BasePreferences -import eu.kanade.domain.category.model.Category import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.ui.UiPreferences @@ -95,6 +94,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import logcat.LogPriority +import tachiyomi.domain.category.model.Category import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt index 13f2c16b3..2016d703a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt @@ -15,7 +15,6 @@ import eu.kanade.core.util.addOrRemove import eu.kanade.data.chapter.NoChaptersException import eu.kanade.domain.category.interactor.GetCategories import eu.kanade.domain.category.interactor.SetMangaCategories -import eu.kanade.domain.category.model.Category import eu.kanade.domain.chapter.interactor.SetMangaDefaultChapterFlags import eu.kanade.domain.chapter.interactor.SetReadStatus import eu.kanade.domain.chapter.interactor.SyncChaptersWithSource @@ -70,6 +69,7 @@ import kotlinx.coroutines.flow.update import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import logcat.LogPriority +import tachiyomi.domain.category.model.Category import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.text.DecimalFormat diff --git a/data/build.gradle.kts b/data/build.gradle.kts index 250b0a8b4..062405e63 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -21,6 +21,7 @@ android { dependencies { implementation(project(":source-api")) + implementation(project(":domain")) api(libs.sqldelight.android.driver) api(libs.sqldelight.coroutines) api(libs.sqldelight.android.paging) diff --git a/data/src/main/AndroidManifest.xml b/data/src/main/AndroidManifest.xml index a5918e68a..568741e54 100644 --- a/data/src/main/AndroidManifest.xml +++ b/data/src/main/AndroidManifest.xml @@ -1,4 +1,2 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/data/category/CategoryMapper.kt b/data/src/main/java/tachiyomi/data/category/CategoryMapper.kt similarity index 71% rename from app/src/main/java/eu/kanade/data/category/CategoryMapper.kt rename to data/src/main/java/tachiyomi/data/category/CategoryMapper.kt index 3f9a3ec51..37f18ae80 100644 --- a/app/src/main/java/eu/kanade/data/category/CategoryMapper.kt +++ b/data/src/main/java/tachiyomi/data/category/CategoryMapper.kt @@ -1,6 +1,6 @@ -package eu.kanade.data.category +package tachiyomi.data.category -import eu.kanade.domain.category.model.Category +import tachiyomi.domain.category.model.Category val categoryMapper: (Long, String, Long, Long) -> Category = { id, name, order, flags -> Category( diff --git a/app/src/main/java/eu/kanade/data/category/CategoryRepositoryImpl.kt b/data/src/main/java/tachiyomi/data/category/CategoryRepositoryImpl.kt similarity index 92% rename from app/src/main/java/eu/kanade/data/category/CategoryRepositoryImpl.kt rename to data/src/main/java/tachiyomi/data/category/CategoryRepositoryImpl.kt index 2fb6971d4..75cfbf7d1 100644 --- a/app/src/main/java/eu/kanade/data/category/CategoryRepositoryImpl.kt +++ b/data/src/main/java/tachiyomi/data/category/CategoryRepositoryImpl.kt @@ -1,11 +1,11 @@ -package eu.kanade.data.category +package tachiyomi.data.category -import eu.kanade.domain.category.model.Category -import eu.kanade.domain.category.model.CategoryUpdate -import eu.kanade.domain.category.repository.CategoryRepository import kotlinx.coroutines.flow.Flow import tachiyomi.data.Database import tachiyomi.data.DatabaseHandler +import tachiyomi.domain.category.model.Category +import tachiyomi.domain.category.model.CategoryUpdate +import tachiyomi.domain.category.repository.CategoryRepository class CategoryRepositoryImpl( private val handler: DatabaseHandler, diff --git a/domain/.gitignore b/domain/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/domain/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts new file mode 100644 index 000000000..cfbcc1926 --- /dev/null +++ b/domain/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + id("com.android.library") + kotlin("android") +} + +android { + namespace = "tachiyomi.domain" + + defaultConfig { + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + +} + +dependencies { + implementation(platform(kotlinx.coroutines.bom)) + implementation(kotlinx.bundles.coroutines) +} diff --git a/domain/consumer-rules.pro b/domain/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/domain/proguard-rules.pro b/domain/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/domain/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/domain/src/main/AndroidManifest.xml b/domain/src/main/AndroidManifest.xml new file mode 100644 index 000000000..568741e54 --- /dev/null +++ b/domain/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/domain/category/model/Category.kt b/domain/src/main/java/tachiyomi/domain/category/model/Category.kt similarity index 66% rename from app/src/main/java/eu/kanade/domain/category/model/Category.kt rename to domain/src/main/java/tachiyomi/domain/category/model/Category.kt index 742e481d2..ea901ce80 100644 --- a/app/src/main/java/eu/kanade/domain/category/model/Category.kt +++ b/domain/src/main/java/tachiyomi/domain/category/model/Category.kt @@ -1,4 +1,4 @@ -package eu.kanade.domain.category.model +package tachiyomi.domain.category.model import java.io.Serializable @@ -15,7 +15,3 @@ data class Category( const val UNCATEGORIZED_ID = 0L } } - -internal fun List.anyWithName(name: String): Boolean { - return any { name == it.name } -} diff --git a/app/src/main/java/eu/kanade/domain/category/model/CategoryUpdate.kt b/domain/src/main/java/tachiyomi/domain/category/model/CategoryUpdate.kt similarity index 77% rename from app/src/main/java/eu/kanade/domain/category/model/CategoryUpdate.kt rename to domain/src/main/java/tachiyomi/domain/category/model/CategoryUpdate.kt index fc9bc25f0..d3ee8baa9 100644 --- a/app/src/main/java/eu/kanade/domain/category/model/CategoryUpdate.kt +++ b/domain/src/main/java/tachiyomi/domain/category/model/CategoryUpdate.kt @@ -1,4 +1,4 @@ -package eu.kanade.domain.category.model +package tachiyomi.domain.category.model data class CategoryUpdate( val id: Long, diff --git a/app/src/main/java/eu/kanade/domain/category/repository/CategoryRepository.kt b/domain/src/main/java/tachiyomi/domain/category/repository/CategoryRepository.kt similarity index 80% rename from app/src/main/java/eu/kanade/domain/category/repository/CategoryRepository.kt rename to domain/src/main/java/tachiyomi/domain/category/repository/CategoryRepository.kt index bda15edf7..e2f8871df 100644 --- a/app/src/main/java/eu/kanade/domain/category/repository/CategoryRepository.kt +++ b/domain/src/main/java/tachiyomi/domain/category/repository/CategoryRepository.kt @@ -1,8 +1,8 @@ -package eu.kanade.domain.category.repository +package tachiyomi.domain.category.repository -import eu.kanade.domain.category.model.Category -import eu.kanade.domain.category.model.CategoryUpdate import kotlinx.coroutines.flow.Flow +import tachiyomi.domain.category.model.Category +import tachiyomi.domain.category.model.CategoryUpdate interface CategoryRepository { diff --git a/settings.gradle.kts b/settings.gradle.kts index b10f164d5..c2aba5f71 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -42,3 +42,4 @@ include(":source-api") include(":core") include(":macrobenchmark") include(":data") +include(":domain")