🛠️ Refactor code

* Inspected and refactored code in various places
This commit is contained in:
Acclorite 2025-03-11 19:37:45 +02:00
parent 78e7d710ea
commit 8981c92df3
66 changed files with 100 additions and 168 deletions

View file

@ -44,5 +44,5 @@
-keepnames class **
-keepnames class org.xmlpull.** { *; }
-keepclassmembernames class org.xmlpull.** { *; }
-keepnames class kotlin.reflect.jvm.internal.impl.builtins.PrimitiveType { values(); }
#-keepnames class kotlin.reflect.jvm.internal.impl.builtins.PrimitiveType { values(); }
-keepnames class * implements android.os.Parcelable { ** CREATOR; }

View file

@ -6,7 +6,7 @@
package ua.acclorite.book_story.data.mapper.book
import android.net.Uri
import androidx.core.net.toUri
import ua.acclorite.book_story.R
import ua.acclorite.book_story.data.local.dto.BookEntity
import ua.acclorite.book_story.domain.library.book.Book
@ -43,7 +43,7 @@ class BookMapperImpl @Inject constructor() : BookMapper {
filePath = bookEntity.filePath,
lastOpened = null,
category = bookEntity.category,
coverImage = if (bookEntity.image != null) Uri.parse(bookEntity.image) else null
coverImage = if (bookEntity.image != null) bookEntity.image.toUri() else null
)
}
}

View file

@ -42,7 +42,7 @@ class DocumentParser @Inject constructor(
var chapterAdded = false
document.selectFirst("body")
.run { if (this == null) document.body() else this }
.run { this ?: document.body() }
.apply {
// Remove manual line breaks from all <p>, <a>
select("p").forEach { element ->

View file

@ -8,8 +8,8 @@
package ua.acclorite.book_story.data.parser.epub
import android.net.Uri
import android.util.Log
import androidx.core.net.toUri
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
@ -21,7 +21,6 @@ import ua.acclorite.book_story.data.parser.DocumentParser
import ua.acclorite.book_story.data.parser.TextParser
import ua.acclorite.book_story.domain.file.CachedFile
import ua.acclorite.book_story.domain.reader.ReaderText
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideImageExtensions
import ua.acclorite.book_story.presentation.core.util.addAll
import ua.acclorite.book_story.presentation.core.util.containsVisibleText
@ -62,7 +61,7 @@ class EpubTextParser @Inject constructor(
val chapterEntries = zip.getChapterEntries(opfEntry)
val imageEntries = zip.entries().toList().filter {
Constants.provideImageExtensions().any { format ->
provideImageExtensions().any { format ->
it.name.endsWith(format, ignoreCase = true)
}
}
@ -108,7 +107,6 @@ class EpubTextParser @Inject constructor(
*
* @return Null if could not parse.
*/
@OptIn(ExperimentalCoroutinesApi::class)
private suspend fun ZipFile.parseEpub(
chapterEntries: List<ZipEntry>,
imageEntries: List<ZipEntry>,
@ -166,7 +164,9 @@ class EpubTextParser @Inject constructor(
chapterTitleMap: Map<Source, ReaderText.Chapter>?
) {
// Getting all text
val content = zip.getInputStream(entry).bufferedReader().use { it.readText() }
val content = withContext(Dispatchers.IO) {
zip.getInputStream(entry)
}.bufferedReader().use { it.readText() }
var readerText = documentParser.parseDocument(
document = Jsoup.parse(content),
zipFile = zip,
@ -227,7 +227,7 @@ class EpubTextParser @Inject constructor(
val tocDocument = tocContent?.let { Jsoup.parse(it) }
if (tocDocument == null) return null
var titleMap = mutableMapOf<Source, ReaderText.Chapter>()
val titleMap = mutableMapOf<Source, ReaderText.Chapter>()
tocDocument.select("navPoint").forEach { navPoint ->
val title = navPoint.selectFirst("navLabel > text")?.text()
@ -239,7 +239,7 @@ class EpubTextParser @Inject constructor(
val source = navPoint.selectFirst("content")?.attr("src")?.trim()
.let { source ->
if (source.isNullOrBlank()) return@forEach
Uri.parse(source).path ?: source
source.toUri().path ?: source
}.substringAfterLast(File.separator)
val parent = navPoint.parent()
@ -250,7 +250,7 @@ class EpubTextParser @Inject constructor(
val parentSource = parent.selectFirst("content")?.attr("src")?.trim()
.let { parentSource ->
if (parentSource.isNullOrBlank()) return@forEach
Uri.parse(parentSource).path ?: parentSource
parentSource.toUri().path ?: parentSource
}.substringAfterLast(File.separator)
if (parentSource == source) return@let null
return@let parentSource
@ -294,11 +294,7 @@ class EpubTextParser @Inject constructor(
* @return List of chapter entries in correct order (do not reorder).
*/
private fun ZipFile.getChapterEntries(opfEntry: ZipEntry?): List<ZipEntry> {
opfEntry.let { opfEntry ->
if (opfEntry == null) {
return@let
}
opfEntry?.let {
val opfContent = getInputStream(opfEntry).bufferedReader().use {
it.readText()
}

View file

@ -12,6 +12,7 @@ import android.graphics.BitmapFactory
import android.net.Uri
import android.provider.MediaStore
import android.util.Log
import androidx.core.net.toUri
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import ua.acclorite.book_story.data.local.room.BookDao
@ -191,7 +192,7 @@ class BookRepositoryImpl @Inject constructor(
listOf(
bookMapper.toBookEntity(
book.copy(
coverImage = if (entity.image != null) Uri.parse(entity.image) else null
coverImage = if (entity.image != null) entity.image.toUri() else null
)
)
)
@ -357,7 +358,7 @@ class BookRepositoryImpl @Inject constructor(
val currentCover = try {
MediaStore.Images.Media.getBitmap(
application.contentResolver,
Uri.parse(book.image)
book.image.toUri()
)
} catch (e: Exception) {
Log.i(CAN_RESET_COVER, "Can reset cover image. (could not get current)")

View file

@ -19,7 +19,6 @@ import ua.acclorite.book_story.domain.library.book.NullableBook.NotNull
import ua.acclorite.book_story.domain.library.book.NullableBook.Null
import ua.acclorite.book_story.domain.repository.FileSystemRepository
import ua.acclorite.book_story.domain.ui.UIText
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideExtensions
import java.util.UUID
import javax.inject.Inject
@ -49,7 +48,7 @@ class FileSystemRepositoryImpl @Inject constructor(
val existingPaths = database
.searchBooks("")
.map { it.filePath }
val supportedExtensions = Constants.provideExtensions()
val supportedExtensions = provideExtensions()
/**
* Verify that [CachedFile] is valid and can be shown correctly.

View file

@ -23,7 +23,7 @@ import java.util.UUID
* Faster than [androidx.documentfile.provider.DocumentFile].
* Saves all it's variables after initialized.
*/
@Suppress("unused")
@Suppress("unused", "MemberVisibilityCanBePrivate")
@Immutable
class CachedFile(
private val context: Context,

View file

@ -38,7 +38,7 @@ object CachedFileCompat {
): CachedFile? {
val uri = try {
val fullPathUri = DocumentFileCompat.fromFullPath(context, path)?.uri
if (fullPathUri == null) throw NullPointerException("Could not get URI from full path.")
?: throw NullPointerException("Could not get URI from full path.")
fullPathUri
} catch (e: Exception) {
@ -49,7 +49,7 @@ object CachedFileCompat {
context = context,
fullPath = path
)?.uri
if (parentUri == null) throw NullPointerException("Could not get parent URI.")
?: throw NullPointerException("Could not get parent URI.")
val storageId = DocumentFileCompat.getStorageId(context, path)
if (storageId.isBlank()) throw NullPointerException("Could not get storageId.")

View file

@ -24,7 +24,7 @@ class Navigator @AssistedInject constructor(
@Assisted private val initialScreen: Screen
) : ViewModel() {
val items = savedStateHandle.getStateFlow("items", mutableListOf<Screen>(initialScreen))
val items = savedStateHandle.getStateFlow("items", mutableListOf(initialScreen))
private fun StateFlow<MutableList<Screen>>.removeLast() {
savedStateHandle["items"] = value.dropLast(1)
}
@ -42,7 +42,7 @@ class Navigator @AssistedInject constructor(
)
val lastEvent = savedStateHandle.getStateFlow("stack_event", StackEvent.Default)
private fun StateFlow<StackEvent>.change(stackEvent: StackEvent) {
private fun changeStackEvent(stackEvent: StackEvent) {
savedStateHandle["stack_event"] = stackEvent
}
@ -55,7 +55,7 @@ class Navigator @AssistedInject constructor(
if (lastItem.value::class == targetScreen::class) return
if (!saveInBackStack) items.removeLast()
lastEvent.change(
changeStackEvent(
if (popping) StackEvent.Pop
else StackEvent.Default
)
@ -66,7 +66,7 @@ class Navigator @AssistedInject constructor(
fun pop(popping: Boolean = true) {
if (items.value.count() > 1) {
lastEvent.change(
changeStackEvent(
if (popping) StackEvent.Pop
else StackEvent.Default
)

View file

@ -18,7 +18,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.R
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideAboutBadges
import ua.acclorite.book_story.presentation.core.util.showToast
import ua.acclorite.book_story.ui.about.AboutEvent
@ -39,7 +38,7 @@ fun AboutBadges(
horizontalArrangement = Arrangement.spacedBy(13.dp)
) {
items(
Constants.provideAboutBadges(),
provideAboutBadges(),
key = { it.id }
) { badge ->
AboutBadgeItem(badge = badge) {

View file

@ -15,7 +15,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
@ -28,7 +27,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.R
import ua.acclorite.book_story.presentation.core.components.common.LazyColumnWithScrollbar
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideContributorsPage
import ua.acclorite.book_story.presentation.core.constants.provideIssuesPage
import ua.acclorite.book_story.presentation.core.constants.provideReleasesPage
@ -36,7 +34,6 @@ import ua.acclorite.book_story.presentation.core.constants.provideSupportPage
import ua.acclorite.book_story.presentation.core.constants.provideTranslationPage
import ua.acclorite.book_story.ui.about.AboutEvent
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AboutLayout(
paddingValues: PaddingValues,
@ -88,7 +85,7 @@ fun AboutLayout(
) {
navigateToBrowserPage(
AboutEvent.OnNavigateToBrowserPage(
page = Constants.provideReleasesPage(),
page = provideReleasesPage(),
context = context
)
)
@ -102,7 +99,7 @@ fun AboutLayout(
) {
navigateToBrowserPage(
AboutEvent.OnNavigateToBrowserPage(
page = Constants.provideIssuesPage(),
page = provideIssuesPage(),
context = context
)
)
@ -117,7 +114,7 @@ fun AboutLayout(
) {
navigateToBrowserPage(
AboutEvent.OnNavigateToBrowserPage(
page = Constants.provideContributorsPage(),
page = provideContributorsPage(),
context = context
)
)
@ -149,7 +146,7 @@ fun AboutLayout(
) {
navigateToBrowserPage(
AboutEvent.OnNavigateToBrowserPage(
page = Constants.provideTranslationPage(),
page = provideTranslationPage(),
context = context
)
)
@ -163,7 +160,7 @@ fun AboutLayout(
) {
navigateToBrowserPage(
AboutEvent.OnNavigateToBrowserPage(
page = Constants.provideSupportPage(),
page = provideSupportPage(),
context = context
)
)

View file

@ -7,14 +7,12 @@
package ua.acclorite.book_story.presentation.book_info
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.runtime.Composable
import ua.acclorite.book_story.domain.library.book.Book
import ua.acclorite.book_story.domain.util.BottomSheet
import ua.acclorite.book_story.domain.util.Dialog
import ua.acclorite.book_story.ui.book_info.BookInfoEvent
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun BookInfoContent(
book: Book,

View file

@ -22,7 +22,6 @@ import ua.acclorite.book_story.domain.file.CachedFileCompat
import ua.acclorite.book_story.domain.library.book.Book
import ua.acclorite.book_story.presentation.core.components.common.LazyColumnWithScrollbar
import ua.acclorite.book_story.presentation.core.components.modal_bottom_sheet.ModalBottomSheet
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideExtensions
import ua.acclorite.book_story.presentation.settings.components.SettingsSubcategoryTitle
import ua.acclorite.book_story.ui.book_info.BookInfoEvent
@ -61,7 +60,7 @@ fun BookInfoDetailsBottomSheet(
val fileExists = remember(cachedFile) {
cachedFile.let {
it != null && it.canAccess() && !it.isDirectory && Constants.provideExtensions()
it != null && it.canAccess() && !it.isDirectory && provideExtensions()
.any { ext ->
it.name.endsWith(ext, ignoreCase = true)
}

View file

@ -19,7 +19,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.domain.library.book.Book
import ua.acclorite.book_story.presentation.core.components.common.LazyColumnWithScrollbar
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.providePrimaryScrollbar
import ua.acclorite.book_story.ui.book_info.BookInfoEvent
@ -39,7 +38,7 @@ fun BookInfoLayout(
LazyColumnWithScrollbar(
modifier = Modifier.fillMaxSize(),
state = listState,
scrollbarSettings = Constants.providePrimaryScrollbar(false),
scrollbarSettings = providePrimaryScrollbar(false),
contentPadding = PaddingValues(bottom = 18.dp)
) {
item {

View file

@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -19,7 +18,6 @@ import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.domain.library.book.Book
import ua.acclorite.book_story.ui.book_info.BookInfoEvent
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
fun BookInfoLayoutInfo(
book: Book,

View file

@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
@ -20,7 +19,6 @@ import androidx.compose.ui.Modifier
import ua.acclorite.book_story.domain.library.book.Book
import ua.acclorite.book_story.ui.book_info.BookInfoEvent
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun BookInfoScaffold(
book: Book,

View file

@ -6,7 +6,6 @@
package ua.acclorite.book_story.presentation.browse
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Column
@ -21,7 +20,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.domain.browse.file.SelectableFile
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun BrowseGridItem(
modifier: Modifier,

View file

@ -21,7 +21,6 @@ import ua.acclorite.book_story.domain.browse.file.GroupedFiles
import ua.acclorite.book_story.domain.browse.file.SelectableFile
import ua.acclorite.book_story.presentation.core.components.common.LazyVerticalGridWithScrollbar
import ua.acclorite.book_story.presentation.core.components.common.header
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.providePrimaryScrollbar
@Composable
@ -39,7 +38,7 @@ fun BrowseGridLayout(
state = gridState,
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(horizontal = 8.dp),
scrollbarSettings = Constants.providePrimaryScrollbar(false)
scrollbarSettings = providePrimaryScrollbar(false)
) {
groupedFiles.forEach { group ->
stickyHeader {

View file

@ -6,7 +6,6 @@
package ua.acclorite.book_story.presentation.browse
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Row
@ -26,7 +25,6 @@ import ua.acclorite.book_story.domain.browse.file.SelectableFile
import ua.acclorite.book_story.presentation.core.components.common.CircularCheckbox
import ua.acclorite.book_story.ui.theme.FadeTransitionPreservingSpace
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun BrowseListItem(
modifier: Modifier,

View file

@ -19,7 +19,6 @@ import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.domain.browse.file.GroupedFiles
import ua.acclorite.book_story.domain.browse.file.SelectableFile
import ua.acclorite.book_story.presentation.core.components.common.LazyColumnWithScrollbar
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.providePrimaryScrollbar
@Composable
@ -33,7 +32,7 @@ fun BrowseListLayout(
state = listState,
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(horizontal = 8.dp),
scrollbarSettings = Constants.providePrimaryScrollbar(false)
scrollbarSettings = providePrimaryScrollbar(false)
) {
groupedFiles.forEach { group ->
stickyHeader {

View file

@ -20,7 +20,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import my.nanihadesuka.compose.InternalLazyColumnScrollbar
import my.nanihadesuka.compose.ScrollbarSettings
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideSecondaryScrollbar
@Composable
@ -28,7 +27,7 @@ fun LazyColumnWithScrollbar(
modifier: Modifier = Modifier,
parentModifier: Modifier = Modifier,
state: LazyListState = rememberLazyListState(),
scrollbarSettings: ScrollbarSettings = Constants.provideSecondaryScrollbar(),
scrollbarSettings: ScrollbarSettings = provideSecondaryScrollbar(),
enableScrollbar: Boolean = true,
contentPadding: PaddingValues = PaddingValues(0.dp),
verticalArrangement: Arrangement.Vertical = Arrangement.Top,

View file

@ -21,7 +21,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import my.nanihadesuka.compose.InternalLazyVerticalGridScrollbar
import my.nanihadesuka.compose.ScrollbarSettings
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideSecondaryScrollbar
@Composable
@ -29,7 +28,7 @@ fun LazyVerticalGridWithScrollbar(
modifier: Modifier = Modifier,
columns: GridCells,
state: LazyGridState = rememberLazyGridState(),
scrollbarSettings: ScrollbarSettings = Constants.provideSecondaryScrollbar(),
scrollbarSettings: ScrollbarSettings = provideSecondaryScrollbar(),
enableScrollbar: Boolean = true,
contentPadding: PaddingValues = PaddingValues(0.dp),
verticalArrangement: Arrangement.Vertical = Arrangement.Top,

View file

@ -41,7 +41,6 @@ import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.presentation.core.components.common.AnimatedVisibility
import ua.acclorite.book_story.presentation.core.components.common.LazyColumnWithScrollbar
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.providePrimaryScrollbar
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
@ -146,7 +145,7 @@ fun ModalDrawer(
LazyColumnWithScrollbar(
state = rememberLazyListState(startIndex),
modifier = Modifier.fillMaxSize(),
scrollbarSettings = Constants.providePrimaryScrollbar(),
scrollbarSettings = providePrimaryScrollbar(),
contentPadding = PaddingValues(vertical = 9.dp)
) {
content()

View file

@ -8,7 +8,6 @@ package ua.acclorite.book_story.presentation.core.components.settings
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
@ -26,7 +25,6 @@ import ua.acclorite.book_story.presentation.settings.components.SettingsSubcateg
/**
* Chips with title. Use list of [ButtonItem]s to display chips.
*/
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun ChipsWithTitle(
modifier: Modifier = Modifier,

View file

@ -9,7 +9,7 @@ package ua.acclorite.book_story.presentation.core.constants
import ua.acclorite.book_story.R
import ua.acclorite.book_story.domain.about.Badge
fun Constants.provideAboutBadges() = listOf(
fun provideAboutBadges() = listOf(
Badge(
id = "github",
drawable = R.drawable.github,

View file

@ -15,10 +15,10 @@ import ua.acclorite.book_story.domain.reader.ColorPreset
import ua.acclorite.book_story.domain.ui.UIText
// Main State
fun Constants.provideMainState() = "main_state"
fun provideMainState() = "main_state"
// Empty Book
fun Constants.provideEmptyBook() = Book(
fun provideEmptyBook() = Book(
id = -1,
title = "",
author = UIText.StringValue(""),
@ -33,7 +33,7 @@ fun Constants.provideEmptyBook() = Book(
)
// Default Color Preset
fun Constants.provideDefaultColorPreset() = ColorPreset(
fun provideDefaultColorPreset() = ColorPreset(
id = -1,
name = null,
backgroundColor = Color(0xFFFAF8FF), // Blue Light Surface (hardcoded)

View file

@ -1,9 +0,0 @@
/*
* Book's Story free and open-source Material You eBook reader.
* Copyright (C) 2024-2025 Acclorite
* SPDX-License-Identifier: GPL-3.0-only
*/
package ua.acclorite.book_story.presentation.core.constants
object Constants

View file

@ -10,7 +10,7 @@ import ua.acclorite.book_story.R
import ua.acclorite.book_story.domain.about.Credit
import ua.acclorite.book_story.domain.ui.UIText
fun Constants.provideCredits() = listOf(
fun provideCredits() = listOf(
Credit(
name = "Tachiyomi (Mihon)",
source = "GitHub",

View file

@ -17,8 +17,7 @@ import ua.acclorite.book_story.R
import ua.acclorite.book_story.domain.reader.FontWithName
import ua.acclorite.book_story.domain.ui.UIText
@OptIn(ExperimentalTextApi::class)
fun Constants.provideFonts(): List<FontWithName> {
fun provideFonts(): List<FontWithName> {
return mutableListOf(
FontWithName(
"default",

View file

@ -11,7 +11,7 @@ import ua.acclorite.book_story.R
import ua.acclorite.book_story.domain.help.HelpTip
import ua.acclorite.book_story.presentation.help.HelpAnnotation
fun Constants.provideHelpTips() = listOf(
fun provideHelpTips() = listOf(
HelpTip(
title = R.string.help_title_how_to_add_books,
description = {

View file

@ -6,7 +6,7 @@
package ua.acclorite.book_story.presentation.core.constants
fun Constants.provideLanguages() = listOf(
fun provideLanguages() = listOf(
Pair("en", "English"),
Pair("uk", "Українська"),
Pair("de", "Deutsch"),

View file

@ -8,17 +8,17 @@
package ua.acclorite.book_story.presentation.core.constants
fun Constants.provideReleasesPage() =
fun provideReleasesPage() =
"https://www.github.com/Acclorite/book-story/releases/latest"
fun Constants.provideIssuesPage() =
fun provideIssuesPage() =
"https://www.github.com/Acclorite/book-story/issues"
fun Constants.provideContributorsPage() =
fun provideContributorsPage() =
"https://github.com/Acclorite/book-story/graphs/contributors"
fun Constants.provideTranslationPage() =
fun provideTranslationPage() =
"https://hosted.weblate.org/projects/book-story"
fun Constants.provideSupportPage() =
fun provideSupportPage() =
"https://patreon.com/Acclorite"

View file

@ -14,7 +14,7 @@ import my.nanihadesuka.compose.ScrollbarSelectionMode
import my.nanihadesuka.compose.ScrollbarSettings
@Composable
fun Constants.providePrimaryScrollbar(canSelect: Boolean = true) = ScrollbarSettings(
fun providePrimaryScrollbar(canSelect: Boolean = true) = ScrollbarSettings(
thumbUnselectedColor = MaterialTheme.colorScheme.secondary,
thumbSelectedColor = MaterialTheme.colorScheme.secondary.copy(0.8f),
hideDelayMillis = 2000,
@ -25,7 +25,7 @@ fun Constants.providePrimaryScrollbar(canSelect: Boolean = true) = ScrollbarSett
)
@Composable
fun Constants.provideSecondaryScrollbar() = ScrollbarSettings(
fun provideSecondaryScrollbar() = ScrollbarSettings(
thumbUnselectedColor = MaterialTheme.colorScheme.onSurfaceVariant.copy(0.5f),
hideDelayMillis = 500,
durationAnimationMillis = 200,

View file

@ -6,7 +6,7 @@
package ua.acclorite.book_story.presentation.core.constants
fun Constants.provideExtensions() = listOf(
fun provideExtensions() = listOf(
".epub",
".pdf",
".fb2",
@ -16,7 +16,7 @@ fun Constants.provideExtensions() = listOf(
".md"
)
fun Constants.provideImageExtensions() = listOf(
fun provideImageExtensions() = listOf(
".png",
".jpg",
".jpeg",

View file

@ -6,11 +6,9 @@
package ua.acclorite.book_story.presentation.core.util
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
import androidx.compose.ui.Modifier
@OptIn(ExperimentalFoundationApi::class)
fun Modifier.noRippleClickable(
enabled: Boolean = true,
onLongClick: (() -> Unit)? = null,

View file

@ -10,7 +10,6 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
@ -26,7 +25,6 @@ import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.domain.about.Credit
import ua.acclorite.book_story.presentation.core.components.common.StyledText
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun CreditItem(
credit: Credit,

View file

@ -15,7 +15,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import ua.acclorite.book_story.presentation.core.components.common.LazyColumnWithScrollbar
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideCredits
import ua.acclorite.book_story.ui.about.AboutEvent
@ -33,7 +32,7 @@ fun CreditsLayout(
state = listState
) {
items(
Constants.provideCredits(),
provideCredits(),
key = { it.name }
) { credit ->
CreditItem(credit = credit) {

View file

@ -16,7 +16,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.domain.util.Position
import ua.acclorite.book_story.presentation.core.components.common.LazyColumnWithScrollbar
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideHelpTips
@Composable
@ -32,14 +31,14 @@ fun HelpLayout(
contentPadding = PaddingValues(vertical = 16.dp)
) {
itemsIndexed(
Constants.provideHelpTips(),
provideHelpTips(),
key = { _, helpTip -> helpTip.title }
) { index, helpTip ->
HelpItem(
helpTip = helpTip,
position = when (index) {
0 -> Position.TOP
Constants.provideHelpTips().lastIndex -> Position.BOTTOM
provideHelpTips().lastIndex -> Position.BOTTOM
else -> Position.CENTER
}
)

View file

@ -19,7 +19,6 @@ import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.R
import ua.acclorite.book_story.domain.history.GroupedHistory
import ua.acclorite.book_story.presentation.core.components.common.LazyColumnWithScrollbar
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.providePrimaryScrollbar
import ua.acclorite.book_story.presentation.core.util.LocalActivity
import ua.acclorite.book_story.presentation.settings.components.SettingsSubcategoryTitle
@ -43,7 +42,7 @@ fun HistoryLayout(
LazyColumnWithScrollbar(
modifier = Modifier.fillMaxSize(),
state = listState,
scrollbarSettings = Constants.providePrimaryScrollbar(false)
scrollbarSettings = providePrimaryScrollbar(false)
) {
item {
Spacer(modifier = Modifier.height(12.dp))

View file

@ -6,7 +6,6 @@
package ua.acclorite.book_story.presentation.library
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
@ -41,7 +40,6 @@ import ua.acclorite.book_story.presentation.core.components.common.AsyncCoverIma
import ua.acclorite.book_story.presentation.core.components.common.StyledText
import ua.acclorite.book_story.presentation.core.util.calculateProgress
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun LazyGridItemScope.LibraryItem(
book: SelectableBook,

View file

@ -14,7 +14,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import ua.acclorite.book_story.presentation.core.components.common.LazyVerticalGridWithScrollbar
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.providePrimaryScrollbar
@Composable
@ -24,7 +23,7 @@ fun LibraryLayout(
LazyVerticalGridWithScrollbar(
columns = GridCells.Adaptive(120.dp),
modifier = Modifier.fillMaxSize(),
scrollbarSettings = Constants.providePrimaryScrollbar(false),
scrollbarSettings = providePrimaryScrollbar(false),
contentPadding = PaddingValues(8.dp)
) {
items()

View file

@ -46,7 +46,7 @@ fun LibraryMoveDialog(
}
}
}
var selectedCategory = remember {
val selectedCategory = remember {
mutableStateOf(moveCategories.value[0])
}

View file

@ -10,7 +10,6 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
@ -32,7 +31,6 @@ import com.mikepenz.aboutlibraries.ui.compose.m3.util.author
import ua.acclorite.book_story.R
import ua.acclorite.book_story.presentation.core.components.common.StyledText
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun LicensesItem(
library: Library,

View file

@ -54,10 +54,15 @@ fun ReaderBottomBar(
scroll: (ReaderEvent.OnScroll) -> Unit,
changeProgress: (ReaderEvent.OnChangeProgress) -> Unit
) {
val arrowDirection = remember(checkpoint.index, listState.firstVisibleItemIndex) {
val firstVisibleItemIndex = remember {
derivedStateOf {
listState.firstVisibleItemIndex
}
}
val arrowDirection = remember(checkpoint.index, firstVisibleItemIndex) {
derivedStateOf {
val checkpointIndex = checkpoint.index
val index = listState.firstVisibleItemIndex
val index = firstVisibleItemIndex.value
when {
checkpointIndex > index -> Direction.END

View file

@ -14,10 +14,10 @@ import androidx.compose.material3.VerticalDivider
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.coerceAtMost
import androidx.compose.ui.unit.dp
@Composable
fun ReaderPerceptionExpander(
@ -32,9 +32,11 @@ fun ReaderPerceptionExpander(
.fillMaxSize()
.padding(
horizontal = perceptionExpanderPadding.coerceAtMost(
LocalConfiguration.current.screenWidthDp.run {
with(LocalDensity.current) {
LocalWindowInfo.current.containerSize.width.toDp()
}.run {
this / 2f - (this * 0.1f)
}.dp
}
)
),
horizontalArrangement = Arrangement.SpaceBetween

View file

@ -11,7 +11,6 @@ import androidx.compose.animation.expandHorizontally
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkHorizontally
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
@ -76,7 +75,6 @@ import ua.acclorite.book_story.ui.settings.SettingsModel
import ua.acclorite.book_story.ui.theme.FadeTransitionPreservingSpace
import ua.acclorite.book_story.ui.theme.Transitions
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun ColorPresetOption(backgroundColor: Color) {
val settingsModel = hiltViewModel<SettingsModel>()

View file

@ -26,13 +26,12 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import ua.acclorite.book_story.presentation.core.components.common.StyledText
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideExtensions
import ua.acclorite.book_story.ui.main.MainEvent
import ua.acclorite.book_story.ui.main.MainModel
fun LazyListScope.BrowseFilterOption() {
items(Constants.provideExtensions(), key = { it }) {
items(provideExtensions(), key = { it }) {
val mainModel = hiltViewModel<MainModel>()
val state = mainModel.state.collectAsStateWithLifecycle()

View file

@ -10,7 +10,6 @@ import android.content.Context
import android.content.UriPermission
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
@ -48,7 +47,6 @@ import ua.acclorite.book_story.ui.settings.SettingsEvent
import ua.acclorite.book_story.ui.settings.SettingsModel
import ua.acclorite.book_story.ui.theme.dynamicListItemColor
@OptIn(ExperimentalSharedTransitionApi::class)
@Composable
fun BrowseScanOption() {
val settingsModel = hiltViewModel<SettingsModel>()

View file

@ -14,7 +14,6 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import ua.acclorite.book_story.R
import ua.acclorite.book_story.domain.ui.ButtonItem
import ua.acclorite.book_story.presentation.core.components.settings.ChipsWithTitle
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideLanguages
import ua.acclorite.book_story.ui.main.MainEvent
import ua.acclorite.book_story.ui.main.MainModel
@ -26,7 +25,7 @@ fun AppLanguageOption() {
ChipsWithTitle(
title = stringResource(id = R.string.language_option),
chips = Constants.provideLanguages().sortedBy { it.second }.map {
chips = provideLanguages().sortedBy { it.second }.map {
ButtonItem(
it.first,
it.second,

View file

@ -15,7 +15,6 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import ua.acclorite.book_story.R
import ua.acclorite.book_story.domain.ui.ButtonItem
import ua.acclorite.book_story.presentation.core.components.settings.ChipsWithTitle
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideFonts
import ua.acclorite.book_story.ui.main.MainEvent
import ua.acclorite.book_story.ui.main.MainModel
@ -26,7 +25,7 @@ fun FontFamilyOption() {
val state = mainModel.state.collectAsStateWithLifecycle()
val fontFamily = remember(state.value.fontFamily) {
Constants.provideFonts().run {
provideFonts().run {
find {
it.id == state.value.fontFamily
} ?: get(0)
@ -35,7 +34,7 @@ fun FontFamilyOption() {
ChipsWithTitle(
title = stringResource(id = R.string.font_family_option),
chips = Constants.provideFonts()
chips = provideFonts()
.map {
ButtonItem(
id = it.id,

View file

@ -16,7 +16,6 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import ua.acclorite.book_story.R
import ua.acclorite.book_story.domain.ui.ButtonItem
import ua.acclorite.book_story.presentation.core.components.settings.SegmentedButtonWithTitle
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideFonts
import ua.acclorite.book_story.ui.main.MainEvent
import ua.acclorite.book_story.ui.main.MainModel
@ -27,7 +26,7 @@ fun FontStyleOption() {
val state = mainModel.state.collectAsStateWithLifecycle()
val fontFamily = remember(state.value.fontFamily) {
Constants.provideFonts().run {
provideFonts().run {
find {
it.id == state.value.fontFamily
} ?: get(0)

View file

@ -16,7 +16,6 @@ import ua.acclorite.book_story.R
import ua.acclorite.book_story.domain.reader.ReaderFontThickness
import ua.acclorite.book_story.domain.ui.ButtonItem
import ua.acclorite.book_story.presentation.core.components.settings.ChipsWithTitle
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideFonts
import ua.acclorite.book_story.ui.main.MainEvent
import ua.acclorite.book_story.ui.main.MainModel
@ -27,7 +26,7 @@ fun FontThicknessOption() {
val state = mainModel.state.collectAsStateWithLifecycle()
val fontFamily = remember(state.value.fontFamily) {
Constants.provideFonts().run {
provideFonts().run {
find {
it.id == state.value.fontFamily
} ?: get(0)

View file

@ -23,9 +23,8 @@ fun HighlightedReadingThicknessOption() {
ExpandingTransition(visible = state.value.highlightedReading) {
SliderWithTitle(
value = state.value.highlightedReadingThickness.to(
" ${stringResource(R.string.highlighted_reading_level)}"
),
value = state.value.highlightedReadingThickness
to " ${stringResource(R.string.highlighted_reading_level)}",
fromValue = 1,
toValue = 3,
title = stringResource(id = R.string.highlighted_reading_thickness_option),

View file

@ -7,13 +7,12 @@
package ua.acclorite.book_story.ui.about
import android.content.Intent
import android.net.Uri
import androidx.activity.ComponentActivity
import androidx.core.net.toUri
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import ua.acclorite.book_story.R
@ -21,7 +20,6 @@ import ua.acclorite.book_story.presentation.core.util.launchActivity
import ua.acclorite.book_story.presentation.core.util.showToast
import javax.inject.Inject
@OptIn(FlowPreview::class)
@HiltViewModel
class AboutModel @Inject constructor() : ViewModel() {
@ -31,7 +29,7 @@ class AboutModel @Inject constructor() : ViewModel() {
viewModelScope.launch {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse(event.page)
event.page.toUri()
)
intent.launchActivity(event.context as ComponentActivity) {

View file

@ -11,7 +11,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.MutableStateFlow
@ -35,7 +34,6 @@ import ua.acclorite.book_story.ui.history.HistoryScreen
import ua.acclorite.book_story.ui.library.LibraryScreen
import javax.inject.Inject
@OptIn(FlowPreview::class)
@HiltViewModel
class BookInfoModel @Inject constructor(
private val getBookById: GetBookById,

View file

@ -10,7 +10,6 @@ import android.os.Parcelable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
@ -44,7 +43,6 @@ data class BookInfoScreen(val bookId: Int) : Screen, Parcelable {
val changePathChannel: Channel<Boolean> = Channel(Channel.CONFLATED)
}
@OptIn(ExperimentalMaterialApi::class)
@Composable
override fun Content() {
val navigator = LocalNavigator.current

View file

@ -10,12 +10,11 @@ import androidx.compose.runtime.Immutable
import ua.acclorite.book_story.domain.library.book.Book
import ua.acclorite.book_story.domain.util.BottomSheet
import ua.acclorite.book_story.domain.util.Dialog
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideEmptyBook
@Immutable
data class BookInfoState(
val book: Book = Constants.provideEmptyBook(),
val book: Book = provideEmptyBook(),
val canResetCover: Boolean = false,

View file

@ -169,7 +169,7 @@ class BrowseModel @Inject constructor(
viewModelScope.launch(Dispatchers.IO) {
_state.update {
it.copy(
files = it.files.map { it.copy(selected = false) },
files = it.files.map { file -> file.copy(selected = false) },
hasSelectedItems = false
)
}
@ -446,7 +446,7 @@ class BrowseModel @Inject constructor(
return files
.filterFiles()
.sortedWith(
compareByWithOrder<SelectableFile> {
compareByWithOrder {
when (sortOrder) {
BrowseSortOrder.NAME -> {
it.data.name.trim()

View file

@ -37,7 +37,6 @@ import ua.acclorite.book_story.domain.use_case.data_store.ChangeLanguage
import ua.acclorite.book_story.domain.use_case.data_store.GetAllSettings
import ua.acclorite.book_story.domain.use_case.data_store.SetDatastore
import ua.acclorite.book_story.domain.util.toHorizontalAlignment
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.DataStoreConstants
import ua.acclorite.book_story.presentation.core.constants.provideFonts
import ua.acclorite.book_story.presentation.core.constants.provideMainState
@ -62,7 +61,7 @@ class MainModel @Inject constructor(
private val mainModelReady = MutableStateFlow(false)
private val _state: MutableStateFlow<MainState> = MutableStateFlow(
stateHandle[Constants.provideMainState()] ?: MainState()
stateHandle[provideMainState()] ?: MainState()
)
val state = _state.asStateFlow()
@ -107,7 +106,7 @@ class MainModel @Inject constructor(
value = event.value,
updateState = {
it.copy(
fontFamily = Constants.provideFonts().run {
fontFamily = provideFonts().run {
find { font ->
font.id == event.value
}?.id ?: get(0).id
@ -605,7 +604,7 @@ class MainModel @Inject constructor(
) {
withContext(Dispatchers.Main.immediate) {
_state.update {
stateHandle[Constants.provideMainState()] = function(it)
stateHandle[provideMainState()] = function(it)
function(it)
}
}

View file

@ -37,7 +37,6 @@ import ua.acclorite.book_story.domain.ui.toPureDark
import ua.acclorite.book_story.domain.ui.toThemeContrast
import ua.acclorite.book_story.domain.util.HorizontalAlignment
import ua.acclorite.book_story.domain.util.toHorizontalAlignment
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.DataStoreConstants
import ua.acclorite.book_story.presentation.core.constants.provideFonts
import ua.acclorite.book_story.presentation.core.constants.provideLanguages
@ -57,7 +56,7 @@ data class MainState(
// General Settings
val language: String = provideDefaultValue {
val locale = Locale.getDefault().language.take(2)
Constants.provideLanguages().any { locale == it.first }.run {
provideLanguages().any { locale == it.first }.run {
if (this) locale
else "en"// Default language.
}
@ -71,7 +70,7 @@ data class MainState(
val doublePressExit: Boolean = provideDefaultValue { false },
// Reader Settings
val fontFamily: String = provideDefaultValue { Constants.provideFonts()[0].id },
val fontFamily: String = provideDefaultValue { provideFonts()[0].id },
val fontThickness: ReaderFontThickness = provideDefaultValue { ReaderFontThickness.NORMAL },
val isItalic: Boolean = provideDefaultValue { false },
val fontSize: Int = provideDefaultValue { 16 },

View file

@ -8,11 +8,11 @@ package ua.acclorite.book_story.ui.reader
import android.app.SearchManager
import android.content.Intent
import android.net.Uri
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.snapshotFlow
import androidx.core.net.toUri
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
@ -396,7 +396,7 @@ class ReaderModel @Inject constructor(
browserIntent.action = Intent.ACTION_VIEW
val text = event.textToDefine.trim().replace(" ", "+")
browserIntent.data = Uri.parse("https://www.onelook.com/?w=$text")
browserIntent.data = "https://www.onelook.com/?w=$text".toUri()
yield()

View file

@ -48,7 +48,6 @@ import ua.acclorite.book_story.domain.navigator.Screen
import ua.acclorite.book_story.domain.reader.ReaderColorEffects
import ua.acclorite.book_story.domain.reader.ReaderProgressCount
import ua.acclorite.book_story.domain.reader.ReaderTextAlignment
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideFonts
import ua.acclorite.book_story.presentation.core.util.LocalActivity
import ua.acclorite.book_story.presentation.core.util.calculateProgress
@ -118,7 +117,7 @@ data class ReaderScreen(val bookId: Int) : Screen, Parcelable {
}
val fontFamily = remember(mainState.value.fontFamily) {
Constants.provideFonts().run {
provideFonts().run {
find {
it.id == mainState.value.fontFamily
} ?: get(0)

View file

@ -15,12 +15,11 @@ import ua.acclorite.book_story.domain.reader.ReaderText.Chapter
import ua.acclorite.book_story.domain.ui.UIText
import ua.acclorite.book_story.domain.util.BottomSheet
import ua.acclorite.book_story.domain.util.Drawer
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideEmptyBook
@Immutable
data class ReaderState(
val book: Book = Constants.provideEmptyBook(),
val book: Book = provideEmptyBook(),
val text: List<ReaderText> = emptyList(),
val listState: LazyListState = LazyListState(),

View file

@ -28,7 +28,6 @@ import ua.acclorite.book_story.domain.use_case.color_preset.SelectColorPreset
import ua.acclorite.book_story.domain.use_case.color_preset.UpdateColorPreset
import ua.acclorite.book_story.domain.use_case.permission.GrantPersistableUriPermission
import ua.acclorite.book_story.domain.use_case.permission.ReleasePersistableUriPermission
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideDefaultColorPreset
import ua.acclorite.book_story.presentation.core.util.showToast
import javax.inject.Inject
@ -65,7 +64,7 @@ class SettingsModel @Inject constructor(
var colorPresets = getColorPresets.execute()
if (colorPresets.isEmpty()) {
updateColorPreset.execute(Constants.provideDefaultColorPreset())
updateColorPreset.execute(provideDefaultColorPreset())
getColorPresets.execute().first().select()
colorPresets = getColorPresets.execute()
}
@ -365,7 +364,7 @@ class SettingsModel @Inject constructor(
addColorPresetJob = launch {
yield()
val newColorPreset = Constants.provideDefaultColorPreset().copy(
val newColorPreset = provideDefaultColorPreset().copy(
backgroundColor = event.backgroundColor,
fontColor = event.fontColor
)
@ -483,7 +482,7 @@ class SettingsModel @Inject constructor(
val selectedPreset = presets.firstOrNull { it.isSelected }
if (selectedPreset == null) {
return Constants.provideDefaultColorPreset()
return provideDefaultColorPreset()
}
return selectedPreset

View file

@ -9,13 +9,12 @@ package ua.acclorite.book_story.ui.settings
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Immutable
import ua.acclorite.book_story.domain.reader.ColorPreset
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideDefaultColorPreset
@Immutable
data class SettingsState(
val colorPresets: List<ColorPreset> = emptyList(),
val selectedColorPreset: ColorPreset = Constants.provideDefaultColorPreset(),
val selectedColorPreset: ColorPreset = provideDefaultColorPreset(),
val animateColorPreset: Boolean = false,
val colorPresetListState: LazyListState = LazyListState()
)

View file

@ -8,7 +8,6 @@ package ua.acclorite.book_story.ui.start
import android.annotation.SuppressLint
import android.os.Parcelable
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
@ -21,7 +20,6 @@ import kotlinx.parcelize.Parcelize
import ua.acclorite.book_story.domain.navigator.Screen
import ua.acclorite.book_story.domain.navigator.StackEvent
import ua.acclorite.book_story.domain.ui.ButtonItem
import ua.acclorite.book_story.presentation.core.constants.Constants
import ua.acclorite.book_story.presentation.core.constants.provideLanguages
import ua.acclorite.book_story.presentation.core.util.LocalActivity
import ua.acclorite.book_story.presentation.navigator.LocalNavigator
@ -50,7 +48,6 @@ object StartScreen : Screen, Parcelable {
const val DONE = "done"
@SuppressLint("InlinedApi")
@OptIn(ExperimentalMaterial3Api::class)
@Composable
override fun Content() {
val navigator = LocalNavigator.current
@ -64,7 +61,7 @@ object StartScreen : Screen, Parcelable {
val stackEvent = remember { mutableStateOf(StackEvent.Default) }
val languages = remember(mainState.value.language) {
Constants.provideLanguages().sortedBy { it.second }.map {
provideLanguages().sortedBy { it.second }.map {
ButtonItem(
id = it.first,
title = it.second,