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

New Layout - Labs Flag (to replace feature flag) #7038

Merged
merged 16 commits into from
Sep 8, 2022

Conversation

ericdecanini
Copy link
Contributor

@ericdecanini ericdecanini commented Sep 6, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Adds new layout flag as a labs flag

Motivation and context

Screenshots / GIFs

image

(see bottom option)

Tests

Switch on and off labs flag and see that new layout is switched on and off accordingly

Tested devices

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

Checklist

@ericdecanini ericdecanini marked this pull request as ready for review September 6, 2022 10:55
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.

Just a point on default value usage.

@@ -83,4 +83,10 @@
android:summary="@string/labs_enable_element_call_permission_shortcuts_summary"
android:title="@string/labs_enable_element_call_permission_shortcuts" />

<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
Copy link
Member

Choose a reason for hiding this comment

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

You must use settings_labs_new_app_layout_default here too.

@bmarty bmarty disabled auto-merge September 6, 2022 12:14
@ericdecanini ericdecanini requested a review from bmarty September 6, 2022 12:44
…ers_for_space' into feature/eric/new-layout-labs
@bmarty
Copy link
Member

bmarty commented Sep 6, 2022

@ericdecanini I just had a discussion with @fedrunov and I think it's better to keep the feature flag, to be able to completely disable the new app layout feature. It can be useful for forks and also for us if there is a problem with the new app layout.

So if the feature flag is true, the lab flag is displayed. If the feature flag is false, the labs flag is hidden.

Also we will have:

VectorPreferences.isNewAppLayoutEnabled(): Boolean {
    return vectorFeatures.isNewAppLayoutEnabled() &&
        defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default))
}

Can you do that please? Thanks!

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.

See my comment

…ayout-labs

# Conflicts:
#	vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt
@ericdecanini ericdecanini requested a review from bmarty September 6, 2022 13:32
@@ -249,7 +249,7 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver

initUiAndData()

if (vectorFeatures.isNewAppLayoutEnabled()) {
if (vectorPreferences.isNewAppLayoutEnabled()) {
Copy link
Member

Choose a reason for hiding this comment

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

Since both vectorFeatures.isNewAppLayoutEnabled() and vectorPreferences.isNewAppLayoutEnabled() exist now, there is a risk of using the former instead of the latter, especially now that we have many open PR on the subject. Maybe rename the later to something else to force a compilation error on existing PR.

Something like vectorFeatures.isNewAppLayoutFeatureEnabled(). Also maybe document it to tell the developer that they may want to use vectorPreferences.isNewAppLayoutEnabled() instead, to take care of the labs settings.

I admit this is quite ugly...

@@ -63,6 +65,7 @@ class VectorPreferences @Inject constructor(
const val SETTINGS_BACKGROUND_SYNC_PREFERENCE_KEY = "SETTINGS_BACKGROUND_SYNC_PREFERENCE_KEY"
const val SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY = "SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY"
const val SETTINGS_LABS_PREFERENCE_KEY = "SETTINGS_LABS_PREFERENCE_KEY"
const val SETTINGS_LABS_NEW_APP_LAYOUT_KEY = "SETTINGS_LABS_ENABLE_NEW_LAYOUT"
Copy link
Member

Choose a reason for hiding this comment

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

generally the val and the string has the same content (sort of convention, which is nice when looking across the whole codebase for the string), so maybe change to

Suggested change
const val SETTINGS_LABS_NEW_APP_LAYOUT_KEY = "SETTINGS_LABS_ENABLE_NEW_LAYOUT"
const val SETTINGS_LABS_NEW_APP_LAYOUT_KEY = "SETTINGS_LABS_NEW_APP_LAYOUT_KEY"

Do not forget to also change on vector_settings_labs.xml

@@ -152,7 +152,7 @@ class ElementRobot {
}

fun signout(expectSignOutWarning: Boolean) {
if (features.isNewAppLayoutEnabled()) {
if (features.isNewAppLayoutFeatureEnabled()) {
Copy link
Contributor Author

@ericdecanini ericdecanini Sep 6, 2022

Choose a reason for hiding this comment

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

Now that we have it as a labs flag, we can take an approach of making the checks on one layout, enabling the labs flag with the robot and making the checks on the new version. I'll do this in #7020 as to not clutter this pr

Copy link
Member

Choose a reason for hiding this comment

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

OK, good idea! Thanks

@ericdecanini ericdecanini requested a review from bmarty September 6, 2022 14:09
* This is only to enable if the labs flag should be visible and effective
* If on the client-side you want functionality that should be enabled with the new layout,
* use [VectorPreferences.isNewAppLayoutEnabled] instead
*/
Copy link
Member

Choose a reason for hiding this comment

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

👍

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.

I think at some places we want to check the labs flag. Can you double check?

@@ -120,7 +120,7 @@ class HomeActivityViewModel @AssistedInject constructor(

private fun observeReleaseNotes() = withState { state ->
// we don't want to show release notes for new users or after relogin
if (state.authenticationDescription == null && vectorFeatures.isNewAppLayoutEnabled()) {
if (state.authenticationDescription == null && vectorFeatures.isNewAppLayoutFeatureEnabled()) {
Copy link
Member

Choose a reason for hiding this comment

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

so we want to check the labs flag here, no?

}

findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)?.let { pref ->
pref.isVisible = !vectorFeatures.isNewAppLayoutEnabled()
pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled()
Copy link
Member

Choose a reason for hiding this comment

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

same, we want to check the labs flag here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What we should do probably here is make it visible depending on the feature flag, and make it enabled depending on the labs flag

Copy link
Member

Choose a reason for hiding this comment

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

OK, good idea.

@@ -102,7 +102,7 @@ class VectorSettingsPreferencesFragment :
}

findPreference<Preference>(VectorPreferences.SETTINGS_PREF_SPACE_CATEGORY)!!.let { pref ->
pref.isVisible = !vectorFeatures.isNewAppLayoutEnabled()
pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled()
Copy link
Member

Choose a reason for hiding this comment

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

same, we want to check the labs flag here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

@ericdecanini ericdecanini requested a review from bmarty September 6, 2022 15:32
@@ -103,6 +103,7 @@ class VectorSettingsPreferencesFragment :

findPreference<Preference>(VectorPreferences.SETTINGS_PREF_SPACE_CATEGORY)!!.let { pref ->
pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled()
pref.isEnabled = !vectorPreferences.isNewAppLayoutEnabled()
Copy link
Member

Choose a reason for hiding this comment

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

This has to be refreshed as well (like in configureUnreadNotificationsAsTabPreference()). Maybe rename configureUnreadNotificationsAsTabPreference() and use it to refresh all pref enable state?

Copy link
Member

Choose a reason for hiding this comment

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

sorry, please ignore, this is not the same Fragment.

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.

One more important remark about the drawer.

@@ -217,7 +217,7 @@ class HomeActivity :
roomListSharedActionViewModel = viewModelProvider[RoomListSharedActionViewModel::class.java]
views.drawerLayout.addDrawerListener(drawerListener)
if (isFirstCreation()) {
if (vectorFeatures.isNewAppLayoutEnabled()) {
if (vectorPreferences.isNewAppLayoutEnabled()) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we want to unlock the drawer in the else block, since this is now a runtime setting.

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!

@@ -103,6 +103,7 @@ class VectorSettingsPreferencesFragment :

findPreference<Preference>(VectorPreferences.SETTINGS_PREF_SPACE_CATEGORY)!!.let { pref ->
pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled()
pref.isEnabled = !vectorPreferences.isNewAppLayoutEnabled()
Copy link
Member

Choose a reason for hiding this comment

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

sorry, please ignore, this is not the same Fragment.

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!

@bmarty
Copy link
Member

bmarty commented Sep 7, 2022

@ericdecanini can you check the failing test checkCantVerifyPopup locally please?

@ericdecanini ericdecanini added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Sep 7, 2022
@bmarty bmarty disabled auto-merge September 8, 2022 08:57

class ElementRobot(
private val labsPreferences: LabFeaturesPreferences = LabFeaturesPreferences(false)
) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you can invoke the constructor in UiAllScreensSanityTest this way:

    private val elementRobot = ElementRobot(
            LabFeaturesPreferences(
                    InstrumentationRegistry.getInstrumentation()
                            .targetContext
                            .resources
                            .getBoolean(R.bool.settings_labs_new_app_layout_default)
            )
    )

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 8, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@bmarty bmarty merged commit de17c47 into develop Sep 8, 2022
@bmarty bmarty deleted the feature/eric/new-layout-labs branch September 8, 2022 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants