2 * Copyright © 2017-2019 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
6 * Privacy Browser is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Browser is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
20 package com.stoutner.privacybrowser.dialogs;
22 import android.annotation.SuppressLint;
23 import android.app.AlertDialog;
24 import android.app.Dialog;
25 import android.content.Context;
26 import android.content.DialogInterface;
27 import android.graphics.Bitmap;
28 import android.graphics.BitmapFactory;
29 import android.graphics.drawable.BitmapDrawable;
30 import android.graphics.drawable.Drawable;
31 import android.net.Uri;
32 import android.net.http.SslCertificate;
33 import android.os.Bundle;
34 import android.text.SpannableStringBuilder;
35 import android.text.Spanned;
36 import android.text.style.ForegroundColorSpan;
37 import android.view.View;
38 import android.view.ViewGroup;
39 import android.view.WindowManager;
40 import android.widget.TextView;
42 import com.google.android.material.tabs.TabLayout;
44 import com.stoutner.privacybrowser.R;
45 import com.stoutner.privacybrowser.activities.MainWebViewActivity;
46 import com.stoutner.privacybrowser.fragments.WebViewTabFragment;
47 import com.stoutner.privacybrowser.views.NestedScrollWebView;
48 import com.stoutner.privacybrowser.views.WrapVerticalContentViewPager;
49 import com.stoutner.privacybrowser.helpers.DomainsDatabaseHelper;
51 import java.io.ByteArrayOutputStream;
52 import java.text.DateFormat;
53 import java.util.ArrayList;
54 import java.util.Date;
56 import androidx.annotation.NonNull;
57 import androidx.core.content.ContextCompat;
58 import androidx.fragment.app.DialogFragment; // The AndroidX dialog fragment must be used or an error is produced on API <=22.
59 import androidx.viewpager.widget.PagerAdapter;
61 public class PinnedMismatchDialog extends DialogFragment {
62 // Declare the class variables.
63 private PinnedMismatchListener pinnedMismatchListener;
64 private NestedScrollWebView nestedScrollWebView;
65 private String currentSslIssuedToCName;
66 private String currentSslIssuedToOName;
67 private String currentSslIssuedToUName;
68 private String currentSslIssuedByCName;
69 private String currentSslIssuedByOName;
70 private String currentSslIssuedByUName;
71 private Date currentSslStartDate;
72 private Date currentSslEndDate;
74 // The public interface is used to send information back to the parent activity.
75 public interface PinnedMismatchListener {
76 void onPinnedMismatchBack();
78 void onPinnedMismatchProceed();
81 // Check to make sure that the parent activity implements the listener.
82 public void onAttach(Context context) {
83 // Run the default commands.
84 super.onAttach(context);
86 // Get a handle for `PinnedSslCertificateMismatchListener` from the launching context.
87 pinnedMismatchListener = (PinnedMismatchListener) context;
90 public static PinnedMismatchDialog displayDialog(long webViewFragmentId, Bitmap favoriteIconBitmap) {
91 // Create a favorite icon byte array output stream.
92 ByteArrayOutputStream favoriteIconByteArrayOutputStream = new ByteArrayOutputStream();
94 // Convert the favorite icon to a PNG and place it in the byte array output stream. `0` is for lossless compression (the only option for a PNG).
95 favoriteIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, favoriteIconByteArrayOutputStream);
97 // Convert the byte array output stream to a byte array.
98 byte[] favoriteIconByteArray = favoriteIconByteArrayOutputStream.toByteArray();
100 // Create an arguments bundle.
101 Bundle argumentsBundle = new Bundle();
103 // Store the variables in the bundle.
104 argumentsBundle.putLong("webview_fragment_id", webViewFragmentId);
105 argumentsBundle.putByteArray("favorite_icon_byte_array", favoriteIconByteArray);
107 // Create a new instance of the pinned mismatch dialog.
108 PinnedMismatchDialog pinnedMismatchDialog = new PinnedMismatchDialog();
110 // Add the arguments bundle to the new instance.
111 pinnedMismatchDialog.setArguments(argumentsBundle);
114 return pinnedMismatchDialog;
117 // `@SuppressLing("InflateParams")` removes the warning about using `null` as the parent view group when inflating the `AlertDialog`.
118 @SuppressLint("InflateParams")
121 public Dialog onCreateDialog(Bundle savedInstanceState) {
122 // Get the arguments.
123 Bundle arguments = getArguments();
125 // Remove the incorrect lint warning below that `.getArguments().getInt()` might be null.
126 assert arguments != null;
128 // Get the current position of this WebView fragment.
129 int webViewPosition = MainWebViewActivity.webViewPagerAdapter.getPositionForId(arguments.getLong("webview_fragment_id"));
131 // Get the favorite icon byte array.
132 byte[] favoriteIconByteArray = arguments.getByteArray("favorite_icon_byte_array");
134 // Remove the incorrect lint warning below that the favorite icon byte array might be null.
135 assert favoriteIconByteArray != null;
137 // Convert the favorite icon byte array to a bitmap.
138 Bitmap favoriteIconBitmap = BitmapFactory.decodeByteArray(favoriteIconByteArray, 0, favoriteIconByteArray.length);
140 // Get the WebView tab fragment.
141 WebViewTabFragment webViewTabFragment = MainWebViewActivity.webViewPagerAdapter.getPageFragment(webViewPosition);
143 // Get the fragment view.
144 View fragmentView = webViewTabFragment.getView();
146 // Remove the incorrect lint warning below that the fragment view might be null.
147 assert fragmentView != null;
149 // Get a handle for the current WebView.
150 nestedScrollWebView = fragmentView.findViewById(R.id.nestedscroll_webview);
152 // Use an alert dialog builder to create the alert dialog.
153 AlertDialog.Builder dialogBuilder;
155 // Set the style according to the theme.
156 if (MainWebViewActivity.darkTheme) {
157 // Set the dialog theme.
158 dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogDark);
160 // Set the dialog theme.
161 dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.PrivacyBrowserAlertDialogLight);
165 Context context = getContext();
167 // Remove the incorrect lint warning below that the context might be null.
168 assert context != null;
170 // Get the default favorite icon drawable. `ContextCompat` must be used until API >= 21.
171 Drawable defaultFavoriteIconDrawable = ContextCompat.getDrawable(context, R.drawable.world);
173 // Cast the favorite icon drawable to a bitmap drawable.
174 BitmapDrawable defaultFavoriteIconBitmapDrawable = (BitmapDrawable) defaultFavoriteIconDrawable;
176 // Remove the incorrect warning below that the favorite icon bitmap drawable might be null.
177 assert defaultFavoriteIconBitmapDrawable != null;
179 // Store the default icon bitmap.
180 Bitmap defaultFavoriteIconBitmap = defaultFavoriteIconBitmapDrawable.getBitmap();
182 // Set the favorite icon as the dialog icon if it exists.
183 if (favoriteIconBitmap.sameAs(defaultFavoriteIconBitmap)) { // There is no website favorite icon.
184 // Set the icon according to the theme.
185 if (MainWebViewActivity.darkTheme) {
186 dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_dark);
188 dialogBuilder.setIcon(R.drawable.ssl_certificate_enabled_light);
190 } else { // There is a favorite icon.
191 // Create a drawable version of the favorite icon.
192 Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), favoriteIconBitmap);
195 dialogBuilder.setIcon(favoriteIconDrawable);
198 // Setup the neutral button.
199 dialogBuilder.setNeutralButton(R.string.update, (DialogInterface dialog, int which) -> {
200 // Initialize the long date variables. If the date is null, a long value of `0` will be stored in the Domains database entry.
201 long currentSslStartDateLong = 0;
202 long currentSslEndDateLong = 0;
204 // Convert the `Dates` into `longs`.
205 if (currentSslStartDate != null) {
206 currentSslStartDateLong = currentSslStartDate.getTime();
209 if (currentSslEndDate != null) {
210 currentSslEndDateLong = currentSslEndDate.getTime();
213 // Initialize the database handler. The `0` specifies the database version, but that is ignored and set instead using a constant in `DomainsDatabaseHelper`.
214 DomainsDatabaseHelper domainsDatabaseHelper = new DomainsDatabaseHelper(getContext(), null, null, 0);
216 // Update the SSL certificate if it is pinned.
217 if (nestedScrollWebView.hasPinnedSslCertificate()) {
218 // Update the pinned SSL certificate in the domain database.
219 domainsDatabaseHelper.updatePinnedSslCertificate(nestedScrollWebView.getDomainSettingsDatabaseId(), currentSslIssuedToCName, currentSslIssuedToOName, currentSslIssuedToUName,
220 currentSslIssuedByCName, currentSslIssuedByOName, currentSslIssuedByUName, currentSslStartDateLong, currentSslEndDateLong);
222 // Update the pinned SSL certificate in the nested scroll WebView.
223 nestedScrollWebView.setPinnedSslCertificate(currentSslIssuedToCName, currentSslIssuedToOName, currentSslIssuedToUName, currentSslIssuedByCName, currentSslIssuedByOName, currentSslIssuedByUName,
224 currentSslStartDate, currentSslEndDate);
227 // Update the IP addresses if they are pinned.
228 if (nestedScrollWebView.hasPinnedIpAddresses()) {
229 // Update the pinned IP addresses in the domain database.
230 domainsDatabaseHelper.updatePinnedIpAddresses(nestedScrollWebView.getDomainSettingsDatabaseId(), nestedScrollWebView.getCurrentIpAddresses());
232 // Update the pinned IP addresses in the nested scroll WebView.
233 nestedScrollWebView.setPinnedIpAddresses(nestedScrollWebView.getCurrentIpAddresses());
237 // Setup the negative button.
238 dialogBuilder.setNegativeButton(R.string.back, (DialogInterface dialog, int which) -> {
239 // Call the `onSslMismatchBack` public interface to send the `WebView` back one page.
240 pinnedMismatchListener.onPinnedMismatchBack();
243 // Setup the positive button.
244 dialogBuilder.setPositiveButton(R.string.proceed, (DialogInterface dialog, int which) -> {
245 // Call the `onSslMismatchProceed` public interface.
246 pinnedMismatchListener.onPinnedMismatchProceed();
250 dialogBuilder.setTitle(R.string.pinned_mismatch);
252 // Remove the incorrect lint warning below that `getLayoutInflater()` might be null.
253 assert getActivity() != null;
255 // Set the layout. The parent view is `null` because it will be assigned by `AlertDialog`.
256 // For some reason, `getLayoutInflater()` without `getActivity()` produces an endless loop (probably a bug that will be fixed at some point in the future).
257 dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.pinned_mismatch_linearlayout, null));
259 // Create an alert dialog from the alert dialog builder.
260 final AlertDialog alertDialog = dialogBuilder.create();
262 // Disable screenshots if not allowed.
263 if (!MainWebViewActivity.allowScreenshots) {
264 // Remove the warning below that `getWindow()` might be null.
265 assert alertDialog.getWindow() != null;
267 // Disable screenshots.
268 alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
271 // Show the alert dialog so the items in the layout can be modified.
274 // Setup the view pager.
275 WrapVerticalContentViewPager wrapVerticalContentViewPager = alertDialog.findViewById(R.id.pinned_ssl_certificate_mismatch_viewpager);
276 wrapVerticalContentViewPager.setAdapter(new pagerAdapter());
278 // Setup the tab layout and connect it to the view pager.
279 TabLayout tabLayout = alertDialog.findViewById(R.id.pinned_ssl_certificate_mismatch_tablayout);
280 tabLayout.setupWithViewPager(wrapVerticalContentViewPager);
282 // `onCreateDialog()` requires the return of an `AlertDialog`.
286 private class pagerAdapter extends PagerAdapter {
288 public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
289 // Check to see if the `View` and the `Object` are the same.
290 return (view == object);
294 public int getCount() {
295 // There are two tabs.
300 public CharSequence getPageTitle(int position) {
301 // Return the current tab title.
302 if (position == 0) { // The current SSL certificate tab.
303 return getString(R.string.current);
304 } else { // The pinned SSL certificate tab.
305 return getString(R.string.pinned);
311 public Object instantiateItem(@NonNull ViewGroup container, int position) {
312 // Inflate the scroll view for this tab.
313 ViewGroup tabViewGroup = (ViewGroup) getLayoutInflater().inflate(R.layout.pinned_mismatch_scrollview, container, false);
315 // Get handles for the `TextViews`.
316 TextView domainNameTextView = tabViewGroup.findViewById(R.id.domain_name);
317 TextView ipAddressesTextView = tabViewGroup.findViewById(R.id.ip_addresses);
318 TextView issuedToCNameTextView = tabViewGroup.findViewById(R.id.issued_to_cname);
319 TextView issuedToONameTextView = tabViewGroup.findViewById(R.id.issued_to_oname);
320 TextView issuedToUNameTextView = tabViewGroup.findViewById(R.id.issued_to_uname);
321 TextView issuedByCNameTextView = tabViewGroup.findViewById(R.id.issued_by_cname);
322 TextView issuedByONameTextView = tabViewGroup.findViewById(R.id.issued_by_oname);
323 TextView issuedByUNameTextView = tabViewGroup.findViewById(R.id.issued_by_uname);
324 TextView startDateTextView = tabViewGroup.findViewById(R.id.start_date);
325 TextView endDateTextView = tabViewGroup.findViewById(R.id.end_date);
328 String domainNameLabel = getString(R.string.domain_label) + " ";
329 String ipAddressesLabel = getString(R.string.ip_addresses) + " ";
330 String cNameLabel = getString(R.string.common_name) + " ";
331 String oNameLabel = getString(R.string.organization) + " ";
332 String uNameLabel = getString(R.string.organizational_unit) + " ";
333 String startDateLabel = getString(R.string.start_date) + " ";
334 String endDateLabel = getString(R.string.end_date) + " ";
336 // Get a URI for the URL.
337 Uri currentUri = Uri.parse(MainWebViewActivity.formattedUrlString);
339 // Get the current host from the URI.
340 String domainName = currentUri.getHost();
342 // Get the current website SSL certificate.
343 SslCertificate sslCertificate = nestedScrollWebView.getCertificate();
345 // Extract the individual pieces of information from the current website SSL certificate if it is not null.
346 if (sslCertificate != null) {
347 currentSslIssuedToCName = sslCertificate.getIssuedTo().getCName();
348 currentSslIssuedToOName = sslCertificate.getIssuedTo().getOName();
349 currentSslIssuedToUName = sslCertificate.getIssuedTo().getUName();
350 currentSslIssuedByCName = sslCertificate.getIssuedBy().getCName();
351 currentSslIssuedByOName = sslCertificate.getIssuedBy().getOName();
352 currentSslIssuedByUName = sslCertificate.getIssuedBy().getUName();
353 currentSslStartDate = sslCertificate.getValidNotBeforeDate();
354 currentSslEndDate = sslCertificate.getValidNotAfterDate();
356 // Initialize the current website SSL certificate variables with blank information.
357 currentSslIssuedToCName = "";
358 currentSslIssuedToOName = "";
359 currentSslIssuedToUName = "";
360 currentSslIssuedByCName = "";
361 currentSslIssuedByOName = "";
362 currentSslIssuedByUName = "";
365 // Get the pinned SSL certificate.
366 ArrayList<Object> pinnedSslCertificateArrayList = nestedScrollWebView.getPinnedSslCertificate();
368 // Extract the arrays from the array list.
369 String[] pinnedSslCertificateStringArray = (String[]) pinnedSslCertificateArrayList.get(0);
370 Date[] pinnedSslCertificateDateArray = (Date[]) pinnedSslCertificateArrayList.get(1);
372 // Setup the domain name spannable string builder.
373 SpannableStringBuilder domainNameStringBuilder = new SpannableStringBuilder(domainNameLabel + domainName);
375 // Initialize the spannable string builders.
376 SpannableStringBuilder ipAddressesStringBuilder;
377 SpannableStringBuilder issuedToCNameStringBuilder;
378 SpannableStringBuilder issuedToONameStringBuilder;
379 SpannableStringBuilder issuedToUNameStringBuilder;
380 SpannableStringBuilder issuedByCNameStringBuilder;
381 SpannableStringBuilder issuedByONameStringBuilder;
382 SpannableStringBuilder issuedByUNameStringBuilder;
383 SpannableStringBuilder startDateStringBuilder;
384 SpannableStringBuilder endDateStringBuilder;
386 // Setup the spannable string builders for each tab.
387 if (position == 0) { // Setup the current settings tab.
388 // Create the string builders.
389 ipAddressesStringBuilder = new SpannableStringBuilder(ipAddressesLabel + nestedScrollWebView.getCurrentIpAddresses());
390 issuedToCNameStringBuilder = new SpannableStringBuilder(cNameLabel + currentSslIssuedToCName);
391 issuedToONameStringBuilder = new SpannableStringBuilder(oNameLabel + currentSslIssuedToOName);
392 issuedToUNameStringBuilder = new SpannableStringBuilder(uNameLabel + currentSslIssuedToUName);
393 issuedByCNameStringBuilder = new SpannableStringBuilder(cNameLabel + currentSslIssuedByCName);
394 issuedByONameStringBuilder = new SpannableStringBuilder(oNameLabel + currentSslIssuedByOName);
395 issuedByUNameStringBuilder = new SpannableStringBuilder(uNameLabel + currentSslIssuedByUName);
397 // Set the dates if they aren't `null`.
398 if (currentSslStartDate == null) {
399 startDateStringBuilder = new SpannableStringBuilder(startDateLabel);
401 startDateStringBuilder = new SpannableStringBuilder(startDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(currentSslStartDate));
404 if (currentSslEndDate == null) {
405 endDateStringBuilder = new SpannableStringBuilder(endDateLabel);
407 endDateStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(currentSslEndDate));
409 } else { // Setup the pinned settings tab.
410 // Create the string builders.
411 ipAddressesStringBuilder = new SpannableStringBuilder(ipAddressesLabel + nestedScrollWebView.getPinnedIpAddresses());
412 issuedToCNameStringBuilder = new SpannableStringBuilder(cNameLabel + pinnedSslCertificateStringArray[0]);
413 issuedToONameStringBuilder = new SpannableStringBuilder(oNameLabel + pinnedSslCertificateStringArray[1]);
414 issuedToUNameStringBuilder = new SpannableStringBuilder(uNameLabel + pinnedSslCertificateStringArray[2]);
415 issuedByCNameStringBuilder = new SpannableStringBuilder(cNameLabel + pinnedSslCertificateStringArray[3]);
416 issuedByONameStringBuilder = new SpannableStringBuilder(oNameLabel + pinnedSslCertificateStringArray[4]);
417 issuedByUNameStringBuilder = new SpannableStringBuilder(uNameLabel + pinnedSslCertificateStringArray[5]);
419 // Set the dates if they aren't `null`.
420 if (pinnedSslCertificateDateArray[0] == null) {
421 startDateStringBuilder = new SpannableStringBuilder(startDateLabel);
423 startDateStringBuilder = new SpannableStringBuilder(startDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(pinnedSslCertificateDateArray[0]));
426 if (pinnedSslCertificateDateArray[1] == null) {
427 endDateStringBuilder = new SpannableStringBuilder(endDateLabel);
429 endDateStringBuilder = new SpannableStringBuilder(endDateLabel + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(pinnedSslCertificateDateArray[1]));
433 // Create a red foreground color span. The deprecated `getResources().getColor` must be used until the minimum API >= 23.
434 @SuppressWarnings("deprecation") ForegroundColorSpan redColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.red_a700));
436 // Create a blue foreground color span.
437 ForegroundColorSpan blueColorSpan;
439 // Set the blue color span according to the theme. The deprecated `getResources().getColor` must be used until the minimum API >= 23.
440 if (MainWebViewActivity.darkTheme) {
441 //noinspection deprecation
442 blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_400));
444 //noinspection deprecation
445 blueColorSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue_700));
448 // Set the domain name to be blue.
449 domainNameStringBuilder.setSpan(blueColorSpan, domainNameLabel.length(), domainNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
451 // Color coordinate the IP addresses if they are pinned.
452 if (nestedScrollWebView.hasPinnedIpAddresses()) {
453 if (nestedScrollWebView.getCurrentIpAddresses().equals(nestedScrollWebView.getPinnedIpAddresses())) {
454 ipAddressesStringBuilder.setSpan(blueColorSpan, ipAddressesLabel.length(), ipAddressesStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
456 ipAddressesStringBuilder.setSpan(redColorSpan, ipAddressesLabel.length(), ipAddressesStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
460 // Color coordinate the SSL certificate fields if they are pinned.
461 if (nestedScrollWebView.hasPinnedSslCertificate()) {
462 if (currentSslIssuedToCName.equals(pinnedSslCertificateStringArray[0])) {
463 issuedToCNameStringBuilder.setSpan(blueColorSpan, cNameLabel.length(), issuedToCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
465 issuedToCNameStringBuilder.setSpan(redColorSpan, cNameLabel.length(), issuedToCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
468 if (currentSslIssuedToOName.equals(pinnedSslCertificateStringArray[1])) {
469 issuedToONameStringBuilder.setSpan(blueColorSpan, oNameLabel.length(), issuedToONameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
471 issuedToONameStringBuilder.setSpan(redColorSpan, oNameLabel.length(), issuedToONameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
474 if (currentSslIssuedToUName.equals(pinnedSslCertificateStringArray[2])) {
475 issuedToUNameStringBuilder.setSpan(blueColorSpan, uNameLabel.length(), issuedToUNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
477 issuedToUNameStringBuilder.setSpan(redColorSpan, uNameLabel.length(), issuedToUNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
480 if (currentSslIssuedByCName.equals(pinnedSslCertificateStringArray[3])) {
481 issuedByCNameStringBuilder.setSpan(blueColorSpan, cNameLabel.length(), issuedByCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
483 issuedByCNameStringBuilder.setSpan(redColorSpan, cNameLabel.length(), issuedByCNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
486 if (currentSslIssuedByOName.equals(pinnedSslCertificateStringArray[4])) {
487 issuedByONameStringBuilder.setSpan(blueColorSpan, oNameLabel.length(), issuedByONameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
489 issuedByONameStringBuilder.setSpan(redColorSpan, oNameLabel.length(), issuedByONameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
492 if (currentSslIssuedByUName.equals(pinnedSslCertificateStringArray[5])) {
493 issuedByUNameStringBuilder.setSpan(blueColorSpan, uNameLabel.length(), issuedByUNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
495 issuedByUNameStringBuilder.setSpan(redColorSpan, uNameLabel.length(), issuedByUNameStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
498 if ((currentSslStartDate != null) && currentSslStartDate.equals(pinnedSslCertificateDateArray[0])) {
499 startDateStringBuilder.setSpan(blueColorSpan, startDateLabel.length(), startDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
501 startDateStringBuilder.setSpan(redColorSpan, startDateLabel.length(), startDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
504 if ((currentSslEndDate != null) && currentSslEndDate.equals(pinnedSslCertificateDateArray[1])) {
505 endDateStringBuilder.setSpan(blueColorSpan, endDateLabel.length(), endDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
507 endDateStringBuilder.setSpan(redColorSpan, endDateLabel.length(), endDateStringBuilder.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
511 // Display the strings.
512 domainNameTextView.setText(domainNameStringBuilder);
513 ipAddressesTextView.setText(ipAddressesStringBuilder);
514 issuedToCNameTextView.setText(issuedToCNameStringBuilder);
515 issuedToONameTextView.setText(issuedToONameStringBuilder);
516 issuedToUNameTextView.setText(issuedToUNameStringBuilder);
517 issuedByCNameTextView.setText(issuedByCNameStringBuilder);
518 issuedByONameTextView.setText(issuedByONameStringBuilder);
519 issuedByUNameTextView.setText(issuedByUNameStringBuilder);
520 startDateTextView.setText(startDateStringBuilder);
521 endDateTextView.setText(endDateStringBuilder);
524 container.addView(tabViewGroup);