From 24509543b9e2cab1151106b0b29554fff3820fdf Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 6 Sep 2022 12:48:03 +0200 Subject: [PATCH 01/12] Replaces feature flag with labs flag --- library/ui-strings/src/main/res/values/strings.xml | 3 +++ vector-config/src/main/res/values/config-settings.xml | 1 + .../features/debug/features/DebugFeaturesStateFactory.kt | 5 ----- .../app/features/debug/features/DebugVectorFeatures.kt | 4 ---- .../im/vector/app/core/platform/VectorBaseActivity.kt | 2 +- .../main/java/im/vector/app/features/VectorFeatures.kt | 2 -- .../main/java/im/vector/app/features/home/HomeActivity.kt | 8 ++++---- .../im/vector/app/features/settings/VectorPreferences.kt | 8 ++++++++ .../im/vector/app/features/spaces/SpaceListFragment.kt | 8 ++++---- vector/src/main/res/xml/vector_settings_labs.xml | 6 ++++++ 10 files changed, 27 insertions(+), 20 deletions(-) diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 1317ec3c65..cc63ceb2a9 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -438,6 +438,9 @@ Activity A - Z + Enable new layout + A simplified Element with optional tabs + Invites Low priority diff --git a/vector-config/src/main/res/values/config-settings.xml b/vector-config/src/main/res/values/config-settings.xml index b2cd21c3de..1701fd45b0 100755 --- a/vector-config/src/main/res/values/config-settings.xml +++ b/vector-config/src/main/res/values/config-settings.xml @@ -38,6 +38,7 @@ false + false true false diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt index c127e3aed6..607b99ba61 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt @@ -85,11 +85,6 @@ class DebugFeaturesStateFactory @Inject constructor( key = DebugFeatureKeys.startDmOnFirstMsg, factory = VectorFeatures::shouldStartDmOnFirstMessage ), - createBooleanFeature( - label = "Enable New App Layout", - key = DebugFeatureKeys.newAppLayoutEnabled, - factory = VectorFeatures::isNewAppLayoutEnabled - ), createBooleanFeature( label = "Enable New Device Management", key = DebugFeatureKeys.newDeviceManagementEnabled, diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index 003b9b8084..8fa201dcf7 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -76,9 +76,6 @@ class DebugVectorFeatures( override fun shouldStartDmOnFirstMessage(): Boolean = read(DebugFeatureKeys.startDmOnFirstMsg) ?: vectorFeatures.shouldStartDmOnFirstMessage() - override fun isNewAppLayoutEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled) - ?: vectorFeatures.isNewAppLayoutEnabled() - override fun isNewDeviceManagementEnabled(): Boolean = read(DebugFeatureKeys.newDeviceManagementEnabled) ?: vectorFeatures.isNewDeviceManagementEnabled() @@ -141,6 +138,5 @@ object DebugFeatureKeys { val screenSharing = booleanPreferencesKey("screen-sharing") val forceUsageOfOpusEncoder = booleanPreferencesKey("force-usage-of-opus-encoder") val startDmOnFirstMsg = booleanPreferencesKey("start-dm-on-first-msg") - val newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled") val newDeviceManagementEnabled = booleanPreferencesKey("new-device-management-enabled") } diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt index 4e7b174772..c2c66ae69e 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt @@ -249,7 +249,7 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver initUiAndData() - if (vectorFeatures.isNewAppLayoutEnabled()) { + if (vectorPreferences.isNewAppLayoutEnabled()) { tryOrNull { // Add to XML theme when feature flag is removed val toolbarBackground = MaterialColors.getColor(views.root, R.attr.vctr_toolbar_background) window.statusBarColor = toolbarBackground diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index 951cca6735..97a2c954db 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -33,7 +33,6 @@ interface VectorFeatures { fun isLocationSharingEnabled(): Boolean fun forceUsageOfOpusEncoder(): Boolean fun shouldStartDmOnFirstMessage(): Boolean - fun isNewAppLayoutEnabled(): Boolean fun isNewDeviceManagementEnabled(): Boolean } @@ -50,6 +49,5 @@ class DefaultVectorFeatures : VectorFeatures { override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING override fun forceUsageOfOpusEncoder(): Boolean = false override fun shouldStartDmOnFirstMessage(): Boolean = false - override fun isNewAppLayoutEnabled(): Boolean = true override fun isNewDeviceManagementEnabled(): Boolean = false } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt index 2a8390c93c..7665f95a40 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt @@ -200,7 +200,7 @@ class HomeActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - isNewAppLayoutEnabled = vectorFeatures.isNewAppLayoutEnabled() + isNewAppLayoutEnabled = vectorPreferences.isNewAppLayoutEnabled() analyticsScreenName = MobileScreen.ScreenName.Home supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false) unifiedPushHelper.register(this) { @@ -216,7 +216,7 @@ class HomeActivity : roomListSharedActionViewModel = viewModelProvider[RoomListSharedActionViewModel::class.java] views.drawerLayout.addDrawerListener(drawerListener) if (isFirstCreation()) { - if (vectorFeatures.isNewAppLayoutEnabled()) { + if (vectorPreferences.isNewAppLayoutEnabled()) { views.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) replaceFragment(views.homeDetailFragmentContainer, NewHomeDetailFragment::class.java) } else { @@ -575,12 +575,12 @@ class HomeActivity : } private fun checkNewAppLayoutFlagChange() { - if (buildMeta.isDebug && vectorFeatures.isNewAppLayoutEnabled() != isNewAppLayoutEnabled) { + if (buildMeta.isDebug && vectorPreferences.isNewAppLayoutEnabled() != isNewAppLayoutEnabled) { restart() } } - override fun getMenuRes() = if (vectorFeatures.isNewAppLayoutEnabled()) R.menu.menu_new_home else R.menu.menu_home + override fun getMenuRes() = if (vectorPreferences.isNewAppLayoutEnabled()) R.menu.menu_new_home else R.menu.menu_home override fun handlePrepareMenu(menu: Menu) { menu.findItem(R.id.menu_home_init_sync_legacy).isVisible = vectorPreferences.developerMode() diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index cefbe64d9d..4eb67891b8 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -63,6 +63,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" const val SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY" const val SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY" const val SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY" @@ -1146,6 +1147,13 @@ class VectorPreferences @Inject constructor( return spaceIdsJoined?.takeIf { it.isNotEmpty() }?.split(",").orEmpty() } + /** + * Indicates whether or not new app layout is enabled + */ + fun isNewAppLayoutEnabled(): Boolean { + return defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default)) + } + fun showLiveSenderInfo(): Boolean { return defaultPrefs.getBoolean(SETTINGS_TIMELINE_SHOW_LIVE_SENDER_INFO, getDefault(R.bool.settings_timeline_show_live_sender_info_default)) } diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceListFragment.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceListFragment.kt index 0153d64df7..27a118e4dc 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceListFragment.kt @@ -35,11 +35,11 @@ import im.vector.app.core.extensions.configureWith import im.vector.app.core.platform.StateView import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentSpaceListBinding -import im.vector.app.features.VectorFeatures import im.vector.app.features.home.HomeActivitySharedAction import im.vector.app.features.home.HomeSharedActionViewModel import im.vector.app.features.home.room.list.actions.RoomListSharedAction import im.vector.app.features.home.room.list.actions.RoomListSharedActionViewModel +import im.vector.app.features.settings.VectorPreferences import org.matrix.android.sdk.api.session.room.model.RoomSummary import javax.inject.Inject @@ -58,7 +58,7 @@ class SpaceListFragment : @Inject lateinit var spaceController: SpaceSummaryController @Inject lateinit var newSpaceController: NewSpaceSummaryController - @Inject lateinit var vectorFeatures: VectorFeatures + @Inject lateinit var vectorPreferences: VectorPreferences private lateinit var homeActivitySharedActionViewModel: HomeSharedActionViewModel private lateinit var roomListSharedActionViewModel: RoomListSharedActionViewModel @@ -79,7 +79,7 @@ class SpaceListFragment : } private fun setupSpaceController() { - if (vectorFeatures.isNewAppLayoutEnabled()) { + if (vectorPreferences.isNewAppLayoutEnabled()) { newSpaceController.callback = this views.groupListView.configureWith(newSpaceController) } else { @@ -169,7 +169,7 @@ class SpaceListFragment : else -> Unit } - if (vectorFeatures.isNewAppLayoutEnabled()) { + if (vectorPreferences.isNewAppLayoutEnabled()) { newSpaceController.update(state) } else { spaceController.update(state) diff --git a/vector/src/main/res/xml/vector_settings_labs.xml b/vector/src/main/res/xml/vector_settings_labs.xml index 80b71a1f75..3f7c74af4b 100644 --- a/vector/src/main/res/xml/vector_settings_labs.xml +++ b/vector/src/main/res/xml/vector_settings_labs.xml @@ -83,4 +83,10 @@ android:summary="@string/labs_enable_element_call_permission_shortcuts_summary" android:title="@string/labs_enable_element_call_permission_shortcuts" /> + + From fbe5918f30f635f08b295a0a2d5e4d0db5c29060 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 6 Sep 2022 12:52:48 +0200 Subject: [PATCH 02/12] Adds changelog file --- changelog.d/7038.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7038.feature diff --git a/changelog.d/7038.feature b/changelog.d/7038.feature new file mode 100644 index 0000000000..b7a0fbce6e --- /dev/null +++ b/changelog.d/7038.feature @@ -0,0 +1 @@ +Adds New App Layout into Labs From a851b0aa96040778ea17bf4891da1e9fc35c7f7e Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 6 Sep 2022 13:31:57 +0200 Subject: [PATCH 03/12] Fixes lint error --- .../java/im/vector/app/features/settings/VectorPreferences.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 4eb67891b8..1b92016b7a 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -1148,7 +1148,7 @@ class VectorPreferences @Inject constructor( } /** - * Indicates whether or not new app layout is enabled + * Indicates whether or not new app layout is enabled. */ fun isNewAppLayoutEnabled(): Boolean { return defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default)) From 5e0d84bb25eb699536c7ae94f2f980a0de7f5111 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 6 Sep 2022 14:42:54 +0200 Subject: [PATCH 04/12] Uses referenced default value for new layout labs flag --- vector/src/main/res/xml/vector_settings_labs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/res/xml/vector_settings_labs.xml b/vector/src/main/res/xml/vector_settings_labs.xml index 3f7c74af4b..e06613f85b 100644 --- a/vector/src/main/res/xml/vector_settings_labs.xml +++ b/vector/src/main/res/xml/vector_settings_labs.xml @@ -84,7 +84,7 @@ android:title="@string/labs_enable_element_call_permission_shortcuts" /> From 468c7b600cb62807364fe404df6f638f30c3daed Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 6 Sep 2022 15:30:19 +0200 Subject: [PATCH 05/12] Re-adds feature flag --- .../features/debug/features/DebugFeaturesStateFactory.kt | 5 +++++ .../app/features/debug/features/DebugVectorFeatures.kt | 4 ++++ .../src/main/java/im/vector/app/features/VectorFeatures.kt | 2 ++ .../im/vector/app/features/settings/VectorPreferences.kt | 5 ++++- .../app/features/settings/VectorSettingsLabsFragment.kt | 6 ++++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt index 607b99ba61..c127e3aed6 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt @@ -85,6 +85,11 @@ class DebugFeaturesStateFactory @Inject constructor( key = DebugFeatureKeys.startDmOnFirstMsg, factory = VectorFeatures::shouldStartDmOnFirstMessage ), + createBooleanFeature( + label = "Enable New App Layout", + key = DebugFeatureKeys.newAppLayoutEnabled, + factory = VectorFeatures::isNewAppLayoutEnabled + ), createBooleanFeature( label = "Enable New Device Management", key = DebugFeatureKeys.newDeviceManagementEnabled, diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index 8fa201dcf7..003b9b8084 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -76,6 +76,9 @@ class DebugVectorFeatures( override fun shouldStartDmOnFirstMessage(): Boolean = read(DebugFeatureKeys.startDmOnFirstMsg) ?: vectorFeatures.shouldStartDmOnFirstMessage() + override fun isNewAppLayoutEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled) + ?: vectorFeatures.isNewAppLayoutEnabled() + override fun isNewDeviceManagementEnabled(): Boolean = read(DebugFeatureKeys.newDeviceManagementEnabled) ?: vectorFeatures.isNewDeviceManagementEnabled() @@ -138,5 +141,6 @@ object DebugFeatureKeys { val screenSharing = booleanPreferencesKey("screen-sharing") val forceUsageOfOpusEncoder = booleanPreferencesKey("force-usage-of-opus-encoder") val startDmOnFirstMsg = booleanPreferencesKey("start-dm-on-first-msg") + val newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled") val newDeviceManagementEnabled = booleanPreferencesKey("new-device-management-enabled") } diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index 97a2c954db..951cca6735 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -33,6 +33,7 @@ interface VectorFeatures { fun isLocationSharingEnabled(): Boolean fun forceUsageOfOpusEncoder(): Boolean fun shouldStartDmOnFirstMessage(): Boolean + fun isNewAppLayoutEnabled(): Boolean fun isNewDeviceManagementEnabled(): Boolean } @@ -49,5 +50,6 @@ class DefaultVectorFeatures : VectorFeatures { override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING override fun forceUsageOfOpusEncoder(): Boolean = false override fun shouldStartDmOnFirstMessage(): Boolean = false + override fun isNewAppLayoutEnabled(): Boolean = true override fun isNewDeviceManagementEnabled(): Boolean = false } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 1b92016b7a..483b246595 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -27,6 +27,7 @@ import im.vector.app.R import im.vector.app.core.di.DefaultSharedPreferences import im.vector.app.core.resources.BuildMeta import im.vector.app.core.time.Clock +import im.vector.app.features.VectorFeatures import im.vector.app.features.disclaimer.SHARED_PREF_KEY import im.vector.app.features.home.ShortcutsHandler import im.vector.app.features.homeserver.ServerUrlsRepository @@ -39,6 +40,7 @@ class VectorPreferences @Inject constructor( private val context: Context, private val clock: Clock, private val buildMeta: BuildMeta, + private val vectorFeatures: VectorFeatures, ) { companion object { @@ -1151,7 +1153,8 @@ class VectorPreferences @Inject constructor( * Indicates whether or not new app layout is enabled. */ fun isNewAppLayoutEnabled(): Boolean { - return defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default)) + return vectorFeatures.isNewAppLayoutEnabled() && + defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default)) } fun showLiveSenderInfo(): Boolean { diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt index eb7864a89d..f43add508c 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt @@ -27,6 +27,7 @@ import im.vector.app.R import im.vector.app.core.preference.VectorSwitchPreference import im.vector.app.features.MainActivity import im.vector.app.features.MainActivityArgs +import im.vector.app.features.VectorFeatures import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.room.threads.ThreadsManager import org.matrix.android.sdk.api.settings.LightweightSettingsStorage @@ -39,6 +40,7 @@ class VectorSettingsLabsFragment : @Inject lateinit var vectorPreferences: VectorPreferences @Inject lateinit var lightweightSettingsStorage: LightweightSettingsStorage @Inject lateinit var threadsManager: ThreadsManager + @Inject lateinit var vectorFeatures: VectorFeatures override var titleRes = R.string.room_settings_labs_pref_title override val preferenceXmlRes = R.xml.vector_settings_labs @@ -72,6 +74,10 @@ class VectorSettingsLabsFragment : true } } + + findPreference(VectorPreferences.SETTINGS_LABS_NEW_APP_LAYOUT_KEY)?.let { pref -> + pref.isVisible = vectorFeatures.isNewAppLayoutEnabled() + } } /** From b7efd6384cd39298f0ba62b395d4290c234e16ef Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 6 Sep 2022 16:07:12 +0200 Subject: [PATCH 06/12] Changes vector feature preference key and function name for clarity --- .../java/im/vector/app/ui/robot/ElementRobot.kt | 2 +- .../debug/features/DebugFeaturesStateFactory.kt | 2 +- .../features/debug/features/DebugVectorFeatures.kt | 4 ++-- .../java/im/vector/app/features/VectorFeatures.kt | 11 +++++++++-- .../vector/app/features/home/HomeActivityViewModel.kt | 2 +- .../vector/app/features/settings/VectorPreferences.kt | 4 ++-- .../features/settings/VectorSettingsLabsFragment.kt | 4 ++-- .../settings/VectorSettingsPreferencesFragment.kt | 2 +- vector/src/main/res/xml/vector_settings_labs.xml | 2 +- 9 files changed, 20 insertions(+), 13 deletions(-) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt index 528589d616..2e87a85e59 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt @@ -152,7 +152,7 @@ class ElementRobot { } fun signout(expectSignOutWarning: Boolean) { - if (features.isNewAppLayoutEnabled()) { + if (features.isNewAppLayoutFeatureEnabled()) { onView(withId((R.id.avatar))) .perform(click()) waitUntilActivityVisible { diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt index c127e3aed6..9b2711a8c3 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt @@ -88,7 +88,7 @@ class DebugFeaturesStateFactory @Inject constructor( createBooleanFeature( label = "Enable New App Layout", key = DebugFeatureKeys.newAppLayoutEnabled, - factory = VectorFeatures::isNewAppLayoutEnabled + factory = VectorFeatures::isNewAppLayoutFeatureEnabled ), createBooleanFeature( label = "Enable New Device Management", diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index 003b9b8084..bb4cae3201 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -76,8 +76,8 @@ class DebugVectorFeatures( override fun shouldStartDmOnFirstMessage(): Boolean = read(DebugFeatureKeys.startDmOnFirstMsg) ?: vectorFeatures.shouldStartDmOnFirstMessage() - override fun isNewAppLayoutEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled) - ?: vectorFeatures.isNewAppLayoutEnabled() + override fun isNewAppLayoutFeatureEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled) + ?: vectorFeatures.isNewAppLayoutFeatureEnabled() override fun isNewDeviceManagementEnabled(): Boolean = read(DebugFeatureKeys.newDeviceManagementEnabled) ?: vectorFeatures.isNewDeviceManagementEnabled() diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index 951cca6735..e021d608cb 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -18,6 +18,7 @@ package im.vector.app.features import im.vector.app.config.Config import im.vector.app.config.OnboardingVariant +import im.vector.app.features.settings.VectorPreferences interface VectorFeatures { @@ -33,7 +34,13 @@ interface VectorFeatures { fun isLocationSharingEnabled(): Boolean fun forceUsageOfOpusEncoder(): Boolean fun shouldStartDmOnFirstMessage(): Boolean - fun isNewAppLayoutEnabled(): Boolean + + /** + * 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 + */ + fun isNewAppLayoutFeatureEnabled(): Boolean fun isNewDeviceManagementEnabled(): Boolean } @@ -50,6 +57,6 @@ class DefaultVectorFeatures : VectorFeatures { override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING override fun forceUsageOfOpusEncoder(): Boolean = false override fun shouldStartDmOnFirstMessage(): Boolean = false - override fun isNewAppLayoutEnabled(): Boolean = true + override fun isNewAppLayoutFeatureEnabled(): Boolean = true override fun isNewDeviceManagementEnabled(): Boolean = false } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt index dd54285fb5..156c1fca2f 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt @@ -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()) { releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown -> if (!isAppLayoutOnboardingShown) { releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true) diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 529a6d9b14..fca931eaef 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -65,7 +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" + const val SETTINGS_LABS_NEW_APP_LAYOUT_KEY = "SETTINGS_LABS_NEW_APP_LAYOUT_KEY" const val SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY" const val SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY" const val SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY" @@ -1158,7 +1158,7 @@ class VectorPreferences @Inject constructor( * Indicates whether or not new app layout is enabled. */ fun isNewAppLayoutEnabled(): Boolean { - return vectorFeatures.isNewAppLayoutEnabled() && + return vectorFeatures.isNewAppLayoutFeatureEnabled() && defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default)) } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt index 7e414fc4ec..56f884d15c 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt @@ -76,11 +76,11 @@ class VectorSettingsLabsFragment : } findPreference(VectorPreferences.SETTINGS_LABS_NEW_APP_LAYOUT_KEY)?.let { pref -> - pref.isVisible = vectorFeatures.isNewAppLayoutEnabled() + pref.isVisible = vectorFeatures.isNewAppLayoutFeatureEnabled() } findPreference(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)?.let { pref -> - pref.isVisible = !vectorFeatures.isNewAppLayoutEnabled() + pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled() } } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt index 135c25cd8d..d692580931 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt @@ -102,7 +102,7 @@ class VectorSettingsPreferencesFragment : } findPreference(VectorPreferences.SETTINGS_PREF_SPACE_CATEGORY)!!.let { pref -> - pref.isVisible = !vectorFeatures.isNewAppLayoutEnabled() + pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled() } // Url preview diff --git a/vector/src/main/res/xml/vector_settings_labs.xml b/vector/src/main/res/xml/vector_settings_labs.xml index e06613f85b..f61d5fe7bc 100644 --- a/vector/src/main/res/xml/vector_settings_labs.xml +++ b/vector/src/main/res/xml/vector_settings_labs.xml @@ -85,7 +85,7 @@ From d77ce27953e541dffcd17a49b500d32df3eaea96 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 6 Sep 2022 17:31:52 +0200 Subject: [PATCH 07/12] Fixes wrong use of feature flag instead of labs flag --- .../java/im/vector/app/features/home/HomeActivityViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt index 156c1fca2f..2c8ee48d39 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt @@ -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.isNewAppLayoutFeatureEnabled()) { + if (state.authenticationDescription == null && vectorPreferences.isNewAppLayoutEnabled()) { releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown -> if (!isAppLayoutOnboardingShown) { releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true) From 9564c8f144731818eab7bf79a4375cbafb107c24 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 6 Sep 2022 17:32:08 +0200 Subject: [PATCH 08/12] Changes some preferences to be enabled or disabled by labs flag --- .../settings/VectorSettingsLabsFragment.kt | 17 +++++++++++++++++ .../VectorSettingsPreferencesFragment.kt | 1 + 2 files changed, 18 insertions(+) diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt index 56f884d15c..18bc35f72a 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt @@ -77,10 +77,20 @@ class VectorSettingsLabsFragment : findPreference(VectorPreferences.SETTINGS_LABS_NEW_APP_LAYOUT_KEY)?.let { pref -> pref.isVisible = vectorFeatures.isNewAppLayoutFeatureEnabled() + + pref.onPreferenceClickListener = Preference.OnPreferenceClickListener { + onNewLayoutPreferenceClicked() + true + } } + configureUnreadNotificationsAsTabPreference() + } + + private fun configureUnreadNotificationsAsTabPreference() { findPreference(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)?.let { pref -> pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled() + pref.isEnabled = !vectorPreferences.isNewAppLayoutEnabled() } } @@ -123,4 +133,11 @@ class VectorSettingsLabsFragment : displayLoadingView() MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true)) } + + /** + * Action when new layout preference switch is actually clicked. + */ + private fun onNewLayoutPreferenceClicked() { + configureUnreadNotificationsAsTabPreference() + } } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt index d692580931..3c8ec56713 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt @@ -103,6 +103,7 @@ class VectorSettingsPreferencesFragment : findPreference(VectorPreferences.SETTINGS_PREF_SPACE_CATEGORY)!!.let { pref -> pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled() + pref.isEnabled = !vectorPreferences.isNewAppLayoutEnabled() } // Url preview From 6c2363471d1efd041754e11b0ead7140124ec98a Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 6 Sep 2022 18:01:36 +0200 Subject: [PATCH 09/12] Unlocks the drawer layout when not new layout --- vector/src/main/java/im/vector/app/features/home/HomeActivity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt index 6880b85df4..58ff881b7d 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt @@ -223,6 +223,7 @@ class HomeActivity : } else { replaceFragment(views.homeDetailFragmentContainer, HomeDetailFragment::class.java) replaceFragment(views.homeDrawerFragmentContainer, HomeDrawerFragment::class.java) + views.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED) } } From afbb76f34185609b509ab59c90cd0428e051e5c5 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Wed, 7 Sep 2022 08:36:52 +0200 Subject: [PATCH 10/12] Fixes lint error --- vector/src/main/java/im/vector/app/features/VectorFeatures.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index e021d608cb..dbdb0ba1c7 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -36,9 +36,9 @@ interface VectorFeatures { fun shouldStartDmOnFirstMessage(): Boolean /** - * This is only to enable if the labs flag should be visible and effective + * 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 + * use [VectorPreferences.isNewAppLayoutEnabled] instead. */ fun isNewAppLayoutFeatureEnabled(): Boolean fun isNewDeviceManagementEnabled(): Boolean From 6badbe738d1659617665953d460a1bd2131b1395 Mon Sep 17 00:00:00 2001 From: NIkita Fedrunov Date: Thu, 8 Sep 2022 12:09:33 +0200 Subject: [PATCH 11/12] robots are not checking feature flag for newAppLayout --- .../im/vector/app/ui/robot/ElementRobot.kt | 29 +++++++++---------- .../im/vector/app/ui/robot/NewRoomRobot.kt | 6 ++-- .../im/vector/app/ui/robot/RoomListRobot.kt | 10 +++---- .../settings/labs/LabFeaturesPreferences.kt | 19 ++++++++++++ .../vector/app/ui/robot/space/SpaceRobot.kt | 11 +++---- 5 files changed, 47 insertions(+), 28 deletions(-) create mode 100644 vector-app/src/androidTest/java/im/vector/app/ui/robot/settings/labs/LabFeaturesPreferences.kt diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt index 48a435c877..b70fcfec25 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt @@ -37,8 +37,6 @@ import im.vector.app.espresso.tools.clickOnPreference import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilViewVisible -import im.vector.app.features.DefaultVectorFeatures -import im.vector.app.features.VectorFeatures import im.vector.app.features.createdirect.CreateDirectRoomActivity import im.vector.app.features.home.HomeActivity import im.vector.app.features.onboarding.OnboardingActivity @@ -46,13 +44,14 @@ import im.vector.app.features.settings.VectorSettingsActivity import im.vector.app.initialSyncIdlingResource import im.vector.app.ui.robot.settings.SettingsRobot import im.vector.app.ui.robot.settings.labs.LabFeature +import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences import im.vector.app.ui.robot.space.SpaceRobot import im.vector.app.withIdlingResource import timber.log.Timber -class ElementRobot { - private val features: VectorFeatures = DefaultVectorFeatures() - +class ElementRobot( + private val labsPreferences: LabFeaturesPreferences = LabFeaturesPreferences(false) +) { fun onboarding(block: OnboardingRobot.() -> Unit) { block(OnboardingRobot()) } @@ -83,7 +82,7 @@ class ElementRobot { } fun settings(shouldGoBack: Boolean = true, block: SettingsRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { onView(withId((R.id.avatar))).perform(click()) } else { openDrawer() @@ -96,7 +95,7 @@ class ElementRobot { } fun newDirectMessage(block: NewDirectMessageRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.newLayoutCreateChatButton) waitUntilDialogVisible(withId(R.id.start_chat)) clickOn(R.id.start_chat) @@ -111,29 +110,29 @@ class ElementRobot { closeSoftKeyboard() block(NewDirectMessageRobot()) pressBack() - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { pressBack() // close create dialog } waitUntilViewVisible(withId(R.id.roomListContainer)) } fun newRoom(block: NewRoomRobot.() -> Unit) { - if (!features.isNewAppLayoutEnabled()) { + if (!labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.bottom_action_rooms) } - RoomListRobot().newRoom { block() } - if (features.isNewAppLayoutEnabled()) { + RoomListRobot(labsPreferences).newRoom { block() } + if (labsPreferences.isNewAppLayoutEnabled) { pressBack() // close create dialog } waitUntilViewVisible(withId(R.id.roomListContainer)) } fun roomList(block: RoomListRobot.() -> Unit) { - if (!features.isNewAppLayoutEnabled()) { + if (!labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.bottom_action_rooms) } - block(RoomListRobot()) + block(RoomListRobot(labsPreferences)) waitUntilViewVisible(withId(R.id.roomListContainer)) } @@ -174,7 +173,7 @@ class ElementRobot { } fun signout(expectSignOutWarning: Boolean) { - if (features.isNewAppLayoutFeatureEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { onView(withId((R.id.avatar))) .perform(click()) waitUntilActivityVisible { @@ -224,7 +223,7 @@ class ElementRobot { } fun space(block: SpaceRobot.() -> Unit) { - block(SpaceRobot()) + block(SpaceRobot(labsPreferences)) } } diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt index 3d82fa4a65..55142d128c 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt @@ -23,14 +23,16 @@ import im.vector.app.R import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.features.DefaultVectorFeatures import im.vector.app.features.VectorFeatures +import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences class NewRoomRobot( - var createdRoom: Boolean = false + var createdRoom: Boolean = false, + private val labsPreferences: LabFeaturesPreferences ) { private val features: VectorFeatures = DefaultVectorFeatures() fun createNewRoom(block: CreateNewRoomRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { clickOn(R.string.create_new_room) } waitUntilViewVisible(withId(R.id.createRoomForm)) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt index 71ccad0870..e4984aeed0 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt @@ -28,12 +28,10 @@ import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import im.vector.app.R import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.espresso.tools.waitUntilDialogVisible -import im.vector.app.features.DefaultVectorFeatures -import im.vector.app.features.VectorFeatures import im.vector.app.features.roomdirectory.RoomDirectoryActivity +import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences -class RoomListRobot { - private val features: VectorFeatures = DefaultVectorFeatures() +class RoomListRobot(private val labsPreferences: LabFeaturesPreferences) { fun openRoom(roomName: String, block: RoomDetailRobot.() -> Unit) { clickOn(roomName) @@ -53,7 +51,7 @@ class RoomListRobot { } fun newRoom(block: NewRoomRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.newLayoutCreateChatButton) waitUntilDialogVisible(ViewMatchers.withId(R.id.create_room)) clickOn(R.id.create_room) @@ -63,7 +61,7 @@ class RoomListRobot { BaristaVisibilityAssertions.assertDisplayed(R.id.publicRoomsList) } } - val newRoomRobot = NewRoomRobot() + val newRoomRobot = NewRoomRobot(false, labsPreferences) block(newRoomRobot) if (!newRoomRobot.createdRoom) { pressBack() diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/settings/labs/LabFeaturesPreferences.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/settings/labs/LabFeaturesPreferences.kt new file mode 100644 index 0000000000..8f36e7ae23 --- /dev/null +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/settings/labs/LabFeaturesPreferences.kt @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.ui.robot.settings.labs + +data class LabFeaturesPreferences(val isNewAppLayoutEnabled: Boolean) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt index 8b69b43107..e8ff58ba6a 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt @@ -30,13 +30,14 @@ import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.features.DefaultVectorFeatures import im.vector.app.features.VectorFeatures +import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences import org.hamcrest.Matchers -class SpaceRobot { +class SpaceRobot(private val labsPreferences: LabFeaturesPreferences) { private val features: VectorFeatures = DefaultVectorFeatures() fun createSpace(isFirstSpace: Boolean, block: SpaceCreateRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.newLayoutOpenSpacesButton) if (isFirstSpace) { waitUntilDialogVisible(ViewMatchers.withId(R.id.spaces_empty_group)) @@ -59,7 +60,7 @@ class SpaceRobot { } fun spaceMenu(spaceName: String, block: SpaceMenuRobot.() -> Unit) { - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { clickOn(R.id.newLayoutOpenSpacesButton) waitUntilDialogVisible(ViewMatchers.withId(R.id.groupListView)) } else { @@ -73,7 +74,7 @@ class SpaceRobot { fun openMenu(spaceName: String) { waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) - if (features.isNewAppLayoutEnabled()) { + if (labsPreferences.isNewAppLayoutEnabled) { Espresso.onView(ViewMatchers.withId(R.id.groupListView)) .perform( RecyclerViewActions.actionOnItem( @@ -95,7 +96,7 @@ class SpaceRobot { } fun selectSpace(spaceName: String) { - if (!features.isNewAppLayoutEnabled()) { + if (!labsPreferences.isNewAppLayoutEnabled) { openDrawer() waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) } From 2ab0343e4f879131226b67b4c740d1e160f16b3b Mon Sep 17 00:00:00 2001 From: NIkita Fedrunov Date: Thu, 8 Sep 2022 12:37:25 +0200 Subject: [PATCH 12/12] sanity test now reads properties value to determine app layout feature status + small fix for tests --- .../java/im/vector/app/ui/UiAllScreensSanityTest.kt | 11 ++++++++++- .../java/im/vector/app/ui/robot/NewRoomRobot.kt | 4 +--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt b/vector-app/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt index ad11d953d4..d4878b8dcc 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt @@ -21,6 +21,7 @@ import androidx.test.espresso.IdlingPolicies import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest +import androidx.test.platform.app.InstrumentationRegistry import androidx.test.rule.GrantPermissionRule import im.vector.app.R import im.vector.app.espresso.tools.ScreenshotFailureRule @@ -28,6 +29,7 @@ import im.vector.app.features.MainActivity import im.vector.app.getString import im.vector.app.ui.robot.ElementRobot import im.vector.app.ui.robot.settings.labs.LabFeature +import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences import im.vector.app.ui.robot.withDeveloperMode import org.junit.Rule import org.junit.Test @@ -49,7 +51,14 @@ class UiAllScreensSanityTest { .around(GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)) .around(ScreenshotFailureRule()) - private val elementRobot = ElementRobot() + private val elementRobot = ElementRobot( + LabFeaturesPreferences( + InstrumentationRegistry.getInstrumentation() + .targetContext + .resources + .getBoolean(R.bool.settings_labs_new_app_layout_default) + ) + ) // Last passing: // 2020-11-09 diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt index 55142d128c..0cea26d5cc 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt @@ -32,9 +32,7 @@ class NewRoomRobot( private val features: VectorFeatures = DefaultVectorFeatures() fun createNewRoom(block: CreateNewRoomRobot.() -> Unit) { - if (labsPreferences.isNewAppLayoutEnabled) { - clickOn(R.string.create_new_room) - } + clickOn(R.string.create_new_room) waitUntilViewVisible(withId(R.id.createRoomForm)) val createNewRoomRobot = CreateNewRoomRobot() block(createNewRoomRobot)