]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksActivity.java
Remove AsyncTask from SSLCertificateErrorDialog. https://redmine.stoutner.com/issues/987
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / BookmarksActivity.java
index d7137e2041689c10a62fdbe75f3d6ff04a4390e3..8c14b0ef3fea8db6387d85bcdb2b9c2f389aa359 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2016-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
  *
@@ -31,7 +31,6 @@ import android.graphics.Typeface;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
-import android.preference.PreferenceManager;
 import android.util.SparseBooleanArray;
 import android.view.ActionMode;
 import android.view.Menu;
@@ -54,16 +53,17 @@ import androidx.appcompat.app.ActionBar;
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.appcompat.widget.Toolbar;
 import androidx.fragment.app.DialogFragment;
+import androidx.preference.PreferenceManager;
 
 import com.google.android.material.floatingactionbutton.FloatingActionButton;
 import com.google.android.material.snackbar.Snackbar;
 
+import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.dialogs.CreateBookmarkDialog;
 import com.stoutner.privacybrowser.dialogs.CreateBookmarkFolderDialog;
 import com.stoutner.privacybrowser.dialogs.EditBookmarkDialog;
 import com.stoutner.privacybrowser.dialogs.EditBookmarkFolderDialog;
 import com.stoutner.privacybrowser.dialogs.MoveToFolderDialog;
-import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.helpers.BookmarksDatabaseHelper;
 
 import java.io.ByteArrayOutputStream;
@@ -287,7 +287,7 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                     // Adjust the ActionMode and the menu according to the number of selected bookmarks.
                     if (numberOfSelectedBookmarks == 1) {  // One bookmark is selected.
                         // List the number of selected bookmarks in the subtitle.
-                        mode.setSubtitle(getString(R.string.selected) + "  1");
+                        mode.setSubtitle(getString(R.string.selected) + "1");
 
                         // Show the `Move Up`, `Move Down`, and  `Edit` options.
                         moveBookmarkUpMenuItem.setVisible(true);
@@ -298,7 +298,7 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                         updateMoveIcons();
                     } else {  // More than one bookmark is selected.
                         // List the number of selected bookmarks in the subtitle.
-                        mode.setSubtitle(getString(R.string.selected) + "  " + numberOfSelectedBookmarks);
+                        mode.setSubtitle(getString(R.string.selected) + numberOfSelectedBookmarks);
 
                         // Hide non-applicable `MenuItems`.
                         moveBookmarkUpMenuItem.setVisible(false);
@@ -504,7 +504,7 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                     bookmarksCursorAdapter.changeCursor(bookmarksCursor);
 
                     // Create a Snackbar with the number of deleted bookmarks.
-                    bookmarksDeletedSnackbar = Snackbar.make(findViewById(R.id.bookmarks_coordinatorlayout), getString(R.string.bookmarks_deleted) + "  " + numberOfBookmarksToDelete,
+                    bookmarksDeletedSnackbar = Snackbar.make(findViewById(R.id.bookmarks_coordinatorlayout), getString(R.string.bookmarks_deleted) + numberOfBookmarksToDelete,
                             Snackbar.LENGTH_LONG)
                             .setAction(R.string.undo, view -> {
                                 // Do nothing because everything will be handled by `onDismissed()` below.
@@ -625,12 +625,9 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                 // Get the checked bookmarks array list.
                 ArrayList<Integer> checkedBookmarksArrayList = savedInstanceState.getIntegerArrayList(CHECKED_BOOKMARKS_ARRAY_LIST);
 
-                // Check each previously checked bookmark in the list view.  When the minimum API >= 24 a `forEach()` command can be used instead.
-                if (checkedBookmarksArrayList != null) {
-                    for (int i = 0; i < checkedBookmarksArrayList.size(); i++) {
-                        bookmarksListView.setItemChecked(checkedBookmarksArrayList.get(i), true);
-                    }
-                }
+                // Check each previously checked bookmark in the list view.
+                if (checkedBookmarksArrayList != null)
+                    checkedBookmarksArrayList.forEach((position) -> bookmarksListView.setItemChecked(position, true));
             });
         }