]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Display a snackbar when opening a bookmark in a background tab. https://redmine.stout...
authorSoren Stoutner <soren@stoutner.com>
Thu, 22 Apr 2021 23:02:28 +0000 (16:02 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 22 Apr 2021 23:02:28 +0000 (16:02 -0700)
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/res/values/strings.xml

index bc31f56681583e564d004cd7233f65c40773ea19..a321b6c8b1e1c813f4d89714840026ac100eb6a2 100644 (file)
@@ -3450,7 +3450,8 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             // Find out if the selected bookmark is a folder.
             boolean isFolder = bookmarksDatabaseHelper.isFolder(databaseId);
 
-            if (isFolder) {
+            // 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.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME));
 
@@ -3459,7 +3460,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
                 // Show the edit folder bookmark dialog.
                 editBookmarkFolderDialog.show(getSupportFragmentManager(), getString(R.string.edit_folder));
-            } else {
+            } else {  // The bookmark is not a folder.
                 // Get the bookmark cursor for this ID.
                 Cursor bookmarkCursor = bookmarksDatabaseHelper.getBookmark(databaseId);
 
@@ -3468,6 +3469,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
                 // 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);
+
+                // Display a snackbar.
+                Snackbar.make(currentWebView, R.string.bookmark_opened_in_background, Snackbar.LENGTH_SHORT).show();
             }
 
             // Consume the event.
@@ -4445,11 +4449,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         // Update the bookmarks cursor with the contents of the bookmarks database for the current folder.
         bookmarksCursor = bookmarksDatabaseHelper.getBookmarksByDisplayOrder(currentBookmarksFolder);
 
-        // Populate the bookmarks cursor adapter.  `this` specifies the `Context`.  `false` disables `autoRequery`.
+        // Populate the bookmarks cursor adapter.
         bookmarksCursorAdapter = new CursorAdapter(this, bookmarksCursor, false) {
             @Override
             public View newView(Context context, Cursor cursor, ViewGroup parent) {
-                // Inflate the individual item layout.  `false` does not attach it to the root.
+                // Inflate the individual item layout.
                 return getLayoutInflater().inflate(R.layout.bookmarks_drawer_item_linearlayout, parent, false);
             }
 
index 3f5aff2bc638ecf39f564d272b20d777e5da36c5..2728f65276e5b9cc5bebcd1e23752d930f23e829 100644 (file)
     <!-- Bookmarks. -->
     <string name="bookmarks">Bookmarks</string>
     <string name="database_view">Database View</string>
+    <string name="bookmark_opened_in_background">The bookmark was opened in a background tab.</string>
     <string name="create_bookmark">Create Bookmark</string>
     <string name="create_folder">Create Folder</string>
     <string name="current_bookmark_icon">Current bookmark icon</string>