mirror of
https://github.com/bitwarden/android.git
synced 2026-06-08 08:06:32 -05:00
Hook up inline autofill setting to UI (#653)
This commit is contained in:
committed by
Álison Fernandes
parent
c7dad53fe4
commit
ff7a015472
@@ -52,6 +52,11 @@ interface SettingsRepository {
|
||||
*/
|
||||
val isUnlockWithPinEnabled: Boolean
|
||||
|
||||
/**
|
||||
* Whether or not inline autofill is enabled for the current user.
|
||||
*/
|
||||
var isInlineAutofillEnabled: Boolean
|
||||
|
||||
/**
|
||||
* Sets default values for various settings for the given [userId] if necessary. This is
|
||||
* typically used when logging into a new account.
|
||||
|
||||
@@ -97,6 +97,18 @@ class SettingsRepositoryImpl(
|
||||
?.let { authDiskSource.getEncryptedPin(userId = it) != null }
|
||||
?: false
|
||||
|
||||
override var isInlineAutofillEnabled: Boolean
|
||||
get() = activeUserId
|
||||
?.let { settingsDiskSource.getInlineAutofillEnabled(userId = it) }
|
||||
?: true
|
||||
set(value) {
|
||||
val userId = activeUserId ?: return
|
||||
settingsDiskSource.storeInlineAutofillEnabled(
|
||||
userId = userId,
|
||||
isInlineAutofillEnabled = value,
|
||||
)
|
||||
}
|
||||
|
||||
override fun setDefaultsIfNecessary(userId: String) {
|
||||
// Set Vault Settings defaults
|
||||
if (!isVaultTimeoutActionSet(userId = userId)) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.os.Parcelable
|
||||
import androidx.lifecycle.SavedStateHandle
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.data.platform.repository.SettingsRepository
|
||||
import com.x8bit.bitwarden.ui.platform.base.BaseViewModel
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.Text
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||
@@ -23,6 +24,7 @@ private const val KEY_STATE = "state"
|
||||
@HiltViewModel
|
||||
class AutoFillViewModel @Inject constructor(
|
||||
private val savedStateHandle: SavedStateHandle,
|
||||
private val settingsRepository: SettingsRepository,
|
||||
) : BaseViewModel<AutoFillState, AutoFillEvent, AutoFillAction>(
|
||||
initialState = savedStateHandle[KEY_STATE]
|
||||
?: AutoFillState(
|
||||
@@ -31,7 +33,7 @@ class AutoFillViewModel @Inject constructor(
|
||||
isCopyTotpAutomaticallyEnabled = false,
|
||||
isUseAccessibilityEnabled = false,
|
||||
isUseDrawOverEnabled = false,
|
||||
isUseInlineAutoFillEnabled = false,
|
||||
isUseInlineAutoFillEnabled = settingsRepository.isInlineAutofillEnabled,
|
||||
uriDetectionMethod = AutoFillState.UriDetectionMethod.DEFAULT,
|
||||
),
|
||||
) {
|
||||
@@ -90,8 +92,7 @@ class AutoFillViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
private fun handleUseInlineAutofillClick(action: AutoFillAction.UseInlineAutofillClick) {
|
||||
// TODO BIT-833: Persist selection
|
||||
sendEvent(AutoFillEvent.ShowToast("Not yet implemented.".asText()))
|
||||
settingsRepository.isInlineAutofillEnabled = action.isEnabled
|
||||
mutableStateFlow.update { it.copy(isUseInlineAutoFillEnabled = action.isEnabled) }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user