- case R.id.forward:
- if (currentWebView.canGoForward()) {
- // Reset the current domain name so that navigation works if third-party requests are blocked.
- currentWebView.resetCurrentDomainName();
-
- // Set navigating history so that the domain settings are applied when the new URL is loaded.
- currentWebView.setNavigatingHistory(true);
-
- // Load the next website in the history.
- currentWebView.goForward();
- }
- break;
-
- case R.id.history:
- // Instantiate the URL history dialog.
- DialogFragment urlHistoryDialogFragment = UrlHistoryDialog.loadBackForwardList(currentWebView.getWebViewFragmentId());
-
- // Show the URL history dialog.
- urlHistoryDialogFragment.show(getSupportFragmentManager(), getString(R.string.history));
- break;
-
- case R.id.requests:
- // Populate the resource requests.
- RequestsActivity.resourceRequests = currentWebView.getResourceRequests();
-
- // Create an intent to launch the Requests activity.
- Intent requestsIntent = new Intent(this, RequestsActivity.class);
-
- // Add the block third-party requests status to the intent.
- requestsIntent.putExtra("block_all_third_party_requests", currentWebView.isBlocklistEnabled(NestedScrollWebView.THIRD_PARTY_REQUESTS));
-
- // Make it so.
- startActivity(requestsIntent);
- break;
-
- case R.id.downloads:
- // Launch the system Download Manager.
- Intent downloadManagerIntent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS);
-
- // Launch as a new task so that Download Manager and Privacy Browser show as separate windows in the recent tasks list.
- downloadManagerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- startActivity(downloadManagerIntent);
- break;
-
- case R.id.domains:
- // Set the flag to reapply the domain settings on restart when returning from Domain Settings.
- reapplyDomainSettingsOnRestart = true;
-
- // Launch the domains activity.
- Intent domainsIntent = new Intent(this, DomainsActivity.class);
-
- // Add the extra information to the intent.
- domainsIntent.putExtra("current_url", currentWebView.getUrl());
-
- // Get the current certificate.
- SslCertificate sslCertificate = currentWebView.getCertificate();
-
- // Check to see if the SSL certificate is populated.
- if (sslCertificate != null) {
- // Extract the certificate to strings.
- String issuedToCName = sslCertificate.getIssuedTo().getCName();
- String issuedToOName = sslCertificate.getIssuedTo().getOName();
- String issuedToUName = sslCertificate.getIssuedTo().getUName();
- String issuedByCName = sslCertificate.getIssuedBy().getCName();
- String issuedByOName = sslCertificate.getIssuedBy().getOName();
- String issuedByUName = sslCertificate.getIssuedBy().getUName();
- long startDateLong = sslCertificate.getValidNotBeforeDate().getTime();
- long endDateLong = sslCertificate.getValidNotAfterDate().getTime();
-
- // Add the certificate to the intent.
- domainsIntent.putExtra("ssl_issued_to_cname", issuedToCName);
- domainsIntent.putExtra("ssl_issued_to_oname", issuedToOName);
- domainsIntent.putExtra("ssl_issued_to_uname", issuedToUName);
- domainsIntent.putExtra("ssl_issued_by_cname", issuedByCName);
- domainsIntent.putExtra("ssl_issued_by_oname", issuedByOName);
- domainsIntent.putExtra("ssl_issued_by_uname", issuedByUName);
- domainsIntent.putExtra("ssl_start_date", startDateLong);
- domainsIntent.putExtra("ssl_end_date", endDateLong);
- }
-
- // Check to see if the current IP addresses have been received.
- if (currentWebView.hasCurrentIpAddresses()) {
- // Add the current IP addresses to the intent.
- domainsIntent.putExtra("current_ip_addresses", currentWebView.getCurrentIpAddresses());
- }
-
- // Make it so.
- startActivity(domainsIntent);
- break;
-
- case R.id.settings:
- // Set the flag to reapply app settings on restart when returning from Settings.
- reapplyAppSettingsOnRestart = true;
-
- // Set the flag to reapply the domain settings on restart when returning from Settings.
- reapplyDomainSettingsOnRestart = true;
-
- // Launch the settings activity.
- Intent settingsIntent = new Intent(this, SettingsActivity.class);
- startActivity(settingsIntent);
- break;
-
- case R.id.import_export:
- // Launch the import/export activity.
- Intent importExportIntent = new Intent (this, ImportExportActivity.class);
- startActivity(importExportIntent);
- break;
-
- case R.id.logcat:
- // Launch the logcat activity.
- Intent logcatIntent = new Intent(this, LogcatActivity.class);
- startActivity(logcatIntent);
- break;
-
- case R.id.guide:
- // Launch `GuideActivity`.
- Intent guideIntent = new Intent(this, GuideActivity.class);
- startActivity(guideIntent);
- break;
-
- case R.id.about:
- // Create an intent to launch the about activity.
- Intent aboutIntent = new Intent(this, AboutActivity.class);
-
- // Create a string array for the blocklist versions.
- String[] blocklistVersions = new String[] {easyList.get(0).get(0)[0], easyPrivacy.get(0).get(0)[0], fanboysAnnoyanceList.get(0).get(0)[0], fanboysSocialList.get(0).get(0)[0],
- ultraPrivacy.get(0).get(0)[0]};
-
- // Add the blocklist versions to the intent.
- aboutIntent.putExtra("blocklist_versions", blocklistVersions);
-
- // Make it so.
- startActivity(aboutIntent);
- break;
- }
-
- // Get a handle for the drawer layout.
- DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
-
- // Close the navigation drawer.
- drawerLayout.closeDrawer(GravityCompat.START);
- return true;
- }
-
- @Override
- public void onPostCreate(Bundle savedInstanceState) {
- // Run the default commands.
- super.onPostCreate(savedInstanceState);
-
- // Sync the state of the DrawerToggle after the default `onRestoreInstanceState()` has finished. This creates the navigation drawer icon.
- actionBarDrawerToggle.syncState();
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- // Run the default commands.
- super.onConfigurationChanged(newConfig);
-
- // Get the status bar pixel size.
- int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
- int statusBarPixelSize = getResources().getDimensionPixelSize(statusBarResourceId);
-
- // Get the resource density.
- float screenDensity = getResources().getDisplayMetrics().density;