// Close the current tab.
closeCurrentTab();
} else { // There isn't anything to do in Privacy Browser.
- // Close Privacy Browser. `finishAndRemoveTask()` also removes Privacy Browser from the recent app list.
- finishAndRemoveTask();
-
- // Manually kill Privacy Browser. Otherwise, it is glitchy when restarted.
- System.exit(0);
+ // Run clear and exit.
+ clearAndExit();
}
}
};
// Check to see if the bookmark is a folder.
if (isFolder) { // The bookmark is a folder.
- // Save the current folder name, which is used in `onSaveEditBookmarkFolder()`.
- oldFolderNameString = bookmarksCursor.getString(bookmarksCursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.BOOKMARK_NAME));
+ // Get a cursor of all the bookmarks in the folder.
+ Cursor bookmarksCursor = bookmarksDatabaseHelper.getFolderBookmarks(databaseId);
+
+ // Move to the first entry in the cursor.
+ bookmarksCursor.moveToFirst();
+
+ // Open each bookmark
+ for (int i = 0; i < bookmarksCursor.getCount(); i++) {
+ // Load the bookmark in a new tab, moving to the tab for the first bookmark (i == 0).
+ addNewTab(bookmarksCursor.getString(bookmarksCursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.BOOKMARK_URL)), (i == 0));
- // Instantiate the edit folder bookmark dialog.
- DialogFragment editBookmarkFolderDialog = EditBookmarkFolderDialog.folderDatabaseId(databaseId, currentWebView.getFavoriteOrDefaultIcon());
+ // Move to the next bookmark.
+ bookmarksCursor.moveToNext();
+ }
+
+ // Close the cursor.
+ bookmarksCursor.close();
- // Show the edit folder bookmark dialog.
- editBookmarkFolderDialog.show(getSupportFragmentManager(), getString(R.string.edit_folder));
+ // Close the bookmarks drawer.
+ drawerLayout.closeDrawer(GravityCompat.END);
} else { // The bookmark is not a folder.
// Get the bookmark cursor for this ID.
Cursor bookmarkCursor = bookmarksDatabaseHelper.getBookmark(databaseId);
// Load the bookmark in a new tab.
addNewTab(bookmarkCursor.getString(bookmarkCursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.BOOKMARK_URL)), true);
+ // Close the cursor.
+ bookmarkCursor.close();
+
// Close the bookmarks drawer.
drawerLayout.closeDrawer(GravityCompat.END);
}
// Update the swipe refresh layout.
if (defaultSwipeToRefresh) { // Swipe to refresh is enabled.
- // Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
- swipeRefreshLayout.setEnabled(currentWebView.getScrollY() == 0);
+ // Update the status of the swipe refresh layout if the current WebView is not null (crash reports indicate that in some unexpected way it sometimes is null).
+ if (currentWebView != null) {
+ // Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
+ swipeRefreshLayout.setEnabled(currentWebView.getScrollY() == 0);
+ }
} else { // Swipe to refresh is disabled.
// Disable the swipe refresh layout.
swipeRefreshLayout.setEnabled(false);
// Store the swipe to refresh status in the nested scroll WebView.
nestedScrollWebView.setSwipeToRefresh(true);
- // Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
- swipeRefreshLayout.setEnabled(currentWebView.getScrollY() == 0);
+
+ // Update the status of the swipe refresh layout if the current WebView is not null (crash reports indicate that in some unexpected way it sometimes is null).
+ if (currentWebView != null) {
+ // Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
+ swipeRefreshLayout.setEnabled(currentWebView.getScrollY() == 0);
+ }
break;
case DomainsDatabaseHelper.DISABLED:
// Update the swipe refresh layout.
if (defaultSwipeToRefresh) { // Swipe to refresh is enabled.
- // Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
- swipeRefreshLayout.setEnabled(currentWebView.getScrollY() == 0);
+ // Update the status of the swipe refresh layout if the current WebView is not null (crash reports indicate that in some unexpected way it sometimes is null).
+ if (currentWebView != null) {
+ // Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
+ swipeRefreshLayout.setEnabled(currentWebView.getScrollY() == 0);
+ }
} else { // Swipe to refresh is disabled.
// Disable the swipe refresh layout.
swipeRefreshLayout.setEnabled(false);