From 3af663e91f8f2642267e50b7ab1c7ac4b5afec38 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Mon, 25 Jul 2022 09:57:51 +0200 Subject: [PATCH] Put EC permission shortcuts behind labs flag (PSG-630) Signed-off-by: Johannes Marbach --- .../im/vector/app/features/settings/VectorPreferences.kt | 6 ++++++ .../java/im/vector/app/features/widgets/WidgetActivity.kt | 6 +++++- .../java/im/vector/app/features/widgets/WidgetFragment.kt | 4 +++- vector/src/main/res/values/strings.xml | 4 ++++ vector/src/main/res/xml/vector_settings_labs.xml | 6 ++++++ 5 files changed, 24 insertions(+), 2 deletions(-) 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 7bee66d722..587e6a59b4 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 @@ -206,6 +206,8 @@ class VectorPreferences @Inject constructor( private const val SETTINGS_LABS_ENABLE_LIVE_LOCATION = "SETTINGS_LABS_ENABLE_LIVE_LOCATION" + private const val SETTINGS_LABS_ENABLE_ELEMENT_CALL_PERMISSION_SHORTCUTS = "SETTINGS_LABS_ENABLE_ELEMENT_CALL_PERMISSION_SHORTCUTS" + // This key will be used to identify clients with the old thread support enabled io.element.thread const val SETTINGS_LABS_ENABLE_THREAD_MESSAGES_OLD_CLIENTS = "SETTINGS_LABS_ENABLE_THREAD_MESSAGES" @@ -1050,6 +1052,10 @@ class VectorPreferences @Inject constructor( } } + fun labsEnableElementCallPermissionShortcuts(): Boolean { + return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_ELEMENT_CALL_PERMISSION_SHORTCUTS, false) + } + /** * Indicates whether or not thread messages are enabled. */ diff --git a/vector/src/main/java/im/vector/app/features/widgets/WidgetActivity.kt b/vector/src/main/java/im/vector/app/features/widgets/WidgetActivity.kt index 0b78d8d2f1..bf6b2fd051 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/WidgetActivity.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/WidgetActivity.kt @@ -38,12 +38,14 @@ import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivityWidgetBinding +import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.widgets.permissions.RoomWidgetPermissionBottomSheet import im.vector.app.features.widgets.permissions.RoomWidgetPermissionViewEvents import im.vector.app.features.widgets.permissions.RoomWidgetPermissionViewModel import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.session.events.model.Content import java.io.Serializable +import javax.inject.Inject @AndroidEntryPoint class WidgetActivity : VectorBaseActivity() { @@ -78,6 +80,8 @@ class WidgetActivity : VectorBaseActivity() { private val viewModel: WidgetViewModel by viewModel() private val permissionViewModel: RoomWidgetPermissionViewModel by viewModel() + @Inject lateinit var vectorPreferences: VectorPreferences + override fun getBinding() = ActivityWidgetBinding.inflate(layoutInflater) override fun getTitleRes() = R.string.room_widget_activity_title @@ -99,7 +103,7 @@ class WidgetActivity : VectorBaseActivity() { } // Trust element call widget by default - if (widgetArgs.kind == WidgetKind.ELEMENT_CALL) { + if (widgetArgs.kind == WidgetKind.ELEMENT_CALL && vectorPreferences.labsEnableElementCallPermissionShortcuts()) { if (supportFragmentManager.findFragmentByTag(WIDGET_FRAGMENT_TAG) == null) { addOnPictureInPictureModeChangedListener(pictureInPictureModeChangedInfoConsumer) addFragment(views.fragmentContainer, WidgetFragment::class.java, widgetArgs, WIDGET_FRAGMENT_TAG) diff --git a/vector/src/main/java/im/vector/app/features/widgets/WidgetFragment.kt b/vector/src/main/java/im/vector/app/features/widgets/WidgetFragment.kt index 9ac085fa89..ed1bace70c 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/WidgetFragment.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/WidgetFragment.kt @@ -46,6 +46,7 @@ import im.vector.app.core.platform.VectorMenuProvider import im.vector.app.core.utils.CheckWebViewPermissionsUseCase import im.vector.app.core.utils.openUrlInExternalBrowser import im.vector.app.databinding.FragmentRoomWidgetBinding +import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.webview.WebEventListener import im.vector.app.features.widgets.webview.WebviewPermissionUtils import im.vector.app.features.widgets.webview.clearAfterWidget @@ -68,6 +69,7 @@ data class WidgetArgs( class WidgetFragment @Inject constructor( private val permissionUtils: WebviewPermissionUtils, private val checkWebViewPermissionsUseCase: CheckWebViewPermissionsUseCase, + private val vectorPreferences: VectorPreferences, ) : VectorBaseFragment(), WebEventListener, @@ -303,7 +305,7 @@ class WidgetFragment @Inject constructor( context = requireContext(), activity = requireActivity(), activityResultLauncher = permissionResultLauncher, - autoApprove = fragmentArgs.kind == WidgetKind.ELEMENT_CALL + autoApprove = fragmentArgs.kind == WidgetKind.ELEMENT_CALL && vectorPreferences.labsEnableElementCallPermissionShortcuts() ) } diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index b162814a9d..43e0c6385b 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3179,4 +3179,8 @@ %d message removed %d messages removed + + + Enable Element Call permission shortcuts + Auto-approve Element Call widgets and grant camera / mic access diff --git a/vector/src/main/res/xml/vector_settings_labs.xml b/vector/src/main/res/xml/vector_settings_labs.xml index 555470e643..80b71a1f75 100644 --- a/vector/src/main/res/xml/vector_settings_labs.xml +++ b/vector/src/main/res/xml/vector_settings_labs.xml @@ -77,4 +77,10 @@ android:summary="@string/labs_enable_live_location_summary" android:title="@string/labs_enable_live_location" /> + +