// `dismissingSnackbar` is public static so it can be accessed from `DomainsListFragment`. It is also used in `onOptionsItemSelected()`.
public static boolean dismissingSnackbar;
+ // The SSL certificate and current IP addresses are used to update pinned settings.
+ public static SslCertificate currentSslCertificate;
+ public static String currentIpAddresses;
+
+
// `closeActivityAfterDismissingSnackbar` is used in `onOptionsItemSelected()`, and `onBackPressed()`.
private boolean closeActivityAfterDismissingSnackbar;
// Extract the values from `savedInstanceState` if it is not `null`.
if (savedInstanceState != null) {
restartAfterRotate = true;
- domainSettingsDisplayedBeforeRotate = savedInstanceState.getBoolean("domainSettingsDisplayed");
- domainSettingsDatabaseIdBeforeRotate = savedInstanceState.getInt("domainSettingsDatabaseId");
+ domainSettingsDisplayedBeforeRotate = savedInstanceState.getBoolean("domain_settings_displayed");
+ domainSettingsDatabaseIdBeforeRotate = savedInstanceState.getInt("domain_settings_database_id");
}
// Get the launching intent
Intent intent = getIntent();
// Extract the domain to load if there is one. `-1` is the default value.
- goDirectlyToDatabaseId = intent.getIntExtra("loadDomain", -1);
+ goDirectlyToDatabaseId = intent.getIntExtra("load_domain", -1);
// Get the status of close-on-back, which is true when the domains activity is called from the options menu.
- closeOnBack = intent.getBooleanExtra("closeOnBack", false);
+ closeOnBack = intent.getBooleanExtra("close_on_back", false);
+
+ // Get the current URL.
+ String currentUrl = intent.getStringExtra("current_url");
// Set the content view.
setContentView(R.layout.domains_coordinatorlayout);
// Determine if we are in two pane mode. `domain_settings_fragment_container` does not exist on devices with a width less than 900dp.
twoPanedMode = (findViewById(R.id.domain_settings_fragment_container) != null);
- // Configure `addDomainFAB`.
+ // Get a handle for the add domain floating action button.
addDomainFAB = findViewById(R.id.add_domain_fab);
+
+ // Configure the add domain floating action button.
addDomainFAB.setOnClickListener((View view) -> {
- // Show the add domain `AlertDialog`.
- DialogFragment addDomainDialog = new AddDomainDialog();
+ // Create an add domain dialog.
+ DialogFragment addDomainDialog = AddDomainDialog.addDomain(currentUrl);
+
+ // Show the add domain dialog.
addDomainDialog.show(getSupportFragmentManager(), resources.getString(R.string.add_domain));
});
}
// Show `deleteMenuItem`.
deleteMenuItem.setVisible(true);
- // Hide `add_domain_fab`.
+ // Hide the add domain floating action button.
addDomainFAB.hide();
// Display `domainSettingsFragment`.
// Show `deleteMenuItem`.
deleteMenuItem.setVisible(true);
- // Hide `add_domain_fab`.
+ // Hide the add domain floating action button.
addDomainFAB.hide();
// Display `domainSettingsFragment`.
// Populate the list of domains. `-1` highlights the first domain if in two-paned mode. It has no effect in single-paned mode.
populateDomainsListView(-1);
- // Show the add domain FAB.
+ // Show the add domain floating action button.
addDomainFAB.show();
// Hide the delete menu item.
fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
fragmentManager.executePendingTransactions();
- // Show the add domain FAB.
+ // Show the add domain floating action button.
addDomainFAB.show();
// Hide `deleteMenuItem`.
// Display `domainSettingsFragment`.
fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
- // Hide the add domain FAB.
+ // Hide the add domain floating action button.
addDomainFAB.hide();
// Show and enable `deleteMenuItem`.
saveDomainSettings(coordinatorLayout, resources);
// Store `DomainSettingsDisplayed`.
- outState.putBoolean("domainSettingsDisplayed", true);
- outState.putInt("domainSettingsDatabaseId", DomainSettingsFragment.databaseId);
+ outState.putBoolean("domain_settings_displayed", true);
+ outState.putInt("domain_settings_database_id", DomainSettingsFragment.databaseId);
} else { // `DomainSettingsFragment` is not displayed.
- outState.putBoolean("domainSettingsDisplayed", false);
- outState.putInt("domainSettingsDatabaseId", -1);
+ outState.putBoolean("domain_settings_displayed", false);
+ outState.putInt("domain_settings_database_id", -1);
}
super.onSaveInstanceState(outState);
// Populate the list of domains. `-1` highlights the first domain if in two-paned mode. It has no effect in single-paned mode.
populateDomainsListView(-1);
- // Show the add domain FAB.
+ // Show the add domain floating action button.
addDomainFAB.show();
// Hide the delete menu item.
if (twoPanedMode) { // The device in in two-paned mode.
populateDomainsListView(currentDomainDatabaseId);
} else { // The device is in single-paned mode.
- // Hide the add domain FAB.
+ // Hide the add domain floating action button.
addDomainFAB.hide();
// Show and enable `deleteMenuItem`.
// Update the pinned SSL certificate if a new one is checked.
if (currentWebsiteCertificateRadioButton.isChecked()) {
- // Get the current website SSL certificate.
- SslCertificate currentWebsiteSslCertificate = MainWebViewActivity.sslCertificate;
-
// Store the values from the SSL certificate.
- String issuedToCommonName = currentWebsiteSslCertificate.getIssuedTo().getCName();
- String issuedToOrganization = currentWebsiteSslCertificate.getIssuedTo().getOName();
- String issuedToOrganizationalUnit = currentWebsiteSslCertificate.getIssuedTo().getUName();
- String issuedByCommonName = currentWebsiteSslCertificate.getIssuedBy().getCName();
- String issuedByOrganization = currentWebsiteSslCertificate.getIssuedBy().getOName();
- String issuedByOrganizationalUnit = currentWebsiteSslCertificate.getIssuedBy().getUName();
- long startDateLong = currentWebsiteSslCertificate.getValidNotBeforeDate().getTime();
- long endDateLong = currentWebsiteSslCertificate.getValidNotAfterDate().getTime();
+ String issuedToCommonName = currentSslCertificate.getIssuedTo().getCName();
+ String issuedToOrganization = currentSslCertificate.getIssuedTo().getOName();
+ String issuedToOrganizationalUnit = currentSslCertificate.getIssuedTo().getUName();
+ String issuedByCommonName = currentSslCertificate.getIssuedBy().getCName();
+ String issuedByOrganization = currentSslCertificate.getIssuedBy().getOName();
+ String issuedByOrganizationalUnit = currentSslCertificate.getIssuedBy().getUName();
+ long startDateLong = currentSslCertificate.getValidNotBeforeDate().getTime();
+ long endDateLong = currentSslCertificate.getValidNotAfterDate().getTime();
// Update the database.
domainsDatabaseHelper.updatePinnedSslCertificate(currentDomainDatabaseId, issuedToCommonName, issuedToOrganization, issuedToOrganizationalUnit, issuedByCommonName, issuedByOrganization,