Compare commits

..

5 Commits

Author SHA1 Message Date
Cuong-Tran
264030d6ec
Add libs.material to presentation-widget (#1373)
Fixes some build issues
2024-10-26 09:02:07 +06:00
AntsyLich
140083ee39
Update dependency com.pinterest.ktlint:ktlint-cli to v1.4.0
Co-authored-by: Mend Renovate <bot@renovateapp.com>
2024-10-26 07:40:57 +06:00
Mend Renovate
2bf7ef5d18
Update actions/setup-java action to v4.5.0 (#1366) 2024-10-26 07:23:13 +06:00
AntsyLich
df9fff60da
Cleanup Slider usage 2024-10-26 07:15:01 +06:00
Mend Renovate
aae0e3459c
Update dependency me.zhanghai.android.libarchive:library to v1.1.4 (#1378) 2024-10-26 03:55:19 +06:00
25 changed files with 96 additions and 49 deletions

View File

@ -32,7 +32,7 @@ jobs:
uses: actions/dependency-review-action@a6993e2c61fd5dc440b409aa1d6904921c5e1894 # v4.3.5 uses: actions/dependency-review-action@a6993e2c61fd5dc440b409aa1d6904921c5e1894 # v4.3.5
- name: Set up JDK - name: Set up JDK
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0 uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
with: with:
java-version: 17 java-version: 17
distribution: adopt distribution: adopt

View File

@ -27,7 +27,7 @@ jobs:
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3" ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3"
- name: Set up JDK - name: Set up JDK
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0 uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
with: with:
java-version: 17 java-version: 17
distribution: adopt distribution: adopt

View File

@ -56,7 +56,7 @@ fun ReaderAppBars(
enabledPrevious: Boolean, enabledPrevious: Boolean,
currentPage: Int, currentPage: Int,
totalPages: Int, totalPages: Int,
onSliderValueChange: (Int) -> Unit, onPageIndexChange: (Int) -> Unit,
readingMode: ReadingMode, readingMode: ReadingMode,
onClickReadingMode: () -> Unit, onClickReadingMode: () -> Unit,
@ -176,9 +176,8 @@ fun ReaderAppBars(
enabledPrevious = enabledPrevious, enabledPrevious = enabledPrevious,
currentPage = currentPage, currentPage = currentPage,
totalPages = totalPages, totalPages = totalPages,
onSliderValueChange = onSliderValueChange, onPageIndexChange = onPageIndexChange,
) )
BottomReaderBar( BottomReaderBar(
backgroundColor = backgroundColor, backgroundColor = backgroundColor,
readingMode = readingMode, readingMode = readingMode,

View File

@ -4,6 +4,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsDraggedAsState import androidx.compose.foundation.interaction.collectIsDraggedAsState
import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
@ -16,7 +17,6 @@ import androidx.compose.material3.FilledIconButton
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButtonDefaults import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Slider
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -29,6 +29,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.platform.LocalLayoutDirection
@ -38,8 +39,8 @@ import androidx.compose.ui.unit.dp
import eu.kanade.presentation.theme.TachiyomiPreviewTheme import eu.kanade.presentation.theme.TachiyomiPreviewTheme
import eu.kanade.presentation.util.isTabletUi import eu.kanade.presentation.util.isTabletUi
import tachiyomi.i18n.MR import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.Slider
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
import kotlin.math.roundToInt
@Composable @Composable
fun ChapterNavigator( fun ChapterNavigator(
@ -50,7 +51,7 @@ fun ChapterNavigator(
enabledPrevious: Boolean, enabledPrevious: Boolean,
currentPage: Int, currentPage: Int,
totalPages: Int, totalPages: Int,
onSliderValueChange: (Int) -> Unit, onPageIndexChange: (Int) -> Unit,
) { ) {
val isTabletUi = isTabletUi() val isTabletUi = isTabletUi()
val horizontalPadding = if (isTabletUi) 24.dp else 8.dp val horizontalPadding = if (isTabletUi) 24.dp else 8.dp
@ -97,7 +98,11 @@ fun ChapterNavigator(
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
Box(contentAlignment = Alignment.CenterEnd) {
Text(text = currentPage.toString()) Text(text = currentPage.toString())
// Taking up full length so the slider doesn't shift when 'currentPage' length changes
Text(text = totalPages.toString(), color = Color.Transparent)
}
val interactionSource = remember { MutableInteractionSource() } val interactionSource = remember { MutableInteractionSource() }
val sliderDragged by interactionSource.collectIsDraggedAsState() val sliderDragged by interactionSource.collectIsDraggedAsState()
@ -110,14 +115,11 @@ fun ChapterNavigator(
modifier = Modifier modifier = Modifier
.weight(1f) .weight(1f)
.padding(horizontal = 8.dp), .padding(horizontal = 8.dp),
value = currentPage.toFloat(), value = currentPage,
valueRange = 1f..totalPages.toFloat(), valueRange = 1..totalPages,
steps = totalPages - 2, onValueChange = f@{
onValueChange = { if (it == currentPage) return@f
val new = it.roundToInt() - 1 onPageIndexChange(it - 1)
if (new != currentPage) {
onSliderValueChange(new)
}
}, },
interactionSource = interactionSource, interactionSource = interactionSource,
) )
@ -158,7 +160,7 @@ private fun ChapterNavigatorPreview() {
enabledPrevious = true, enabledPrevious = true,
currentPage = currentPage, currentPage = currentPage,
totalPages = 10, totalPages = 10,
onSliderValueChange = { currentPage = it }, onPageIndexChange = { currentPage = (it + 1) },
) )
} }
} }

View File

@ -1,4 +1,4 @@
@file:Suppress("PropertyName", "ktlint:standard:property-naming") @file:Suppress("PropertyName")
package eu.kanade.tachiyomi.data.database.models package eu.kanade.tachiyomi.data.database.models

View File

@ -1,4 +1,4 @@
@file:Suppress("PropertyName", "ktlint:standard:property-naming") @file:Suppress("PropertyName")
package eu.kanade.tachiyomi.data.database.models package eu.kanade.tachiyomi.data.database.models

View File

@ -1,4 +1,4 @@
@file:Suppress("PropertyName", "ktlint:standard:property-naming") @file:Suppress("PropertyName")
package eu.kanade.tachiyomi.data.database.models package eu.kanade.tachiyomi.data.database.models

View File

@ -1,4 +1,4 @@
@file:Suppress("PropertyName", "ktlint:standard:property-naming") @file:Suppress("PropertyName")
package eu.kanade.tachiyomi.data.database.models package eu.kanade.tachiyomi.data.database.models

View File

@ -1,4 +1,4 @@
@file:Suppress("PropertyName", "ktlint:standard:property-naming") @file:Suppress("PropertyName")
package eu.kanade.tachiyomi.data.track.model package eu.kanade.tachiyomi.data.track.model

View File

@ -401,7 +401,7 @@ class ReaderActivity : BaseActivity() {
enabledPrevious = state.viewerChapters?.prevChapter != null, enabledPrevious = state.viewerChapters?.prevChapter != null,
currentPage = state.currentPage, currentPage = state.currentPage,
totalPages = state.totalPages, totalPages = state.totalPages,
onSliderValueChange = { onPageIndexChange = {
isScrollingThroughPages = true isScrollingThroughPages = true
moveToPageIndex(it) moveToPageIndex(it)
}, },

View File

@ -1,4 +1,4 @@
@file:Suppress("FunctionName", "ktlint:standard:function-naming") @file:Suppress("FunctionName")
package eu.kanade.tachiyomi.network package eu.kanade.tachiyomi.network

View File

@ -9,7 +9,7 @@ sqldelight = "2.0.2"
sqlite = "2.4.0" sqlite = "2.4.0"
voyager = "1.0.0" voyager = "1.0.0"
spotless = "6.25.0" spotless = "6.25.0"
ktlint-core = "1.3.1" ktlint-core = "1.4.0"
firebase-bom = "33.5.1" firebase-bom = "33.5.1"
[libraries] [libraries]
@ -32,7 +32,7 @@ jsoup = "org.jsoup:jsoup:1.18.1"
disklrucache = "com.jakewharton:disklrucache:2.0.2" disklrucache = "com.jakewharton:disklrucache:2.0.2"
unifile = "com.github.tachiyomiorg:unifile:e0def6b3dc" unifile = "com.github.tachiyomiorg:unifile:e0def6b3dc"
libarchive = "me.zhanghai.android.libarchive:library:1.1.3" libarchive = "me.zhanghai.android.libarchive:library:1.1.4"
sqlite-framework = { module = "androidx.sqlite:sqlite-framework", version.ref = "sqlite" } sqlite-framework = { module = "androidx.sqlite:sqlite-framework", version.ref = "sqlite" }
sqlite-ktx = { module = "androidx.sqlite:sqlite-ktx", version.ref = "sqlite" } sqlite-ktx = { module = "androidx.sqlite:sqlite-ktx", version.ref = "sqlite" }

View File

@ -28,7 +28,6 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.RadioButton import androidx.compose.material3.RadioButton
import androidx.compose.material3.Slider
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@ -46,6 +45,7 @@ import tachiyomi.core.common.preference.Preference
import tachiyomi.core.common.preference.TriState import tachiyomi.core.common.preference.TriState
import tachiyomi.core.common.preference.toggle import tachiyomi.core.common.preference.toggle
import tachiyomi.presentation.core.components.material.DISABLED_ALPHA import tachiyomi.presentation.core.components.material.DISABLED_ALPHA
import tachiyomi.presentation.core.components.material.Slider
import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.components.material.padding
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.theme.header import tachiyomi.presentation.core.theme.header
@ -192,17 +192,14 @@ fun SliderItem(
} }
Slider( Slider(
value = value.toFloat(),
onValueChange = {
val newValue = it.toInt()
if (newValue != value) {
onChange(newValue)
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
}
},
modifier = Modifier.weight(1.5f), modifier = Modifier.weight(1.5f),
valueRange = min.toFloat()..max.toFloat(), value = value,
steps = max - min - 1, onValueChange = f@{
if (it == value) return@f
onChange(it)
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
},
valueRange = min..max,
) )
} }
} }

View File

@ -0,0 +1,48 @@
package tachiyomi.presentation.core.components.material
import androidx.annotation.IntRange
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.material3.Slider
import androidx.compose.material3.SliderColors
import androidx.compose.material3.SliderDefaults
import androidx.compose.material3.SliderState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
@Composable
fun Slider(
value: Int,
onValueChange: (Int) -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
valueRange: ClosedRange<Int> = 0..1,
@IntRange(from = 0) steps: Int = with(valueRange) { (endInclusive - start) - 1 },
onValueChangeFinished: (() -> Unit)? = null,
colors: SliderColors = SliderDefaults.colors(),
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
thumb: @Composable (SliderState) -> Unit = {
SliderDefaults.Thumb(
interactionSource = interactionSource,
colors = colors,
enabled = enabled,
)
},
track: @Composable (SliderState) -> Unit = { sliderState ->
SliderDefaults.Track(colors = colors, enabled = enabled, sliderState = sliderState)
},
) {
Slider(
value = value.toFloat(),
onValueChange = { onValueChange(it.toInt()) },
modifier = modifier,
enabled = enabled,
valueRange = with(valueRange) { start.toFloat()..endInclusive.toFloat() },
steps = steps,
onValueChangeFinished = onValueChangeFinished,
colors = colors,
interactionSource = interactionSource,
thumb = thumb,
track = track,
)
}

View File

@ -82,5 +82,5 @@ val CustomIcons.Discord: ImageVector
return _discord!! return _discord!!
} }
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming") @Suppress("ObjectPropertyName")
private var _discord: ImageVector? = null private var _discord: ImageVector? = null

View File

@ -59,5 +59,5 @@ val CustomIcons.Facebook: ImageVector
return _facebook!! return _facebook!!
} }
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming") @Suppress("ObjectPropertyName")
private var _facebook: ImageVector? = null private var _facebook: ImageVector? = null

View File

@ -64,5 +64,5 @@ val CustomIcons.Github: ImageVector
return _github!! return _github!!
} }
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming") @Suppress("ObjectPropertyName")
private var _github: ImageVector? = null private var _github: ImageVector? = null

View File

@ -90,5 +90,5 @@ val CustomIcons.Reddit: ImageVector
return _reddit!! return _reddit!!
} }
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming") @Suppress("ObjectPropertyName")
private var _reddit: ImageVector? = null private var _reddit: ImageVector? = null

View File

@ -57,5 +57,5 @@ val CustomIcons.X: ImageVector
return _x!! return _x!!
} }
@Suppress("ObjectPropertyName", "ktlint:standard:backing-property-naming") @Suppress("ObjectPropertyName")
private var _x: ImageVector? = null private var _x: ImageVector? = null

View File

@ -20,6 +20,7 @@ dependencies {
api(projects.i18n) api(projects.i18n)
implementation(compose.glance) implementation(compose.glance)
implementation(libs.material)
implementation(kotlinx.immutables) implementation(kotlinx.immutables)

View File

@ -1,4 +1,4 @@
@file:Suppress("PropertyName", "ktlint:standard:property-naming") @file:Suppress("PropertyName")
package eu.kanade.tachiyomi.source.model package eu.kanade.tachiyomi.source.model

View File

@ -1,4 +1,4 @@
@file:Suppress("PropertyName", "ktlint:standard:property-naming") @file:Suppress("PropertyName")
package eu.kanade.tachiyomi.source.model package eu.kanade.tachiyomi.source.model

View File

@ -1,4 +1,4 @@
@file:Suppress("PropertyName", "ktlint:standard:property-naming") @file:Suppress("PropertyName")
package eu.kanade.tachiyomi.source.model package eu.kanade.tachiyomi.source.model

View File

@ -1,4 +1,4 @@
@file:Suppress("PropertyName", "ktlint:standard:property-naming") @file:Suppress("PropertyName")
package eu.kanade.tachiyomi.source.model package eu.kanade.tachiyomi.source.model

View File

@ -55,10 +55,10 @@ actual class LocalSource(
private val json: Json by injectLazy() private val json: Json by injectLazy()
private val xml: XML by injectLazy() private val xml: XML by injectLazy()
@Suppress("PrivatePropertyName", "ktlint:standard:property-naming") @Suppress("PrivatePropertyName")
private val PopularFilters = FilterList(OrderBy.Popular(context)) private val PopularFilters = FilterList(OrderBy.Popular(context))
@Suppress("PrivatePropertyName", "ktlint:standard:property-naming") @Suppress("PrivatePropertyName")
private val LatestFilters = FilterList(OrderBy.Latest(context)) private val LatestFilters = FilterList(OrderBy.Latest(context))
override val name: String = context.stringResource(MR.strings.local_source) override val name: String = context.stringResource(MR.strings.local_source)