mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-17 19:58:57 +03:00
Reformats modules
This commit is contained in:
parent
cc1e1fe8eb
commit
8c53d2f9b0
24 changed files with 135 additions and 126 deletions
|
@ -37,9 +37,9 @@ import org.matrix.android.sdk.internal.auth.db.PendingSessionData
|
|||
* This class execute the registration request and is responsible to keep the session of interactive authentication.
|
||||
*/
|
||||
internal class DefaultRegistrationWizard(
|
||||
authAPI: AuthAPI,
|
||||
private val sessionCreator: SessionCreator,
|
||||
private val pendingSessionStore: PendingSessionStore
|
||||
authAPI: AuthAPI,
|
||||
private val sessionCreator: SessionCreator,
|
||||
private val pendingSessionStore: PendingSessionStore
|
||||
) : RegistrationWizard {
|
||||
|
||||
private var pendingSessionData: PendingSessionData = pendingSessionStore.getPendingSessionData() ?: error("Pending session data should exist here")
|
||||
|
@ -74,20 +74,20 @@ internal class DefaultRegistrationWizard(
|
|||
initialDeviceDisplayName: String?
|
||||
): RegistrationResult {
|
||||
val params = RegistrationParams(
|
||||
username = userName,
|
||||
password = password,
|
||||
initialDeviceDisplayName = initialDeviceDisplayName
|
||||
username = userName,
|
||||
password = password,
|
||||
initialDeviceDisplayName = initialDeviceDisplayName
|
||||
)
|
||||
return performRegistrationRequest(params, LoginType.PASSWORD)
|
||||
.also {
|
||||
pendingSessionData = pendingSessionData.copy(isRegistrationStarted = true)
|
||||
.also { pendingSessionStore.savePendingSessionData(it) }
|
||||
}
|
||||
.also {
|
||||
pendingSessionData = pendingSessionData.copy(isRegistrationStarted = true)
|
||||
.also { pendingSessionStore.savePendingSessionData(it) }
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun performReCaptcha(response: String): RegistrationResult {
|
||||
val safeSession = pendingSessionData.currentSession
|
||||
?: throw IllegalStateException("developer error, call createAccount() method first")
|
||||
?: throw IllegalStateException("developer error, call createAccount() method first")
|
||||
|
||||
val params = RegistrationParams(auth = AuthParams.createForCaptcha(safeSession, response))
|
||||
return performRegistrationRequest(params, LoginType.PASSWORD)
|
||||
|
@ -95,7 +95,7 @@ internal class DefaultRegistrationWizard(
|
|||
|
||||
override suspend fun acceptTerms(): RegistrationResult {
|
||||
val safeSession = pendingSessionData.currentSession
|
||||
?: throw IllegalStateException("developer error, call createAccount() method first")
|
||||
?: throw IllegalStateException("developer error, call createAccount() method first")
|
||||
|
||||
val params = RegistrationParams(auth = AuthParams(type = LoginFlowTypes.TERMS, session = safeSession))
|
||||
return performRegistrationRequest(params, LoginType.PASSWORD)
|
||||
|
@ -103,14 +103,14 @@ internal class DefaultRegistrationWizard(
|
|||
|
||||
override suspend fun addThreePid(threePid: RegisterThreePid): RegistrationResult {
|
||||
pendingSessionData = pendingSessionData.copy(currentThreePidData = null)
|
||||
.also { pendingSessionStore.savePendingSessionData(it) }
|
||||
.also { pendingSessionStore.savePendingSessionData(it) }
|
||||
|
||||
return sendThreePid(threePid)
|
||||
}
|
||||
|
||||
override suspend fun sendAgainThreePid(): RegistrationResult {
|
||||
val safeCurrentThreePid = pendingSessionData.currentThreePidData?.threePid
|
||||
?: throw IllegalStateException("developer error, call createAccount() method first")
|
||||
?: throw IllegalStateException("developer error, call createAccount() method first")
|
||||
|
||||
return sendThreePid(safeCurrentThreePid)
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ internal class DefaultRegistrationWizard(
|
|||
)
|
||||
|
||||
pendingSessionData = pendingSessionData.copy(sendAttempt = pendingSessionData.sendAttempt + 1)
|
||||
.also { pendingSessionStore.savePendingSessionData(it) }
|
||||
.also { pendingSessionStore.savePendingSessionData(it) }
|
||||
|
||||
val params = RegistrationParams(
|
||||
auth = if (threePid is RegisterThreePid.Email) {
|
||||
|
@ -149,7 +149,7 @@ internal class DefaultRegistrationWizard(
|
|||
)
|
||||
// Store data
|
||||
pendingSessionData = pendingSessionData.copy(currentThreePidData = ThreePidData.from(threePid, response, params))
|
||||
.also { pendingSessionStore.savePendingSessionData(it) }
|
||||
.also { pendingSessionStore.savePendingSessionData(it) }
|
||||
|
||||
// and send the sid a first time
|
||||
return performRegistrationRequest(params, LoginType.PASSWORD)
|
||||
|
@ -157,7 +157,7 @@ internal class DefaultRegistrationWizard(
|
|||
|
||||
override suspend fun checkIfEmailHasBeenValidated(delayMillis: Long): RegistrationResult {
|
||||
val safeParam = pendingSessionData.currentThreePidData?.registrationParams
|
||||
?: throw IllegalStateException("developer error, no pending three pid")
|
||||
?: throw IllegalStateException("developer error, no pending three pid")
|
||||
|
||||
return performRegistrationRequest(safeParam, LoginType.PASSWORD, delayMillis)
|
||||
}
|
||||
|
@ -168,13 +168,13 @@ internal class DefaultRegistrationWizard(
|
|||
|
||||
private suspend fun validateThreePid(code: String): RegistrationResult {
|
||||
val registrationParams = pendingSessionData.currentThreePidData?.registrationParams
|
||||
?: throw IllegalStateException("developer error, no pending three pid")
|
||||
?: throw IllegalStateException("developer error, no pending three pid")
|
||||
val safeCurrentData = pendingSessionData.currentThreePidData ?: throw IllegalStateException("developer error, call createAccount() method first")
|
||||
val url = safeCurrentData.addThreePidRegistrationResponse.submitUrl ?: throw IllegalStateException("Missing url to send the code")
|
||||
val validationBody = ValidationCodeBody(
|
||||
clientSecret = pendingSessionData.clientSecret,
|
||||
sid = safeCurrentData.addThreePidRegistrationResponse.sid,
|
||||
code = code
|
||||
clientSecret = pendingSessionData.clientSecret,
|
||||
sid = safeCurrentData.addThreePidRegistrationResponse.sid,
|
||||
code = code
|
||||
)
|
||||
val validationResponse = validateCodeTask.execute(ValidateCodeTask.Params(url, validationBody))
|
||||
if (validationResponse.isSuccess()) {
|
||||
|
@ -189,7 +189,7 @@ internal class DefaultRegistrationWizard(
|
|||
|
||||
override suspend fun dummy(): RegistrationResult {
|
||||
val safeSession = pendingSessionData.currentSession
|
||||
?: throw IllegalStateException("developer error, call createAccount() method first")
|
||||
?: throw IllegalStateException("developer error, call createAccount() method first")
|
||||
|
||||
val params = RegistrationParams(auth = AuthParams(type = LoginFlowTypes.DUMMY, session = safeSession))
|
||||
return performRegistrationRequest(params, LoginType.PASSWORD)
|
||||
|
|
|
@ -604,14 +604,16 @@ internal class MXOlmDevice @Inject constructor(
|
|||
* @param sharedHistory MSC3061, this key is sharable on invite
|
||||
* @return true if the operation succeeds.
|
||||
*/
|
||||
fun addInboundGroupSession(sessionId: String,
|
||||
sessionKey: String,
|
||||
roomId: String,
|
||||
senderKey: String,
|
||||
forwardingCurve25519KeyChain: List<String>,
|
||||
keysClaimed: Map<String, String>,
|
||||
exportFormat: Boolean,
|
||||
sharedHistory: Boolean): AddSessionResult {
|
||||
fun addInboundGroupSession(
|
||||
sessionId: String,
|
||||
sessionKey: String,
|
||||
roomId: String,
|
||||
senderKey: String,
|
||||
forwardingCurve25519KeyChain: List<String>,
|
||||
keysClaimed: Map<String, String>,
|
||||
exportFormat: Boolean,
|
||||
sharedHistory: Boolean
|
||||
): AddSessionResult {
|
||||
val candidateSession = tryOrNull("Failed to create inbound session in room $roomId") {
|
||||
if (exportFormat) {
|
||||
OlmInboundGroupSession.importSession(sessionKey)
|
||||
|
@ -701,8 +703,8 @@ internal class MXOlmDevice @Inject constructor(
|
|||
val senderKey = megolmSessionData.senderKey ?: continue
|
||||
val roomId = megolmSessionData.roomId
|
||||
|
||||
val candidateSessionToImport = try {
|
||||
MXInboundMegolmSessionWrapper.newFromMegolmData(megolmSessionData, true)
|
||||
val candidateSessionToImport = try {
|
||||
MXInboundMegolmSessionWrapper.newFromMegolmData(megolmSessionData, true)
|
||||
} catch (e: Throwable) {
|
||||
Timber.tag(loggerTag.value).e(e, "## importInboundGroupSession() : Failed to import session $senderKey/$sessionId")
|
||||
continue
|
||||
|
|
|
@ -38,6 +38,7 @@ internal class MXMegolmDecryptionFactory @Inject constructor(
|
|||
outgoingKeyRequestManager,
|
||||
cryptoStore,
|
||||
matrixConfiguration,
|
||||
eventsManager)
|
||||
eventsManager
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -250,8 +250,10 @@ internal class MXMegolmEncryption(
|
|||
* @param sessionInfo the session info
|
||||
* @param devicesByUser the devices map
|
||||
*/
|
||||
private suspend fun shareUserDevicesKey(sessionInfo: MXOutboundSessionInfo,
|
||||
devicesByUser: Map<String, List<CryptoDeviceInfo>>) {
|
||||
private suspend fun shareUserDevicesKey(
|
||||
sessionInfo: MXOutboundSessionInfo,
|
||||
devicesByUser: Map<String, List<CryptoDeviceInfo>>
|
||||
) {
|
||||
val sessionKey = olmDevice.getSessionKey(sessionInfo.sessionId) ?: return Unit.also {
|
||||
Timber.tag(loggerTag.value).v("shareUserDevicesKey() Failed to share session, failed to export")
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import timber.log.Timber
|
|||
/**
|
||||
* Throws in debug, only log in production.
|
||||
* As this method does not always throw, next statement should be a return.
|
||||
*/
|
||||
*/
|
||||
internal fun fatalError(message: String) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
error(message)
|
||||
|
|
|
@ -21,11 +21,11 @@ import im.vector.app.features.onboarding.AuthenticationDescription
|
|||
|
||||
fun AuthenticationDescription.AuthenticationType.toAnalyticsType() = when (this) {
|
||||
AuthenticationDescription.AuthenticationType.Password -> Signup.AuthenticationType.Password
|
||||
AuthenticationDescription.AuthenticationType.Apple -> Signup.AuthenticationType.Apple
|
||||
AuthenticationDescription.AuthenticationType.Apple -> Signup.AuthenticationType.Apple
|
||||
AuthenticationDescription.AuthenticationType.Facebook -> Signup.AuthenticationType.Facebook
|
||||
AuthenticationDescription.AuthenticationType.GitHub -> Signup.AuthenticationType.GitHub
|
||||
AuthenticationDescription.AuthenticationType.GitLab -> Signup.AuthenticationType.GitLab
|
||||
AuthenticationDescription.AuthenticationType.Google -> Signup.AuthenticationType.Google
|
||||
AuthenticationDescription.AuthenticationType.SSO -> Signup.AuthenticationType.SSO
|
||||
AuthenticationDescription.AuthenticationType.Other -> Signup.AuthenticationType.Other
|
||||
AuthenticationDescription.AuthenticationType.SSO -> Signup.AuthenticationType.SSO
|
||||
AuthenticationDescription.AuthenticationType.Other -> Signup.AuthenticationType.Other
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class AvatarRenderer @Inject constructor(
|
|||
render(
|
||||
GlideApp.with(imageView),
|
||||
matrixItem,
|
||||
DrawableImageViewTarget(imageView)
|
||||
DrawableImageViewTarget(imageView),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ class AvatarRenderer @Inject constructor(
|
|||
render(
|
||||
glideRequests,
|
||||
matrixItem,
|
||||
DrawableImageViewTarget(imageView)
|
||||
DrawableImageViewTarget(imageView),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ class AvatarRenderer @Inject constructor(
|
|||
val matrixItem = MatrixItem.UserItem(
|
||||
// Need an id starting with @
|
||||
id = "@${mappedContact.displayName}",
|
||||
displayName = mappedContact.displayName
|
||||
displayName = mappedContact.displayName,
|
||||
)
|
||||
|
||||
val placeholder = getPlaceholderDrawable(matrixItem)
|
||||
|
@ -140,7 +140,7 @@ class AvatarRenderer @Inject constructor(
|
|||
val matrixItem = MatrixItem.UserItem(
|
||||
// Need an id starting with @
|
||||
id = profileInfo.matrixId,
|
||||
displayName = profileInfo.displayName
|
||||
displayName = profileInfo.displayName,
|
||||
)
|
||||
|
||||
val placeholder = getPlaceholderDrawable(matrixItem)
|
||||
|
@ -215,7 +215,7 @@ class AvatarRenderer @Inject constructor(
|
|||
.bold()
|
||||
.endConfig()
|
||||
.buildRect(matrixItem.firstLetterOfDisplayName(), avatarColor)
|
||||
.toBitmap(width = iconSize, height = iconSize)
|
||||
.toBitmap(width = iconSize, height = iconSize),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ class AvatarRenderer @Inject constructor(
|
|||
addPlaceholder: Boolean
|
||||
) {
|
||||
val transformations = mutableListOf<Transformation<Bitmap>>(
|
||||
BlurTransformation(20, sampling)
|
||||
BlurTransformation(20, sampling),
|
||||
)
|
||||
if (colorFilter != null) {
|
||||
transformations.add(ColorFilterTransformation(colorFilter))
|
||||
|
|
|
@ -219,7 +219,7 @@ class HomeActivity :
|
|||
is HomeActivitySharedAction.ShowSpaceSettings -> showSpaceSettings(sharedAction.spaceId)
|
||||
is HomeActivitySharedAction.OpenSpaceInvite -> openSpaceInvite(sharedAction.spaceId)
|
||||
HomeActivitySharedAction.SendSpaceFeedBack -> bugReporter.openBugReportScreen(this, ReportType.SPACE_BETA_FEEDBACK)
|
||||
HomeActivitySharedAction.OnCloseSpace -> onCloseSpace()
|
||||
HomeActivitySharedAction.OnCloseSpace -> onCloseSpace()
|
||||
}
|
||||
}
|
||||
.launchIn(lifecycleScope)
|
||||
|
|
|
@ -1706,7 +1706,7 @@ class TimelineFragment @Inject constructor(
|
|||
|
||||
private fun renderToolbar(roomSummary: RoomSummary?) {
|
||||
when {
|
||||
isLocalRoom() -> {
|
||||
isLocalRoom() -> {
|
||||
views.includeRoomToolbar.roomToolbarContentView.isVisible = false
|
||||
views.includeThreadToolbar.roomToolbarThreadConstraintLayout.isVisible = false
|
||||
setupToolbar(views.roomToolbar)
|
||||
|
@ -1724,7 +1724,7 @@ class TimelineFragment @Inject constructor(
|
|||
}
|
||||
views.includeThreadToolbar.roomToolbarThreadTitleTextView.text = resources.getText(R.string.thread_timeline_title)
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
views.includeRoomToolbar.roomToolbarContentView.isVisible = true
|
||||
views.includeThreadToolbar.roomToolbarThreadConstraintLayout.isVisible = false
|
||||
if (roomSummary == null) {
|
||||
|
|
|
@ -63,10 +63,10 @@ class EncryptionItemFactory @Inject constructor(
|
|||
isDirect && RoomLocalEcho.isLocalEchoId(event.root.roomId.orEmpty()) -> {
|
||||
R.string.direct_room_encryption_enabled_tile_description_future
|
||||
}
|
||||
isDirect -> {
|
||||
isDirect -> {
|
||||
R.string.direct_room_encryption_enabled_tile_description
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
R.string.encryption_enabled_tile_description
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,17 +146,17 @@ class RoomListViewModel @AssistedInject constructor(
|
|||
companion object : MavericksViewModelFactory<RoomListViewModel, RoomListViewState> by hiltMavericksViewModelFactory()
|
||||
|
||||
private val roomListSectionBuilder = RoomListSectionBuilder(
|
||||
session,
|
||||
stringProvider,
|
||||
appStateHandler,
|
||||
viewModelScope,
|
||||
autoAcceptInvites,
|
||||
{
|
||||
updatableQuery = it
|
||||
},
|
||||
suggestedRoomJoiningState,
|
||||
!vectorPreferences.prefSpacesShowAllRoomInHome()
|
||||
)
|
||||
session,
|
||||
stringProvider,
|
||||
appStateHandler,
|
||||
viewModelScope,
|
||||
autoAcceptInvites,
|
||||
{
|
||||
updatableQuery = it
|
||||
},
|
||||
suggestedRoomJoiningState,
|
||||
!vectorPreferences.prefSpacesShowAllRoomInHome()
|
||||
)
|
||||
|
||||
val sections: List<RoomsSection> by lazy {
|
||||
roomListSectionBuilder.buildSections(initialState.displayMode)
|
||||
|
|
|
@ -85,27 +85,27 @@ class EventHtmlRenderer @Inject constructor(
|
|||
} else {
|
||||
builder
|
||||
}
|
||||
.usePlugin(
|
||||
MarkwonInlineParserPlugin.create(
|
||||
/* Configuring the Markwon inline formatting processor.
|
||||
* Default settings are all Markdown features. Turn those off, only using the
|
||||
* inline HTML processor and HTML entities processor.
|
||||
*/
|
||||
MarkwonInlineParser.factoryBuilderNoDefaults()
|
||||
.addInlineProcessor(HtmlInlineProcessor()) // use inline HTML processor
|
||||
.addInlineProcessor(EntityInlineProcessor()) // use HTML entities processor
|
||||
.usePlugin(
|
||||
MarkwonInlineParserPlugin.create(
|
||||
/* Configuring the Markwon inline formatting processor.
|
||||
* Default settings are all Markdown features. Turn those off, only using the
|
||||
* inline HTML processor and HTML entities processor.
|
||||
*/
|
||||
MarkwonInlineParser.factoryBuilderNoDefaults()
|
||||
.addInlineProcessor(HtmlInlineProcessor()) // use inline HTML processor
|
||||
.addInlineProcessor(EntityInlineProcessor()) // use HTML entities processor
|
||||
)
|
||||
)
|
||||
)
|
||||
.usePlugin(object : AbstractMarkwonPlugin() {
|
||||
override fun configureParser(builder: Parser.Builder) {
|
||||
/* Configuring the Markwon block formatting processor.
|
||||
* Default settings are all Markdown blocks. Turn those off.
|
||||
*/
|
||||
builder.enabledBlockTypes(kotlin.collections.emptySet())
|
||||
}
|
||||
})
|
||||
.textSetter(PrecomputedFutureTextSetterCompat.create())
|
||||
.build()
|
||||
.usePlugin(object : AbstractMarkwonPlugin() {
|
||||
override fun configureParser(builder: Parser.Builder) {
|
||||
/* Configuring the Markwon block formatting processor.
|
||||
* Default settings are all Markdown blocks. Turn those off.
|
||||
*/
|
||||
builder.enabledBlockTypes(kotlin.collections.emptySet())
|
||||
}
|
||||
})
|
||||
.textSetter(PrecomputedFutureTextSetterCompat.create())
|
||||
.build()
|
||||
|
||||
val plugins: List<MarkwonPlugin> = markwon.plugins
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import im.vector.app.databinding.BottomSheetLiveLocationLabsFlagPromotionBinding
|
|||
* This should not be shown if the user already enabled the labs flag.
|
||||
*/
|
||||
class LiveLocationLabsFlagPromotionBottomSheet :
|
||||
VectorBaseBottomSheetDialogFragment<BottomSheetLiveLocationLabsFlagPromotionBinding>() {
|
||||
VectorBaseBottomSheetDialogFragment<BottomSheetLiveLocationLabsFlagPromotionBinding>() {
|
||||
|
||||
override val showExpanded = true
|
||||
|
||||
|
|
|
@ -41,12 +41,12 @@ sealed interface AuthenticationDescription : Parcelable {
|
|||
}
|
||||
|
||||
fun SsoIdentityProvider?.toAuthenticationType() = when (this?.brand) {
|
||||
SsoIdentityProvider.BRAND_GOOGLE -> AuthenticationType.Google
|
||||
SsoIdentityProvider.BRAND_GITHUB -> AuthenticationType.GitHub
|
||||
SsoIdentityProvider.BRAND_APPLE -> AuthenticationType.Apple
|
||||
SsoIdentityProvider.BRAND_GOOGLE -> AuthenticationType.Google
|
||||
SsoIdentityProvider.BRAND_GITHUB -> AuthenticationType.GitHub
|
||||
SsoIdentityProvider.BRAND_APPLE -> AuthenticationType.Apple
|
||||
SsoIdentityProvider.BRAND_FACEBOOK -> AuthenticationType.Facebook
|
||||
SsoIdentityProvider.BRAND_GITLAB -> AuthenticationType.GitLab
|
||||
SsoIdentityProvider.BRAND_TWITTER -> AuthenticationType.SSO
|
||||
null -> AuthenticationType.SSO
|
||||
else -> AuthenticationType.SSO
|
||||
SsoIdentityProvider.BRAND_GITLAB -> AuthenticationType.GitLab
|
||||
SsoIdentityProvider.BRAND_TWITTER -> AuthenticationType.SSO
|
||||
null -> AuthenticationType.SSO
|
||||
else -> AuthenticationType.SSO
|
||||
}
|
||||
|
|
|
@ -511,7 +511,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
setState { copy(isLoading = false, resetState = ResetState()) }
|
||||
val nextEvent = when {
|
||||
vectorFeatures.isOnboardingCombinedLoginEnabled() -> OnboardingViewEvents.OnResetPasswordComplete
|
||||
else -> OnboardingViewEvents.OpenResetPasswordComplete
|
||||
else -> OnboardingViewEvents.OpenResetPasswordComplete
|
||||
}
|
||||
_viewEvents.post(nextEvent)
|
||||
},
|
||||
|
|
|
@ -53,6 +53,6 @@ fun observeContentChangesAndResetErrors(username: TextInputLayout, password: Tex
|
|||
}
|
||||
|
||||
fun ThemeProvider.ftueBreakerBackground() = when (isLightTheme()) {
|
||||
true -> R.drawable.bg_gradient_ftue_breaker
|
||||
true -> R.drawable.bg_gradient_ftue_breaker
|
||||
false -> R.drawable.bg_color_background
|
||||
}
|
||||
|
|
|
@ -33,6 +33,6 @@ class BiometricAuthError(val code: Int, message: String) : Throwable(message) {
|
|||
val isAuthPermanentlyDisabledError: Boolean get() = code == BiometricPrompt.ERROR_LOCKOUT_PERMANENT
|
||||
|
||||
companion object {
|
||||
private val LOCKOUT_ERROR_CODES = arrayOf(BiometricPrompt.ERROR_LOCKOUT, BiometricPrompt.ERROR_LOCKOUT_PERMANENT)
|
||||
private val LOCKOUT_ERROR_CODES = arrayOf(BiometricPrompt.ERROR_LOCKOUT, BiometricPrompt.ERROR_LOCKOUT_PERMANENT)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,26 +73,30 @@ class BiometricHelper @Inject constructor(
|
|||
/**
|
||||
* Returns true if a weak biometric method (i.e.: some face or iris unlock implementations) can be used.
|
||||
*/
|
||||
val canUseWeakBiometricAuth: Boolean get() =
|
||||
configuration.isWeakBiometricsEnabled && biometricManager.canAuthenticate(BIOMETRIC_WEAK) == BIOMETRIC_SUCCESS
|
||||
val canUseWeakBiometricAuth: Boolean
|
||||
get() =
|
||||
configuration.isWeakBiometricsEnabled && biometricManager.canAuthenticate(BIOMETRIC_WEAK) == BIOMETRIC_SUCCESS
|
||||
|
||||
/**
|
||||
* Returns true if a strong biometric method (i.e.: fingerprint, some face or iris unlock implementations) can be used.
|
||||
*/
|
||||
val canUseStrongBiometricAuth: Boolean get() =
|
||||
configuration.isStrongBiometricsEnabled && biometricManager.canAuthenticate(BIOMETRIC_STRONG) == BIOMETRIC_SUCCESS
|
||||
val canUseStrongBiometricAuth: Boolean
|
||||
get() =
|
||||
configuration.isStrongBiometricsEnabled && biometricManager.canAuthenticate(BIOMETRIC_STRONG) == BIOMETRIC_SUCCESS
|
||||
|
||||
/**
|
||||
* Returns true if the device credentials can be used to unlock (system pin code, password, pattern, etc.).
|
||||
*/
|
||||
val canUseDeviceCredentialsAuth: Boolean get() =
|
||||
configuration.isDeviceCredentialUnlockEnabled && biometricManager.canAuthenticate(DEVICE_CREDENTIAL) == BIOMETRIC_SUCCESS
|
||||
val canUseDeviceCredentialsAuth: Boolean
|
||||
get() =
|
||||
configuration.isDeviceCredentialUnlockEnabled && biometricManager.canAuthenticate(DEVICE_CREDENTIAL) == BIOMETRIC_SUCCESS
|
||||
|
||||
/**
|
||||
* Returns true if any system authentication method (biometric weak/strong or device credentials) can be used.
|
||||
*/
|
||||
@VisibleForTesting(otherwise = PRIVATE)
|
||||
internal val canUseAnySystemAuth: Boolean get() = canUseWeakBiometricAuth || canUseStrongBiometricAuth || canUseDeviceCredentialsAuth
|
||||
internal val canUseAnySystemAuth: Boolean
|
||||
get() = canUseWeakBiometricAuth || canUseStrongBiometricAuth || canUseDeviceCredentialsAuth
|
||||
|
||||
/**
|
||||
* Returns true if any system authentication method and there is a valid associated key.
|
||||
|
@ -153,9 +157,9 @@ class BiometricHelper @Inject constructor(
|
|||
@SuppressLint("NewApi")
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
private fun authenticateInternal(
|
||||
activity: FragmentActivity,
|
||||
checkSystemKeyExists: Boolean,
|
||||
cryptoObject: BiometricPrompt.CryptoObject? = null,
|
||||
activity: FragmentActivity,
|
||||
checkSystemKeyExists: Boolean,
|
||||
cryptoObject: BiometricPrompt.CryptoObject? = null,
|
||||
): Flow<Boolean> {
|
||||
if (checkSystemKeyExists && !isSystemAuthEnabledAndValid) return flowOf(false)
|
||||
|
||||
|
@ -189,9 +193,9 @@ class BiometricHelper @Inject constructor(
|
|||
|
||||
@VisibleForTesting(otherwise = PRIVATE)
|
||||
internal fun authenticateWithPromptInternal(
|
||||
activity: FragmentActivity,
|
||||
cryptoObject: BiometricPrompt.CryptoObject? = null,
|
||||
channel: Channel<Boolean>,
|
||||
activity: FragmentActivity,
|
||||
cryptoObject: BiometricPrompt.CryptoObject? = null,
|
||||
channel: Channel<Boolean>,
|
||||
): BiometricPrompt {
|
||||
val executor = ContextCompat.getMainExecutor(context)
|
||||
val callback = createSuspendingAuthCallback(channel, executor.asCoroutineDispatcher())
|
||||
|
|
|
@ -36,7 +36,7 @@ class LockScreenKeyRepository(
|
|||
private val systemKeyAlias = "$baseName.system"
|
||||
|
||||
private val pinCodeCrypto: KeyStoreCrypto by lazy {
|
||||
keyStoreCryptoFactory.provide(pinCodeKeyAlias, keyNeedsUserAuthentication = false)
|
||||
keyStoreCryptoFactory.provide(pinCodeKeyAlias, keyNeedsUserAuthentication = false)
|
||||
}
|
||||
private val systemKeyCrypto: KeyStoreCrypto by lazy {
|
||||
keyStoreCryptoFactory.provide(systemKeyAlias, keyNeedsUserAuthentication = true)
|
||||
|
|
|
@ -114,15 +114,15 @@ class LockScreenFragment : VectorBaseFragment<FragmentLockScreenBinding>() {
|
|||
private fun handleEvent(viewEvent: LockScreenViewEvent) {
|
||||
when (viewEvent) {
|
||||
is LockScreenViewEvent.CodeCreationComplete -> lockScreenListener?.onPinCodeCreated()
|
||||
is LockScreenViewEvent.ClearPinCode -> {
|
||||
is LockScreenViewEvent.ClearPinCode -> {
|
||||
if (viewEvent.confirmationFailed) {
|
||||
lockScreenListener?.onNewCodeValidationFailed()
|
||||
}
|
||||
views.codeView.clearCode()
|
||||
}
|
||||
is LockScreenViewEvent.AuthSuccessful -> lockScreenListener?.onAuthenticationSuccess(viewEvent.method)
|
||||
is LockScreenViewEvent.AuthFailure -> onAuthFailure(viewEvent.method)
|
||||
is LockScreenViewEvent.AuthError -> onAuthError(viewEvent.method, viewEvent.throwable)
|
||||
is LockScreenViewEvent.AuthSuccessful -> lockScreenListener?.onAuthenticationSuccess(viewEvent.method)
|
||||
is LockScreenViewEvent.AuthFailure -> onAuthFailure(viewEvent.method)
|
||||
is LockScreenViewEvent.AuthError -> onAuthError(viewEvent.method, viewEvent.throwable)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ class LockScreenViewModel @AssistedInject constructor(
|
|||
|
||||
override fun handle(action: LockScreenAction) {
|
||||
when (action) {
|
||||
is LockScreenAction.PinCodeEntered -> onPinCodeEntered(action.value)
|
||||
is LockScreenAction.PinCodeEntered -> onPinCodeEntered(action.value)
|
||||
is LockScreenAction.ShowBiometricPrompt -> showBiometricPrompt(action.callingActivity)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,15 +48,15 @@ object DevicePromptCheck {
|
|||
* See [this OP forum thread](https://forums.oneplus.com/threads/oneplus-7-pro-fingerprint-biometricprompt-does-not-show.1035821/).
|
||||
*/
|
||||
private val isOnePlusDeviceWithNoBiometricUI: Boolean =
|
||||
Build.BRAND.equals("OnePlus", ignoreCase = true) &&
|
||||
!onePlusModelsWithWorkingBiometricUI.contains(Build.MODEL) &&
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.R
|
||||
Build.BRAND.equals("OnePlus", ignoreCase = true) &&
|
||||
!onePlusModelsWithWorkingBiometricUI.contains(Build.MODEL) &&
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.R
|
||||
|
||||
/**
|
||||
* Some LG models don't seem to have a system biometric prompt at all.
|
||||
*/
|
||||
private val isLGDeviceWithNoBiometricUI: Boolean =
|
||||
Build.BRAND.equals("LG", ignoreCase = true) && lgModelsWithoutBiometricUI.contains(Build.MODEL)
|
||||
Build.BRAND.equals("LG", ignoreCase = true) && lgModelsWithoutBiometricUI.contains(Build.MODEL)
|
||||
|
||||
/**
|
||||
* Check if this device is included in the list of devices with known Biometric Prompt issues.
|
||||
|
|
|
@ -31,7 +31,7 @@ import javax.inject.Inject
|
|||
|
||||
class FontScaleSettingFragment @Inject constructor(
|
||||
private val fontListController: FontScaleSettingController
|
||||
) : VectorBaseFragment<FragmentSettingsFontScalingBinding>(), FontScaleSettingController.Callback {
|
||||
) : VectorBaseFragment<FragmentSettingsFontScalingBinding>(), FontScaleSettingController.Callback {
|
||||
|
||||
private val viewModel: FontScaleSettingViewModel by fragmentViewModel()
|
||||
|
||||
|
|
|
@ -94,10 +94,10 @@ class SoftLogoutController @Inject constructor(
|
|||
}
|
||||
|
||||
private fun buildForm(state: SoftLogoutViewState) = when (state.asyncHomeServerLoginFlowRequest) {
|
||||
is Fail -> buildLoginErrorWithRetryItem(state.asyncHomeServerLoginFlowRequest.error)
|
||||
is Success -> buildLoginSuccessItem(state)
|
||||
is Fail -> buildLoginErrorWithRetryItem(state.asyncHomeServerLoginFlowRequest.error)
|
||||
is Success -> buildLoginSuccessItem(state)
|
||||
is Loading, Uninitialized -> buildLoadingItem()
|
||||
is Incomplete -> Unit
|
||||
is Incomplete -> Unit
|
||||
}
|
||||
|
||||
private fun buildLoadingItem() {
|
||||
|
@ -116,11 +116,11 @@ class SoftLogoutController @Inject constructor(
|
|||
}
|
||||
|
||||
private fun buildLoginSuccessItem(state: SoftLogoutViewState) = when (state.asyncHomeServerLoginFlowRequest.invoke()) {
|
||||
LoginMode.Password -> buildLoginPasswordForm(state)
|
||||
is LoginMode.Sso -> buildLoginSSOForm()
|
||||
LoginMode.Password -> buildLoginPasswordForm(state)
|
||||
is LoginMode.Sso -> buildLoginSSOForm()
|
||||
is LoginMode.SsoAndPassword -> disambiguateLoginSSOAndPasswordForm(state)
|
||||
LoginMode.Unsupported -> buildLoginUnsupportedForm()
|
||||
LoginMode.Unknown, null -> Unit // Should not happen
|
||||
LoginMode.Unsupported -> buildLoginUnsupportedForm()
|
||||
LoginMode.Unknown, null -> Unit // Should not happen
|
||||
}
|
||||
|
||||
private fun buildLoginPasswordForm(state: SoftLogoutViewState) {
|
||||
|
@ -148,12 +148,12 @@ class SoftLogoutController @Inject constructor(
|
|||
|
||||
private fun disambiguateLoginSSOAndPasswordForm(state: SoftLogoutViewState) {
|
||||
when (state.loginType) {
|
||||
LoginType.PASSWORD -> buildLoginPasswordForm(state)
|
||||
LoginType.SSO -> buildLoginSSOForm()
|
||||
LoginType.PASSWORD -> buildLoginPasswordForm(state)
|
||||
LoginType.SSO -> buildLoginSSOForm()
|
||||
LoginType.DIRECT,
|
||||
LoginType.CUSTOM,
|
||||
LoginType.UNSUPPORTED -> buildLoginUnsupportedForm()
|
||||
LoginType.UNKNOWN -> Unit
|
||||
LoginType.UNKNOWN -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue