package com.stoutner.privacybrowser.activities;
+import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.http.SslCertificate;
import android.os.Bundle;
import android.os.Handler;
-import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.Snackbar;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.NavUtils;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-// `AppCompatDialogFragment` is required instead of `DialogFragment` or an error is produced on API <=22.
-import android.support.v7.app.AppCompatDialogFragment;
-import android.support.v7.widget.Toolbar;
+import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Switch;
import android.widget.TextView;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar; // The AndroidX toolbar must be used until the minimum API is >= 21.
+import androidx.core.app.NavUtils;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.FragmentManager; // The AndroidX dialog fragment must be used or an error is produced on API <=22.
+
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.snackbar.Snackbar;
+
import com.stoutner.privacybrowser.R;
import com.stoutner.privacybrowser.dialogs.AddDomainDialog;
import com.stoutner.privacybrowser.fragments.DomainSettingsFragment;
import java.util.Objects;
-public class DomainsActivity extends AppCompatActivity implements AddDomainDialog.AddDomainListener {
+public class DomainsActivity extends AppCompatActivity implements AddDomainDialog.AddDomainListener, DomainsListFragment.DismissSnackbarInterface {
// `twoPanedMode` is public static so it can be accessed from `DomainsListFragment`. It is also used in `onCreate()`, `onCreateOptionsMenu()`, and `populateDomainsListView()`.
public static boolean twoPanedMode;
// `deleteMenuItem` is public static so it can be accessed from `DomainsListFragment`. It is also used in `onCreateOptionsMenu()`, `onOptionsItemSelected()`, and `onBackPressed()`.
public static MenuItem deleteMenuItem;
- // `undoDeleteSnackbar` is public static so it can be accessed from `DomainsListFragment`. It is also used in `onOptionsItemSelected()` and `onBackPressed()`.
- public static Snackbar undoDeleteSnackbar;
-
// `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;
- // `context` is used in `onCreate()`, `onOptionsItemSelected()`, and `onAddDomain()`.
- private Context context;
-
- // `supportFragmentManager` is used in `onCreate()` and `onCreateOptionsMenu()`.
- private FragmentManager supportFragmentManager;
+ // The undelete snackbar is used in `onOptionsItemSelected()` and `onBackPressed()`.
+ private Snackbar undoDeleteSnackbar;
// `domainsDatabaseHelper` is used in `onCreate()`, `saveDomainSettings()`, and `onDestroy()`.
private static DomainsDatabaseHelper domainsDatabaseHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
+ // Get a handle for the shared preferences.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+
+ // Get the theme and screenshot preferences.
+ boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+ boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
// Disable screenshots if not allowed.
- if (!MainWebViewActivity.allowScreenshots) {
+ if (!allowScreenshots) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
// Set the activity theme.
- if (MainWebViewActivity.darkTheme) {
+ if (darkTheme) {
setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
} else {
setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
// 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);
// Populate the class variables.
coordinatorLayout = findViewById(R.id.domains_coordinatorlayout);
resources = getResources();
- context = this;
- supportFragmentManager = getSupportFragmentManager();
// `SupportActionBar` from `android.support.v7.app.ActionBar` must be used until the minimum API is >= 21.
- final Toolbar domainsAppBar = findViewById(R.id.domains_toolbar);
- setSupportActionBar(domainsAppBar);
+ final Toolbar toolbar = findViewById(R.id.domains_toolbar);
+ setSupportActionBar(toolbar);
+
+ // Get a handle for the action bar.
+ ActionBar actionBar = getSupportActionBar();
- // Display the home arrow on the support action bar.
- ActionBar appBar = getSupportActionBar();
- assert appBar != null;// This assert removes the incorrect warning in Android Studio on the following line that `appBar` might be null.
- appBar.setDisplayHomeAsUpEnabled(true);
+ // Remove the incorrect lint warning that the action bar might be null.
+ assert actionBar != null;
+
+ // Set the back arrow on the action bar.
+ actionBar.setDisplayHomeAsUpEnabled(true);
// Initialize the database handler. The `0` specifies the database version, but that is ignored and set instead using a constant in `DomainsDatabaseHelper`.
- domainsDatabaseHelper = new DomainsDatabaseHelper(context, null, null, 0);
+ domainsDatabaseHelper = new DomainsDatabaseHelper(this, null, null, 0);
// 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`.
- AppCompatDialogFragment addDomainDialog = new AddDomainDialog();
- addDomainDialog.show(supportFragmentManager, resources.getString(R.string.add_domain));
+ // Create an add domain dialog.
+ DialogFragment addDomainDialog = AddDomainDialog.addDomain(currentUrl);
+
+ // Show the add domain dialog.
+ addDomainDialog.show(getSupportFragmentManager(), resources.getString(R.string.add_domain));
});
}
// Only display `deleteMenuItem` (initially) in two-paned mode.
deleteMenuItem.setVisible(twoPanedMode);
+ // Get a handle for the fragment manager.
+ FragmentManager fragmentManager = getSupportFragmentManager();
+
// Display the fragments. This must be done from `onCreateOptionsMenu()` instead of `onCreate()` because `populateDomainsListView()` needs `deleteMenuItem` to be inflated.
if (restartAfterRotate && domainSettingsDisplayedBeforeRotate) { // The device was rotated and domain settings were displayed previously.
if (twoPanedMode) { // The device is in two-paned mode.
// Display `DomainsListFragment`.
DomainsListFragment domainsListFragment = new DomainsListFragment();
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
- supportFragmentManager.executePendingTransactions();
+ fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
+ fragmentManager.executePendingTransactions();
// Populate the list of domains. `domainSettingsDatabaseId` highlights the domain that was highlighted before the rotation.
populateDomainsListView(domainSettingsDatabaseIdBeforeRotate);
// Show `deleteMenuItem`.
deleteMenuItem.setVisible(true);
- // Hide `add_domain_fab`.
+ // Hide the add domain floating action button.
addDomainFAB.hide();
// Display `domainSettingsFragment`.
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
+ fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
}
} else { // The device was not rotated or, if it was, domain settings were not displayed previously.
if (goDirectlyToDatabaseId >=0) { // Load the indicated domain settings.
if (twoPanedMode) { // The device is in two-paned mode.
// Display `DomainsListFragment`.
DomainsListFragment domainsListFragment = new DomainsListFragment();
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
- supportFragmentManager.executePendingTransactions();
+ fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
+ fragmentManager.executePendingTransactions();
// Populate the list of domains. `domainSettingsDatabaseId` highlights the domain that was highlighted before the rotation.
populateDomainsListView(goDirectlyToDatabaseId);
// Show `deleteMenuItem`.
deleteMenuItem.setVisible(true);
- // Hide `add_domain_fab`.
+ // Hide the add domain floating action button.
addDomainFAB.hide();
// Display `domainSettingsFragment`.
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
+ fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
}
} else { // Highlight the first domain.
// Display `DomainsListFragment`.
DomainsListFragment domainsListFragment = new DomainsListFragment();
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
- supportFragmentManager.executePendingTransactions();
+ fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
+ fragmentManager.executePendingTransactions();
// Populate the list of domains. `-1` highlights the first domain.
populateDomainsListView(-1);
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
- // Get the ID of the `MenuItem` that was selected.
+ // Get the ID of the menu item that was selected.
int menuItemID = menuItem.getItemId();
+ // Get a handle for the fragment manager.
+ FragmentManager fragmentManager = getSupportFragmentManager();
+
switch (menuItemID) {
case android.R.id.home: // The home arrow is identified as `android.R.id.home`, not just `R.id.home`.
if (twoPanedMode) { // The device is in two-paned mode.
// Display the domains list fragment.
DomainsListFragment domainsListFragment = new DomainsListFragment();
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
- supportFragmentManager.executePendingTransactions();
+ fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
+ fragmentManager.executePendingTransactions();
// 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.
deleteMenuItem.setIcon(R.drawable.delete_blue);
// Remove the domain settings fragment.
- supportFragmentManager.beginTransaction().remove(Objects.requireNonNull(supportFragmentManager.findFragmentById(R.id.domain_settings_fragment_container))).commit();
+ fragmentManager.beginTransaction().remove(Objects.requireNonNull(fragmentManager.findFragmentById(R.id.domain_settings_fragment_container))).commit();
} else { // Single-paned mode.
// Display `DomainsListFragment`.
DomainsListFragment domainsListFragment = new DomainsListFragment();
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
- supportFragmentManager.executePendingTransactions();
+ 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`.
// Do nothing because everything will be handled by `onDismissed()` below.
})
.addCallback(new Snackbar.Callback() {
+ @SuppressLint("SwitchIntDef") // Ignore the lint warning about not handling the other possible events as they are covered by `default:`.
@Override
public void onDismissed(Snackbar snackbar, int event) {
switch (event) {
Cursor undoDeleteDomainsCursor = domainsDatabaseHelper.getDomainNameCursorOrderedByDomain();
// Setup `domainsCursorAdapter` with `this` context. `false` disables `autoRequery`.
- CursorAdapter undoDeleteDomainsCursorAdapter = new CursorAdapter(context, undoDeleteDomainsCursor, false) {
+ CursorAdapter undoDeleteDomainsCursorAdapter = new CursorAdapter(getApplicationContext(), undoDeleteDomainsCursor, false) {
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// Inflate the individual item layout. `false` does not attach it to the root.
domainsListView.setItemChecked(deletedDomainPosition, true);
// Display `domainSettingsFragment`.
- supportFragmentManager.beginTransaction().replace(R.id.domain_settings_fragment_container, domainSettingsFragment).commit();
+ fragmentManager.beginTransaction().replace(R.id.domain_settings_fragment_container, domainSettingsFragment).commit();
// Enable the options `MenuItems`.
deleteMenuItem.setEnabled(true);
deleteMenuItem.setIcon(R.drawable.delete_light);
} else { // The device in in one-paned mode.
// Display `domainSettingsFragment`.
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
+ 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`.
deleteMenuItem.setVisible(true);
// Display `domainSettingsFragment`.
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
+ fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
}
break;
Runnable enableDeleteMenuItemRunnable = () -> {
// Enable `deleteMenuItem` according to the display mode.
if (twoPanedMode) { // Two-paned mode.
- // Enable `deleteMenuItem`.
+ // Enable the delete menu item.
deleteMenuItem.setEnabled(true);
+ // Get a handle for the shared preferences.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+
+ // Get the theme preferences.
+ boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+
// Set the delete icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
+ if (darkTheme) {
deleteMenuItem.setIcon(R.drawable.delete_dark);
} else {
deleteMenuItem.setIcon(R.drawable.delete_light);
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);
// Control what the navigation bar back button does.
@Override
public void onBackPressed() {
+ // Get a handle for the fragment manager.
+ FragmentManager fragmentManager = getSupportFragmentManager();
+
if (twoPanedMode) { // The device is in two-paned mode.
// Save the current domain settings if the domain settings fragment is displayed.
if (findViewById(R.id.domain_settings_scrollview) != null) {
// Display the domains list fragment.
DomainsListFragment domainsListFragment = new DomainsListFragment();
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
- supportFragmentManager.executePendingTransactions();
+ fragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainsListFragment).commit();
+ fragmentManager.executePendingTransactions();
// 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.
}
@Override
- public void onAddDomain(AppCompatDialogFragment dialogFragment) {
+ public void onAddDomain(DialogFragment dialogFragment) {
// Dismiss the undo delete snackbar if it is currently displayed.
if ((undoDeleteSnackbar != null) && undoDeleteSnackbar.isShown()) {
undoDeleteSnackbar.dismiss();
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`.
DomainsActivity.deleteMenuItem.setVisible(true);
- // Add `currentDomainDatabaseId` to `argumentsBundle`.
+ // Add the current domain database ID to the arguments bundle.
Bundle argumentsBundle = new Bundle();
argumentsBundle.putInt(DomainSettingsFragment.DATABASE_ID, currentDomainDatabaseId);
- // Add `argumentsBundle` to `domainSettingsFragment`.
+ // Add and arguments bundle to the domain setting fragment.
DomainSettingsFragment domainSettingsFragment = new DomainSettingsFragment();
domainSettingsFragment.setArguments(argumentsBundle);
- // Display `domainSettingsFragment`.
- supportFragmentManager.beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
+ // Display the domain settings fragment.
+ getSupportFragmentManager().beginTransaction().replace(R.id.domains_listview_fragment_container, domainSettingsFragment).commit();
}
}
// 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,
Cursor domainsCursor = domainsDatabaseHelper.getDomainNameCursorOrderedByDomain();
// Setup `domainsCursorAdapter` with `this` context. `false` disables `autoRequery`.
- CursorAdapter domainsCursorAdapter = new CursorAdapter(context, domainsCursor, false) {
+ CursorAdapter domainsCursorAdapter = new CursorAdapter(getApplicationContext(), domainsCursor, false) {
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// Inflate the individual item layout. `false` does not attach it to the root.
// Select the highlighted domain.
domainsListView.setItemChecked(highlightedDomainPosition, true);
- // Get the `databaseId` for the highlighted domain.
+ // Get the database ID for the highlighted domain.
domainsCursor.moveToPosition(highlightedDomainPosition);
currentDomainDatabaseId = domainsCursor.getInt(domainsCursor.getColumnIndex(DomainsDatabaseHelper._ID));
- // Store `databaseId` in `argumentsBundle`.
+ // Store the database ID in the arguments bundle.
Bundle argumentsBundle = new Bundle();
argumentsBundle.putInt(DomainSettingsFragment.DATABASE_ID, currentDomainDatabaseId);
- // Add `argumentsBundle` to `domainSettingsFragment`.
+ // Add and arguments bundle to the domain settings fragment.
DomainSettingsFragment domainSettingsFragment = new DomainSettingsFragment();
domainSettingsFragment.setArguments(argumentsBundle);
- // Display `domainSettingsFragment`.
- supportFragmentManager.beginTransaction().replace(R.id.domain_settings_fragment_container, domainSettingsFragment).commit();
+ // Display the domain settings fragment.
+ getSupportFragmentManager().beginTransaction().replace(R.id.domain_settings_fragment_container, domainSettingsFragment).commit();
- // Enable the options `MenuItems`.
+ // Enable the delete options menu items.
deleteMenuItem.setEnabled(true);
+ // Get a handle for the shared preferences.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+
+ // Get the theme and screenshot preferences.
+ boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+
// Set the delete icon according to the theme.
- if (MainWebViewActivity.darkTheme) {
+ if (darkTheme) {
deleteMenuItem.setIcon(R.drawable.delete_dark);
} else {
deleteMenuItem.setIcon(R.drawable.delete_light);
}
}
+ @Override
+ public void dismissSnackbar() {
+ // Dismiss the undo delete snackbar if it is shown.
+ if (undoDeleteSnackbar != null && undoDeleteSnackbar.isShown()) {
+ // Dismiss the snackbar.
+ undoDeleteSnackbar.dismiss();
+ }
+ }
+
@Override
public void onDestroy() {
// Close the domains database helper.