X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Fdialogs%2FWebViewDialog.kt;h=aa7d296a141def98def55dd87cfd32b767038b85;hb=HEAD;hp=ab99a11b5950187f75338d403905932ed8ae4762;hpb=dc76c6f07fd9a5718049d160e079842fa60ff406;p=PrivacyCell.git diff --git a/app/src/main/java/com/stoutner/privacycell/dialogs/WebViewDialog.kt b/app/src/main/java/com/stoutner/privacycell/dialogs/WebViewDialog.kt index ab99a11..aa7d296 100644 --- a/app/src/main/java/com/stoutner/privacycell/dialogs/WebViewDialog.kt +++ b/app/src/main/java/com/stoutner/privacycell/dialogs/WebViewDialog.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2021-2022 Soren Stoutner . + * Copyright 2021-2022 Soren Stoutner . * * This file is part of Privacy Cell . * @@ -21,7 +21,6 @@ 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,32 +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 // Can be removed once the minimum API >= 31. - const val OVERRIDE_NETWORK_NR_ADVANCED = 31 + 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. @@ -149,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) @@ -165,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) @@ -173,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) @@ -181,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) @@ -189,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) @@ -197,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) @@ -205,7 +211,7 @@ 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) @@ -213,7 +219,7 @@ class WebViewDialog : DialogFragment() { NETWORK_1xRTT -> { // Set the icon. - dialogBuilder.setIcon(R.drawable.privacy_policy) + dialogBuilder.setIcon(R.drawable.protocols) // Set the title. dialogBuilder.setTitle(R.string.rtt) @@ -221,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) @@ -229,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) @@ -237,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) @@ -245,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) @@ -253,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) @@ -261,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) @@ -269,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) @@ -277,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) @@ -285,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) @@ -293,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) @@ -301,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) @@ -309,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) @@ -317,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) @@ -325,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) @@ -333,7 +339,7 @@ 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_advanced_pro) @@ -341,7 +347,7 @@ class WebViewDialog : DialogFragment() { 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) @@ -349,7 +355,7 @@ 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) @@ -357,7 +363,7 @@ class WebViewDialog : DialogFragment() { OVERRIDE_NETWORK_NR_ADVANCED -> { // Set the icon. - dialogBuilder.setIcon(R.drawable.privacy_policy) + dialogBuilder.setIcon(R.drawable.protocols) // Set the title. dialogBuilder.setTitle(R.string.nr_advanced) @@ -379,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() @@ -423,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") @@ -471,4 +469,4 @@ class WebViewDialog : DialogFragment() { // Save the scroll position. savedInstanceState.putInt(SCROLL_Y, webView.scrollY) } -} \ No newline at end of file +}