X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyCell.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Fdialogs%2FPhonePermissionDialog.kt;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Fdialogs%2FPhonePermissionDialog.kt;h=f6a0d3877b98eb41b0ee2fc8e7f40a08d99e441e;hp=0000000000000000000000000000000000000000;hb=135083ed1d09126bde43ded4befc444040a13ed8;hpb=703dff21803cc19357c55982e596d114e81348c8 diff --git a/app/src/main/java/com/stoutner/privacycell/dialogs/PhonePermissionDialog.kt b/app/src/main/java/com/stoutner/privacycell/dialogs/PhonePermissionDialog.kt new file mode 100644 index 0000000..f6a0d38 --- /dev/null +++ b/app/src/main/java/com/stoutner/privacycell/dialogs/PhonePermissionDialog.kt @@ -0,0 +1,71 @@ +/* + * Copyright © 2021 Soren Stoutner . + * + * This file is part of Privacy Cell . + * + * Privacy Cell is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Privacy Cell is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Privacy Browser. If not, see . + */ + +package com.stoutner.privacycell.dialogs + +import android.app.Dialog +import android.content.Context +import android.content.DialogInterface +import android.os.Bundle + +import androidx.appcompat.app.AlertDialog +import androidx.fragment.app.DialogFragment + +import com.stoutner.privacycell.R + +class PhonePermissionDialog : DialogFragment() { + // Declare the listener. + private lateinit var storagePermissionDialogListener: StoragePermissionDialogListener + + // The public interface is used to send information back to the parent activity. + interface StoragePermissionDialogListener { + fun onCloseStoragePermissionDialog() + } + + override fun onAttach(context: Context) { + // Run the default commands. + super.onAttach(context) + + // Get a handle for the listener from the launching context. + storagePermissionDialogListener = context as StoragePermissionDialogListener + } + + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + // Use a builder to create the alert dialog. + val dialogBuilder: AlertDialog.Builder = AlertDialog.Builder(requireContext(), R.style.Theme_PrivacyCellAlertDialog) + + // Set the icon. + dialogBuilder.setIcon(R.drawable.phone_permission) + + // Set the title. + dialogBuilder.setTitle(R.string.phone_permission) + + // Set the text. + dialogBuilder.setMessage(R.string.phone_permission_text) + + // Set the close button listener. + dialogBuilder.setNegativeButton(R.string.ok) { _: DialogInterface, _: Int -> + // Call the storage permission dialog listener. + storagePermissionDialogListener.onCloseStoragePermissionDialog() + } + + // Return the alert dialog. + return dialogBuilder.create() + } +} \ No newline at end of file