diff --git a/vector/build.gradle b/vector/build.gradle index 7c1119f9c1..f5731c819f 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -143,7 +143,7 @@ android { resValue "bool", "useLoginV2", "false" // NotificationSettingsV2 is disabled. To be released in conjunction with iOS/Web - def useNotificationSettingsV2 = false + def useNotificationSettingsV2 = true buildConfigField "Boolean", "USE_NOTIFICATION_SETTINGS_V2", "${useNotificationSettingsV2}" resValue "bool", "useNotificationSettingsV1", "${!useNotificationSettingsV2}" resValue "bool", "useNotificationSettingsV2", "${useNotificationSettingsV2}" diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt index 4a563b563a..9ae6d4c39f 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt @@ -143,6 +143,8 @@ class HomeActivity : } } + override fun getCoordinatorLayout() = views.coordinatorLayout + override fun getBinding() = ActivityHomeBinding.inflate(layoutInflater) override fun injectWith(injector: ScreenComponent) { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index 344a4abbac..fdfe171439 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -473,16 +473,9 @@ class RoomListFragment @Inject constructor( // refresh footer footerController.setData(it) } - val bottomSheet = RoomListQuickActionsBottomSheet + RoomListQuickActionsBottomSheet .newInstance(room.roomId, RoomListActionsArgs.Mode.FULL) - bottomSheet.listener = object : RoomListQuickActionsBottomSheet.Listener { - override fun handleFailure(throwable: Throwable) { - showFailure(throwable) - } - } - - bottomSheet.show(childFragmentManager, "ROOM_LIST_QUICK_ACTIONS") - + .show(childFragmentManager, "ROOM_LIST_QUICK_ACTIONS") return true } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt index ccbed264e3..fcc9960414 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt @@ -25,10 +25,14 @@ import androidx.recyclerview.widget.RecyclerView import com.airbnb.mvrx.args import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState +import com.google.android.material.dialog.MaterialAlertDialogBuilder +import im.vector.app.R import im.vector.app.core.di.ScreenComponent +import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment +import im.vector.app.core.platform.showOptimizedSnackbar import im.vector.app.databinding.BottomSheetGenericListBinding import im.vector.app.features.navigation.Navigator import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsAction @@ -57,20 +61,17 @@ class RoomListQuickActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), RoomListQuickActionsEpoxyController.Listener { - interface Listener { - fun handleFailure(throwable: Throwable) - } private lateinit var sharedActionViewModel: RoomListQuickActionsSharedActionViewModel @Inject lateinit var sharedViewPool: RecyclerView.RecycledViewPool @Inject lateinit var roomNotificationSettingsViewModelFactory: RoomNotificationSettingsViewModel.Factory @Inject lateinit var roomListActionsEpoxyController: RoomListQuickActionsEpoxyController @Inject lateinit var navigator: Navigator + @Inject lateinit var errorFormatter: ErrorFormatter private val roomListActionsArgs: RoomListActionsArgs by args() private val viewModel: RoomNotificationSettingsViewModel by fragmentViewModel(RoomNotificationSettingsViewModel::class) override val showExpanded = true - var listener: Listener? = null override fun injectWith(injector: ScreenComponent) { injector.inject(this) @@ -93,7 +94,7 @@ class RoomListQuickActionsBottomSheet : viewModel.observeViewEvents { when (it) { - is RoomNotificationSettingsViewEvents.Failure -> listener?.handleFailure(it.throwable) + is RoomNotificationSettingsViewEvents.Failure -> displayErrorDialog(it.throwable) } } } @@ -134,4 +135,12 @@ class RoomListQuickActionsBottomSheet : } } } + + private fun displayErrorDialog(throwable: Throwable) { + MaterialAlertDialogBuilder(requireActivity()) + .setTitle(R.string.dialog_title_error) + .setMessage(errorFormatter.toHumanReadable(throwable)) + .setPositiveButton(R.string.ok, null) + .show() + } }