From e917349bb7e1fb37b5cf58a130a33d13e1872093 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 5 Mar 2023 15:37:41 -0500 Subject: [PATCH] Use Compose icons instead of drawables Using: - https://github.com/DevSrSouza/compose-icons - https://github.com/DevSrSouza/compose-icons/blob/master/simple-icons/DOCUMENTATION.md --- app/build.gradle.kts | 13 ++++++------ .../more/settings/screen/AboutScreen.kt | 20 +++++++++++-------- .../more/stats/components/StatsItem.kt | 3 +-- app/src/main/res/drawable/ic_discord_24dp.xml | 9 --------- .../main/res/drawable/ic_facebook_24dp.xml | 9 --------- app/src/main/res/drawable/ic_github_24dp.xml | 9 --------- app/src/main/res/drawable/ic_reddit_24dp.xml | 9 --------- app/src/main/res/drawable/ic_twitter_24dp.xml | 9 --------- gradle/libs.versions.toml | 5 +++-- .../presentation/core/components/LinkIcon.kt | 18 ++++------------- 10 files changed, 26 insertions(+), 78 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_discord_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_facebook_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_github_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_reddit_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_twitter_24dp.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 22fce094cb..fde464935a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -191,16 +191,14 @@ dependencies { // Job scheduling implementation(androidx.bundles.workmanager) - // RX + // RxJava implementation(libs.bundles.reactivex) implementation(libs.flowreactivenetwork) - // Network client + // Networking implementation(libs.bundles.okhttp) implementation(libs.okio) - - // TLS 1.3 support for Android < 10 - implementation(libs.conscrypt.android) + implementation(libs.conscrypt.android) // TLS 1.3 support for Android < 10 // Data serialization (JSON, protobuf, xml) implementation(kotlinx.bundles.serialization) @@ -237,9 +235,10 @@ dependencies { implementation(libs.insetter) implementation(libs.bundles.richtext) implementation(libs.aboutLibraries.compose) - implementation(libs.cascade) implementation(libs.bundles.voyager) - implementation(libs.materialmotion.core) + implementation(libs.compose.cascade) + implementation(libs.compose.materialmotion) + implementation(libs.compose.simpleicons) // Logging implementation(libs.logcat) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/AboutScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/AboutScreen.kt index edc61a180d..c5381e1f93 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/AboutScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/AboutScreen.kt @@ -10,14 +10,18 @@ import androidx.compose.material.icons.outlined.Public import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalUriHandler -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import compose.icons.SimpleIcons +import compose.icons.simpleicons.Discord +import compose.icons.simpleicons.Facebook +import compose.icons.simpleicons.Github +import compose.icons.simpleicons.Reddit +import compose.icons.simpleicons.Twitter import eu.kanade.domain.ui.UiPreferences import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.more.LogoHeader @@ -145,32 +149,32 @@ object AboutScreen : Screen() { ) { LinkIcon( label = stringResource(R.string.website), - painter = rememberVectorPainter(Icons.Outlined.Public), + icon = Icons.Outlined.Public, url = "https://tachiyomi.org", ) LinkIcon( label = "Discord", - painter = painterResource(R.drawable.ic_discord_24dp), + icon = SimpleIcons.Discord, url = "https://discord.gg/tachiyomi", ) LinkIcon( label = "Twitter", - painter = painterResource(R.drawable.ic_twitter_24dp), + icon = SimpleIcons.Twitter, url = "https://twitter.com/tachiyomiorg", ) LinkIcon( label = "Facebook", - painter = painterResource(R.drawable.ic_facebook_24dp), + icon = SimpleIcons.Facebook, url = "https://facebook.com/tachiyomiorg", ) LinkIcon( label = "Reddit", - painter = painterResource(R.drawable.ic_reddit_24dp), + icon = SimpleIcons.Reddit, url = "https://www.reddit.com/r/Tachiyomi", ) LinkIcon( label = "GitHub", - painter = painterResource(R.drawable.ic_github_24dp), + icon = SimpleIcons.Github, url = "https://github.com/tachiyomiorg", ) } diff --git a/app/src/main/java/eu/kanade/presentation/more/stats/components/StatsItem.kt b/app/src/main/java/eu/kanade/presentation/more/stats/components/StatsItem.kt index 65e01b1991..32f4fcd28b 100644 --- a/app/src/main/java/eu/kanade/presentation/more/stats/components/StatsItem.kt +++ b/app/src/main/java/eu/kanade/presentation/more/stats/components/StatsItem.kt @@ -10,7 +10,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign @@ -76,7 +75,7 @@ private fun RowScope.BaseStatsItem( ) if (icon != null) { Icon( - painter = rememberVectorPainter(icon), + imageVector = icon, contentDescription = null, tint = MaterialTheme.colorScheme.primary, ) diff --git a/app/src/main/res/drawable/ic_discord_24dp.xml b/app/src/main/res/drawable/ic_discord_24dp.xml deleted file mode 100644 index 4524f21c1b..0000000000 --- a/app/src/main/res/drawable/ic_discord_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_facebook_24dp.xml b/app/src/main/res/drawable/ic_facebook_24dp.xml deleted file mode 100644 index 62ceb98fb6..0000000000 --- a/app/src/main/res/drawable/ic_facebook_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_github_24dp.xml b/app/src/main/res/drawable/ic_github_24dp.xml deleted file mode 100644 index 711b50d380..0000000000 --- a/app/src/main/res/drawable/ic_github_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_reddit_24dp.xml b/app/src/main/res/drawable/ic_reddit_24dp.xml deleted file mode 100644 index de352a164c..0000000000 --- a/app/src/main/res/drawable/ic_reddit_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_twitter_24dp.xml b/app/src/main/res/drawable/ic_twitter_24dp.xml deleted file mode 100644 index 970b94c02d..0000000000 --- a/app/src/main/res/drawable/ic_twitter_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9aaed0cdb1..90f2b38c74 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -60,8 +60,9 @@ flexible-adapter-ui = "com.github.arkon.FlexibleAdapter:flexible-adapter-ui:c801 photoview = "com.github.chrisbanes:PhotoView:2.3.0" directionalviewpager = "com.github.tachiyomiorg:DirectionalViewPager:1.0.0" insetter = "dev.chrisbanes.insetter:insetter:0.6.1" -cascade = "me.saket.cascade:cascade-compose:2.0.0-rc02" -materialmotion-core = "io.github.fornewid:material-motion-compose-core:0.10.4" +compose-cascade = "me.saket.cascade:cascade-compose:2.0.0-rc02" +compose-materialmotion = "io.github.fornewid:material-motion-compose-core:0.10.4" +compose-simpleicons = "br.com.devsrsouza.compose.icons.android:simple-icons:1.0.0" logcat = "com.squareup.logcat:logcat:0.1" diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/components/LinkIcon.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/components/LinkIcon.kt index 9208c587a2..17dc818cae 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/components/LinkIcon.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/components/LinkIcon.kt @@ -6,7 +6,7 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.painter.Painter +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.unit.dp @@ -14,26 +14,16 @@ import androidx.compose.ui.unit.dp fun LinkIcon( modifier: Modifier = Modifier, label: String, - painter: Painter, + icon: ImageVector, url: String, ) { val uriHandler = LocalUriHandler.current - LinkIcon(modifier, label, painter) { uriHandler.openUri(url) } -} - -@Composable -fun LinkIcon( - modifier: Modifier = Modifier, - label: String, - painter: Painter, - onClick: () -> Unit, -) { IconButton( modifier = modifier.padding(4.dp), - onClick = onClick, + onClick = { uriHandler.openUri(url) }, ) { Icon( - painter = painter, + imageVector = icon, tint = MaterialTheme.colorScheme.primary, contentDescription = label, )