From: Soren Stoutner Date: Thu, 22 Apr 2021 23:02:28 +0000 (-0700) Subject: Display a snackbar when opening a bookmark in a background tab. https://redmine.stout... X-Git-Tag: v3.8~9 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=bc976a00a37730c5bb863eed888b88043769ddaa;p=PrivacyBrowserAndroid.git Display a snackbar when opening a bookmark in a background tab. https://redmine.stoutner.com/issues/644 --- diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index bc31f566..a321b6c8 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -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); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3f5aff2b..2728f652 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -234,6 +234,7 @@ Bookmarks Database View + The bookmark was opened in a background tab. Create Bookmark Create Folder Current bookmark icon