Improve SY specific change declarations

This commit is contained in:
Jobobby04 2022-11-24 15:16:58 -05:00
parent 9dc233cbbd
commit e0ad9f78ac
18 changed files with 54 additions and 23 deletions

View File

@ -55,7 +55,9 @@ val libraryManga: (Long, Long, String, String?, String?, String?, List<String>?,
chapterFlags,
coverLastModified,
dateAdded,
// SY -->
filteredScanlators,
// SY <--
updateStrategy,
),
category = category,

View File

@ -161,6 +161,7 @@ class MangaRepositoryImpl(
}
}
// SY -->
override suspend fun getMangaBySourceId(sourceId: Long): List<Manga> {
return handler.awaitList { mangasQueries.getBySource(sourceId, mangaMapper) }
}
@ -172,4 +173,5 @@ class MangaRepositoryImpl(
override suspend fun deleteManga(mangaId: Long) {
handler.await { mangasQueries.deleteById(mangaId) }
}
// SY <--
}

View File

@ -35,9 +35,11 @@ interface MangaRepository {
suspend fun updateAll(mangaUpdates: List<MangaUpdate>): Boolean
// SY -->
suspend fun getMangaBySourceId(sourceId: Long): List<Manga>
suspend fun getAll(): List<Manga>
suspend fun deleteManga(mangaId: Long)
// SY <--
}

View File

@ -38,7 +38,9 @@ data class Source(
val key: () -> String = {
when {
isUsedLast -> "$id-lastused"
// SY -->
category != null -> "$id-$category"
// SY <--
else -> "$id"
}
}

View File

@ -53,8 +53,10 @@ fun SourcesScreen(
onClickItem: (Source, String) -> Unit,
onClickDisable: (Source) -> Unit,
onClickPin: (Source) -> Unit,
// SY -->
onClickSetCategories: (Source, List<String>) -> Unit,
onClickToggleDataSaver: (Source) -> Unit,
// SY <--
) {
val context = LocalContext.current
when {
@ -70,8 +72,10 @@ fun SourcesScreen(
onClickItem = onClickItem,
onClickDisable = onClickDisable,
onClickPin = onClickPin,
// SY -->
onClickSetCategories = onClickSetCategories,
onClickToggleDataSaver = onClickToggleDataSaver,
// SY <--
)
}
}
@ -93,8 +97,10 @@ private fun SourceList(
onClickItem: (Source, String) -> Unit,
onClickDisable: (Source) -> Unit,
onClickPin: (Source) -> Unit,
// SY -->
onClickSetCategories: (Source, List<String>) -> Unit,
onClickToggleDataSaver: (Source) -> Unit,
// SY <--
) {
ScrollbarLazyColumn(
contentPadding = contentPadding + topSmallPaddingValues,
@ -119,16 +125,22 @@ private fun SourceList(
SourceHeader(
modifier = Modifier.animateItemPlacement(),
language = model.language,
// SY -->
isCategory = model.isCategory,
// SY <--
)
}
is SourceUiModel.Item -> SourceItem(
modifier = Modifier.animateItemPlacement(),
source = model.source,
// SY -->
showLatest = state.showLatest,
showPin = state.showPin,
// SY <--
onClickItem = onClickItem,
// SY -->
onLongClickItem = { state.dialog = Dialog.SourceLongClick(it) },
// SY <--
onClickPin = onClickPin,
)
}
@ -179,15 +191,19 @@ private fun SourceList(
private fun SourceHeader(
modifier: Modifier = Modifier,
language: String,
// SY -->
isCategory: Boolean,
// SY <--
) {
val context = LocalContext.current
Text(
// SY -->
text = if (!isCategory) {
LocaleHelper.getSourceDisplayName(language, context)
} else {
language
},
// SY <--
modifier = modifier
.padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small),
style = MaterialTheme.typography.header,
@ -256,8 +272,10 @@ private fun SourceOptionsDialog(
source: Source,
onClickPin: () -> Unit,
onClickDisable: () -> Unit,
// SY -->
onClickSetCategories: () -> Unit,
onClickToggleDataSaver: () -> Unit,
// SY <--
onDismiss: () -> Unit,
) {
AlertDialog(

View File

@ -90,6 +90,7 @@ fun BrowseSourceListItem(
if (manga.favorite) {
Badge(text = stringResource(R.string.in_library))
}
// SY -->
if (metadata is MangaDexSearchMetadata) {
metadata.followStatus?.let { followStatus ->
val text = LocalContext.current
@ -115,6 +116,7 @@ fun BrowseSourceListItem(
)
}
}
// SY <--
},
onLongClick = onLongClick,
onClick = onClick,

View File

@ -131,8 +131,10 @@ fun CategoryRenameDialog(
fun CategoryDeleteDialog(
onDismissRequest: () -> Unit,
onDelete: () -> Unit,
// SY -->
title: String,
text: String,
// SY <--
) {
AlertDialog(
onDismissRequest = onDismissRequest,

View File

@ -853,6 +853,7 @@ private fun onChapterItemClick(
}
}
// SY -->
typealias MetadataDescriptionComposable = @Composable (state: MangaScreenState.Success, openMetadataViewer: () -> Unit, search: (String) -> Unit) -> Unit
@Composable
@ -885,3 +886,4 @@ fun metadataDescription(source: Source): MetadataDescriptionComposable? {
}
}
}
// SY <--

View File

@ -147,6 +147,7 @@ fun MangaToolbar(
},
)
}
// SY -->
if (onClickMerge != null) {
DropdownMenuItem(
text = { Text(text = stringResource(R.string.merge)) },
@ -183,6 +184,7 @@ fun MangaToolbar(
},
)
}
// SY <--
}
}
}

View File

@ -43,10 +43,10 @@ class SettingsBrowseScreen : SearchableSettings {
val unsortedPreferences = remember { Injekt.get<UnsortedPreferences>() }
// SY <--
return listOf(
// SY -->
Preference.PreferenceGroup(
title = stringResource(R.string.label_sources),
preferenceItems = listOf(
// SY -->
kotlin.run {
val router = LocalRouter.currentOrThrow
val count by sourcePreferences.sourcesTabCategories().collectAsState()
@ -73,10 +73,8 @@ class SettingsBrowseScreen : SearchableSettings {
title = stringResource(R.string.pref_local_source_hidden_folders),
subtitle = stringResource(R.string.pref_local_source_hidden_folders_summery),
),
// SY <--
),
),
// SY -->
Preference.PreferenceGroup(
title = stringResource(R.string.feed),
preferenceItems = listOf(

View File

@ -247,7 +247,7 @@ class SettingsDownloadScreen : SearchableSettings {
if (it == 0) {
stringResource(R.string.disabled)
} else {
pluralStringResource(R.plurals.next_unread_chapters, count = it, it)
pluralStringResource(id = R.plurals.next_unread_chapters, count = it, it)
}
},
),

View File

@ -77,7 +77,7 @@ class SettingsSecurityScreen : SearchableSettings {
when (it) {
-1 -> stringResource(R.string.lock_never)
0 -> stringResource(R.string.lock_always)
else -> pluralStringResource(R.plurals.lock_after_mins, count = it, it)
else -> pluralStringResource(id = R.plurals.lock_after_mins, count = it, it)
}
},
onValueChanged = {

View File

@ -271,7 +271,7 @@ class LibraryUpdateService(
}
// Update favorite manga
val categoryId = intent.getLongExtra(KEY_CATEGORY, -1)
val categoryId = intent.getLongExtra(KEY_CATEGORY, -1L)
val group = intent.getIntExtra(KEY_GROUP, LibraryGroup.BY_DEFAULT)
val groupExtra = intent.getStringExtra(KEY_GROUP_EXTRA)
addMangaToQueue(categoryId, group, groupExtra)
@ -406,7 +406,9 @@ class LibraryUpdateService(
withIOContext {
mangaToUpdate.groupBy { it.manga.source }
// SY -->
.filterNot { it.key in LIBRARY_UPDATE_EXCLUDED_SOURCES }
// SY <--
.values
.map { mangaInSource ->
async {

View File

@ -14,7 +14,6 @@ import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
* A controller that displays a dialog window, floating on top of its activity's window.
* This is a wrapper over [Dialog] object like [android.app.DialogFragment].
*
*
* Implementations should override this class and implement [.onCreateDialog] to create a custom dialog, such as an [android.app.AlertDialog]
*/
abstract class DialogController : Controller {

View File

@ -58,11 +58,6 @@ open class GlobalSearchController(
return presenter.query
}
/**
* Create the [GlobalSearchPresenter] used in controller.
*
* @return instance of [GlobalSearchPresenter]
*/
override fun createPresenter(): GlobalSearchPresenter {
return GlobalSearchPresenter(initialQuery, extensionFilter)
}

View File

@ -41,7 +41,10 @@ class LibrarySettingsSheet(
val filters: Filter
private val sort: Sort
private val display: Display
// SY -->
private val grouping: Grouping
// SY <--
val sheetScope = CoroutineScope(Job() + Dispatchers.IO)
@ -55,8 +58,10 @@ class LibrarySettingsSheet(
display = Display(router.activity!!)
display.onGroupClicked = onGroupClickListener
// SY -->
grouping = Grouping(router.activity!!)
grouping.onGroupClicked = onGroupClickListener
// SY <--
}
/**
@ -75,14 +80,18 @@ class LibrarySettingsSheet(
filters,
sort,
display,
// SY -->
grouping,
// SY <--
)
override fun getTabTitles(): List<Int> = listOf(
R.string.action_filter,
R.string.action_sort,
R.string.action_display,
// SY -->
R.string.group,
// SY <--
)
/**
@ -271,14 +280,6 @@ class LibrarySettingsSheet(
(it as Item.MultiStateGroup).state =
Item.MultiSort.SORT_NONE
}
item.state = when (prevState) {
Item.MultiSort.SORT_NONE -> Item.MultiSort.SORT_ASC
Item.MultiSort.SORT_ASC -> Item.MultiSort.SORT_DESC
Item.MultiSort.SORT_DESC -> Item.MultiSort.SORT_ASC
else -> throw Exception("Unknown state")
}
item.state = when (prevState) {
Item.MultiSort.SORT_NONE -> Item.MultiSort.SORT_ASC
Item.MultiSort.SORT_ASC -> Item.MultiSort.SORT_DESC

View File

@ -235,7 +235,9 @@ class MangaScreen(
onSortModeChanged = screenModel::setSorting,
onDisplayModeChanged = screenModel::setDisplayMode,
onSetAsDefault = screenModel::setCurrentSettingsAsDefault,
// SY -->
onClickShowScanlatorSelection = { showScanlatorsDialog = true }.takeIf { successState.scanlators.size > 1 },
// SY <--
)
MangaInfoScreenModel.Dialog.TrackSheet -> {
var enableSwipeDismiss by remember { mutableStateOf(true) }
@ -290,6 +292,7 @@ class MangaScreen(
LoadingScreen(Modifier.systemBarsPadding())
}
}
// SY -->
is MangaInfoScreenModel.Dialog.EditMangaInfo -> {
EditMangaDialog(
manga = dialog.manga,
@ -305,6 +308,7 @@ class MangaScreen(
onPositiveClick = screenModel::updateMergeSettings,
)
}
// SY <--
}
// SY -->
if (showScanlatorsDialog) {
@ -451,9 +455,7 @@ class MangaScreen(
.setNegativeButton(android.R.string.cancel, null)
.show()
}
// SY <--
// SY -->
private fun openMorePagePreviews(router: Router, manga: Manga) {
router.pushController(PagePreviewController(manga.id))
}

View File

@ -65,4 +65,4 @@ UPDATE categories SET
flags = coalesce(?, flags);
selectLastInsertedRowId:
SELECT last_insert_rowid();
SELECT last_insert_rowid();