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 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-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..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 @@ -32,8 +33,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/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt b/vector/src/androidTest/java/im/vector/app/features/voice/VoiceRecorderProviderTests.kt index 12a3a9b8aa..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 @@ -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/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index 209c0fba3c..3569bd8dbd 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" />