From 13144f078a4aa9170121642782afacce3e7d1bbf Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Mon, 20 Jun 2022 15:41:43 +0300 Subject: [PATCH] Implement live location promotional bottom sheet. --- ...iveLocationLabsFlagPromotionBottomSheet.kt | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 vector/src/main/java/im/vector/app/features/location/live/LiveLocationLabsFlagPromotionBottomSheet.kt diff --git a/vector/src/main/java/im/vector/app/features/location/live/LiveLocationLabsFlagPromotionBottomSheet.kt b/vector/src/main/java/im/vector/app/features/location/live/LiveLocationLabsFlagPromotionBottomSheet.kt new file mode 100644 index 0000000000..283e44b0e3 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/live/LiveLocationLabsFlagPromotionBottomSheet.kt @@ -0,0 +1,57 @@ +/* + * 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.features.location.live + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment +import im.vector.app.databinding.BottomSheetLiveLocationLabsFlagPromotionBinding + +/** + * Bottom sheet to warn users that feature is still in active development. Users are able to enable labs flag by using the switch in this bottom sheet. + * This should not be shown if the user already enabled the labs flag. + */ +class LiveLocationLabsFlagPromotionBottomSheet + : VectorBaseBottomSheetDialogFragment() { + + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetLiveLocationLabsFlagPromotionBinding { + return BottomSheetLiveLocationLabsFlagPromotionBinding.inflate(inflater, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + initOkButton() + } + + private fun initOkButton() { + views.promoteLiveLocationFlagOkButton.debouncedClicks { + val enableLabsFlag = views.promoteLiveLocationFlagSwitch.isChecked + resultListener?.onBottomSheetResult(ResultListener.RESULT_OK, enableLabsFlag) + dismiss() + } + } + + companion object { + fun newInstance(resultListener: ResultListener): LiveLocationLabsFlagPromotionBottomSheet { + return LiveLocationLabsFlagPromotionBottomSheet().also { + it.resultListener = resultListener + } + } + } +}