]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Add opening bookmarks in new tab. https://redmine.stoutner.com/issues/469
authorSoren Stoutner <soren@stoutner.com>
Wed, 23 Oct 2019 23:22:29 +0000 (16:22 -0700)
committerSoren Stoutner <soren@stoutner.com>
Wed, 23 Oct 2019 23:22:29 +0000 (16:22 -0700)
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java

index 96380b3d9b90ed7724d73ef47caae82a49858782..f4c51bb6acabaf071e363f34658b6058866cc152 100644 (file)
@@ -3627,10 +3627,12 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
         bookmarksListView.setOnItemClickListener((parent, view, position, id) -> {
             // Convert the id from long to int to match the format of the bookmarks database.
-            int databaseID = (int) id;
+            int databaseId = (int) id;
+
+            // Get the bookmark cursor for this ID.
+            Cursor bookmarkCursor = bookmarksDatabaseHelper.getBookmark(databaseId);
 
-            // Get the bookmark cursor for this ID and move it to the first row.
-            Cursor bookmarkCursor = bookmarksDatabaseHelper.getBookmark(databaseID);
+            // Move the bookmark cursor to the first row.
             bookmarkCursor.moveToFirst();
 
             // Act upon the bookmark according to the type.
@@ -3663,13 +3665,20 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 // Save the current folder name, which is used in `onSaveEditBookmarkFolder()`.
                 oldFolderNameString = bookmarksCursor.getString(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME));
 
-                // Show the edit bookmark folder `AlertDialog` and name the instance `@string/edit_folder`.
+                // Instantiate the edit folder bookmark dialog.
                 DialogFragment editBookmarkFolderDialog = EditBookmarkFolderDialog.folderDatabaseId(databaseId, currentWebView.getFavoriteOrDefaultIcon());
+
+                // Show the edit folder bookmark dialog.
                 editBookmarkFolderDialog.show(getSupportFragmentManager(), getString(R.string.edit_folder));
             } else {
-                // Show the edit bookmark `AlertDialog` and name the instance `@string/edit_bookmark`.
-                DialogFragment editBookmarkDialog = EditBookmarkDialog.bookmarkDatabaseId(databaseId, currentWebView.getFavoriteOrDefaultIcon());
-                editBookmarkDialog.show(getSupportFragmentManager(), getString(R.string.edit_bookmark));
+                // Get the bookmark cursor for this ID.
+                Cursor bookmarkCursor = bookmarksDatabaseHelper.getBookmark(databaseId);
+
+                // Move the bookmark cursor to the first row.
+                bookmarkCursor.moveToFirst();
+
+                // Load the bookmark in a new tab but do not switch to the tab or close the drawer.
+                addNewTab(bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_URL)), false);
             }
 
             // Consume the event.