diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt index 03d065c982..5e7a34856b 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt @@ -22,7 +22,6 @@ import dagger.hilt.android.AndroidEntryPoint import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.databinding.FragmentGenericRecyclerBinding -import im.vector.app.features.DefaultVectorFeatures import im.vector.app.features.themes.ActivityOtherThemes import im.vector.app.features.themes.ThemeUtils import javax.inject.Inject @@ -31,7 +30,7 @@ import javax.inject.Inject class DebugFeaturesSettingsActivity : AppCompatActivity() { @Inject lateinit var debugFeatures: DebugVectorFeatures - @Inject lateinit var defaultFeatures: DefaultVectorFeatures + @Inject lateinit var debugFeaturesStateFactory: DebugFeaturesStateFactory private lateinit var views: FragmentGenericRecyclerBinding @@ -48,27 +47,7 @@ class DebugFeaturesSettingsActivity : AppCompatActivity() { } }) views.genericRecyclerView.configureWith(controller) - controller.setData(createState()) - } - - private fun createState(): FeaturesState { - return FeaturesState(listOf( - createEnumFeature( - label = "Login version", - selection = debugFeatures.loginVersion(), - default = defaultFeatures.loginVersion() - ) - )) - } - - private inline fun > createEnumFeature(label: String, selection: T, default: T): Feature { - return Feature.EnumFeature( - label = label, - selection = selection.takeIf { debugFeatures.hasEnumOverride(T::class) }, - default = default, - options = enumValues().toList(), - type = T::class - ) + controller.setData(debugFeaturesStateFactory.create()) } override fun onDestroy() { 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 new file mode 100644 index 0000000000..8d22fc599f --- /dev/null +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 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.features.debug.features + +import im.vector.app.features.DefaultVectorFeatures +import javax.inject.Inject + +class DebugFeaturesStateFactory @Inject constructor( + private val debugFeatures: DebugVectorFeatures, + private val defaultFeatures: DefaultVectorFeatures +) { + + fun create(): FeaturesState { + return FeaturesState(listOf( + createEnumFeature( + label = "Login version", + selection = debugFeatures.loginVersion(), + default = defaultFeatures.loginVersion() + ) + )) + } + + private inline fun > createEnumFeature(label: String, selection: T, default: T): Feature { + return Feature.EnumFeature( + label = label, + selection = selection.takeIf { debugFeatures.hasEnumOverride(T::class) }, + default = default, + options = enumValues().toList(), + type = T::class + ) + } +}