From f46e71de1aac58dee587063ed3277ce9f3692ec7 Mon Sep 17 00:00:00 2001 From: Wing <44992537+wingio@users.noreply.github.com> Date: Wed, 28 Aug 2024 14:27:57 -0400 Subject: [PATCH] Address most warnings --- .../gloom/service/InstallService.kt | 9 ++++++-- .../gloom/ui/components/BackButton.kt | 4 ++-- .../gloom/ui/components/DividerWithLabel.kt | 4 ++-- .../gloom/ui/components/ThinDivider.kt | 6 +++--- .../bottomsheet/BottomSheetScope.kt | 2 -- .../screens/home/component/NewReleaseItem.kt | 7 ++----- .../ui/screens/list/base/BaseListScreen.kt | 6 ++---- .../screens/release/component/ReleaseAsset.kt | 6 +++--- .../screens/repo/component/IssueOrPRItem.kt | 8 +++---- .../gloom/ui/screens/repo/tab/DetailsTab.kt | 21 +++++-------------- .../gloom/ui/screens/repo/tab/IssuesTab.kt | 7 ++----- .../ui/screens/repo/tab/PullRequestTab.kt | 6 ++---- .../gloom/ui/utils/NavigationUtils.kt | 2 +- 13 files changed, 35 insertions(+), 53 deletions(-) diff --git a/ui/src/androidMain/kotlin/com/materiiapps/gloom/service/InstallService.kt b/ui/src/androidMain/kotlin/com/materiiapps/gloom/service/InstallService.kt index 60b17406..d6c8bef0 100644 --- a/ui/src/androidMain/kotlin/com/materiiapps/gloom/service/InstallService.kt +++ b/ui/src/androidMain/kotlin/com/materiiapps/gloom/service/InstallService.kt @@ -3,6 +3,7 @@ package com.materiiapps.gloom.service import android.app.Service import android.content.Intent import android.content.pm.PackageInstaller +import android.os.Build import android.os.IBinder import com.materiiapps.gloom.Res import com.materiiapps.gloom.domain.manager.ToastManager @@ -26,8 +27,12 @@ class InstallService : Service(), KoinComponent { override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { when (val statusCode = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999)) { PackageInstaller.STATUS_PENDING_USER_ACTION -> { - val confirmationIntent = intent.getParcelableExtra(Intent.EXTRA_INTENT)!! - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + + @Suppress("DEPRECATION") + val confirmationIntent = when { + Build.VERSION.SDK_INT < 34 -> intent.getParcelableExtra(Intent.EXTRA_INTENT)!! + else -> intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java)!! + }.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) startActivity(confirmationIntent) } diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/BackButton.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/BackButton.kt index b902ae89..f5ecc760 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/BackButton.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/BackButton.kt @@ -1,7 +1,7 @@ package com.materiiapps.gloom.ui.components import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.runtime.Composable @@ -15,7 +15,7 @@ fun BackButton() { if (nav?.canPop == true) { IconButton(onClick = { nav.pop() }) { - Icon(Icons.Filled.ArrowBack, stringResource(Res.strings.action_back)) + Icon(Icons.AutoMirrored.Filled.ArrowBack, stringResource(Res.strings.action_back)) } } } \ No newline at end of file diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/DividerWithLabel.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/DividerWithLabel.kt index 72d8861a..0a6d0fb2 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/DividerWithLabel.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/DividerWithLabel.kt @@ -4,8 +4,8 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Divider import androidx.compose.material3.DividerDefaults +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ProvideTextStyle import androidx.compose.runtime.Composable @@ -28,7 +28,7 @@ fun DividerWithLabel( contentAlignment = Alignment.Center, modifier = modifier ) { - Divider( + HorizontalDivider( thickness = thickness, color = color ) diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/ThinDivider.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/ThinDivider.kt index a4f8fa62..a2f6824e 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/ThinDivider.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/ThinDivider.kt @@ -1,12 +1,12 @@ package com.materiiapps.gloom.ui.components -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.unit.dp @Composable -fun ThinDivider() = Divider( - color = MaterialTheme.colorScheme.onSurface.copy(0.1f), +fun ThinDivider() = HorizontalDivider( thickness = 0.5.dp, + color = MaterialTheme.colorScheme.onSurface.copy(0.1f) ) \ No newline at end of file diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/bottomsheet/BottomSheetScope.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/bottomsheet/BottomSheetScope.kt index 3b4e130a..4ea9a368 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/bottomsheet/BottomSheetScope.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/components/bottomsheet/BottomSheetScope.kt @@ -1,5 +1,3 @@ -@file:Suppress("INVISIBLE_REFERENCE") - package com.materiiapps.gloom.ui.components.bottomsheet import androidx.compose.foundation.layout.ColumnScope diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/home/component/NewReleaseItem.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/home/component/NewReleaseItem.kt index 8adc8500..d5f73a10 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/home/component/NewReleaseItem.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/home/component/NewReleaseItem.kt @@ -19,7 +19,6 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ChevronRight import androidx.compose.material.icons.filled.LocalOffer import androidx.compose.material.icons.outlined.LocalOffer -import androidx.compose.material3.Divider import androidx.compose.material3.ElevatedCard import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -52,6 +51,7 @@ import com.materiiapps.gloom.Res import com.materiiapps.gloom.api.dto.user.User import com.materiiapps.gloom.gql.fragment.NewReleaseItemFragment import com.materiiapps.gloom.ui.components.Avatar +import com.materiiapps.gloom.ui.components.ThinDivider import com.materiiapps.gloom.ui.icons.Commit import com.materiiapps.gloom.ui.icons.Custom import com.materiiapps.gloom.ui.screens.release.ReleaseScreen @@ -219,10 +219,7 @@ fun ReleaseCard( } } - Divider( - color = MaterialTheme.colorScheme.onSurface.copy(0.1f), - thickness = 0.5.dp, - ) + ThinDivider() Row( horizontalArrangement = Arrangement.spacedBy(10.dp), diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/list/base/BaseListScreen.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/list/base/BaseListScreen.kt index bcd2c77d..132390cb 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/list/base/BaseListScreen.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/list/base/BaseListScreen.kt @@ -24,6 +24,7 @@ import androidx.paging.compose.itemKey import cafe.adriel.voyager.core.screen.Screen import com.apollographql.apollo.api.Query import com.materiiapps.gloom.ui.components.RefreshIndicator +import com.materiiapps.gloom.ui.components.ThinDivider import com.materiiapps.gloom.ui.components.toolbar.LargeToolbar import com.materiiapps.gloom.ui.screens.list.viewmodel.BaseListViewModel import dev.icerock.moko.resources.StringResource @@ -74,10 +75,7 @@ abstract class BaseListScreen Icons.Outlined.FolderZip - else -> Icons.Outlined.InsertDriveFile + else -> Icons.AutoMirrored.Outlined.InsertDriveFile } Row( diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/component/IssueOrPRItem.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/component/IssueOrPRItem.kt index 3bfd2a9b..dc8e20a7 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/component/IssueOrPRItem.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/component/IssueOrPRItem.kt @@ -25,6 +25,7 @@ import androidx.compose.material3.Icon import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text +import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -132,11 +133,10 @@ fun IssueOrPRItem( .height(23.dp) .padding(horizontal = 3.dp) ) { - Divider( + VerticalDivider( color = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f), - modifier = Modifier - .height(18.dp) - .width(1.dp) + thickness = 1.dp, + modifier = Modifier.height(18.dp) ) } } diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/DetailsTab.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/DetailsTab.kt index 46bc25f1..1b8a3448 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/DetailsTab.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/DetailsTab.kt @@ -42,6 +42,7 @@ import com.materiiapps.gloom.Res import com.materiiapps.gloom.ui.components.LargeSegmentedButton import com.materiiapps.gloom.ui.components.LargeSegmentedButtonRow import com.materiiapps.gloom.ui.components.RefreshIndicator +import com.materiiapps.gloom.ui.components.ThinDivider import com.materiiapps.gloom.ui.icons.Balance import com.materiiapps.gloom.ui.icons.Custom import com.materiiapps.gloom.ui.icons.Fork @@ -145,10 +146,7 @@ class DetailsTab( } } - Divider( - color = MaterialTheme.colorScheme.onSurface.copy(0.1f), - thickness = 0.5.dp, - ) + ThinDivider() } Box( @@ -188,10 +186,7 @@ class DetailsTab( } } - Divider( - color = MaterialTheme.colorScheme.onSurface.copy(0.1f), - thickness = 0.5.dp, - ) + ThinDivider() if (!(details.readme?.contentHTML).isNullOrBlank()) { Text( @@ -214,19 +209,13 @@ class DetailsTab( } repoDetails.contributors.let { - if (it.nodes?.isNotEmpty() == true) Divider( - color = MaterialTheme.colorScheme.onSurface.copy(0.1f), - thickness = 0.5.dp, - ) + if (it.nodes?.isNotEmpty() == true) ThinDivider() ContributorsRow(contributors = it) } repoDetails.languages?.languages?.let { - if (it.edges?.isNotEmpty() == true) Divider( - color = MaterialTheme.colorScheme.onSurface.copy(0.1f), - thickness = 0.5.dp, - ) + if (it.edges?.isNotEmpty() == true) ThinDivider() LanguageMakeup(it) } } diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/IssuesTab.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/IssuesTab.kt index f9a594e7..1dd42ee3 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/IssuesTab.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/IssuesTab.kt @@ -7,7 +7,6 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState -import androidx.compose.material3.Divider import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -23,6 +22,7 @@ import cafe.adriel.voyager.navigator.tab.TabOptions import com.benasher44.uuid.uuid4 import com.materiiapps.gloom.Res import com.materiiapps.gloom.ui.components.RefreshIndicator +import com.materiiapps.gloom.ui.components.ThinDivider import com.materiiapps.gloom.ui.screens.repo.viewmodel.RepoIssuesViewModel import com.materiiapps.gloom.ui.screens.repo.component.IssueItem import dev.icerock.moko.resources.compose.stringResource @@ -66,10 +66,7 @@ class IssuesTab( items[index]?.let { issue -> Column { IssueItem(issue) - Divider( - color = MaterialTheme.colorScheme.onSurface.copy(0.1f), - thickness = 0.5.dp, - ) + ThinDivider() } } } diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/PullRequestTab.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/PullRequestTab.kt index 1b06f723..c770c833 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/PullRequestTab.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/screens/repo/tab/PullRequestTab.kt @@ -23,6 +23,7 @@ import cafe.adriel.voyager.navigator.tab.TabOptions import com.benasher44.uuid.uuid4 import com.materiiapps.gloom.Res import com.materiiapps.gloom.ui.components.RefreshIndicator +import com.materiiapps.gloom.ui.components.ThinDivider import com.materiiapps.gloom.ui.screens.repo.viewmodel.RepoPullRequestsViewModel import com.materiiapps.gloom.ui.screens.repo.component.PullRequestItem import dev.icerock.moko.resources.compose.stringResource @@ -66,10 +67,7 @@ class PullRequestTab( items[index]?.let { pullRequest -> Column { PullRequestItem(pullRequest) - Divider( - color = MaterialTheme.colorScheme.onSurface.copy(0.1f), - thickness = 0.5.dp, - ) + ThinDivider() } } } diff --git a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/utils/NavigationUtils.kt b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/utils/NavigationUtils.kt index 1ba5df44..b99eb718 100644 --- a/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/utils/NavigationUtils.kt +++ b/ui/src/commonMain/kotlin/com/materiiapps/gloom/ui/utils/NavigationUtils.kt @@ -19,7 +19,7 @@ enum class RootTab(val tab: Tab) { PROFILE(ProfileTab()) } -tailrec fun Navigator.navigate(screen: Screen) { +fun Navigator.navigate(screen: Screen) { return if (parent == null && items.firstOrNull { it.key == screen.key } == null) try { push(screen) } catch (_: Throwable) {