mirror of
https://github.com/bitwarden/android.git
synced 2026-10-22 02:53:19 -05:00
Chore: Addresses minor lint warnings (#7397)
This commit is contained in:
1 parent
a2586225f0
commit
be789c8adc
16 files changed
+51
-35
No files matched your search
+11
-8
@@ -5,9 +5,9 @@ import android.content.ClipDescription
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.PersistableBundle
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.os.persistableBundleOf
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.OneTimeWorkRequest
|
||||
import androidx.work.WorkManager
|
||||
@@ -43,13 +43,16 @@ class BitwardenClipboardManagerImpl(
|
||||
ClipData
|
||||
.newPlainText("", text)
|
||||
.apply {
|
||||
description.extras = persistableBundleOf(
|
||||
if (isBuildVersionAtLeast(version = Build.VERSION_CODES.TIRAMISU)) {
|
||||
ClipDescription.EXTRA_IS_SENSITIVE to isSensitive
|
||||
} else {
|
||||
"android.content.extra.IS_SENSITIVE" to isSensitive
|
||||
},
|
||||
)
|
||||
description.extras = PersistableBundle().apply {
|
||||
this.putBoolean(
|
||||
if (isBuildVersionAtLeast(version = Build.VERSION_CODES.TIRAMISU)) {
|
||||
ClipDescription.EXTRA_IS_SENSITIVE
|
||||
} else {
|
||||
"android.content.extra.IS_SENSITIVE"
|
||||
},
|
||||
isSensitive,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
if (!isBuildVersionAtLeast(version = Build.VERSION_CODES.TIRAMISU)) {
|
||||
|
||||
+3
-2
@@ -5,6 +5,7 @@ import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.TimeoutCancellationException
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
/**
|
||||
* Launch a new coroutine that runs [block] and will safely timeout and invoke [timeoutBlock] after
|
||||
@@ -17,8 +18,8 @@ fun CoroutineScope.launchWithTimeout(
|
||||
): Job =
|
||||
launch {
|
||||
try {
|
||||
withTimeout(timeoutDuration, block)
|
||||
} catch (e: TimeoutCancellationException) {
|
||||
withTimeout(timeoutDuration.milliseconds, block)
|
||||
} catch (_: TimeoutCancellationException) {
|
||||
timeoutBlock()
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import kotlinx.coroutines.flow.onCompletion
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.isActive
|
||||
import java.time.Clock
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
private const val ONE_SECOND_MILLISECOND = 1000L
|
||||
|
||||
@@ -130,7 +131,7 @@ class TotpCodeManagerImpl(
|
||||
item?.let {
|
||||
emit(DataState.Loaded(it))
|
||||
}
|
||||
delay(ONE_SECOND_MILLISECOND)
|
||||
delay(ONE_SECOND_MILLISECOND.milliseconds)
|
||||
}
|
||||
}
|
||||
.onCompletion {
|
||||
|
||||
+2
-1
@@ -66,6 +66,7 @@ import com.x8bit.bitwarden.ui.platform.manager.biometrics.BiometricsManager
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.delay
|
||||
import javax.crypto.Cipher
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
/**
|
||||
* Time slice to delay auto-focusing on the password/pin field. Because of the refresh that
|
||||
@@ -254,7 +255,7 @@ fun VaultUnlockScreen(
|
||||
mutableStateOf(false)
|
||||
}
|
||||
LaunchedEffect(Unit) {
|
||||
delay(AUTO_FOCUS_DELAY)
|
||||
delay(AUTO_FOCUS_DELAY.milliseconds)
|
||||
autoFocusDelayCompleted = true
|
||||
}
|
||||
BitwardenPasswordField(
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.SnackbarDuration
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.TopAppBarScrollBehavior
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfoV2
|
||||
import androidx.compose.material3.rememberTopAppBarState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
@@ -368,7 +368,7 @@ private fun CoachMarkScope<ExploreGeneratorCoachMark>.ScrollContent(
|
||||
onUpgradedToPremiumCardDismiss: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val windowAdaptiveInfo = currentWindowAdaptiveInfo()
|
||||
val windowAdaptiveInfo = currentWindowAdaptiveInfoV2()
|
||||
LazyColumn(
|
||||
state = lazyListState,
|
||||
modifier = modifier
|
||||
|
||||
@@ -45,6 +45,7 @@ import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
private const val KEY_STATE = "state"
|
||||
|
||||
@@ -493,11 +494,10 @@ class SendViewModel @Inject constructor(
|
||||
mutableStateFlow.update { it.copy(dialogState = null) }
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
private fun handleRefreshPull() {
|
||||
mutableStateFlow.update { it.copy(isRefreshing = true) }
|
||||
viewModelScope.launch {
|
||||
delay(250)
|
||||
delay(250.milliseconds)
|
||||
if (networkConnectionManager.isNetworkConnected) {
|
||||
vaultRepo.sync(forced = false)
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfoV2
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
@@ -95,7 +95,7 @@ fun CoachMarkScope<AddEditItemCoachMark>.VaultAddEditContent(
|
||||
|
||||
val focusManager = LocalFocusManager.current
|
||||
val isAdditionalOptionsExpanded = rememberSaveable { mutableStateOf(value = false) }
|
||||
val windowAdaptiveInfo = currentWindowAdaptiveInfo()
|
||||
val windowAdaptiveInfo = currentWindowAdaptiveInfoV2()
|
||||
LazyColumn(modifier = modifier, state = lazyListState) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(height = 12.dp))
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@ import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
private const val KEY_STATE = "state"
|
||||
|
||||
@@ -87,7 +88,7 @@ class CardScanViewModel @Inject constructor(
|
||||
private fun startHintTimeout() {
|
||||
hintTimeoutJob?.cancel()
|
||||
hintTimeoutJob = viewModelScope.launch {
|
||||
delay(SCAN_HINT_TIMEOUT_MS)
|
||||
delay(SCAN_HINT_TIMEOUT_MS.milliseconds)
|
||||
sendAction(CardScanAction.Internal.HintTimeoutElapsed)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -126,6 +126,7 @@ import kotlinx.parcelize.Parcelize
|
||||
import timber.log.Timber
|
||||
import java.time.Clock
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
/**
|
||||
* Manages [VaultItemListingState], handles [VaultItemListingsAction],
|
||||
@@ -400,11 +401,10 @@ class VaultItemListingViewModel @Inject constructor(
|
||||
vaultRepository.sync(forced = true)
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
private fun handleRefreshPull() {
|
||||
mutableStateFlow.update { it.copy(isRefreshing = true) }
|
||||
viewModelScope.launch {
|
||||
delay(250)
|
||||
delay(250.milliseconds)
|
||||
if (networkConnectionManager.isNetworkConnected) {
|
||||
vaultRepository.sync(forced = false)
|
||||
} else {
|
||||
|
||||
+1
-3
@@ -41,9 +41,7 @@ fun Triple<CipherView?, List<CollectionView>, UserState?>.toViewState():
|
||||
organizations = userOrganizations.map { organization ->
|
||||
VaultMoveToOrganizationState.ViewState.Content.Organization(
|
||||
id = organization.id,
|
||||
name = organization
|
||||
.name
|
||||
.orEmpty(),
|
||||
name = organization.name,
|
||||
collections = collections
|
||||
.filter { collection ->
|
||||
collection.organizationId == organization.id &&
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ fun UserState.Account.toVaultFilterData(
|
||||
.map { organization ->
|
||||
VaultFilterType.OrganizationVault(
|
||||
organizationId = organization.id,
|
||||
organizationName = organization.name.orEmpty(),
|
||||
organizationName = organization.name,
|
||||
)
|
||||
}
|
||||
.toTypedArray(),
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.isActive
|
||||
import java.time.Clock
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
private const val ONE_SECOND_MILLISECOND = 1000L
|
||||
|
||||
@@ -141,7 +142,7 @@ class TotpCodeManagerImpl @Inject constructor(
|
||||
}
|
||||
|
||||
emit(verificationCodeItem)
|
||||
delay(ONE_SECOND_MILLISECOND)
|
||||
delay(ONE_SECOND_MILLISECOND.milliseconds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-4
@@ -1,13 +1,15 @@
|
||||
package com.bitwarden.authenticator.data.platform.manager.clipboard
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipDescription
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.PersistableBundle
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.os.persistableBundleOf
|
||||
import com.bitwarden.core.data.manager.toast.ToastManager
|
||||
import com.bitwarden.core.util.isBuildVersionAtLeast
|
||||
import com.bitwarden.ui.platform.base.util.toAnnotatedString
|
||||
import com.bitwarden.ui.platform.resource.BitwardenString
|
||||
import com.bitwarden.ui.util.Text
|
||||
@@ -30,9 +32,16 @@ class BitwardenClipboardManagerImpl(
|
||||
ClipData
|
||||
.newPlainText("", text)
|
||||
.apply {
|
||||
description.extras = persistableBundleOf(
|
||||
"android.content.extra.IS_SENSITIVE" to isSensitive,
|
||||
)
|
||||
description.extras = PersistableBundle().apply {
|
||||
this.putBoolean(
|
||||
if (isBuildVersionAtLeast(version = Build.VERSION_CODES.TIRAMISU)) {
|
||||
ClipDescription.EXTRA_IS_SENSITIVE
|
||||
} else {
|
||||
"android.content.extra.IS_SENSITIVE"
|
||||
},
|
||||
isSensitive,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.TopAppBarScrollBehavior
|
||||
import androidx.compose.material3.adaptive.WindowAdaptiveInfo
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfoV2
|
||||
import androidx.compose.material3.ripple
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Stable
|
||||
@@ -319,7 +319,7 @@ fun Modifier.standardHorizontalMargin(
|
||||
standardHorizontalMargin(
|
||||
compact = compact,
|
||||
medium = medium,
|
||||
windowAdaptiveInfo = currentWindowAdaptiveInfo(),
|
||||
windowAdaptiveInfo = currentWindowAdaptiveInfoV2(),
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ import androidx.compose.runtime.remember
|
||||
import kotlinx.coroutines.CancellableContinuation
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
/**
|
||||
* Default implementation of [BitwardenToolTipState]
|
||||
@@ -57,7 +58,7 @@ internal class BitwardenToolTipStateImpl(
|
||||
if (isPersistent) {
|
||||
cancellableShow()
|
||||
} else {
|
||||
withTimeout(BITWARDEN_TOOL_TIP_TIMEOUT) { cancellableShow() }
|
||||
withTimeout(BITWARDEN_TOOL_TIP_TIMEOUT.milliseconds) { cancellableShow() }
|
||||
}
|
||||
} finally {
|
||||
if (mutatePriority != MutatePriority.PreventUserInput) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.bitwarden.ui.platform.util
|
||||
|
||||
import androidx.compose.material3.adaptive.WindowAdaptiveInfo
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfoV2
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import com.bitwarden.ui.platform.model.WindowSize
|
||||
@@ -11,7 +11,7 @@ import com.bitwarden.ui.platform.model.WindowSize
|
||||
*/
|
||||
@Composable
|
||||
fun rememberWindowSize(
|
||||
windowAdaptiveInfo: WindowAdaptiveInfo = currentWindowAdaptiveInfo(),
|
||||
windowAdaptiveInfo: WindowAdaptiveInfo = currentWindowAdaptiveInfoV2(),
|
||||
): WindowSize {
|
||||
return remember(key1 = windowAdaptiveInfo.windowSizeClass) {
|
||||
windowAdaptiveInfo.getWindowSize()
|
||||
|
||||
Reference in new issue
Block a user