]> gitweb.stoutner.com Git - PrivacyCell.git/blobdiff - app/src/main/java/com/stoutner/privacycell/dialogs/WebViewDialog.kt
Release 1.11.
[PrivacyCell.git] / app / src / main / java / com / stoutner / privacycell / dialogs / WebViewDialog.kt
index 3b448bd666f0e75b6fd84902884e4abe3aa5f0a1..071f17cdeac61dd6bbf52318b00d05f478c60bc5 100644 (file)
@@ -1,27 +1,26 @@
-/*
- * Copyright © 2021 Soren Stoutner <soren@stoutner.com>.
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2021-2022, 2025 Soren Stoutner <soren@stoutner.com>
  *
- * This file is part of Privacy Cell <https://www.stoutner.com/privacy-cell>.
+ * This file is part of Privacy Cell <https://www.stoutner.com/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.
+ * This program 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.
+ * This program 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 Cell.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 package com.stoutner.privacycell.dialogs
 
 import android.app.Dialog
 import android.content.Intent
-import android.content.res.Configuration
 import android.os.Bundle
 import android.webkit.WebResourceRequest
 import android.webkit.WebResourceResponse
@@ -30,9 +29,7 @@ import android.webkit.WebViewClient
 
 import androidx.appcompat.app.AlertDialog
 import androidx.fragment.app.DialogFragment
-import androidx.webkit.WebSettingsCompat
 import androidx.webkit.WebViewAssetLoader
-import androidx.webkit.WebViewFeature
 
 import com.stoutner.privacycell.R
 
@@ -49,31 +46,33 @@ class WebViewDialog : DialogFragment() {
         const val LICENSES = 3
         const val CONTRIBUTORS = 4
         const val STINGRAY = 5
-        const val NETWORK_UNKNOWN = 6
-        const val NETWORK_GPRS = 7
-        const val NETWORK_EDGE = 8
-        const val NETWORK_UMTS = 9
-        const val NETWORK_CDMA = 10
-        const val NETWORK_EVDO_0 = 11
-        const val NETWORK_EVDO_A = 12
-        const val NETWORK_1xRTT = 13
-        const val NETWORK_HSDPA = 14
-        const val NETWORK_HSUPA = 15
-        const val NETWORK_HSPA = 16
-        const val NETWORK_IDEN = 17
-        const val NETWORK_EVDO_B = 18
-        const val NETWORK_LTE = 19
-        const val NETWORK_EHRPD = 20
-        const val NETWORK_HSPAP = 21
-        const val NETWORK_GSM = 22
-        const val NETWORK_TD_SCDMA = 23
-        const val NETWORK_IWLAN = 24
-        const val NETWORK_NR = 25
-        const val OVERRIDE_NETWORK_NONE = 26
-        const val OVERRIDE_NETWORK_LTE_CA = 27
-        const val OVERRIDE_NETWORK_LTE_ADVANCED_PRO = 28
-        const val OVERRIDE_NETWORK_NR_NSA = 29
-        const val OVERRIDE_NETWORK_NR_NSA_MMWAVE = 30
+        const val ANTIQUATED_NETWORK = 6
+        const val NETWORK_UNKNOWN = 7
+        const val NETWORK_GPRS = 8
+        const val NETWORK_EDGE = 9
+        const val NETWORK_UMTS = 10
+        const val NETWORK_CDMA = 11
+        const val NETWORK_EVDO_0 = 12
+        const val NETWORK_EVDO_A = 13
+        const val NETWORK_1XRTT = 14
+        const val NETWORK_HSDPA = 15
+        const val NETWORK_HSUPA = 16
+        const val NETWORK_HSPA = 17
+        const val NETWORK_IDEN = 18
+        const val NETWORK_EVDO_B = 19
+        const val NETWORK_LTE = 20
+        const val NETWORK_EHRPD = 21
+        const val NETWORK_HSPAP = 22
+        const val NETWORK_GSM = 23
+        const val NETWORK_TD_SCDMA = 24
+        const val NETWORK_IWLAN = 25
+        const val NETWORK_NR = 26
+        const val OVERRIDE_NETWORK_NONE = 27
+        const val OVERRIDE_NETWORK_LTE_CA = 28
+        const val OVERRIDE_NETWORK_LTE_ADVANCED_PRO = 29
+        const val OVERRIDE_NETWORK_NR_NSA = 30
+        const val OVERRIDE_NETWORK_NR_NSA_MMWAVE = 31  // Can be removed once the minimum API >= 31.
+        const val OVERRIDE_NETWORK_NR_ADVANCED = 32
     }
 
     // Define the class views.
@@ -148,15 +147,23 @@ class WebViewDialog : DialogFragment() {
 
             STINGRAY -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.secure_5g_nr_sa)
+                dialogBuilder.setIcon(R.drawable.secure)
 
                 // Set the tile.
                 dialogBuilder.setTitle(R.string.stingrays)
             }
 
+            ANTIQUATED_NETWORK -> {
+                // Set the icon.
+                dialogBuilder.setIcon(R.drawable.antiquated)
+
+                // Set the title.
+                dialogBuilder.setTitle(R.string.antiquated_network_title)
+            }
+
             NETWORK_UNKNOWN -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.unknown)
@@ -164,7 +171,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_GPRS -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.gprs)
@@ -172,7 +179,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_EDGE -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.edge)
@@ -180,7 +187,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_UMTS -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.umts)
@@ -188,7 +195,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_CDMA -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.cdma)
@@ -196,7 +203,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_EVDO_0 -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.evdo_0)
@@ -204,15 +211,15 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_EVDO_A -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.evdo_a)
             }
 
-            NETWORK_1xRTT -> {
+            NETWORK_1XRTT -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.rtt)
@@ -220,7 +227,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_HSDPA -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.hsdpa)
@@ -228,7 +235,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_HSUPA -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.hsupa)
@@ -236,7 +243,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_HSPA -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.hspa)
@@ -244,7 +251,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_IDEN -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.iden)
@@ -252,7 +259,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_EVDO_B -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.evdo_b)
@@ -260,7 +267,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_LTE -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.lte)
@@ -268,7 +275,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_EHRPD -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.ehrpd)
@@ -276,7 +283,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_HSPAP -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.hspap)
@@ -284,7 +291,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_GSM -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.gsm)
@@ -292,7 +299,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_TD_SCDMA -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.td_scdma)
@@ -300,7 +307,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_IWLAN -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.iwlan)
@@ -308,7 +315,7 @@ class WebViewDialog : DialogFragment() {
 
             NETWORK_NR -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.nr)
@@ -316,7 +323,7 @@ class WebViewDialog : DialogFragment() {
 
             OVERRIDE_NETWORK_NONE -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.none)
@@ -324,7 +331,7 @@ class WebViewDialog : DialogFragment() {
 
             OVERRIDE_NETWORK_LTE_CA -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.lte_ca)
@@ -332,15 +339,15 @@ class WebViewDialog : DialogFragment() {
 
             OVERRIDE_NETWORK_LTE_ADVANCED_PRO -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
-                dialogBuilder.setTitle(R.string.lte_ca)
+                dialogBuilder.setTitle(R.string.lte_advanced_pro)
             }
 
             OVERRIDE_NETWORK_NR_NSA -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.nr_nsa)
@@ -348,11 +355,19 @@ class WebViewDialog : DialogFragment() {
 
             OVERRIDE_NETWORK_NR_NSA_MMWAVE -> {
                 // Set the icon.
-                dialogBuilder.setIcon(R.drawable.privacy_policy)
+                dialogBuilder.setIcon(R.drawable.protocols)
 
                 // Set the title.
                 dialogBuilder.setTitle(R.string.nr_nsa_mmwave)
             }
+
+            OVERRIDE_NETWORK_NR_ADVANCED -> {
+                // Set the icon.
+                dialogBuilder.setIcon(R.drawable.protocols)
+
+                // Set the title.
+                dialogBuilder.setTitle(R.string.nr_advanced)
+            }
         }
 
         // Set the view.
@@ -370,15 +385,6 @@ class WebViewDialog : DialogFragment() {
         // Get a handle for the WebView.
         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.
         val webViewAssetLoader = WebViewAssetLoader.Builder().addPathHandler("/assets/", WebViewAssetLoader.AssetsPathHandler(requireContext())).build()
 
@@ -414,6 +420,7 @@ class WebViewDialog : DialogFragment() {
             LICENSES -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/licenses.html")
             CONTRIBUTORS -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/contributors.html")
             STINGRAY -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/stingrays.html")
+            ANTIQUATED_NETWORK -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/antiquated_network.html")
             NETWORK_UNKNOWN -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_unknown.html")
             NETWORK_GPRS -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_gprs.html")
             NETWORK_EDGE -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_edge.html")
@@ -421,7 +428,7 @@ class WebViewDialog : DialogFragment() {
             NETWORK_CDMA -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_cdma.html")
             NETWORK_EVDO_0 -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_evdo_0.html")
             NETWORK_EVDO_A -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_evdo_a.html")
-            NETWORK_1xRTT -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_1xrtt.html")
+            NETWORK_1XRTT -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_1xrtt.html")
             NETWORK_HSDPA -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_hsdpa.html")
             NETWORK_HSUPA -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_hsupa.html")
             NETWORK_HSPA -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/network_hspa.html")
@@ -439,7 +446,9 @@ class WebViewDialog : DialogFragment() {
             OVERRIDE_NETWORK_LTE_ADVANCED_PRO -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) +
                     "/explanations/override_network_lte_advanced_pro.html")
             OVERRIDE_NETWORK_NR_NSA -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/override_network_nr_nsa.html")
+            // The item below can be removed once the minimum API >= 31.
             OVERRIDE_NETWORK_NR_NSA_MMWAVE -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/override_network_nr_nsa_mmwave.html")
+            OVERRIDE_NETWORK_NR_ADVANCED -> webView.loadUrl("https://appassets.androidplatform.net/assets/" + getString(R.string.asset_directory) + "/explanations/override_network_nr_advanced.html")
         }
 
         // Scroll the WebView if the saved instance state is not null.
@@ -460,4 +469,4 @@ class WebViewDialog : DialogFragment() {
         // Save the scroll position.
         savedInstanceState.putInt(SCROLL_Y, webView.scrollY)
     }
-}
\ No newline at end of file
+}