Merge pull request #7038 from vector-im/feature/eric/new-layout-labs

New Layout - Labs Flag (to replace feature flag)
This commit is contained in:
Benoit Marty 2022-09-08 14:35:38 +02:00 committed by GitHub
commit de17c47a7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 127 additions and 49 deletions

1
changelog.d/7038.feature Normal file
View file

@ -0,0 +1 @@
Adds New App Layout into Labs

View file

@ -439,6 +439,9 @@
<string name="home_layout_preferences_sort_activity">Activity</string> <string name="home_layout_preferences_sort_activity">Activity</string>
<string name="home_layout_preferences_sort_name">A - Z</string> <string name="home_layout_preferences_sort_name">A - Z</string>
<string name="labs_enable_new_app_layout_title">Enable new layout</string>
<string name="labs_enable_new_app_layout_summary">A simplified Element with optional tabs</string>
<!-- Home fragment --> <!-- Home fragment -->
<string name="invitations_header">Invites</string> <string name="invitations_header">Invites</string>
<string name="low_priority_header">Low priority</string> <string name="low_priority_header">Low priority</string>

View file

@ -21,6 +21,7 @@ import androidx.test.espresso.IdlingPolicies
import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest import androidx.test.filters.LargeTest
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule import androidx.test.rule.GrantPermissionRule
import im.vector.app.R import im.vector.app.R
import im.vector.app.espresso.tools.ScreenshotFailureRule 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.getString
import im.vector.app.ui.robot.ElementRobot import im.vector.app.ui.robot.ElementRobot
import im.vector.app.ui.robot.settings.labs.LabFeature 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 im.vector.app.ui.robot.withDeveloperMode
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -49,7 +51,14 @@ class UiAllScreensSanityTest {
.around(GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)) .around(GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE))
.around(ScreenshotFailureRule()) .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: // Last passing:
// 2020-11-09 // 2020-11-09

View file

@ -37,8 +37,6 @@ import im.vector.app.espresso.tools.clickOnPreference
import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.espresso.tools.waitUntilActivityVisible
import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilDialogVisible
import im.vector.app.espresso.tools.waitUntilViewVisible 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.createdirect.CreateDirectRoomActivity
import im.vector.app.features.home.HomeActivity import im.vector.app.features.home.HomeActivity
import im.vector.app.features.onboarding.OnboardingActivity 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.initialSyncIdlingResource
import im.vector.app.ui.robot.settings.SettingsRobot 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.LabFeature
import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences
import im.vector.app.ui.robot.space.SpaceRobot import im.vector.app.ui.robot.space.SpaceRobot
import im.vector.app.withIdlingResource import im.vector.app.withIdlingResource
import timber.log.Timber import timber.log.Timber
class ElementRobot { class ElementRobot(
private val features: VectorFeatures = DefaultVectorFeatures() private val labsPreferences: LabFeaturesPreferences = LabFeaturesPreferences(false)
) {
fun onboarding(block: OnboardingRobot.() -> Unit) { fun onboarding(block: OnboardingRobot.() -> Unit) {
block(OnboardingRobot()) block(OnboardingRobot())
} }
@ -83,7 +82,7 @@ class ElementRobot {
} }
fun settings(shouldGoBack: Boolean = true, block: SettingsRobot.() -> Unit) { fun settings(shouldGoBack: Boolean = true, block: SettingsRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) { if (labsPreferences.isNewAppLayoutEnabled) {
onView(withId((R.id.avatar))).perform(click()) onView(withId((R.id.avatar))).perform(click())
} else { } else {
openDrawer() openDrawer()
@ -96,7 +95,7 @@ class ElementRobot {
} }
fun newDirectMessage(block: NewDirectMessageRobot.() -> Unit) { fun newDirectMessage(block: NewDirectMessageRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) { if (labsPreferences.isNewAppLayoutEnabled) {
clickOn(R.id.newLayoutCreateChatButton) clickOn(R.id.newLayoutCreateChatButton)
waitUntilDialogVisible(withId(R.id.start_chat)) waitUntilDialogVisible(withId(R.id.start_chat))
clickOn(R.id.start_chat) clickOn(R.id.start_chat)
@ -111,29 +110,29 @@ class ElementRobot {
closeSoftKeyboard() closeSoftKeyboard()
block(NewDirectMessageRobot()) block(NewDirectMessageRobot())
pressBack() pressBack()
if (features.isNewAppLayoutEnabled()) { if (labsPreferences.isNewAppLayoutEnabled) {
pressBack() // close create dialog pressBack() // close create dialog
} }
waitUntilViewVisible(withId(R.id.roomListContainer)) waitUntilViewVisible(withId(R.id.roomListContainer))
} }
fun newRoom(block: NewRoomRobot.() -> Unit) { fun newRoom(block: NewRoomRobot.() -> Unit) {
if (!features.isNewAppLayoutEnabled()) { if (!labsPreferences.isNewAppLayoutEnabled) {
clickOn(R.id.bottom_action_rooms) clickOn(R.id.bottom_action_rooms)
} }
RoomListRobot().newRoom { block() } RoomListRobot(labsPreferences).newRoom { block() }
if (features.isNewAppLayoutEnabled()) { if (labsPreferences.isNewAppLayoutEnabled) {
pressBack() // close create dialog pressBack() // close create dialog
} }
waitUntilViewVisible(withId(R.id.roomListContainer)) waitUntilViewVisible(withId(R.id.roomListContainer))
} }
fun roomList(block: RoomListRobot.() -> Unit) { fun roomList(block: RoomListRobot.() -> Unit) {
if (!features.isNewAppLayoutEnabled()) { if (!labsPreferences.isNewAppLayoutEnabled) {
clickOn(R.id.bottom_action_rooms) clickOn(R.id.bottom_action_rooms)
} }
block(RoomListRobot()) block(RoomListRobot(labsPreferences))
waitUntilViewVisible(withId(R.id.roomListContainer)) waitUntilViewVisible(withId(R.id.roomListContainer))
} }
@ -174,7 +173,7 @@ class ElementRobot {
} }
fun signout(expectSignOutWarning: Boolean) { fun signout(expectSignOutWarning: Boolean) {
if (features.isNewAppLayoutEnabled()) { if (labsPreferences.isNewAppLayoutEnabled) {
onView(withId((R.id.avatar))) onView(withId((R.id.avatar)))
.perform(click()) .perform(click())
waitUntilActivityVisible<VectorSettingsActivity> { waitUntilActivityVisible<VectorSettingsActivity> {
@ -224,7 +223,7 @@ class ElementRobot {
} }
fun space(block: SpaceRobot.() -> Unit) { fun space(block: SpaceRobot.() -> Unit) {
block(SpaceRobot()) block(SpaceRobot(labsPreferences))
} }
} }

View file

@ -23,16 +23,16 @@ import im.vector.app.R
import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.espresso.tools.waitUntilViewVisible
import im.vector.app.features.DefaultVectorFeatures import im.vector.app.features.DefaultVectorFeatures
import im.vector.app.features.VectorFeatures import im.vector.app.features.VectorFeatures
import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences
class NewRoomRobot( class NewRoomRobot(
var createdRoom: Boolean = false var createdRoom: Boolean = false,
private val labsPreferences: LabFeaturesPreferences
) { ) {
private val features: VectorFeatures = DefaultVectorFeatures() private val features: VectorFeatures = DefaultVectorFeatures()
fun createNewRoom(block: CreateNewRoomRobot.() -> Unit) { fun createNewRoom(block: CreateNewRoomRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) { clickOn(R.string.create_new_room)
clickOn(R.string.create_new_room)
}
waitUntilViewVisible(withId(R.id.createRoomForm)) waitUntilViewVisible(withId(R.id.createRoomForm))
val createNewRoomRobot = CreateNewRoomRobot() val createNewRoomRobot = CreateNewRoomRobot()
block(createNewRoomRobot) block(createNewRoomRobot)

View file

@ -28,12 +28,10 @@ import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import im.vector.app.R import im.vector.app.R
import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.espresso.tools.waitUntilActivityVisible
import im.vector.app.espresso.tools.waitUntilDialogVisible 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.features.roomdirectory.RoomDirectoryActivity
import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences
class RoomListRobot { class RoomListRobot(private val labsPreferences: LabFeaturesPreferences) {
private val features: VectorFeatures = DefaultVectorFeatures()
fun openRoom(roomName: String, block: RoomDetailRobot.() -> Unit) { fun openRoom(roomName: String, block: RoomDetailRobot.() -> Unit) {
clickOn(roomName) clickOn(roomName)
@ -53,7 +51,7 @@ class RoomListRobot {
} }
fun newRoom(block: NewRoomRobot.() -> Unit) { fun newRoom(block: NewRoomRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) { if (labsPreferences.isNewAppLayoutEnabled) {
clickOn(R.id.newLayoutCreateChatButton) clickOn(R.id.newLayoutCreateChatButton)
waitUntilDialogVisible(ViewMatchers.withId(R.id.create_room)) waitUntilDialogVisible(ViewMatchers.withId(R.id.create_room))
clickOn(R.id.create_room) clickOn(R.id.create_room)
@ -63,7 +61,7 @@ class RoomListRobot {
BaristaVisibilityAssertions.assertDisplayed(R.id.publicRoomsList) BaristaVisibilityAssertions.assertDisplayed(R.id.publicRoomsList)
} }
} }
val newRoomRobot = NewRoomRobot() val newRoomRobot = NewRoomRobot(false, labsPreferences)
block(newRoomRobot) block(newRoomRobot)
if (!newRoomRobot.createdRoom) { if (!newRoomRobot.createdRoom) {
pressBack() pressBack()

View file

@ -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)

View file

@ -30,13 +30,14 @@ import im.vector.app.espresso.tools.waitUntilDialogVisible
import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.espresso.tools.waitUntilViewVisible
import im.vector.app.features.DefaultVectorFeatures import im.vector.app.features.DefaultVectorFeatures
import im.vector.app.features.VectorFeatures import im.vector.app.features.VectorFeatures
import im.vector.app.ui.robot.settings.labs.LabFeaturesPreferences
import org.hamcrest.Matchers import org.hamcrest.Matchers
class SpaceRobot { class SpaceRobot(private val labsPreferences: LabFeaturesPreferences) {
private val features: VectorFeatures = DefaultVectorFeatures() private val features: VectorFeatures = DefaultVectorFeatures()
fun createSpace(isFirstSpace: Boolean, block: SpaceCreateRobot.() -> Unit) { fun createSpace(isFirstSpace: Boolean, block: SpaceCreateRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) { if (labsPreferences.isNewAppLayoutEnabled) {
clickOn(R.id.newLayoutOpenSpacesButton) clickOn(R.id.newLayoutOpenSpacesButton)
if (isFirstSpace) { if (isFirstSpace) {
waitUntilDialogVisible(ViewMatchers.withId(R.id.spaces_empty_group)) waitUntilDialogVisible(ViewMatchers.withId(R.id.spaces_empty_group))
@ -59,7 +60,7 @@ class SpaceRobot {
} }
fun spaceMenu(spaceName: String, block: SpaceMenuRobot.() -> Unit) { fun spaceMenu(spaceName: String, block: SpaceMenuRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) { if (labsPreferences.isNewAppLayoutEnabled) {
clickOn(R.id.newLayoutOpenSpacesButton) clickOn(R.id.newLayoutOpenSpacesButton)
waitUntilDialogVisible(ViewMatchers.withId(R.id.groupListView)) waitUntilDialogVisible(ViewMatchers.withId(R.id.groupListView))
} else { } else {
@ -73,7 +74,7 @@ class SpaceRobot {
fun openMenu(spaceName: String) { fun openMenu(spaceName: String) {
waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView))
if (features.isNewAppLayoutEnabled()) { if (labsPreferences.isNewAppLayoutEnabled) {
Espresso.onView(ViewMatchers.withId(R.id.groupListView)) Espresso.onView(ViewMatchers.withId(R.id.groupListView))
.perform( .perform(
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>( RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
@ -95,7 +96,7 @@ class SpaceRobot {
} }
fun selectSpace(spaceName: String) { fun selectSpace(spaceName: String) {
if (!features.isNewAppLayoutEnabled()) { if (!labsPreferences.isNewAppLayoutEnabled) {
openDrawer() openDrawer()
waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView))
} }

View file

@ -38,6 +38,7 @@
<!-- Level 1: Labs --> <!-- Level 1: Labs -->
<bool name="settings_labs_thread_messages_default">false</bool> <bool name="settings_labs_thread_messages_default">false</bool>
<bool name="settings_labs_new_app_layout_default">false</bool>
<bool name="settings_timeline_show_live_sender_info_visible">true</bool> <bool name="settings_timeline_show_live_sender_info_visible">true</bool>
<bool name="settings_timeline_show_live_sender_info_default">false</bool> <bool name="settings_timeline_show_live_sender_info_default">false</bool>
<!-- Level 1: Advanced settings --> <!-- Level 1: Advanced settings -->

View file

@ -88,7 +88,7 @@ class DebugFeaturesStateFactory @Inject constructor(
createBooleanFeature( createBooleanFeature(
label = "Enable New App Layout", label = "Enable New App Layout",
key = DebugFeatureKeys.newAppLayoutEnabled, key = DebugFeatureKeys.newAppLayoutEnabled,
factory = VectorFeatures::isNewAppLayoutEnabled factory = VectorFeatures::isNewAppLayoutFeatureEnabled
), ),
createBooleanFeature( createBooleanFeature(
label = "Enable New Device Management", label = "Enable New Device Management",

View file

@ -76,8 +76,8 @@ class DebugVectorFeatures(
override fun shouldStartDmOnFirstMessage(): Boolean = read(DebugFeatureKeys.startDmOnFirstMsg) override fun shouldStartDmOnFirstMessage(): Boolean = read(DebugFeatureKeys.startDmOnFirstMsg)
?: vectorFeatures.shouldStartDmOnFirstMessage() ?: vectorFeatures.shouldStartDmOnFirstMessage()
override fun isNewAppLayoutEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled) override fun isNewAppLayoutFeatureEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled)
?: vectorFeatures.isNewAppLayoutEnabled() ?: vectorFeatures.isNewAppLayoutFeatureEnabled()
override fun isNewDeviceManagementEnabled(): Boolean = read(DebugFeatureKeys.newDeviceManagementEnabled) override fun isNewDeviceManagementEnabled(): Boolean = read(DebugFeatureKeys.newDeviceManagementEnabled)
?: vectorFeatures.isNewDeviceManagementEnabled() ?: vectorFeatures.isNewDeviceManagementEnabled()

View file

@ -249,7 +249,7 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
initUiAndData() initUiAndData()
if (vectorFeatures.isNewAppLayoutEnabled()) { if (vectorPreferences.isNewAppLayoutEnabled()) {
tryOrNull { // Add to XML theme when feature flag is removed tryOrNull { // Add to XML theme when feature flag is removed
val toolbarBackground = MaterialColors.getColor(views.root, R.attr.vctr_toolbar_background) val toolbarBackground = MaterialColors.getColor(views.root, R.attr.vctr_toolbar_background)
window.statusBarColor = toolbarBackground window.statusBarColor = toolbarBackground

View file

@ -18,6 +18,7 @@ package im.vector.app.features
import im.vector.app.config.Config import im.vector.app.config.Config
import im.vector.app.config.OnboardingVariant import im.vector.app.config.OnboardingVariant
import im.vector.app.features.settings.VectorPreferences
interface VectorFeatures { interface VectorFeatures {
@ -33,7 +34,13 @@ interface VectorFeatures {
fun isLocationSharingEnabled(): Boolean fun isLocationSharingEnabled(): Boolean
fun forceUsageOfOpusEncoder(): Boolean fun forceUsageOfOpusEncoder(): Boolean
fun shouldStartDmOnFirstMessage(): 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 fun isNewDeviceManagementEnabled(): Boolean
} }
@ -50,6 +57,6 @@ class DefaultVectorFeatures : VectorFeatures {
override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING
override fun forceUsageOfOpusEncoder(): Boolean = false override fun forceUsageOfOpusEncoder(): Boolean = false
override fun shouldStartDmOnFirstMessage(): Boolean = false override fun shouldStartDmOnFirstMessage(): Boolean = false
override fun isNewAppLayoutEnabled(): Boolean = true override fun isNewAppLayoutFeatureEnabled(): Boolean = true
override fun isNewDeviceManagementEnabled(): Boolean = false override fun isNewDeviceManagementEnabled(): Boolean = false
} }

View file

@ -201,7 +201,7 @@ class HomeActivity :
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
isNewAppLayoutEnabled = vectorFeatures.isNewAppLayoutEnabled() isNewAppLayoutEnabled = vectorPreferences.isNewAppLayoutEnabled()
analyticsScreenName = MobileScreen.ScreenName.Home analyticsScreenName = MobileScreen.ScreenName.Home
supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false) supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false)
unifiedPushHelper.register(this) { unifiedPushHelper.register(this) {
@ -217,12 +217,13 @@ class HomeActivity :
roomListSharedActionViewModel = viewModelProvider[RoomListSharedActionViewModel::class.java] roomListSharedActionViewModel = viewModelProvider[RoomListSharedActionViewModel::class.java]
views.drawerLayout.addDrawerListener(drawerListener) views.drawerLayout.addDrawerListener(drawerListener)
if (isFirstCreation()) { if (isFirstCreation()) {
if (vectorFeatures.isNewAppLayoutEnabled()) { if (vectorPreferences.isNewAppLayoutEnabled()) {
views.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) views.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
replaceFragment(views.homeDetailFragmentContainer, NewHomeDetailFragment::class.java) replaceFragment(views.homeDetailFragmentContainer, NewHomeDetailFragment::class.java)
} else { } else {
replaceFragment(views.homeDetailFragmentContainer, HomeDetailFragment::class.java) replaceFragment(views.homeDetailFragmentContainer, HomeDetailFragment::class.java)
replaceFragment(views.homeDrawerFragmentContainer, HomeDrawerFragment::class.java) replaceFragment(views.homeDrawerFragmentContainer, HomeDrawerFragment::class.java)
views.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
} }
} }
@ -581,12 +582,12 @@ class HomeActivity :
} }
private fun checkNewAppLayoutFlagChange() { private fun checkNewAppLayoutFlagChange() {
if (buildMeta.isDebug && vectorFeatures.isNewAppLayoutEnabled() != isNewAppLayoutEnabled) { if (buildMeta.isDebug && vectorPreferences.isNewAppLayoutEnabled() != isNewAppLayoutEnabled) {
restart() 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) { override fun handlePrepareMenu(menu: Menu) {
menu.findItem(R.id.menu_home_init_sync_legacy).isVisible = vectorPreferences.developerMode() menu.findItem(R.id.menu_home_init_sync_legacy).isVisible = vectorPreferences.developerMode()

View file

@ -120,7 +120,7 @@ class HomeActivityViewModel @AssistedInject constructor(
private fun observeReleaseNotes() = withState { state -> private fun observeReleaseNotes() = withState { state ->
// we don't want to show release notes for new users or after relogin // we don't want to show release notes for new users or after relogin
if (state.authenticationDescription == null && vectorFeatures.isNewAppLayoutEnabled()) { if (state.authenticationDescription == null && vectorPreferences.isNewAppLayoutEnabled()) {
releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown -> releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown ->
if (!isAppLayoutOnboardingShown) { if (!isAppLayoutOnboardingShown) {
_viewEvents.post(HomeActivityViewEvents.ShowReleaseNotes) _viewEvents.post(HomeActivityViewEvents.ShowReleaseNotes)

View file

@ -27,6 +27,7 @@ import im.vector.app.R
import im.vector.app.core.di.DefaultSharedPreferences import im.vector.app.core.di.DefaultSharedPreferences
import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.BuildMeta
import im.vector.app.core.time.Clock 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.disclaimer.SHARED_PREF_KEY
import im.vector.app.features.home.ShortcutsHandler import im.vector.app.features.home.ShortcutsHandler
import im.vector.app.features.homeserver.ServerUrlsRepository import im.vector.app.features.homeserver.ServerUrlsRepository
@ -39,6 +40,7 @@ class VectorPreferences @Inject constructor(
private val context: Context, private val context: Context,
private val clock: Clock, private val clock: Clock,
private val buildMeta: BuildMeta, private val buildMeta: BuildMeta,
private val vectorFeatures: VectorFeatures,
) { ) {
companion object { companion object {
@ -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_PREFERENCE_KEY = "SETTINGS_BACKGROUND_SYNC_PREFERENCE_KEY"
const val SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY = "SETTINGS_BACKGROUND_SYNC_DIVIDER_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_PREFERENCE_KEY = "SETTINGS_LABS_PREFERENCE_KEY"
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_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY"
const val SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_DIVIDER_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" const val SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY = "SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY"
@ -1151,6 +1154,14 @@ class VectorPreferences @Inject constructor(
return spaceIdsJoined?.takeIf { it.isNotEmpty() }?.split(",").orEmpty() return spaceIdsJoined?.takeIf { it.isNotEmpty() }?.split(",").orEmpty()
} }
/**
* Indicates whether or not new app layout is enabled.
*/
fun isNewAppLayoutEnabled(): Boolean {
return vectorFeatures.isNewAppLayoutFeatureEnabled() &&
defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default))
}
fun showLiveSenderInfo(): Boolean { fun showLiveSenderInfo(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_TIMELINE_SHOW_LIVE_SENDER_INFO, getDefault(R.bool.settings_timeline_show_live_sender_info_default)) return defaultPrefs.getBoolean(SETTINGS_TIMELINE_SHOW_LIVE_SENDER_INFO, getDefault(R.bool.settings_timeline_show_live_sender_info_default))
} }

View file

@ -75,8 +75,22 @@ class VectorSettingsLabsFragment :
} }
} }
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)!!.let { findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_NEW_APP_LAYOUT_KEY)?.let { pref ->
it.isVisible = !vectorFeatures.isNewAppLayoutEnabled() pref.isVisible = vectorFeatures.isNewAppLayoutFeatureEnabled()
pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
onNewLayoutPreferenceClicked()
true
}
}
configureUnreadNotificationsAsTabPreference()
}
private fun configureUnreadNotificationsAsTabPreference() {
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)?.let { pref ->
pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled()
pref.isEnabled = !vectorPreferences.isNewAppLayoutEnabled()
} }
} }
@ -119,4 +133,11 @@ class VectorSettingsLabsFragment :
displayLoadingView() displayLoadingView()
MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true)) MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true))
} }
/**
* Action when new layout preference switch is actually clicked.
*/
private fun onNewLayoutPreferenceClicked() {
configureUnreadNotificationsAsTabPreference()
}
} }

View file

@ -102,7 +102,8 @@ class VectorSettingsPreferencesFragment :
} }
findPreference<Preference>(VectorPreferences.SETTINGS_PREF_SPACE_CATEGORY)!!.let { pref -> findPreference<Preference>(VectorPreferences.SETTINGS_PREF_SPACE_CATEGORY)!!.let { pref ->
pref.isVisible = !vectorFeatures.isNewAppLayoutEnabled() pref.isVisible = !vectorFeatures.isNewAppLayoutFeatureEnabled()
pref.isEnabled = !vectorPreferences.isNewAppLayoutEnabled()
} }
// Url preview // Url preview

View file

@ -35,11 +35,11 @@ import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.StateView import im.vector.app.core.platform.StateView
import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentSpaceListBinding 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.HomeActivitySharedAction
import im.vector.app.features.home.HomeSharedActionViewModel 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.RoomListSharedAction
import im.vector.app.features.home.room.list.actions.RoomListSharedActionViewModel 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 org.matrix.android.sdk.api.session.room.model.RoomSummary
import javax.inject.Inject import javax.inject.Inject
@ -58,7 +58,7 @@ class SpaceListFragment :
@Inject lateinit var spaceController: SpaceSummaryController @Inject lateinit var spaceController: SpaceSummaryController
@Inject lateinit var newSpaceController: NewSpaceSummaryController @Inject lateinit var newSpaceController: NewSpaceSummaryController
@Inject lateinit var vectorFeatures: VectorFeatures @Inject lateinit var vectorPreferences: VectorPreferences
private lateinit var homeActivitySharedActionViewModel: HomeSharedActionViewModel private lateinit var homeActivitySharedActionViewModel: HomeSharedActionViewModel
private lateinit var roomListSharedActionViewModel: RoomListSharedActionViewModel private lateinit var roomListSharedActionViewModel: RoomListSharedActionViewModel
@ -79,7 +79,7 @@ class SpaceListFragment :
} }
private fun setupSpaceController() { private fun setupSpaceController() {
if (vectorFeatures.isNewAppLayoutEnabled()) { if (vectorPreferences.isNewAppLayoutEnabled()) {
newSpaceController.callback = this newSpaceController.callback = this
views.groupListView.configureWith(newSpaceController) views.groupListView.configureWith(newSpaceController)
} else { } else {
@ -169,7 +169,7 @@ class SpaceListFragment :
else -> Unit else -> Unit
} }
if (vectorFeatures.isNewAppLayoutEnabled()) { if (vectorPreferences.isNewAppLayoutEnabled()) {
newSpaceController.update(state) newSpaceController.update(state)
} else { } else {
spaceController.update(state) spaceController.update(state)

View file

@ -83,4 +83,10 @@
android:summary="@string/labs_enable_element_call_permission_shortcuts_summary" android:summary="@string/labs_enable_element_call_permission_shortcuts_summary"
android:title="@string/labs_enable_element_call_permission_shortcuts" /> android:title="@string/labs_enable_element_call_permission_shortcuts" />
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="@bool/settings_labs_new_app_layout_default"
android:key="SETTINGS_LABS_NEW_APP_LAYOUT_KEY"
android:summary="@string/labs_enable_new_app_layout_summary"
android:title="@string/labs_enable_new_app_layout_title" />
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>