removing more warnings
This commit is contained in:
+2
@@ -18,6 +18,8 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* 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.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("DEPRECATION")
|
||||||
|
|
||||||
package com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.watchers
|
package com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.watchers
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,6 +18,8 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* 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.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("DEPRECATION")
|
||||||
|
|
||||||
package com.vitorpamplona.amethyst.ui.note.types
|
package com.vitorpamplona.amethyst.ui.note.types
|
||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
|
|||||||
+2
@@ -18,6 +18,8 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* 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.
|
* 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
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.conversations.dal
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
|
|||||||
+2
@@ -18,6 +18,8 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* 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.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("DEPRECATION")
|
||||||
|
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
|
|||||||
+10
-11
@@ -169,18 +169,17 @@ fun GalleryContentView(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
) {
|
) {
|
||||||
AutoNonlazyGrid(contentList.size, modifier = Modifier.fillMaxSize()) { contentIndex ->
|
AutoNonlazyGrid(contentList.size, modifier = Modifier.fillMaxSize()) { contentIndex ->
|
||||||
when (val content = contentList[contentIndex]) {
|
val content = contentList[contentIndex]
|
||||||
is MediaUrlContent -> {
|
|
||||||
val sensitivityReason =
|
val sensitivityReason =
|
||||||
when (content) {
|
when (content) {
|
||||||
is MediaUrlVideo -> content.contentWarning
|
is MediaUrlVideo -> content.contentWarning
|
||||||
is MediaUrlImage -> content.contentWarning
|
is MediaUrlImage -> content.contentWarning
|
||||||
else -> null
|
else -> null
|
||||||
}
|
|
||||||
SensitivityWarning(sensitivityReason, accountViewModel) {
|
|
||||||
UrlImageView(content, accountViewModel)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SensitivityWarning(sensitivityReason, accountViewModel) {
|
||||||
|
UrlImageView(content, accountViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -543,6 +543,7 @@ fun RelayInformationBody(
|
|||||||
// Active subscriptions + outbox display
|
// Active subscriptions + outbox display
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
fun kindDisplayName(kind: Int): Int =
|
fun kindDisplayName(kind: Int): Int =
|
||||||
when (kind) {
|
when (kind) {
|
||||||
AdvertisedRelayListEvent.KIND -> R.string.kind_outbox_relays
|
AdvertisedRelayListEvent.KIND -> R.string.kind_outbox_relays
|
||||||
|
|||||||
-2
@@ -20,7 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.settings
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.settings
|
||||||
|
|
||||||
import android.R.attr.targetName
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
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.Size20dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.SpacedBy10dp
|
import com.vitorpamplona.amethyst.ui.theme.SpacedBy10dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonRow
|
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonRow
|
||||||
import okio.`-DeprecatedOkio`.source
|
|
||||||
import java.util.Locale as JavaLocale
|
import java.util.Locale as JavaLocale
|
||||||
|
|
||||||
@Preview(device = "spec:width=2160px,height=2340px,dpi=440")
|
@Preview(device = "spec:width=2160px,height=2340px,dpi=440")
|
||||||
|
|||||||
-9
@@ -39,13 +39,4 @@ class DesktopRelayConnectionManagerTest {
|
|||||||
assertTrue(connectedRelays.isEmpty(), "Should have no connected relays on initialization")
|
assertTrue(connectedRelays.isEmpty(), "Should have no connected relays on initialization")
|
||||||
assertTrue(availableRelays.isEmpty(), "Should have no available 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",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -56,7 +56,7 @@ actual class LargeCache<K, V> : ICacheOperations<K, V> {
|
|||||||
|
|
||||||
actual fun getOrCreate(
|
actual fun getOrCreate(
|
||||||
key: K,
|
key: K,
|
||||||
builder: (K) -> V,
|
builder: (key: K) -> V,
|
||||||
): V {
|
): V {
|
||||||
val value = concurrentMap.get(key)
|
val value = concurrentMap.get(key)
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ actual class LargeCache<K, V> : ICacheOperations<K, V> {
|
|||||||
|
|
||||||
actual fun createIfAbsent(
|
actual fun createIfAbsent(
|
||||||
key: K,
|
key: K,
|
||||||
builder: (K) -> V,
|
builder: (key: K) -> V,
|
||||||
): Boolean =
|
): Boolean =
|
||||||
runBlocking {
|
runBlocking {
|
||||||
val value = concurrentMap.get(key)
|
val value = concurrentMap.get(key)
|
||||||
|
|||||||
+2
-2
@@ -65,7 +65,7 @@ actual class LargeCache<K, V> : ICacheOperations<K, V> {
|
|||||||
|
|
||||||
actual fun getOrCreate(
|
actual fun getOrCreate(
|
||||||
key: K,
|
key: K,
|
||||||
builder: (K) -> V,
|
builder: (key: K) -> V,
|
||||||
): V {
|
): V {
|
||||||
val existing = get(key)
|
val existing = get(key)
|
||||||
if (existing != null) return existing
|
if (existing != null) return existing
|
||||||
@@ -76,7 +76,7 @@ actual class LargeCache<K, V> : ICacheOperations<K, V> {
|
|||||||
|
|
||||||
actual fun createIfAbsent(
|
actual fun createIfAbsent(
|
||||||
key: K,
|
key: K,
|
||||||
builder: (K) -> V,
|
builder: (key: K) -> V,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val existing = get(key)
|
val existing = get(key)
|
||||||
if (existing != null) return false
|
if (existing != null) return false
|
||||||
|
|||||||
Reference in New Issue
Block a user