Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5307 Adds ForceLoginFallback feature flag to Login and Registration #5325

Merged
merged 15 commits into from
Feb 28, 2022

Conversation

ericdecanini
Copy link
Contributor

@ericdecanini ericdecanini commented Feb 23, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Adds a new feature flag forceLoginFallback used in FtueAuthVariant's registration and login flows to force web registration / login to be used

Motivation and context

Addresses Issue #5307

I also took this as an opportunity to do some light refactoring within FtueAuthVariant with the only real change being the addition of said feature flag. It might look more functions have been added / removed in the diff when in reality they've only been moved around (and some functions have been split out for better abstraction and readability).

I limited this refactoring to only the flows directly related to where the feature flag was used, otherwise this PR would be far larger than it needs to be.

I suggest looking through the commits when reviewing as I've separated out the behavioural changes and the refactoral changes

Screenshots / GIFs

Feature Flag

image

Usage

Registration Login
image image

Tests

  1. Run the build on a fresh install (or clear your data)
  2. On the first FTUE screen go to developer options > private settings and enable Force login and registration fallback
  3. Attempt a sign in & registration and see that they both force you to fallback to following the web flow

Tested devices

  • Physical
  • Emulator
  • OS version(s): Android 10

Checklist

…tration-feature-flag

# Conflicts:
#	vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt
#	vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt
#	vector/src/main/java/im/vector/app/features/VectorFeatures.kt
package im.vector.lib.core.utils.extensions

@Suppress("UNUSED_PARAMETER")
fun doNothing(reason: String = "") = Unit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially useful in single line lambdas (e.g. when statements, example below) as a cleaner alternative to { /* do nothing */ }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just write { Unit } ?

@@ -228,6 +224,25 @@ class FtueAuthVariant(
}.exhaustive
}

private fun registrationShouldFallback(registrationFlowResult: OnboardingViewEvents.RegistrationFlowResult) =
vectorFeatures.isForceLoginFallbackEnabled() || registrationFlowResult.containsUnsupportedRegistrationFlow()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real change no. 1

.setNegativeButton(R.string.no, null)
.show()
}

private fun handleSignInWithMatrixId(state: OnboardingViewState) {
if (vectorFeatures.isForceLoginFallbackEnabled())
onLoginModeNotSupported(state.loginModeSupportedTypes)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real change no. 3

?.let { onboardingViewModel.handle(OnboardingAction.LoginWithToken(it)) }
private fun handleSignInSelected(state: OnboardingViewState) {
if (vectorFeatures.isForceLoginFallbackEnabled())
onLoginModeNotSupported(state.loginModeSupportedTypes)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real change no. 2

@github-actions
Copy link

github-actions bot commented Feb 23, 2022

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
    passed="25" failures="17" errors="0" skipped="2"
  • [org.matrix.android.sdk.account]
    passed="1" failures="1" errors="0" skipped="0"
  • [org.matrix.android.sdk.internal]
    passed="158" failures="12" errors="0" skipped="38"
  • [org.matrix.android.sdk.ordering]
    passed="1" failures="1" errors="0" skipped="0"
  • [org.matrix.android.sdk.PermalinkParserTest]
    passed="1" failures="1" errors="0" skipped="0"

@github-actions
Copy link

github-actions bot commented Feb 23, 2022

Unit Test Results

  84 files  ±0    84 suites  ±0   1m 2s ⏱️ -2s
157 tests ±0  157 ✔️ ±0  0 💤 ±0  0 ±0 
504 runs  ±0  504 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 65242df. ± Comparison against base commit 9e9dc1d.

♻️ This comment has been updated with latest results.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Some remarks.

package im.vector.lib.core.utils.extensions

@Suppress("UNUSED_PARAMETER")
fun doNothing(reason: String = "") = Unit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just write { Unit } ?

@@ -110,7 +111,7 @@ class FtueAuthVariant(
}

override fun setIsLoading(isLoading: Boolean) {
// do nothing
doNothing()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a comment, or write override fun setIsLoading(isLoading: Boolean) = Unit. I do not know what others think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. This is purely my personal preference, but Unit definitely works too

is LoginMode.SsoAndPassword,
LoginMode.Password -> openAuthLoginFragmentWithTag(FRAGMENT_LOGIN_TAG)
LoginMode.Unsupported -> onLoginModeNotSupported(state.loginModeSupportedTypes)
}.exhaustive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here .exhaustive is not necessary anymore, since when statement is "assigned" to the fun

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@@ -106,4 +108,5 @@ object DebugFeatureKeys {
val onboardingSplashCarousel = booleanPreferencesKey("onboarding-splash-carousel")
val onboardingUseCase = booleanPreferencesKey("onbboarding-splash-carousel")
val onboardingPersonalize = booleanPreferencesKey("onbboarding-personalize")
val forceLoginFallback = booleanPreferencesKey("force-login-fallback")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to add this simple boolean to the screen DebugPrivateSettingsFragment as suggested by @ouchadam , since this is really something for internal test and not a feature we can disable or enable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was my thinking ^^^ I don't see us wanting to promoting this setting for production/all users

@bmarty bmarty requested a review from ouchadam February 23, 2022 18:22
@@ -59,4 +59,16 @@ class VectorDataStore @Inject constructor(
settings[forceDialPadDisplay] = force
}
}

private val forceLoginFallback = booleanPreferencesKey("force_login_fallback")
Copy link
Contributor

@ouchadam ouchadam Feb 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected this to be beside the dial pad option within the VectorDataStore (along with the store read/write access below) 🤔

I have an upcoming PR to move the override options out of the VectorDataStore and into a VectorOverrides abstraction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soz for the conflict 😅 For visibility sake, because they're pretty minor, we decided that you'd resolve them on your pr

Copy link
Contributor

@ouchadam ouchadam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good from my side! thanks for adding the screenshots 💯

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

@@ -75,6 +75,8 @@ class FtueAuthVariant(
private val popEnterAnim = R.anim.no_anim
private val popExitAnim = R.anim.exit_fade_out

private var isForceLoginFallbackEnabled = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for this private var, as a cache, because the boolean is also in the state.

@bmarty bmarty merged commit 2790506 into develop Feb 28, 2022
@bmarty bmarty deleted the feature/eric/registration-feature-flag branch February 28, 2022 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants