X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FBookmarksActivity.java;h=4d752d126f7af645482e53f250b4d47de093f52e;hp=d48fe2b32aac1f2964ef47f03b20ecf8168bb56d;hb=9db0afa3b1f85a74c6ddf7a7cedd7cb7ddd1035a;hpb=64fe50abeacf25f6fde5d3b3de11801f1618987b diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java index d48fe2b3..4d752d12 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2018 Soren Stoutner . + * Copyright © 2016-2019 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -561,10 +561,10 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma // Close the activity if back has been pressed. if (closeActivityAfterDismissingSnackbar) { - // Update the bookmarks folder for the bookmarks drawer in `MainWebViewActivity`. - MainWebViewActivity.currentBookmarksFolder = ""; + // Update the bookmarks folder for the bookmarks drawer in the main WebView activity. + MainWebViewActivity.currentBookmarksFolder = currentFolder; - // Close the bookmarks drawer and reload the bookmarks `ListView` when returning to `MainWebViewActivity`. + // Close the bookmarks drawer and reload the bookmarks ListView when returning to the main WebView activity. MainWebViewActivity.restartFromBookmarksActivity = true; // Return to `MainWebViewActivity`. @@ -631,7 +631,7 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma @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(); switch (menuItemId) { @@ -684,30 +684,22 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma @Override public void onBackPressed() { - if (currentFolder.isEmpty()) { // Currently in the home folder. - // Go home. - if ((bookmarksDeletedSnackbar != null) && bookmarksDeletedSnackbar.isShown()) { // Close the bookmarks delete snackbar before going home. - // Set the close flag. - closeActivityAfterDismissingSnackbar = true; - - // Dismiss the snackbar. - bookmarksDeletedSnackbar.dismiss(); - } else { // Go home immediately. - // Update the bookmarks folder for the bookmarks drawer in `MainWebViewActivity`. - MainWebViewActivity.currentBookmarksFolder = ""; - - // Close the bookmarks drawer and reload the bookmarks `ListView` when returning to `MainWebViewActivity`. - MainWebViewActivity.restartFromBookmarksActivity = true; - - // Exit `BookmarksActivity`. - super.onBackPressed(); - } - } else { // Currently in a subfolder. - // Place the former parent folder in `currentFolder`. - currentFolder = bookmarksDatabaseHelper.getParentFolder(currentFolder); - - // Load the new folder. - loadFolder(); + // Check to see if a snackbar is currently displayed. If so, it must be closed before exiting so that a pending delete is completed before reloading the ListView in the bookmarks drawer. + if ((bookmarksDeletedSnackbar != null) && bookmarksDeletedSnackbar.isShown()) { // Close the bookmarks delete snackbar before going home. + // Set the close flag. + closeActivityAfterDismissingSnackbar = true; + + // Dismiss the snackbar. + bookmarksDeletedSnackbar.dismiss(); + } else { // Go home immediately. + // Update the bookmarks folder for the bookmarks drawer in the main WebView activity. + MainWebViewActivity.currentBookmarksFolder = currentFolder; + + // Close the bookmarks drawer and reload the bookmarks ListView when returning to the main WebView activity. + MainWebViewActivity.restartFromBookmarksActivity = true; + + // Exit `BookmarksActivity`. + super.onBackPressed(); } }