Last Commit Merged: ed5a56be60
This commit is contained in:
LuftVerbot 2023-10-21 12:45:41 +02:00
parent e99e4c2f41
commit c62f86f6cc
28 changed files with 306 additions and 214 deletions

View file

@ -34,7 +34,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
@ -382,7 +383,7 @@ private fun AnimeScreenSmallImpl(
refreshing = state.isRefreshingData,
onRefresh = onRefresh,
enabled = episodes.fastAll { !it.selected },
indicatorPadding = contentPadding,
indicatorPadding = WindowInsets.systemBars.only(WindowInsetsSides.Top).asPaddingValues(),
) {
val layoutDirection = LocalLayoutDirection.current
VerticalFastScroller(
@ -465,7 +466,7 @@ private fun AnimeScreenSmallImpl(
contentType = EntryScreenItem.AIRING_TIME,
) {
// Handles the second by second countdown
var timer by remember { mutableStateOf(state.airingTime) }
var timer by remember { mutableLongStateOf(state.airingTime) }
LaunchedEffect(key1 = timer) {
if (timer > 0L) {
delay(1000L)
@ -561,7 +562,7 @@ fun AnimeScreenLargeImpl(
val episodes = remember(state) { state.processedEpisodes.toList() }
val insetPadding = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal).asPaddingValues()
var topBarHeight by remember { mutableStateOf(0) }
var topBarHeight by remember { mutableIntStateOf(0) }
PullRefresh(
refreshing = state.isRefreshingData,
@ -722,7 +723,7 @@ fun AnimeScreenLargeImpl(
contentType = EntryScreenItem.AIRING_TIME,
) {
// Handles the second by second countdown
var timer by remember { mutableStateOf(state.airingTime) }
var timer by remember { mutableLongStateOf(state.airingTime) }
LaunchedEffect(key1 = timer) {
if (timer > 0L) {
delay(1000L)

View file

@ -38,6 +38,7 @@ import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
@ -214,7 +215,7 @@ fun AnimeEpisodeListItem(
horizontalArrangement = Arrangement.spacedBy(2.dp),
verticalAlignment = Alignment.CenterVertically,
) {
var textHeight by remember { mutableStateOf(0) }
var textHeight by remember { mutableIntStateOf(0) }
if (!seen) {
Icon(
imageVector = Icons.Filled.Circle,
@ -354,7 +355,7 @@ fun NextEpisodeAiringListItem(
) {
Column(modifier = Modifier.weight(1f)) {
Row(verticalAlignment = Alignment.CenterVertically) {
var textHeight by remember { mutableStateOf(0) }
var textHeight by remember { mutableIntStateOf(0) }
Text(
text = title,
style = MaterialTheme.typography.bodyMedium,

View file

@ -48,6 +48,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
@ -575,8 +576,8 @@ private fun AnimeSummary(
expanded: Boolean,
modifier: Modifier = Modifier,
) {
var expandedHeight by remember { mutableStateOf(0) }
var shrunkHeight by remember { mutableStateOf(0) }
var expandedHeight by remember { mutableIntStateOf(0) }
var shrunkHeight by remember { mutableIntStateOf(0) }
val heightDelta = remember(expandedHeight, shrunkHeight) { expandedHeight - shrunkHeight }
val animProgress by animateFloatAsState(if (expanded) 1f else 0f)
val scrimHeight = with(LocalDensity.current) { remember { 24.sp.roundToPx() } }

View file

@ -32,7 +32,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
@ -357,7 +357,7 @@ private fun MangaScreenSmallImpl(
refreshing = state.isRefreshingData,
onRefresh = onRefresh,
enabled = chapters.fastAll { !it.selected },
indicatorPadding = contentPadding,
indicatorPadding = WindowInsets.systemBars.only(WindowInsetsSides.Top).asPaddingValues(),
) {
val layoutDirection = LocalLayoutDirection.current
VerticalFastScroller(
@ -507,7 +507,7 @@ fun MangaScreenLargeImpl(
val chapters = remember(state) { state.processedChapters.toList() }
val insetPadding = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal).asPaddingValues()
var topBarHeight by remember { mutableStateOf(0) }
var topBarHeight by remember { mutableIntStateOf(0) }
PullRefresh(
refreshing = state.isRefreshingData,
onRefresh = onRefresh,

View file

@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.DismissDirection
import androidx.compose.material.DismissValue
import androidx.compose.material.SwipeToDismiss
@ -26,8 +25,6 @@ import androidx.compose.material.icons.filled.FileDownloadOff
import androidx.compose.material.icons.filled.Visibility
import androidx.compose.material.icons.filled.VisibilityOff
import androidx.compose.material.rememberDismissState
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
@ -37,6 +34,7 @@ import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
@ -56,7 +54,6 @@ import tachiyomi.domain.library.service.LibraryPreferences
import tachiyomi.presentation.core.components.material.ReadItemAlpha
import tachiyomi.presentation.core.components.material.SecondaryItemAlpha
import tachiyomi.presentation.core.util.selectedBackground
import kotlin.math.min
@Composable
fun MangaChapterListItem(
@ -103,6 +100,15 @@ fun MangaChapterListItem(
lastDismissDirection = null
},
)
val dismissContentAlpha = if (lastDismissDirection != null) animateDismissContentAlpha else 1f
val backgroundColor = if (chapterSwipeEndEnabled && (dismissState.dismissDirection == DismissDirection.StartToEnd || lastDismissDirection == DismissDirection.StartToEnd)) {
MaterialTheme.colorScheme.primary
} else if (chapterSwipeStartEnabled && (dismissState.dismissDirection == DismissDirection.EndToStart || lastDismissDirection == DismissDirection.EndToStart)) {
MaterialTheme.colorScheme.primary
} else {
Color.Unspecified
}
LaunchedEffect(dismissState.currentValue) {
when (dismissState.currentValue) {
DismissValue.DismissedToEnd -> {
@ -126,17 +132,11 @@ fun MangaChapterListItem(
DismissValue.Default -> {}
}
}
SwipeToDismiss(
state = dismissState,
directions = dismissDirections,
background = {
val backgroundColor = if (chapterSwipeEndEnabled && (dismissState.dismissDirection == DismissDirection.StartToEnd || lastDismissDirection == DismissDirection.StartToEnd)) {
MaterialTheme.colorScheme.primary
} else if (chapterSwipeStartEnabled && (dismissState.dismissDirection == DismissDirection.EndToStart || lastDismissDirection == DismissDirection.EndToStart)) {
MaterialTheme.colorScheme.primary
} else {
Color.Unspecified
}
Box(
modifier = Modifier
.fillMaxSize()
@ -174,26 +174,8 @@ fun MangaChapterListItem(
}
},
dismissContent = {
val animateCornerRatio = if (dismissState.offset.value != 0f) {
min(
dismissState.progress.fraction / .075f,
1f,
)
} else {
0f
}
val animateCornerShape = (8f * animateCornerRatio).dp
val dismissContentAlpha =
if (lastDismissDirection != null) animateDismissContentAlpha else 1f
Card(
modifier = modifier,
colors = CardDefaults.elevatedCardColors(
containerColor = Color.Transparent,
),
shape = RoundedCornerShape(animateCornerShape),
) {
Row(
modifier = Modifier
modifier = modifier
.background(
MaterialTheme.colorScheme.background.copy(dismissContentAlpha),
)
@ -213,7 +195,7 @@ fun MangaChapterListItem(
horizontalArrangement = Arrangement.spacedBy(2.dp),
verticalAlignment = Alignment.CenterVertically,
) {
var textHeight by remember { mutableStateOf(0) }
var textHeight by remember { mutableIntStateOf(0) }
if (!read) {
Icon(
imageVector = Icons.Filled.Circle,
@ -277,6 +259,7 @@ fun MangaChapterListItem(
}
}
}
}
if (onDownloadClick != null) {
ChapterDownloadIndicator(
@ -287,8 +270,6 @@ fun MangaChapterListItem(
onClick = onDownloadClick,
)
}
}
}
},
)
}

View file

@ -48,6 +48,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
@ -575,8 +576,8 @@ private fun MangaSummary(
expanded: Boolean,
modifier: Modifier = Modifier,
) {
var expandedHeight by remember { mutableStateOf(0) }
var shrunkHeight by remember { mutableStateOf(0) }
var expandedHeight by remember { mutableIntStateOf(0) }
var shrunkHeight by remember { mutableIntStateOf(0) }
val heightDelta = remember(expandedHeight, shrunkHeight) { expandedHeight - shrunkHeight }
val animProgress by animateFloatAsState(if (expanded) 1f else 0f)
val scrimHeight = with(LocalDensity.current) { remember { 24.sp.roundToPx() } }

View file

@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.pager.PagerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -61,7 +61,7 @@ fun AnimeLibraryPager(
remember(isLandscape) { getColumnsForOrientation(isLandscape) }
} else {
remember { mutableStateOf(0) }
remember { mutableIntStateOf(0) }
}
when (displayMode) {

View file

@ -11,7 +11,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -70,7 +70,7 @@ fun MangaLibraryPager(
remember(isLandscape) { getColumnsForOrientation(isLandscape) }
} else {
remember { mutableStateOf(0) }
remember { mutableIntStateOf(0) }
}
when (displayMode) {

View file

@ -13,6 +13,7 @@ import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
@ -174,7 +175,7 @@ object SettingsAdvancedScreen : SearchableSettings {
val chapterCache = remember { Injekt.get<ChapterCache>() }
val episodeCache = remember { Injekt.get<EpisodeCache>() }
var readableSizeSema by remember { mutableStateOf(0) }
var readableSizeSema by remember { mutableIntStateOf(0) }
val readableSize = remember(readableSizeSema) { chapterCache.readableSize }
val readableAnimeSize = remember(readableSizeSema) { episodeCache.readableSize }

View file

@ -26,6 +26,7 @@ import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@ -93,7 +94,7 @@ object SettingsBackupScreen : SearchableSettings {
val scope = rememberCoroutineScope()
val context = LocalContext.current
var flag by rememberSaveable { mutableStateOf(0) }
var flag by rememberSaveable { mutableIntStateOf(0) }
val chooseBackupDir = rememberLauncherForActivityResult(
contract = ActivityResultContracts.CreateDocument("application/*"),
) {

View file

@ -0,0 +1,78 @@
package eu.kanade.presentation.more.settings.screen.debug
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.AppBarActions
import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.backup.models.Backup
import eu.kanade.tachiyomi.util.system.copyToClipboard
import kotlinx.serialization.protobuf.schema.ProtoBufSchemaGenerator
import tachiyomi.presentation.core.components.material.Scaffold
object BackupSchemaScreen : Screen() {
const val title = "Backup file schema"
@Composable
override fun Content() {
val context = LocalContext.current
val navigator = LocalNavigator.currentOrThrow
val schema = remember { ProtoBufSchemaGenerator.generateSchemaText(Backup.serializer().descriptor) }
Scaffold(
topBar = {
TopAppBar(
title = { Text(text = title) },
navigationIcon = {
IconButton(onClick = navigator::pop) {
Icon(imageVector = Icons.Default.ArrowBack, contentDescription = null)
}
},
actions = {
AppBarActions(
listOf(
AppBar.Action(
title = stringResource(R.string.action_copy_to_clipboard),
icon = Icons.Default.ContentCopy,
onClick = {
context.copyToClipboard(title, schema)
},
),
),
)
},
scrollBehavior = it,
)
},
) { contentPadding ->
Text(
text = schema,
modifier = Modifier
.verticalScroll(rememberScrollState())
.padding(contentPadding)
.padding(16.dp),
fontFamily = FontFamily.Monospace,
)
}
}
}

View file

@ -31,6 +31,10 @@ object DebugInfoScreen : Screen() {
title = WorkerInfoScreen.title,
onClick = { navigator.push(WorkerInfoScreen) },
),
Preference.PreferenceItem.TextPreference(
title = BackupSchemaScreen.title,
onClick = { navigator.push(BackupSchemaScreen) },
),
getAppInfoGroup(),
getDeviceInfoGroup(),
)

View file

@ -23,7 +23,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
@ -203,7 +203,7 @@ fun AnimeUpdatesUiItem(
)
Row(verticalAlignment = Alignment.CenterVertically) {
var textHeight by remember { mutableStateOf(0) }
var textHeight by remember { mutableIntStateOf(0) }
if (!update.seen) {
Icon(
imageVector = Icons.Filled.Circle,

View file

@ -23,7 +23,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
@ -200,7 +200,7 @@ fun MangaUpdatesUiItem(
overflow = TextOverflow.Ellipsis,
)
Row(verticalAlignment = Alignment.CenterVertically) {
var textHeight by remember { mutableStateOf(0) }
var textHeight by remember { mutableIntStateOf(0) }
if (!update.read) {
Icon(
imageVector = Icons.Filled.Circle,

View file

@ -81,15 +81,15 @@ fun WebViewScreenContent(
),
AppBar.OverflowAction(
title = stringResource(R.string.action_share),
onClick = { onShare(state.lastLoadedUrl!!) },
onClick = { onShare(state.lastLoadedUrl ?: url) },
),
AppBar.OverflowAction(
title = stringResource(R.string.action_open_in_browser),
onClick = { onOpenInBrowser(state.lastLoadedUrl!!) },
onClick = { onOpenInBrowser(state.lastLoadedUrl ?: url) },
),
AppBar.OverflowAction(
title = stringResource(R.string.pref_clear_cookies),
onClick = { onClearCookies(state.lastLoadedUrl!!) },
onClick = { onClearCookies(state.lastLoadedUrl ?: url) },
),
),
)

View file

@ -216,9 +216,12 @@ class AnimeDownloadManager(
* @param source the source of the episodes.
*/
fun deleteEpisodes(episodes: List<Episode>, anime: Anime, source: AnimeSource) {
val filteredEpisodes = getEpisodesToDelete(episodes, anime)
if (filteredEpisodes.isNotEmpty()) {
launchIO {
val filteredEpisodes = getEpisodesToDelete(episodes, anime)
if (filteredEpisodes.isEmpty()) {
return@launchIO
}
removeFromDownloadQueue(filteredEpisodes)
val (animeDir, episodeDirs) = provider.findEpisodeDirs(filteredEpisodes, anime, source)
@ -231,7 +234,6 @@ class AnimeDownloadManager(
}
}
}
}
/**
* Deletes the directory of a downloaded anime.
@ -279,7 +281,7 @@ class AnimeDownloadManager(
* @param episodes the list of episodes to delete.
* @param anime the anime of the episodes.
*/
fun enqueueEpisodesToDelete(episodes: List<Episode>, anime: Anime) {
suspend fun enqueueEpisodesToDelete(episodes: List<Episode>, anime: Anime) {
pendingDeleter.addEpisodes(getEpisodesToDelete(episodes, anime), anime)
}
@ -349,22 +351,24 @@ class AnimeDownloadManager(
}
}
private fun getEpisodesToDelete(episodes: List<Episode>, anime: Anime): List<Episode> {
private suspend fun getEpisodesToDelete(episodes: List<Episode>, anime: Anime): List<Episode> {
// Retrieve the categories that are set to exclude from being deleted on read
val categoriesToExclude = downloadPreferences.removeExcludeAnimeCategories().get().map(String::toLong)
val categoriesForAnime = runBlocking { getCategories.await(anime.id) }
val categoriesForAnime = getCategories.await(anime.id)
.map { it.id }
.takeUnless { it.isEmpty() }
?: listOf(0)
return if (categoriesForAnime.intersect(categoriesToExclude).isNotEmpty()) {
.ifEmpty { listOf(0) }
val filteredCategoryAnime = if (categoriesForAnime.intersect(categoriesToExclude).isNotEmpty()) {
episodes.filterNot { it.seen }
} else if (!downloadPreferences.removeBookmarkedChapters().get()) {
episodes.filterNot { it.bookmark }
} else {
episodes
}
return if (!downloadPreferences.removeBookmarkedChapters().get()) {
filteredCategoryAnime.filterNot { it.bookmark }
} else {
filteredCategoryAnime
}
}
fun statusFlow(): Flow<AnimeDownload> = queueState

View file

@ -213,9 +213,12 @@ class MangaDownloadManager(
* @param source the source of the chapters.
*/
fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: MangaSource) {
val filteredChapters = getChaptersToDelete(chapters, manga)
if (filteredChapters.isNotEmpty()) {
launchIO {
val filteredChapters = getChaptersToDelete(chapters, manga)
if (filteredChapters.isEmpty()) {
return@launchIO
}
removeFromDownloadQueue(filteredChapters)
val (mangaDir, chapterDirs) = provider.findChapterDirs(filteredChapters, manga, source)
@ -228,7 +231,6 @@ class MangaDownloadManager(
}
}
}
}
/**
* Deletes the directory of a downloaded manga.
@ -277,7 +279,7 @@ class MangaDownloadManager(
* @param chapters the list of chapters to delete.
* @param manga the manga of the chapters.
*/
fun enqueueChaptersToDelete(chapters: List<Chapter>, manga: Manga) {
suspend fun enqueueChaptersToDelete(chapters: List<Chapter>, manga: Manga) {
pendingDeleter.addChapters(getChaptersToDelete(chapters, manga), manga)
}
@ -350,22 +352,24 @@ class MangaDownloadManager(
}
}
private fun getChaptersToDelete(chapters: List<Chapter>, manga: Manga): List<Chapter> {
private suspend fun getChaptersToDelete(chapters: List<Chapter>, manga: Manga): List<Chapter> {
// Retrieve the categories that are set to exclude from being deleted on read
val categoriesToExclude = downloadPreferences.removeExcludeCategories().get().map(String::toLong)
val categoriesForManga = runBlocking { getCategories.await(manga.id) }
val categoriesForManga = getCategories.await(manga.id)
.map { it.id }
.takeUnless { it.isEmpty() }
?: listOf(0)
return if (categoriesForManga.intersect(categoriesToExclude).isNotEmpty()) {
.ifEmpty { listOf(0) }
val filteredCategoryManga = if (categoriesForManga.intersect(categoriesToExclude).isNotEmpty()) {
chapters.filterNot { it.read }
} else if (!downloadPreferences.removeBookmarkedChapters().get()) {
chapters.filterNot { it.bookmark }
} else {
chapters
}
return if (!downloadPreferences.removeBookmarkedChapters().get()) {
filteredCategoryManga.filterNot { it.bookmark }
} else {
filteredCategoryManga
}
}
fun statusFlow(): Flow<MangaDownload> = queueState

View file

@ -15,6 +15,7 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
@ -93,7 +94,7 @@ class SourcePreferencesScreen(val sourceId: Long) : Screen() {
commit: FragmentTransaction.(containerId: Int) -> Unit,
) {
val containerId by rememberSaveable {
mutableStateOf(View.generateViewId())
mutableIntStateOf(View.generateViewId())
}
var initialized by rememberSaveable { mutableStateOf(false) }
AndroidView(

View file

@ -15,6 +15,7 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
@ -93,7 +94,7 @@ class MangaSourcePreferencesScreen(val sourceId: Long) : Screen() {
commit: FragmentTransaction.(containerId: Int) -> Unit,
) {
val containerId by rememberSaveable {
mutableStateOf(View.generateViewId())
mutableIntStateOf(View.generateViewId())
}
var initialized by rememberSaveable { mutableStateOf(false) }
AndroidView(

View file

@ -14,6 +14,7 @@ import android.graphics.Paint
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.text.TextUtils
import android.view.Gravity
import android.view.KeyEvent
import android.view.Menu
@ -38,6 +39,7 @@ import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.lifecycleScope
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import com.google.android.material.internal.ToolbarUtils
import com.google.android.material.shape.MaterialShapeDrawable
import com.google.android.material.transition.platform.MaterialContainerTransform
import dev.chrisbanes.insetter.applyInsetter
@ -697,10 +699,16 @@ class ReaderActivity : BaseActivity() {
* method to the current viewer, but also set the subtitle on the toolbar, and
* hides or disables the reader prev/next buttons if there's a prev or next chapter
*/
@SuppressLint("RestrictedApi")
private fun setChapters(viewerChapters: ViewerChapters) {
binding.readerContainer.removeView(loadingIndicator)
viewModel.state.value.viewer?.setChapters(viewerChapters)
binding.toolbar.subtitle = viewerChapters.currChapter.chapter.name
ToolbarUtils.getSubtitleTextView(binding.toolbar)?.let {
it.ellipsize = TextUtils.TruncateAt.MARQUEE
it.isSelected = true
}
// Invalidate menu to show proper chapter bookmark state
invalidateOptionsMenu()

View file

@ -25,10 +25,12 @@ import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import kotlinx.coroutines.supervisorScope
import kotlinx.coroutines.suspendCancellableCoroutine
import logcat.LogPriority
import tachiyomi.core.util.lang.launchIO
import tachiyomi.core.util.lang.withIOContext
import tachiyomi.core.util.lang.withUIContext
import tachiyomi.core.util.system.ImageUtil
import tachiyomi.core.util.system.logcat
import java.io.BufferedInputStream
import java.io.InputStream
@ -234,6 +236,7 @@ class WebtoonPageHolder(
}
private fun onStripSplit(imageStream: BufferedInputStream): InputStream {
try {
// If we have reached this point [page] and its stream shouldn't be null
val page = page!!
val stream = page.stream!!
@ -247,6 +250,10 @@ class WebtoonPageHolder(
// Running [onLongStripSplit] first results in issues with splitting
viewer.onLongStripSplit(page, newPages)
}
} catch (e: Exception) {
logcat(LogPriority.ERROR, e) { "Failed to split image" }
return imageStream
}
}
/**

View file

@ -298,9 +298,8 @@ object ImageUtil {
"splitHeight=${splitData.splitHeight} bottomOffset=${splitData.bottomOffset}"
}
val region = Rect(0, splitData.topOffset, splitData.splitWidth, splitData.bottomOffset)
try {
val region = Rect(0, splitData.topOffset, splitData.splitWidth, splitData.bottomOffset)
val splitBitmap = bitmapRegionDecoder.decodeRegion(region, null)
val outputStream = ByteArrayOutputStream()
splitBitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream)

View file

@ -1,6 +1,6 @@
[versions]
compiler = "1.4.7"
compose-bom = "2023.04.00-alpha04"
compose-bom = "2023.04.00-beta01.1"
accompanist = "0.31.2-alpha"
[libraries]

View file

@ -26,7 +26,7 @@ import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
@ -61,7 +61,7 @@ fun AdaptiveSheet(
) {
val scope = rememberCoroutineScope()
if (isTabletUi) {
var targetAlpha by remember { mutableStateOf(0f) }
var targetAlpha by remember { mutableFloatStateOf(0f) }
val alpha by animateFloatAsState(
targetValue = targetAlpha,
animationSpec = SheetAnimationSpec,

View file

@ -1,11 +1,10 @@
package tachiyomi.presentation.core.components
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@ -24,7 +23,7 @@ fun Pill(
elevation: Dp = 1.dp,
fontSize: TextUnit = LocalTextStyle.current.fontSize,
) {
androidx.compose.material3.Surface(
Surface(
modifier = modifier
.padding(start = 4.dp),
shape = MaterialTheme.shapes.extraLarge,
@ -34,7 +33,6 @@ fun Pill(
) {
Box(
modifier = Modifier
.requiredWidth(IntrinsicSize.Max)
.padding(6.dp, 1.dp),
contentAlignment = Alignment.Center,
) {

View file

@ -28,7 +28,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
@ -85,7 +85,7 @@ fun VerticalFastScroller(
if (!showScroller) return@subcompose
val thumbTopPadding = with(LocalDensity.current) { topContentPadding.toPx() }
var thumbOffsetY by remember(thumbTopPadding) { mutableStateOf(thumbTopPadding) }
var thumbOffsetY by remember(thumbTopPadding) { mutableFloatStateOf(thumbTopPadding) }
val dragInteractionSource = remember { MutableInteractionSource() }
val isThumbDragged by dragInteractionSource.collectIsDraggedAsState()
@ -251,7 +251,7 @@ fun VerticalGridFastScroller(
val showScroller = layoutInfo.visibleItemsInfo.size < layoutInfo.totalItemsCount
if (!showScroller) return@subcompose
val thumbTopPadding = with(LocalDensity.current) { topContentPadding.toPx() }
var thumbOffsetY by remember(thumbTopPadding) { mutableStateOf(thumbTopPadding) }
var thumbOffsetY by remember(thumbTopPadding) { mutableFloatStateOf(thumbTopPadding) }
val dragInteractionSource = remember { MutableInteractionSource() }
val isThumbDragged by dragInteractionSource.collectIsDraggedAsState()

View file

@ -20,6 +20,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
@ -113,7 +114,7 @@ private fun <T> WheelPicker(
val haptic = LocalHapticFeedback.current
val lazyListState = rememberLazyListState(startIndex)
var internalIndex by remember { mutableStateOf(startIndex) }
var internalIndex by remember { mutableIntStateOf(startIndex) }
val internalOnSelectionChanged: (Int) -> Unit = {
internalIndex = it
onSelectionChanged(it)

View file

@ -4,7 +4,7 @@ import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
@ -30,8 +30,8 @@ fun LazyListState.isScrolledToEnd(): Boolean {
@Composable
fun LazyListState.isScrollingUp(): Boolean {
var previousIndex by remember { mutableStateOf(firstVisibleItemIndex) }
var previousScrollOffset by remember { mutableStateOf(firstVisibleItemScrollOffset) }
var previousIndex by remember { mutableIntStateOf(firstVisibleItemIndex) }
var previousScrollOffset by remember { mutableIntStateOf(firstVisibleItemScrollOffset) }
return remember {
derivedStateOf {
if (previousIndex != firstVisibleItemIndex) {
@ -48,8 +48,8 @@ fun LazyListState.isScrollingUp(): Boolean {
@Composable
fun LazyListState.isScrollingDown(): Boolean {
var previousIndex by remember { mutableStateOf(firstVisibleItemIndex) }
var previousScrollOffset by remember { mutableStateOf(firstVisibleItemScrollOffset) }
var previousIndex by remember { mutableIntStateOf(firstVisibleItemIndex) }
var previousScrollOffset by remember { mutableIntStateOf(firstVisibleItemScrollOffset) }
return remember {
derivedStateOf {
if (previousIndex != firstVisibleItemIndex) {