1 /** <lambda>null2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * ``` 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * ``` 10 * 11 * Unless required by applicable law or agreed to in writing, software distributed under the License 12 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 * or implied. See the License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 package com.android.healthconnect.controller.deletion 17 18 import android.app.Dialog 19 import android.os.Bundle 20 import androidx.fragment.app.DialogFragment 21 import androidx.fragment.app.setFragmentResult 22 import com.android.healthconnect.controller.R 23 import com.android.healthconnect.controller.deletion.DeletionConstants.TRY_AGAIN_EVENT 24 import com.android.healthconnect.controller.shared.dialog.AlertDialogBuilder 25 import com.android.healthconnect.controller.utils.logging.FailedDialogElement 26 import dagger.hilt.android.AndroidEntryPoint 27 28 /** A deletion {@link DialogFragment} notifying user about a failed deletion. */ 29 @Deprecated("This won't be used once the NEW_INFORMATION_ARCHITECTURE feature is enabled.") 30 @AndroidEntryPoint(DialogFragment::class) 31 class FailedDialogFragment : Hilt_FailedDialogFragment() { 32 33 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { 34 return AlertDialogBuilder(this, FailedDialogElement.DELETION_DIALOG_ERROR_CONTAINER) 35 .setIcon(R.attr.failureIcon) 36 .setTitle(R.string.delete_dialog_failure_title) 37 .setMessage(R.string.delete_dialog_failure_message) 38 .setPositiveButton( 39 R.string.delete_dialog_failure_try_again_button, 40 FailedDialogElement.DELETION_DIALOG_ERROR_TRY_AGAIN_BUTTON) { _, _ -> 41 setFragmentResult(TRY_AGAIN_EVENT, Bundle()) 42 } 43 .setNeutralButton( 44 R.string.delete_dialog_failure_close_button, 45 FailedDialogElement.DELETION_DIALOG_ERROR_CLOSE_BUTTON) 46 .create() 47 } 48 49 companion object { 50 const val TAG = "FailedDialogFragment" 51 } 52 } 53