1 /* <lambda>null2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.wallpaper.picker.preview.ui.view 18 19 import android.app.Activity 20 import android.app.AlertDialog 21 import android.app.Dialog 22 23 /** The dialog is used for image effect preview, with a continue button and a cancel button. */ 24 class ImageEffectDialog( 25 activity: Activity, 26 title: String, 27 description: String, 28 cancelButtonString: String, 29 continueButtonString: String, 30 ) { 31 32 var onDismiss: (() -> Unit)? = null 33 var onContinue: (() -> Unit)? = null 34 35 private val dialog: Dialog 36 37 init { 38 dialog = 39 AlertDialog.Builder(activity) 40 .setTitle(title) 41 .setMessage(description) 42 .setOnDismissListener { onDismiss?.invoke() } 43 .setNegativeButton(cancelButtonString, null) 44 .setPositiveButton(continueButtonString) { _, _ -> onContinue?.invoke() } 45 .create() 46 } 47 48 fun show() { 49 dialog.show() 50 } 51 52 fun dismiss() { 53 dialog.dismiss() 54 } 55 } 56