]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/helpers/CheckPinnedMismatchHelper.kt
First wrong button text in View Headers in night theme. https://redmine.stoutner...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / helpers / CheckPinnedMismatchHelper.kt
index 8fa8369fc365e0ae192d60655e6c8a948c662888..1dd50853425fec15898a0b75b0188a96280922b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2018-2019,2021-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2018-2019,2021-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
  *
  * You should have received a copy of the GNU General Public License
  * along with Privacy Browser Android.  If not, see <http://www.gnu.org/licenses/>.
  */
-package com.stoutner.privacybrowser.helpers
 
-import android.app.Activity
+package com.stoutner.privacybrowser.helpers
 
 import androidx.fragment.app.DialogFragment
 import androidx.fragment.app.FragmentManager
 
-import com.stoutner.privacybrowser.R
 import com.stoutner.privacybrowser.activities.MainWebViewActivity
-import com.stoutner.privacybrowser.dataclasses.PendingDialog
+import com.stoutner.privacybrowser.dataclasses.PendingDialogDataClass
 import com.stoutner.privacybrowser.dialogs.PinnedMismatchDialog.Companion.displayDialog
 import com.stoutner.privacybrowser.views.NestedScrollWebView
 
@@ -34,8 +32,7 @@ import java.lang.Exception
 import java.util.Date
 
 object CheckPinnedMismatchHelper {
-    @JvmStatic
-    fun checkPinnedMismatch(activity: Activity, fragmentManager: FragmentManager, nestedScrollWebView: NestedScrollWebView) {
+    fun checkPinnedMismatch(nestedScrollWebView: NestedScrollWebView, supportFragmentManager: FragmentManager, pinnedMismatchString: String) {
         // Initialize the current SSL certificate variables.
         var currentWebsiteIssuedToCName = ""
         var currentWebsiteIssuedToOName = ""
@@ -114,23 +111,24 @@ object CheckPinnedMismatchHelper {
         }
 
         // Check to see if the pinned information matches the current information.
-        if (((nestedScrollWebView.pinnedIpAddresses != "") && (nestedScrollWebView.currentIpAddresses != nestedScrollWebView.pinnedIpAddresses)) ||
-            (nestedScrollWebView.hasPinnedSslCertificate() && ((currentWebsiteIssuedToCName != pinnedSslIssuedToCName) ||
-                    (currentWebsiteIssuedToOName != pinnedSslIssuedToOName) || (currentWebsiteIssuedToUName != pinnedSslIssuedToUName) ||
-                    (currentWebsiteIssuedByCName != pinnedSslIssuedByCName) || (currentWebsiteIssuedByOName != pinnedSslIssuedByOName) ||
-                    (currentWebsiteIssuedByUName != pinnedSslIssuedByUName) || (currentWebsiteSslStartDateString != pinnedSslStartDateString) ||
-                    (currentWebsiteSslEndDateString != pinnedSslEndDateString)))) {
+        if (((nestedScrollWebView.pinnedIpAddresses.isNotEmpty()) && (nestedScrollWebView.currentIpAddresses != nestedScrollWebView.pinnedIpAddresses)) ||
+             (nestedScrollWebView.hasPinnedSslCertificate() && ((currentWebsiteIssuedToCName != pinnedSslIssuedToCName) ||
+             (currentWebsiteIssuedToOName != pinnedSslIssuedToOName) || (currentWebsiteIssuedToUName != pinnedSslIssuedToUName) ||
+             (currentWebsiteIssuedByCName != pinnedSslIssuedByCName) || (currentWebsiteIssuedByOName != pinnedSslIssuedByOName) ||
+             (currentWebsiteIssuedByUName != pinnedSslIssuedByUName) || (currentWebsiteSslStartDateString != pinnedSslStartDateString) ||
+             (currentWebsiteSslEndDateString != pinnedSslEndDateString)))) {
+
             // Get a handle for the pinned mismatch alert dialog.
             val pinnedMismatchDialogFragment: DialogFragment = displayDialog(nestedScrollWebView.webViewFragmentId)
 
             // Try to show the dialog.  Sometimes the window is not active.
             try {
                 // Show the pinned mismatch alert dialog.
-                pinnedMismatchDialogFragment.show(fragmentManager, activity.getString(R.string.pinned_mismatch))
+                pinnedMismatchDialogFragment.show(supportFragmentManager, pinnedMismatchString)
             } catch (exception: Exception) {
                 // Add the dialog to the pending dialog array list.  It will be displayed in `onStart()`.
-                MainWebViewActivity.pendingDialogsArrayList.add(PendingDialog(pinnedMismatchDialogFragment, activity.getString(R.string.pinned_mismatch)))
+                MainWebViewActivity.pendingDialogsArrayList.add(PendingDialogDataClass(pinnedMismatchDialogFragment, pinnedMismatchString))
             }
         }
     }
-}
\ No newline at end of file
+}