diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetDialogFragment.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetDialogFragment.kt index ddc281fdd14..f03d1d73abd 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetDialogFragment.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetDialogFragment.kt @@ -47,7 +47,7 @@ import timber.log.Timber /** * Add Mavericks capabilities, handle DI and bindings. */ -abstract class VectorBaseBottomSheetDialogFragment : BottomSheetDialogFragment(), MavericksView { +abstract class VectorBaseBottomSheetDialogFragment : BottomSheetDialogFragment(), MavericksView, VectorBaseBottomSheetListener { /* ========================================================================================== * Analytics * ========================================================================================== */ @@ -126,6 +126,12 @@ abstract class VectorBaseBottomSheetDialogFragment : BottomShe super.onDestroy() } + override fun doCancel(dialog: DialogInterface) {} + override fun onCancel(dialog: DialogInterface) { + doCancel(dialog) + super.onCancel(dialog) + } + override fun onAttach(context: Context) { val activityEntryPoint = EntryPointAccessors.fromActivity(vectorBaseActivity, ActivityEntryPoint::class.java) viewModelFactory = activityEntryPoint.viewModelFactory() diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetListener.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetListener.kt new file mode 100644 index 00000000000..98c7e9399c1 --- /dev/null +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetListener.kt @@ -0,0 +1,23 @@ +/* + * 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.core.platform + +import android.content.DialogInterface + +interface VectorBaseBottomSheetListener { + fun doCancel(dialog: DialogInterface) +} diff --git a/vector/src/main/java/im/vector/app/features/widgets/permissions/RoomWidgetPermissionBottomSheet.kt b/vector/src/main/java/im/vector/app/features/widgets/permissions/RoomWidgetPermissionBottomSheet.kt index 91371b1f73b..ba0f4e5e190 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/permissions/RoomWidgetPermissionBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/permissions/RoomWidgetPermissionBottomSheet.kt @@ -61,6 +61,10 @@ class RoomWidgetPermissionBottomSheet : views.widgetPermissionContinue.debouncedClicks { doAccept() } } + override fun doCancel(dialog: DialogInterface) { + doDecline() + } + override fun invalidate() = withState(viewModel) { state -> super.invalidate() val permissionData = state.permissionData() ?: return@withState