From 6985cc78beec8c484b81d02ffccb8e151420f189 Mon Sep 17 00:00:00 2001 From: yostyle Date: Wed, 13 Mar 2024 09:33:52 +0100 Subject: [PATCH 1/6] Update labs visibility --- .../vector/app/features/debug/di/FeaturesModule.kt | 5 +++-- .../features/debug/features/DebugVectorFeatures.kt | 2 ++ .../java/im/vector/app/core/di/FeaturesModule.kt | 4 ++-- .../src/btchap/res/values/config-settings.xml | 3 ++- .../src/debug/res/values/config-settings.xml | 3 +++ .../src/devTchap/res/values/config-settings.xml | 3 ++- .../src/main/res/values/config-settings.xml | 3 +-- .../src/tchap/res/values/config-settings.xml | 4 ---- .../java/im/vector/app/features/VectorFeatures.kt | 5 +++++ .../features/settings/VectorSettingsRootFragment.kt | 13 +++++++++++++ vector/src/main/res/xml/vector_settings_root.xml | 3 ++- 11 files changed, 35 insertions(+), 13 deletions(-) delete mode 100755 vector-config/src/tchap/res/values/config-settings.xml diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt b/vector-app/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt index 0a18214038..e38282d1fa 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt @@ -22,6 +22,7 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent +import im.vector.app.core.resources.AppNameProvider import im.vector.app.core.resources.BooleanProvider import im.vector.app.core.resources.StringArrayProvider import im.vector.app.features.DefaultVectorFeatures @@ -44,8 +45,8 @@ interface FeaturesModule { companion object { @Provides - fun providesDefaultVectorFeatures(stringArrayProvider: StringArrayProvider, booleanProvider: BooleanProvider): DefaultVectorFeatures { - return DefaultVectorFeatures(stringArrayProvider, booleanProvider) + fun providesDefaultVectorFeatures(appNameProvider: AppNameProvider, stringArrayProvider: StringArrayProvider, booleanProvider: BooleanProvider): DefaultVectorFeatures { + return DefaultVectorFeatures(appNameProvider, stringArrayProvider, booleanProvider) } @Provides diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index 684a284418..54c7de9b7a 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -48,6 +48,8 @@ class DebugVectorFeatures( override fun tchapIsThreadEnabled() = vectorFeatures.tchapIsThreadEnabled() + override fun tchapIsLabsVisible(domain: String) = vectorFeatures.tchapIsLabsVisible(domain) + override fun onboardingVariant(): OnboardingVariant { return readPreferences().getEnum() ?: vectorFeatures.onboardingVariant() } diff --git a/vector-app/src/release/java/im/vector/app/core/di/FeaturesModule.kt b/vector-app/src/release/java/im/vector/app/core/di/FeaturesModule.kt index ce218888c6..697f73a287 100644 --- a/vector-app/src/release/java/im/vector/app/core/di/FeaturesModule.kt +++ b/vector-app/src/release/java/im/vector/app/core/di/FeaturesModule.kt @@ -32,8 +32,8 @@ import im.vector.app.features.VectorOverrides object FeaturesModule { @Provides - fun providesFeatures(stringArrayProvider: StringArrayProvider, booleanProvider: BooleanProvider): VectorFeatures { - return DefaultVectorFeatures(stringArrayProvider, booleanProvider) + fun providesFeatures(appNameProvider: AppNameProvider, stringArrayProvider: StringArrayProvider, booleanProvider: BooleanProvider): VectorFeatures { + return DefaultVectorFeatures(appNameProvider, stringArrayProvider, booleanProvider) } @Provides diff --git a/vector-config/src/btchap/res/values/config-settings.xml b/vector-config/src/btchap/res/values/config-settings.xml index 8c8a269d16..30b15f7361 100755 --- a/vector-config/src/btchap/res/values/config-settings.xml +++ b/vector-config/src/btchap/res/values/config-settings.xml @@ -1,4 +1,5 @@ - true + + true diff --git a/vector-config/src/debug/res/values/config-settings.xml b/vector-config/src/debug/res/values/config-settings.xml index 87946442ba..a83157d9a8 100755 --- a/vector-config/src/debug/res/values/config-settings.xml +++ b/vector-config/src/debug/res/values/config-settings.xml @@ -1,6 +1,9 @@ + + true + true diff --git a/vector-config/src/devTchap/res/values/config-settings.xml b/vector-config/src/devTchap/res/values/config-settings.xml index 8c8a269d16..30b15f7361 100755 --- a/vector-config/src/devTchap/res/values/config-settings.xml +++ b/vector-config/src/devTchap/res/values/config-settings.xml @@ -1,4 +1,5 @@ - true + + true diff --git a/vector-config/src/main/res/values/config-settings.xml b/vector-config/src/main/res/values/config-settings.xml index 096d38b1e1..06c87af0f1 100755 --- a/vector-config/src/main/res/values/config-settings.xml +++ b/vector-config/src/main/res/values/config-settings.xml @@ -17,8 +17,7 @@ true - - + false true true true diff --git a/vector-config/src/tchap/res/values/config-settings.xml b/vector-config/src/tchap/res/values/config-settings.xml deleted file mode 100755 index 6b542c4f3f..0000000000 --- a/vector-config/src/tchap/res/values/config-settings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - false - 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 209c0fba3c..a17c3a2dc8 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -19,6 +19,7 @@ package im.vector.app.features import im.vector.app.R import im.vector.app.config.Config import im.vector.app.config.OnboardingVariant +import im.vector.app.core.resources.AppNameProvider import im.vector.app.core.resources.BooleanProvider import im.vector.app.core.resources.StringArrayProvider import im.vector.app.features.settings.VectorPreferences @@ -30,6 +31,7 @@ interface VectorFeatures { fun tchapIsCrossSigningEnabled(): Boolean fun tchapIsKeyBackupEnabled(): Boolean fun tchapIsThreadEnabled(): Boolean + fun tchapIsLabsVisible(domain: String): Boolean fun onboardingVariant(): OnboardingVariant fun isOnboardingAlreadyHaveAccountSplashEnabled(): Boolean fun isOnboardingSplashCarouselEnabled(): Boolean @@ -56,6 +58,7 @@ interface VectorFeatures { } class DefaultVectorFeatures @Inject constructor( + private val appNameProvider: AppNameProvider, private val stringArrayProvider: StringArrayProvider, private val booleanProvider: BooleanProvider ) : VectorFeatures { @@ -66,6 +69,8 @@ class DefaultVectorFeatures @Inject constructor( override fun tchapIsCrossSigningEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_cross_signing_enabled) override fun tchapIsKeyBackupEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_key_backup_enabled) override fun tchapIsThreadEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_thread_enabled) + override fun tchapIsLabsVisible(domain: String) = booleanProvider.getBoolean(R.bool.settings_root_labs_visible) + || domain == appNameProvider.getAppName() override fun onboardingVariant() = Config.ONBOARDING_VARIANT override fun isOnboardingAlreadyHaveAccountSplashEnabled() = true override fun isOnboardingSplashCarouselEnabled() = false // Tchap: no carousel diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsRootFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsRootFragment.kt index ff376aefa8..a054c39fbb 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsRootFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsRootFragment.kt @@ -19,16 +19,24 @@ package im.vector.app.features.settings import android.os.Bundle import androidx.preference.Preference import dagger.hilt.android.AndroidEntryPoint +import fr.gouv.tchap.core.utils.TchapUtils import im.vector.app.R import im.vector.app.core.preference.VectorPreference import im.vector.app.core.utils.FirstThrottler import im.vector.app.core.utils.openUrlInChromeCustomTab +import im.vector.app.features.VectorFeatures import im.vector.app.features.analytics.plan.MobileScreen +import im.vector.app.features.displayname.getBestName +import org.matrix.android.sdk.api.session.getUserOrDefault +import org.matrix.android.sdk.api.util.toMatrixItem +import javax.inject.Inject @AndroidEntryPoint class VectorSettingsRootFragment : VectorSettingsBaseFragment() { + @Inject lateinit var vectorFeatures: VectorFeatures + override var titleRes: Int = R.string.title_activity_settings override val preferenceXmlRes = R.xml.vector_settings_root @@ -50,6 +58,11 @@ class VectorSettingsRootFragment : } false } + + // Tchap: Manage labs entry. + val myUserDisplayName = session.getUserOrDefault(session.myUserId).toMatrixItem().getBestName() + findPreference(VectorPreferences.SETTINGS_LABS_PREFERENCE_KEY)!! + .isVisible = vectorFeatures.tchapIsLabsVisible(TchapUtils.getDomainFromDisplayName(myUserDisplayName)) } private fun tintIcons() { diff --git a/vector/src/main/res/xml/vector_settings_root.xml b/vector/src/main/res/xml/vector_settings_root.xml index 13a3022233..e7700a2cab 100644 --- a/vector/src/main/res/xml/vector_settings_root.xml +++ b/vector/src/main/res/xml/vector_settings_root.xml @@ -34,9 +34,10 @@ + app:isPreferenceVisible="@bool/settings_root_labs_visible" /> Date: Wed, 13 Mar 2024 09:38:01 +0100 Subject: [PATCH 2/6] Add changelog --- changelog.d/1019.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/1019.misc diff --git a/changelog.d/1019.misc b/changelog.d/1019.misc new file mode 100644 index 0000000000..6b13db2dc5 --- /dev/null +++ b/changelog.d/1019.misc @@ -0,0 +1 @@ +Update labs visibility. \ No newline at end of file From 65c82e326981941fb7c0d2a26eb79c822ddc799b Mon Sep 17 00:00:00 2001 From: yostyle Date: Wed, 13 Mar 2024 15:36:29 +0100 Subject: [PATCH 3/6] Fix lint --- 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 a17c3a2dc8..3569bd8dbd 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -69,8 +69,8 @@ class DefaultVectorFeatures @Inject constructor( override fun tchapIsCrossSigningEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_cross_signing_enabled) override fun tchapIsKeyBackupEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_key_backup_enabled) override fun tchapIsThreadEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_thread_enabled) - override fun tchapIsLabsVisible(domain: String) = booleanProvider.getBoolean(R.bool.settings_root_labs_visible) - || domain == appNameProvider.getAppName() + override fun tchapIsLabsVisible(domain: String) = booleanProvider.getBoolean(R.bool.settings_root_labs_visible) || + domain == appNameProvider.getAppName() override fun onboardingVariant() = Config.ONBOARDING_VARIANT override fun isOnboardingAlreadyHaveAccountSplashEnabled() = true override fun isOnboardingSplashCarouselEnabled() = false // Tchap: no carousel From e67f19e7475e06e990ad41af1cf9d5d85fdd7aaf Mon Sep 17 00:00:00 2001 From: yostyle Date: Thu, 14 Mar 2024 09:01:37 +0100 Subject: [PATCH 4/6] Fix tests --- .../androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt | 4 +++- .../java/im/vector/app/ui/robot/OnboardingRobot.kt | 6 +++++- .../java/im/vector/app/ui/robot/space/SpaceRobot.kt | 4 +++- .../vector/app/features/voice/VoiceRecorderProviderTests.kt | 3 ++- .../java/im/vector/app/test/fakes/FakeVectorFeatures.kt | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) 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 f433bcc199..cec356755c 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 @@ -22,6 +22,7 @@ import androidx.test.platform.app.InstrumentationRegistry import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import im.vector.app.R import im.vector.app.core.resources.BooleanProvider +import im.vector.app.core.resources.DefaultAppNameProvider import im.vector.app.core.resources.StringArrayProvider import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.features.DefaultVectorFeatures @@ -33,7 +34,8 @@ class NewRoomRobot( private val labsPreferences: LabFeaturesPreferences ) { private val context = InstrumentationRegistry.getInstrumentation().targetContext - private val features: VectorFeatures = DefaultVectorFeatures(StringArrayProvider(context.resources), BooleanProvider(context.resources)) + private val features: VectorFeatures = + DefaultVectorFeatures(DefaultAppNameProvider(context), StringArrayProvider(context.resources), BooleanProvider(context.resources)) fun createNewRoom(block: CreateNewRoomRobot.() -> Unit) { clickOn(R.string.create_new_room) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt index 3861f86796..d748608fcd 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt @@ -30,6 +30,7 @@ import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaEditTextInteractions.writeTo import im.vector.app.R import im.vector.app.core.resources.BooleanProvider +import im.vector.app.core.resources.DefaultAppNameProvider import im.vector.app.core.resources.StringArrayProvider import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.features.DefaultVectorFeatures @@ -42,7 +43,10 @@ class OnboardingRobot { // Tchap: Override default feature values for tests private val context = InstrumentationRegistry.getInstrumentation().targetContext private val defaultVectorFeatures = - DebugVectorFeatures(context, DefaultVectorFeatures(StringArrayProvider(context.resources), BooleanProvider(context.resources))).apply { + DebugVectorFeatures( + context, + DefaultVectorFeatures(DefaultAppNameProvider(context), StringArrayProvider(context.resources), BooleanProvider(context.resources)) + ).apply { override(true, DebugFeatureKeys.tchapIsKeyBackupEnabled) } 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 6d560cffb7..410bb328cf 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 @@ -28,6 +28,7 @@ import com.adevinta.android.barista.interaction.BaristaDrawerInteractions.openDr import com.adevinta.android.barista.internal.viewaction.ClickChildAction import im.vector.app.R import im.vector.app.core.resources.BooleanProvider +import im.vector.app.core.resources.DefaultAppNameProvider import im.vector.app.core.resources.StringArrayProvider import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilViewVisible @@ -38,7 +39,8 @@ import org.hamcrest.Matchers class SpaceRobot(private val labsPreferences: LabFeaturesPreferences) { private val context = InstrumentationRegistry.getInstrumentation().targetContext - private val features: VectorFeatures = DefaultVectorFeatures(StringArrayProvider(context.resources), BooleanProvider(context.resources)) + private val features: VectorFeatures = + DefaultVectorFeatures(DefaultAppNameProvider(context), StringArrayProvider(context.resources), BooleanProvider(context.resources)) fun createSpace(isFirstSpace: Boolean, block: SpaceCreateRobot.() -> Unit) { if (labsPreferences.isNewAppLayoutEnabled) { diff --git a/vector/src/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt b/vector/src/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt index 12a3a9b8aa..340f6c5030 100644 --- a/vector/src/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt +++ b/vector/src/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt @@ -20,6 +20,7 @@ import android.os.Build import androidx.test.platform.app.InstrumentationRegistry import im.vector.app.TestBuildVersionSdkIntProvider import im.vector.app.core.resources.BooleanProvider +import im.vector.app.core.resources.DefaultAppNameProvider import im.vector.app.core.resources.StringArrayProvider import im.vector.app.features.DefaultVectorFeatures import io.mockk.every @@ -34,7 +35,7 @@ class VoiceRecorderProviderTests { private val provider = spyk( VoiceRecorderProvider( context, - DefaultVectorFeatures(StringArrayProvider(context.resources), BooleanProvider(context.resources)), + DefaultVectorFeatures(DefaultAppNameProvider(context),StringArrayProvider(context.resources), BooleanProvider(context.resources)), buildVersionSdkIntProvider ) ) diff --git a/vector/src/test/java/im/vector/app/test/fakes/FakeVectorFeatures.kt b/vector/src/test/java/im/vector/app/test/fakes/FakeVectorFeatures.kt index 4c5d296ab5..b27e99b6d5 100644 --- a/vector/src/test/java/im/vector/app/test/fakes/FakeVectorFeatures.kt +++ b/vector/src/test/java/im/vector/app/test/fakes/FakeVectorFeatures.kt @@ -22,7 +22,7 @@ import io.mockk.every import io.mockk.mockk import io.mockk.spyk -class FakeVectorFeatures : VectorFeatures by spyk(DefaultVectorFeatures(mockk(), mockk())) { +class FakeVectorFeatures : VectorFeatures by spyk(DefaultVectorFeatures(mockk(), mockk(), mockk())) { fun givenPersonalisationEnabled() { every { isOnboardingPersonalizeEnabled() } returns true From 52367000f0dcb7db52adb7f0138e1cf1d279e993 Mon Sep 17 00:00:00 2001 From: yostyle Date: Thu, 14 Mar 2024 09:56:03 +0100 Subject: [PATCH 5/6] Fix lint --- .../im/vector/app/features/voice/VoiceRecorderProviderTests.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt b/vector/src/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt index 340f6c5030..5dd3d01505 100644 --- a/vector/src/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt +++ b/vector/src/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt @@ -35,7 +35,7 @@ class VoiceRecorderProviderTests { private val provider = spyk( VoiceRecorderProvider( context, - DefaultVectorFeatures(DefaultAppNameProvider(context),StringArrayProvider(context.resources), BooleanProvider(context.resources)), + DefaultVectorFeatures(DefaultAppNameProvider(context), StringArrayProvider(context.resources), BooleanProvider(context.resources)), buildVersionSdkIntProvider ) ) From fa4d2cbcf914547f097a72dc4fc143d3297c4534 Mon Sep 17 00:00:00 2001 From: yostyle Date: Thu, 14 Mar 2024 12:14:03 +0100 Subject: [PATCH 6/6] Fix import --- .../src/release/java/im/vector/app/core/di/FeaturesModule.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/vector-app/src/release/java/im/vector/app/core/di/FeaturesModule.kt b/vector-app/src/release/java/im/vector/app/core/di/FeaturesModule.kt index 697f73a287..bd7437a3f7 100644 --- a/vector-app/src/release/java/im/vector/app/core/di/FeaturesModule.kt +++ b/vector-app/src/release/java/im/vector/app/core/di/FeaturesModule.kt @@ -20,6 +20,7 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent +import im.vector.app.core.resources.AppNameProvider import im.vector.app.core.resources.BooleanProvider import im.vector.app.core.resources.StringArrayProvider import im.vector.app.features.DefaultVectorFeatures