diff --git a/androidApp/src/main/java/com/m3u/androidApp/navigation/M3UNavHost.kt b/androidApp/src/main/java/com/m3u/androidApp/navigation/M3UNavHost.kt index 5c076780e..037a8c578 100644 --- a/androidApp/src/main/java/com/m3u/androidApp/navigation/M3UNavHost.kt +++ b/androidApp/src/main/java/com/m3u/androidApp/navigation/M3UNavHost.kt @@ -42,7 +42,7 @@ fun M3UNavHost( onCurrentPage = onCurrentPage, navigateToFeed = { feed -> helper.title = feed.title.ifEmpty { - if (feed.specially) context.getString(R.string.imported_feed_title) + if (feed.local) context.getString(R.string.imported_feed_title) else "" } navigate(Destination.Feed(feed.url)) diff --git a/benchmark/build.gradle.kts b/benchmark/build.gradle.kts index 8bf03b368..41b028704 100644 --- a/benchmark/build.gradle.kts +++ b/benchmark/build.gradle.kts @@ -1,4 +1,3 @@ -@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed plugins { alias(libs.plugins.com.android.test) alias(libs.plugins.org.jetbrains.kotlin.android) diff --git a/data/src/main/java/com/m3u/data/database/entity/Feed.kt b/data/src/main/java/com/m3u/data/database/entity/Feed.kt index bebec3f39..5fe296fa1 100644 --- a/data/src/main/java/com/m3u/data/database/entity/Feed.kt +++ b/data/src/main/java/com/m3u/data/database/entity/Feed.kt @@ -14,7 +14,7 @@ data class Feed( @ColumnInfo(name = "url") val url: String ) { - val specially: Boolean + val local: Boolean get() = url == URL_IMPORTED || url.startsWithAny("file://", "content://") diff --git a/features/main/src/main/java/com/m3u/features/main/MainScreen.kt b/features/main/src/main/java/com/m3u/features/main/MainScreen.kt index f41b699c7..429f2a1c4 100644 --- a/features/main/src/main/java/com/m3u/features/main/MainScreen.kt +++ b/features/main/src/main/java/com/m3u/features/main/MainScreen.kt @@ -157,7 +157,7 @@ fun PortraitOrientationContent( FeedItem( label = detail.feed.calculateUiTitle(), number = detail.count, - special = detail.feed.specially, + local = detail.feed.local, modifier = Modifier.fillParentMaxWidth(), onClick = { navigateToFeed(detail.feed) @@ -197,7 +197,7 @@ private fun LandscapeOrientationContent( FeedItem( label = detail.feed.calculateUiTitle(), number = detail.count, - special = detail.feed.specially, + local = detail.feed.local, modifier = Modifier.fillMaxWidth(), onClick = { navigateToFeed(detail.feed) @@ -213,7 +213,7 @@ private fun LandscapeOrientationContent( @Composable private fun Feed.calculateUiTitle(): AnnotatedString { val actual = title.ifEmpty { - if (specially) stringResource(R.string.imported_feed_title) + if (local) stringResource(R.string.imported_feed_title) else "" } return AnnotatedString( diff --git a/features/main/src/main/java/com/m3u/features/main/components/FeedItem.kt b/features/main/src/main/java/com/m3u/features/main/components/FeedItem.kt index c1ea4d024..256e3d66d 100644 --- a/features/main/src/main/java/com/m3u/features/main/components/FeedItem.kt +++ b/features/main/src/main/java/com/m3u/features/main/components/FeedItem.kt @@ -8,9 +8,13 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.ContentAlpha +import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.rounded.DriveFileMove import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment @@ -34,7 +38,7 @@ import com.m3u.ui.model.LocalTheme internal fun FeedItem( label: AnnotatedString, number: Int, - special: Boolean, + local: Boolean, onClick: () -> Unit, onLongClick: () -> Unit, modifier: Modifier = Modifier @@ -43,12 +47,12 @@ internal fun FeedItem( val theme = LocalTheme.current val actualBackgroundColor by theme.surface.animated("FeedItemBackground") val actualContentColor by theme.onSurface.animated("FeedItemContent") - val actualBorder by animateDp("FeedItemBorder") { - if (special) spacing.extraSmall + val actualBorderDp by animateDp("FeedItemBorder") { + if (local) spacing.extraSmall else spacing.none } val actualBorderColor by animateColor("FeedItemBorderColor") { - if (special) Color.Black.copy(alpha = 0.12f) + if (local) Color.Black.copy(alpha = 0.12f) else Color.Transparent } Surface( @@ -56,7 +60,7 @@ internal fun FeedItem( color = actualBackgroundColor, contentColor = actualContentColor, elevation = spacing.none, - border = BorderStroke(actualBorder, actualBorderColor) + border = BorderStroke(actualBorderDp, actualBorderColor) ) { OuterRow( modifier = modifier @@ -66,6 +70,13 @@ internal fun FeedItem( ), verticalAlignment = Alignment.CenterVertically ) { + if (local) { + Icon( + imageVector = Icons.AutoMirrored.Rounded.DriveFileMove, + contentDescription = null, + tint = actualContentColor.copy(alpha = ContentAlpha.medium) + ) + } Text( text = label, style = MaterialTheme.typography.body1, diff --git a/features/main/src/main/java/com/m3u/features/main/components/MainDialog.kt b/features/main/src/main/java/com/m3u/features/main/components/MainDialog.kt index 2d0b174b2..d6bd996b3 100644 --- a/features/main/src/main/java/com/m3u/features/main/components/MainDialog.kt +++ b/features/main/src/main/java/com/m3u/features/main/components/MainDialog.kt @@ -62,17 +62,21 @@ internal fun MainDialog( val context = LocalContext.current val currentStatus = remember { status as MainDialog.Selections } if (status is MainDialog.Selections) { - var renamedText by remember { + val editable = with(currentStatus.feed) { + !local || title.isNotEmpty() + } + var renamedText by remember(currentStatus) { mutableStateOf( - if (!currentStatus.feed.specially) currentStatus.feed.title - else context.getString(R.string.imported_feed_title) + with(currentStatus.feed) { + if (editable) title else context.getString(R.string.imported_feed_title) + } ) } DialogTextField( text = renamedText, onTextChange = { renamedText = it }, readOnly = !editMode, - icon = Icons.Rounded.Edit.takeUnless { currentStatus.feed.specially }, + icon = Icons.Rounded.Edit.takeIf { editable }, iconTint = if (editMode) theme.tint else theme.onBackground, onIconClick = { val target = !editMode @@ -87,7 +91,7 @@ internal fun MainDialog( unsubscribe(currentStatus.feed.url) update(MainDialog.Idle) } - if (!currentStatus.feed.specially) { + if (!currentStatus.feed.local) { val clipboardManager = LocalClipboardManager.current DialogItem(R.string.copy_feed_url) { val annotatedString = AnnotatedString(currentStatus.feed.url) diff --git a/ui/src/main/java/com/m3u/ui/components/Dialog.kt b/ui/src/main/java/com/m3u/ui/components/Dialog.kt index 9a35277ef..f4f2b4574 100644 --- a/ui/src/main/java/com/m3u/ui/components/Dialog.kt +++ b/ui/src/main/java/com/m3u/ui/components/Dialog.kt @@ -71,7 +71,6 @@ fun DialogTextField( ) } } - } @Composable