/*
- * Copyright 2016-2017 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2017 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
// Scroll to where the deleted bookmark was located.
bookmarksListView.setSelection(selectedBookmarkPosition - 5);
+ // Initialize `snackbarMessage`.
String snackbarMessage;
// Determine how many items are in the array and prepare an appropriate Snackbar message.
.addCallback(new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar snackbar, int event) {
- // Android Studio wants to see entries for every possible `Snackbar.Callback` even if they aren't used.
switch (event) {
- // The user pushed the "Undo" button.
+ // The user pushed the `Undo` button.
case Snackbar.Callback.DISMISS_EVENT_ACTION:
// Refresh the ListView to show the rows again.
updateBookmarksListView(currentFolder);
// Scroll to where the deleted bookmark was located.
bookmarksListView.setSelection(selectedBookmarkPosition - 5);
-
break;
- case Snackbar.Callback.DISMISS_EVENT_CONSECUTIVE:
- // Do nothing and let the default behavior run.
-
- case Snackbar.Callback.DISMISS_EVENT_MANUAL:
- // Do nothing and let the default behavior run.
-
- case Snackbar.Callback.DISMISS_EVENT_SWIPE:
- // Do nothing and let the default behavior run.
-
- case Snackbar.Callback.DISMISS_EVENT_TIMEOUT:
- // Do nothing and let the default behavior run.
-
- // The Snackbar was dismissed without the "Undo" button being pushed.
+ // The `Snackbar` was dismissed without the `Undo` button being pushed.
default:
// Delete each selected row.
for (long databaseIdLong : selectedBookmarksLongArray) {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- //Inflate the menu.
+ // Inflate the menu.
getMenuInflater().inflate(R.menu.bookmarks_options_menu, menu);
- return true;
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- super.onPrepareOptionsMenu(menu);
-
+ // Success.
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
+ // Get the ID of the `MenuItem` that was selected.
int menuItemId = menuItem.getItemId();
switch (menuItemId) {
- case android.R.id.home:
+ case android.R.id.home: // The home arrow is identified as `android.R.id.home`, not just `R.id.home`.
if (currentFolder.isEmpty()) { // Exit BookmarksActivity if currently in the home folder.
NavUtils.navigateUpFromSameTask(this);
} else { // Navigate up one folder.
// Place the former parent folder in `currentFolder`.
currentFolder = bookmarksDatabaseHelper.getParentFolder(currentFolder);
- // Exit BookmarksActivity if currently in the home folder.
+ // Update `bookmarksListView`.
updateBookmarksListView(currentFolder);
}
break;
// Convert the favoriteIcon Bitmap to a byte array.
ByteArrayOutputStream favoriteIconByteArrayOutputStream = new ByteArrayOutputStream();
// `0` is for lossless compression (the only option for a PNG).
- MainWebViewActivity.favoriteIcon.compress(Bitmap.CompressFormat.PNG, 0, favoriteIconByteArrayOutputStream);
+ MainWebViewActivity.favoriteIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, favoriteIconByteArrayOutputStream);
byte[] favoriteIconByteArray = favoriteIconByteArrayOutputStream.toByteArray();
// Display the new bookmark below the current items in the (0 indexed) list.
BitmapDrawable folderIconBitmapDrawable = (BitmapDrawable) folderIconDrawable;
folderIconBitmap = folderIconBitmapDrawable.getBitmap();
} else { // Assign `favoriteIcon` from the `WebView`.
- folderIconBitmap = MainWebViewActivity.favoriteIcon;
+ folderIconBitmap = MainWebViewActivity.favoriteIconBitmap;
}
// Convert `folderIconBitmap` to a byte array. `0` is for lossless compression (the only option for a PNG).
bookmarksDatabaseHelper.updateBookmark(selectedBookmarkDatabaseId, bookmarkNameString, bookmarkUrlString);
} else { // Update the bookmark using the `WebView` favorite icon.
ByteArrayOutputStream newFavoriteIconByteArrayOutputStream = new ByteArrayOutputStream();
- MainWebViewActivity.favoriteIcon.compress(Bitmap.CompressFormat.PNG, 0, newFavoriteIconByteArrayOutputStream);
+ MainWebViewActivity.favoriteIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, newFavoriteIconByteArrayOutputStream);
byte[] newFavoriteIconByteArray = newFavoriteIconByteArrayOutputStream.toByteArray();
// Update the bookmark and the favorite icon.
BitmapDrawable folderIconBitmapDrawable = (BitmapDrawable) folderIconDrawable;
folderIconBitmap = folderIconBitmapDrawable.getBitmap();
} else { // Get the web page icon `ImageView` from the `Dialog`.
- folderIconBitmap = MainWebViewActivity.favoriteIcon;
+ folderIconBitmap = MainWebViewActivity.favoriteIconBitmap;
}
// Convert the folder `Bitmap` to a byte array. `0` is for lossless compression (the only option for a PNG).