X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyCell.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Fdialogs%2FPermissionsDialog.kt;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Fdialogs%2FPermissionsDialog.kt;h=0000000000000000000000000000000000000000;hp=8cf799e7b3cd066ebe34117f5c509db9277aa498;hb=70fa89f618b62a9d17064699ec130341069aa77d;hpb=578979a47d905469cfc5c7cdc748fe9b539437e2 diff --git a/app/src/main/java/com/stoutner/privacycell/dialogs/PermissionsDialog.kt b/app/src/main/java/com/stoutner/privacycell/dialogs/PermissionsDialog.kt deleted file mode 100644 index 8cf799e..0000000 --- a/app/src/main/java/com/stoutner/privacycell/dialogs/PermissionsDialog.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.res.Configuration -import android.os.Bundle -import android.webkit.WebView - -import androidx.appcompat.app.AlertDialog -import androidx.fragment.app.DialogFragment -import androidx.webkit.WebSettingsCompat -import androidx.webkit.WebViewFeature - -import com.stoutner.privacycell.R - -class PermissionsDialog : DialogFragment() { - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - // Use a builder to create the alert dialog. - val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.Theme_PrivacyCellAlertDialog) - - // Set the icon. - dialogBuilder.setIcon(R.drawable.permissions) - - // Set the title. - dialogBuilder.setTitle(R.string.permissions) - - // Set the view. - dialogBuilder.setView(R.layout.permissions_dialog) - - // Set a listener on the close button. Using `null` as the listener closes the dialog without doing anything else. - dialogBuilder.setNegativeButton(R.string.close, null) - - // Create an alert dialog from the builder. - val alertDialog = dialogBuilder.create() - - // The alert dialog needs to be shown before the contents can be modified. - alertDialog.show() - - // Get a handle for the WebView. - val webView = alertDialog.findViewById(R.id.webview)!! - - // Get the current theme status. - val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK - - // Check to see if the app is in night mode. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) { // The app is in night mode. - // Apply the dark WebView theme. - WebSettingsCompat.setForceDark(webView.settings, WebSettingsCompat.FORCE_DARK_ON) - } - - // Create a WebView asset loader. TODO. - // val webViewAssetLoader = WebViewAssetLoader.Builder().addPathHandler("/assets/", WebViewAssetLoader.AssetsPathHandler(requireContext())).build() - - // Load the WebView data. - webView.loadUrl("file:///android_asset/en/permissions.html") - - // Return the alert dialog. - return alertDialog - } -} \ No newline at end of file