mirror of https://github.com/Ashinch/ReadYou.git
Fix several deprecation notices (#758)
* migrate to Gradle Kotlin DSL, version catalog and ksp * replace buildDir with layout.buildDirectory * declare plugins in version catalogs * add room plugin * specify type of keyPropsFile * added missing version number in [versions] * use alias instead of id whenever possible * finishes replacing id with alias * migrate pager * Migrate to androidx.compose.foundation FlowLayouts * add optin to avoid warning during build * use nonFinalResIds for faster compilation * use nonTransitiveRclass for faster compilation * migrate smallTopAppBarColors to topAppBarColors * migrate 'with(ExitTransition): ContentTransform' to togetherWith * migrate fromHtml * migrate TextFieldDefaults.textFieldColors to TextFieldDefaults.colors * migrate get(...).toString() to getString(...) * add optin * rename Divider to HorizontalDivider
This commit is contained in:
parent
573fead2da
commit
81dbe094f9
|
@ -2,7 +2,7 @@ import java.util.Properties
|
|||
import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.ksp)
|
||||
alias(libs.plugins.aboutlibraries)
|
||||
|
@ -130,8 +130,6 @@ dependencies {
|
|||
implementation(libs.compose.material3)
|
||||
|
||||
// Accompanist
|
||||
implementation(libs.accompanist.pager)
|
||||
implementation(libs.accompanist.flowlayout)
|
||||
implementation(libs.accompanist.swiperefresh)
|
||||
|
||||
// Coil
|
||||
|
|
|
@ -46,7 +46,7 @@ fun AnimatedText(
|
|||
200,
|
||||
easing = FastOutSlowInEasing
|
||||
)
|
||||
) { height -> height } with slideOutVertically { height -> -height } + fadeOut(
|
||||
) { height -> height } togetherWith slideOutVertically { height -> -height } + fadeOut(
|
||||
tween(
|
||||
200,
|
||||
easing = FastOutSlowInEasing
|
||||
|
|
|
@ -60,8 +60,9 @@ fun RYOutlineTextField(
|
|||
|
||||
OutlinedTextField(
|
||||
modifier = Modifier.focusRequester(focusRequester),
|
||||
colors = TextFieldDefaults.textFieldColors(
|
||||
containerColor = Color.Transparent,
|
||||
colors = TextFieldDefaults.colors(
|
||||
unfocusedContainerColor = Color.Transparent,
|
||||
focusedContainerColor = Color.Transparent
|
||||
),
|
||||
maxLines = if (singleLine) 1 else Int.MAX_VALUE,
|
||||
enabled = !readOnly,
|
||||
|
|
|
@ -44,7 +44,7 @@ fun RYScaffold(
|
|||
title = {},
|
||||
navigationIcon = { navigationIcon?.invoke() },
|
||||
actions = { actions?.invoke(this) },
|
||||
colors = TopAppBarDefaults.smallTopAppBarColors(
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
|
||||
topBarTonalElevation
|
||||
),
|
||||
|
|
|
@ -46,8 +46,9 @@ fun RYTextField(
|
|||
|
||||
TextField(
|
||||
modifier = Modifier.focusRequester(focusRequester),
|
||||
colors = TextFieldDefaults.textFieldColors(
|
||||
containerColor = Color.Transparent,
|
||||
colors = TextFieldDefaults.colors(
|
||||
unfocusedContainerColor = Color.Transparent,
|
||||
focusedContainerColor = Color.Transparent
|
||||
),
|
||||
maxLines = if (singleLine) 1 else Int.MAX_VALUE,
|
||||
enabled = !readOnly,
|
||||
|
|
|
@ -1,26 +1,24 @@
|
|||
package me.ash.reader.ui.component.base
|
||||
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.google.accompanist.pager.ExperimentalPagerApi
|
||||
import com.google.accompanist.pager.HorizontalPager
|
||||
import com.google.accompanist.pager.PagerState
|
||||
|
||||
@OptIn(ExperimentalPagerApi::class)
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun ViewPager(
|
||||
modifier: Modifier = Modifier,
|
||||
state: PagerState = com.google.accompanist.pager.rememberPagerState(),
|
||||
composableList: List<@Composable () -> Unit>,
|
||||
userScrollEnabled: Boolean = true,
|
||||
) {
|
||||
HorizontalPager(
|
||||
count = composableList.size,
|
||||
state = state,
|
||||
state = rememberPagerState { composableList.size },
|
||||
verticalAlignment = Alignment.Top,
|
||||
modifier = modifier
|
||||
.animateContentSize()
|
||||
|
@ -30,4 +28,4 @@ fun ViewPager(
|
|||
) { page ->
|
||||
composableList[page]()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,30 +19,18 @@ import androidx.compose.ui.platform.LocalView
|
|||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.lerp
|
||||
import com.google.accompanist.pager.ExperimentalPagerApi
|
||||
import com.google.accompanist.pager.PagerScope
|
||||
import com.google.accompanist.pager.calculateCurrentOffsetForPage
|
||||
import androidx.compose.foundation.pager.PagerState
|
||||
import kotlin.math.absoluteValue
|
||||
|
||||
@OptIn(ExperimentalPagerApi::class)
|
||||
fun Modifier.pagerAnimate(pagerScope: PagerScope, page: Int): Modifier {
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
fun Modifier.pagerAnimate(pagerState: PagerState, page: Int): Modifier {
|
||||
return graphicsLayer {
|
||||
// Calculate the absolute offset for the current page from the
|
||||
// scroll position. We use the absolute value which allows us to mirror
|
||||
// any effects for both directions
|
||||
val pageOffset = pagerScope.calculateCurrentOffsetForPage(page).absoluteValue
|
||||
val pageOffset = ((pagerState.currentPage - page) + pagerState.currentPageOffsetFraction).absoluteValue
|
||||
|
||||
// We animate the scaleX + scaleY, between 85% and 100%
|
||||
// lerp(
|
||||
// start = 0.85f.dp,
|
||||
// stop = 1f.dp,
|
||||
// fraction = 1f - pageOffset.coerceIn(0f, 1f)
|
||||
// ).also { scale ->
|
||||
// scaleX = scale.value
|
||||
// scaleY = scale.value
|
||||
// }
|
||||
|
||||
// We animate the alpha, between 50% and 100%
|
||||
// We animate the alpha, between 20% and 100%
|
||||
alpha = lerp(
|
||||
start = 0.2f.dp,
|
||||
stop = 1f.dp,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package me.ash.reader.ui.ext
|
||||
|
||||
import com.google.accompanist.pager.ExperimentalPagerApi
|
||||
import com.google.accompanist.pager.PagerState
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.pager.PagerState
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalPagerApi::class)
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
fun PagerState.animateScrollToPage(
|
||||
scope: CoroutineScope,
|
||||
targetPage: Int,
|
||||
|
|
|
@ -43,7 +43,7 @@ fun String.md5(): String =
|
|||
BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray()))
|
||||
.toString(16).padStart(32, '0')
|
||||
|
||||
fun String?.decodeHTML(): String? = this?.run { Html.fromHtml(this).toString() }
|
||||
fun String?.decodeHTML(): String? = this?.run { Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY).toString() }
|
||||
|
||||
fun String?.orNotEmpty(l: (value: String) -> String): String =
|
||||
if (this.isNullOrBlank()) "" else l(this)
|
||||
|
|
|
@ -69,7 +69,7 @@ fun HomeEntry(
|
|||
|
||||
val intent by rememberSaveable { mutableStateOf(context.findActivity()?.intent) }
|
||||
var openArticleId by rememberSaveable {
|
||||
mutableStateOf(intent?.extras?.get(ExtraName.ARTICLE_ID)?.toString() ?: "")
|
||||
mutableStateOf(intent?.extras?.getString(ExtraName.ARTICLE_ID) ?: "")
|
||||
}.also {
|
||||
intent?.replaceExtras(null)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import androidx.compose.foundation.shape.CircleShape
|
|||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.Article
|
||||
import androidx.compose.material.icons.outlined.Add
|
||||
import androidx.compose.material.icons.outlined.Article
|
||||
import androidx.compose.material.icons.outlined.Notifications
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
|
@ -22,9 +21,7 @@ import androidx.compose.ui.draw.clip
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.google.accompanist.flowlayout.FlowCrossAxisAlignment
|
||||
import com.google.accompanist.flowlayout.FlowRow
|
||||
import com.google.accompanist.flowlayout.MainAxisAlignment
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import me.ash.reader.R
|
||||
import me.ash.reader.domain.model.group.Group
|
||||
import me.ash.reader.ui.component.base.RYSelectionChip
|
||||
|
@ -119,6 +116,7 @@ private fun EditableUrl(
|
|||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun Preset(
|
||||
selectedAllowNotificationPreset: Boolean = false,
|
||||
|
@ -133,10 +131,8 @@ private fun Preset(
|
|||
Subtitle(text = stringResource(R.string.preset))
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
FlowRow(
|
||||
mainAxisAlignment = MainAxisAlignment.Start,
|
||||
crossAxisAlignment = FlowCrossAxisAlignment.Center,
|
||||
crossAxisSpacing = 10.dp,
|
||||
mainAxisSpacing = 10.dp,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.Start),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterVertically),
|
||||
) {
|
||||
RYSelectionChip(
|
||||
modifier = Modifier.animateContentSize(),
|
||||
|
@ -193,6 +189,7 @@ private fun Preset(
|
|||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun AddToGroup(
|
||||
isMoveToGroup: Boolean = false,
|
||||
|
@ -222,10 +219,8 @@ private fun AddToGroup(
|
|||
}
|
||||
} else {
|
||||
FlowRow(
|
||||
mainAxisAlignment = MainAxisAlignment.Start,
|
||||
crossAxisAlignment = FlowCrossAxisAlignment.Center,
|
||||
crossAxisSpacing = 10.dp,
|
||||
mainAxisSpacing = 10.dp,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.Start),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterVertically),
|
||||
) {
|
||||
groups.forEach {
|
||||
RYSelectionChip(
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.lifecycle.viewModelScope
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import me.ash.reader.R
|
||||
|
@ -39,6 +40,7 @@ class FeedsViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
fun pullFeeds(filterState: FilterState) {
|
||||
val isStarred = filterState.filter.isStarred()
|
||||
val isUnread = filterState.filter.isUnread()
|
||||
|
|
|
@ -22,15 +22,14 @@ import androidx.compose.ui.text.style.TextAlign
|
|||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.google.accompanist.flowlayout.FlowCrossAxisAlignment
|
||||
import com.google.accompanist.flowlayout.FlowRow
|
||||
import com.google.accompanist.flowlayout.MainAxisAlignment
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import me.ash.reader.R
|
||||
import me.ash.reader.domain.model.account.Account
|
||||
import me.ash.reader.ui.component.base.RYDialog
|
||||
import me.ash.reader.ui.ext.currentAccountId
|
||||
import me.ash.reader.ui.theme.palette.alwaysLight
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
fun AccountsTab(
|
||||
modifier: Modifier = Modifier,
|
||||
|
@ -58,10 +57,8 @@ fun AccountsTab(
|
|||
},
|
||||
text = {
|
||||
FlowRow(
|
||||
mainAxisAlignment = MainAxisAlignment.Start,
|
||||
crossAxisAlignment = FlowCrossAxisAlignment.Start,
|
||||
crossAxisSpacing = 10.dp,
|
||||
mainAxisSpacing = 10.dp,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.Start),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterVertically),
|
||||
) {
|
||||
accounts.forEach { account ->
|
||||
Column(
|
||||
|
|
|
@ -27,9 +27,7 @@ import androidx.compose.ui.text.style.TextAlign
|
|||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import com.google.accompanist.flowlayout.FlowCrossAxisAlignment
|
||||
import com.google.accompanist.flowlayout.FlowRow
|
||||
import com.google.accompanist.flowlayout.MainAxisAlignment
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import kotlinx.coroutines.launch
|
||||
import me.ash.reader.R
|
||||
import me.ash.reader.domain.model.group.Group
|
||||
|
@ -149,6 +147,7 @@ fun GroupOptionDrawer(
|
|||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun Preset(
|
||||
viewModel: GroupOptionViewModel,
|
||||
|
@ -156,10 +155,8 @@ private fun Preset(
|
|||
context: Context,
|
||||
) {
|
||||
FlowRow(
|
||||
mainAxisAlignment = MainAxisAlignment.Start,
|
||||
crossAxisAlignment = FlowCrossAxisAlignment.Center,
|
||||
crossAxisSpacing = 10.dp,
|
||||
mainAxisSpacing = 10.dp,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.Start),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterVertically),
|
||||
) {
|
||||
RYSelectionChip(
|
||||
modifier = Modifier.animateContentSize(),
|
||||
|
@ -212,6 +209,7 @@ private fun Preset(
|
|||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun FlowRowGroups(
|
||||
groupOptionUiState: GroupOptionUiState,
|
||||
|
@ -219,10 +217,8 @@ private fun FlowRowGroups(
|
|||
groupOptionViewModel: GroupOptionViewModel,
|
||||
) {
|
||||
FlowRow(
|
||||
mainAxisAlignment = MainAxisAlignment.Start,
|
||||
crossAxisAlignment = FlowCrossAxisAlignment.Center,
|
||||
crossAxisSpacing = 10.dp,
|
||||
mainAxisSpacing = 10.dp,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.Start),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterVertically),
|
||||
) {
|
||||
groupOptionUiState.groups.forEach {
|
||||
if (it.id != group?.id) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.compose.animation.fadeIn
|
|||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
import androidx.compose.animation.togetherWith
|
||||
import androidx.compose.animation.with
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
|
@ -104,8 +105,8 @@ fun SubscribeDialog(
|
|||
AnimatedContent(
|
||||
targetState = subscribeUiState.isSearchPage,
|
||||
transitionSpec = {
|
||||
slideInHorizontally { width -> width } + fadeIn() with
|
||||
slideOutHorizontally { width -> -width } + fadeOut()
|
||||
(slideInHorizontally { width -> width } + fadeIn()).togetherWith(
|
||||
slideOutHorizontally { width -> -width } + fadeOut())
|
||||
}
|
||||
) { targetExpanded ->
|
||||
if (targetExpanded) {
|
||||
|
|
|
@ -61,7 +61,6 @@ import me.ash.reader.ui.page.common.RouteName
|
|||
import me.ash.reader.ui.page.home.HomeViewModel
|
||||
|
||||
@OptIn(
|
||||
com.google.accompanist.pager.ExperimentalPagerApi::class,
|
||||
androidx.compose.ui.ExperimentalComposeUiApi::class,
|
||||
)
|
||||
@Composable
|
||||
|
|
|
@ -81,7 +81,7 @@ fun TopBar(
|
|||
) {
|
||||
sharedContent.share(context, title, link)
|
||||
}
|
||||
}, colors = TopAppBarDefaults.smallTopAppBarColors(
|
||||
}, colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(tonalElevation.value.dp),
|
||||
)
|
||||
)
|
||||
|
|
|
@ -85,11 +85,11 @@ fun SettingItem(
|
|||
}
|
||||
action?.let {
|
||||
if (separatedActions) {
|
||||
Divider(
|
||||
HorizontalDivider(
|
||||
modifier = Modifier
|
||||
.padding(start = 16.dp)
|
||||
.size(1.dp, 32.dp),
|
||||
color = tonalPalettes neutralVariant 80 onDark (tonalPalettes neutralVariant 30),
|
||||
color = tonalPalettes neutralVariant 80 onDark (tonalPalettes neutralVariant 30)
|
||||
)
|
||||
}
|
||||
Box(Modifier.padding(start = 16.dp)) {
|
||||
|
|
|
@ -88,7 +88,7 @@ fun FeedsPagePreview(
|
|||
contentDescription = stringResource(R.string.subscribe),
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
}, colors = TopAppBarDefaults.smallTopAppBarColors(
|
||||
}, colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
|
||||
topBarTonalElevation.value.dp
|
||||
),
|
||||
|
|
|
@ -26,7 +26,6 @@ import me.ash.reader.domain.model.feed.Feed
|
|||
import me.ash.reader.domain.model.general.Filter
|
||||
import me.ash.reader.infrastructure.preference.FlowArticleListTonalElevationPreference
|
||||
import me.ash.reader.infrastructure.preference.FlowTopBarTonalElevationPreference
|
||||
import me.ash.reader.infrastructure.preference.LocalDarkTheme
|
||||
import me.ash.reader.ui.component.FilterBar
|
||||
import me.ash.reader.ui.component.base.FeedbackIconButton
|
||||
import me.ash.reader.ui.ext.surfaceColorAtElevation
|
||||
|
@ -76,7 +75,7 @@ fun FlowPagePreview(
|
|||
contentDescription = stringResource(R.string.search),
|
||||
tint = MaterialTheme.colorScheme.onSurface,
|
||||
) {}
|
||||
}, colors = TopAppBarDefaults.smallTopAppBarColors(
|
||||
}, colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
|
||||
topBarTonalElevation.value.dp
|
||||
),
|
||||
|
|
|
@ -73,8 +73,6 @@ compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4
|
|||
compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
|
||||
# Accompanist
|
||||
accompanist-pager = { group = "com.google.accompanist", name = "accompanist-pager", version.ref = "accompanist" }
|
||||
accompanist-flowlayout = { group = "com.google.accompanist", name = "accompanist-flowlayout", version.ref = "accompanist" }
|
||||
accompanist-swiperefresh = { group = "com.google.accompanist", name = "accompanist-swiperefresh", version.ref = "accompanist" }
|
||||
|
||||
# Coil
|
||||
|
@ -133,4 +131,4 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
|||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||
aboutlibraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "aboutLibsRelease" }
|
||||
room = { id = "androidx.room", version.ref = "room" }
|
||||
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hiltAndroid" }
|
||||
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hiltAndroid" }
|
Loading…
Reference in New Issue