From cfa59dab01691eecdffc6ac97b58cd5bb0b001dd Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sat, 28 Mar 2026 14:24:13 -0400 Subject: [PATCH] removing more warnings --- .../FilterRepliesAndReactionsToNotes.kt | 2 + .../ui/components/util/DeviceUtils.kt | 114 ------------------ .../amethyst/ui/note/types/TorrentComment.kt | 2 + .../dal/UserProfileConversationsFeedFilter.kt | 2 + .../datasource/FilterUserProfilePosts.kt | 2 + .../loggedIn/profile/gallery/GalleryThumb.kt | 21 ++-- .../loggedIn/relays/RelayInformationScreen.kt | 1 + .../loggedIn/settings/UserSettingsScreen.kt | 2 - .../DesktopRelayConnectionManagerTest.kt | 9 -- .../quartz/utils/cache/LargeCache.apple.kt | 4 +- .../quartz/utils/cache/LargeCache.linux.kt | 4 +- 11 files changed, 23 insertions(+), 140 deletions(-) delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/util/DeviceUtils.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/watchers/FilterRepliesAndReactionsToNotes.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/watchers/FilterRepliesAndReactionsToNotes.kt index 55220b18f..57faeb9f0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/watchers/FilterRepliesAndReactionsToNotes.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/watchers/FilterRepliesAndReactionsToNotes.kt @@ -18,6 +18,8 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +@file:Suppress("DEPRECATION") + package com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.watchers import com.vitorpamplona.amethyst.model.Note diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/util/DeviceUtils.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/util/DeviceUtils.kt deleted file mode 100644 index f87fffad3..000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/util/DeviceUtils.kt +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.components.util - -import android.app.Activity -import android.content.Context -import android.content.pm.ActivityInfo -import android.content.pm.PackageManager -import android.provider.Settings -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.window.core.layout.WindowHeightSizeClass -import androidx.window.core.layout.WindowSizeClass -import androidx.window.core.layout.WindowWidthSizeClass -import com.vitorpamplona.amethyst.ui.components.util.DeviceUtils.screenOrientationIsLocked - -object DeviceUtils { - /** - * Tries to determine if the device is - * in landscape mode, by using the [android.util.DisplayMetrics] API. - * - * Credits: NewPipe devs - */ - fun isLandscapeMetric(context: Context): Boolean = context.resources.displayMetrics.heightPixels < context.resources.displayMetrics.widthPixels - - /** - * Checks if the device's orientation is set to locked. - * - * Credits: NewPipe devs - */ - fun screenOrientationIsLocked(context: Context): Boolean { - // 1: Screen orientation changes using accelerometer - // 0: Screen orientation is locked - // if the accelerometer sensor is missing completely, assume locked orientation - return ( - Settings.System.getInt( - context.contentResolver, - Settings.System.ACCELEROMETER_ROTATION, - 0, - ) == 0 || - !context.packageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER) - ) - } - - /** - * Changes the device's orientation. This works even if the device's orientation - * is set to locked. - * Thus, to prevent unwanted behaviour, - * it's use can be guarded by conditions such as [screenOrientationIsLocked]. - */ - fun changeDeviceOrientation( - isInLandscape: Boolean, - currentActivity: Activity, - ) { - val newOrientation = - if (isInLandscape) { - ActivityInfo.SCREEN_ORIENTATION_PORTRAIT - } else { - ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE - } - currentActivity.requestedOrientation = newOrientation - } - - /** - * This method looks at the window in which the app resides, - * and determines if it is large, while making sure not to be affected - * by configuration changes(such as screen rotation), - * as the device display metrics can be affected as well. - * - * It could be used as an approximation of the type of device(as is the case here), - * though one ought to be careful about multi-window situations. - */ - - @Composable - fun windowIsLarge( - isInLandscapeMode: Boolean, - windowSize: WindowSizeClass, - ): Boolean = - remember(windowSize) { - if (isInLandscapeMode) { - when (windowSize.windowHeightSizeClass) { - WindowHeightSizeClass.COMPACT -> false - WindowHeightSizeClass.MEDIUM -> true - WindowHeightSizeClass.EXPANDED -> true - else -> true - } - } else { - when (windowSize.windowWidthSizeClass) { - WindowWidthSizeClass.EXPANDED -> true - WindowWidthSizeClass.MEDIUM -> true - WindowWidthSizeClass.COMPACT -> false - else -> true - } - } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/TorrentComment.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/TorrentComment.kt index 7c5442ff0..a0fd3a87b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/TorrentComment.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/TorrentComment.kt @@ -18,6 +18,8 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +@file:Suppress("DEPRECATION") + package com.vitorpamplona.amethyst.ui.note.types import androidx.compose.foundation.clickable diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/conversations/dal/UserProfileConversationsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/conversations/dal/UserProfileConversationsFeedFilter.kt index 1cb20b8e9..18bfaeae7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/conversations/dal/UserProfileConversationsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/conversations/dal/UserProfileConversationsFeedFilter.kt @@ -18,6 +18,8 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +@file:Suppress("DEPRECATION") + package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.conversations.dal import com.vitorpamplona.amethyst.model.Account diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt index 906ed2d78..967c1422d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt @@ -18,6 +18,8 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +@file:Suppress("DEPRECATION") + package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource import com.vitorpamplona.amethyst.model.LocalCache diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt index b153ef37e..fce93165f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt @@ -169,18 +169,17 @@ fun GalleryContentView( accountViewModel: AccountViewModel, ) { AutoNonlazyGrid(contentList.size, modifier = Modifier.fillMaxSize()) { contentIndex -> - when (val content = contentList[contentIndex]) { - is MediaUrlContent -> { - val sensitivityReason = - when (content) { - is MediaUrlVideo -> content.contentWarning - is MediaUrlImage -> content.contentWarning - else -> null - } - SensitivityWarning(sensitivityReason, accountViewModel) { - UrlImageView(content, accountViewModel) - } + val content = contentList[contentIndex] + + val sensitivityReason = + when (content) { + is MediaUrlVideo -> content.contentWarning + is MediaUrlImage -> content.contentWarning + else -> null } + + SensitivityWarning(sensitivityReason, accountViewModel) { + UrlImageView(content, accountViewModel) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt index dea189e37..9be2e718c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt @@ -543,6 +543,7 @@ fun RelayInformationBody( // Active subscriptions + outbox display // --------------------------------------------------------------------------- +@Suppress("DEPRECATION") fun kindDisplayName(kind: Int): Int = when (kind) { AdvertisedRelayListEvent.KIND -> R.string.kind_outbox_relays diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/UserSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/UserSettingsScreen.kt index 16af23f49..922885d88 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/UserSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/UserSettingsScreen.kt @@ -20,7 +20,6 @@ */ package com.vitorpamplona.amethyst.ui.screen.loggedIn.settings -import android.R.attr.targetName import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -80,7 +79,6 @@ import com.vitorpamplona.amethyst.ui.theme.Size10dp import com.vitorpamplona.amethyst.ui.theme.Size20dp import com.vitorpamplona.amethyst.ui.theme.SpacedBy10dp import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonRow -import okio.`-DeprecatedOkio`.source import java.util.Locale as JavaLocale @Preview(device = "spec:width=2160px,height=2340px,dpi=440") diff --git a/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/network/DesktopRelayConnectionManagerTest.kt b/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/network/DesktopRelayConnectionManagerTest.kt index 773ebd3b4..0f494ac3e 100644 --- a/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/network/DesktopRelayConnectionManagerTest.kt +++ b/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/network/DesktopRelayConnectionManagerTest.kt @@ -39,13 +39,4 @@ class DesktopRelayConnectionManagerTest { assertTrue(connectedRelays.isEmpty(), "Should have no connected relays on initialization") assertTrue(availableRelays.isEmpty(), "Should have no available relays on initialization") } - - @Test - fun testRelayConnectionManagerInheritsFromBaseClass() { - val manager = DesktopRelayConnectionManager() - assertTrue( - manager is RelayConnectionManager, - "DesktopRelayConnectionManager should extend RelayConnectionManager", - ) - } } diff --git a/quartz/src/appleMain/kotlin/com/vitorpamplona/quartz/utils/cache/LargeCache.apple.kt b/quartz/src/appleMain/kotlin/com/vitorpamplona/quartz/utils/cache/LargeCache.apple.kt index bcec6b77b..1b07dd530 100644 --- a/quartz/src/appleMain/kotlin/com/vitorpamplona/quartz/utils/cache/LargeCache.apple.kt +++ b/quartz/src/appleMain/kotlin/com/vitorpamplona/quartz/utils/cache/LargeCache.apple.kt @@ -56,7 +56,7 @@ actual class LargeCache : ICacheOperations { actual fun getOrCreate( key: K, - builder: (K) -> V, + builder: (key: K) -> V, ): V { val value = concurrentMap.get(key) @@ -71,7 +71,7 @@ actual class LargeCache : ICacheOperations { actual fun createIfAbsent( key: K, - builder: (K) -> V, + builder: (key: K) -> V, ): Boolean = runBlocking { val value = concurrentMap.get(key) diff --git a/quartz/src/linuxMain/kotlin/com/vitorpamplona/quartz/utils/cache/LargeCache.linux.kt b/quartz/src/linuxMain/kotlin/com/vitorpamplona/quartz/utils/cache/LargeCache.linux.kt index 272602309..74861078f 100644 --- a/quartz/src/linuxMain/kotlin/com/vitorpamplona/quartz/utils/cache/LargeCache.linux.kt +++ b/quartz/src/linuxMain/kotlin/com/vitorpamplona/quartz/utils/cache/LargeCache.linux.kt @@ -65,7 +65,7 @@ actual class LargeCache : ICacheOperations { actual fun getOrCreate( key: K, - builder: (K) -> V, + builder: (key: K) -> V, ): V { val existing = get(key) if (existing != null) return existing @@ -76,7 +76,7 @@ actual class LargeCache : ICacheOperations { actual fun createIfAbsent( key: K, - builder: (K) -> V, + builder: (key: K) -> V, ): Boolean { val existing = get(key) if (existing != null) return false