mirror of
https://github.com/bitwarden/android.git
synced 2026-07-10 11:51:05 -05:00
PM-11356 Adjust autofocus delay to be greater than screen refresh delay. (#4866)
This commit is contained in:
@@ -58,6 +58,7 @@ import java.time.Clock
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
private const val SPECIAL_CIRCUMSTANCE_KEY = "special-circumstance"
|
private const val SPECIAL_CIRCUMSTANCE_KEY = "special-circumstance"
|
||||||
|
private const val ANIMATION_REFRESH_DELAY = 500L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A view model that helps launch actions for the [MainActivity].
|
* A view model that helps launch actions for the [MainActivity].
|
||||||
@@ -148,8 +149,7 @@ class MainViewModel @Inject constructor(
|
|||||||
// Switching between account states often involves some kind of animation (ex:
|
// Switching between account states often involves some kind of animation (ex:
|
||||||
// account switcher) that we might want to give time to finish before triggering
|
// account switcher) that we might want to give time to finish before triggering
|
||||||
// a refresh.
|
// a refresh.
|
||||||
@Suppress("MagicNumber")
|
delay(ANIMATION_REFRESH_DELAY)
|
||||||
delay(500)
|
|
||||||
trySendAction(MainAction.Internal.CurrentUserStateChange)
|
trySendAction(MainAction.Internal.CurrentUserStateChange)
|
||||||
}
|
}
|
||||||
.launchIn(viewModelScope)
|
.launchIn(viewModelScope)
|
||||||
@@ -161,8 +161,7 @@ class MainViewModel @Inject constructor(
|
|||||||
is VaultStateEvent.Locked -> {
|
is VaultStateEvent.Locked -> {
|
||||||
// Similar to account switching, triggering this action too soon can
|
// Similar to account switching, triggering this action too soon can
|
||||||
// interfere with animations or navigation logic, so we will delay slightly.
|
// interfere with animations or navigation logic, so we will delay slightly.
|
||||||
@Suppress("MagicNumber")
|
delay(ANIMATION_REFRESH_DELAY)
|
||||||
delay(500)
|
|
||||||
trySendAction(MainAction.Internal.VaultUnlockStateChange)
|
trySendAction(MainAction.Internal.VaultUnlockStateChange)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,14 @@ import kotlinx.collections.immutable.toImmutableList
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import javax.crypto.Cipher
|
import javax.crypto.Cipher
|
||||||
|
|
||||||
private const val AUTO_FOCUS_DELAY = 415L
|
/**
|
||||||
|
* Time slice to delay auto-focusing on the password/pin field. Because of the refresh that
|
||||||
|
* takes place when switching accounts or changing the lock status we want to delay this
|
||||||
|
* longer than the delay in place for sending those actions in [com.x8bit.bitwarden.MainViewModel]
|
||||||
|
* defined by `ANIMATION_REFRESH_DELAY`. We need to ensure this value is
|
||||||
|
* always greater.
|
||||||
|
*/
|
||||||
|
private const val AUTO_FOCUS_DELAY = 575L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The top level composable for the Vault Unlock screen.
|
* The top level composable for the Vault Unlock screen.
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ class VaultUnlockScreenTest : BaseComposeTest() {
|
|||||||
@Test
|
@Test
|
||||||
fun `state with input and without biometrics should request focus on input field`() = runTest {
|
fun `state with input and without biometrics should request focus on input field`() = runTest {
|
||||||
mutableStateFlow.update { it.copy(hideInput = false, isBiometricEnabled = false) }
|
mutableStateFlow.update { it.copy(hideInput = false, isBiometricEnabled = false) }
|
||||||
dispatcher.advanceTimeByAndRunCurrent(500L)
|
dispatcher.advanceTimeByAndRunCurrent(600L)
|
||||||
composeTestRule
|
composeTestRule
|
||||||
.onNodeWithText("Master password")
|
.onNodeWithText("Master password")
|
||||||
.performScrollTo()
|
.performScrollTo()
|
||||||
|
|||||||
Reference in New Issue
Block a user