X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2FViewSslCertificate.java;h=76b6abe6097147ff1c549943e93b5f0a0ca5cd01;hb=7d632afdd10cad5b4d62fce37707eaceebe260cb;hp=8b370748ae7653555c08b6c6a8b4e15825c7ef1b;hpb=757139ad59282fb8400bc641a4be574e0b88de49;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/ViewSslCertificate.java b/app/src/main/java/com/stoutner/privacybrowser/ViewSslCertificate.java index 8b370748..76b6abe6 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/ViewSslCertificate.java +++ b/app/src/main/java/com/stoutner/privacybrowser/ViewSslCertificate.java @@ -19,6 +19,7 @@ package com.stoutner.privacybrowser; +import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; @@ -26,17 +27,16 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.http.SslCertificate; import android.os.Bundle; -import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; import android.view.LayoutInflater; import android.widget.TextView; -import org.w3c.dom.Text; - import java.util.Date; +// `@SuppressLing("InflateParams")` removes the warning about using `null` as the parent view group when inflating the `AlertDialog`. +@SuppressLint("InflateParams") public class ViewSslCertificate extends DialogFragment { public Dialog onCreateDialog(Bundle savedInstanceState) { // Get the activity's layout inflater. @@ -53,7 +53,7 @@ public class ViewSslCertificate extends DialogFragment { dialogBuilder.setNegativeButton(R.string.close, null); // Check to see if the website is encrypted. - if (MainWebViewActivity.mainWebView.getCertificate() == null) { // The website is not encrypted. + if (MainWebViewActivity.sslCertificate == null) { // The website is not encrypted. // Set the title. dialogBuilder.setTitle(R.string.unencrypted_website); @@ -100,7 +100,7 @@ public class ViewSslCertificate extends DialogFragment { String endDateLabel = getString(R.string.end_date) + " "; // Get the SSL certificate. - SslCertificate sslCertificate = MainWebViewActivity.mainWebView.getCertificate(); + SslCertificate sslCertificate = MainWebViewActivity.sslCertificate; // Get the strings from the SSL certificate. String issuedToCNameString = sslCertificate.getIssuedTo().getCName(); @@ -112,7 +112,7 @@ public class ViewSslCertificate extends DialogFragment { Date startDate = sslCertificate.getValidNotBeforeDate(); Date endDate = sslCertificate.getValidNotAfterDate(); - // Create a `SpannableStringBuilder` for each item. + // Create a `SpannableStringBuilder` for each `TextView` that needs multiple colors of text. SpannableStringBuilder issuedToCNameStringBuilder = new SpannableStringBuilder(cNameLabel + issuedToCNameString); SpannableStringBuilder issuedToONameStringBuilder = new SpannableStringBuilder(oNameLabel + issuedToONameString); SpannableStringBuilder issuedToUNameStringBuilder = new SpannableStringBuilder(uNameLabel + issuedToUNameString); @@ -123,10 +123,9 @@ public class ViewSslCertificate extends DialogFragment { SpannableStringBuilder endDateStringBuilder = new SpannableStringBuilder(endDateLabel + endDate.toString()); // Create a blue `ForegroundColorSpan`. We have to use the deprecated `getColor` until API >= 23. - ForegroundColorSpan blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue)); + @SuppressWarnings("deprecation") ForegroundColorSpan blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700)); - // Setup the spans to display the certificate information in blue. - // `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction. + // Setup the spans to display the certificate information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction. issuedToCNameStringBuilder.setSpan(blueColorSpan, cNameLabel.length(), issuedToCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); issuedToONameStringBuilder.setSpan(blueColorSpan, oNameLabel.length(), issuedToONameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); issuedToUNameStringBuilder.setSpan(blueColorSpan, uNameLabel.length(), issuedToUNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);